PageSourceSearch

https://rapier.rs/assets/js/124f64cc.bdc90b73.js

js rapier.rs collected 2026-09-24 19:26:34 UTC 9,953 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkrapier=self.webpackChunkrapier||[]).push([[4780],{3488:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>u,contentTitle:()=>c,default:()=>p,frontMatter:()=>i,metadata:()=>o,toc:()=>d});var r=s(4848),n=s(8453),a=s(1470),l=s(9365);const i={},c=void 0,o={id:"user_guides/templates/scene_queries_intersection_test",title:"scene_queries_intersection_test",description:"Intersection tests will find all the colliders with a shape intersecting a given shape. This can be useful for, e.g.,",source:"@site/docs/user_guides/templates/scene_queries_intersection_test.mdx",sourceDirName:"user_guides/templates",slug:"/user_guides/templates/scene_queries_intersection_test",permalink:"/docs/user_guides/templates/scene_queries_intersection_test",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{}},u={},d=[];function h(e){const t={a:"a",admonition:"admonition",code:"code",li:"li",p:"p",pre:"pre",ul:"ul",...(0,n.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.p,{children:"Intersection tests will find all the colliders with a shape intersecting a given shape. This can be useful for, e.g.,\nselecting all the objects that intersect a given area. There are two kind of intersection tests:"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["The exact intersection test ",(0,r.jsx)("rapier",{children:(0,r.jsx)(t.code,{children:"QueryPipeline::intersections_with_shape"})}),(0,r.jsx)("bevy",{children:(0,r.jsx)(t.code,{children:"RapierContext::intersections_with_shape"})}),(0,r.jsx)("js",{children:(0,r.jsx)(t.code,{children:"World.intersectionsWithShape"})}),"\nsearches for all the colliders with shapes intersecting the given shape."]}),"\n",(0,r.jsxs)(t.li,{children:["The approximate intersection test ",(0,r.jsx)("rapier",{children:(0,r.jsx)(t.code,{children:"QueryPipeline::colliders_with_aabb_intersecting_aabb"})}),(0,r.jsx)("bevy",{children:(0,r.jsx)(t.code,{children:"RapierContext::colliders_with_aabb_intersecting_aabb"})}),(0,r.jsx)("js",{children:(0,r.jsx)(t.code,{children:"World.collidersWithAabbIntersectingAabb"})})," searches\nfor all the colliders with an AABB intersecting the given AABB. This does not check if the actual shapes of these colliders\nintersect the AABB."]}),"\n"]}),"\n",(0,r.jsx)(t.admonition,{type:"info",children:(0,r.jsxs)(t.p,{children:["See the ",(0,r.jsx)(t.a,{href:"/docs/user_guides/templates/scene_queries#ray-casting",children:"ray-casting"})," section for details about intersection tests between a ray and the colliders on the scene.\nAnd see the ",(0,r.jsx)(t.a,{href:"/docs/user_guides/templates/scene_queries#point-projection",children:"point projection"})," section for details about the intersection test between the colliders and\na point."]})}),"\n",(0,r.jsx)("rapier",{children:(0,r.jsxs)(a.A,{groupId:"dim",defaultValue:"2D",values:[{label:"Example 2D",value:"2D"},{label:"Example 3D",value:"3D"}],children:[(0,r.jsx)(l.A,{value:"2D",children:(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-rust",children:"<load path='/2d/rust/examples/rs_scene_queries2.rs' marker='IntersectionTest' />\n"})})}),(0,r.jsx)(l.A,{value:"3D",children:(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-rust",children:"<load path='/3d/rust/examples/rs_scene_queries3.rs' marker='IntersectionTest' />\n"})})})]})}),"\n",(0,r.jsx)("bevy",{children:(0,r.jsxs)(a.A,{groupId:"dim",defaultValue:"2D",values:[{label:"Example 2D",value:"2D"},{label:"Example 3D",value:"3D"}],children:[(0,r.jsx)(l.A,{value:"2D",children:(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-rust",children:"<load path='/2d/bevy/examples/scene_queries2.rs' marker='IntersectionTest' />\n"})})}),(0,r.jsx)(l.A,{value:"3D",children:(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-rust",children:"<load path='/3d/bevy/examples/scene_queries3.rs' marker='IntersectionTest' />\n"})})})]})}),"\n",(0,r.jsx)("js",{children:(0,r.jsxs)(a.A,{groupId:"dim",defaultValue:"2D",values:[{label:"Example 2D",value:"2D"},{label:"Example 3D",value:"3D"}],children:[(0,r.jsx)(l.A,{value:"2D",children:(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-js",children:"<load path='/2d/javascript/src/snippets/scene_queries.ts' marker='IntersectionTest' />\n"})})}),(0,r.jsx)(l.A,{value:"3D",children:(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-js",children:"<load path='/3d/javascript/src/snippets/scene_queries.ts' marker='IntersectionTest' />\n"})})})]})}),"\n",(0,r.jsxs)(t.p,{children:["It is possible to only apply the scene query to a 
1subsets of the colliders using ",(0,r.jsx)(t.a,{href:"/docs/user_guides/templates/scene_queries#query-filters",children:"a query filter"})]})]})}function p(e={}){const{wrapper:t}={...(0,n.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},9365:(e,t,s)=>{s.d(t,{A:()=>l});s(6540);var r=s(8215);const n={tabItem:"tabItem_Ymn6"};var a=s(4848);function l(e){let{children:t,hidden:s,className:l}=e;return(0,a.jsx)("div",{role:"tabpanel",className:(0,r.A)(n.tabItem,l),hidden:s,children:t})}},1470:(e,t,s)=>{s.d(t,{A:()=>y});var r=s(6540),n=s(8215),a=s(3104),l=s(6347),i=s(205),c=s(7485),o=s(1682),u=s(679);function d(e){return r.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,r.isValidElement)(e)&&function(e){const{props:t}=e;return!!t&&"object"==typeof t&&"value"in t}(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 h(e){const{values:t,children:s}=e;return(0,r.useMemo)((()=>{const e=t??function(e){return d(e).map((e=>{let{props:{value:t,label:s,attributes:r,default:n}}=e;return{value:t,label:s,attributes:r,default:n}}))}(s);return function(e){const t=(0,o.XI)(e,((e,t)=>e.value===t.value));if(t.length>0)throw new Error(`Docusaurus error: Duplicate values "${t.map((e=>e.value)).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e}),[t,s])}function p(e){let{value:t,tabValues:s}=e;return s.some((e=>e.value===t))}function m(e){let{queryString:t=!1,groupId:s}=e;const n=(0,l.W6)(),a=function(e){let{queryString:t=!1,groupId:s}=e;if("string"==typeof t)return t;if(!1===t)return null;if(!0===t&&!s)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 s??null}({queryString:t,groupId:s});return[(0,c.aZ)(a),(0,r.useCallback)((e=>{if(!a)return;const t=new URLSearchParams(n.location.search);t.set(a,e),n.replace({...n.location,search:t.toString()})}),[a,n])]}function b(e){const{defaultValue:t,queryString:s=!1,groupId:n}=e,a=h(e),[l,c]=(0,r.useState)((()=>function(e){let{defaultValue:t,tabValues:s}=e;if(0===s.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(t){if(!p({value:t,tabValues:s}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${t}" but none of its children has the corresponding value. Available values are: ${s.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return t}const r=s.find((e=>e.default))??s[0];if(!r)throw new Error("Unexpected error: 0 tabValues");return r.value}({defaultValue:t,tabValues:a}))),[o,d]=m({queryString:s,groupId:n}),[b,f]=function(e){let{groupId:t}=e;const s=function(e){return e?`docusaurus.tab.${e}`:null}(t),[n,a]=(0,u.Dv)(s);return[n,(0,r.useCallback)((e=>{s&&a.set(e)}),[s,a])]}({groupId:n}),x=(()=>{const e=o??b;return p({value:e,tabValues:a})?e:null})();(0,i.A)((()=>{x&&c(x)}),[x]);return{selectedValue:l,selectValue:(0,r.useCallback)((e=>{if(!p({value:e,tabValues:a}))throw new Error(`Can't select invalid tab value=${e}`);c(e),d(e),f(e)}),[d,f,a]),tabValues:a}}var f=s(2303);const x={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var v=s(4848);function g(e){let{className:t,block:s,selectedValue:r,selectValue:l,tabValues:i}=e;const c=[],{blockElementScrollPositionUntilNextRender:o}=(0,a.a_)(),u=e=>{const t=e.currentTarget,s=c.indexOf(t),n=i[s].value;n!==r&&(o(t),l(n))},d=e=>{let t=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{const s=c.indexOf(e.currentTarget)+1;t=c[s]??c[0];break}case"ArrowLeft":{const s=c.indexOf(e.currentTarget)-1;t=c[s]??c[c.length-1];break}}t?.focus()};return(0,v.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,n.A)("tabs",{"tabs--block":s},t),children:i.map((e=>{let{value:t,label:s,attributes:a}=e;return(0,v.jsx)("li",{role:"tab",tabIndex:r===t?0:-1,"aria-selected":r===t,ref:e=>c.push(e),onKeyDown:d,onClick:u,...a,className:(0,n.A)("tabs__item",x.tabItem,a?.className,{"tabs__item--active":r===t}),children:s??t},t)}))})}function j(e){let{lazy:t,children:s,selectedValue:a}=e;
1const l=(Array.isArray(s)?s:[s]).filter(Boolean);if(t){const e=l.find((e=>e.props.value===a));return e?(0,r.cloneElement)(e,{className:(0,n.A)("margin-top--md",e.props.className)}):null}return(0,v.jsx)("div",{className:"margin-top--md",children:l.map(((e,t)=>(0,r.cloneElement)(e,{key:t,hidden:e.props.value!==a})))})}function _(e){const t=b(e);return(0,v.jsxs)("div",{className:(0,n.A)("tabs-container",x.tabList),children:[(0,v.jsx)(g,{...t,...e}),(0,v.jsx)(j,{...t,...e})]})}function y(e){const t=(0,f.A)();return(0,v.jsx)(_,{...e,children:d(e.children)},String(t))}},8453:(e,t,s)=>{s.d(t,{R:()=>l,x:()=>i});var r=s(6540);const n={},a=r.createContext(n);function l(e){const t=r.useContext(a);return r.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:l(e.components),r.createElement(a.Provider,{value:t},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.