@iwsdk/core 0.5.3 → 1.0.0-rc.1
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/README.md +22 -1
- package/dist/asset/asset-manager.d.ts.map +1 -1
- package/dist/asset/asset-manager.js +3 -2
- package/dist/asset/asset-manager.js.map +1 -1
- package/dist/asset/cache-manager.js.map +1 -1
- package/dist/asset/loaders/audio-loader.js.map +1 -1
- package/dist/asset/loaders/cached-asset-load.js.map +1 -1
- package/dist/asset/loaders/gltf-loader.js.map +1 -1
- package/dist/asset/loaders/hdr-texture-loader.js.map +1 -1
- package/dist/asset/loaders/texture-loader.js.map +1 -1
- package/dist/asset/loaders/uikitml-loader.js.map +1 -1
- package/dist/audio/audio-pool.js.map +1 -1
- package/dist/audio/audio-system.js.map +1 -1
- package/dist/audio/audio-utils.js.map +1 -1
- package/dist/audio/audio.js.map +1 -1
- package/dist/camera/camera-source.js.map +1 -1
- package/dist/camera/camera-system.d.ts +7 -3
- package/dist/camera/camera-system.d.ts.map +1 -1
- package/dist/camera/camera-system.js +81 -50
- package/dist/camera/camera-system.js.map +1 -1
- package/dist/camera/camera-utils.d.ts +5 -0
- package/dist/camera/camera-utils.d.ts.map +1 -1
- package/dist/camera/camera-utils.js +8 -1
- package/dist/camera/camera-utils.js.map +1 -1
- package/dist/camera/types.js.map +1 -1
- package/dist/depth/depth-occludable.js.map +1 -1
- package/dist/depth/depth-sensing-system.d.ts +3 -0
- package/dist/depth/depth-sensing-system.d.ts.map +1 -1
- package/dist/depth/depth-sensing-system.js +55 -1
- package/dist/depth/depth-sensing-system.js.map +1 -1
- package/dist/depth/depth-textures.js.map +1 -1
- package/dist/depth/occlusion/preprocessing-pass.js.map +1 -1
- package/dist/depth/occlusion/preprocessing-shader.glsl.js.map +1 -1
- package/dist/ecs/builtin-components.js.map +1 -1
- package/dist/ecs/component-editor-metadata.js.map +1 -1
- package/dist/ecs/component-manifest.js.map +1 -1
- package/dist/ecs/entity.js.map +1 -1
- package/dist/ecs/system.js.map +1 -1
- package/dist/ecs/world.d.ts +2 -0
- package/dist/ecs/world.d.ts.map +1 -1
- package/dist/ecs/world.js +4 -0
- package/dist/ecs/world.js.map +1 -1
- package/dist/environment/dome-gradient.js.map +1 -1
- package/dist/environment/dome-texture.js.map +1 -1
- package/dist/environment/environment-system.js.map +1 -1
- package/dist/environment/gradient-environment.js.map +1 -1
- package/dist/environment/ibl-gradient.js.map +1 -1
- package/dist/environment/ibl-texture.js.map +1 -1
- package/dist/environment/scene-ar-environment.js.map +1 -1
- package/dist/environment-raycast/environment-raycast.js.map +1 -1
- package/dist/environment-raycast/raycast-target.js.map +1 -1
- package/dist/grab/distance-grabbable.d.ts +5 -0
- package/dist/grab/distance-grabbable.d.ts.map +1 -1
- package/dist/grab/distance-grabbable.js +5 -0
- package/dist/grab/distance-grabbable.js.map +1 -1
- package/dist/grab/grab-helpers.js.map +1 -1
- package/dist/grab/grab-system.js.map +1 -1
- package/dist/grab/grab-warnings.js.map +1 -1
- package/dist/grab/grabbed.js.map +1 -1
- package/dist/grab/handles.d.ts +6 -0
- package/dist/grab/handles.d.ts.map +1 -1
- package/dist/grab/handles.js +46 -12
- package/dist/grab/handles.js.map +1 -1
- package/dist/grab/index.js.map +1 -1
- package/dist/grab/one-hand-grabbable.d.ts +5 -0
- package/dist/grab/one-hand-grabbable.d.ts.map +1 -1
- package/dist/grab/one-hand-grabbable.js +5 -0
- package/dist/grab/one-hand-grabbable.js.map +1 -1
- package/dist/grab/pointer-events-patch.js.map +1 -1
- package/dist/grab/two-hands-grabbable.d.ts +5 -0
- package/dist/grab/two-hands-grabbable.d.ts.map +1 -1
- package/dist/grab/two-hands-grabbable.js +5 -0
- package/dist/grab/two-hands-grabbable.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/init/browser-camera.js.map +1 -1
- package/dist/init/index.d.ts +2 -2
- package/dist/init/index.d.ts.map +1 -1
- package/dist/init/player-camera.js.map +1 -1
- package/dist/init/session-grant.d.ts +34 -0
- package/dist/init/session-grant.d.ts.map +1 -0
- package/dist/init/session-grant.js +89 -0
- package/dist/init/session-grant.js.map +1 -0
- package/dist/init/world-initializer.d.ts +87 -4
- package/dist/init/world-initializer.d.ts.map +1 -1
- package/dist/init/world-initializer.js +45 -41
- package/dist/init/world-initializer.js.map +1 -1
- package/dist/init/xr.d.ts +19 -0
- package/dist/init/xr.d.ts.map +1 -1
- package/dist/init/xr.js +136 -41
- package/dist/init/xr.js.map +1 -1
- package/dist/input/canvas-pointer-system.d.ts +2 -0
- package/dist/input/canvas-pointer-system.d.ts.map +1 -1
- package/dist/input/canvas-pointer-system.js +33 -13
- package/dist/input/canvas-pointer-system.js.map +1 -1
- package/dist/input/input-actions.js.map +1 -1
- package/dist/input/input-manager.js.map +1 -1
- package/dist/input/input-system.d.ts.map +1 -1
- package/dist/input/input-system.js +5 -2
- package/dist/input/input-system.js.map +1 -1
- package/dist/input/state-tags.js.map +1 -1
- package/dist/input/stateful-browser-gamepad.js.map +1 -1
- package/dist/input/stateful-keyboard.js.map +1 -1
- package/dist/layers/xr-cylinder-layer.d.ts +2 -1
- package/dist/layers/xr-cylinder-layer.d.ts.map +1 -1
- package/dist/layers/xr-cylinder-layer.js +2 -1
- package/dist/layers/xr-cylinder-layer.js.map +1 -1
- package/dist/layers/xr-layer-init.d.ts +19 -0
- package/dist/layers/xr-layer-init.d.ts.map +1 -0
- package/dist/layers/xr-layer-init.js +20 -0
- package/dist/layers/xr-layer-init.js.map +1 -0
- package/dist/layers/xr-layer-state.js.map +1 -1
- package/dist/layers/xr-layer-system.d.ts +41 -1
- package/dist/layers/xr-layer-system.d.ts.map +1 -1
- package/dist/layers/xr-layer-system.js +506 -132
- package/dist/layers/xr-layer-system.js.map +1 -1
- package/dist/layers/xr-layer-transform.d.ts +18 -0
- package/dist/layers/xr-layer-transform.d.ts.map +1 -0
- package/dist/layers/xr-layer-transform.js +115 -0
- package/dist/layers/xr-layer-transform.js.map +1 -0
- package/dist/layers/xr-quad-layer.d.ts +2 -1
- package/dist/layers/xr-quad-layer.d.ts.map +1 -1
- package/dist/layers/xr-quad-layer.js +2 -1
- package/dist/layers/xr-quad-layer.js.map +1 -1
- package/dist/level/level-component-applier.d.ts +2 -0
- package/dist/level/level-component-applier.d.ts.map +1 -1
- package/dist/level/level-component-applier.js +24 -5
- package/dist/level/level-component-applier.js.map +1 -1
- package/dist/level/level-player-rig.js.map +1 -1
- package/dist/level/level-root.js.map +1 -1
- package/dist/level/level-scene-environment.js.map +1 -1
- package/dist/level/level-scene-json-importer.js.map +1 -1
- package/dist/level/level-scene-material.js.map +1 -1
- package/dist/level/level-scene-object.js.map +1 -1
- package/dist/level/level-scene-primitive.js.map +1 -1
- package/dist/level/level-system.js.map +1 -1
- package/dist/level/level-tag.js.map +1 -1
- package/dist/lighting/light-binding.js.map +1 -1
- package/dist/lighting/light-components.js.map +1 -1
- package/dist/lighting/light-system.js.map +1 -1
- package/dist/locomotion/geometries/beveled-cylinder.js.map +1 -1
- package/dist/locomotion/locomotion-environment.js.map +1 -1
- package/dist/locomotion/locomotion-input-provider.js.map +1 -1
- package/dist/locomotion/locomotion.js.map +1 -1
- package/dist/locomotion/materials/line.js.map +1 -1
- package/dist/locomotion/slide.js.map +1 -1
- package/dist/locomotion/teleport.js.map +1 -1
- package/dist/locomotion/turn.js.map +1 -1
- package/dist/mcp/ecs-debug-tools.d.ts +4 -1
- package/dist/mcp/ecs-debug-tools.d.ts.map +1 -1
- package/dist/mcp/ecs-debug-tools.js +113 -10
- package/dist/mcp/ecs-debug-tools.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/mcp-runtime.d.ts +2 -0
- package/dist/mcp/mcp-runtime.d.ts.map +1 -1
- package/dist/mcp/mcp-runtime.js +41 -0
- package/dist/mcp/mcp-runtime.js.map +1 -1
- package/dist/mcp/scene-tools.js.map +1 -1
- package/dist/mcp/ui-debug-tools.d.ts +56 -0
- package/dist/mcp/ui-debug-tools.d.ts.map +1 -0
- package/dist/mcp/ui-debug-tools.js +412 -0
- package/dist/mcp/ui-debug-tools.js.map +1 -0
- package/dist/physics/index.js +1 -1
- package/dist/physics/physics-runtime.d.ts +22 -0
- package/dist/physics/physics-runtime.d.ts.map +1 -0
- package/dist/physics/physics-runtime.js +423 -0
- package/dist/physics/physics-runtime.js.map +1 -0
- package/dist/physics/physics-system.d.ts +84 -108
- package/dist/physics/physics-system.d.ts.map +1 -1
- package/dist/physics/physics-system.js +686 -555
- package/dist/physics/physics-system.js.map +1 -1
- package/dist/physics/physics-transport.d.ts +20 -0
- package/dist/physics/physics-transport.d.ts.map +1 -0
- package/dist/physics/physics-transport.js +111 -0
- package/dist/physics/physics-transport.js.map +1 -0
- package/dist/physics/physics-worker-protocol.d.ts +144 -0
- package/dist/physics/physics-worker-protocol.d.ts.map +1 -0
- package/dist/physics/physics-worker-protocol.js +41 -0
- package/dist/physics/physics-worker-protocol.js.map +1 -0
- package/dist/physics/physics-worker-utils.d.ts +8 -0
- package/dist/physics/physics-worker-utils.d.ts.map +1 -0
- package/dist/physics/physics-worker-utils.js +12 -0
- package/dist/physics/physics-worker-utils.js.map +1 -0
- package/dist/physics/physics-worker.d.ts +8 -0
- package/dist/physics/physics-worker.d.ts.map +1 -0
- package/dist/physics/physics-worker.js +66 -0
- package/dist/physics/physics-worker.js.map +1 -0
- package/dist/physics/physicsBody.js.map +1 -1
- package/dist/physics/physicsManipulation.js.map +1 -1
- package/dist/physics/physicsShape.js.map +1 -1
- package/dist/physics/utils.js.map +1 -1
- package/dist/project/normalize.js +7 -1
- package/dist/project/normalize.js.map +1 -1
- package/dist/project/paths.js.map +1 -1
- package/dist/project/types.d.ts +7 -1
- package/dist/project/types.d.ts.map +1 -1
- package/dist/project/types.js.map +1 -1
- package/dist/project/validation.js +36 -2
- package/dist/project/validation.js.map +1 -1
- package/dist/runtime/three.js.map +1 -1
- package/dist/scene-understanding/anchor.js.map +1 -1
- package/dist/scene-understanding/mesh.js.map +1 -1
- package/dist/scene-understanding/plane.js.map +1 -1
- package/dist/scene-understanding/scene-understanding-system.d.ts +42 -6
- package/dist/scene-understanding/scene-understanding-system.d.ts.map +1 -1
- package/dist/scene-understanding/scene-understanding-system.js +391 -106
- package/dist/scene-understanding/scene-understanding-system.js.map +1 -1
- package/dist/schemas/iwsdk-project.v1.schema.json +20 -1
- package/dist/transform/synced-euler.js.map +1 -1
- package/dist/transform/synced-quaternion.js.map +1 -1
- package/dist/transform/synced-vector3.js.map +1 -1
- package/dist/transform/transform-component.js.map +1 -1
- package/dist/transform/transform-utils.js.map +1 -1
- package/dist/transform/transform.js.map +1 -1
- package/dist/ui/document.js.map +1 -1
- package/dist/ui/follow-component.js.map +1 -1
- package/dist/ui/follow.d.ts.map +1 -1
- package/dist/ui/follow.js +0 -1
- package/dist/ui/follow.js.map +1 -1
- package/dist/ui/panel-components.js.map +1 -1
- package/dist/ui/screenspace-component.js.map +1 -1
- package/dist/ui/screenspace.js.map +1 -1
- package/dist/ui/ui.js.map +1 -1
- package/dist/ui/uikitml-asset.js.map +1 -1
- package/dist/ui/uikitml.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/visibility/visibility-component.js.map +1 -1
- package/dist/visibility/visibility.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locomotion-input-provider.js","sources":["../../src/locomotion/locomotion-input-provider.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"locomotion-input-provider.js","sources":["../../src/locomotion/locomotion-input-provider.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { World } from '../ecs/world.js';\nimport { InputActions } from '../input/input-actions.js';\nimport { Quaternion, Vector2, Vector3 } from '../runtime/index.js';\n\nconst TURN_THRESHOLD = 0.8;\n\nexport type BrowserLocomotionControls =\n | boolean\n | {\n keyboard?: boolean;\n gamepad?: boolean;\n /** Reserved for a future pointer-lock camera adapter. */\n pointerLock?: false;\n };\n\n/**\n * Converts low-level input actions into locomotion intent.\n *\n * Locomotion should not care whether input came from XR controllers, keyboard,\n * browser gamepads, or an app-authored adapter. This provider is the narrow\n * bridge between generic actions and the existing locomotor systems.\n */\nexport class ActionLocomotionInputProvider {\n constructor(private readonly world: World) {}\n\n enableBrowserControls(options: BrowserLocomotionControls): void {\n if (!options) {\n return;\n }\n\n const bindingOptions =\n typeof options === 'object'\n ? {\n keyboard: options.keyboard,\n gamepad: options.gamepad,\n }\n : undefined;\n\n this.world.input.actions.enableDefaultBindings(\n 'browser-first-person',\n bindingOptions,\n );\n }\n\n getMoveAxis(out: Vector2): Vector2 {\n const value = this.world.input.actions.getAxis2D(\n InputActions.LocomotionMove,\n );\n return out.set(value.x, value.y);\n }\n\n getMovementReferenceQuaternion(out: Quaternion): Quaternion {\n if (this.world.session) {\n this.world.player.head.getWorldQuaternion(out);\n } else {\n this.world.camera.getWorldQuaternion(out);\n }\n return out;\n }\n\n getJumpDown(): boolean {\n return this.world.input.actions.getButtonDown(InputActions.LocomotionJump);\n }\n\n getTurnAxis(): number {\n return this.world.input.actions.getAxis1D(InputActions.LocomotionTurn);\n }\n\n getTurnLeftDown(microGestureControlsEnabled: boolean): boolean {\n if (this.isHandMicroGestureMode(microGestureControlsEnabled)) {\n return this.world.input.xr.gamepads.right?.getButtonDownByIdx(5) ?? false;\n }\n\n return this.world.input.actions.getAxis1DEnteringNegative(\n InputActions.LocomotionTurn,\n TURN_THRESHOLD,\n );\n }\n\n getTurnRightDown(microGestureControlsEnabled: boolean): boolean {\n if (this.isHandMicroGestureMode(microGestureControlsEnabled)) {\n return this.world.input.xr.gamepads.right?.getButtonDownByIdx(6) ?? false;\n }\n\n return this.world.input.actions.getAxis1DEnteringPositive(\n InputActions.LocomotionTurn,\n TURN_THRESHOLD,\n );\n }\n\n shouldShowTurnSignals(microGestureControlsEnabled: boolean): boolean {\n return this.isHandMicroGestureMode(microGestureControlsEnabled);\n }\n\n getTeleportActive(\n pointerBusy: boolean,\n microGestureControlsEnabled: boolean,\n ): boolean {\n if (pointerBusy) {\n return false;\n }\n\n if (this.world.input.xr.isPrimary('hand', 'right')) {\n return (\n microGestureControlsEnabled &&\n !(this.world.input.xr.gamepads.right?.getButtonDownByIdx(9) ?? false)\n );\n }\n\n return this.world.input.actions.getButtonPressed(\n InputActions.LocomotionTeleportAim,\n );\n }\n\n getTeleportCommit(microGestureControlsEnabled: boolean): boolean {\n if (this.world.input.xr.isPrimary('hand', 'right')) {\n return (\n microGestureControlsEnabled &&\n (this.world.input.xr.gamepads.right?.getButtonDownByIdx(9) ?? false)\n );\n }\n\n return this.world.input.actions.getButtonUp(\n InputActions.LocomotionTeleportAim,\n );\n }\n\n getTeleportRay(origin: Vector3, direction: Vector3): boolean {\n if (!this.world.session) {\n return false;\n }\n\n this.world.player.raySpaces.right.getWorldPosition(origin);\n this.world.player.raySpaces.right.getWorldDirection(direction);\n return true;\n }\n\n private isHandMicroGestureMode(\n microGestureControlsEnabled: boolean,\n ): boolean {\n return (\n microGestureControlsEnabled &&\n this.world.input.xr.isPrimary('hand', 'right')\n );\n }\n}\n\nexport function getRequiredInputProvider(\n systemName: string,\n value: unknown,\n): ActionLocomotionInputProvider {\n if (value instanceof ActionLocomotionInputProvider) {\n return value;\n }\n\n throw new Error(\n `${systemName} must be registered through LocomotionSystem so locomotion subsystems share one input provider.`,\n );\n}\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAMH,MAAM,cAAc,GAAG,GAAG;AAW1B;;;;;;AAMG;MACU,6BAA6B,CAAA;AACxC,IAAA,WAAA,CAA6B,KAAY,EAAA;QAAZ,IAAA,CAAA,KAAK,GAAL,KAAK;IAAU;AAE5C,IAAA,qBAAqB,CAAC,OAAk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I,IAAI,CAAC,UAAU,EAAE;4BACnB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,2BAA2B,CAAC,KAAK,GAAG,IAAI;wBACjE;AACA,wBAAA,IAAI,IAAI,CAAC,cAAc,EAAE;4BACvB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,2BAA2B,CAAC,KAAK,GAAG,IAAI;wBACrE;oBACF;gBACF;AAAO,qBAAA,IAAI,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE;AACnC,oBAAA,IAAI,IAAI,CAAC,2BAA2B,EAAE;AACpC,wBAAA,IAAI,CAAC,2BAA2B,GAAG,KAAK;AACxC,wBAAA,IAAI,IAAI,CAAC,UAAU,EAAE;4BACnB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,2BAA2B,CAAC,KAAK,GAAG,KAAK;wBAClE;AACA,wBAAA,IAAI,IAAI,CAAC,cAAc,EAAE;4BACvB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,2BAA2B,CAAC,KAAK,GAAG,KAAK;wBACtE;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAO,GAAA;QACL,KAAK,CAAC,OAAO,EAAE;AACf,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE;AAClB,YAAA,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;QAC5B;AACA,QAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,CAAC;AACvC,QAAA,IAAI,IAAI,CAAC,cAAc,EAAE;AACvB,YAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC;QAC7C;AACA,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AACpB,YAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC;QAC1C;IACF;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"locomotion.js","sources":["../../src/locomotion/locomotion.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Locomotor, LocomotorConfig } from '@iwsdk/locomotor';\nimport { Types } from '../ecs/component.js';\nimport { Entity } from '../ecs/entity.js';\nimport { createSystem } from '../ecs/system.js';\nimport { Vector3 } from '../runtime/index.js';\nimport { LocomotionEnvironment } from './locomotion-environment.js';\nimport {\n ActionLocomotionInputProvider,\n type BrowserLocomotionControls,\n} from './locomotion-input-provider.js';\nimport { SlideSystem } from './slide.js';\nimport { TeleportSystem } from './teleport.js';\nimport { TurnSystem, TurningMethod } from './turn.js';\n\nexport { LocomotionEnvironment } from './locomotion-environment.js';\n\n/**\n * Physics‑driven locomotion (slide, teleport, turn) backed by the {@link @iwsdk/locomotor!Locomotor} engine.\n *\n * @remarks\n * - Enable this system via {@link WorldOptions.features.enableLocomotion}.\n * - Add {@link LocomotionEnvironment} to level meshes to make them walkable.\n * - For moving platforms, use `EnvironmentType.KINEMATIC` and keep transforms updated.\n * - In hand‑tracking mode, micro‑gesture controls can toggle turn/teleport using swipe gestures.\n *\n * @category Locomotion\n * @example\n * ```ts\n * world.registerSystem(LocomotionSystem, {\n * configData: { turningAngle: 45, slidingSpeed: 4.5 }\n * });\n * ```\n */\nexport class LocomotionSystem extends createSystem(\n {\n envs: { required: [LocomotionEnvironment] },\n },\n {\n /** Starting player position before the first update. */\n initialPlayerPosition: { type: Types.Vec3, default: [0, 0, 0] },\n /** Run the locomotion engine in a WebWorker for better main‑thread perf. */\n useWorker: { type: Types.Boolean, default: true },\n /** Comfort vignette strength forwarded to SlideSystem. */\n comfortAssist: { type: Types.Float32, default: 0.5 },\n /** Maximum sliding speed (m/s). */\n slidingSpeed: { type: Types.Float32, default: 5 },\n /** Turning mode: snap vs smooth. */\n turningMethod: { type: Types.Int8, default: TurningMethod.SnapTurn },\n /** Degrees per snap turn. */\n turningAngle: { type: Types.Float32, default: 45 },\n /** Degrees per second for smooth turning. */\n turningSpeed: { type: Types.Float32, default: 180 },\n /** Parabolic ray gravity for teleport guide (negative). */\n rayGravity: { type: Types.Float32, default: -0.4 },\n /** Max drop allowed when projecting the player onto walkable surfaces. */\n maxDropDistance: { type: Types.Float32, default: 5.0 },\n /** Jump apex height in meters. */\n jumpHeight: { type: Types.Float32, default: 1.5 },\n /** Minimum seconds between jumps. */\n jumpCooldown: { type: Types.Float32, default: 0.1 },\n /** Whether jumping is enabled. */\n enableJumping: { type: Types.Boolean, default: true },\n /** Optional browser bindings for action-backed first-person locomotion. */\n browserControls: { type: Types.Object, default: false },\n },\n) {\n private locomotor!: Locomotor;\n private inputProvider!: ActionLocomotionInputProvider;\n\n private teleportSystem?: TeleportSystem;\n private slideSystem?: SlideSystem;\n private turnSystem!: TurnSystem;\n private microGestureControlsEnabled = false;\n private requestedPlayerPosition?: Vector3;\n\n /** Place the locomotion origin at an authored virtual-environment position. */\n setPlayerPosition(position: Vector3): void {\n this.requestedPlayerPosition ??= new Vector3();\n this.requestedPlayerPosition.copy(position);\n this.config.initialPlayerPosition.value = position.toArray();\n this.player.position.copy(position);\n if (this.locomotor?.isInitialized()) {\n this.locomotor.teleport(position);\n }\n }\n\n init() {\n // Apply the configured starting position synchronously. Native scene\n // loading captures the current player transform as its restoration\n // baseline, while the locomotor finishes initializing asynchronously.\n this.player.position.fromArray(\n this.config.initialPlayerPosition.value as number[],\n );\n this.cleanupFuncs.push(\n this.world.onAuthoredPlayerPosition((position) => {\n this.setPlayerPosition(position);\n }),\n );\n this.inputProvider = new ActionLocomotionInputProvider(this.world);\n this.inputProvider.enableBrowserControls(\n this.config.browserControls.value as BrowserLocomotionControls,\n );\n\n this.world.registerSystem(TurnSystem, {\n configData: {\n turningMethod: this.config.turningMethod.value,\n turningAngle: this.config.turningAngle.value,\n turningSpeed: this.config.turningSpeed.value,\n microGestureControlsEnabled: false,\n inputProvider: this.inputProvider,\n },\n });\n this.turnSystem = this.world.getSystem(TurnSystem)!;\n this.initLocomotor().then(() => {\n this.cleanupFuncs.push(\n this.config.rayGravity.subscribe((value) => {\n this.locomotor.updateConfig({ rayGravity: value });\n if (this.teleportSystem) {\n this.teleportSystem.config.rayGravity.value = value;\n }\n }),\n this.config.slidingSpeed.subscribe((value) => {\n if (this.slideSystem) {\n this.slideSystem.config.maxSpeed.value = value;\n }\n }),\n this.config.comfortAssist.subscribe((value) => {\n if (this.slideSystem) {\n this.slideSystem.config.comfortAssist.value = value;\n }\n }),\n this.config.turningMethod.subscribe((value) => {\n this.turnSystem.config.turningMethod.value = value;\n }),\n this.config.turningAngle.subscribe((value) => {\n this.turnSystem.config.turningAngle.value = value;\n }),\n this.config.turningSpeed.subscribe((value) => {\n this.turnSystem.config.turningSpeed.value = value;\n }),\n this.config.maxDropDistance.subscribe((value) => {\n this.locomotor.updateConfig({ maxDropDistance: value });\n }),\n this.config.jumpHeight.subscribe((value) => {\n this.locomotor.updateConfig({ jumpHeight: value });\n }),\n this.config.jumpCooldown.subscribe((value) => {\n this.locomotor.updateConfig({ jumpCooldown: value });\n }),\n this.config.enableJumping.subscribe((value) => {\n if (this.slideSystem) {\n this.slideSystem.config.enableJumping.value = value;\n }\n }),\n );\n });\n\n // Register the env query subscriptions on cleanupFuncs (the config\n // subscriptions above are already registered) so they're released when the\n // LocomotionSystem is torn down.\n this.cleanupFuncs.push(\n this.queries.envs.subscribe('qualify', (entity) => {\n this.addEnvironmentToEngine(entity);\n }),\n this.queries.envs.subscribe('disqualify', (entity) => {\n this.removeEnvironmentFromEngine(entity);\n }),\n );\n }\n\n private async initLocomotor(): Promise<void> {\n // Create Locomotor with configuration\n const locomotorConfig: LocomotorConfig = {\n initialPlayerPosition:\n this.requestedPlayerPosition?.clone() ??\n new Vector3().fromArray(\n this.config.initialPlayerPosition.value as number[],\n ),\n rayGravity: this.config.rayGravity.value as number,\n maxDropDistance: this.config.maxDropDistance.value as number,\n jumpHeight: this.config.jumpHeight.value as number,\n jumpCooldown: this.config.jumpCooldown.value as number,\n useWorker: this.config.useWorker.value as boolean,\n };\n\n this.locomotor = new Locomotor(locomotorConfig);\n await this.locomotor.initialize();\n if (this.requestedPlayerPosition != null) {\n this.locomotor.teleport(this.requestedPlayerPosition);\n this.player.position.copy(this.requestedPlayerPosition);\n }\n\n // Register subsystems with locomotor\n this.world.registerSystem(TeleportSystem, {\n configData: {\n rayGravity: this.config.rayGravity.value,\n locomotor: this.locomotor,\n inputProvider: this.inputProvider,\n microGestureControlsEnabled: false,\n },\n });\n this.world.registerSystem(SlideSystem, {\n configData: {\n maxSpeed: this.config.slidingSpeed.value,\n comfortAssist: this.config.comfortAssist.value,\n enableJumping: this.config.enableJumping.value,\n locomotor: this.locomotor,\n inputProvider: this.inputProvider,\n },\n });\n\n this.teleportSystem = this.world.getSystem(TeleportSystem);\n this.slideSystem = this.world.getSystem(SlideSystem);\n\n // Add any existing environments to the engine\n for (const entity of this.queries.envs.entities) {\n this.addEnvironmentToEngine(entity);\n }\n }\n\n private addEnvironmentToEngine(entity: Entity): void {\n if (!this.locomotor?.isInitialized()) {\n return;\n }\n if (entity.getValue(LocomotionEnvironment, '_initialized')) {\n return; // Already initialized\n }\n\n const envGroup = entity.object3D;\n if (!envGroup?.isObject3D) {\n return;\n }\n\n const envType = entity.getValue(LocomotionEnvironment, 'type');\n\n if (envType !== null) {\n try {\n // Add environment through Locomotor - returns handle\n const envHandle = this.locomotor.addEnvironment(envGroup, envType);\n\n // Store the generated handle for tracking\n entity.setValue(LocomotionEnvironment, '_envHandle', envHandle);\n entity.setValue(LocomotionEnvironment, '_initialized', true);\n } catch (error) {\n console.error('Failed to add environment to locomotion engine:', error);\n }\n }\n }\n\n private removeEnvironmentFromEngine(entity: Entity): void {\n if (!this.locomotor) {\n return;\n }\n const envHandle = entity.getValue(LocomotionEnvironment, '_envHandle');\n if (envHandle === 0) {\n return; // Not initialized or invalid handle\n } else if (envHandle !== null) {\n this.locomotor.removeEnvironment(envHandle);\n }\n }\n\n update(delta: number): void {\n if (!this.locomotor) {\n return;\n }\n this.locomotor.updateKinematicEnvironments();\n this.locomotor.update(delta);\n this.player.position.copy(this.locomotor.position);\n\n // Toggle micro-gesture controls in hand-tracking mode\n if (this.input.xr.isPrimary('hand', 'right')) {\n const gp = this.input.xr.gamepads.right;\n if (gp) {\n // Swipe up (7) enables; swipe down (8) disables\n if (gp.getButtonDownByIdx(7)) {\n if (!this.microGestureControlsEnabled) {\n this.microGestureControlsEnabled = true;\n if (this.turnSystem) {\n this.turnSystem.config.microGestureControlsEnabled.value = true;\n }\n if (this.teleportSystem) {\n this.teleportSystem.config.microGestureControlsEnabled.value = true;\n }\n }\n } else if (gp.getButtonDownByIdx(8)) {\n if (this.microGestureControlsEnabled) {\n this.microGestureControlsEnabled = false;\n if (this.turnSystem) {\n this.turnSystem.config.microGestureControlsEnabled.value = false;\n }\n if (this.teleportSystem) {\n this.teleportSystem.config.microGestureControlsEnabled.value = false;\n }\n }\n }\n }\n }\n }\n\n destroy(): void {\n super.destroy();\n if (this.locomotor) {\n this.locomotor.terminate();\n }\n this.world.unregisterSystem(TurnSystem);\n if (this.teleportSystem) {\n this.world.unregisterSystem(TeleportSystem);\n }\n if (this.slideSystem) {\n this.world.unregisterSystem(SlideSystem);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;AAKG;AAkBH;;;;;;;;;;;;;;;;AAgBG;AACG,MAAO,gBAAiB,SAAQ,YAAY,CAChD;AACE,IAAA,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,qBAAqB,CAAC,EAAE;CAC5C,EACD;;AAEE,IAAA,qBAAqB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;;IAE/D,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;;IAEjD,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE;;I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AC,OAAO,CAAC,QAAQ,GAAG,EAAE;QAC5B;aAAO;AACL,YAAA,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ;QAC9B;IACF;;AAGA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK;IACpC;IAEA,IAAI,OAAO,CAAC,KAAK,EAAA;AACf,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB;QACF;QACA,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK;IACrC;;;;AAKA,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,WAAW;IACzB;IACA,IAAI,UAAU,CAAC,CAAU,EAAA;AACvB,QAAA,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;IACxB;AAGD;;;;"}
|
|
1
|
+
{"version":3,"file":"line.js","sources":["../../../src/locomotion/materials/line.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n Color,\n ShaderLib,\n ShaderMaterial,\n UniformsLib,\n UniformsUtils,\n Vector3,\n} from '../../runtime/three.js';\n\n// @ts-ignore\nUniformsLib.linee = {\n linewidth: { value: 1 },\n color: { value: new Color(0xffffff) },\n startPoint: { value: new Vector3() },\n endPoint: { value: new Vector3() },\n};\n\nShaderLib['linee'] = {\n uniforms: UniformsUtils.merge([\n UniformsLib.common,\n UniformsLib.fog,\n // @ts-ignore\n UniformsLib.linee,\n ]),\n\n vertexShader: /* glsl */ `\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec3 startPoint;\n\t\tuniform vec3 endPoint;\n\t\tvarying float vDistanceAlpha;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\n\t\t\tworldStart = start.xyz;\n\t\t\tworldEnd = end.xyz;\n\n\t\t\tvec3 currentPosition = (position.y < 0.5) ? instanceStart : instanceEnd;\n \tfloat distanceToStart = length(currentPosition - startPoint);\n\t\t\tfloat startAlpha = smoothstep(0.0, 0.8, distanceToStart);\n \tfloat distanceToEnd = length(currentPosition - endPoint);\n\t\t\tfloat endAlpha = smoothstep(0.5, 2.0, distanceToEnd);\n \t// Compute vDistanceAlpha using smoothstep\n \tvDistanceAlpha = min(startAlpha, endAlpha);\n\t\t\t\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\t\t\tdir = normalize( dir );\n\n\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t// height offset\n\t\t\tfloat hw = linewidth * 0.5;\n\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t// won't be rendering the endcaps\n\n\t\t\t// cap extension\n\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t// add width to the box\n\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t}\n\n\n\t\t\t// project the worldpos\n\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t// shift the depth of the projected points so the line\n\t\t\t// segments overlap neatly\n\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t`,\n\n fragmentShader: /* glsl */ `\n\t\tuniform float linewidth;\n\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\t\tvarying float vDistanceAlpha;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\tvec3 delta = p1 - p2;\n\t\t\tfloat len = length( delta );\n\t\t\tfloat norm = len / linewidth;\n\n\t\t\tif ( norm > 0.5 ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\t#include <logdepthbuf_fragment>\n\n\t\t\tgl_FragColor = vec4( 1.0, 1.0, 1.0, vDistanceAlpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t`,\n};\n\nclass LineMaterial extends ShaderMaterial {\n isLineMaterial = true;\n // Compatibility flags with three/examples LineMaterial API\n // worldUnits is effectively always true in this shader, but we accept the flag to avoid warnings\n private _worldUnits: boolean = true;\n constructor(parameters: any) {\n super({\n // @ts-ignore\n type: 'LineMaterial',\n uniforms: UniformsUtils.clone(ShaderLib['linee'].uniforms),\n\n vertexShader: ShaderLib['linee'].vertexShader,\n fragmentShader: ShaderLib['linee'].fragmentShader,\n\n clipping: true, // required for clipping support\n });\n\n this.setValues(parameters);\n }\n\n get color() {\n return this.uniforms.diffuse.value;\n }\n\n set color(value) {\n this.uniforms.diffuse.value = value;\n }\n\n // @ts-ignore\n get linewidth() {\n return this.uniforms.linewidth.value;\n }\n\n // @ts-ignore\n set linewidth(value) {\n if (!this.uniforms.linewidth) {\n return;\n }\n this.uniforms.linewidth.value = value;\n }\n\n get dashed() {\n return 'USE_DASH' in this.defines;\n }\n\n set dashed(value) {\n if ((value === true) !== this.dashed) {\n this.needsUpdate = true;\n }\n\n if (value === true) {\n this.defines.USE_DASH = '';\n } else {\n delete this.defines.USE_DASH;\n }\n }\n\n // @ts-ignore\n get opacity() {\n return this.uniforms.opacity.value;\n }\n\n set opacity(value) {\n if (!this.uniforms) {\n return;\n }\n this.uniforms.opacity.value = value;\n }\n\n // --- Compatibility API ---\n // Accept and expose `worldUnits` so Material.setValues doesn't warn.\n // Our implementation measures linewidth in world space, so this is a no-op.\n get worldUnits(): boolean {\n return this._worldUnits;\n }\n set worldUnits(v: boolean) {\n this._worldUnits = !!v;\n }\n\n // Note: `vertexColors` is a property on ShaderMaterial; we rely on three's behavior.\n}\n\nexport { LineMaterial };\n"],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAWH;AACA,WAAW,CAAC,KAAK,GAAG;AAClB,IAAA,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;IACvB,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE;AACrC,IAAA,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,EAAE;AACpC,IAAA,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,EAAE;CACnC;AAED,SAAS,CAAC,OAAO,CAAC,GAAG;AACnB,IAAA,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC;AAC5B,QAAA,WAAW,CAAC,MAAM;AAClB,QAAA,WAAW,CAAC,GAAG;;AAEf,QAAA,WAAW,CAAC,KAAK;KAClB,CAAC;IAEF,YAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2IxB,EAAA,CAAA;IAED,cAAc,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwE1B,EAAA,CAAA;C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A,IAAI,KAAK,KAAK,IAAI,EAAE;AAClB,YAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,EAAE;QAC5B;aAAO;AACL,YAAA,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ;QAC9B;IACF;;AAGA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK;IACpC;IAEA,IAAI,OAAO,CAAC,KAAK,EAAA;AACf,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB;QACF;QACA,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK;IACrC;;;;AAKA,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,WAAW;IACzB;IACA,IAAI,UAAU,CAAC,CAAU,EAAA;AACvB,QAAA,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;IACxB;AAGD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slide.js","sources":["../../src/locomotion/slide.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"slide.js","sources":["../../src/locomotion/slide.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Locomotor } from '@iwsdk/locomotor';\nimport { Types } from '../ecs/component.js';\nimport { createSystem } from '../ecs/system.js';\nimport {\n BackSide,\n Color,\n CylinderGeometry,\n MathUtils,\n Mesh,\n Quaternion,\n ShaderMaterial,\n Vector2,\n Vector3,\n} from '../runtime/index.js';\nimport {\n ActionLocomotionInputProvider,\n getRequiredInputProvider,\n} from './locomotion-input-provider.js';\n\nconst { lerp } = MathUtils;\n\nconst vertexShader = `\n\tvarying vec2 vUv;\n\n\tvoid main() {\n\t\tvUv = uv;\n\t\tvec4 modelPosition = modelMatrix * vec4(position, 1.0);\n\t\tvec4 viewPosition = viewMatrix * modelPosition;\n\t\tvec4 projectedPosition = projectionMatrix * viewPosition;\n\n\t\tgl_Position = projectedPosition;\n\t}\n`;\n\nconst fragmentShader = `\n\tuniform vec3 uColor;\n\tuniform float uAlpha;\n\tvarying vec2 vUv;\n\n\tvoid main() {\n\t\tgl_FragColor = vec4(uColor, uAlpha * vUv.y);\n\t}\n`;\n\nconst createVignette = (radius: number, colorRep: number = 0x000000) => {\n const vignette = new Mesh(\n new CylinderGeometry(radius, radius * 0.5, 0.3, 16, 1, true),\n new ShaderMaterial({\n vertexShader: vertexShader,\n fragmentShader: fragmentShader,\n uniforms: {\n uColor: { value: new Color(colorRep) },\n uAlpha: { value: 0 },\n },\n depthTest: false,\n side: BackSide,\n transparent: true,\n }),\n );\n vignette.frustumCulled = false;\n vignette.renderOrder = 999;\n vignette.rotateX(Math.PI / 2);\n vignette.position.z = -0.15;\n return vignette;\n};\n\n/**\n * Analog stick sliding locomotion with optional comfort vignette and jump.\n *\n * @remarks\n * - Reads left controller thumbstick for planar movement relative to head yaw.\n * - Applies a dynamic peripheral vignette based on input magnitude scaled by\n * `comfortAssist` to reduce motion sickness.\n * - Triggers jump when the locomotion jump action is pressed.\n *\n * @category Locomotion\n */\nexport class SlideSystem extends createSystem(\n {},\n {\n /** Locomotor engine shared across locomotion systems. */\n locomotor: { type: Types.Object, default: undefined },\n /** Action-backed input provider shared across locomotion systems. */\n inputProvider: { type: Types.Object, default: undefined },\n /** Maximum linear speed in meters/second. */\n maxSpeed: { type: Types.Float32, default: 5 },\n /** Comfort vignette strength [0..1]; 0 disables vignetting. */\n comfortAssist: { type: Types.Float32, default: 0.5 },\n /** Whether jumping is enabled. */\n enableJumping: { type: Types.Boolean, default: true },\n },\n) {\n private movementVector = new Vector3();\n private movementDirection = new Quaternion();\n private input2D = new Vector2();\n private isMoving = false;\n private vignette = createVignette(0.3);\n private vignetteAlphaTarget = 0;\n private locomotor!: Locomotor;\n private inputProvider!: ActionLocomotionInputProvider;\n\n init() {\n this.locomotor = this.config.locomotor.value as Locomotor;\n this.inputProvider = getRequiredInputProvider(\n 'SlideSystem',\n this.config.inputProvider.value,\n );\n this.camera.add(this.vignette);\n }\n\n destroy(): void {\n this.vignette.removeFromParent();\n }\n\n update(delta: number): void {\n this.vignetteAlphaTarget = 0;\n\n // Handle jump input\n if (this.config.enableJumping.value && this.inputProvider.getJumpDown()) {\n this.locomotor.jump();\n }\n\n this.inputProvider.getMoveAxis(this.input2D);\n {\n this.movementVector.set(this.input2D.x, 0, this.input2D.y);\n const inputValue = Math.min(this.input2D.length(), 1);\n if (inputValue > 0) {\n this.inputProvider.getMovementReferenceQuaternion(\n this.movementDirection,\n );\n this.movementVector.applyQuaternion(this.movementDirection);\n this.movementVector.y = 0;\n this.movementVector\n .normalize()\n .multiplyScalar(inputValue * (this.config.maxSpeed.value as number));\n this.locomotor.slide(this.movementVector);\n this.vignetteAlphaTarget =\n inputValue * (this.config.comfortAssist.value as number);\n } else {\n if (this.isMoving) {\n // Stop movement by sending zero vector\n this.movementVector.set(0, 0, 0);\n this.locomotor.slide(this.movementVector);\n }\n }\n\n this.isMoving = inputValue > 0;\n this.vignette.material.uniforms.uAlpha.value = lerp(\n this.vignette.material.uniforms.uAlpha.value,\n this.vignetteAlphaTarget,\n delta * 10,\n );\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAqBH,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS;AAE1B,MAAM,YAAY,GAAG;;;;;;;;;;;CAWpB;AAED,MAAM,cAAc,GAAG;;;;;;;;CAQtB;AAED,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,QAAA,GAAmB,QAAQ,KAAI;IACrE,MAAM,QAAQ,GAAG,IAAI,IAAI,CACvB,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAC5D,IAAI,cAAc,CAAC;AACjB,QAAA,YA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Content":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Locomotor, sampleParabolicCurve } from '@iwsdk/locomotor';\nimport { Line2 } from 'three/examples/jsm/lines/Line2.js';\nimport { LineGeometry } from 'three/examples/jsm/lines/LineGeometry.js';\nimport { Types } from '../ecs/component.js';\nimport { createSystem } from '../ecs/system.js';\nimport {\n Color,\n Mesh,\n MeshBasicMaterial,\n RingGeometry,\n Vector3,\n} from '../runtime/index.js';\nimport {\n ActionLocomotionInputProvider,\n getRequiredInputProvider,\n} from './locomotion-input-provider.js';\nimport { LineMaterial } from './materials/line.js';\n\nconst Colors = {\n valid: new Color(0xffffff),\n invalid: new Color(0xed4337),\n};\n\nconst Scales = {\n valid: new Vector3(1, 1, 1),\n invalid: new Vector3(0.5, 0.5, 0.5),\n};\n\n/**\n * Arc‑based teleportation with surface validation and hand/controller input.\n *\n * @remarks\n * - Uses locomotor ray hit tests and only allows targets with upward normals.\n * - In hand‑tracking mode, optional micro‑gestures can control activation\n * (e.g., thumb tap to confirm).\n * - Draws a curved parabolic guide and landing marker with visual feedback.\n *\n * @category Locomotion\n */\nexport class TeleportSystem extends createSystem(\n {},\n {\n /** Downward acceleration for the parabolic guide (negative). */\n rayGravity: { type: Types.Float32, default: -0.4 },\n /** Locomotor engine used for hit testing and teleport execution. */\n locomotor: { type: Types.Object, default: undefined },\n /** Action-backed input provider shared across locomotion systems. */\n inputProvider: { type: Types.Object, default: undefined },\n /** Enable hand‑tracking micro‑gesture flow for activation/confirm. */\n microGestureControlsEnabled: { type: Types.Boolean, default: false },\n },\n) {\n private rayOrigin = new Vector3();\n private rayDirection = new Vector3();\n private markers!: Vector3[];\n private targetValid = false;\n private teleportMarker!: Mesh;\n private markerMat!: MeshBasicMaterial;\n private line!: Line2;\n private teleportWasActive = false;\n private locomotor!: Locomotor;\n private inputProvider!: ActionLocomotionInputProvider;\n\n init() {\n this.locomotor = this.config.locomotor.value as Locomotor;\n this.inputProvider = getRequiredInputProvider(\n 'TeleportSystem',\n this.config.inputProvider.value,\n );\n this.markerMat = new MeshBasicMaterial();\n this.teleportMarker = new Mesh(\n new RingGeometry(0.12, 0.15).translate(0, 0, 0.02),\n this.markerMat,\n );\n this.scene.add(this.teleportMarker);\n\n this.markers = [];\n for (let i = 0; i < 20; i++) {\n this.markers.push(new Vector3(0, i, 0));\n }\n const geometry = new LineGeometry().setFromPoints(this.markers);\n const mat = new LineMaterial({\n color: 0xffffff,\n linewidth: 0.01,\n worldUnits: true,\n vertexColors: true,\n alphaToCoverage: false,\n transparent: true,\n });\n\n this.line = new Line2(geometry, mat as any);\n this.line.frustumCulled = false;\n this.scene.add(this.line);\n this.line.visible = false;\n this.teleportMarker.visible = false;\n }\n\n destroy(): void {\n this.teleportMarker.removeFromParent();\n this.line.removeFromParent();\n // Note: No need to remove raycastTarget as we use locomotor's hit test target\n }\n\n update(): void {\n // Get hit test target from locomotor\n const hitTestTarget = this.locomotor.hitTestTarget;\n const hitTestNormal = this.locomotor.hitTestNormal;\n\n // Validate target: must have hit AND normal must be mostly upward-facing (> 0.7)\n this.targetValid = hitTestTarget.visible && hitTestNormal.y > 0.7;\n\n const pointerBusy = this.input.xr.multiPointers.right.getRayBusy();\n let teleportActive = this.inputProvider.getTeleportActive(\n pointerBusy,\n this.config.microGestureControlsEnabled.value,\n );\n\n if (teleportActive) {\n if (\n !this.inputProvider.getTeleportRay(this.rayOrigin, this.rayDirection)\n ) {\n teleportActive = false;\n }\n }\n\n if (teleportActive) {\n if (!this.teleportWasActive) {\n this.line.visible = true;\n this.teleportMarker.visible = true;\n }\n\n const minY = Math.max(\n this.player.position.y,\n this.teleportMarker.position.y,\n );\n\n sampleParabolicCurve(\n this.rayOrigin,\n this.rayDirection,\n minY,\n this.config.rayGravity.value,\n this.markers,\n 1,\n );\n\n this.line.geometry.setFromPoints(this.markers);\n this.line.material.uniforms.startPoint.value.copy(this.markers[0]);\n this.line.material.uniforms.endPoint.value.copy(\n this.markers[this.markers.length - 1],\n );\n\n // Request hit test from locomotor\n this.locomotor.requestHitTest(this.rayOrigin, this.rayDirection);\n\n // Update teleport marker to follow hit test target\n this.teleportMarker.position.lerp(hitTestTarget.position, 0.2);\n this.teleportMarker.quaternion.slerp(hitTestTarget.quaternion, 0.2);\n this.markerMat.color.lerp(\n this.targetValid ? Colors.valid : Colors.invalid,\n 0.2,\n );\n this.teleportMarker.scale.lerp(\n this.targetValid ? Scales.valid : Scales.invalid,\n 0.2,\n );\n } else if (this.teleportWasActive) {\n if (\n this.targetValid &&\n this.inputProvider.getTeleportCommit(\n this.config.microGestureControlsEnabled.value,\n )\n ) {\n // Teleport to the hit test target position\n this.locomotor.teleport(this.teleportMarker.position);\n }\n this.line.visible = false;\n this.teleportMarker.visible = false;\n }\n\n this.teleportWasActive = teleportActive;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;AAKG;AAoBH,MAAM,MAAM,GAAG;AACb,IAAA,KAAK,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC;AAC1B,IAAA,OAAO,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC;CAC7B;AAED,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;CACpC;AAED;;;;;;;;;;AAUG;MACU,cAAe,SAAQ,YAAY,CAC9C,EAAE,EACF;;AAEE,IAAA,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;;IAElD,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE;;IAErD,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EA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AAS,CAAC,KAAK,CAAC,IAAI,CACvB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,EAChD,GAAG,CACJ;YACD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAC5B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,EAChD,GAAG,CACJ;QACH;AAAO,aAAA,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACjC,IACE,IAAI,CAAC,WAAW;AAChB,gBAAA,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAClC,IAAI,CAAC,MAAM,CAAC,2BAA2B,CAAC,KAAK,CAC9C,EACD;;gBAEA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;YACvD;AACA,YAAA,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK;AACzB,YAAA,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,KAAK;QACrC;AAEA,QAAA,IAAI,CAAC,iBAAiB,GAAG,cAAc;IACzC;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn.js","sources":["../../src/locomotion/turn.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"turn.js","sources":["../../src/locomotion/turn.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Types } from '../ecs/component.js';\nimport { createSystem } from '../ecs/system.js';\nimport { Group, Mesh, Vector3 } from '../runtime/index.js';\nimport { BeveledCylinderGeometry } from './geometries/beveled-cylinder.js';\nimport {\n ActionLocomotionInputProvider,\n getRequiredInputProvider,\n} from './locomotion-input-provider.js';\n\nconst unitVector = new Vector3(1, 1, 1);\n\nexport enum TurningMethod {\n SnapTurn = 1,\n SmoothTurn = 2,\n}\n\n/**\n * Player yaw rotation via snap or smooth turning.\n *\n * @remarks\n * - When snap turning is active, visual turn signals render on the right ray\n * and respond to thumbstick left/right or hand micro‑gestures (if enabled).\n * - Smooth turning applies a continuous yaw at `turningSpeed` degrees/second.\n *\n * @category Locomotion\n */\nexport class TurnSystem extends createSystem(\n {},\n {\n /** Choose snap or smooth turning. */\n turningMethod: { type: Types.Int8, default: TurningMethod.SnapTurn },\n /** Degrees to rotate per snap. */\n turningAngle: { type: Types.Float32, default: 45 },\n /** Degrees per second when smooth turning. */\n turningSpeed: { type: Types.Float32, default: 180 },\n /** Enable swipe‑gesture turning in hand‑tracking mode. */\n microGestureControlsEnabled: { type: Types.Boolean, default: false },\n /** Action-backed input provider shared across locomotion systems. */\n inputProvider: { type: Types.Object, default: undefined },\n },\n) {\n private turnSignals = new Group();\n private leftSignal = new Mesh(\n new BeveledCylinderGeometry(0.004, 0.012, 0.022, 4, 0.004).rotateZ(\n Math.PI / 2,\n ),\n );\n private rightSignal = new Mesh(\n new BeveledCylinderGeometry(0.004, 0.012, 0.022, 4, 0.004).rotateZ(\n -Math.PI / 2,\n ),\n );\n private playerHeadPosition = new Vector3();\n private inputProvider!: ActionLocomotionInputProvider;\n\n init() {\n this.inputProvider = getRequiredInputProvider(\n 'TurnSystem',\n this.config.inputProvider.value,\n );\n this.turnSignals.add(this.leftSignal, this.rightSignal);\n this.leftSignal.position.set(-0.015, 0.02, 0);\n this.rightSignal.position.set(0.055, 0.02, 0);\n this.cleanupFuncs.push(\n this.config.turningMethod.subscribe((value) => {\n if (value === TurningMethod.SmoothTurn) {\n this.turnSignals.removeFromParent();\n } else {\n this.player.raySpaces.right.add(this.turnSignals);\n }\n }),\n );\n }\n\n destroy(): void {\n super.destroy();\n this.turnSignals.removeFromParent();\n }\n\n update(delta: number): void {\n if (this.config.turningMethod.value === TurningMethod.SmoothTurn) {\n this.updateSmooth(delta);\n } else {\n this.updateSnap(delta);\n }\n }\n\n private updateSmooth(delta: number): void {\n const turnAxis = this.inputProvider.getTurnAxis();\n const turningSpeedRadian = (this.config.turningSpeed.value / 180) * Math.PI;\n if (turnAxis !== 0) {\n this.player.rotateY(-turnAxis * turningSpeedRadian * delta);\n }\n }\n\n private updateSnap(delta: number): void {\n const turningAngleRadian = (this.config.turningAngle.value / 180) * Math.PI;\n const showSignals = this.inputProvider.shouldShowTurnSignals(\n this.config.microGestureControlsEnabled.value,\n );\n this.turnSignals.visible = showSignals;\n if (showSignals) {\n this.player.head.getWorldPosition(this.playerHeadPosition);\n this.turnSignals.lookAt(this.playerHeadPosition);\n } else {\n this.turnSignals.visible = false;\n }\n\n const turningLeft = this.inputProvider.getTurnLeftDown(\n this.config.microGestureControlsEnabled.value,\n );\n const turningRight = this.inputProvider.getTurnRightDown(\n this.config.microGestureControlsEnabled.value,\n );\n\n if (turningLeft) {\n this.player.rotateY(turningAngleRadian);\n if (this.turnSignals.visible) {\n this.leftSignal.scale.setScalar(1.5);\n }\n } else if (turningRight) {\n this.player.rotateY(-turningAngleRadian);\n if (this.turnSignals.visible) {\n this.rightSignal.scale.setScalar(1.5);\n }\n }\n if (this.turnSignals.visible) {\n this.leftSignal.scale.lerp(unitVector, 5 * delta);\n this.rightSignal.scale.lerp(unitVector, 5 * delta);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;AAKG;AAWH,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAE3B;AAAZ,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,aAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAY;AACZ,IAAA,aAAA,CAAA,aAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAc;AAChB,CAAC,EAHW,aAAa,KAAb,aAAa,GAAA,EAAA,CAAA,CAAA;AAKzB;;;;;;;;;AASG;MACU,UAAW,SAAQ,YAAY,CAC1C,EAAE,EACF;;AAEE,IAAA,aAAa,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C,SAAS,CAAC,GAAG,CAAC;YACvC;QACF;AACA,QAAA,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;AAC5B,YAAA,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC;AACjD,YAAA,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC;QACpD;IACF;AACD;;;;"}
|
|
@@ -11,7 +11,7 @@ export interface EcsPauseResult {
|
|
|
11
11
|
frame: number;
|
|
12
12
|
systemCount: number;
|
|
13
13
|
}
|
|
14
|
-
export declare function ecsPause(world: World): EcsPauseResult
|
|
14
|
+
export declare function ecsPause(world: World): Promise<EcsPauseResult>;
|
|
15
15
|
export interface EcsResumeResult {
|
|
16
16
|
paused: boolean;
|
|
17
17
|
framesWhilePaused: number;
|
|
@@ -122,12 +122,15 @@ export interface EcsSnapshot {
|
|
|
122
122
|
}
|
|
123
123
|
export interface EcsSnapshotParams {
|
|
124
124
|
label?: string;
|
|
125
|
+
capacity?: number;
|
|
125
126
|
}
|
|
126
127
|
export interface EcsSnapshotResult {
|
|
127
128
|
label: string;
|
|
128
129
|
entityCount: number;
|
|
129
130
|
componentCount: number;
|
|
130
131
|
storedSnapshots: string[];
|
|
132
|
+
snapshotCapacity: number;
|
|
133
|
+
evictedSnapshots: string[];
|
|
131
134
|
}
|
|
132
135
|
export declare function ecsSnapshot(world: World, params: Record<string, unknown>): EcsSnapshotResult;
|
|
133
136
|
export interface EcsDiffParams {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecs-debug-tools.d.ts","sourceRoot":"","sources":["../../src/mcp/ecs-debug-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ecs-debug-tools.d.ts","sourceRoot":"","s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IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D;AAED,wBAAgB,OAAO,CACrB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,aAAa,CAgHf"}
|
|
@@ -12,10 +12,52 @@ import { ComponentRegistry } from 'elics';
|
|
|
12
12
|
const debugState = {
|
|
13
13
|
paused: false,
|
|
14
14
|
stepResolve: null,
|
|
15
|
+
stepReject: null,
|
|
16
|
+
stepInFlight: false,
|
|
15
17
|
stepDelta: 1 / 72,
|
|
16
18
|
frameCount: 0,
|
|
17
19
|
pausedAtFrame: 0,
|
|
18
20
|
};
|
|
21
|
+
const DEBUG_SYNC_TIMEOUT_MS = 5000;
|
|
22
|
+
function isDebugFrameSynchronizer(system) {
|
|
23
|
+
return (typeof system === 'object' &&
|
|
24
|
+
system !== null &&
|
|
25
|
+
'flushDebugFrame' in system &&
|
|
26
|
+
typeof system.flushDebugFrame === 'function');
|
|
27
|
+
}
|
|
28
|
+
async function flushDebugSystems(world) {
|
|
29
|
+
await Promise.all(world
|
|
30
|
+
.getSystems()
|
|
31
|
+
.map((system) => isDebugFrameSynchronizer(system)
|
|
32
|
+
? system.flushDebugFrame()
|
|
33
|
+
: Promise.resolve()));
|
|
34
|
+
}
|
|
35
|
+
function prepareDebugSystems(world, delta) {
|
|
36
|
+
var _a;
|
|
37
|
+
for (const system of world.getSystems()) {
|
|
38
|
+
if (isDebugFrameSynchronizer(system)) {
|
|
39
|
+
(_a = system.prepareDebugFrame) === null || _a === void 0 ? void 0 : _a.call(system, delta);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function flushDebugSystemsWithTimeout(world, operation) {
|
|
44
|
+
let timer;
|
|
45
|
+
try {
|
|
46
|
+
await Promise.race([
|
|
47
|
+
flushDebugSystems(world),
|
|
48
|
+
new Promise((_, reject) => {
|
|
49
|
+
timer = setTimeout(() => {
|
|
50
|
+
reject(new Error(`${operation} timed out after ${DEBUG_SYNC_TIMEOUT_MS}ms while waiting for asynchronous systems to settle`));
|
|
51
|
+
}, DEBUG_SYNC_TIMEOUT_MS);
|
|
52
|
+
}),
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
if (timer !== undefined) {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
19
61
|
// ---------------------------------------------------------------------------
|
|
20
62
|
// Install debug hook — monkey-patches world.update()
|
|
21
63
|
// ---------------------------------------------------------------------------
|
|
@@ -34,19 +76,40 @@ function installDebugHook(world) {
|
|
|
34
76
|
return;
|
|
35
77
|
}
|
|
36
78
|
if (debugState.paused && debugState.stepResolve) {
|
|
79
|
+
if (debugState.stepInFlight) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
37
82
|
// Stepping — use fixed timestep
|
|
38
|
-
originalUpdate(debugState.stepDelta, time);
|
|
39
83
|
const resolve = debugState.stepResolve;
|
|
84
|
+
const reject = debugState.stepReject;
|
|
40
85
|
debugState.stepResolve = null;
|
|
41
|
-
|
|
86
|
+
debugState.stepReject = null;
|
|
87
|
+
debugState.stepInFlight = true;
|
|
88
|
+
try {
|
|
89
|
+
prepareDebugSystems(world, debugState.stepDelta);
|
|
90
|
+
originalUpdate(debugState.stepDelta, time);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
debugState.stepInFlight = false;
|
|
94
|
+
reject === null || reject === void 0 ? void 0 : reject(error instanceof Error ? error : new Error(String(error)));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
void flushDebugSystems(world).then(() => {
|
|
98
|
+
debugState.stepInFlight = false;
|
|
99
|
+
resolve();
|
|
100
|
+
}, (error) => {
|
|
101
|
+
debugState.stepInFlight = false;
|
|
102
|
+
reject === null || reject === void 0 ? void 0 : reject(error instanceof Error ? error : new Error(String(error)));
|
|
103
|
+
});
|
|
42
104
|
return;
|
|
43
105
|
}
|
|
44
106
|
originalUpdate(delta, time);
|
|
45
107
|
};
|
|
46
108
|
}
|
|
47
|
-
function ecsPause(world) {
|
|
109
|
+
async function ecsPause(world) {
|
|
48
110
|
debugState.paused = true;
|
|
49
111
|
debugState.pausedAtFrame = debugState.frameCount;
|
|
112
|
+
await flushDebugSystemsWithTimeout(world, 'Pause');
|
|
50
113
|
return {
|
|
51
114
|
paused: true,
|
|
52
115
|
frame: debugState.frameCount,
|
|
@@ -58,6 +121,10 @@ function ecsResume(world) {
|
|
|
58
121
|
const framesWhilePaused = debugState.frameCount - debugState.pausedAtFrame;
|
|
59
122
|
debugState.paused = false;
|
|
60
123
|
debugState.stepResolve = null;
|
|
124
|
+
debugState.stepReject = null;
|
|
125
|
+
// Keep stepInFlight set until its asynchronous system flush actually
|
|
126
|
+
// settles. Normal updates can resume, but a later debugger step must not
|
|
127
|
+
// overlap the abandoned exchange.
|
|
61
128
|
// Cap first real delta after resume to avoid physics explosions
|
|
62
129
|
if (!resumeClampInstalled && originalUpdate) {
|
|
63
130
|
const currentUpdate = world.update;
|
|
@@ -96,18 +163,25 @@ async function ecsStep(_world, params) {
|
|
|
96
163
|
// no active XR session, page hidden), the resolve callback from
|
|
97
164
|
// world.update() never fires. A 5s timeout per step prevents the MCP
|
|
98
165
|
// call from hanging indefinitely.
|
|
99
|
-
const STEP_TIMEOUT_MS = 5000;
|
|
100
166
|
for (let i = 0; i < frameCount; i++) {
|
|
101
167
|
await new Promise((resolve, reject) => {
|
|
102
168
|
debugState.stepResolve = () => {
|
|
103
169
|
clearTimeout(timer);
|
|
104
170
|
resolve();
|
|
105
171
|
};
|
|
172
|
+
debugState.stepReject = (error) => {
|
|
173
|
+
clearTimeout(timer);
|
|
174
|
+
reject(error);
|
|
175
|
+
};
|
|
106
176
|
const timer = setTimeout(() => {
|
|
107
177
|
debugState.stepResolve = null;
|
|
108
|
-
|
|
178
|
+
debugState.stepReject = null;
|
|
179
|
+
// If world.update already started this step, its asynchronous flush is
|
|
180
|
+
// still physically in flight. Leave the guard set so a retry cannot
|
|
181
|
+
// submit another exact step until that work really settles.
|
|
182
|
+
reject(new Error(`Step timeout after ${DEBUG_SYNC_TIMEOUT_MS}ms — the render loop may not be running. ` +
|
|
109
183
|
`Ensure an XR session is active and the browser tab is visible.`));
|
|
110
|
-
},
|
|
184
|
+
}, DEBUG_SYNC_TIMEOUT_MS);
|
|
111
185
|
});
|
|
112
186
|
}
|
|
113
187
|
return {
|
|
@@ -464,9 +538,29 @@ function ecsSetComponent(world, params) {
|
|
|
464
538
|
// ---------------------------------------------------------------------------
|
|
465
539
|
// Module-scoped snapshot storage
|
|
466
540
|
const snapshots = new Map();
|
|
541
|
+
const DEFAULT_SNAPSHOT_CAPACITY = 2;
|
|
542
|
+
const MAX_SNAPSHOT_CAPACITY = 20;
|
|
543
|
+
let snapshotCapacity = DEFAULT_SNAPSHOT_CAPACITY;
|
|
544
|
+
let nextSnapshotSequence = 0;
|
|
545
|
+
function nextSnapshotLabel() {
|
|
546
|
+
let label;
|
|
547
|
+
do {
|
|
548
|
+
label = `snap-${nextSnapshotSequence++}`;
|
|
549
|
+
} while (snapshots.has(label));
|
|
550
|
+
return label;
|
|
551
|
+
}
|
|
467
552
|
function ecsSnapshot(world, params) {
|
|
468
553
|
var _a;
|
|
469
|
-
const { label
|
|
554
|
+
const { capacity, label: requestedLabel } = params;
|
|
555
|
+
const label = requestedLabel !== null && requestedLabel !== void 0 ? requestedLabel : nextSnapshotLabel();
|
|
556
|
+
if (capacity !== undefined) {
|
|
557
|
+
if (!Number.isInteger(capacity) ||
|
|
558
|
+
capacity < DEFAULT_SNAPSHOT_CAPACITY ||
|
|
559
|
+
capacity > MAX_SNAPSHOT_CAPACITY) {
|
|
560
|
+
throw new Error(`Snapshot capacity must be an integer from ${DEFAULT_SNAPSHOT_CAPACITY} to ${MAX_SNAPSHOT_CAPACITY}.`);
|
|
561
|
+
}
|
|
562
|
+
snapshotCapacity = capacity;
|
|
563
|
+
}
|
|
470
564
|
// See comment in ecsFindEntities — indexLookup is internal to ELICS.
|
|
471
565
|
const lookup = world.entityManager.indexLookup;
|
|
472
566
|
const entities = [];
|
|
@@ -498,17 +592,26 @@ function ecsSnapshot(world, params) {
|
|
|
498
592
|
frame: debugState.frameCount,
|
|
499
593
|
entities,
|
|
500
594
|
};
|
|
501
|
-
//
|
|
502
|
-
|
|
595
|
+
// Replacing a named snapshot should make the new capture the most recent
|
|
596
|
+
// entry. Map.set() preserves an existing key's insertion order, which could
|
|
597
|
+
// otherwise evict the snapshot we just wrote when capacity is reduced.
|
|
598
|
+
snapshots.delete(label);
|
|
599
|
+
snapshots.set(label, snapshot);
|
|
600
|
+
// Map insertion order makes retention deterministic: oldest labels leave
|
|
601
|
+
// first and replaced labels move to the newest position.
|
|
602
|
+
const evictedSnapshots = [];
|
|
603
|
+
while (snapshots.size > snapshotCapacity) {
|
|
503
604
|
const oldest = snapshots.keys().next().value;
|
|
504
605
|
snapshots.delete(oldest);
|
|
606
|
+
evictedSnapshots.push(oldest);
|
|
505
607
|
}
|
|
506
|
-
snapshots.set(label, snapshot);
|
|
507
608
|
return {
|
|
508
609
|
label,
|
|
509
610
|
entityCount: entities.length,
|
|
510
611
|
componentCount,
|
|
511
612
|
storedSnapshots: Array.from(snapshots.keys()),
|
|
613
|
+
snapshotCapacity,
|
|
614
|
+
evictedSnapshots,
|
|
512
615
|
};
|
|
513
616
|
}
|
|
514
617
|
function ecsDiff(_world, params) {
|