[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"github-stars":3,"guide-nav":5,"doc-\u002Fdocs\u002Fprimitives\u002Fsim-agentforces\u002Fforce-containment":129},{"stars":4},5507,[6,11,15,19,23,27,31,35,39,43,47,51,55,59,63,67,72,76,80,84,88,93,97,101,105,109,113,117,121,125],{"path":7,"title":8,"description":9,"category":10},"\u002Fdocs\u002Fguide","Getting started","Shaders is a library of GPU effect components for Vue, React, Svelte, Solid, JavaScript and Framer, with a design editor for building with them.","code",{"path":12,"title":13,"description":14,"category":10},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":16,"title":17,"description":18,"category":10},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":20,"title":21,"description":22,"category":10},"\u002Fdocs\u002Fguide\u002Fblending-masking","Blending and masking","Control how a layer mixes with the layers below it, and reveal one layer through another.",{"path":24,"title":25,"description":26,"category":10},"\u002Fdocs\u002Fguide\u002Fprops-reactivity","Props and reactivity","Bind props to your framework's state so effects update when it changes, and animate props with an animation library.",{"path":28,"title":29,"description":30,"category":10},"\u002Fdocs\u002Fguide\u002Fdynamic-props","Dynamic props","Drive any numeric or position prop from time, the cursor, or another layer, without writing animation code.",{"path":32,"title":33,"description":34,"category":10},"\u002Fdocs\u002Fguide\u002Flayout-positioning","Layout and positioning","Size and place a shader in your page with CSS, as a background, a fill, or an inline block.",{"path":36,"title":37,"description":38,"category":10},"\u002Fdocs\u002Fguide\u002Fsizing-and-units","Sizing and units","Size and place layers in CSS units (px, %, vw, rem, and canvas units) that stay correct as the canvas and window resize.",{"path":40,"title":41,"description":42,"category":10},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":44,"title":45,"description":46,"category":10},"\u002Fdocs\u002Fguide\u002Fshape-effects","Shape effects","Pick the 2D, 3D or custom SVG shape that Glass, Neon, Emboss and other shape effects draw inside.",{"path":48,"title":49,"description":50,"category":10},"\u002Fdocs\u002Fguide\u002Fcolor-space","Color space","Match colors to your design tool with the output color space, and keep bright layers from clipping with tone mapping.",{"path":52,"title":53,"description":54,"category":10},"\u002Fdocs\u002Fguide\u002Fhooks-events","Hooks and events","Run code when an effect is ready to show, and show a fallback when the GPU can't run it.",{"path":56,"title":57,"description":58,"category":10},"\u002Fdocs\u002Fguide\u002Fperformance","Performance","Learn what makes an effect expensive on the GPU and how to keep it inside the frame budget.",{"path":60,"title":61,"description":62,"category":10},"\u002Fdocs\u002Fguide\u002Fcustom-shaders","Custom components","Write your own component in TypeScript, use it like any component in the library, and write WGSL by hand when you need to.",{"path":64,"title":65,"description":66,"category":10},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":68,"title":69,"description":70,"category":71},"\u002Fdocs\u002Fguide\u002Fmcp","Shaders MCP","Connect your AI coding agent to Shaders so it can find, install and edit effects in your codebase.","workflows",{"path":73,"title":74,"description":75,"category":71},"\u002Fdocs\u002Fguide\u002Fcli","Shaders CLI","Install your own shaders and Pro shaders into your codebase as component files, and keep them in sync with the design editor.",{"path":77,"title":78,"description":79,"category":71},"\u002Fdocs\u002Fguide\u002Fagent-skill","Agent skill","Give your coding agent a skill that teaches it to build with Shaders components, the CLI and Pro shaders.",{"path":81,"title":82,"description":83,"category":10},"\u002Fdocs\u002Fguide\u002Fvideo-rendering","Rendering to video","Turn a shader effect into a video file, from the design editor or from a frame-by-frame pipeline such as Remotion, Hyperframes or Puppeteer.",{"path":85,"title":86,"description":87,"category":10},"\u002Fdocs\u002Fguide\u002Fssr","Server rendering","Render Shaders in Next.js, Nuxt, SvelteKit, SolidStart and other SSR apps by keeping each shader on the client.",{"path":89,"title":90,"description":91,"category":92},"\u002Fdocs\u002Fguide\u002Fquick-tour-of-the-design-editor","Quick tour of the design editor","A short walkthrough of the full Shaders workflow, from designing on the infinite canvas to exporting code.","editor",{"path":94,"title":95,"description":96,"category":92},"\u002Fdocs\u002Fguide\u002Fintro-to-the-interface","Intro to the interface","A tour of the design editor interface: the canvas, layers, the Properties panel, and the ways to share and export.",{"path":98,"title":99,"description":100,"category":92},"\u002Fdocs\u002Fguide\u002Fcomposing-your-first-shader-effect","Composing your first shader effect","Building a first shader effect in the design editor by stacking and nesting components as layers.",{"path":102,"title":103,"description":104,"category":92},"\u002Fdocs\u002Fguide\u002Fmasking-and-blending","Masking and blending","How blend modes and masks combine components in the design editor.",{"path":106,"title":107,"description":108,"category":92},"\u002Fdocs\u002Fguide\u002Fdynamic-prop-mapping","Dynamic prop mapping","Turning static props into dynamic ones in the design editor: mapping one layer's output into another's prop, following the cursor, or animating automatically.",{"path":110,"title":111,"description":112,"category":92},"\u002Fdocs\u002Fguide\u002Fcustom-media-and-transformations","Custom media and transformations","Uploading images, videos, and SVG files to the media gallery, adding them to a composition, and placing them with transformations.",{"path":114,"title":115,"description":116,"category":92},"\u002Fdocs\u002Fguide\u002Finstalling-a-shader-via-mcp","Installing a shader via MCP","Installing a shader from the design editor into a hero section with the Shaders MCP.",{"path":118,"title":119,"description":120,"category":92},"\u002Fdocs\u002Fguide\u002Fexploring-shape-effects","Exploring shape effects","Applying shape effects such as liquid glass, liquid metal, and glowing edges to built-in shapes and your own SVG.",{"path":122,"title":123,"description":124,"category":92},"\u002Fdocs\u002Fguide\u002Fglass-component-spotlight","Component spotlight: Glass","A short look at the Glass component and the liquid-glass look it creates.",{"path":126,"title":127,"description":128,"category":92},"\u002Fdocs\u002Fguide\u002Fdigital-looks-component-spotlight","Component spotlight: Digital looks","A look at the digital stylization components for glitchy, futuristic, or technical effects.",{"id":130,"title":131,"body":132,"categoryId":485,"categorySlug":486,"categoryTitle":487,"curated":488,"description":142,"editUrl":489,"extension":490,"group":491,"groupTitle":492,"kind":493,"meta":494,"navigation":495,"path":496,"seo":497,"sourceUrl":498,"stem":499,"wordCount":489,"__hash__":500},"primitives\u002Fdocs\u002Fprimitives\u002F41.sim-agentforces\u002F13.force-containment.md","force.containment",{"type":133,"value":134,"toc":480},"minimark",[135,139,143,271,286,291,340,348,351,355,447,451,476],[136,137,131],"h1",{"id":138},"forcecontainment",[140,141,142],"p",{},"Keep a 3D swarm inside a shape: a spring at the surface, a pull back from far away, and a drag when the shape rotates.",[144,145,150],"pre",{"className":146,"code":147,"language":148,"meta":149,"style":149},"language-ts shiki shiki-themes github-dark","force.containment(layout: VolumeSwarmLayout, cfg: {\n    field: ShapeField3\n    \u002F** How far apart the two samples of the field's slope are taken. 0.02 is typical. *\u002F\n    \u002F\u002F Central-difference epsilon for the field gradient.\n    gradEps: number\n    \u002F** The spring at the surface: fades in from `featherFrom` to `featherTo` (signed distance), `base` push plus `springK` per unit outside. *\u002F\n    \u002F\u002F Strong outside, diffuse inside (a sharp feather packs a coherent shell).\n    wall: {featherFrom: number; featherTo: number; base: number; springK: number}\n    \u002F** The pull home once an agent is `from`..`to` from the origin, with strength `k`. *\u002F\n    \u002F\u002F A hard clamp piles strays into lines.\n    recall: {from: number; to: number; k: number}\n    \u002F** The pull toward the middle where the signed distance is `from`..`to`, with strength `k`. *\u002F\n    \u002F\u002F SDF-VALUE-driven pull toward the origin — direction-safe where the gradient degenerates.\n    homing: {from: number; to: number; k: number}\n    \u002F** How wide a band around the surface the rotation drag fades over. *\u002F\n    \u002F\u002F Drag toward the rotating container's feature velocity ω×r, feathered to inside.\n    entrainment: {featherHalf: number}\n}): AgentForce3\n","ts","",[10,151,152,168,174,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265],{"__ignoreMap":149},[153,154,157,161,165],"span",{"class":155,"line":156},"line",1,[153,158,160],{"class":159},"s95oV","force.",[153,162,164],{"class":163},"svObZ","containment",[153,166,167],{"class":159},"(layout: VolumeSwarmLayout, cfg: {\n",[153,169,171],{"class":155,"line":170},2,[153,172,173],{"class":159},"    field: ShapeField3\n",[153,175,177],{"class":155,"line":176},3,[153,178,180],{"class":179},"sAwPA","    \u002F** How far apart the two samples of the field's slope are taken. 0.02 is typical. *\u002F\n",[153,182,184],{"class":155,"line":183},4,[153,185,186],{"class":179},"    \u002F\u002F Central-difference epsilon for the field gradient.\n",[153,188,190],{"class":155,"line":189},5,[153,191,192],{"class":159},"    gradEps: number\n",[153,194,196],{"class":155,"line":195},6,[153,197,198],{"class":179},"    \u002F** The spring at the surface: fades in from `featherFrom` to `featherTo` (signed distance), `base` push plus `springK` per unit outside. *\u002F\n",[153,200,202],{"class":155,"line":201},7,[153,203,204],{"class":179},"    \u002F\u002F Strong outside, diffuse inside (a sharp feather packs a coherent shell).\n",[153,206,208],{"class":155,"line":207},8,[153,209,210],{"class":159},"    wall: {featherFrom: number; featherTo: number; base: number; springK: number}\n",[153,212,214],{"class":155,"line":213},9,[153,215,216],{"class":179},"    \u002F** The pull home once an agent is `from`..`to` from the origin, with strength `k`. *\u002F\n",[153,218,220],{"class":155,"line":219},10,[153,221,222],{"class":179},"    \u002F\u002F A hard clamp piles strays into lines.\n",[153,224,226],{"class":155,"line":225},11,[153,227,228],{"class":159},"    recall: {from: number; to: number; k: number}\n",[153,230,232],{"class":155,"line":231},12,[153,233,234],{"class":179},"    \u002F** The pull toward the middle where the signed distance is `from`..`to`, with strength `k`. *\u002F\n",[153,236,238],{"class":155,"line":237},13,[153,239,240],{"class":179},"    \u002F\u002F SDF-VALUE-driven pull toward the origin — direction-safe where the gradient degenerates.\n",[153,242,244],{"class":155,"line":243},14,[153,245,246],{"class":159},"    homing: {from: number; to: number; k: number}\n",[153,248,250],{"class":155,"line":249},15,[153,251,252],{"class":179},"    \u002F** How wide a band around the surface the rotation drag fades over. *\u002F\n",[153,254,256],{"class":155,"line":255},16,[153,257,258],{"class":179},"    \u002F\u002F Drag toward the rotating container's feature velocity ω×r, feathered to inside.\n",[153,260,262],{"class":155,"line":261},17,[153,263,264],{"class":159},"    entrainment: {featherHalf: number}\n",[153,266,268],{"class":155,"line":267},18,[153,269,270],{"class":159},"}): AgentForce3\n",[140,272,273,274,277,278,281,282,285],{},"Import ",[10,275,276],{},"sim"," from ",[10,279,280],{},"shaders\u002Fstd"," and use ",[10,283,284],{},"sim.agentForces.force.containment",".",[287,288,290],"h2",{"id":289},"parameters","Parameters",[292,293,294,310],"table",{},[295,296,297],"thead",{},[298,299,300,304,307],"tr",{},[301,302,303],"th",{},"Name",[301,305,306],{},"Type",[301,308,309],{},"Notes",[311,312,313,328],"tbody",{},[298,314,315,321,326],{},[316,317,318],"td",{},[10,319,320],{},"layout",[316,322,323],{},[10,324,325],{},"VolumeSwarmLayout",[316,327],{},[298,329,330,335,338],{},[316,331,332],{},[10,333,334],{},"cfg",[316,336,337],{},"`{",[316,339],{},[144,341,346],{"className":342,"code":344,"language":345},[343],"language-text","field: ShapeField3\n\u002F** How far apart the two samples of the field's slope are taken. 0.02 is typical. *\u002F\n\u002F\u002F Central-difference epsilon for the field gradient.\ngradEps: number\n\u002F** The spring at the surface: fades in from `featherFrom` to `featherTo` (signed distance), `base` push plus `springK` per unit outside. *\u002F\n\u002F\u002F Strong outside, diffuse inside (a sharp feather packs a coherent shell).\nwall: {featherFrom: number; featherTo: number; base: number; springK: number}\n\u002F** The pull home once an agent is `from`..`to` from the origin, with strength `k`. *\u002F\n\u002F\u002F A hard clamp piles strays into lines.\nrecall: {from: number; to: number; k: number}\n\u002F** The pull toward the middle where the signed distance is `from`..`to`, with strength `k`. *\u002F\n\u002F\u002F SDF-VALUE-driven pull toward the origin — direction-safe where the gradient degenerates.\nhoming: {from: number; to: number; k: number}\n\u002F** How wide a band around the surface the rotation drag fades over. *\u002F\n\u002F\u002F Drag toward the rotating container's feature velocity ω×r, feathered to inside.\nentrainment: {featherHalf: number}\n","text",[10,347,344],{"__ignoreMap":149},[140,349,350],{},"}` |  |",[287,352,354],{"id":353},"example","Example",[144,356,358],{"className":146,"code":357,"language":148,"meta":149,"style":149},"forces: [pressure.force, force.containment(simLayout, {field: hexField, gradEps: 0.02, wall: {featherFrom: -0.1, featherTo: 0.01, base: 1.1, springK: 22}, recall: {from: 0.85, to: 1.1, k: 9}, homing: {from: 0.12, to: 0.45, k: 5}, entrainment: {featherHalf: 0.05}})]\n",[10,359,360],{"__ignoreMap":149},[153,361,362,365,368,370,373,377,380,384,387,390,393,396,399,402,405,408,411,414,416,419,422,425,428,430,433,435,438,441,444],{"class":155,"line":156},[153,363,364],{"class":163},"forces",[153,366,367],{"class":159},": [pressure.force, force.",[153,369,164],{"class":163},[153,371,372],{"class":159},"(simLayout, {field: hexField, gradEps: ",[153,374,376],{"class":375},"sDLfK","0.02",[153,378,379],{"class":159},", wall: {featherFrom: ",[153,381,383],{"class":382},"snl16","-",[153,385,386],{"class":375},"0.1",[153,388,389],{"class":159},", featherTo: ",[153,391,392],{"class":375},"0.01",[153,394,395],{"class":159},", base: ",[153,397,398],{"class":375},"1.1",[153,400,401],{"class":159},", springK: ",[153,403,404],{"class":375},"22",[153,406,407],{"class":159},"}, recall: {from: ",[153,409,410],{"class":375},"0.85",[153,412,413],{"class":159},", to: ",[153,415,398],{"class":375},[153,417,418],{"class":159},", k: ",[153,420,421],{"class":375},"9",[153,423,424],{"class":159},"}, homing: {from: ",[153,426,427],{"class":375},"0.12",[153,429,413],{"class":159},[153,431,432],{"class":375},"0.45",[153,434,418],{"class":159},[153,436,437],{"class":375},"5",[153,439,440],{"class":159},"}, entrainment: {featherHalf: ",[153,442,443],{"class":375},"0.05",[153,445,446],{"class":159},"}})]\n",[287,448,450],{"id":449},"see-also","See also",[452,453,454,467],"ul",{},[455,456,457,464,465,285],"li",{},[458,459,461],"a",{"href":460},"\u002Fdocs\u002Fprimitives\u002Fsim-shapefields\u002Fshapefield",[10,462,463],{},"shapeField"," — The signed-distance function of the shape a swarm lives in, for ",[10,466,131],{},[455,468,469,475],{},[458,470,472],{"href":471},"\u002Fdocs\u002Fprimitives\u002Fsim-agentforces\u002Fforce-pressure",[10,473,474],{},"force.pressure"," — Spread a 3D swarm evenly by pushing agents away from crowded cells of a density grid.",[477,478,479],"style",{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}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 pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}",{"title":149,"searchDepth":170,"depth":170,"links":481},[482,483,484],{"id":289,"depth":170,"text":290},{"id":353,"depth":170,"text":354},{"id":449,"depth":170,"text":450},"sim.agentForces","sim-agentforces","Agent forces",false,null,"md","simulation","Simulation","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fsim-agentforces\u002Fforce-containment",{"title":131,"description":142},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fsim\u002FagentForces.ts#L239","docs\u002Fprimitives\u002F41.sim-agentforces\u002F13.force-containment","6Zsnx5ML5Q59KPdBNuQYRCEUWQKT8cFEqllJvoi_ams"]