[{"data":1,"prerenderedAt":549},["ShallowReactive",2],{"navigation":3,"/api/use-rapier":72,"/api/use-rapier-surround":546},[4,22],{"title":5,"path":6,"stem":7,"children":8},"Getting Started","/getting-started","1.getting-started/1.index",[9,10,14,18],{"title":5,"path":6,"stem":7},{"title":11,"path":12,"stem":13},"Installation Guide","/getting-started/installation","1.getting-started/2.installation",{"title":15,"path":16,"stem":17},"Usage","/getting-started/usage","1.getting-started/3.usage",{"title":19,"path":20,"stem":21},"How it works","/getting-started/how-it-works","1.getting-started/how-it-works",{"title":23,"path":24,"stem":25,"children":26},"Api","/api","2.api",[27,30,64,68],{"title":28,"path":24,"stem":29},"Physics","2.api/index",{"title":31,"path":32,"stem":33,"children":34},"Rigid body","/api/rigid-body","2.api/1.rigid-body/index",[35,36,40,44,48,52,56,60],{"title":31,"path":32,"stem":33},{"title":37,"path":38,"stem":39},"Automatic colliders","/api/rigid-body/automatic-colliders","2.api/1.rigid-body/1.automatic-colliders",{"title":41,"path":42,"stem":43},"Custom colliders","/api/rigid-body/custom-colliders","2.api/1.rigid-body/2.custom-colliders",{"title":45,"path":46,"stem":47},"Forces","/api/rigid-body/forces","2.api/1.rigid-body/3.forces",{"title":49,"path":50,"stem":51},"Collisions","/api/rigid-body/collisions","2.api/1.rigid-body/4.collisions",{"title":53,"path":54,"stem":55},"Sensor","/api/rigid-body/sensor","2.api/1.rigid-body/5.sensor",{"title":57,"path":58,"stem":59},"Contact force","/api/rigid-body/contact-force","2.api/1.rigid-body/6.contact-force",{"title":61,"path":62,"stem":63},"Instance rigid body","/api/rigid-body/instance-rigid-body","2.api/1.rigid-body/7.instance-rigid-body",{"title":65,"path":66,"stem":67},"Joints","/api/joint","2.api/2.joint",{"title":69,"path":70,"stem":71},"UseRapier","/api/use-rapier","2.api/3.use-rapier",{"id":73,"title":69,"body":74,"description":540,"extension":541,"links":542,"meta":543,"navigation":254,"path":70,"seo":544,"stem":71,"__hash__":545},"docs/2.api/3.use-rapier.md",{"type":75,"value":76,"toc":536},"minimark",[77,90,111,115,195,215,335,338,388,392,401,472,475,502,521,532],[78,79,80,81,85,86,89],"p",{},"In order to provide more flexibility in more advance physic scenes, and similar to ",[82,83,84],"code",{},"useTresContext"," we provide ",[82,87,88],{},"useRapier"," to access the physic world, internally is used by other components in this library.",[91,92,93],"prose-warning",{},[78,94,95,96,103,104,106,107,110],{},"Similar to ",[97,98,102],"a",{"href":99,"rel":100},"https://docs.tresjs.org/api/composables/use-tres",[101],"nofollow","useTres",", ",[82,105,88],{}," can be only be used inside of a ",[82,108,109],{},"\u003Cphysics />"," since this component acts as the provider for the context data.",[112,113,15],"h2",{"id":114},"usage",[116,117,122],"pre",{"className":118,"code":119,"language":120,"meta":121,"style":121},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const { world, rapier, isDebug, isPaused, timeStep, timeScale, setWorld, step, onBeforeStep } = useRapier()\n","ts","",[82,123,124],{"__ignoreMap":121},[125,126,129,133,137,141,144,147,149,152,154,157,159,162,164,167,169,172,174,177,179,182,185,188,192],"span",{"class":127,"line":128},"line",1,[125,130,132],{"class":131},"spNyl","const",[125,134,136],{"class":135},"sMK4o"," {",[125,138,140],{"class":139},"sTEyZ"," world",[125,142,143],{"class":135},",",[125,145,146],{"class":139}," rapier",[125,148,143],{"class":135},[125,150,151],{"class":139}," isDebug",[125,153,143],{"class":135},[125,155,156],{"class":139}," isPaused",[125,158,143],{"class":135},[125,160,161],{"class":139}," timeStep",[125,163,143],{"class":135},[125,165,166],{"class":139}," timeScale",[125,168,143],{"class":135},[125,170,171],{"class":139}," setWorld",[125,173,143],{"class":135},[125,175,176],{"class":139}," step",[125,178,143],{"class":135},[125,180,181],{"class":139}," onBeforeStep ",[125,183,184],{"class":135},"}",[125,186,187],{"class":135}," =",[125,189,191],{"class":190},"s2Zo4"," useRapier",[125,193,194],{"class":139},"()\n",[78,196,197,103,200,103,203,206,207,210,211,214],{},[82,198,199],{},"isDebug",[82,201,202],{},"isPaused",[82,204,205],{},"timeStep"," and ",[82,208,209],{},"timeScale"," are reactive refs synced from ",[82,212,213],{},"\u003CPhysics>"," props. They can be mutated at runtime:",[116,216,218],{"className":118,"code":217,"language":120,"meta":121,"style":121},"const { isDebug, isPaused, timeScale, timeStep } = useRapier()\n\nisDebug.value = true // Physics world in debug mode\nisPaused.value = true // Pause the simulation\ntimeScale.value = 2 // Double speed\ntimeStep.value = 1 / 120 // Finer fixed steps\n",[82,219,220,249,256,278,294,312],{"__ignoreMap":121},[125,221,222,224,226,228,230,232,234,236,238,241,243,245,247],{"class":127,"line":128},[125,223,132],{"class":131},[125,225,136],{"class":135},[125,227,151],{"class":139},[125,229,143],{"class":135},[125,231,156],{"class":139},[125,233,143],{"class":135},[125,235,166],{"class":139},[125,237,143],{"class":135},[125,239,240],{"class":139}," timeStep ",[125,242,184],{"class":135},[125,244,187],{"class":135},[125,246,191],{"class":190},[125,248,194],{"class":139},[125,250,252],{"class":127,"line":251},2,[125,253,255],{"emptyLinePlaceholder":254},true,"\n",[125,257,259,261,264,267,270,274],{"class":127,"line":258},3,[125,260,199],{"class":139},[125,262,263],{"class":135},".",[125,265,266],{"class":139},"value ",[125,268,269],{"class":135},"=",[125,271,273],{"class":272},"sfNiH"," true",[125,275,277],{"class":276},"sHwdD"," // Physics world in debug mode\n",[125,279,281,283,285,287,289,291],{"class":127,"line":280},4,[125,282,202],{"class":139},[125,284,263],{"class":135},[125,286,266],{"class":139},[125,288,269],{"class":135},[125,290,273],{"class":272},[125,292,293],{"class":276}," // Pause the simulation\n",[125,295,297,299,301,303,305,309],{"class":127,"line":296},5,[125,298,209],{"class":139},[125,300,263],{"class":135},[125,302,266],{"class":139},[125,304,269],{"class":135},[125,306,308],{"class":307},"sbssI"," 2",[125,310,311],{"class":276}," // Double speed\n",[125,313,315,317,319,321,323,326,329,332],{"class":127,"line":314},6,[125,316,205],{"class":139},[125,318,263],{"class":135},[125,320,266],{"class":139},[125,322,269],{"class":135},[125,324,325],{"class":307}," 1",[125,327,328],{"class":135}," /",[125,330,331],{"class":307}," 120",[125,333,334],{"class":276}," // Finer fixed steps\n",[78,336,337],{},"Gravity stays on the world itself and can be updated anytime:",[116,339,341],{"className":118,"code":340,"language":120,"meta":121,"style":121},"const { world } = useRapier()\nworld.value.gravity.y = -20\n",[82,342,343,360],{"__ignoreMap":121},[125,344,345,347,349,352,354,356,358],{"class":127,"line":128},[125,346,132],{"class":131},[125,348,136],{"class":135},[125,350,351],{"class":139}," world ",[125,353,184],{"class":135},[125,355,187],{"class":135},[125,357,191],{"class":190},[125,359,194],{"class":139},[125,361,362,365,367,370,372,375,377,380,382,385],{"class":127,"line":251},[125,363,364],{"class":139},"world",[125,366,263],{"class":135},[125,368,369],{"class":139},"value",[125,371,263],{"class":135},[125,373,374],{"class":139},"gravity",[125,376,263],{"class":135},[125,378,379],{"class":139},"y ",[125,381,269],{"class":135},[125,383,384],{"class":135}," -",[125,386,387],{"class":307},"20\n",[112,389,391],{"id":390},"onbeforestep","onBeforeStep",[78,393,394,396,397,400],{},[82,395,391],{}," registers a callback invoked right before every world step (once per fixed substep) with the timestep about to be solved. Use it for logic that must run in lockstep with the solver, like applying forces or updating a ",[82,398,399],{},"DynamicRayCastVehicleController",":",[116,402,404],{"className":118,"code":403,"language":120,"meta":121,"style":121},"const { onBeforeStep } = useRapier()\n\nonBeforeStep((timestep) => {\n  vehicleController.updateVehicle(timestep)\n})\n",[82,405,406,422,426,448,466],{"__ignoreMap":121},[125,407,408,410,412,414,416,418,420],{"class":127,"line":128},[125,409,132],{"class":131},[125,411,136],{"class":135},[125,413,181],{"class":139},[125,415,184],{"class":135},[125,417,187],{"class":135},[125,419,191],{"class":190},[125,421,194],{"class":139},[125,423,424],{"class":127,"line":251},[125,425,255],{"emptyLinePlaceholder":254},[125,427,428,430,433,435,439,442,445],{"class":127,"line":258},[125,429,391],{"class":190},[125,431,432],{"class":139},"(",[125,434,432],{"class":135},[125,436,438],{"class":437},"sHdIc","timestep",[125,440,441],{"class":135},")",[125,443,444],{"class":131}," =>",[125,446,447],{"class":135}," {\n",[125,449,450,453,455,458,461,463],{"class":127,"line":280},[125,451,452],{"class":139},"  vehicleController",[125,454,263],{"class":135},[125,456,457],{"class":190},"updateVehicle",[125,459,432],{"class":460},"swJcz",[125,462,438],{"class":139},[125,464,465],{"class":460},")\n",[125,467,468,470],{"class":127,"line":296},[125,469,184],{"class":135},[125,471,465],{"class":139},[78,473,474],{},"The callback auto-unregisters when the component scope is disposed. It also returns an unregister function for manual cleanup:",[116,476,478],{"className":118,"code":477,"language":120,"meta":121,"style":121},"const unregister = onBeforeStep(callback)\nunregister()\n",[82,479,480,495],{"__ignoreMap":121},[125,481,482,484,487,489,492],{"class":127,"line":128},[125,483,132],{"class":131},[125,485,486],{"class":139}," unregister ",[125,488,269],{"class":135},[125,490,491],{"class":190}," onBeforeStep",[125,493,494],{"class":139},"(callback)\n",[125,496,497,500],{"class":127,"line":251},[125,498,499],{"class":190},"unregister",[125,501,194],{"class":139},[91,503,504],{},[78,505,506,507,509,510,512,513,516,517,520],{},"With a fixed ",[82,508,205],{},", the world can step zero or multiple times per rendered frame. Prefer ",[82,511,391],{}," over ",[82,514,515],{},"useLoop","'s ",[82,518,519],{},"onBeforeRender"," for physics logic, otherwise forces desync from the simulation.",[91,522,523],{},[78,524,525,526,531],{},"Please note that in the examples below use top level await. Make sure to wrap such code with a Vue's ",[97,527,530],{"href":528,"rel":529},"https://vuejs.org/guide/built-ins/suspense.html#suspense",[101],"Suspense"," component.",[533,534,535],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}",{"title":121,"searchDepth":128,"depth":251,"links":537},[538,539],{"id":114,"depth":251,"text":15},{"id":390,"depth":251,"text":391},"Composable more advance physics world manipulation.","md",null,{},{"title":69,"description":540},"W2rH65V5Vbfl4gxiU00YTfihEHHwCtDjknw86D9fkfs",[547,542],{"title":65,"path":66,"stem":67,"description":548,"children":-1},"Simple and declarative way to joint two or more rigidBodies.",1789116600847]