1"use strict";(self.webpackChunkrapier=self.webpackChunkrapier||[]).push([[2012],{97662:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>s,toc:()=>l});var r=t(74848),a=t(28453);t(11470),t(19365);const i={},o=void 0,s={id:"user_guides/javascript/rigid_body_dominance",title:"rigid_body_dominance",description:"Dominance is a non-realistic, but sometimes useful, feature. It can be used to make one rigid-body immune to forces",source:"@site/docs/user_guides/javascript/rigid_body_dominance.mdx",sourceDirName:"user_guides/javascript",slug:"/user_guides/javascript/rigid_body_dominance",permalink:"/docs/user_guides/javascript/rigid_body_dominance",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{}},c={},l=[];function u(e){const n={admonition:"admonition",code:"code",p:"p",pre:"pre",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:'Dominance is a non-realistic, but sometimes useful, feature. It can be used to make one rigid-body immune to forces\noriginating from contacts with some other bodies. For example this can be used to model a player represented as a\ndynamic rigid-body that cannot be "pushed back" by any, or some, other dynamic rigid-bodies part of the environment.'}),"\n",(0,r.jsxs)(n.p,{children:["Each rigid-body is part of a dominance group in ",(0,r.jsx)(n.code,{children:"[-127; 127]"})," (the default group is ",(0,r.jsx)(n.code,{children:"0"}),"). If the colliders from two rigid-bodies\nare in contact, the one with the highest dominance will act as if it has an infinite mass, making it immune to the\ncontact forces the other body would apply on it. If both bodies are part of the same dominance group, then their\ncontacts will work in the usual way (both are affected by opposite forces with the same magnitude)."]}),"\n",(0,r.jsxs)(n.p,{children:["For example, if a dynamic body ",(0,r.jsx)(n.code,{children:"A"}
1)," is in the dominance group ",(0,r.jsx)(n.code,{children:"10"}),", and a dynamic body ",(0,r.jsx)(n.code,{children:"B"})," in the dominance group ",(0,r.jsx)(n.code,{children:"-20"}),", then\na contact between a collider attached to ",(0,r.jsx)(n.code,{children:"A"})," and a collider attached ",(0,r.jsx)(n.code,{children:"B"})," will result in ",(0,r.jsx)(n.code,{children:"A"})," remaining immobile and ",(0,r.jsx)(n.code,{children:"B"})," being\npushed by ",(0,r.jsx)(n.code,{children:"A"})," (independently from their mass)."]}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsx)(n.p,{children:"A non-dynamic rigid-body is always considered as being part of a dominance group greater than any dynamic rigid-body.\nThis means that dynamic/fixed and dynamic/kinematic contacts will continue to work normally, independently from the\ndominance group they were given by the user."})}),"\n",(0,r.jsx)(n.p,{children:"The dominance group can be set when the rigid-body is created or after its creation:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-js",children:"/* Set the damping coefficients when the rigid-body is created. */\nlet rigidBodyDesc = RAPIER.RigidBodyDesc.dynamic()\n .setDominanceGroup(10);\nlet rigidBody = world.createRigidBody(rigidBodyDesc);\n"})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-js",children:"/* Set the damping coefficients after the rigid-body creation. */\nrigidBody.setDominanceGroup(10);\n"})})]})}function d(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(u,{...e})}):u(e)}},19365:(e,n,t)=>{t.d(n,{A:()=>o});t(96540);var r=t(18215);const a={tabItem:"tabItem_Ymn6"};var i=t(74848);function o(e){let{children:n,hidden:t,className:o}=e;return(0,i.jsx)("div",{role:"tabpanel",className:(0,r.A)(a.tabItem,o),hidden:t,children:n})}},11470:(e,n,t)=>{t.d(n,{A:()=>w});var r=t(96540),a=t(18215),i=t(23104),o=t(56347),s=t(205),c=t(57485),l=t(31682),u=t(70679);function d(e){return r.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,r.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function m(e){const{values:n,children:t}=e;return(0,r.useMemo)((()=>{const e=n??function(e){return d(e).map((e=>{let{props:{value:n,label:t,attributes:r,default:a}}=e;return{value:n,label:t,attributes:r,default:a}}))}(t);return function(e){const n=(0,l.XI)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e}),[n,t])}function h(e){let{value:n,tabValues:t}=e;return t.some((e=>e.value===n))}function p(e){let{queryString:n=!1,groupId:t}=e;const a=(0,o.W6)(),i=function(e){let{queryString:n=!1,groupId:t}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:n,groupId:t});return[(0,c.aZ)(i),(0,r.useCallback)((e=>{if(!i)return;const n=new URLSearchParams(a.location.search);n.set(i,e),a.replace({...a.location,search:n.toString()})}),[i,a])]}function f(e){const{defaultValue:n,queryString:t=!1,groupId:a}=e,i=m(e),[o,c]=(0,r.useState)((()=>function(e){let{defaultValue:n,tabValues:t}=e;if(0===t.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(n){if(!h({value:n,tabValues:t}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${t.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const r=t.find((e=>e.default))??t[0];if(!r)throw new Error("Unexpected error: 0 tabValues");return r.value}({defaultValue:n,tabValues:i}))),[l,d]=p({queryString:t,groupId:a}),[f,b]=function(e){let{groupId:n}=e;const t=function(e){return e?`docusaurus.tab.${e}`:null}(n),[a,i]=(0,u.Dv)(t);return[a,(0,r.useCallback)((e=>{t&&i.set(e)}),[t,i])]}({groupId:a}),g=(()=>{const e=l??f;return h({value:e,tabValues:i})?e:null})();(0,s.A)((()=>{g&&c(g)}),[g]);return{selectedValue:o,selectValue:(0,r.useCallback)((e=>{if(!h({value:e,tabValues:i}))throw new Error(`Can't select invalid tab value=${e}`);c(e),d(e),b(e)}),[d,b,i]),tabValues:i}}var b=t(92303);const g={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var y=t(74848);function v(e){let{className:n,block:t,selectedValue:r,selectValue:o,tabValues:s}=e;const c=[],{blockElementScrollPositionUntilNextRender:l}=(0,i.a_)(),u=e=>{const n=e.currentTarget,t=c.indexOf(n),a=s[t].value;a!==r&&(l(n),o(a))},d=e=>{let n=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{const t=c.indexOf(e.currentTarget)+1;n=c[t]??c[0];break}case"ArrowLeft":{const t=c.indexOf(e.currentTarget)-1;n=c[t]??c[c.length-1];break}}n?.focus()};return(0,y.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,a.A)("tabs",{"tabs--block":t},n),children:s.map((e=>{let{value:n,label:t,attributes:i}=e;return(0,y.jsx)("li",{role:"tab",tabIndex:r===n?0:-1,"aria-selected":r===n,ref:e=>c.push(e),onKeyDown:d,onClick:u,...i,className:(0,a.A)("tabs__item",g.tabItem,i?.className,{"tabs__item--active":r===n}),children:t??n},n)}))})}function x(e){let{lazy:n,children:t,selectedValue:i}=e;
1const o=(Array.isArray(t)?t:[t]).filter(Boolean);if(n){const e=o.find((e=>e.props.value===i));return e?(0,r.cloneElement)(e,{className:(0,a.A)("margin-top--md",e.props.className)}):null}return(0,y.jsx)("div",{className:"margin-top--md",children:o.map(((e,n)=>(0,r.cloneElement)(e,{key:n,hidden:e.props.value!==i})))})}function j(e){const n=f(e);return(0,y.jsxs)("div",{className:(0,a.A)("tabs-container",g.tabList),children:[(0,y.jsx)(v,{...n,...e}),(0,y.jsx)(x,{...n,...e})]})}function w(e){const n=(0,b.A)();return(0,y.jsx)(j,{...e,children:d(e.children)},String(n))}},28453:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>s});var r=t(96540);const a={},i=r.createContext(a);function o(e){const n=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:o(e.components),r.createElement(i.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.