@zylem/behaviors 0.5.2 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{behavior-system-CldqNUgr.d.ts → behavior-system-HEt67el5.d.ts} +14 -1
- package/dist/{chunk-EIWQM6U3.js → chunk-2HKY6WF7.js} +0 -1
- package/dist/{chunk-IZJFUAXB.js → chunk-2HLZBWGD.js} +0 -1
- package/dist/{chunk-LL4FLHIY.js → chunk-2YF7J3H4.js} +0 -1
- package/dist/{chunk-SGHIGTVZ.js → chunk-3X3CL24Z.js} +0 -1
- package/dist/{chunk-HZMY3TT4.js → chunk-4DVDFCVY.js} +0 -1
- package/dist/{chunk-QVCMJ4Q2.js → chunk-4EWASZHB.js} +0 -1
- package/dist/{chunk-4LLK2FJI.js → chunk-55CFXXZH.js} +3 -4
- package/dist/{chunk-4MZ57HPD.js → chunk-57GLKGEX.js} +3 -4
- package/dist/{chunk-QS3VXWVO.js → chunk-7GGR26YA.js} +3 -4
- package/dist/{chunk-Y4PHT2HG.js → chunk-7LHXAEOZ.js} +4 -5
- package/dist/{chunk-PLIXVF7B.js → chunk-7TIIRJKF.js} +3 -4
- package/dist/{chunk-LZIHSJZR.js → chunk-CB3C7CRD.js} +4 -5
- package/dist/{chunk-G2KUXVU6.js → chunk-CTSYM56P.js} +30 -12
- package/dist/{chunk-2PAHQZZD.js → chunk-CVRN7YAI.js} +3 -4
- package/dist/{chunk-NW4SE5XW.js → chunk-DD4U42FG.js} +2 -3
- package/dist/{chunk-BAXJ7XHJ.js → chunk-E2MOFIDH.js} +3 -4
- package/dist/{chunk-WOMHL23C.js → chunk-ERS6SNA5.js} +1 -2
- package/dist/{chunk-4WH2ZN7P.js → chunk-F7E23E26.js} +0 -1
- package/dist/{chunk-DZ4LLQON.js → chunk-GZ3DQIIZ.js} +23 -2
- package/dist/{chunk-5WRI5ZAA.js → chunk-JSBRDJBE.js} +0 -1
- package/dist/{chunk-5A5AYP2C.js → chunk-K6CWKFHL.js} +0 -1
- package/dist/{chunk-52FJIDGL.js → chunk-LAN7U3AK.js} +1 -2
- package/dist/{chunk-WU6XXL3D.js → chunk-LLDLVVG4.js} +4 -5
- package/dist/{chunk-M3QDKKDF.js → chunk-LWM346FW.js} +0 -1
- package/dist/{chunk-7DGXUAPV.js → chunk-M25QJBDN.js} +4 -5
- package/dist/{chunk-7JLWZXPA.js → chunk-NDJO56BB.js} +3 -4
- package/dist/{chunk-AS3HR7AS.js → chunk-OBF6BIA2.js} +1 -2
- package/dist/{chunk-KIYUUSPK.js → chunk-OSPQFWQF.js} +2 -3
- package/dist/{chunk-4CEW64HO.js → chunk-OU2SW4U5.js} +3 -4
- package/dist/{chunk-H4TJ7X4O.js → chunk-QU6GQ657.js} +2 -3
- package/dist/{chunk-KFFETUAL.js → chunk-RR3XNDKG.js} +2 -3
- package/dist/{chunk-JVADRLWX.js → chunk-SHZZ2QRV.js} +2 -3
- package/dist/{chunk-7W3KY55G.js → chunk-TK3AXXXI.js} +3 -4
- package/dist/{chunk-OPZ2LVS2.js → chunk-TZQQYJYK.js} +0 -1
- package/dist/{chunk-7JJEIADR.js → chunk-UF7QPYUX.js} +299 -157
- package/dist/{chunk-NQPYMUDF.js → chunk-UKGBQTHL.js} +3 -4
- package/dist/{chunk-5XPPLTC7.js → chunk-UUMH3DC3.js} +1 -2
- package/dist/{chunk-TBUKJKY6.js → chunk-VJ3UA6OD.js} +1 -2
- package/dist/{chunk-OHCPV2NT.js → chunk-WHKPWIQO.js} +0 -1
- package/dist/{chunk-EZNCCO4L.js → chunk-YDLO5M7S.js} +0 -1
- package/dist/{components-BmievOxF.d.ts → components-JZQoO2sU.d.ts} +1 -1
- package/dist/cooldown.d.ts +1 -1
- package/dist/cooldown.js +3 -4
- package/dist/coordinators/boundary-ricochet-3d.d.ts +2 -2
- package/dist/coordinators/boundary-ricochet-3d.js +4 -5
- package/dist/coordinators/boundary-ricochet.d.ts +2 -2
- package/dist/coordinators/boundary-ricochet.js +4 -5
- package/dist/coordinators/first-person-shooter.js +4 -5
- package/dist/coordinators/multidirectional-space-shooter.d.ts +1 -1
- package/dist/coordinators/multidirectional-space-shooter.js +6 -7
- package/dist/coordinators/top-down-shooter.d.ts +1 -1
- package/dist/coordinators/top-down-shooter.js +6 -7
- package/dist/core.d.ts +21 -6
- package/dist/core.js +29 -7
- package/dist/destructible-3d.d.ts +1 -1
- package/dist/destructible-3d.js +4 -5
- package/dist/destructible-prebake.js +2 -3
- package/dist/{first-person-perspective-C9Mptl0-.d.ts → first-person-perspective-BxFHgFln.d.ts} +2 -0
- package/dist/first-person.d.ts +12 -3
- package/dist/first-person.js +7 -8
- package/dist/index.d.ts +5 -5
- package/dist/index.js +40 -41
- package/dist/jumper-2d.d.ts +1 -1
- package/dist/jumper-2d.js +5 -6
- package/dist/jumper-3d.d.ts +1 -1
- package/dist/jumper-3d.js +6 -7
- package/dist/{moveable-rdIvWiak.d.ts → moveable-BdFmI3s1.d.ts} +1 -1
- package/dist/particle-emitter/presets.d.ts +1 -1
- package/dist/particle-emitter/presets.js +2 -3
- package/dist/particle-emitter.d.ts +3 -3
- package/dist/particle-emitter.js +5 -6
- package/dist/platformer-2d.d.ts +1 -1
- package/dist/platformer-2d.js +5 -6
- package/dist/platformer-3d.d.ts +1 -1
- package/dist/platformer-3d.js +5 -6
- package/dist/ricochet-2d.d.ts +1 -1
- package/dist/ricochet-2d.js +5 -6
- package/dist/ricochet-3d.d.ts +1 -1
- package/dist/ricochet-3d.js +5 -6
- package/dist/runtime-2d.d.ts +1 -1
- package/dist/runtime-2d.js +2 -3
- package/dist/screen-visibility.d.ts +1 -1
- package/dist/screen-visibility.js +3 -4
- package/dist/screen-wrap.d.ts +1 -1
- package/dist/screen-wrap.js +5 -6
- package/dist/shooter-2d.d.ts +1 -1
- package/dist/shooter-2d.js +5 -6
- package/dist/{spark-Dx3cJbTW.d.ts → spark-C4Tp-52_.d.ts} +4 -2
- package/dist/thruster.d.ts +1 -1
- package/dist/thruster.js +5 -6
- package/dist/top-down-movement.d.ts +1 -1
- package/dist/top-down-movement.js +7 -8
- package/dist/world-boundary-2d.d.ts +1 -1
- package/dist/world-boundary-2d.js +6 -7
- package/dist/world-boundary-3d.d.ts +1 -1
- package/dist/world-boundary-3d.js +6 -7
- package/package.json +159 -161
- package/dist/chunk-2PAHQZZD.js.map +0 -1
- package/dist/chunk-4CEW64HO.js.map +0 -1
- package/dist/chunk-4LLK2FJI.js.map +0 -1
- package/dist/chunk-4MZ57HPD.js.map +0 -1
- package/dist/chunk-4WH2ZN7P.js.map +0 -1
- package/dist/chunk-52FJIDGL.js.map +0 -1
- package/dist/chunk-5A5AYP2C.js.map +0 -1
- package/dist/chunk-5WRI5ZAA.js.map +0 -1
- package/dist/chunk-5XPPLTC7.js.map +0 -1
- package/dist/chunk-7DGXUAPV.js.map +0 -1
- package/dist/chunk-7JJEIADR.js.map +0 -1
- package/dist/chunk-7JLWZXPA.js.map +0 -1
- package/dist/chunk-7W3KY55G.js.map +0 -1
- package/dist/chunk-AS3HR7AS.js.map +0 -1
- package/dist/chunk-BAXJ7XHJ.js.map +0 -1
- package/dist/chunk-DZ4LLQON.js.map +0 -1
- package/dist/chunk-EIWQM6U3.js.map +0 -1
- package/dist/chunk-EZNCCO4L.js.map +0 -1
- package/dist/chunk-G2KUXVU6.js.map +0 -1
- package/dist/chunk-H4TJ7X4O.js.map +0 -1
- package/dist/chunk-HZMY3TT4.js.map +0 -1
- package/dist/chunk-IZJFUAXB.js.map +0 -1
- package/dist/chunk-JVADRLWX.js.map +0 -1
- package/dist/chunk-KFFETUAL.js.map +0 -1
- package/dist/chunk-KIYUUSPK.js.map +0 -1
- package/dist/chunk-LL4FLHIY.js.map +0 -1
- package/dist/chunk-LZIHSJZR.js.map +0 -1
- package/dist/chunk-M3QDKKDF.js.map +0 -1
- package/dist/chunk-NQPYMUDF.js.map +0 -1
- package/dist/chunk-NW4SE5XW.js.map +0 -1
- package/dist/chunk-OHCPV2NT.js.map +0 -1
- package/dist/chunk-OPZ2LVS2.js.map +0 -1
- package/dist/chunk-PLIXVF7B.js.map +0 -1
- package/dist/chunk-QS3VXWVO.js.map +0 -1
- package/dist/chunk-QVCMJ4Q2.js.map +0 -1
- package/dist/chunk-SGHIGTVZ.js.map +0 -1
- package/dist/chunk-TBUKJKY6.js.map +0 -1
- package/dist/chunk-WOMHL23C.js.map +0 -1
- package/dist/chunk-WU6XXL3D.js.map +0 -1
- package/dist/chunk-Y4PHT2HG.js.map +0 -1
- package/dist/cooldown.js.map +0 -1
- package/dist/coordinators/boundary-ricochet-3d.js.map +0 -1
- package/dist/coordinators/boundary-ricochet.js.map +0 -1
- package/dist/coordinators/first-person-shooter.js.map +0 -1
- package/dist/coordinators/multidirectional-space-shooter.js.map +0 -1
- package/dist/coordinators/top-down-shooter.js.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/destructible-3d.js.map +0 -1
- package/dist/destructible-prebake.js.map +0 -1
- package/dist/first-person.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jumper-2d.js.map +0 -1
- package/dist/jumper-3d.js.map +0 -1
- package/dist/particle-emitter/presets.js.map +0 -1
- package/dist/particle-emitter.js.map +0 -1
- package/dist/platformer-2d.js.map +0 -1
- package/dist/platformer-3d.js.map +0 -1
- package/dist/ricochet-2d.js.map +0 -1
- package/dist/ricochet-3d.js.map +0 -1
- package/dist/runtime-2d.js.map +0 -1
- package/dist/screen-visibility.js.map +0 -1
- package/dist/screen-wrap.js.map +0 -1
- package/dist/shooter-2d.js.map +0 -1
- package/dist/thruster.js.map +0 -1
- package/dist/top-down-movement.js.map +0 -1
- package/dist/world-boundary-2d.js.map +0 -1
- package/dist/world-boundary-3d.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/coordinators/multidirectional-space-shooter.coordinator.ts"],"sourcesContent":["import {\n\tcreateThrusterInputComponent,\n\ttype ThrusterInputComponent,\n} from '../behaviors/thruster/components';\nimport type {\n\tShooter2DHandle,\n\tShooter2DSourceEntity,\n\tShooter2DStageLike,\n} from '../behaviors/shooter-2d/shooter-2d.descriptor';\nimport { getEntityFacingAngle2D, resolveAim2D } from './shared/top-down-aim';\nimport {\n\tfireShooter2DIfRequested,\n\ttype Shooter2DAimFireInput,\n} from './shared/shooter-fire';\n\nexport interface MultidirectionalSpaceShooterInput extends Shooter2DAimFireInput {\n\tmoveX: number;\n\tmoveY: number;\n}\n\nexport type MultidirectionalSpaceShooterEntity = Shooter2DSourceEntity & {\n\t$thruster?: ThrusterInputComponent;\n\tsetRotationZ(angle: number): void;\n};\n\n/**\n * Coordinator that fans a single input snapshot out to the thruster behavior\n * (vector thrust), entity rotation (aim), and the Shooter2D behavior (fire\n * requests).\n */\nexport class MultidirectionalSpaceShooterCoordinator {\n\tconstructor(\n\t\tprivate entity: MultidirectionalSpaceShooterEntity,\n\t\tprivate shooter: Shooter2DHandle,\n\t\tprivate stage: Shooter2DStageLike,\n\t) {}\n\n\tpublic update(input: MultidirectionalSpaceShooterInput): void {\n\t\tif (!this.entity.$thruster) {\n\t\t\tthis.entity.$thruster = createThrusterInputComponent();\n\t\t}\n\n\t\tthis.entity.$thruster.thrustX = input.moveX;\n\t\tthis.entity.$thruster.thrustY = input.moveY;\n\t\tthis.entity.$thruster.thrust = 0;\n\t\tthis.entity.$thruster.rotate = 0;\n\n\t\tconst aim = resolveAim2D(\n\t\t\tinput.aimX,\n\t\t\tinput.aimY,\n\t\t\tgetEntityFacingAngle2D(this.entity),\n\t\t);\n\t\tif (aim.hasAimInput) {\n\t\t\tthis.entity.setRotationZ(aim.angle);\n\t\t}\n\n\t\tfireShooter2DIfRequested(this.entity, this.shooter, this.stage, input, aim);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AA8BO,IAAM,0CAAN,MAA8C;AAAA,EACpD,YACS,QACA,SACA,OACP;AAHO;AACA;AACA;AAAA,EACN;AAAA,EAHM;AAAA,EACA;AAAA,EACA;AAAA,EAGF,OAAO,OAAgD;AAC7D,QAAI,CAAC,KAAK,OAAO,WAAW;AAC3B,WAAK,OAAO,YAAY,6BAA6B;AAAA,IACtD;AAEA,SAAK,OAAO,UAAU,UAAU,MAAM;AACtC,SAAK,OAAO,UAAU,UAAU,MAAM;AACtC,SAAK,OAAO,UAAU,SAAS;AAC/B,SAAK,OAAO,UAAU,SAAS;AAE/B,UAAM,MAAM;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,uBAAuB,KAAK,MAAM;AAAA,IACnC;AACA,QAAI,IAAI,aAAa;AACpB,WAAK,OAAO,aAAa,IAAI,KAAK;AAAA,IACnC;AAEA,6BAAyB,KAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,OAAO,GAAG;AAAA,EAC3E;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/coordinators/boundary-ricochet.coordinator.ts"],"sourcesContent":["import type { Ricochet2DHandle } from '../behaviors/ricochet-2d/ricochet-2d.descriptor';\nimport type { WorldBoundary2DHandle } from '../behaviors/world-boundary-2d/world-boundary-2d.descriptor';\nimport type { MoveableEntity } from '../capabilities/moveable';\nimport type { BaseEntityInterface } from '../types/entity-types';\nimport { getBounds2DNormalFromHits } from '../behaviors/shared/bounds-2d';\nimport { updateBoundaryRicochet } from './shared/boundary-ricochet';\n\n/** Entity shape required by the 2D boundary-ricochet coordinator. */\nexport type BoundaryRicochetEntity = BaseEntityInterface & MoveableEntity;\n\n/**\n * Coordinator that bridges WorldBoundary2DBehavior and Ricochet2DBehavior.\n *\n * Automatically handles:\n * 1. Checking boundary hits\n * 2. Computing collision normals\n * 3. Requesting ricochet result\n * 4. Applying movement\n */\nexport class BoundaryRicochetCoordinator {\n\tconstructor(\n\t\tprivate entity: BoundaryRicochetEntity,\n\t\tprivate boundary: WorldBoundary2DHandle,\n\t\tprivate ricochet: Ricochet2DHandle,\n\t) {}\n\n\t/**\n\t * Update loop - call this every frame.\n\t * Applies ricochet via transformStore and notifies listeners.\n\t *\n\t * @returns true if ricochet was applied, false otherwise\n\t */\n\tpublic update(): boolean {\n\t\treturn updateBoundaryRicochet({\n\t\t\tgetLastHits: () => this.boundary.getLastHits(),\n\t\t\thasAnyHit: (hits) => hits.left || hits.right || hits.top || hits.bottom,\n\t\t\tgetNormal: (hits) => getBounds2DNormalFromHits(hits),\n\t\t\tapplyRicochet: (normal) =>\n\t\t\t\tthis.ricochet.applyRicochet({\n\t\t\t\t\tentity: this.entity,\n\t\t\t\t\tcontact: { normal: { x: normal.x, y: normal.y } },\n\t\t\t\t}),\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;AAmBO,IAAM,8BAAN,MAAkC;AAAA,EACxC,YACS,QACA,UACA,UACP;AAHO;AACA;AACA;AAAA,EACN;AAAA,EAHM;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASF,SAAkB;AACxB,WAAO,uBAAuB;AAAA,MAC7B,aAAa,MAAM,KAAK,SAAS,YAAY;AAAA,MAC7C,WAAW,CAAC,SAAS,KAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,KAAK;AAAA,MACjE,WAAW,CAAC,SAAS,0BAA0B,IAAI;AAAA,MACnD,eAAe,CAAC,WACf,KAAK,SAAS,cAAc;AAAA,QAC3B,QAAQ,KAAK;AAAA,QACb,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,GAAG,GAAG,OAAO,EAAE,EAAE;AAAA,MACjD,CAAC;AAAA,IACH,CAAC;AAAA,EACF;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/shared/bounds-3d.ts"],"sourcesContent":["export interface Bounds3DPoint {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\nexport interface Bounds3DBox {\n\tminX: number;\n\tmaxX: number;\n\tminY: number;\n\tmaxY: number;\n\tminZ: number;\n\tmaxZ: number;\n}\n\nexport interface Bounds3DSize {\n\twidth: number;\n\theight: number;\n\tdepth: number;\n\tcenterX?: number;\n\tcenterY?: number;\n\tcenterZ?: number;\n}\n\nexport interface Bounds3DHits {\n\tleft: boolean;\n\tright: boolean;\n\ttop: boolean;\n\tbottom: boolean;\n\tback: boolean;\n\tfront: boolean;\n}\n\nexport interface Bounds3DPadding {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\nexport type Bounds3DPaddingInput =\n\t| number\n\t| Partial<Bounds3DPadding>\n\t| undefined;\n\nexport function createBounds3DBox({\n\twidth,\n\theight,\n\tdepth,\n\tcenterX = 0,\n\tcenterY = 0,\n\tcenterZ = 0,\n}: Bounds3DSize): Bounds3DBox {\n\tconst halfWidth = width / 2;\n\tconst halfHeight = height / 2;\n\tconst halfDepth = depth / 2;\n\treturn {\n\t\tminX: centerX - halfWidth,\n\t\tmaxX: centerX + halfWidth,\n\t\tminY: centerY - halfHeight,\n\t\tmaxY: centerY + halfHeight,\n\t\tminZ: centerZ - halfDepth,\n\t\tmaxZ: centerZ + halfDepth,\n\t};\n}\n\nexport function normalizeBounds3DPadding(\n\tpadding?: Bounds3DPaddingInput,\n): Bounds3DPadding {\n\tif (typeof padding === 'number') {\n\t\treturn { x: padding, y: padding, z: padding };\n\t}\n\n\treturn {\n\t\tx: padding?.x ?? 0,\n\t\ty: padding?.y ?? 0,\n\t\tz: padding?.z ?? 0,\n\t};\n}\n\nexport function insetBounds3D(\n\tbounds: Bounds3DBox,\n\tpadding?: Bounds3DPaddingInput,\n): Bounds3DBox {\n\tconst resolved = normalizeBounds3DPadding(padding);\n\treturn {\n\t\tminX: bounds.minX + resolved.x,\n\t\tmaxX: bounds.maxX - resolved.x,\n\t\tminY: bounds.minY + resolved.y,\n\t\tmaxY: bounds.maxY - resolved.y,\n\t\tminZ: bounds.minZ + resolved.z,\n\t\tmaxZ: bounds.maxZ - resolved.z,\n\t};\n}\n\nexport function computeBounds3DHits(\n\tposition: Bounds3DPoint,\n\tbounds: Bounds3DBox,\n): Bounds3DHits {\n\tconst hits: Bounds3DHits = {\n\t\tleft: false,\n\t\tright: false,\n\t\ttop: false,\n\t\tbottom: false,\n\t\tback: false,\n\t\tfront: false,\n\t};\n\n\tif (position.x <= bounds.minX) hits.left = true;\n\telse if (position.x >= bounds.maxX) hits.right = true;\n\n\tif (position.y <= bounds.minY) hits.bottom = true;\n\telse if (position.y >= bounds.maxY) hits.top = true;\n\n\tif (position.z <= bounds.minZ) hits.back = true;\n\telse if (position.z >= bounds.maxZ) hits.front = true;\n\n\treturn hits;\n}\n\nexport function hasAnyBounds3DHit(hits: Bounds3DHits): boolean {\n\treturn hits.left || hits.right || hits.top || hits.bottom || hits.back || hits.front;\n}\n\nexport function constrainMovementToBounds3D(\n\thits: Bounds3DHits,\n\tmoveX: number,\n\tmoveY: number,\n\tmoveZ: number,\n): { moveX: number; moveY: number; moveZ: number } {\n\tlet adjustedX = moveX;\n\tlet adjustedY = moveY;\n\tlet adjustedZ = moveZ;\n\n\tif ((hits.left && moveX < 0) || (hits.right && moveX > 0)) {\n\t\tadjustedX = 0;\n\t}\n\n\tif ((hits.bottom && moveY < 0) || (hits.top && moveY > 0)) {\n\t\tadjustedY = 0;\n\t}\n\n\tif ((hits.back && moveZ < 0) || (hits.front && moveZ > 0)) {\n\t\tadjustedZ = 0;\n\t}\n\n\treturn { moveX: adjustedX, moveY: adjustedY, moveZ: adjustedZ };\n}\n\nexport function clampPointToBounds3D(\n\tposition: Bounds3DPoint,\n\tbounds: Bounds3DBox,\n): Bounds3DPoint {\n\treturn {\n\t\tx: Math.min(bounds.maxX, Math.max(bounds.minX, position.x)),\n\t\ty: Math.min(bounds.maxY, Math.max(bounds.minY, position.y)),\n\t\tz: Math.min(bounds.maxZ, Math.max(bounds.minZ, position.z)),\n\t};\n}\n\nexport function getBounds3DNormalFromHits(\n\thits: Bounds3DHits,\n): { x: number; y: number; z: number } {\n\tlet x = 0;\n\tlet y = 0;\n\tlet z = 0;\n\n\tif (hits.left) x = 1;\n\tif (hits.right) x = -1;\n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AAQ,KAAK;AAChF;AAEO,SAAS,4BACf,MACA,OACA,OACA,OACkD;AAClD,MAAI,YAAY;AAChB,MAAI,YAAY;AAChB,MAAI,YAAY;AAEhB,MAAK,KAAK,QAAQ,QAAQ,KAAO,KAAK,SAAS,QAAQ,GAAI;AAC1D,gBAAY;AAAA,EACb;AAEA,MAAK,KAAK,UAAU,QAAQ,KAAO,KAAK,OAAO,QAAQ,GAAI;AAC1D,gBAAY;AAAA,EACb;AAEA,MAAK,KAAK,QAAQ,QAAQ,KAAO,KAAK,SAAS,QAAQ,GAAI;AAC1D,gBAAY;AAAA,EACb;AAEA,SAAO,EAAE,OAAO,WAAW,OAAO,WAAW,OAAO,UAAU;AAC/D;AAEO,SAAS,qBACf,UACA,QACgB;AAChB,SAAO;AAAA,IACN,GAAG,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;AAAA,IAC1D,GAAG,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;AAAA,IAC1D,GAAG,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;AAAA,EAC3D;AACD;AAEO,SAAS,0BACf,MACsC;AACtC,MAAI,IAAI;AACR,MAAI,IAAI;AACR,MAAI,IAAI;AAER,MAAI,KAAK,KAAM,KAAI;AACnB,MAAI,KAAK,MAAO,KAAI;AACpB,MAAI,KAAK,OAAQ,KAAI;AACrB,MAAI,KAAK,IAAK,KAAI;AAClB,MAAI,KAAK,KAAM,KAAI;AACnB,MAAI,KAAK,MAAO,KAAI;AAEpB,SAAO,EAAE,GAAG,GAAG,EAAE;AAClB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/shared/bounds-2d.ts"],"sourcesContent":["export interface Bounds2DPoint {\n\tx: number;\n\ty: number;\n}\n\nexport interface Bounds2DRect {\n\tminX: number;\n\tmaxX: number;\n\tminY: number;\n\tmaxY: number;\n}\n\nexport interface Bounds2DSize {\n\twidth: number;\n\theight: number;\n\tcenterX?: number;\n\tcenterY?: number;\n}\n\nexport interface Bounds2DHits {\n\tleft: boolean;\n\tright: boolean;\n\ttop: boolean;\n\tbottom: boolean;\n}\n\nexport interface Bounds2DWrapResult {\n\tx: number;\n\ty: number;\n\twrapped: boolean;\n}\n\nexport function createBounds2DRect({\n\twidth,\n\theight,\n\tcenterX = 0,\n\tcenterY = 0,\n}: Bounds2DSize): Bounds2DRect {\n\tconst halfWidth = width / 2;\n\tconst halfHeight = height / 2;\n\treturn {\n\t\tminX: centerX - halfWidth,\n\t\tmaxX: centerX + halfWidth,\n\t\tminY: centerY - halfHeight,\n\t\tmaxY: centerY + halfHeight,\n\t};\n}\n\nexport function computeBounds2DHits(\n\tposition: Bounds2DPoint,\n\tbounds: Bounds2DRect,\n): Bounds2DHits {\n\tconst hits: Bounds2DHits = {\n\t\ttop: false,\n\t\tbottom: false,\n\t\tleft: false,\n\t\tright: false,\n\t};\n\n\tif (position.x <= bounds.minX) hits.left = true;\n\telse if (position.x >= bounds.maxX) hits.right = true;\n\n\tif (position.y <= bounds.minY) hits.bottom = true;\n\telse if (position.y >= bounds.maxY) hits.top = true;\n\n\treturn hits;\n}\n\nexport function hasAnyBounds2DHit(hits: Bounds2DHits): boolean {\n\treturn hits.left || hits.right || hits.top || hits.bottom;\n}\n\nexport function constrainMovementToBounds2D(\n\thits: Bounds2DHits,\n\tmoveX: number,\n\tmoveY: number,\n): { moveX: number; moveY: number } {\n\tlet adjustedX = moveX;\n\tlet adjustedY = moveY;\n\n\tif ((hits.left && moveX < 0) || (hits.right && moveX > 0)) {\n\t\tadjustedX = 0;\n\t}\n\n\tif ((hits.bottom && moveY < 0) || (hits.top && moveY > 0)) {\n\t\tadjustedY = 0;\n\t}\n\n\treturn { moveX: adjustedX, moveY: adjustedY };\n}\n\nexport function wrapPoint2D(\n\tposition: Bounds2DPoint,\n\tbounds: Bounds2DRect,\n): Bounds2DWrapResult {\n\tlet x = position.x;\n\tlet y = position.y;\n\tlet wrapped = false;\n\n\tif (position.x < bounds.minX) {\n\t\tx = bounds.maxX - (bounds.minX - position.x);\n\t\twrapped = true;\n\t} else if (position.x > bounds.maxX) {\n\t\tx = bounds.minX + (position.x - bounds.maxX);\n\t\twrapped = true;\n\t}\n\n\tif (position.y < bounds.minY) {\n\t\ty = bounds.maxY - (bounds.minY - position.y);\n\t\twrapped = true;\n\t} else if (position.y > bounds.maxY) {\n\t\ty = bounds.minY + (position.y - bounds.maxY);\n\t\twrapped = true;\n\t}\n\n\treturn { x, y, wrapped };\n}\n\nexport function getBounds2DNormalFromHits(\n\thits: Bounds2DHits,\n): { x: number; y: number } {\n\tlet x = 0;\n\tlet y = 0;\n\n\tif (hits.left) x = 1;\n\tif (hits.right) x = -1;\n\tif (hits.bottom) y = 1;\n\tif (hits.top) y = -1;\n\n\treturn { x, y };\n}\n"],"mappings":";AAgCO,SAAS,mBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,UAAU;AACX,GAA+B;AAC9B,QAAM,YAAY,QAAQ;AAC1B,QAAM,aAAa,SAAS;AAC5B,SAAO;AAAA,IACN,MAAM,UAAU;AAAA,IAChB,MAAM,UAAU;AAAA,IAChB,MAAM,UAAU;AAAA,IAChB,MAAM,UAAU;AAAA,EACjB;AACD;AAEO,SAAS,oBACf,UACA,QACe;AACf,QAAM,OAAqB;AAAA,IAC1B,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAEA,MAAI,SAAS,KAAK,OAAO,KAAM,MAAK,OAAO;AAAA,WAClC,SAAS,KAAK,OAAO,KAAM,MAAK,QAAQ;AAEjD,MAAI,SAAS,KAAK,OAAO,KAAM,MAAK,SAAS;AAAA,WACpC,SAAS,KAAK,OAAO,KAAM,MAAK,MAAM;AAE/C,SAAO;AACR;AAEO,SAAS,kBAAkB,MAA6B;AAC9D,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,KAAK;AACpD;AAEO,SAAS,4BACf,MACA,OACA,OACmC;AACnC,MAAI,YAAY;AAChB,MAAI,YAAY;AAEhB,MAAK,KAAK,QAAQ,QAAQ,KAAO,KAAK,SAAS,QAAQ,GAAI;AAC1D,gBAAY;AAAA,EACb;AAEA,MAAK,KAAK,UAAU,QAAQ,KAAO,KAAK,OAAO,QAAQ,GAAI;AAC1D,gBAAY;AAAA,EACb;AAEA,SAAO,EAAE,OAAO,WAAW,OAAO,UAAU;AAC7C;AA6BO,SAAS,0BACf,MAC2B;AAC3B,MAAI,IAAI;AACR,MAAI,IAAI;AAER,MAAI,KAAK,KAAM,KAAI;AACnB,MAAI,KAAK,MAAO,KAAI;AACpB,MAAI,KAAK,OAAQ,KAAI;AACrB,MAAI,KAAK,IAAK,KAAI;AAElB,SAAO,EAAE,GAAG,EAAE;AACf;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/shooter-2d/components.ts","../src/lib/behaviors/shooter-2d/shooter-2d.descriptor.ts"],"sourcesContent":["export interface Shooter2DStateComponent {\n\tcooldownRemainingMs: number;\n}\n\nexport function createShooter2DStateComponent(): Shooter2DStateComponent {\n\treturn {\n\t\tcooldownRemainingMs: 0,\n\t};\n}\n","import { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport { normalizeVec3, type Vec3Input } from '../../core/vector';\nimport type { BehaviorRuntime } from '../../runtime/wasm-stage-runtime';\nimport {\n\tangleFromDirection2D,\n\tdirectionFromAngle2D,\n\tgetRotationAngle2D,\n\tnormalizeDirection2D,\n\trotateLocalOffset2D,\n} from '../shared/direction-2d';\nimport {\n\tcreateShooter2DStateComponent,\n\ttype Shooter2DStateComponent,\n} from './components';\n\nexport interface Shooter2DTarget {\n\tx: number;\n\ty: number;\n}\n\nexport interface Shooter2DStageLike {\n\tadd(...inputs: any[]): void;\n}\n\nexport interface Shooter2DProjectileEntity {\n\ttransformStore: {\n\t\tvelocity: { x: number; y: number; z: number };\n\t\tdirty: { velocityX: boolean; velocityY: boolean; velocityZ: boolean };\n\t};\n\tprependSetup(\n\t\tcallback: (params: { me: Shooter2DProjectileEntity }) => void,\n\t): unknown;\n\tsetPosition(x: number, y: number, z: number): void;\n\tsetRotationZ(angle: number): void;\n}\n\nexport type Shooter2DProjectileFactory = () =>\n\t| Shooter2DProjectileEntity\n\t| Promise<Shooter2DProjectileEntity>;\n\nexport interface Shooter2DBehaviorOptions {\n\tprojectileFactory: Shooter2DProjectileFactory;\n\tprojectileSpeed: number;\n\tcooldownMs?: number;\n\tspawnOffset?: Shooter2DTarget;\n\trotateProjectile?: boolean;\n}\n\nexport interface Shooter2DSourceEntity {\n\tbody?: {\n\t\ttranslation(): { x: number; y: number; z: number };\n\t\trotation?: () => { x: number; y: number; z: number; w: number };\n\t} | null;\n\toptions?: {\n\t\tposition?: Vec3Input;\n\t};\n\ttopDownMovementState?: {\n\t\tfacingAngle: number;\n\t};\n\tshooter2dState?: Shooter2DStateComponent;\n\t_rotation2DAngle?: number;\n}\n\nexport interface Shooter2DFireArgs {\n\tsource: Shooter2DSourceEntity;\n\tstage: Shooter2DStageLike;\n\ttarget: Shooter2DTarget;\n}\n\nexport interface Shooter2DHandle {\n\tisReady(source: Shooter2DSourceEntity): boolean;\n\tfire(args: Shooter2DFireArgs): Promise<Shooter2DProjectileEntity | null>;\n}\n\nconst defaultOptions: Shooter2DBehaviorOptions = {\n\tprojectileFactory: () => {\n\t\tthrow new Error('Shooter2DBehavior requires a projectileFactory.');\n\t},\n\tprojectileSpeed: 12,\n\tcooldownMs: 0,\n\tspawnOffset: { x: 0, y: 1 },\n\trotateProjectile: true,\n};\n\nconst SHOOTER_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:shooter-2d');\n\nfunction ensureShooterState(entity: Shooter2DSourceEntity): Shooter2DStateComponent {\n\tif (!entity.shooter2dState) {\n\t\tentity.shooter2dState = createShooter2DStateComponent();\n\t}\n\treturn entity.shooter2dState;\n}\n\nfunction getEntityPosition(\n\tentity: Shooter2DSourceEntity,\n): { x: number; y: number; z: number } | null {\n\tif (entity.body?.translation) {\n\t\treturn entity.body.translation();\n\t}\n\n\tconst position = entity.options?.position;\n\tif (!position) {\n\t\treturn null;\n\t}\n\n\treturn normalizeVec3(position);\n}\n\nfunction getEntityFacingAngle(entity: Shooter2DSourceEntity): number {\n\tif (entity.topDownMovementState) {\n\t\treturn entity.topDownMovementState.facingAngle;\n\t}\n\n\tif (entity.body?.rotation) {\n\t\treturn getRotationAngle2D(entity.body.rotation());\n\t}\n\n\treturn entity._rotation2DAngle ?? 0;\n}\n\nfunction createShooter2DHandle(\n\tref: BehaviorRef<Shooter2DBehaviorOptions>,\n): Shooter2DHandle {\n\treturn {\n\t\tisReady: (source: Shooter2DSourceEntity) =>\n\t\t\tensureShooterState(source).cooldownRemainingMs <= 0,\n\t\tfire: async ({\n\t\t\tsource,\n\t\t\tstage,\n\t\t\ttarget,\n\t\t}: Shooter2DFireArgs): Promise<Shooter2DProjectileEntity | null> => {\n\t\t\tconst state = ensureShooterState(source);\n\t\t\tif (state.cooldownRemainingMs > 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst sourcePosition = getEntityPosition(source);\n\t\t\tif (!sourcePosition) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst options = ref.options;\n\t\t\tconst aimDirection = normalizeDirection2D(\n\t\t\t\ttarget.x - sourcePosition.x,\n\t\t\t\ttarget.y - sourcePosition.y,\n\t\t\t);\n\t\t\tconst angle = aimDirection\n\t\t\t\t? angleFromDirection2D(aimDirection)\n\t\t\t\t: getEntityFacingAngle(source);\n\t\t\tconst direction = aimDirection ?? directionFromAngle2D(angle);\n\t\t\tconst offset = rotateLocalOffset2D(\n\t\t\t\toptions.spawnOffset ?? defaultOptions.spawnOffset!,\n\t\t\t\tangle,\n\t\t\t);\n\t\t\tconst spawnPosition = {\n\t\t\t\tx: sourcePosition.x + offset.x,\n\t\t\t\ty: sourcePosition.y + offset.y,\n\t\t\t\tz: sourcePosition.z,\n\t\t\t};\n\t\t\tconst projectile = await Promise.resolve(options.projectileFactory());\n\t\t\tprojectile.prependSetup(({ me }) => {\n\t\t\t\tme.setPosition(spawnPosition.x, spawnPosition.y, spawnPosition.z);\n\t\t\t\tif (options.rotateProjectile ?? true) {\n\t\t\t\t\tme.setRotationZ(angle);\n\t\t\t\t}\n\t\t\t\tme.transformStore.velocity.x = direction.x * options.projectileSpeed;\n\t\t\t\tme.transformStore.velocity.y = direction.y * options.projectileSpeed;\n\t\t\t\tme.transformStore.velocity.z = 0;\n\t\t\t\tme.transformStore.dirty.velocityX = true;\n\t\t\t\tme.transformStore.dirty.velocityY = true;\n\t\t\t\tme.transformStore.dirty.velocityZ = true;\n\t\t\t});\n\n\t\t\tstage.add(projectile);\n\t\t\tstate.cooldownRemainingMs = Math.max(0, options.cooldownMs ?? 0);\n\t\t\treturn projectile;\n\t\t},\n\t};\n}\n\nclass Shooter2DBehaviorSystem implements BehaviorSystem {\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate wasmStage: BehaviorRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(SHOOTER_2D_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst entity = link.entity as Shooter2DSourceEntity & { runtimeHandle?: number };\n\t\t\tconst ref = link.ref as any;\n\t\t\tconst state = ensureShooterState(entity);\n\t\t\tstate.cooldownRemainingMs = Math.max(\n\t\t\t\t0,\n\t\t\t\tstate.cooldownRemainingMs - delta * 1000,\n\t\t\t);\n\t\t\tref.__entity = entity;\n\n\t\t\tconst handle = (entity.runtimeHandle ?? -1) as number;\n\t\t\tif (this.wasmStage && handle >= 0) {\n\t\t\t\tthis.ensureWasmAttached(handle, ref.options as Shooter2DBehaviorOptions);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: Shooter2DBehaviorOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tconst offset = options.spawnOffset ?? defaultOptions.spawnOffset!;\n\t\tconst fireRateHz = options.cooldownMs && options.cooldownMs > 0\n\t\t\t? 1000 / options.cooldownMs\n\t\t\t: 0;\n\t\tthis.wasmStage.attachShooter2D(handle, {\n\t\t\tfireRateHz,\n\t\t\tmuzzleOffsetX: offset.x,\n\t\t\tmuzzleOffsetY: offset.y,\n\t\t\tmuzzleSpeed: options.projectileSpeed,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\nexport const Shooter2DBehavior = defineBehavior<\n\tShooter2DBehaviorOptions,\n\tShooter2DHandle,\n\tShooter2DSourceEntity\n>({\n\tname: 'shooter-2d',\n\tdefaultOptions,\n\tsystemFactory: (ctx) => new Shooter2DBehaviorSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),\n\tcreateHandle: createShooter2DHandle,\n});\n"],"mappings":";;;;;;;;;;;;;;;AAIO,SAAS,gCAAyD;AACxE,SAAO;AAAA,IACN,qBAAqB;AAAA,EACtB;AACD;;;ACmEA,IAAM,iBAA2C;AAAA,EAChD,mBAAmB,MAAM;AACxB,UAAM,IAAI,MAAM,iDAAiD;AAAA,EAClE;AAAA,EACA,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,aAAa,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,EAC1B,kBAAkB;AACnB;AAEA,IAAM,0BAA0B,uBAAO,IAAI,2BAA2B;AAEtE,SAAS,mBAAmB,QAAwD;AACnF,MAAI,CAAC,OAAO,gBA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AAI,CAAC,KAAK,aAAa,KAAK,qBAAqB,IAAI,MAAM,EAAG;AAC9D,UAAM,SAAS,QAAQ,eAAe,eAAe;AACrD,UAAM,aAAa,QAAQ,cAAc,QAAQ,aAAa,IAC3D,MAAO,QAAQ,aACf;AACH,SAAK,UAAU,gBAAgB,QAAQ;AAAA,MACtC;AAAA,MACA,eAAe,OAAO;AAAA,MACtB,eAAe,OAAO;AAAA,MACtB,aAAa,QAAQ;AAAA,IACtB,CAAC;AACD,SAAK,qBAAqB,IAAI,MAAM;AAAA,EACrC;AAAA,EAEA,QAAQ,MAAqB;AAC5B,SAAK,qBAAqB,MAAM;AAAA,EACjC;AACD;AAEO,IAAM,oBAAoB,eAI/B;AAAA,EACD,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,QAAQ,IAAI,wBAAwB,IAAI,aAAa,MAAM,IAAI,gBAAgB;AAAA,EAC/F,cAAc;AACf,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/ricochet-3d/ricochet-3d-fsm.ts","../src/lib/behaviors/ricochet-3d/ricochet-3d.descriptor.ts"],"sourcesContent":["import { SyncStateMachine, t } from '../../core/utility/sync-state-machine';\nimport { BaseEntityInterface } from '../../types/entity-types';\n\nexport interface Ricochet3DResult {\n\tvelocity: { x: number; y: number; z: number };\n\tspeed: number;\n\tnormal: { x: number; y: number; z: number };\n}\n\nexport interface Ricochet3DCollisionContext {\n\tentity?: BaseEntityInterface;\n\totherEntity?: BaseEntityInterface;\n\tselfVelocity?: { x: number; y: number; z: number };\n\tcontact: {\n\t\tnormal?: { x: number; y: number; z: number };\n\t\tposition?: { x: number; y: number; z: number };\n\t};\n\tselfPosition?: { x: number; y: number; z: number };\n\totherPosition?: { x: number; y: number; z: number };\n\totherSize?: { x: number; y: number; z: number };\n}\n\nexport enum Ricochet3DState {\n\tIdle = 'idle',\n\tRicocheting = 'ricocheting',\n}\n\nexport enum Ricochet3DEvent {\n\tStartRicochet = 'start-ricochet',\n\tEndRicochet = 'end-ricochet',\n}\n\nexport type Ricochet3DCallback = (result: Ricochet3DResult) => void;\n\n/** Structural view of a host-attached body (harness/simulation facade). */\ninterface RicochetBodyLike {\n\tlinvel(): { x: number; y: number; z: number };\n\ttranslation(): { x: number; y: number; z: number };\n}\n\nfunction bodyOf(entity: BaseEntityInterface | undefined): RicochetBodyLike | null {\n\tconst body = entity?.body as Partial<RicochetBodyLike> | null | undefined;\n\tif (body && typeof body.linvel === 'function' && typeof body.translation === 'function') {\n\t\treturn body as RicochetBodyLike;\n\t}\n\treturn null;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n\treturn Math.max(min, Math.min(max, value));\n}\n\nfunction length3(x: number, y: number, z: number): number {\n\treturn Math.sqrt(x * x + y * y + z * z);\n}\n\nexport class Ricochet3DFSM {\n\tpublic readonly machine: SyncStateMachine<Ricochet3DState, Ricochet3DEvent, never>;\n\n\tprivate lastResult: Ricochet3DResult | null = null;\n\tprivate lastUpdatedAtMs: number | null = null;\n\tprivate currentTimeMs = 0;\n\tprivate listeners = new Set<Ricochet3DCallback>();\n\n\tconstructor() {\n\t\tthis.machine = new SyncStateMachine<Ricochet3DState, Ricochet3DEvent, never>(\n\t\t\tRicochet3DState.Idle,\n\t\t\t[\n\t\t\t\tt(Ricochet3DState.Idle, Ricochet3DEvent.StartRicochet, Ricochet3DState.Ricocheting),\n\t\t\t\tt(Ricochet3DState.Ricocheting, Ricochet3DEvent.EndRicochet, Ricochet3DState.Idle),\n\t\t\t\tt(Ricochet3DState.Idle, Ricochet3DEvent.EndRicochet, Ricochet3DState.Idle),\n\t\t\t\tt(Ricochet3DState.Ricocheting, Ricochet3DEvent.StartRicochet, Ricochet3DState.Ricocheting),\n\t\t\t],\n\t\t);\n\t}\n\n\taddListener(callback: Ricochet3DCallback): () => void {\n\t\tthis.listeners.add(callback);\n\t\treturn () => this.listeners.delete(callback);\n\t}\n\n\tgetState(): Ricochet3DState {\n\t\treturn this.machine.getState();\n\t}\n\n\tgetLastResult(): Ricochet3DResult | null {\n\t\treturn this.lastResult;\n\t}\n\n\tgetLastUpdatedAtMs(): number | null {\n\t\treturn this.lastUpdatedAtMs;\n\t}\n\n\tsetCurrentTimeMs(timeMs: number): void {\n\t\tthis.currentTimeMs = timeMs;\n\t}\n\n\tisOnCooldown(cooldownMs: number = 50): boolean {\n\t\tif (this.lastUpdatedAtMs === null) return false;\n\t\treturn (this.currentTimeMs - this.lastUpdatedAtMs) < cooldownMs;\n\t}\n\n\tresetCooldown(): void {\n\t\tthis.lastUpdatedAtMs = null;\n\t}\n\n\tcomputeRicochet(\n\t\tctx: Ricochet3DCollisionContext,\n\t\toptions: {\n\t\t\tminSpeed?: number;\n\t\t\tmaxSpeed?: number;\n\t\t\tspeedMultiplier?: number;\n\t\t\treflectionMode?: 'simple' | 'angled';\n\t\t\tmaxAngleDeg?: number;\n\t\t} = {},\n\t): Ricochet3DResult | null {\n\t\tconst {\n\t\t\tminSpeed = 2,\n\t\t\tmaxSpeed = 20,\n\t\t\tspeedMultiplier = 1.05,\n\t\t\treflectionMode = 'angled',\n\t\t\tmaxAngleDeg = 45,\n\t\t} = options;\n\n\t\tconst {\n\t\t\tselfVelocity,\n\t\t\tselfPosition,\n\t\t\totherPosition,\n\t\t\totherSize,\n\t\t} = this.extractDataFromEntities(ctx);\n\n\t\tif (!selfVelocity) {\n\t\t\tthis.dispatch(Ricochet3DEvent.EndRicochet);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst speed = length3(selfVelocity.x, selfVelocity.y, selfVelocity.z);\n\t\tif (speed === 0) {\n\t\t\tthis.dispatch(Ricochet3DEvent.EndRicochet);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst normal = ctx.contact.normal ?? this.computeNormalFromPositions(selfPosition, otherPosition);\n\t\tif (!normal) {\n\t\t\tthis.dispatch(Ricochet3DEvent.EndRicochet);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst unitNormal = this.normalizeVector(normal);\n\t\tlet reflected = this.computeBasicReflection(selfVelocity, unitNormal);\n\n\t\tif (reflectionMode === 'angled') {\n\t\t\treflected = this.computeAngledDeflection(\n\t\t\t\treflected,\n\t\t\t\tselfVelocity,\n\t\t\t\tunitNormal,\n\t\t\t\tspeed,\n\t\t\t\tmaxAngleDeg,\n\t\t\t\tspeedMultiplier,\n\t\t\t\tselfPosition,\n\t\t\t\totherPosition,\n\t\t\t\totherSize,\n\t\t\t\tctx.contact.position,\n\t\t\t);\n\t\t} else {\n\t\t\treflected = {\n\t\t\t\tx: reflected.x * speedMultiplier,\n\t\t\t\ty: reflected.y * speedMultiplier,\n\t\t\t\tz: reflected.z * speedMultiplier,\n\t\t\t};\n\t\t}\n\n\t\treflected = this.applySpeedClamp(reflected, minSpeed, maxSpeed);\n\n\t\tconst result: Ricochet3DResult = {\n\t\t\tvelocity: reflected,\n\t\t\tspeed: length3(reflected.x, reflected.y, reflected.z),\n\t\t\tnormal: unitNormal,\n\t\t};\n\n\t\tthis.lastResult = result;\n\t\tthis.lastUpdatedAtMs = this.currentTimeMs;\n\t\tthis.dispatch(Ricochet3DEvent.StartRicochet);\n\t\tthis.emitToListeners(result);\n\t\treturn result;\n\t}\n\n\tclearRicochet(): void {\n\t\tthis.dispatch(Ricochet3DEvent.EndRicochet);\n\t}\n\n\tprivate emitToListeners(result: Ricochet3DResult): void {\n\t\tfor (const callback of this.listeners) {\n\t\t\ttry {\n\t\t\t\tcallback(result);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[Ricochet3DFSM] Listener error:', error);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate extractDataFromEntities(ctx: Ricochet3DCollisionContext) {\n\t\tlet selfVelocity = ctx.selfVelocity;\n\t\tlet selfPosition = ctx.selfPosition;\n\t\tlet otherPosition = ctx.otherPosition;\n\t\tlet otherSize = ctx.otherSize;\n\n\t\tconst selfBody = bodyOf(ctx.entity);\n\t\tif (selfBody) {\n\t\t\tconst velocity = selfBody.linvel();\n\t\t\tselfVelocity = selfVelocity ?? { x: velocity.x, y: velocity.y, z: velocity.z };\n\t\t\tconst position = selfBody.translation();\n\t\t\tselfPosition = selfPosition ?? { x: position.x, y: position.y, z: position.z };\n\t\t}\n\n\t\tconst otherBody = bodyOf(ctx.otherEntity);\n\t\tif (otherBody) {\n\t\t\tconst position = otherBody.translation();\n\t\t\totherPosition = otherPosition ?? { x: position.x, y: position.y, z: position.z };\n\t\t}\n\n\t\tif (ctx.otherEntity && 'size' in ctx.otherEntity) {\n\t\t\tconst size = (ctx.otherEntity as any).size;\n\t\t\tif (size && typeof size.x === 'number') {\n\t\t\t\totherSize = otherSize ?? { x: size.x, y: size.y, z: size.z };\n\t\t\t}\n\t\t}\n\n\t\treturn { selfVelocity, selfPosition, otherPosition, otherSize };\n\t}\n\n\tprivate computeNormalFromPositions(\n\t\tselfPosition?: { x: number; y: number; z: number },\n\t\totherPosition?: { x: number; y: number; z: number },\n\t): { x: number; y: number; z: number } | null {\n\t\tif (!selfPosition || !otherPosition) return null;\n\n\t\tconst delta = {\n\t\t\tx: selfPosition.x - otherPosition.x,\n\t\t\ty: selfPosition.y - otherPosition.y,\n\t\t\tz: selfPosition.z - otherPosition.z,\n\t\t};\n\t\tconst absX = Math.abs(delta.x);\n\t\tconst absY = Math.abs(delta.y);\n\t\tconst absZ = Math.abs(delta.z);\n\n\t\tif (absX >= absY && absX >= absZ) {\n\t\t\treturn { x: delta.x >= 0 ? 1 : -1, y: 0, z: 0 };\n\t\t}\n\t\tif (absY >= absX && absY >= absZ) {\n\t\t\treturn { x: 0, y: delta.y >= 0 ? 1 : -1, z: 0 };\n\t\t}\n\t\treturn { x: 0, y: 0, z: delta.z >= 0 ? 1 : -1 };\n\t}\n\n\tprivate normalizeVector(vector: { x: number; y: number; z: number }) {\n\t\tconst magnitude = length3(vector.x, vector.y, vector.z);\n\t\tif (magnitude <= 1e-6) {\n\t\t\treturn { x: 0, y: 1, z: 0 };\n\t\t}\n\t\treturn {\n\t\t\tx: vector.x / magnitude,\n\t\t\ty: vector.y / magnitude,\n\t\t\tz: vector.z / magnitude,\n\t\t};\n\t}\n\n\tprivate dot(\n\t\ta: { x: number; y: number; z: number },\n\t\tb: { x: number; y: number; z: number },\n\t): number {\n\t\treturn a.x * b.x + a.y * b.y + a.z * b.z;\n\t}\n\n\tprivate computeBasicReflection(\n\t\tvelocity: { x: number; y: number; z: number },\n\t\tnormal: { x: number; y: number; z: number },\n\t): { x: number; y: number; z: number } {\n\t\tconst dotProduct = this.dot(velocity, normal);\n\t\treturn {\n\t\t\tx: velocity.x - 2 * dotProduct * normal.x,\n\t\t\ty: velocity.y - 2 * dotProduct * normal.y,\n\t\t\tz: velocity.z - 2 * dotProduct * normal.z,\n\t\t};\n\t}\n\n\tprivate computeAngledDeflection(\n\t\treflected: { x: number; y: number; z: number },\n\t\tincoming: { x: number; y: number; z: number },\n\t\tnormal: { x: number; y: number; z: number },\n\t\tspeed: number,\n\t\tmaxAngleDeg: number,\n\t\tspeedMultiplier: number,\n\t\tselfPosition?: { x: number; y: number; z: number },\n\t\totherPosition?: { x: number; y: number; z: number },\n\t\totherSize?: { x: number; y: number; z: number },\n\t\tcontactPosition?: { x: number; y: number; z: number },\n\t): { x: number; y: number; z: number } {\n\t\tconst baseDirection = this.normalizeVector(reflected);\n\t\tconst tangentVector = this.computeHitOffsetVector(\n\t\t\tincoming,\n\t\t\tnormal,\n\t\t\tselfPosition,\n\t\t\totherPosition,\n\t\t\totherSize,\n\t\t\tcontactPosition,\n\t\t);\n\n\t\tconst offsetStrength = clamp(\n\t\t\tlength3(tangentVector.x, tangentVector.y, tangentVector.z),\n\t\t\t0,\n\t\t\t1,\n\t\t);\n\t\tif (offsetStrength === 0) {\n\t\t\treturn {\n\t\t\t\tx: baseDirection.x * speed * speedMultiplier,\n\t\t\t\ty: baseDirection.y * speed * speedMultiplier,\n\t\t\t\tz: baseDirection.z * speed * speedMultiplier,\n\t\t\t};\n\t\t}\n\n\t\tconst tangentDirection = this.normalizeVector(tangentVector);\n\t\tconst angle = offsetStrength * (maxAngleDeg * Math.PI / 180);\n\t\tconst cosAngle = Math.cos(angle);\n\t\tconst sinAngle = Math.sin(angle);\n\t\tconst direction = this.normalizeVector({\n\t\t\tx: baseDirection.x * cosAngle + tangentDirection.x * sinAngle,\n\t\t\ty: baseDirection.y * cosAngle + tangentDirection.y * sinAngle,\n\t\t\tz: baseDirection.z * cosAngle + tangentDirection.z * sinAngle,\n\t\t});\n\t\tconst newSpeed = speed * speedMultiplier;\n\n\t\treturn {\n\t\t\tx: direction.x * newSpeed,\n\t\t\ty: direction.y * newSpeed,\n\t\t\tz: direction.z * newSpeed,\n\t\t};\n\t}\n\n\tprivate computeHitOffsetVector(\n\t\tvelocity: { x: number; y: number; z: number },\n\t\tnormal: { x: number; y: number; z: number },\n\t\tselfPosition?: { x: number; y: number; z: number },\n\t\totherPosition?: { x: number; y: number; z: number },\n\t\totherSize?: { x: number; y: number; z: number },\n\t\tcontactPosition?: { x: number; y: number; z: number },\n\t): { x: number; y: number; z: number } {\n\t\tif (otherPosition && otherSize) {\n\t\t\tconst faceAxis = this.getDominantAxis(normal);\n\t\t\tif (faceAxis === 'x') {\n\t\t\t\treturn {\n\t\t\t\t\tx: 0,\n\t\t\t\t\ty: ((selfPosition?.y ?? contactPosition?.y ?? otherPosition.y) - otherPosition.y) / Math.max(otherSize.y / 2, 1e-6),\n\t\t\t\t\tz: ((selfPosition?.z ?? contactPosition?.z ?? otherPosition.z) - otherPosition.z) / Math.max(otherSize.z / 2, 1e-6),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (faceAxis === 'y') {\n\t\t\t\treturn {\n\t\t\t\t\tx: ((selfPosition?.x ?? contactPosition?.x ?? otherPosition.x) - otherPosition.x) / Math.max(otherSize.x / 2, 1e-6),\n\t\t\t\t\ty: 0,\n\t\t\t\t\tz: ((selfPosition?.z ?? contactPosition?.z ?? otherPosition.z) - otherPosition.z) / Math.max(otherSize.z / 2, 1e-6),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tx: ((selfPosition?.x ?? contactPosition?.x ?? otherPosition.x) - otherPosition.x) / Math.max(otherSize.x / 2, 1e-6),\n\t\t\t\ty: ((selfPosition?.y ?? contactPosition?.y ?? otherPosition.y) - otherPosition.y) / Math.max(otherSize.y / 2, 1e-6),\n\t\t\t\tz: 0,\n\t\t\t};\n\t\t}\n\n\t\tconst tangent = {\n\t\t\tx: velocity.x - this.dot(velocity, normal) * normal.x,\n\t\t\ty: velocity.y - this.dot(velocity, normal) * normal.y,\n\t\t\tz: velocity.z - this.dot(velocity, normal) * normal.z,\n\t\t};\n\t\tconst tangentLength = length3(tangent.x, tangent.y, tangent.z);\n\t\tif (tangentLength <= 1e-6) {\n\t\t\treturn { x: 0, y: 0, z: 0 };\n\t\t}\n\t\treturn {\n\t\t\tx: tangent.x / tangentLength,\n\t\t\ty: tangent.y / tangentLength,\n\t\t\tz: tangent.z / tangentLength,\n\t\t};\n\t}\n\n\tprivate getDominantAxis(vector: { x: number; y: number; z: number }): 'x' | 'y' | 'z' {\n\t\tconst absX = Math.abs(vector.x);\n\t\tconst absY = Math.abs(vector.y);\n\t\tconst absZ = Math.abs(vector.z);\n\t\tif (absX >= absY && absX >= absZ) return 'x';\n\t\tif (absY >= absX && absY >= absZ) return 'y';\n\t\treturn 'z';\n\t}\n\n\tprivate applySpeedClamp(\n\t\tvelocity: { x: number; y: number; z: number },\n\t\tminSpeed: number,\n\t\tmaxSpeed: number,\n\t): { x: number; y: number; z: number } {\n\t\tconst currentSpeed = length3(velocity.x, velocity.y, velocity.z);\n\t\tif (currentSpeed === 0) return velocity;\n\n\t\tconst targetSpeed = clamp(currentSpeed, minSpeed, maxSpeed);\n\t\tconst scale = targetSpeed / currentSpeed;\n\t\treturn {\n\t\t\tx: velocity.x * scale,\n\t\t\ty: velocity.y * scale,\n\t\t\tz: velocity.z * scale,\n\t\t};\n\t}\n\n\tprivate dispatch(event: Ricochet3DEvent): void {\n\t\tif (this.machine.can(event)) {\n\t\t\tthis.machine.syncDispatch(event);\n\t\t}\n\t}\n}\n","import { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport {\n\tRicochet3DFSM,\n\ttype Ricochet3DResult,\n\ttype Ricochet3DCollisionContext,\n\ttype Ricochet3DCallback,\n} from './ricochet-3d-fsm';\nimport {\n\tStageRicochetDim,\n\tStageRicochetReflection,\n\ttype BehaviorRuntime,\n} from '../../runtime/wasm-stage-runtime';\n\nexport type { Ricochet3DResult };\n\nexport interface Ricochet3DOptions {\n\tminSpeed: number;\n\tmaxSpeed: number;\n\tspeedMultiplier: number;\n\treflectionMode: 'simple' | 'angled';\n\tmaxAngleDeg: number;\n}\n\nexport interface Ricochet3DHandle {\n\tgetRicochet(ctx: Ricochet3DCollisionContext): Ricochet3DResult | null;\n\tapplyRicochet(ctx: Ricochet3DCollisionContext): boolean;\n\tgetLastResult(): Ricochet3DResult | null;\n\tonRicochet(callback: Ricochet3DCallback): () => void;\n}\n\nconst defaultOptions: Ricochet3DOptions = {\n\tminSpeed: 2,\n\tmaxSpeed: 20,\n\tspeedMultiplier: 1.05,\n\treflectionMode: 'angled',\n\tmaxAngleDeg: 45,\n};\n\nconst RICOCHET_3D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:ricochet-3d');\n\nfunction createRicochet3DHandle(\n\tref: BehaviorRef<Ricochet3DOptions>,\n): Ricochet3DHandle {\n\treturn {\n\t\tgetRicochet: (ctx: Ricochet3DCollisionContext) => {\n\t\t\tconst fsm = ref.fsm as Ricochet3DFSM | undefined;\n\t\t\tif (!fsm) return null;\n\t\t\treturn fsm.computeRicochet(ctx, ref.options);\n\t\t},\n\t\tapplyRicochet: (ctx: Ricochet3DCollisionContext): boolean => {\n\t\t\tconst fsm = ref.fsm as Ricochet3DFSM | undefined;\n\t\t\tif (!fsm || fsm.isOnCooldown()) return false;\n\n\t\t\tconst result = fsm.computeRicochet(ctx, ref.options);\n\t\t\tif (!result) return false;\n\n\t\t\tconst entity = ctx.entity as any;\n\t\t\tif (entity?.transformStore) {\n\t\t\t\tentity.transformStore.velocity.x = result.velocity.x;\n\t\t\t\tentity.transformStore.velocity.y = result.velocity.y;\n\t\t\t\tentity.transformStore.velocity.z = result.velocity.z;\n\t\t\t\tentity.transformStore.dirty.velocityX = true;\n\t\t\t\tentity.transformStore.dirty.velocityY = true;\n\t\t\t\tentity.transformStore.dirty.velocityZ = true;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t\tgetLastResult: () => {\n\t\t\tconst fsm = ref.fsm as Ricochet3DFSM | undefined;\n\t\t\treturn fsm?.getLastResult() ?? null;\n\t\t},\n\t\tonRicochet: (callback: Ricochet3DCallback) => {\n\t\t\tconst fsm = ref.fsm as Ricochet3DFSM | undefined;\n\t\t\tif (!fsm) {\n\t\t\t\tif (!(ref as any).pendingListeners) {\n\t\t\t\t\t(ref as any).pendingListeners = [];\n\t\t\t\t}\n\t\t\t\t(ref as any).pendingListeners.push(callback);\n\t\t\t\treturn () => {\n\t\t\t\t\tconst pending = (ref as any).pendingListeners as Ricochet3DCallback[];\n\t\t\t\t\tconst index = pending.indexOf(callback);\n\t\t\t\t\tif (index >= 0) pending.splice(index, 1);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn fsm.addListener(callback);\n\t\t},\n\t};\n}\n\nclass Ricochet3DSystem implements BehaviorSystem {\n\tprivate elapsedMs = 0;\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate wasmStage: BehaviorRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, delta: number): void {\n\t\tthis.elapsedMs += delta * 1000;\n\n\t\tconst links = this.getBehaviorLinks?.(RICOCHET_3D_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst ref = link.ref as any;\n\t\t\tconst gameEntity = link.entity as any;\n\t\t\tif (!ref.fsm) {\n\t\t\t\tref.fsm = new Ricochet3DFSM();\n\t\t\t\tconst pending = ref.pendingListeners as Ricochet3DCallback[] | undefined;\n\t\t\t\tif (pending) {\n\t\t\t\t\tfor (const callback of pending) {\n\t\t\t\t\t\tref.fsm.addListener(callback);\n\t\t\t\t\t}\n\t\t\t\t\tref.pendingListeners = [];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tref.fsm.setCurrentTimeMs(this.elapsedMs);\n\n\t\t\tconst handle = (gameEntity?.runtimeHandle ?? -1) as number;\n\t\t\tif (this.wasmStage && handle >= 0) {\n\t\t\t\tthis.ensureWasmAttached(handle, ref.options as Ricochet3DOptions);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: Ricochet3DOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tconst reflectionMode = options.reflectionMode === 'simple'\n\t\t\t? StageRicochetReflection.Mirror\n\t\t\t: StageRicochetReflection.Angled;\n\t\tthis.wasmStage.attachRicochet(handle, StageRicochetDim.Three, {\n\t\t\tminSpeed: options.minSpeed,\n\t\t\tmaxSpeed: options.maxSpeed,\n\t\t\tspeedMultiplier: options.speedMultiplier,\n\t\t\tmaxAngleDeg: options.maxAngleDeg,\n\t\t\treflectionMode,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tconst links = this.getBehaviorLinks?.(RICOCHET_3D_BEHAVIOR_KEY);\n\t\tif (links) {\n\t\t\tfor (const link of links) {\n\t\t\t\tconst ref = link.ref as any;\n\t\t\t\tref.fsm?.resetCooldown();\n\t\t\t}\n\t\t}\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\nexport const Ricochet3DBehavior = defineBehavior({\n\tname: 'ricochet-3d',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew Ricochet3DSystem(ctx.was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EAEA,QAAQ,MAAqB;AAC5B,UAAM,QAAQ,KAAK,mBAAmB,wBAAwB;AAC9D,QAAI,OAAO;AACV,iBAAW,QAAQ,OAAO;AACzB,cAAM,MAAM,KAAK;AACjB,YAAI,KAAK,cAAc;AAAA,MACxB;AAAA,IACD;AACA,SAAK,qBAAqB,MAAM;AAAA,EACjC;AACD;AAEO,IAAM,qBAAqB,eAAe;AAAA,EAChD,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,QACf,IAAI,iBAAiB,IAAI,aAAa,MAAM,IAAI,gBAAgB;AAAA,EACjE,cAAc;AACf,CAAC;","names":["Ricochet3DState","Ricochet3DEvent"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/first-person/components.ts"],"sourcesContent":["/**\n * First Person Controller ECS Components\n *\n * Components for first-person movement and camera control:\n * - Movement configuration (walk/run speed, sensitivity, eye height)\n * - Input intent (WASD movement + mouse look deltas)\n * - Runtime state (yaw, pitch, speed)\n */\n\n// ─────────────────────────────────────────────────────────────────────────────\n// FirstPersonMovementComponent (capability / configuration)\n// Defines movement capabilities and look parameters\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface FirstPersonMovementComponent {\n\t/** Base walking speed (units/sec) */\n\twalkSpeed: number;\n\t/** Sprint/run speed (units/sec) */\n\trunSpeed: number;\n\t/** Look sensitivity multiplier applied to raw input deltas */\n\tlookSensitivity: number;\n\t/** Vertical offset above entity position for eye/camera placement */\n\teyeHeight: number;\n}\n\nexport function createFirstPersonMovementComponent(\n\toptions: Partial<FirstPersonMovementComponent> = {},\n): FirstPersonMovementComponent {\n\treturn {\n\t\twalkSpeed: options.walkSpeed ?? 8,\n\t\trunSpeed: options.runSpeed ?? 16,\n\t\tlookSensitivity: options.lookSensitivity ?? 2,\n\t\teyeHeight: options.eyeHeight ?? 1.7,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// FirstPersonInputComponent (intent)\n// Written by: Player controller (game.onUpdate / entity.onUpdate)\n// Read by: FirstPersonSystem\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface FirstPersonInputComponent {\n\t/** Horizontal movement input (-1 to 1, strafe) */\n\tmoveX: number;\n\t/** Forward/backward movement input (-1 to 1) */\n\tmoveZ: number;\n\t/** Horizontal look delta (mouse/stick, raw value before sensitivity) */\n\tlookX: number;\n\t/** Vertical look delta (mouse/stick, raw value before sensitivity) */\n\tlookY: number;\n\t/** Sprint button held */\n\tsprint: boolean;\n}\n\nexport function createFirstPersonInputComponent(): FirstPersonInputComponent {\n\treturn {\n\t\tmoveX: 0,\n\t\tmoveZ: 0,\n\t\tlookX: 0,\n\t\tlookY: 0,\n\t\tsprint: false,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// FirstPersonStateComponent (runtime state)\n// Tracks the current state of the first-person entity\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface FirstPersonStateComponent {\n\t/** Current yaw in radians */\n\tyaw: number;\n\t/** Current pitch in radians */\n\tpitch: number;\n\t/** Current movement speed being applied */\n\tcurrentSpeed: number;\n}\n\nexport function createFirstPersonStateComponent(): FirstPersonStateComponent {\n\treturn {\n\t\tyaw: 0,\n\t\tpitch: 0,\n\t\tcurrentSpeed: 0,\n\t};\n}\n"],"mappings":";AAyBO,SAAS,mCACf,UAAiD,CAAC,GACnB;AAC/B,SAAO;AAAA,IACN,WAAW,QAAQ,aAAa;AAAA,IAChC,UAAU,QAAQ,YAAY;AAAA,IAC9B,iBAAiB,QAAQ,mBAAmB;AAAA,IAC5C,WAAW,QAAQ,aAAa;AAAA,EACjC;AACD;AAqBO,SAAS,kCAA6D;AAC5E,SAAO;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,EACT;AACD;AAgBO,SAAS,kCAA6D;AAC5E,SAAO;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,EACf;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/shared/direction-2d.ts"],"sourcesContent":["export interface Direction2D {\n\tx: number;\n\ty: number;\n}\n\nconst DIRECTION_EPSILON = 1e-6;\n\nexport function normalizeDirection2D(x: number, y: number): Direction2D | null {\n\tconst length = Math.hypot(x, y);\n\tif (length <= DIRECTION_EPSILON) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tx: x / length,\n\t\ty: y / length,\n\t};\n}\n\n/**\n * Allocation-free variant of {@link normalizeDirection2D} for per-frame paths.\n * Writes the normalized direction into `out` and returns true, or returns\n * false (leaving `out` untouched) when the input is effectively zero-length.\n */\nexport function normalizeDirection2DInto(\n\tx: number,\n\ty: number,\n\tout: Direction2D,\n): boolean {\n\tconst length = Math.hypot(x, y);\n\tif (length <= DIRECTION_EPSILON) {\n\t\treturn false;\n\t}\n\n\tout.x = x / length;\n\tout.y = y / length;\n\treturn true;\n}\n\nexport function angleFromDirection2D(direction: Direction2D): number {\n\treturn Math.atan2(-direction.x, direction.y);\n}\n\nexport function directionFromAngle2D(angle: number): Direction2D {\n\treturn {\n\t\tx: Math.sin(-angle),\n\t\ty: Math.cos(-angle),\n\t};\n}\n\nexport function rightFromAngle2D(angle: number): Direction2D {\n\treturn {\n\t\tx: Math.cos(angle),\n\t\ty: Math.sin(angle),\n\t};\n}\n\nexport function rotateLocalOffset2D(\n\toffset: Direction2D,\n\tangle: number,\n): Direction2D {\n\tconst right = rightFromAngle2D(angle);\n\tconst forward = directionFromAngle2D(angle);\n\treturn {\n\t\tx: right.x * offset.x + forward.x * offset.y,\n\t\ty: right.y * offset.x + forward.y * offset.y,\n\t};\n}\n\nexport function getRotationAngle2D(\n\trotation: { x: number; y: number; z: number; w: number },\n): number {\n\treturn Math.atan2(\n\t\t2 * (rotation.w * rotation.z + rotation.x * rotation.y),\n\t\t1 - 2 * (rotation.y * rotation.y + rotation.z * rotation.z),\n\t);\n}\n"],"mappings":";AAKA,IAAM,oBAAoB;AAEnB,SAAS,qBAAqB,GAAW,GAA+B;AAC9E,QAAM,SAAS,KAAK,MAAM,GAAG,CAAC;AAC9B,MAAI,UAAU,mBAAmB;AAChC,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,GAAG,IAAI;AAAA,IACP,GAAG,IAAI;AAAA,EACR;AACD;AAsBO,SAAS,qBAAqB,WAAgC;AACpE,SAAO,KAAK,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;AAC5C;AAEO,SAAS,qBAAqB,OAA4B;AAChE,SAAO;AAAA,IACN,GAAG,KAAK,IAAI,CAAC,KAAK;AAAA,IAClB,GAAG,KAAK,IAAI,CAAC,KAAK;AAAA,EACnB;AACD;AAEO,SAAS,iBAAiB,OAA4B;AAC5D,SAAO;AAAA,IACN,GAAG,KAAK,IAAI,KAAK;AAAA,IACjB,GAAG,KAAK,IAAI,KAAK;AAAA,EAClB;AACD;AAEO,SAAS,oBACf,QACA,OACc;AACd,QAAM,QAAQ,iBAAiB,KAAK;AACpC,QAAM,UAAU,qBAAqB,KAAK;AAC1C,SAAO;AAAA,IACN,GAAG,MAAM,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO;AAAA,IAC3C,GAAG,MAAM,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO;AAAA,EAC5C;AACD;AAEO,SAAS,mBACf,UACS;AACT,SAAO,KAAK;AAAA,IACX,KAAK,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS;AAAA,IACrD,IAAI,KAAK,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS;AAAA,EAC1D;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/coordinators/shared/top-down-aim.ts"],"sourcesContent":["import {\n\tangleFromDirection2D,\n\tdirectionFromAngle2D,\n\tgetRotationAngle2D,\n\tnormalizeDirection2D,\n} from '../../behaviors/shared/direction-2d';\n\nexport interface ResolvedAim2D {\n\tangle: number;\n\tdirection: { x: number; y: number };\n\thasAimInput: boolean;\n}\n\n/**\n * Minimal entity slice needed to derive a 2D facing angle. Structurally\n * satisfied by `Shooter2DSourceEntity` and the engine entity.\n */\nexport interface FacingAngle2DEntity {\n\ttopDownMovementState?: { facingAngle: number };\n\tbody?: {\n\t\trotation?: () => { x: number; y: number; z: number; w: number };\n\t} | null;\n\t/** Cached Z rotation maintained by 2D rotation helpers. */\n\t_rotation2DAngle?: number;\n}\n\nexport function getEntityFacingAngle2D(entity: FacingAngle2DEntity): number {\n\tif (entity.topDownMovementState) {\n\t\treturn entity.topDownMovementState.facingAngle;\n\t}\n\n\tif (entity.body?.rotation) {\n\t\treturn getRotationAngle2D(entity.body.rotation());\n\t}\n\n\treturn entity._rotation2DAngle ?? 0;\n}\n\nexport function resolveAim2D(\n\taimX: number,\n\taimY: number,\n\tfallbackAngle: number,\n): ResolvedAim2D {\n\tconst direction = normalizeDirection2D(aimX, aimY);\n\tif (direction) {\n\t\treturn {\n\t\t\tangle: angleFromDirection2D(direction),\n\t\t\tdirection,\n\t\t\thasAimInput: true,\n\t\t};\n\t}\n\n\treturn {\n\t\tangle: fallbackAngle,\n\t\tdirection: directionFromAngle2D(fallbackAngle),\n\t\thasAimInput: false,\n\t};\n}\n"],"mappings":";;;;;;;;AA0BO,SAAS,uBAAuB,QAAqC;AAC3E,MAAI,OAAO,sBAAsB;AAChC,WAAO,OAAO,qBAAqB;AAAA,EACpC;AAEA,MAAI,OAAO,MAAM,UAAU;AAC1B,WAAO,mBAAmB,OAAO,KAAK,SAAS,CAAC;AAAA,EACjD;AAEA,SAAO,OAAO,oBAAoB;AACnC;AAEO,SAAS,aACf,MACA,MACA,eACgB;AAChB,QAAM,YAAY,qBAAqB,MAAM,IAAI;AACjD,MAAI,WAAW;AACd,WAAO;AAAA,MACN,OAAO,qBAAqB,SAAS;AAAA,MACrC;AAAA,MACA,aAAa;AAAA,IACd;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,WAAW,qBAAqB,aAAa;AAAA,IAC7C,aAAa;AAAA,EACd;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/screen-visibility/screen-visibility.descriptor.ts","../src/lib/behaviors/screen-visibility/screen-visibility-fsm.ts"],"sourcesContent":["import {\n\tBox3,\n\tFrustum,\n\tMatrix4,\n\tQuaternion,\n\tVector3,\n\ttype Object3D,\n} from 'three';\n\nimport { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport { ScreenVisibilityFSM, type ScreenVisibilitySnapshot } from './screen-visibility-fsm';\nimport type { GameEntity } from '../../entities/entity';\nimport type { ZylemCamera } from '../../camera/zylem-camera';\n\nexport interface ScreenVisibilitySize {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\nexport interface ScreenVisibilityChangeContext {\n\tentity: GameEntity<any>;\n\tvisible: boolean;\n\twasVisible: boolean;\n\tjustEntered: boolean;\n\tjustExited: boolean;\n\tvisibleCameraNames: string[];\n\tcameraName: string | null;\n}\n\nexport interface ScreenVisibilityOptions {\n\t/**\n\t * Restrict visibility checks to one active camera by name.\n\t * When omitted, any active camera can make the entity visible.\n\t */\n\tcameraName: string | null;\n\t/**\n\t * Require the full entity bounds to remain inside the camera frustum.\n\t * Defaults to partial visibility (any intersection counts).\n\t */\n\trequireFullyVisible: boolean;\n\t/**\n\t * Expand or shrink the computed bounds in world units.\n\t * Positive values make visibility checks more generous.\n\t */\n\tpadding: number;\n\t/**\n\t * Optional bounds to use when the entity has no renderable mesh/group.\n\t * Falls back to the entity's configured size when available.\n\t */\n\tfallbackSize: ScreenVisibilitySize | null;\n\tonChange?: (context: ScreenVisibilityChangeContext) => void;\n\tonEnter?: (context: ScreenVisibilityChangeContext) => void;\n\tonExit?: (context: ScreenVisibilityChangeContext) => void;\n}\n\nexport interface ScreenVisibilityHandle {\n\tisVisible(): boolean;\n\tisOffscreen(): boolean;\n\twasJustEntered(): boolean;\n\twasJustExited(): boolean;\n\tgetVisibleCameraNames(): string[];\n\tgetState(): ScreenVisibilitySnapshot | null;\n}\n\nconst defaultOptions: ScreenVisibilityOptions = {\n\tcameraName: null,\n\trequireFullyVisible: false,\n\tpadding: 0,\n\tfallbackSize: null,\n\tonChange: undefined,\n\tonEnter: undefined,\n\tonExit: undefined,\n};\n\nconst SCREEN_VISIBILITY_BEHAVIOR_KEY = Symbol.for(\n\t'zylem:behavior:screen-visibility',\n);\n\nclass ScreenVisibilitySystem implements BehaviorSystem {\n\tprivate readonly worldBounds = new Box3();\n\tprivate readonly projectionMatrix = new Matrix4();\n\tprivate readonly frustum = new Frustum();\n\tprivate readonly savedPosition = new Vector3();\n\tprivate readonly savedQuaternion = new Quaternion();\n\tprivate readonly worldPosition = new Vector3();\n\tprivate readonly fallbackMin = new Vector3();\n\tprivate readonly fallbackMax = new Vector3();\n\tprivate readonly corners = Array.from({ length: 8 }, () => new Vector3());\n\tprivate readonly boundsCache = new Map<string, {\n\t\tbounds: Box3;\n\t\tkey: string;\n\t}>();\n\n\tconstructor(\n\t\tprivate scene: any,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) { }\n\n\tupdate(_ecs: unknown, _delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(SCREEN_VISIBILITY_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst entity = link.entity as GameEntity<any>;\n\t\t\tconst visibilityRef = link.ref as BehaviorRef<ScreenVisibilityOptions>;\n\t\t\tconst options = visibilityRef.options;\n\n\t\t\tif (!visibilityRef.fsm) {\n\t\t\t\tvisibilityRef.fsm = new ScreenVisibilityFSM();\n\t\t\t}\n\n\t\t\tconst fsm = visibilityRef.fsm as ScreenVisibilityFSM;\n\t\t\tconst previousState = fsm.getState();\n\t\t\tconst cameras = this.resolveActiveCameras(options.cameraName);\n\t\t\tconst visibleCameraNames: string[] = [];\n\n\t\t\tconst bounds = this.computeWorldBounds(entity, visibilityRef, options);\n\t\t\tif (bounds) {\n\t\t\t\tfor (let index = 0; index < cameras.length; index++) {\n\t\t\t\t\tconst cameraRef = cameras[index];\n\t\t\t\t\tif (this.isBoundsVisible(bounds, cameraRef, options.requireFullyVisible)) {\n\t\t\t\t\t\tvisibleCameraNames.push(this.getCameraLabel(cameraRef, index));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfsm.update(visibleCameraNames.length > 0, visibleCameraNames);\n\t\t\tthis.notifyVisibilityChange(entity, options, previousState, fsm.getState());\n\t\t}\n\t}\n\n\tprivate resolveActiveCameras(cameraName: string | null): ZylemCamera[] {\n\t\tconst activeCameras = this.scene?.cameraManager?.activeCameras?.length\n\t\t\t? [...this.scene.cameraManager.activeCameras]\n\t\t\t: this.scene?.zylemCamera\n\t\t\t\t? [this.scene.zylemCamera]\n\t\t\t\t: [];\n\n\t\tif (!cameraName) {\n\t\t\treturn activeCameras;\n\t\t}\n\n\t\treturn activeCameras.filter((camera: ZylemCamera) => camera.name === cameraName);\n\t}\n\n\tprivate computeWorldBounds(\n\t\tentity: GameEntity<any>,\n\t\tref: BehaviorRef<ScreenVisibilityOptions>,\n\t\toptions: ScreenVisibilityOptions,\n\t): Box3 | null {\n\t\tconst cacheKey = this.getBoundsCacheKey(entity, options);\n\t\tconst cached = this.boundsCache.get(entity.uuid);\n\t\tif (cached && cached.key === cacheKey) {\n\t\t\treturn cached.bounds;\n\t\t}\n\n\t\tconst target = (entity.group ?? entity.mesh) as Object3D | undefined;\n\t\tthis.worldBounds.makeEmpty();\n\n\t\tif (target) {\n\t\t\tconst wasmPose = (entity as any).getPose?.();\n\t\t\tconst useWasm = wasmPose && (entity as any).runtimeHandle >= 0;\n\t\t\tconst body = useWasm ? null : (entity as any).body;\n\n\t\t\tif (useWasm || body) {\n\t\t\t\tthis.savedPosition.copy(target.position);\n\t\t\t\tthis.savedQuaternion.copy(target.quaternion);\n\n\t\t\t\tif (useWasm) {\n\t\t\t\t\ttarget.position.set(wasmPose.position.x, wasmPose.position.y, wasmPose.position.z);\n\t\t\t\t\tif (!(entity as any).controlledRotation) {\n\t\t\t\t\t\ttarget.quaternion.set(\n\t\t\t\t\t\t\twasmPose.rotation.x,\n\t\t\t\t\t\t\twasmPose.rotation.y,\n\t\t\t\t\t\t\twasmPose.rotation.z,\n\t\t\t\t\t\t\twasmPose.rotation.w,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst translation = body.translation();\n\t\t\t\t\ttarget.position.set(translation.x, translation.y, translation.z);\n\t\t\t\t\tif (!(entity as any).controlledRotation) {\n\t\t\t\t\t\tconst rotation = body.rotation();\n\t\t\t\t\t\ttarget.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttarget.updateWorldMatrix(true, true);\n\t\t\t\tthis.worldBounds.setFromObject(target);\n\n\t\t\t\ttarget.position.copy(this.savedPosition);\n\t\t\t\ttarget.quaternion.copy(this.savedQuaternion);\n\t\t\t\ttarget.updateWorldMatrix(true, true);\n\t\t\t} else {\n\t\t\t\ttarget.updateWorldMatrix(true, true);\n\t\t\t\tthis.worldBounds.setFromObject(target);\n\t\t\t}\n\t\t}\n\n\t\tif (this.worldBounds.isEmpty()) {\n\t\t\tconst fallbackSize = options.fallbackSize\n\t\t\t\t?? ((entity.options?.size as ScreenVisibilitySize | undefined) ?? null);\n\t\t\tthis.resolveFallbackCenter(entity, target);\n\n\t\t\tconst halfX = (fallbackSize?.x ?? 0) / 2;\n\t\t\tconst halfY = (fallbackSize?.y ?? 0) / 2;\n\t\t\tconst halfZ = (fallbackSize?.z ?? 0) / 2;\n\n\t\t\tthis.fallbackMin.set(\n\t\t\t\tthis.worldPosition.x - halfX,\n\t\t\t\tthis.worldPosition.y - halfY,\n\t\t\t\tthis.worldPosition.z - halfZ,\n\t\t\t);\n\t\t\tthis.fallbackMax.set(\n\t\t\t\tthis.worldPosition.x + halfX,\n\t\t\t\tthis.worldPosition.y + halfY,\n\t\t\t\tthis.worldPosition.z + halfZ,\n\t\t\t);\n\t\t\tthis.worldBounds.set(this.fallbackMin, this.fallbackMax);\n\t\t}\n\n\t\tif (options.padding !== 0) {\n\t\t\tthis.worldBounds.expandByScalar(options.padding);\n\t\t}\n\n\t\tif (this.worldBounds.isEmpty()) {\n\t\t\tthis.boundsCache.delete(entity.uuid);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst cachedBounds = cached?.bounds ?? new Box3();\n\t\tcachedBounds.copy(this.worldBounds);\n\t\tthis.boundsCache.set(entity.uuid, {\n\t\t\tbounds: cachedBounds,\n\t\t\tkey: cacheKey,\n\t\t});\n\t\t(ref as any).__screenVisibilityBoundsKey = cacheKey;\n\t\treturn cachedBounds;\n\t}\n\n\tprivate getBoundsCacheKey(\n\t\tentity: GameEntity<any>,\n\t\toptions: ScreenVisibilityOptions,\n\t): string {\n\t\tconst body = (entity as any).body;\n\t\tif (body) {\n\t\t\tconst translation = body.translation();\n\t\t\tconst rotation = body.rotation();\n\t\t\treturn [\n\t\t\t\t'b',\n\t\t\t\ttranslation.x.toFixed(3),\n\t\t\t\ttranslation.y.toFixed(3),\n\t\t\t\ttranslation.z.toFixed(3),\n\t\t\t\trotation.x.toFixed(3),\n\t\t\t\trotation.y.toFixed(3),\n\t\t\t\trotation.z.toFixed(3),\n\t\t\t\trotation.w.toFixed(3),\n\t\t\t\toptions.padding,\n\t\t\t\toptions.requireFullyVisible,\n\t\t\t\toptions.fallbackSize?.x ?? '',\n\t\t\t\toptions.fallbackSize?.y ?? '',\n\t\t\t\toptions.fallbackSize?.z ?? '',\n\t\t\t].join('|');\n\t\t}\n\n\t\tconst target = (entity.group ?? entity.mesh) as Object3D | undefined;\n\t\tif (target) {\n\t\t\tconst position = target.position;\n\t\t\tconst quaternion = target.quaternion;\n\t\t\tconst scale = target.scale;\n\t\t\treturn [\n\t\t\t\t'o',\n\t\t\t\tposition.x.toFixed(3),\n\t\t\t\tposition.y.toFixed(3),\n\t\t\t\tposition.z.toFixed(3),\n\t\t\t\tquaternion.x.toFixed(3),\n\t\t\t\tquaternion.y.toFixed(3),\n\t\t\t\tquaternion.z.toFixed(3),\n\t\t\t\tquaternion.w.toFixed(3),\n\t\t\t\tscale.x.toFixed(3),\n\t\t\t\tscale.y.toFixed(3),\n\t\t\t\tscale.z.toFixed(3),\n\t\t\t\toptions.padding,\n\t\t\t\toptions.requireFullyVisible,\n\t\t\t\toptions.fallbackSize?.x ?? '',\n\t\t\t\toptions.fallbackSize?.y ?? '',\n\t\t\t\toptions.fallbackSize?.z ?? '',\n\t\t\t].join('|');\n\t\t}\n\n\t\tconst position = entity.options?.position ?? { x: 0, y: 0, z: 0 };\n\t\tconst size = entity.options?.size ?? { x: 0, y: 0, z: 0 };\n\t\treturn [\n\t\t\t's',\n\t\t\tposition.x,\n\t\t\tposition.y,\n\t\t\tposition.z,\n\t\t\tsize.x,\n\t\t\tsize.y,\n\t\t\tsize.z,\n\t\t\toptions.padding,\n\t\t\toptions.requireFullyVisible,\n\t\t\toptions.fallbackSize?.x ?? '',\n\t\t\toptions.fallbackSize?.y ?? '',\n\t\t\toptions.fallbackSize?.z ?? '',\n\t\t].join('|');\n\t}\n\n\tprivate resolveFallbackCenter(\n\t\tentity: GameEntity<any>,\n\t\ttarget: Object3D | undefined,\n\t): void {\n\t\tconst body = (entity as any).body;\n\t\tif (body) {\n\t\t\tconst translation = body.translation();\n\t\t\tthis.worldPosition.set(translation.x, translation.y, translation.z);\n\t\t\treturn;\n\t\t}\n\n\t\tif (target) {\n\t\t\ttarget.updateWorldMatrix(true, false);\n\t\t\ttarget.getWorldPosition(this.worldPosition);\n\t\t\treturn;\n\t\t}\n\n\t\tconst position = entity.options?.position ?? { x: 0, y: 0, z: 0 };\n\t\tthis.worldPosition.set(position.x, position.y, position.z);\n\t}\n\n\tprivate isBoundsVisible(\n\t\tbounds: Box3,\n\t\tcameraRef: ZylemCamera,\n\t\trequireFullyVisible: boolean,\n\t): boolean {\n\t\tconst camera = cameraRef.camera;\n\t\tcamera.updateMatrixWorld(true);\n\t\tthis.projectionMatrix.multiplyMatrices(\n\t\t\tcamera.projectionMatrix,\n\t\t\tcamera.matrixWorldInverse,\n\t\t);\n\t\tthis.frustum.setFromProjectionMatrix(this.projectionMatrix);\n\n\t\tif (!requireFullyVisible) {\n\t\t\treturn this.frustum.intersectsBox(bounds);\n\t\t}\n\n\t\treturn this.getCorners(bounds).every((corner) => this.frustum.containsPoint(corner));\n\t}\n\n\tprivate getCorners(bounds: Box3): Vector3[] {\n\t\tconst { min, max } = bounds;\n\t\tthis.corners[0].set(min.x, min.y, min.z);\n\t\tthis.corners[1].set(min.x, min.y, max.z);\n\t\tthis.corners[2].set(min.x, max.y, min.z);\n\t\tthis.corners[3].set(min.x, max.y, max.z);\n\t\tthis.corners[4].set(max.x, min.y, min.z);\n\t\tthis.corners[5].set(max.x, min.y, max.z);\n\t\tthis.corners[6].set(max.x, max.y, min.z);\n\t\tthis.corners[7].set(max.x, max.y, max.z);\n\t\treturn this.corners;\n\t}\n\n\tprivate getCameraLabel(camera: ZylemCamera, index: number): string {\n\t\treturn camera.name || (index === 0 ? 'primary' : `camera-${index}`);\n\t}\n\n\tprivate notifyVisibilityChange(\n\t\tentity: GameEntity<any>,\n\t\toptions: ScreenVisibilityOptions,\n\t\tpreviousState: ScreenVisibilitySnapshot,\n\t\tnextState: ScreenVisibilitySnapshot,\n\t): void {\n\t\tif (!nextState.justEntered && !nextState.justExited) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst context: ScreenVisibilityChangeContext = {\n\t\t\tentity,\n\t\t\tvisible: nextState.visible,\n\t\t\twasVisible: previousState.visible,\n\t\t\tjustEntered: nextState.justEntered,\n\t\t\tjustExited: nextState.justExited,\n\t\t\tvisibleCameraNames: [...nextState.visibleCameraNames],\n\t\t\tcameraName: options.cameraName,\n\t\t};\n\n\t\tif (nextState.justEntered) {\n\t\t\toptions.onEnter?.(context);\n\t\t}\n\n\t\tif (nextState.justExited) {\n\t\t\toptions.onExit?.(context);\n\t\t}\n\n\t\toptions.onChange?.(context);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.boundsCache.clear();\n\t}\n}\n\nfunction createScreenVisibilityHandle(\n\tref: BehaviorRef<ScreenVisibilityOptions>,\n): ScreenVisibilityHandle {\n\treturn {\n\t\tisVisible: () => {\n\t\t\tconst fsm = ref.fsm as ScreenVisibilityFSM | undefined;\n\t\t\treturn fsm?.isVisible() ?? false;\n\t\t},\n\t\tisOffscreen: () => {\n\t\t\tconst fsm = ref.fsm as ScreenVisibilityFSM | undefined;\n\t\t\treturn !(fsm?.isVisible() ?? false);\n\t\t},\n\t\twasJustEntered: () => {\n\t\t\tconst fsm = ref.fsm as ScreenVisibilityFSM | undefined;\n\t\t\treturn fsm?.wasJustEntered() ?? false;\n\t\t},\n\t\twasJustExited: () => {\n\t\t\tconst fsm = ref.fsm as ScreenVisibilityFSM | undefined;\n\t\t\treturn fsm?.wasJustExited() ?? false;\n\t\t},\n\t\tgetVisibleCameraNames: () => {\n\t\t\tconst fsm = ref.fsm as ScreenVisibilityFSM | undefined;\n\t\t\treturn fsm?.getVisibleCameraNames() ?? [];\n\t\t},\n\t\tgetState: () => {\n\t\t\tconst fsm = ref.fsm as ScreenVisibilityFSM | undefined;\n\t\t\treturn fsm?.getState() ?? null;\n\t\t},\n\t};\n}\n\nexport const ScreenVisibilityBehavior = defineBehavior<\n\tScreenVisibilityOptions,\n\tScreenVisibilityHandle\n>({\n\tname: 'screen-visibility',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew ScreenVisibilitySystem(ctx.scene, ctx.getBehaviorLinks),\n\tcreateHandle: createScreenVisibilityHandle,\n});\n","export interface ScreenVisibilitySnapshot {\n\tinitialized: boolean;\n\tvisible: boolean;\n\tjustEntered: boolean;\n\tjustExited: boolean;\n\tvisibleCameraNames: string[];\n}\n\nexport class ScreenVisibilityFSM {\n\tprivate initialized = false;\n\tprivate visible = false;\n\tprivate justEntered = false;\n\tprivate justExited = false;\n\tprivate visibleCameraNames: string[] = [];\n\n\tupdate(visible: boolean, visibleCameraNames: readonly string[]): void {\n\t\tconst wasVisible = this.visible;\n\n\t\tthis.justEntered = !wasVisible && visible;\n\t\tthis.justExited = wasVisible && !visible;\n\n\t\tif (!this.initialized) {\n\t\t\tthis.justEntered = visible;\n\t\t\tthis.justExited = false;\n\t\t}\n\n\t\tthis.initialized = true;\n\t\tthis.visible = visible;\n\t\tthis.visibleCameraNames = [...visibleCameraNames];\n\t}\n\n\tisInitialized(): boolean {\n\t\treturn this.initialized;\n\t}\n\n\tisVisible(): boolean {\n\t\treturn this.visible;\n\t}\n\n\twasJustEntered(): boolean {\n\t\treturn this.justEntered;\n\t}\n\n\twasJustExited(): boolean {\n\t\treturn this.justExited;\n\t}\n\n\tgetVisibleCameraNames(): string[] {\n\t\treturn [...this.visibleCameraNames];\n\t}\n\n\tgetState(): ScreenVisibilitySnapshot {\n\t\treturn {\n\t\t\tinitialized: this.initialized,\n\t\t\tvisible: this.visible,\n\t\t\tjustEntered: this.justEntered,\n\t\t\tjustExited: this.justExited,\n\t\t\tvisibleCameraNames: this.getVisibleCameraNames(),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;;;ACCA,IAAM,sBAAN,MAA0B;AAAA,EACxB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,cAAc;AAAA,EACd,aAAa;AAAA,EACb,qBAA+B,CAAC;AAAA,EAExC,OAAO,SAAkB,oBAA6C;AACrE,UAAM,aAAa,KAAK;AAExB,SAAK,cAAc,CAAC,cAAc;AAClC,SAAK,aAAa,cAAc,CAAC;AAEjC,QAAI,CAAC,KAAK,aAAa;AACtB,WAAK,cA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MAAM;AAClB,YAAM,MAAM,IAAI;AAChB,aAAO,EAAE,KAAK,UAAU,KAAK;AAAA,IAC9B;AAAA,IACA,gBAAgB,MAAM;AACrB,YAAM,MAAM,IAAI;AAChB,aAAO,KAAK,eAAe,KAAK;AAAA,IACjC;AAAA,IACA,eAAe,MAAM;AACpB,YAAM,MAAM,IAAI;AAChB,aAAO,KAAK,cAAc,KAAK;AAAA,IAChC;AAAA,IACA,uBAAuB,MAAM;AAC5B,YAAM,MAAM,IAAI;AAChB,aAAO,KAAK,sBAAsB,KAAK,CAAC;AAAA,IACzC;AAAA,IACA,UAAU,MAAM;AACf,YAAM,MAAM,IAAI;AAChB,aAAO,KAAK,SAAS,KAAK;AAAA,IAC3B;AAAA,EACD;AACD;AAEO,IAAM,2BAA2B,eAGtC;AAAA,EACD,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,QACf,IAAI,uBAAuB,IAAI,OAAO,IAAI,gBAAgB;AAAA,EAC3D,cAAc;AACf,CAAC;","names":["position"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/world-boundary-3d/world-boundary-3d-fsm.ts","../src/lib/behaviors/world-boundary-3d/world-boundary-3d.descriptor.ts"],"sourcesContent":["import { SyncStateMachine, t } from '../../core/utility/sync-state-machine';\nimport {\n\tclampPointToBounds3D,\n\tcomputeBounds3DHits,\n\tconstrainMovementToBounds3D,\n\thasAnyBounds3DHit,\n\tinsetBounds3D,\n\ttype Bounds3DPaddingInput,\n\ttype Bounds3DPoint,\n} from '../shared/bounds-3d';\n\nexport type WorldBoundary3DHit =\n\t| 'top'\n\t| 'bottom'\n\t| 'left'\n\t| 'right'\n\t| 'back'\n\t| 'front';\n\nexport type WorldBoundary3DHits = Record<WorldBoundary3DHit, boolean>;\n\nexport interface WorldBoundary3DPosition extends Bounds3DPoint {}\n\nexport interface WorldBoundary3DBounds {\n\ttop: number;\n\tbottom: number;\n\tleft: number;\n\tright: number;\n\tback: number;\n\tfront: number;\n}\n\nexport enum WorldBoundary3DState {\n\tInside = 'inside',\n\tTouching = 'touching',\n}\n\nexport enum WorldBoundary3DEvent {\n\tEnterInside = 'enter-inside',\n\tTouchBoundary = 'touch-boundary',\n}\n\nexport function computeWorldBoundary3DHits(\n\tposition: WorldBoundary3DPosition,\n\tbounds: WorldBoundary3DBounds,\n\tpadding?: Bounds3DPaddingInput,\n): WorldBoundary3DHits {\n\treturn computeBounds3DHits(position, insetBounds3D({\n\t\tminX: bounds.left,\n\t\tmaxX: bounds.right,\n\t\tminY: bounds.bottom,\n\t\tmaxY: bounds.top,\n\t\tminZ: bounds.back,\n\t\tmaxZ: bounds.front,\n\t}, padding));\n}\n\nexport function hasAnyWorldBoundary3DHit(hits: WorldBoundary3DHits): boolean {\n\treturn hasAnyBounds3DHit(hits);\n}\n\nexport class WorldBoundary3DFSM {\n\tpublic readonly machine: SyncStateMachine<WorldBoundary3DState, WorldBoundary3DEvent, never>;\n\n\tprivate lastHits: WorldBoundary3DHits = {\n\t\ttop: false,\n\t\tbottom: false,\n\t\tleft: false,\n\t\tright: false,\n\t\tback: false,\n\t\tfront: false,\n\t};\n\tprivate lastPosition: WorldBoundary3DPosition | null = null;\n\tprivate lastClampedPosition: WorldBoundary3DPosition | null = null;\n\tprivate lastUpdatedAtMs: number | null = null;\n\n\tconstructor() {\n\t\tthis.machine = new SyncStateMachine<WorldBoundary3DState, WorldBoundary3DEvent, never>(\n\t\t\tWorldBoundary3DState.Inside,\n\t\t\t[\n\t\t\t\tt(WorldBoundary3DState.Inside, WorldBoundary3DEvent.TouchBoundary, WorldBoundary3DState.Touching),\n\t\t\t\tt(WorldBoundary3DState.Touching, WorldBoundary3DEvent.EnterInside, WorldBoundary3DState.Inside),\n\t\t\t\tt(WorldBoundary3DState.Inside, WorldBoundary3DEvent.EnterInside, WorldBoundary3DState.Inside),\n\t\t\t\tt(WorldBoundary3DState.Touching, WorldBoundary3DEvent.TouchBoundary, WorldBoundary3DState.Touching),\n\t\t\t],\n\t\t);\n\t}\n\n\tgetState(): WorldBoundary3DState {\n\t\treturn this.machine.getState();\n\t}\n\n\tgetLastHits(): WorldBoundary3DHits {\n\t\treturn this.lastHits;\n\t}\n\n\tgetMovement(\n\t\tmoveX: number,\n\t\tmoveY: number,\n\t\tmoveZ: number,\n\t): { moveX: number; moveY: number; moveZ: number } {\n\t\treturn constrainMovementToBounds3D(this.lastHits, moveX, moveY, moveZ);\n\t}\n\n\tgetLastPosition(): WorldBoundary3DPosition | null {\n\t\treturn this.lastPosition;\n\t}\n\n\tgetLastClampedPosition(): WorldBoundary3DPosition | null {\n\t\treturn this.lastClampedPosition;\n\t}\n\n\tgetLastUpdatedAtMs(): number | null {\n\t\treturn this.lastUpdatedAtMs;\n\t}\n\n\tupdate(\n\t\tposition: WorldBoundary3DPosition,\n\t\tbounds: WorldBoundary3DBounds,\n\t\tpadding?: Bounds3DPaddingInput,\n\t): WorldBoundary3DHits {\n\t\tconst effectiveBounds = insetBounds3D({\n\t\t\tminX: bounds.left,\n\t\t\tmaxX: bounds.right,\n\t\t\tminY: bounds.bottom,\n\t\t\tmaxY: bounds.top,\n\t\t\tminZ: bounds.back,\n\t\t\tmaxZ: bounds.front,\n\t\t}, padding);\n\n\t\tconst hits = computeBounds3DHits(position, effectiveBounds);\n\t\tthis.lastHits = hits;\n\t\tthis.lastPosition = { x: position.x, y: position.y, z: position.z };\n\t\tthis.lastClampedPosition = clampPointToBounds3D(position, effectiveBounds);\n\t\tthis.lastUpdatedAtMs = Date.now();\n\n\t\tif (hasAnyWorldBoundary3DHit(hits)) {\n\t\t\tthis.dispatch(WorldBoundary3DEvent.TouchBoundary);\n\t\t} else {\n\t\t\tthis.dispatch(WorldBoundary3DEvent.EnterInside);\n\t\t}\n\n\t\treturn hits;\n\t}\n\n\tprivate dispatch(event: WorldBoundary3DEvent): void {\n\t\tif (this.machine.can(event)) {\n\t\t\tthis.machine.syncDispatch(event);\n\t\t}\n\t}\n}\n","import { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport type { Bounds3DPaddingInput } from '../shared/bounds-3d';\nimport {\n\tWorldBoundary3DFSM,\n\ttype WorldBoundary3DBounds,\n\ttype WorldBoundary3DHits,\n\ttype WorldBoundary3DPosition,\n} from './world-boundary-3d-fsm';\nimport {\n\tStageBoundaryDim,\n\ttype BehaviorRuntime,\n} from '../../runtime/wasm-stage-runtime';\n\nexport interface WorldBoundary3DOptions {\n\tboundaries: WorldBoundary3DBounds;\n\tpadding?: Bounds3DPaddingInput;\n}\n\nexport interface WorldBoundary3DHandle {\n\tgetLastHits(): WorldBoundary3DHits | null;\n\tgetMovement(\n\t\tmoveX: number,\n\t\tmoveY: number,\n\t\tmoveZ: number,\n\t): { moveX: number; moveY: number; moveZ: number };\n\tgetLastClampedPosition(): WorldBoundary3DPosition | null;\n}\n\nconst defaultOptions: WorldBoundary3DOptions = {\n\tboundaries: { top: 0, bottom: 0, left: 0, right: 0, back: 0, front: 0 },\n\tpadding: 0,\n};\n\nconst WORLD_BOUNDARY_3D_BEHAVIOR_KEY = Symbol.for(\n\t'zylem:behavior:world-boundary-3d',\n);\n\nfunction createWorldBoundary3DHandle(\n\tref: BehaviorRef<WorldBoundary3DOptions>,\n): WorldBoundary3DHandle {\n\treturn {\n\t\tgetLastHits: () => {\n\t\t\tconst fsm = ref.fsm as WorldBoundary3DFSM | undefined;\n\t\t\treturn fsm?.getLastHits() ?? null;\n\t\t},\n\t\tgetMovement: (moveX: number, moveY: number, moveZ: number) => {\n\t\t\tconst fsm = ref.fsm as WorldBoundary3DFSM | undefined;\n\t\t\treturn fsm?.getMovement(moveX, moveY, moveZ) ?? { moveX, moveY, moveZ };\n\t\t},\n\t\tgetLastClampedPosition: () => {\n\t\t\tconst fsm = ref.fsm as WorldBoundary3DFSM | undefined;\n\t\t\treturn fsm?.getLastClampedPosition() ?? null;\n\t\t},\n\t};\n}\n\nclass WorldBoundary3DSystem implements BehaviorSystem {\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate wasmStage: BehaviorRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, _delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(WORLD_BOUNDARY_3D_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst gameEntity = link.entity as any;\n\t\t\tconst boundaryRef = link.ref as any;\n\t\t\tconst options = boundaryRef.options as WorldBoundary3DOptions;\n\t\t\tif (!boundaryRef.fsm) {\n\t\t\t\tboundaryRef.fsm = new WorldBoundary3DFSM();\n\t\t\t}\n\n\t\t\tconst handle = (gameEntity.runtimeHandle ?? -1) as number;\n\t\t\tif (!this.wasmStage || handle < 0) continue;\n\n\t\t\tthis.ensureWasmAttached(handle, options);\n\t\t\tconst query = this.wasmStage.queryWorldBoundary(handle);\n\t\t\tif (query) {\n\t\t\t\tboundaryRef.fsm.update(\n\t\t\t\t\t{ x: query.clamped[0], y: query.clamped[1], z: query.clamped[2] },\n\t\t\t\t\toptions.boundaries,\n\t\t\t\t\toptions.padding,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: WorldBoundary3DOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tconst padding = typeof options.padding === 'number' ? options.padding : 0;\n\t\tthis.wasmStage.attachWorldBoundary(handle, StageBoundaryDim.Three, {\n\t\t\ttop: options.boundaries.top,\n\t\t\tbottom: options.boundaries.bottom,\n\t\t\tleft: options.boundaries.left,\n\t\t\tright: options.boundaries.right,\n\t\t\tfront: options.boundaries.front,\n\t\t\tback: options.boundaries.back,\n\t\t\tpadding,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\nexport const WorldBoundary3DBehavior = defineBehavior({\n\tname: 'world-boundary-3d',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew WorldBoundary3DSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),\n\tcreateHandle: createWorldBoundary3DHandle,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCO,IAAK,uBAAL,kBAAKA,0BAAL;AACN,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,cAAW;AAFA,SAAAA;AAAA,GAAA;AAKL,IAAK,uBAAL,kBAAKC,0BAAL;AACN,EAAAA,sBAAA,iBAAc;AACd,EAAAA,sBAAA,mBAAgB;AAFL,SAAAA;AAAA,GAAA;AAKL,SAAS,2BACf,UACA,QACA,SACsB;AACtB,SAAO,oBAAoB,UAAU,cAAc;AAAA,IAClD,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,EACd,GAAG,OAAO,CAAC;AACZ;AAEO,SAAS,yBAAyB,MAAoC;AAC5E,SAAO,kBAAkB,IAAI;AAC9B;AAEO,IAAM,qBAAN,MAAyB;AAAA,EACf;AAAA,EAER,WAAgC;AAAA,IACvC,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACQ,eAA+C;AAAA,EAC/C,sBAAsD;AAAA,EACtD,kBAAiC;AAAA,EAEzC,cAAc;AACb,SAAK,UAAU,IAAI;AAAA,MAClB;AAAA,MACA;AAAA,YACC,yBAAE,uBAA6B,sCAAoC,yBAA6B;AAAA,YAChG,yBAAE,2BAA+B,kCAAkC,qBAA2B;AAAA,YAC9F,yBAAE,uBAA6B,kCAAkC,qBAA2B;AAAA,YAC5F,yBAAE,2BAA+B,sCAAoC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A,EACD;AAAA,EAEQ,mBAAmB,QAAgB,SAAuC;AACjF,QAAI,CAAC,KAAK,aAAa,KAAK,qBAAqB,IAAI,MAAM,EAAG;AAC9D,UAAM,UAAU,OAAO,QAAQ,YAAY,WAAW,QAAQ,UAAU;AACxE,SAAK,UAAU,oBAAoB,QAAQ,iBAAiB,OAAO;AAAA,MAClE,KAAK,QAAQ,WAAW;AAAA,MACxB,QAAQ,QAAQ,WAAW;AAAA,MAC3B,MAAM,QAAQ,WAAW;AAAA,MACzB,OAAO,QAAQ,WAAW;AAAA,MAC1B,OAAO,QAAQ,WAAW;AAAA,MAC1B,MAAM,QAAQ,WAAW;AAAA,MACzB;AAAA,IACD,CAAC;AACD,SAAK,qBAAqB,IAAI,MAAM;AAAA,EACrC;AAAA,EAEA,QAAQ,MAAqB;AAC5B,SAAK,qBAAqB,MAAM;AAAA,EACjC;AACD;AAEO,IAAM,0BAA0B,eAAe;AAAA,EACrD,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,QACf,IAAI,sBAAsB,IAAI,aAAa,MAAM,IAAI,gBAAgB;AAAA,EACtE,cAAc;AACf,CAAC;","names":["WorldBoundary3DState","WorldBoundary3DEvent"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/top-down-movement/top-down-movement.descriptor.ts"],"sourcesContent":["import { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport {\n\tcreateTopDownMovementComponent,\n\tcreateTopDownMovementInputComponent,\n\tcreateTopDownMovementStateComponent,\n} from './components';\nimport type {\n\tTopDownMovementComponent,\n\tTopDownMovementInputComponent,\n\tTopDownMovementStateComponent,\n} from './components';\nimport {\n\tStageTopDownPlane,\n\ttype BehaviorRuntime,\n} from '../../runtime/wasm-stage-runtime';\nimport { resolveAim2D } from '../../coordinators/shared/top-down-aim';\n\n/**\n * Entity with top-down movement components (input written by the game,\n * simulation owned by the wasm runtime).\n */\nexport interface TopDownMovementEntity {\n\ttopDownMovement: TopDownMovementComponent;\n\t$topDownMovement: TopDownMovementInputComponent;\n\ttopDownMovementState: TopDownMovementStateComponent;\n}\n\nexport interface TopDownMovementBehaviorOptions {\n\tmoveSpeed?: number;\n\t/** When true, WASM rotates toward velocity; default false for twin-stick face axes. */\n\tfaceMovement?: boolean;\n}\n\nexport interface TopDownMovementHandle {\n\tgetFacingAngle(): number;\n}\n\nconst defaultOptions: TopDownMovementBehaviorOptions = {\n\tmoveSpeed: 8,\n\tfaceMovement: false,\n};\n\nconst TOP_DOWN_MOVEMENT_BEHAVIOR_KEY = Symbol.for(\n\t'zylem:behavior:top-down-movement',\n);\n\nfunction createTopDownMovementHandle(\n\tref: BehaviorRef<TopDownMovementBehaviorOptions>,\n): TopDownMovementHandle {\n\treturn {\n\t\tgetFacingAngle: () =>\n\t\t\t(ref as any).__entity?.topDownMovementState?.facingAngle ?? 0,\n\t};\n}\n\nclass TopDownMovementBehaviorSystem implements BehaviorSystem {\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate wasmStage: BehaviorRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, _delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(TOP_DOWN_MOVEMENT_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst entity = link.entity as any;\n\t\t\tconst ref = link.ref as any;\n\n\t\t\tif (!entity.topDownMovement) {\n\t\t\t\tentity.topDownMovement = createTopDownMovementComponent(ref.options);\n\t\t\t}\n\t\t\tif (!entity.$topDownMovement) {\n\t\t\t\tentity.$topDownMovement = createTopDownMovementInputComponent();\n\t\t\t}\n\t\t\tif (!entity.topDownMovementState) {\n\t\t\t\tentity.topDownMovementState = createTopDownMovementStateComponent();\n\t\t\t}\n\n\t\t\tref.__entity = entity;\n\n\t\t\tconst handle = (entity.runtimeHandle ?? -1) as number;\n\t\t\tif (!this.wasmStage || handle < 0) continue;\n\n\t\t\tthis.ensureWasmAttached(handle, ref.options as TopDownMovementBehaviorOptions);\n\t\t\tconst input = entity.$topDownMovement;\n\t\t\tconst state = entity.topDownMovementState;\n\t\t\tif (input) {\n\t\t\t\tconst moveX = input.moveX ?? 0;\n\t\t\t\tconst moveY = input.moveY ?? input.moveZ ?? 0;\n\t\t\t\tthis.wasmStage.writeInputAxes(handle, moveX, moveY);\n\t\t\t\tstate.moving = Math.hypot(moveX, moveY) > 0.001;\n\n\t\t\t\tconst aim = resolveAim2D(\n\t\t\t\t\tinput.faceX ?? 0,\n\t\t\t\t\tinput.faceY ?? 0,\n\t\t\t\t\tstate.facingAngle,\n\t\t\t\t);\n\t\t\t\tif (aim.hasAimInput) {\n\t\t\t\t\tstate.facingAngle = aim.angle;\n\t\t\t\t\tentity.setRotationZ?.(aim.angle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: TopDownMovementBehaviorOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tthis.wasmStage.attachTopDown(handle, {\n\t\t\tplane: StageTopDownPlane.Xy,\n\t\t\tspeed: options.moveSpeed ?? defaultOptions.moveSpeed!,\n\t\t\tfaceMovement: options.faceMovement ?? defaultOptions.faceMovement!,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\nexport const TopDownMovementBehavior = defineBehavior<\n\tTopDownMovementBehaviorOptions,\n\tTopDownMovementHandle,\n\tTopDownMovementEntity\n>({\n\tname: 'top-down-movement',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew TopDownMovementBehaviorSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),\n\tcreateHandle: createTopDownMovementHandle,\n});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MAAM;AAAA,QACP;AACA,YAAI,IAAI,aAAa;AACpB,gBAAM,cAAc,IAAI;AACxB,iBAAO,eAAe,IAAI,KAAK;AAAA,QAChC;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,mBAAmB,QAAgB,SAA+C;AACzF,QAAI,CAAC,KAAK,aAAa,KAAK,qBAAqB,IAAI,MAAM,EAAG;AAC9D,SAAK,UAAU,cAAc,QAAQ;AAAA,MACpC,OAAO,kBAAkB;AAAA,MACzB,OAAO,QAAQ,aAAa,eAAe;AAAA,MAC3C,cAAc,QAAQ,gBAAgB,eAAe;AAAA,IACtD,CAAC;AACD,SAAK,qBAAqB,IAAI,MAAM;AAAA,EACrC;AAAA,EAEA,QAAQ,MAAqB;AAC5B,SAAK,qBAAqB,MAAM;AAAA,EACjC;AACD;AAEO,IAAM,0BAA0B,eAIrC;AAAA,EACD,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,QACf,IAAI,8BAA8B,IAAI,aAAa,MAAM,IAAI,gBAAgB;AAAA,EAC9E,cAAc;AACf,CAAC;","names":[]}
|
package/dist/cooldown.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/core.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/capabilities/transform-store.ts","../src/lib/capabilities/velocity-intents.ts","../src/lib/capabilities/moveable.ts","../src/lib/runtime/mock-behavior-runtime.ts","../src/lib/runtime/simulation.ts","../src/lib/entities/entity.ts"],"sourcesContent":["import { proxy } from 'valtio/vanilla';\n\nexport type VelocityIntentMode = 'replace' | 'add';\n\nexport interface VelocityIntent {\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\tmode: VelocityIntentMode;\n\tpriority?: number;\n}\n\n/**\n * Transform state managed by Valtio for per-frame physics intent accumulation.\n * \n * This store accumulates transformation intents during the frame,\n * then applies them all at once after onUpdate() callbacks complete.\n * \n * Design decisions:\n * - Position: Accumulated deltas (additive)\n * - Rotation: Last value wins (replacement)\n * - Velocity: Accumulated deltas (additive)\n * - Angular velocity: Accumulated deltas (additive)\n */\nexport interface TransformState {\n\t/** Position deltas to be applied (accumulated) */\n\tposition: { x: number; y: number; z: number };\n\t\n\t/** Rotation quaternion (last value wins) */\n\trotation: { x: number; y: number; z: number; w: number };\n\t\n\t/** Linear velocity (accumulated) */\n\tvelocity: { x: number; y: number; z: number };\n\t\n\t/** Angular velocity (accumulated) */\n\tangularVelocity: { x: number; y: number; z: number };\n\n\t/** Per-source velocity intents composed once per frame */\n\tvelocityChannels: Record<string, VelocityIntent>;\n\t\n\t/** Dirty flags to track what needs to be applied */\n\tdirty: {\n\t\tposition: boolean;\n\t\trotation: boolean;\n\t\tvelocityX: boolean;\n\t\tvelocityY: boolean;\n\t\tvelocityZ: boolean;\n\t\tvelocityChannels: boolean;\n\t\tangularVelocity: boolean;\n\t};\n}\n\n/**\n * Create a new transform store with optional initial values.\n * The store is a Valtio proxy, making it reactive for debugging/visualization.\n * \n * @param initial Optional initial state values\n * @returns Reactive transform state\n */\nexport function createTransformStore(initial?: Partial<TransformState>): TransformState {\n\tconst defaultState: TransformState = {\n\t\tposition: { x: 0, y: 0, z: 0 },\n\t\trotation: { x: 0, y: 0, z: 0, w: 1 },\n\t\tvelocity: { x: 0, y: 0, z: 0 },\n\t\tangularVelocity: { x: 0, y: 0, z: 0 },\n\t\tvelocityChannels: {},\n\t\tdirty: {\n\t\t\tposition: false,\n\t\t\trotation: false,\n\t\t\tvelocityX: false,\n\t\t\tvelocityY: false,\n\t\t\tvelocityZ: false,\n\t\t\tvelocityChannels: false,\n\t\t\tangularVelocity: false,\n\t\t},\n\t};\n\n\treturn proxy({\n\t\t...defaultState,\n\t\t...initial,\n\t\t// Ensure dirty flags are properly initialized even if partial initial state\n\t\tdirty: {\n\t\t\t...defaultState.dirty,\n\t\t\t...initial?.dirty,\n\t\t},\n\t});\n}\n\n","import { TransformState, VelocityIntentMode } from './transform-store';\n\nexport interface VelocityIntentOptions {\n\tmode?: VelocityIntentMode;\n\tpriority?: number;\n}\n\nexport interface VelocityIntentVector {\n\tx?: number;\n\ty?: number;\n\tz?: number;\n}\n\nexport function setVelocityIntent(\n\tstore: TransformState,\n\tsourceId: string,\n\tvector: VelocityIntentVector,\n\toptions: VelocityIntentOptions = {},\n): void {\n\tconst prev = store.velocityChannels[sourceId];\n\tconst mode = options.mode ?? prev?.mode ?? 'replace';\n\tconst priority = options.priority ?? prev?.priority ?? 0;\n\tconst isAdditiveMerge = mode === 'add' && prev?.mode === 'add';\n\n\tconst x =\n\t\tvector.x == null\n\t\t\t? prev?.x\n\t\t\t: isAdditiveMerge\n\t\t\t\t? (prev?.x ?? 0) + vector.x\n\t\t\t\t: vector.x;\n\tconst y =\n\t\tvector.y == null\n\t\t\t? prev?.y\n\t\t\t: isAdditiveMerge\n\t\t\t\t? (prev?.y ?? 0) + vector.y\n\t\t\t\t: vector.y;\n\tconst z =\n\t\tvector.z == null\n\t\t\t? prev?.z\n\t\t\t: isAdditiveMerge\n\t\t\t\t? (prev?.z ?? 0) + vector.z\n\t\t\t\t: vector.z;\n\n\tstore.velocityChannels[sourceId] = {\n\t\tx,\n\t\ty,\n\t\tz,\n\t\tmode,\n\t\tpriority,\n\t};\n\tstore.dirty.velocityChannels = true;\n}\n\nexport function clearVelocityIntent(store: TransformState, sourceId: string): void {\n\tif (!(sourceId in store.velocityChannels)) return;\n\tdelete store.velocityChannels[sourceId];\n\tstore.dirty.velocityChannels = true;\n}\n","import { Vector3 } from 'three';\nimport type { TransformState } from './transform-store';\nimport { createTransformStore } from './transform-store';\nimport { setVelocityIntent } from './velocity-intents';\n\n/** Plain `{ x, y, z }` vector returned by pose/velocity reads. */\nexport interface Vector {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\n/**\n * Structural slice of the host body reference used by the direct-body helpers\n * below (`getPosition`, `setPosition`, `resetVelocity`, ...). The host's\n * runtime-backed body proxy satisfies this shape.\n */\nexport interface MoveableBodyLike {\n\ttranslation(): Vector;\n\tlinvel(): Vector;\n\tsetTranslation(translation: Vector, wakeUp: boolean): void;\n\tsetLinvel(velocity: Vector, wakeUp: boolean): void;\n\tsetLinearDamping(damping: number): void;\n}\n\nexport interface EntityWithBody {\n\tbody: MoveableBodyLike | null;\n\ttransformStore?: TransformState;\n}\n\n/**\n * Move an entity along the X axis, preserving other velocities.\n */\nexport function moveX(entity: EntityWithBody, delta: number): void {\n\tif (!entity.transformStore) return;\n\tsetVelocityIntent(entity.transformStore, 'actions', { x: delta }, { mode: 'replace' });\n}\n\n/**\n * Move an entity along the Y axis, preserving other velocities.\n */\nexport function moveY(entity: EntityWithBody, delta: number): void {\n\tif (!entity.transformStore) return;\n\tsetVelocityIntent(entity.transformStore, 'actions', { y: delta }, { mode: 'replace' });\n}\n\n/**\n * Move an entity along the Z axis, preserving other velocities.\n */\nexport function moveZ(entity: EntityWithBody, delta: number): void {\n\tif (!entity.transformStore) return;\n\tsetVelocityIntent(entity.transformStore, 'actions', { z: delta }, { mode: 'replace' });\n}\n\n/**\n * Move an entity along the X and Y axis, preserving Z velocity.\n */\nexport function moveXY(entity: EntityWithBody, deltaX: number, deltaY: number): void {\n\tif (!entity.transformStore) return;\n\tsetVelocityIntent(\n\t\tentity.transformStore,\n\t\t'actions',\n\t\t{ x: deltaX, y: deltaY },\n\t\t{ mode: 'replace' },\n\t);\n}\n\n/**\n * Move an entity along the X and Z axis, preserving Y velocity.\n */\nexport function moveXZ(entity: EntityWithBody, deltaX: number, deltaZ: number): void {\n\tif (!entity.transformStore) return;\n\tsetVelocityIntent(\n\t\tentity.transformStore,\n\t\t'actions',\n\t\t{ x: deltaX, z: deltaZ },\n\t\t{ mode: 'replace' },\n\t);\n}\n\n/**\n * Move entity based on a vector, adding to existing velocities.\n */\nexport function move(entity: EntityWithBody, vector: Vector3): void {\n\tif (!entity.transformStore) return;\n\tsetVelocityIntent(\n\t\tentity.transformStore,\n\t\t'actions',\n\t\t{ x: vector.x, y: vector.y, z: vector.z },\n\t\t{ mode: 'add' },\n\t);\n}\n\n/**\n * Reset entity velocity\n */\nexport function resetVelocity(entity: EntityWithBody): void {\n\tif (!entity.body) return;\n\tentity.body.setLinvel(new Vector3(0, 0, 0), true);\n\tentity.body.setLinearDamping(5);\n}\n\n/**\n * Move entity forward in 2D space, preserving Z velocity\n */\nexport function moveForwardXY(entity: EntityWithBody, delta: number, rotation2DAngle: number): void {\n\tconst deltaX = Math.sin(-rotation2DAngle) * delta;\n\tconst deltaY = Math.cos(-rotation2DAngle) * delta;\n\tmoveXY(entity, deltaX, deltaY);\n}\n\n/**\n * Get entity position\n */\nexport function getPosition(entity: EntityWithBody): Vector | null {\n\tif (!entity.body) return null;\n\treturn entity.body.translation();\n}\n\n/**\n * Get entity velocity\n */\nexport function getVelocity(entity: EntityWithBody): Vector | null {\n\tif (!entity.body) return null;\n\treturn entity.body.linvel();\n}\n\n/**\n * Set entity position\n */\nexport function setPosition(entity: EntityWithBody, x: number, y: number, z: number): void {\n\tif (!entity.body) return;\n\tentity.body.setTranslation({ x, y, z }, true);\n}\n\n/**\n * Set entity X position\n */\nexport function setPositionX(entity: EntityWithBody, x: number): void {\n\tif (!entity.body) return;\n\tconst { y, z } = entity.body.translation();\n\tentity.body.setTranslation({ x, y, z }, true);\n}\n\n/**\n * Set entity Y position\n */\nexport function setPositionY(entity: EntityWithBody, y: number): void {\n\tif (!entity.body) return;\n\tconst { x, z } = entity.body.translation();\n\tentity.body.setTranslation({ x, y, z }, true);\n}\n\n/**\n * Set entity Z position\n */\nexport function setPositionZ(entity: EntityWithBody, z: number): void {\n\tif (!entity.body) return;\n\tconst { x, y } = entity.body.translation();\n\tentity.body.setTranslation({ x, y, z }, true);\n}\n\n/**\n * Wrap entity around 2D bounds\n */\nexport function wrapAroundXY(entity: EntityWithBody, boundsX: number, boundsY: number): void {\n\tconst position = getPosition(entity);\n\tif (!position) return;\n\n\tconst { x, y } = position;\n\tconst newX = x > boundsX ? -boundsX : (x < -boundsX ? boundsX : x);\n\tconst newY = y > boundsY ? -boundsY : (y < -boundsY ? boundsY : y);\n\n\tif (newX !== x || newY !== y) {\n\t\tsetPosition(entity, newX, newY, 0);\n\t}\n}\n\n/**\n * Wrap entity around 3D bounds\n */\nexport function wrapAround3D(entity: EntityWithBody, boundsX: number, boundsY: number, boundsZ: number): void {\n\tconst position = getPosition(entity);\n\tif (!position) return;\n\n\tconst { x, y, z } = position;\n\tconst newX = x > boundsX ? -boundsX : (x < -boundsX ? boundsX : x);\n\tconst newY = y > boundsY ? -boundsY : (y < -boundsY ? boundsY : y);\n\tconst newZ = z > boundsZ ? -boundsZ : (z < -boundsZ ? boundsZ : z);\n\n\tif (newX !== x || newY !== y || newZ !== z) {\n\t\tsetPosition(entity, newX, newY, newZ);\n\t}\n}\n\n/**\n * Enhanced moveable entity with bound methods\n */\nexport interface MoveableEntity extends EntityWithBody {\n\tmoveX(delta: number): void;\n\tmoveY(delta: number): void;\n\tmoveZ(delta: number): void;\n\tmoveXY(deltaX: number, deltaY: number): void;\n\tmoveXZ(deltaX: number, deltaZ: number): void;\n\tmove(vector: Vector3): void;\n\tresetVelocity(): void;\n\tmoveForwardXY(delta: number, rotation2DAngle: number): void;\n\tgetPosition(): Vector | null;\n\tgetVelocity(): Vector | null;\n\tsetPosition(x: number, y: number, z: number): void;\n\tsetPositionX(x: number): void;\n\tsetPositionY(y: number): void;\n\tsetPositionZ(z: number): void;\n\twrapAroundXY(boundsX: number, boundsY: number): void;\n\twrapAround3D(boundsX: number, boundsY: number, boundsZ: number): void;\n}\n\n/**\n * Enhance an entity with additive movement methods.\n * Automatically creates a transform store if one doesn't exist.\n */\nexport function makeMoveable<T extends EntityWithBody>(entity: T): T & MoveableEntity {\n\tconst moveable = entity as T & MoveableEntity;\n\n\t// Create transform store if it doesn't exist\n\tif (!moveable.transformStore) {\n\t\tmoveable.transformStore = createTransformStore();\n\t}\n\n\tmoveable.moveX = (delta: number) => moveX(entity, delta);\n\tmoveable.moveY = (delta: number) => moveY(entity, delta);\n\tmoveable.moveZ = (delta: number) => moveZ(entity, delta);\n\tmoveable.moveXY = (deltaX: number, deltaY: number) => moveXY(entity, deltaX, deltaY);\n\tmoveable.moveXZ = (deltaX: number, deltaZ: number) => moveXZ(entity, deltaX, deltaZ);\n\tmoveable.move = (vector: Vector3) => move(entity, vector);\n\tmoveable.resetVelocity = () => resetVelocity(entity);\n\tmoveable.moveForwardXY = (delta: number, rotation2DAngle: number) => moveForwardXY(entity, delta, rotation2DAngle);\n\tmoveable.getPosition = () => getPosition(entity);\n\tmoveable.getVelocity = () => getVelocity(entity);\n\tmoveable.setPosition = (x: number, y: number, z: number) => setPosition(entity, x, y, z);\n\tmoveable.setPositionX = (x: number) => setPositionX(entity, x);\n\tmoveable.setPositionY = (y: number) => setPositionY(entity, y);\n\tmoveable.setPositionZ = (z: number) => setPositionZ(entity, z);\n\tmoveable.wrapAroundXY = (boundsX: number, boundsY: number) => wrapAroundXY(entity, boundsX, boundsY);\n\tmoveable.wrapAround3D = (boundsX: number, boundsY: number, boundsZ: number) => wrapAround3D(entity, boundsX, boundsY, boundsZ);\n\n\treturn moveable;\n}","/**\n * In-memory implementation of the {@link BehaviorRuntime} contract for unit\n * tests. Records every attach / input call per handle and lets tests seed\n * poses and behavior snapshots without instantiating the wasm runtime.\n */\n\nimport type {\n\tBehaviorRuntime,\n\tStageBehaviorSnapshot,\n\tStageBoundaryDimValue,\n\tStageFirstPersonInput,\n\tStageFirstPersonOptions,\n\tStageJumper2DOptions,\n\tStageJumper3DOptions,\n\tStagePlatformer2DOptions,\n\tStagePlatformer3DOptions,\n\tStagePose,\n\tStageRicochetDimValue,\n\tStageRicochetOptions,\n\tStageScreenWrapOptions,\n\tStageShooter2DOptions,\n\tStageThrusterOptions,\n\tStageTopDownOptions,\n\tStageWorldBoundaryOptions,\n} from './wasm-stage-runtime';\n\ninterface MockSlotState {\n\tpose: StagePose;\n\tsnapshot: StageBehaviorSnapshot | null;\n\tinput: {\n\t\taxisA: number;\n\t\taxisB: number;\n\t\tyawDelta: number;\n\t\tpitchDelta: number;\n\t\treservedA: number;\n\t\treservedB: number;\n\t\tbuttons: number;\n\t};\n\tattachments: Map<string, unknown>;\n\tinputs: Array<{ kind: string; args: unknown[] }>;\n\tscreenWrapQuery: { fsm: number; lastWrappedAxes: number } | null;\n\tworldBoundaryQuery: { hits: number; clamped: [number, number, number] } | null;\n}\n\nfunction freshSlot(): MockSlotState {\n\treturn {\n\t\tpose: { position: [0, 0, 0], rotation: [0, 0, 0, 1] },\n\t\tsnapshot: null,\n\t\tinput: { axisA: 0, axisB: 0, yawDelta: 0, pitchDelta: 0, reservedA: 0, reservedB: 0, buttons: 0 },\n\t\tattachments: new Map(),\n\t\tinputs: [],\n\t\tscreenWrapQuery: null,\n\t\tworldBoundaryQuery: null,\n\t};\n}\n\nexport class MockBehaviorRuntime implements BehaviorRuntime {\n\tprivate slots = new Map<number, MockSlotState>();\n\n\tprivate slot(handle: number): MockSlotState {\n\t\tlet state = this.slots.get(handle);\n\t\tif (!state) {\n\t\t\tstate = freshSlot();\n\t\t\tthis.slots.set(handle, state);\n\t\t}\n\t\treturn state;\n\t}\n\n\t// ─── Test seams ─────────────────────────────────────────────────────\n\n\t/** Seed the pose returned by {@link getPose} for a handle. */\n\tsetPose(handle: number, pose: StagePose): void {\n\t\tthis.slot(handle).pose = pose;\n\t}\n\n\t/** Seed the snapshot returned by {@link readSnapshot} for a handle. */\n\tsetSnapshot(handle: number, snapshot: StageBehaviorSnapshot | null): void {\n\t\tthis.slot(handle).snapshot = snapshot;\n\t}\n\n\t/** Seed {@link queryScreenWrap} results. */\n\tsetScreenWrapQuery(handle: number, value: { fsm: number; lastWrappedAxes: number } | null): void {\n\t\tthis.slot(handle).screenWrapQuery = value;\n\t}\n\n\t/** Seed {@link queryWorldBoundary} results. */\n\tsetWorldBoundaryQuery(\n\t\thandle: number,\n\t\tvalue: { hits: number; clamped: [number, number, number] } | null,\n\t): void {\n\t\tthis.slot(handle).worldBoundaryQuery = value;\n\t}\n\n\t/** Attachment options recorded for a handle, keyed by behavior name. */\n\tgetAttachment<T>(handle: number, kind: string): T | undefined {\n\t\treturn this.slots.get(handle)?.attachments.get(kind) as T | undefined;\n\t}\n\n\thasAttachment(handle: number, kind: string): boolean {\n\t\treturn this.slots.get(handle)?.attachments.has(kind) ?? false;\n\t}\n\n\t/** Every per-entity input call recorded for a handle, oldest first. */\n\tgetInputCalls(handle: number): Array<{ kind: string; args: unknown[] }> {\n\t\treturn this.slots.get(handle)?.inputs ?? [];\n\t}\n\n\t/** Last written slot-indexed input state for a handle. */\n\tgetBatchedInput(handle: number): MockSlotState['input'] {\n\t\treturn this.slot(handle).input;\n\t}\n\n\treset(): void {\n\t\tthis.slots.clear();\n\t}\n\n\t// ─── BehaviorRuntime contract ───────────────────────────────────────\n\n\tsetPosition(handle: number, x: number, y: number, z: number): boolean {\n\t\tconst pose = this.slot(handle).pose;\n\t\tpose.position[0] = x;\n\t\tpose.position[1] = y;\n\t\tpose.position[2] = z;\n\t\treturn true;\n\t}\n\n\tsetRotation(handle: number, x: number, y: number, z: number, w: number): boolean {\n\t\tconst pose = this.slot(handle).pose;\n\t\tpose.rotation[0] = x;\n\t\tpose.rotation[1] = y;\n\t\tpose.rotation[2] = z;\n\t\tpose.rotation[3] = w;\n\t\treturn true;\n\t}\n\n\tgetPose(handle: number, out?: StagePose): StagePose | null {\n\t\tconst state = this.slots.get(handle);\n\t\tif (!state) return null;\n\t\tconst result = out ?? { position: [0, 0, 0], rotation: [0, 0, 0, 1] } as StagePose;\n\t\tresult.position[0] = state.pose.position[0];\n\t\tresult.position[1] = state.pose.position[1];\n\t\tresult.position[2] = state.pose.position[2];\n\t\tresult.rotation[0] = state.pose.rotation[0];\n\t\tresult.rotation[1] = state.pose.rotation[1];\n\t\tresult.rotation[2] = state.pose.rotation[2];\n\t\tresult.rotation[3] = state.pose.rotation[3];\n\t\treturn result;\n\t}\n\n\twriteInputAxes(handle: number, axisA: number, axisB: number): boolean {\n\t\tconst input = this.slot(handle).input;\n\t\tinput.axisA = axisA;\n\t\tinput.axisB = axisB;\n\t\treturn true;\n\t}\n\n\twriteInputLook(handle: number, yawDelta: number, pitchDelta: number): boolean {\n\t\tconst input = this.slot(handle).input;\n\t\tinput.yawDelta = yawDelta;\n\t\tinput.pitchDelta = pitchDelta;\n\t\treturn true;\n\t}\n\n\twriteInputReserved(handle: number, reservedA: number, reservedB: number): boolean {\n\t\tconst input = this.slot(handle).input;\n\t\tinput.reservedA = reservedA;\n\t\tinput.reservedB = reservedB;\n\t\treturn true;\n\t}\n\n\twriteInputButton(handle: number, buttonMask: number, pressed: boolean): boolean {\n\t\tconst input = this.slot(handle).input;\n\t\tinput.buttons = pressed ? (input.buttons | buttonMask) : (input.buttons & ~buttonMask);\n\t\treturn true;\n\t}\n\n\treadSnapshot(handle: number, out?: StageBehaviorSnapshot): StageBehaviorSnapshot | null {\n\t\tconst snapshot = this.slots.get(handle)?.snapshot ?? null;\n\t\tif (!snapshot) return null;\n\t\tif (!out) return { ...snapshot };\n\t\tObject.assign(out, snapshot);\n\t\treturn out;\n\t}\n\n\tattachThruster(handle: number, opts: StageThrusterOptions): boolean {\n\t\tthis.slot(handle).attachments.set('thruster', opts);\n\t\treturn true;\n\t}\n\n\tsetThrusterInput(\n\t\thandle: number,\n\t\tthrust: number,\n\t\trotate: number,\n\t\tvectorX = 0,\n\t\tvectorY = 0,\n\t): void {\n\t\tthis.slot(handle).inputs.push({\n\t\t\tkind: 'thruster',\n\t\t\targs: [thrust, rotate, vectorX, vectorY],\n\t\t});\n\t}\n\n\tattachTopDown(handle: number, opts: StageTopDownOptions): boolean {\n\t\tthis.slot(handle).attachments.set('topDown', opts);\n\t\treturn true;\n\t}\n\n\tsetTopDownInput(handle: number, moveX: number, moveY: number): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'topDown', args: [moveX, moveY] });\n\t}\n\n\tattachShooter2D(handle: number, opts: StageShooter2DOptions): boolean {\n\t\tthis.slot(handle).attachments.set('shooter2d', opts);\n\t\treturn true;\n\t}\n\n\tattachScreenWrap(handle: number, opts: StageScreenWrapOptions): boolean {\n\t\tthis.slot(handle).attachments.set('screenWrap', opts);\n\t\treturn true;\n\t}\n\n\tqueryScreenWrap(handle: number): { fsm: number; lastWrappedAxes: number } | null {\n\t\treturn this.slots.get(handle)?.screenWrapQuery ?? null;\n\t}\n\n\tattachWorldBoundary(\n\t\thandle: number,\n\t\tdim: StageBoundaryDimValue,\n\t\topts: StageWorldBoundaryOptions,\n\t): boolean {\n\t\tthis.slot(handle).attachments.set('worldBoundary', { dim, ...opts });\n\t\treturn true;\n\t}\n\n\tqueryWorldBoundary(handle: number): { hits: number; clamped: [number, number, number] } | null {\n\t\treturn this.slots.get(handle)?.worldBoundaryQuery ?? null;\n\t}\n\n\tattachRicochet(handle: number, dim: StageRicochetDimValue, opts: StageRicochetOptions): boolean {\n\t\tthis.slot(handle).attachments.set('ricochet', { dim, ...opts });\n\t\treturn true;\n\t}\n\n\tattachPlatformer3D(handle: number, opts: StagePlatformer3DOptions): boolean {\n\t\tthis.slot(handle).attachments.set('platformer3d', opts);\n\t\treturn true;\n\t}\n\n\tsetPlatformer3DInputAxes(handle: number, moveX: number, moveZ: number): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'platformer3dAxes', args: [moveX, moveZ] });\n\t}\n\n\tsetPlatformer3DInputButtons(handle: number, jump: boolean, run: boolean): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'platformer3dButtons', args: [jump, run] });\n\t}\n\n\tattachPlatformer2D(handle: number, opts: StagePlatformer2DOptions): boolean {\n\t\tthis.slot(handle).attachments.set('platformer2d', opts);\n\t\treturn true;\n\t}\n\n\tsetPlatformer2DInputAxes(handle: number, moveX: number): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'platformer2dAxes', args: [moveX] });\n\t}\n\n\tsetPlatformer2DInputButtons(handle: number, jump: boolean, run: boolean): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'platformer2dButtons', args: [jump, run] });\n\t}\n\n\tattachFirstPerson(handle: number, opts: StageFirstPersonOptions): boolean {\n\t\tthis.slot(handle).attachments.set('firstPerson', opts);\n\t\treturn true;\n\t}\n\n\tsetFirstPersonInput(handle: number, input: StageFirstPersonInput): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'firstPerson', args: [input] });\n\t}\n\n\tattachJumper2D(handle: number, opts: StageJumper2DOptions): boolean {\n\t\tthis.slot(handle).attachments.set('jumper2d', opts);\n\t\treturn true;\n\t}\n\n\tsetJumper2DInput(handle: number, jumpPressed: boolean): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'jumper2d', args: [jumpPressed] });\n\t}\n\n\tattachJumper3D(handle: number, opts: StageJumper3DOptions): boolean {\n\t\tthis.slot(handle).attachments.set('jumper3d', opts);\n\t\treturn true;\n\t}\n\n\tsetJumper3DInput(handle: number, jumpPressed: boolean): void {\n\t\tthis.slot(handle).inputs.push({ kind: 'jumper3d', args: [jumpPressed] });\n\t}\n}\n","/**\n * `Simulation` (a.k.a. `BehaviorWorld`) — the primary public abstraction of\n * `@zylem/behaviors`. It owns the wasm runtime lifecycle (one\n * `WebAssembly.Instance` of `@zylem/runtime` per simulation), the fixed\n * timestep accumulator, an entity registry mapping opaque\n * {@link EntityHandle}s to runtime slots, and per-step event translation\n * from raw stage events into typed {@link SimulationEvent}s.\n *\n * Hosts (e.g. `@zylem/game-lib`) call {@link createSimulation} once per\n * stage, `spawn()`/`despawn()` entities, call `update(delta)` once per\n * render frame, and read poses for rendering from the returned\n * {@link SimulationFrame}.\n */\n\nimport {\n\tWasmStageRuntime,\n\tcreateWasmStageRuntime,\n\tStageBodyKind,\n\tStageEventType,\n\tSTAGE_RENDER_STRIDE,\n\treadStageRenderSlot,\n\ttype StageBehaviorSnapshot,\n\ttype StageBodyConfig,\n\ttype StageBodyKindValue,\n\ttype StageColliderConfig,\n\ttype StageColliderShape,\n\ttype StageDebugRender,\n\ttype StageBodyInfo,\n\ttype StageEvent,\n\ttype StagePose,\n\ttype StageRaycastHit,\n\ttype StageRenderSlot,\n\ttype WasmStageRuntimeOptions,\n} from './wasm-stage-runtime';\n\n/**\n * Opaque, stable identifier for a simulation entity. `slot` is the raw\n * runtime slot index — treat it as an implementation detail owned by the\n * Simulation (it is only exposed so hosts can wire behavior systems, which\n * address the slot-indexed buffers by slot).\n */\nexport interface EntityHandle {\n\t/** Monotonic public id, never reused within a Simulation. */\n\treadonly id: number;\n\t/** Raw runtime slot index. Internal — may be reused after despawn. */\n\treadonly slot: number;\n}\n\n/** Partial body description; unspecified fields use sensible defaults. */\nexport interface SimulationBodyDefinition {\n\tkind?: StageBodyKindValue;\n\tposition?: readonly [number, number, number];\n\trotation?: readonly [number, number, number, number];\n\tlinearDamping?: number;\n\tangularDamping?: number;\n\tgravityScale?: number;\n\tcanSleep?: boolean;\n\tccdEnabled?: boolean;\n\tlockRotation?: readonly [boolean, boolean, boolean];\n\tlockTranslation?: readonly [boolean, boolean, boolean];\n}\n\n/** Partial collider description; unspecified fields use sensible defaults. */\nexport interface SimulationColliderDefinition {\n\tshape: StageColliderShape;\n\toffset?: readonly [number, number, number];\n\tfriction?: number;\n\trestitution?: number;\n\tsensor?: boolean;\n\tcollisionGroups?: number;\n}\n\n/** Everything needed to materialize one entity inside the runtime. */\nexport interface EntityDefinition {\n\tbody?: SimulationBodyDefinition;\n\tcolliders?: SimulationColliderDefinition[];\n}\n\n/** Typed, handle-resolved simulation event. */\nexport type SimulationEvent =\n\t| {\n\t\ttype: 'collisionStarted' | 'collisionStopped';\n\t\ta: EntityHandle | null;\n\t\tb: EntityHandle | null;\n\t\t/** True when either collider in the pair is a sensor (zone overlap). */\n\t\tsensor: boolean;\n\t\t/** Best-effort contact normal (x, y); zero for sensor pairs / stops. */\n\t\tnormal: [number, number];\n\t}\n\t| { type: 'boundaryHit'; entity: EntityHandle | null; axes: number; signs: number }\n\t| { type: 'ricochet'; entity: EntityHandle | null; kind: number }\n\t| { type: 'regionEntered'; entity: EntityHandle | null; triggerId: number }\n\t| { type: 'jumpStarted'; entity: EntityHandle | null; jumpCount: number }\n\t| { type: 'landed'; entity: EntityHandle | null }\n\t| { type: 'wrapped'; entity: EntityHandle | null; axes: number }\n\t| { type: 'cooldownFired'; entity: EntityHandle | null; cooldownId: number };\n\n/**\n * Snapshot of one `update()` call: how many fixed steps ran, the live render\n * buffer view, the previous-step render copy + interpolation alpha for\n * smooth rendering, and the translated events from every step taken.\n */\nexport interface SimulationFrame {\n\t/** Wall-clock delta handed to `update()`. */\n\tdeltaTime: number;\n\t/** Number of fixed steps executed (0 when accumulating). */\n\tstepsTaken: number;\n\t/** Interpolation alpha in [0, 1): fraction of a fixed step accumulated. */\n\talpha: number;\n\t/** Live render buffer (post-step poses), {@link STAGE_RENDER_STRIDE} floats per slot. */\n\trender: Float32Array;\n\t/** Copy of the render buffer as of the step before the last one. */\n\tpreviousRender: Float32Array;\n\trenderStride: number;\n\t/** Typed events from all steps taken this update, oldest first. */\n\tevents: SimulationEvent[];\n}\n\nexport interface SimulationOptions extends WasmStageRuntimeOptions {\n\t/** Fixed physics timestep in seconds (default 1/60). */\n\tfixedTimestep?: number;\n\t/** Max fixed steps per `update()` to avoid death spirals (default 4). */\n\tmaxSubSteps?: number;\n}\n\nconst DEFAULT_FIXED_TIMESTEP = 1 / 60;\n// Hosts clamp frame delta to 1/30s, so more than 2 substeps of 1/60 per\n// frame is wasted work that amplifies slow steps into a death spiral.\nconst DEFAULT_MAX_SUB_STEPS = 2;\n\n/**\n * The behavior world. Construct via {@link createSimulation}.\n */\nexport class Simulation {\n\t/**\n\t * The low-level wasm adapter. Behavior systems receive this as their\n\t * `wasmStage` context so descriptors can attach/query behaviors by slot;\n\t * hosts should prefer the handle-based methods on the Simulation itself.\n\t */\n\treadonly adapter: WasmStageRuntime;\n\n\treadonly fixedTimestep: number;\n\tprivate readonly maxSubSteps: number;\n\n\tprivate accumulator = 0;\n\tprivate nextEntityId = 1;\n\tprivate slotToHandle = new Map<number, EntityHandle>();\n\tprivate idToHandle = new Map<number, EntityHandle>();\n\tprivate previousRender: Float32Array = new Float32Array(0);\n\tprivate disposed = false;\n\tprivate eventsEnabled = true;\n\n\tconstructor(adapter: WasmStageRuntime, options: SimulationOptions = {}) {\n\t\tthis.adapter = adapter;\n\t\tthis.fixedTimestep = options.fixedTimestep ?? DEFAULT_FIXED_TIMESTEP;\n\t\tthis.maxSubSteps = Math.max(1, options.maxSubSteps ?? DEFAULT_MAX_SUB_STEPS);\n\t}\n\n\t// ─── Entity lifecycle ───────────────────────────────────────────────\n\n\t/**\n\t * Create a runtime entity from a plain definition. Returns `null` when\n\t * the runtime rejects the allocation.\n\t */\n\tspawn(definition: EntityDefinition = {}): EntityHandle | null {\n\t\tconst slot = this.adapter.createEntity();\n\t\tif (slot === 0xffffffff) return null;\n\n\t\tconst body = definition.body;\n\t\tconst bodyConfig: StageBodyConfig = {\n\t\t\tkind: body?.kind ?? StageBodyKind.Dynamic,\n\t\t\tposition: body?.position ?? [0, 0, 0],\n\t\t\trotation: body?.rotation ?? [0, 0, 0, 1],\n\t\t\tlinearDamping: body?.linearDamping ?? 0,\n\t\t\tangularDamping: body?.angularDamping ?? 0,\n\t\t\tgravityScale: body?.gravityScale ?? 1,\n\t\t\tcanSleep: body?.canSleep ?? false,\n\t\t\tccdEnabled: body?.ccdEnabled ?? true,\n\t\t\tlockRotation: body?.lockRotation ?? [false, false, false],\n\t\t\tlockTranslation: body?.lockTranslation ?? [false, false, false],\n\t\t};\n\t\tthis.adapter.attachBody(slot, bodyConfig);\n\n\t\tfor (const collider of definition.colliders ?? []) {\n\t\t\tconst config: StageColliderConfig = {\n\t\t\t\tshape: collider.shape,\n\t\t\t\toffset: collider.offset ?? [0, 0, 0],\n\t\t\t\tfriction: collider.friction ?? 0.5,\n\t\t\t\trestitution: collider.restitution ?? 0,\n\t\t\t\tsensor: collider.sensor ?? false,\n\t\t\t\tcollisionGroups: collider.collisionGroups ?? 0xffffffff,\n\t\t\t};\n\t\t\tthis.adapter.addCollider(slot, config);\n\t\t}\n\n\t\tconst handle: EntityHandle = { id: this.nextEntityId++, slot };\n\t\tthis.slotToHandle.set(slot, handle);\n\t\tthis.idToHandle.set(handle.id, handle);\n\t\treturn handle;\n\t}\n\n\tdespawn(handle: EntityHandle): boolean {\n\t\tconst registered = this.idToHandle.get(handle.id);\n\t\tif (!registered) return false;\n\t\tthis.idToHandle.delete(handle.id);\n\t\tif (this.slotToHandle.get(registered.slot) === registered) {\n\t\t\tthis.slotToHandle.delete(registered.slot);\n\t\t}\n\t\treturn this.adapter.destroyEntity(registered.slot);\n\t}\n\n\t/** Resolve a raw runtime slot back to its public handle, if alive. */\n\thandleForSlot(slot: number): EntityHandle | null {\n\t\treturn this.slotToHandle.get(slot) ?? null;\n\t}\n\n\t/**\n\t * Toggle collision-event collection. When disabled the wasm stage skips\n\t * per-step contact-pair hashing and `update()` skips event draining /\n\t * translation entirely (`frame.events` stays empty). Re-enabling emits\n\t * `collisionStarted` for every currently overlapping pair on the next\n\t * step, so late listeners observe current state.\n\t */\n\tsetEventsEnabled(enabled: boolean): void {\n\t\tif (this.eventsEnabled === enabled) return;\n\t\tthis.eventsEnabled = enabled;\n\t\tthis.adapter.setEventsEnabled(enabled);\n\t}\n\n\tget areEventsEnabled(): boolean {\n\t\treturn this.eventsEnabled;\n\t}\n\n\tget entityCount(): number {\n\t\treturn this.idToHandle.size;\n\t}\n\n\t// ─── Per-frame update ───────────────────────────────────────────────\n\n\t/**\n\t * Advance the simulation by `deltaTime` seconds using a fixed-timestep\n\t * accumulator. Runs zero or more fixed steps and returns a\n\t * {@link SimulationFrame} with translated events and interpolation data.\n\t */\n\tupdate(deltaTime: number): SimulationFrame {\n\t\tconst events: SimulationEvent[] = [];\n\t\tthis.accumulator += Math.max(0, deltaTime);\n\t\tlet steps = 0;\n\n\t\twhile (this.accumulator >= this.fixedTimestep && steps < this.maxSubSteps) {\n\t\t\tthis.capturePreviousRender();\n\t\t\tthis.adapter.step(this.fixedTimestep);\n\t\t\tif (this.eventsEnabled) {\n\t\t\t\tthis.translateEvents(this.adapter.drainEvents(), events);\n\t\t\t}\n\t\t\tthis.accumulator -= this.fixedTimestep;\n\t\t\tsteps++;\n\t\t}\n\t\t// Drop leftover time we couldn't consume (death-spiral guard).\n\t\tif (steps === this.maxSubSteps && this.accumulator >= this.fixedTimestep) {\n\t\t\tthis.accumulator = this.accumulator % this.fixedTimestep;\n\t\t}\n\n\t\treturn {\n\t\t\tdeltaTime,\n\t\t\tstepsTaken: steps,\n\t\t\talpha: this.fixedTimestep > 0 ? this.accumulator / this.fixedTimestep : 0,\n\t\t\trender: this.adapter.render,\n\t\t\tpreviousRender: this.previousRender,\n\t\t\trenderStride: STAGE_RENDER_STRIDE,\n\t\t\tevents,\n\t\t};\n\t}\n\n\tprivate capturePreviousRender(): void {\n\t\tthis.adapter.refreshViews();\n\t\tconst current = this.adapter.render;\n\t\tif (this.previousRender.length !== current.length) {\n\t\t\tthis.previousRender = new Float32Array(current.length);\n\t\t}\n\t\tthis.previousRender.set(current);\n\t}\n\n\tprivate translateEvents(raw: StageEvent[], out: SimulationEvent[]): void {\n\t\tfor (const event of raw) {\n\t\t\tconst primary = event.primarySlot !== null ? this.handleForSlot(event.primarySlot) : null;\n\t\t\tconst secondary = event.secondarySlot !== null ? this.handleForSlot(event.secondarySlot) : null;\n\t\t\tswitch (event.type) {\n\t\t\t\tcase StageEventType.CollisionStarted:\n\t\t\t\tcase StageEventType.CollisionStopped:\n\t\t\t\t\tout.push({\n\t\t\t\t\t\ttype: event.type === StageEventType.CollisionStarted\n\t\t\t\t\t\t\t? 'collisionStarted'\n\t\t\t\t\t\t\t: 'collisionStopped',\n\t\t\t\t\t\ta: primary,\n\t\t\t\t\t\tb: secondary,\n\t\t\t\t\t\tsensor: event.payload[0] !== 0,\n\t\t\t\t\t\tnormal: [event.payload[1], event.payload[2]],\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase StageEventType.BoundaryHit:\n\t\t\t\t\tout.push({\n\t\t\t\t\t\ttype: 'boundaryHit',\n\t\t\t\t\t\tentity: primary,\n\t\t\t\t\t\taxes: event.payload[0] | 0,\n\t\t\t\t\t\tsigns: event.payload[1] | 0,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase StageEventType.Ricochet:\n\t\t\t\t\tout.push({ type: 'ricochet', entity: primary, kind: event.payload[0] | 0 });\n\t\t\t\t\tbreak;\n\t\t\t\tcase StageEventType.RegionEntered:\n\t\t\t\t\tout.push({ type: 'regionEntered', entity: primary, triggerId: event.payload[0] | 0 });\n\t\t\t\t\tbreak;\n\t\t\t\tcase StageEventType.JumpStarted:\n\t\t\t\t\tout.push({ type: 'jumpStarted', entity: primary, jumpCount: event.payload[0] | 0 });\n\t\t\t\t\tbreak;\n\t\t\t\tcase StageEventType.Landed:\n\t\t\t\t\tout.push({ type: 'landed', entity: primary });\n\t\t\t\t\tbreak;\n\t\t\t\tcase StageEventType.Wrapped:\n\t\t\t\t\tout.push({ type: 'wrapped', entity: primary, axes: event.payload[0] | 0 });\n\t\t\t\t\tbreak;\n\t\t\t\tcase StageEventType.CooldownFired:\n\t\t\t\t\tout.push({ type: 'cooldownFired', entity: primary, cooldownId: event.payload[0] | 0 });\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// ─── Handle-based reads / writes ────────────────────────────────────\n\n\tgetPose(handle: EntityHandle, out?: StagePose): StagePose | null {\n\t\treturn this.adapter.getPose(handle.slot, out);\n\t}\n\n\tsetPosition(handle: EntityHandle, x: number, y: number, z: number): boolean {\n\t\treturn this.adapter.setPosition(handle.slot, x, y, z);\n\t}\n\n\tsetRotation(handle: EntityHandle, x: number, y: number, z: number, w: number): boolean {\n\t\treturn this.adapter.setRotation(handle.slot, x, y, z, w);\n\t}\n\n\tsetLinearVelocity(handle: EntityHandle, x: number, y: number, z: number): boolean {\n\t\treturn this.adapter.setLinearVelocity(handle.slot, x, y, z);\n\t}\n\n\tgetLinearVelocity(handle: EntityHandle): [number, number, number] | null {\n\t\treturn this.adapter.getLinearVelocity(handle.slot);\n\t}\n\n\tsetAngularVelocity(handle: EntityHandle, x: number, y: number, z: number): boolean {\n\t\treturn this.adapter.setAngularVelocity(handle.slot, x, y, z);\n\t}\n\n\tapplyImpulse(handle: EntityHandle, x: number, y: number, z: number): boolean {\n\t\treturn this.adapter.applyImpulse(handle.slot, x, y, z);\n\t}\n\n\treadRenderSlot(handle: EntityHandle, out?: StageRenderSlot): StageRenderSlot | null {\n\t\treturn readStageRenderSlot(this.adapter.render, handle.slot, out);\n\t}\n\n\t/** Decode a handle's pose from the previous-step render copy. */\n\treadPreviousRenderSlot(handle: EntityHandle, out?: StageRenderSlot): StageRenderSlot | null {\n\t\treturn readStageRenderSlot(this.previousRender, handle.slot, out);\n\t}\n\n\treadSnapshot(handle: EntityHandle, out?: StageBehaviorSnapshot): StageBehaviorSnapshot | null {\n\t\treturn this.adapter.readSnapshot(handle.slot, out);\n\t}\n\n\t// ─── World-level controls / diagnostics ─────────────────────────────\n\n\tsetGravity(x: number, y: number, z: number): void {\n\t\tthis.adapter.setGravity(x, y, z);\n\t}\n\n\t/** Physics raycast; the hit's slot is resolved to an entity handle. */\n\tcastRay(\n\t\torigin: readonly [number, number, number],\n\t\tdir: readonly [number, number, number],\n\t\tmaxDistance: number,\n\t\tsolidOnly = true,\n\t): (Omit<StageRaycastHit, 'slot'> & { entity: EntityHandle | null }) | null {\n\t\tconst hit = this.adapter.castRay(origin, dir, maxDistance, solidOnly);\n\t\tif (!hit) return null;\n\t\treturn {\n\t\t\tdistance: hit.distance,\n\t\t\tnormal: hit.normal,\n\t\t\tentity: this.handleForSlot(hit.slot),\n\t\t};\n\t}\n\n\tgetBodyInfo(handle: EntityHandle): StageBodyInfo | null {\n\t\treturn this.adapter.getBodyInfo(handle.slot);\n\t}\n\n\tgetDebugRender(): StageDebugRender | null {\n\t\treturn this.adapter.getDebugRender();\n\t}\n\n\tget isDisposed(): boolean {\n\t\treturn this.disposed;\n\t}\n\n\t/** Destroy the wasm stage. The Simulation must not be used afterwards. */\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.slotToHandle.clear();\n\t\tthis.idToHandle.clear();\n\t\tthis.adapter.dispose();\n\t}\n}\n\n/** Alias matching the architecture doc's naming. */\nexport type BehaviorWorld = Simulation;\n\n/**\n * Load and instantiate the `@zylem/runtime` wasm module and wrap it in a\n * {@link Simulation}. One call per logical stage/world.\n */\nexport async function createSimulation(options: SimulationOptions = {}): Promise<Simulation> {\n\tconst adapter = await createWasmStageRuntime(options);\n\treturn new Simulation(adapter, options);\n}\n","import type {\n\tBehaviorDescriptor,\n\tBehaviorHandle,\n\tBehaviorRef,\n} from '../behaviors/behavior-descriptor';\nimport type { TransformState } from '../capabilities/transform-store';\n\n/**\n * Minimal, runtime-agnostic entity options contract.\n *\n * The full engine entity (in `@zylem/game-lib`) provides a richer options type,\n * but behaviors only rely on this loose shape.\n */\nexport interface GameEntityOptions {\n\t[key: string]: any;\n\tname?: string;\n}\n\n/**\n * Structural stand-in for the engine `GameEntity`.\n *\n * Behaviors annotate against this loose contract so that `@zylem/behaviors`\n * (and its `@zylem/behaviors/core` surface) never has to depend on the concrete\n * `@zylem/game-lib` entity implementation. The real engine entity is\n * structurally assignable to this type.\n */\nexport class GameEntity<TOptions = unknown> {\n\t[key: string]: any;\n\n\tuuid!: string;\n\tname!: string;\n\ttype!: string;\n\toptions?: TOptions & Record<string, unknown>;\n\tgroup: any = null;\n\tmesh?: any;\n\tmaterials?: any[];\n\t/** Opaque host-owned physics references (never inspected by behaviors). */\n\tbody: unknown | null = null;\n\tcollider: unknown | null = null;\n\tcolliderDesc?: any;\n\tcolliderDescs: any[] = [];\n\tbodyDesc?: any;\n\tphysicsAttached = false;\n\truntimeHandle?: number;\n\ttransformStore?: TransformState;\n\tnodeDestroy?: any;\n\tisInstanced?: boolean;\n\n\tprivate __behaviorRefs: BehaviorRef<any>[] = [];\n\n\tcreate(): this {\n\t\treturn this;\n\t}\n\n\tonCleanup(callback: () => void): this {\n\t\tvoid callback;\n\t\treturn this;\n\t}\n\n\tsetPosition(_x: number, _y: number, _z: number): void {}\n\tsetRotation(_x: number, _y: number, _z: number): void {}\n\tsetRotationZ(_z: number): void {}\n\tsetScale(_x: number, _y: number, _z: number): void {}\n\n\t/**\n\t * Attach a behavior to this entity. The real engine entity does substantially\n\t * more, but this functional stub stores the merged ref and builds the handle\n\t * so descriptor/handle logic (and tests that drive behaviors directly) work\n\t * without the full engine.\n\t */\n\tuse<\n\t\tO extends Record<string, any>,\n\t\tH extends Record<string, any> = Record<string, never>,\n\t>(\n\t\tdescriptor: BehaviorDescriptor<O, H>,\n\t\toptions?: Partial<O>,\n\t): BehaviorHandle<O, H> {\n\t\tconst mergedOptions = {\n\t\t\t...(descriptor.defaultOptions as O),\n\t\t\t...(options ?? {}),\n\t\t} as O;\n\t\tconst ref: BehaviorRef<O> = { descriptor, options: mergedOptions };\n\t\tthis.__behaviorRefs.push(ref as BehaviorRef<any>);\n\n\t\tconst baseHandle = {\n\t\t\tgetFSM: () => ref.fsm ?? null,\n\t\t\tgetOptions: () => ref.options,\n\t\t\tref,\n\t\t};\n\t\tconst extra = descriptor.createHandle\n\t\t\t? descriptor.createHandle(ref)\n\t\t\t: ({} as H);\n\t\treturn { ...baseHandle, ...extra } as BehaviorHandle<O, H>;\n\t}\n\n\t/** Live behavior refs attached via {@link use}. */\n\tgetBehaviorRefs(): BehaviorRef<any>[] {\n\t\treturn this.__behaviorRefs;\n\t}\n}\n\n/**\n * Factory contract injected into behavior systems via\n * {@link BehaviorSystemContext.createEntity}. The host engine supplies the real\n * entity factory at stage-construction time.\n */\nexport type CreateEntityFn = (\n\toptions?: Partial<GameEntityOptions>,\n) => GameEntity<GameEntityOptions>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AA2Df,SAAS,qBAAqB,SAAmD;AACvF,QAAM,eAA+B;AAAA,IACpC,UAAU,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAAA,IAC7B,UAAU,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAAA,IACnC,UAAU,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAAA,IAC7B,iBAAiB,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAAA,IACpC,kBAAkB,CAAC;AAAA,IACnB,OAAO;AAAA,MACN,UAAU;AAAA,MACV,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,IAClB;AAAA,EACD;AAEA,SAAO,MAAM;AAAA,IACZ,GAAG;AAAA,IACH,GAAG;AAAA;AAAA,IAEH,OAAO;AAAA,MACN,GAAG,aAAa;AAAA,MAChB,GAAG,SAAS;AAAA,IACb;AAAA,EACD,CAAC;AACF;;;ACzEO,SAAS,kBACf,OACA,UACA,QACA,UAAiC,CAAC,GAC3B;AACP,QAAM,OAAO,MAAM,iBAAiB,QAAQ;AAC5C,QAAM,OAAO,QAAQ,QAAQ,MA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AAM,IAAI;AAAA,MACtB;AAAA,IACD;AACA,UAAM,QAAQ,WAAW,eACtB,WAAW,aAAa,GAAG,IAC1B,CAAC;AACL,WAAO,EAAE,GAAG,YAAY,GAAG,MAAM;AAAA,EAClC;AAAA;AAAA,EAGA,kBAAsC;AACrC,WAAO,KAAK;AAAA,EACb;AACD;","names":["moveX","moveY","moveZ"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/first-person.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/jumper-2d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/jumper-3d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/ricochet-2d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/ricochet-3d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/runtime-2d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/behaviors/runtime-2d/runtime-2d.descriptor.ts"],"sourcesContent":["/**\n * Runtime 2D Behavior Descriptors\n *\n * Marker descriptors for entities managed entirely by the wasm gameplay-2d\n * runtime (paddle-and-ball style games, boundaries, trigger regions, goal\n * zones). The descriptors carry configuration and event wiring only — all\n * per-frame simulation happens inside the wasm runtime, so their systems are\n * no-ops. The host runtime binds concrete callbacks onto the behavior refs\n * (see {@link bindRuntimeDynamicCircleBody2DHandle} and the emit helpers).\n */\n\nimport {\n\tdefineBehavior,\n\ttype BehaviorRef,\n} from '../behavior-descriptor';\nimport type { BehaviorSystem } from '../behavior-system';\n\nexport interface RuntimeDynamicCircleBody2DOptions {\n\tinitialVelocity: readonly [number, number];\n}\n\nexport interface RuntimeDynamicCircleBody2DHandle {\n\tsetRuntimePosition(x: number, y: number, z?: number): void;\n\tsetRuntimeVelocity(x: number, y: number): void;\n\tgetRuntimePosition(): { x: number; y: number; z: number } | null;\n}\n\nexport interface RuntimePlayerInput2DOptions {\n\tplayer: 'p1' | 'p2';\n\tspeed: number;\n}\n\nexport interface RuntimeBoundary2DOptions {\n\tboundaries: {\n\t\tleft: number;\n\t\tright: number;\n\t\tbottom: number;\n\t\ttop: number;\n\t};\n}\n\nexport interface RuntimeRicochet2DOptions {\n\tminSpeed: number;\n\tmaxSpeed: number;\n\tspeedMultiplier: number;\n\treflectionMode: 'simple' | 'angled';\n\tmaxAngleDeg: number;\n}\n\nexport interface RuntimeRicochet2DEvent {\n\tkind: 'wall' | 'paddle';\n}\n\nexport interface RuntimeRicochet2DHandle {\n\tonRicochet(callback: (event: RuntimeRicochet2DEvent) => void): () => void;\n}\n\n/** Registers a gameplay2d trigger AABB (sensor); wasm reports overlap via {@link emitRuntimeTriggerRegionEnter}. */\nexport interface RuntimeTriggerRegion2DOptions {\n\ttriggerId: number;\n\thalfExtents: readonly [number, number];\n}\n\nexport interface RuntimeTriggerRegion2DEvent {\n\ttriggerId: number;\n}\n\nexport interface RuntimeTriggerRegion2DHandle {\n\tonRegionEnter(callback: (event: RuntimeTriggerRegion2DEvent) => void): () => void;\n}\n\nexport interface RuntimeGoalZone2DOptions {\n\tscorer: 'p1' | 'p2';\n}\n\nexport interface RuntimeGoalZone2DEvent {\n\tscorer: 'p1' | 'p2';\n}\n\nexport interface RuntimeGoalZone2DHandle {\n\tonGoal(callback: (event: RuntimeGoalZone2DEvent) => void): () => void;\n}\n\nconst runtimeNoopSystemFactory = (): BehaviorSystem => ({\n\tupdate(_ecs: unknown, _delta: number) {},\n});\n\nexport const RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-dynamic-circle-body-2d');\nexport const RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-player-input-2d');\nexport const RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-boundary-2d');\nexport const RUNTIME_RICOCHET_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-ricochet-2d');\nexport const RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-trigger-region-2d');\nexport const RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-goal-zone-2d');\n\nconst RICOCHET_LISTENERS = Symbol('runtime-ricochet-listeners');\nconst TRIGGER_REGION_LISTENERS = Symbol('runtime-trigger-region-listeners');\nconst GOAL_LISTENERS = Symbol('runtime-goal-listeners');\nconst CIRCLE_BODY_SET_POSITION = Symbol('runtime-circle-body-set-position');\nconst CIRCLE_BODY_SET_VELOCITY = Symbol('runtime-circle-body-set-velocity');\nconst CIRCLE_BODY_GET_POSITION = Symbol('runtime-circle-body-get-position');\n\nfunction getListeners<E>(ref: BehaviorRef<any>, slot: symbol): Array<(event: E) => void> {\n\tlet listeners = (ref as any)[slot] as Array<(event: E) => void> | undefined;\n\tif (!listeners) {\n\t\tlisteners = [];\n\t\t(ref as any)[slot] = listeners;\n\t}\n\treturn listeners;\n}\n\nfunction addListener<E>(ref: BehaviorRef<any>, slot: symbol, callback: (event: E) => void): () => void {\n\tconst listeners = getListeners<E>(ref, slot);\n\tlisteners.push(callback);\n\treturn () => {\n\t\tconst index = listeners.indexOf(callback);\n\t\tif (index >= 0) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\t};\n}\n\nfunction emit<E>(ref: BehaviorRef<any>, slot: symbol, event: E): void {\n\tconst listeners = (ref as any)[slot] as Array<(event: E) => void> | undefined;\n\tif (!listeners) return;\n\tfor (const listener of listeners) {\n\t\tlistener(event);\n\t}\n}\n\nexport const RuntimeDynamicCircleBody2DBehavior = defineBehavior<\n\tRuntimeDynamicCircleBody2DOptions,\n\tRuntimeDynamicCircleBody2DHandle\n>({\n\tname: 'runtime-dynamic-circle-body-2d',\n\tdefaultOptions: {\n\t\tinitialVelocity: [0, 0] as [number, number],\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>) => ({\n\t\tsetRuntimePosition(x: number, y: number, z: number = 0): void {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_SET_POSITION] as\n\t\t\t\t| ((x: number, y: number, z: number) => void)\n\t\t\t\t| undefined;\n\t\t\tcallback?.(x, y, z);\n\t\t},\n\t\tsetRuntimeVelocity(x: number, y: number): void {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_SET_VELOCITY] as\n\t\t\t\t| ((x: number, y: number) => void)\n\t\t\t\t| undefined;\n\t\t\tcallback?.(x, y);\n\t\t},\n\t\tgetRuntimePosition(): { x: number; y: number; z: number } | null {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_GET_POSITION] as\n\t\t\t\t| (() => { x: number; y: number; z: number } | null)\n\t\t\t\t| undefined;\n\t\t\treturn callback?.() ?? null;\n\t\t},\n\t}),\n});\n\nexport const RuntimePlayerInput2DBehavior = defineBehavior<RuntimePlayerInput2DOptions>({\n\tname: 'runtime-player-input-2d',\n\tdefaultOptions: {\n\t\tplayer: 'p1',\n\t\tspeed: 5,\n\t} as RuntimePlayerInput2DOptions,\n\tsystemFactory: runtimeNoopSystemFactory,\n});\n\nexport const RuntimeBoundary2DBehavior = defineBehavior({\n\tname: 'runtime-boundary-2d',\n\tdefaultOptions: {\n\t\tboundaries: {\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\tbottom: 0,\n\t\t\ttop: 0,\n\t\t},\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n});\n\nexport const RuntimeRicochet2DBehavior = defineBehavior<\n\tRuntimeRicochet2DOptions,\n\tRuntimeRicochet2DHandle\n>({\n\tname: 'runtime-ricochet-2d',\n\tdefaultOptions: {\n\t\tminSpeed: 2,\n\t\tmaxSpeed: 20,\n\t\tspeedMultiplier: 1.05,\n\t\treflectionMode: 'angled' as const,\n\t\tmaxAngleDeg: 60,\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeRicochet2DOptions>) => ({\n\t\tonRicochet: (callback: (event: RuntimeRicochet2DEvent) => void) =>\n\t\t\taddListener(ref, RICOCHET_LISTENERS, callback),\n\t}),\n});\n\nexport const RuntimeTriggerRegion2DBehavior = defineBehavior<\n\tRuntimeTriggerRegion2DOptions,\n\tRuntimeTriggerRegion2DHandle\n>({\n\tname: 'runtime-trigger-region-2d',\n\tdefaultOptions: {\n\t\ttriggerId: 0,\n\t\thalfExtents: [0.5, 2.5] as [number, number],\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeTriggerRegion2DOptions>) => ({\n\t\tonRegionEnter: (callback: (event: RuntimeTriggerRegion2DEvent) => void) =>\n\t\t\taddListener(ref, TRIGGER_REGION_LISTENERS, callback),\n\t}),\n});\n\nexport const RuntimeGoalZone2DBehavior = defineBehavior<\n\tRuntimeGoalZone2DOptions,\n\tRuntimeGoalZone2DHandle\n>({\n\tname: 'runtime-goal-zone-2d',\n\tdefaultOptions: {\n\t\tscorer: 'p1',\n\t} as RuntimeGoalZone2DOptions,\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeGoalZone2DOptions>) => ({\n\t\tonGoal: (callback: (event: RuntimeGoalZone2DEvent) => void) =>\n\t\t\taddListener(ref, GOAL_LISTENERS, callback),\n\t}),\n});\n\nexport function emitRuntimeRicochet(\n\tref: BehaviorRef<RuntimeRicochet2DOptions>,\n\tevent: RuntimeRicochet2DEvent,\n): void {\n\temit(ref, RICOCHET_LISTENERS, event);\n}\n\nexport function emitRuntimeTriggerRegionEnter(\n\tref: BehaviorRef<RuntimeTriggerRegion2DOptions>,\n\tevent: RuntimeTriggerRegion2DEvent,\n): void {\n\temit(ref, TRIGGER_REGION_LISTENERS, event);\n}\n\nexport function emitRuntimeGoal(\n\tref: BehaviorRef<RuntimeGoalZone2DOptions>,\n\tevent: RuntimeGoalZone2DEvent,\n): void {\n\temit(ref, GOAL_LISTENERS, event);\n}\n\nexport function bindRuntimeDynamicCircleBody2DHandle(\n\tref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>,\n\tcontrols: {\n\t\tsetPosition: (x: number, y: number, z: number) => void;\n\t\tsetVelocity: (x: number, y: number) => void;\n\t\tgetPosition: () => { x: number; y: number; z: number } | null;\n\t},\n): void {\n\t(ref as any)[CIRCLE_BODY_SET_POSITION] = controls.setPosition;\n\t(ref as any)[CIRCLE_BODY_SET_VELOCITY] = controls.setVelocity;\n\t(ref as any)[CIRCLE_BODY_GET_POSITION] = controls.getPosition;\n}\n"],"mappings":";;;;;;AAmFA,IAAM,2BAA2B,OAAuB;AAAA,EACvD,O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IAAM,4BAA4B,eAGvC;AAAA,EACD,MAAM;AAAA,EACN,gBAAgB;AAAA,IACf,QAAQ;AAAA,EACT;AAAA,EACA,eAAe;AAAA,EACf,cAAc,CAAC,SAAgD;AAAA,IAC9D,QAAQ,CAAC,aACR,YAAY,KAAK,gBAAgB,QAAQ;AAAA,EAC3C;AACD,CAAC;AAEM,SAAS,oBACf,KACA,OACO;AACP,OAAK,KAAK,oBAAoB,KAAK;AACpC;AAEO,SAAS,8BACf,KACA,OACO;AACP,OAAK,KAAK,0BAA0B,KAAK;AAC1C;AAEO,SAAS,gBACf,KACA,OACO;AACP,OAAK,KAAK,gBAAgB,KAAK;AAChC;AAEO,SAAS,qCACf,KACA,UAKO;AACP,EAAC,IAAY,wBAAwB,IAAI,SAAS;AAClD,EAAC,IAAY,wBAAwB,IAAI,SAAS;AAClD,EAAC,IAAY,wBAAwB,IAAI,SAAS;AACnD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/screen-wrap.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/shooter-2d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/thruster.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|