@hology/core 0.0.90 → 0.0.92
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/LICENSE.md +14 -14
- package/README.md +2 -2
- package/dist/config/project-config.d.ts +1 -0
- package/dist/config/project-config.d.ts.map +1 -0
- package/dist/config/project-config.js +1 -2
- package/dist/controllers/base-game-controller.d.ts +1 -0
- package/dist/controllers/base-game-controller.d.ts.map +1 -0
- package/dist/controllers/base-game-controller.js +1 -2
- package/dist/csm.d.ts +1 -0
- package/dist/csm.d.ts.map +1 -0
- package/dist/csm.js +1 -2
- package/dist/effects/particles/examples.d.ts +1 -0
- package/dist/effects/particles/examples.d.ts.map +1 -0
- package/dist/effects/particles/examples.js +1 -2
- package/dist/effects/particles/particle-system-config.d.ts +1 -0
- package/dist/effects/particles/particle-system-config.d.ts.map +1 -0
- package/dist/effects/particles/particle-system-config.js +1 -2
- package/dist/effects/vfx/behaviours.d.ts +3 -1
- package/dist/effects/vfx/behaviours.d.ts.map +1 -0
- package/dist/effects/vfx/behaviours.js +1 -2
- package/dist/effects/vfx/index.d.ts +1 -0
- package/dist/effects/vfx/index.d.ts.map +1 -0
- package/dist/effects/vfx/index.js +1 -2
- package/dist/effects/vfx/initializsers.d.ts +20 -39
- package/dist/effects/vfx/initializsers.d.ts.map +1 -0
- package/dist/effects/vfx/initializsers.js +1 -2
- package/dist/effects/vfx/rates.d.ts +5 -4
- package/dist/effects/vfx/rates.d.ts.map +1 -0
- package/dist/effects/vfx/rates.js +1 -2
- package/dist/effects/vfx/stretched-sprite.d.ts +1 -0
- package/dist/effects/vfx/stretched-sprite.d.ts.map +1 -0
- package/dist/effects/vfx/stretched-sprite.js +1 -2
- package/dist/effects/vfx/trail-renderer.d.ts +1 -0
- package/dist/effects/vfx/trail-renderer.d.ts.map +1 -0
- package/dist/effects/vfx/trail-renderer.js +1 -2
- package/dist/effects/vfx/vfx-actor.d.ts +2 -1
- package/dist/effects/vfx/vfx-actor.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-actor.js +1 -2
- package/dist/effects/vfx/vfx-asset.d.ts +11 -0
- package/dist/effects/vfx/vfx-asset.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-asset.js +1 -2
- package/dist/effects/vfx/vfx-defs.d.ts +11 -7
- package/dist/effects/vfx/vfx-defs.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-defs.js +1 -2
- package/dist/effects/vfx/vfx-materializer.d.ts +9 -1
- package/dist/effects/vfx/vfx-materializer.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-materializer.js +1 -2
- package/dist/effects/vfx/vfx-old-materializer.d.ts +2 -11
- package/dist/effects/vfx/vfx-old-materializer.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-old-materializer.js +1 -2
- package/dist/effects/vfx/vfx-param.d.ts +1 -0
- package/dist/effects/vfx/vfx-param.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-param.js +1 -2
- package/dist/effects/vfx/vfx-renderers.d.ts +2 -1
- package/dist/effects/vfx/vfx-renderers.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-renderers.js +1 -2
- package/dist/effects/vfx/vfx-service.d.ts +1 -0
- package/dist/effects/vfx/vfx-service.d.ts.map +1 -0
- package/dist/effects/vfx/vfx-service.js +1 -2
- package/dist/effects/vfx/zones.d.ts +2 -1
- package/dist/effects/vfx/zones.d.ts.map +1 -0
- package/dist/effects/vfx/zones.js +1 -2
- package/dist/game-component/component-decorators.d.ts +1 -0
- package/dist/game-component/component-decorators.d.ts.map +1 -0
- package/dist/game-component/component-decorators.js +1 -2
- package/dist/game-component/game-component.d.ts +1 -0
- package/dist/game-component/game-component.d.ts.map +1 -0
- package/dist/game-component/game-component.js +1 -2
- package/dist/gameplay/actors/actor.d.ts +1 -0
- package/dist/gameplay/actors/actor.d.ts.map +1 -0
- package/dist/gameplay/actors/actor.js +1 -2
- package/dist/gameplay/actors/builtin/camera-actor.d.ts +1 -0
- package/dist/gameplay/actors/builtin/camera-actor.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/camera-actor.js +1 -2
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -2
- package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement copy.js +1 -2
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -2
- package/dist/gameplay/actors/builtin/components/character/modes.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/character/modes.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/components/character/modes.js +1 -2
- package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/mesh-component.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -2
- package/dist/gameplay/actors/builtin/components/scene-component.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/scene-component.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/components/scene-component.js +1 -2
- package/dist/gameplay/actors/builtin/index.d.ts +1 -0
- package/dist/gameplay/actors/builtin/index.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/index.js +1 -2
- package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +1 -0
- package/dist/gameplay/actors/builtin/navmesh-actor.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -2
- package/dist/gameplay/actors/builtin/positional-audio-actor.d.ts +1 -0
- package/dist/gameplay/actors/builtin/positional-audio-actor.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/positional-audio-actor.js +1 -2
- package/dist/gameplay/actors/builtin/spawn-point.d.ts +1 -0
- package/dist/gameplay/actors/builtin/spawn-point.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/spawn-point.js +1 -2
- package/dist/gameplay/actors/builtin/trigger-volume.d.ts +1 -0
- package/dist/gameplay/actors/builtin/trigger-volume.d.ts.map +1 -0
- package/dist/gameplay/actors/builtin/trigger-volume.js +1 -2
- package/dist/gameplay/actors/camera/camera-component.d.ts +1 -0
- package/dist/gameplay/actors/camera/camera-component.d.ts.map +1 -0
- package/dist/gameplay/actors/camera/camera-component.js +1 -2
- package/dist/gameplay/actors/camera/third-person-camera-component.d.ts +1 -0
- package/dist/gameplay/actors/camera/third-person-camera-component.d.ts.map +1 -0
- package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -2
- package/dist/gameplay/actors/component.d.ts +1 -0
- package/dist/gameplay/actors/component.d.ts.map +1 -0
- package/dist/gameplay/actors/component.js +1 -2
- package/dist/gameplay/actors/factory.d.ts +1 -0
- package/dist/gameplay/actors/factory.d.ts.map +1 -0
- package/dist/gameplay/actors/factory.js +1 -2
- package/dist/gameplay/actors/index.d.ts +1 -0
- package/dist/gameplay/actors/index.d.ts.map +1 -0
- package/dist/gameplay/actors/index.js +1 -2
- package/dist/gameplay/actors/internal/component-init.d.ts +1 -0
- package/dist/gameplay/actors/internal/component-init.d.ts.map +1 -0
- package/dist/gameplay/actors/internal/component-init.js +1 -2
- package/dist/gameplay/actors/internal/container-map.d.ts +1 -0
- package/dist/gameplay/actors/internal/container-map.d.ts.map +1 -0
- package/dist/gameplay/actors/internal/container-map.js +1 -2
- package/dist/gameplay/ai/behavior-tree/bt.d.ts +1 -0
- package/dist/gameplay/ai/behavior-tree/bt.d.ts.map +1 -0
- package/dist/gameplay/ai/behavior-tree/bt.js +1 -2
- package/dist/gameplay/ai/behavior-tree/move.d.ts +1 -0
- package/dist/gameplay/ai/behavior-tree/move.d.ts.map +1 -0
- package/dist/gameplay/ai/behavior-tree/move.js +1 -2
- package/dist/gameplay/ai/build-tile.d.ts +1 -0
- package/dist/gameplay/ai/build-tile.d.ts.map +1 -0
- package/dist/gameplay/ai/build-tile.js +1 -2
- package/dist/gameplay/ai/dynamic-tiled-navmesh.d.ts +1 -0
- package/dist/gameplay/ai/dynamic-tiled-navmesh.d.ts.map +1 -0
- package/dist/gameplay/ai/dynamic-tiled-navmesh.js +1 -2
- package/dist/gameplay/ai/dynamic-tiled-navmesh.worker.d.ts +1 -0
- package/dist/gameplay/ai/dynamic-tiled-navmesh.worker.d.ts.map +1 -0
- package/dist/gameplay/ai/dynamic-tiled-navmesh.worker.js +1 -2
- package/dist/gameplay/ai/index.d.ts +1 -0
- package/dist/gameplay/ai/index.d.ts.map +1 -0
- package/dist/gameplay/ai/index.js +1 -2
- package/dist/gameplay/ai/navigation.d.ts +1 -0
- package/dist/gameplay/ai/navigation.d.ts.map +1 -0
- package/dist/gameplay/ai/navigation.js +1 -2
- package/dist/gameplay/animation/anim-sm.d.ts +1 -0
- package/dist/gameplay/animation/anim-sm.d.ts.map +1 -0
- package/dist/gameplay/animation/anim-sm.js +1 -2
- package/dist/gameplay/animation/root-motion.d.ts +1 -0
- package/dist/gameplay/animation/root-motion.d.ts.map +1 -0
- package/dist/gameplay/animation/root-motion.js +1 -2
- package/dist/gameplay/env.d.ts +1 -0
- package/dist/gameplay/env.d.ts.map +1 -0
- package/dist/gameplay/env.js +1 -2
- package/dist/gameplay/index.d.ts +1 -0
- package/dist/gameplay/index.d.ts.map +1 -0
- package/dist/gameplay/index.js +1 -2
- package/dist/gameplay/initiate.d.ts +1 -0
- package/dist/gameplay/initiate.d.ts.map +1 -0
- package/dist/gameplay/initiate.js +1 -2
- package/dist/gameplay/inject.d.ts +1 -0
- package/dist/gameplay/inject.d.ts.map +1 -0
- package/dist/gameplay/inject.js +1 -2
- package/dist/gameplay/input/index.d.ts +1 -0
- package/dist/gameplay/input/index.d.ts.map +1 -0
- package/dist/gameplay/input/index.js +1 -2
- package/dist/gameplay/input/input-service.d.ts +1 -0
- package/dist/gameplay/input/input-service.d.ts.map +1 -0
- package/dist/gameplay/input/input-service.js +1 -2
- package/dist/gameplay/input/input.d.ts +1 -0
- package/dist/gameplay/input/input.d.ts.map +1 -0
- package/dist/gameplay/input/input.js +1 -2
- package/dist/gameplay/input/keybind.d.ts +1 -0
- package/dist/gameplay/input/keybind.d.ts.map +1 -0
- package/dist/gameplay/input/keybind.js +1 -2
- package/dist/gameplay/polyfill.d.ts +1 -0
- package/dist/gameplay/polyfill.d.ts.map +1 -0
- package/dist/gameplay/polyfill.js +1 -2
- package/dist/gameplay/services/asset-loader.d.ts +1 -0
- package/dist/gameplay/services/asset-loader.d.ts.map +1 -0
- package/dist/gameplay/services/asset-loader.js +1 -2
- package/dist/gameplay/services/physics/abstract-physics-system.d.ts +202 -0
- package/dist/gameplay/services/physics/abstract-physics-system.d.ts.map +1 -0
- package/dist/gameplay/services/physics/abstract-physics-system.js +4 -0
- package/dist/gameplay/services/physics/collision-contact.d.ts +1 -0
- package/dist/gameplay/services/physics/collision-contact.d.ts.map +1 -0
- package/dist/gameplay/services/physics/collision-contact.js +1 -2
- package/dist/gameplay/services/physics/physics-system.d.ts +283 -24
- package/dist/gameplay/services/physics/physics-system.d.ts.map +1 -0
- package/dist/gameplay/services/physics/physics-system.js +1 -2
- package/dist/gameplay/services/pointer-events.d.ts +1 -0
- package/dist/gameplay/services/pointer-events.d.ts.map +1 -0
- package/dist/gameplay/services/pointer-events.js +1 -2
- package/dist/gameplay/services/render.d.ts +1 -0
- package/dist/gameplay/services/render.d.ts.map +1 -0
- package/dist/gameplay/services/render.js +1 -2
- package/dist/gameplay/services/world.d.ts +1 -0
- package/dist/gameplay/services/world.d.ts.map +1 -0
- package/dist/gameplay/services/world.js +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -2
- package/dist/rendering/shader-override.d.ts +1 -0
- package/dist/rendering/shader-override.d.ts.map +1 -0
- package/dist/rendering/shader-override.js +1 -2
- package/dist/rendering.d.ts +1 -0
- package/dist/rendering.d.ts.map +1 -0
- package/dist/rendering.js +1 -2
- package/dist/scene/asset-resource-loader.d.ts +1 -0
- package/dist/scene/asset-resource-loader.d.ts.map +1 -0
- package/dist/scene/asset-resource-loader.js +1 -2
- package/dist/scene/assets-provider.d.ts +1 -0
- package/dist/scene/assets-provider.d.ts.map +1 -0
- package/dist/scene/assets-provider.js +1 -2
- package/dist/scene/bootstrap.d.ts +1 -0
- package/dist/scene/bootstrap.d.ts.map +1 -0
- package/dist/scene/bootstrap.js +1 -2
- package/dist/scene/collision/collision-shape-import.d.ts +1 -0
- package/dist/scene/collision/collision-shape-import.d.ts.map +1 -0
- package/dist/scene/collision/collision-shape-import.js +1 -2
- package/dist/scene/collision/collision-shape.d.ts +1 -0
- package/dist/scene/collision/collision-shape.d.ts.map +1 -0
- package/dist/scene/collision/collision-shape.js +1 -2
- package/dist/scene/landscape/landscape-manager.d.ts +1 -0
- package/dist/scene/landscape/landscape-manager.d.ts.map +1 -0
- package/dist/scene/landscape/landscape-manager.js +1 -2
- package/dist/scene/landscape/landscape.d.ts +1 -0
- package/dist/scene/landscape/landscape.d.ts.map +1 -0
- package/dist/scene/landscape/landscape.js +1 -2
- package/dist/scene/landscape/utils.d.ts +1 -0
- package/dist/scene/landscape/utils.d.ts.map +1 -0
- package/dist/scene/landscape/utils.js +1 -2
- package/dist/scene/materializer.d.ts +1 -0
- package/dist/scene/materializer.d.ts.map +1 -0
- package/dist/scene/materializer.js +1 -2
- package/dist/scene/materials/grass-foliage.d.ts +1 -0
- package/dist/scene/materials/grass-foliage.d.ts.map +1 -0
- package/dist/scene/materials/grass-foliage.js +1 -2
- package/dist/scene/materials/grass.d.ts +1 -0
- package/dist/scene/materials/grass.d.ts.map +1 -0
- package/dist/scene/materials/grass.js +1 -2
- package/dist/scene/materials/utils/material-painting.d.ts +1 -0
- package/dist/scene/materials/utils/material-painting.d.ts.map +1 -0
- package/dist/scene/materials/utils/material-painting.js +1 -2
- package/dist/scene/materials/utils/noise.glsl.d.ts +1 -0
- package/dist/scene/materials/utils/noise.glsl.d.ts.map +1 -0
- package/dist/scene/materials/utils/noise.glsl.js +1 -2
- package/dist/scene/materials/water.d.ts +1 -0
- package/dist/scene/materials/water.d.ts.map +1 -0
- package/dist/scene/materials/water.js +1 -2
- package/dist/scene/model.d.ts +1 -0
- package/dist/scene/model.d.ts.map +1 -0
- package/dist/scene/model.js +1 -2
- package/dist/scene/objects/ramp-geometry.d.ts +1 -0
- package/dist/scene/objects/ramp-geometry.d.ts.map +1 -0
- package/dist/scene/objects/ramp-geometry.js +1 -2
- package/dist/scene/objects/shapes.d.ts +2 -2
- package/dist/scene/objects/shapes.d.ts.map +1 -0
- package/dist/scene/objects/shapes.js +1 -2
- package/dist/scene/objects/stairs-geometry.d.ts +1 -0
- package/dist/scene/objects/stairs-geometry.d.ts.map +1 -0
- package/dist/scene/objects/stairs-geometry.js +1 -2
- package/dist/scene/runtime-asset-service.d.ts +1 -0
- package/dist/scene/runtime-asset-service.d.ts.map +1 -0
- package/dist/scene/runtime-asset-service.js +1 -2
- package/dist/scene/runtime-backend-service.d.ts +1 -0
- package/dist/scene/runtime-backend-service.d.ts.map +1 -0
- package/dist/scene/runtime-backend-service.js +1 -2
- package/dist/scene/runtime-bundled-backend-service.d.ts +1 -0
- package/dist/scene/runtime-bundled-backend-service.d.ts.map +1 -0
- package/dist/scene/runtime-bundled-backend-service.js +1 -2
- package/dist/scene/scene-data-service.d.ts +1 -0
- package/dist/scene/scene-data-service.d.ts.map +1 -0
- package/dist/scene/scene-data-service.js +1 -2
- package/dist/scene/sky.d.ts +1 -0
- package/dist/scene/sky.d.ts.map +1 -0
- package/dist/scene/sky.js +1 -2
- package/dist/scene/storage/storage.d.ts +1 -0
- package/dist/scene/storage/storage.d.ts.map +1 -0
- package/dist/scene/storage/storage.js +1 -2
- package/dist/shader/builtin/index.d.ts +1 -0
- package/dist/shader/builtin/index.d.ts.map +1 -0
- package/dist/shader/builtin/index.js +1 -2
- package/dist/shader/builtin/lambert-shader.d.ts +1 -0
- package/dist/shader/builtin/lambert-shader.d.ts.map +1 -0
- package/dist/shader/builtin/lambert-shader.js +1 -2
- package/dist/shader/builtin/landscape-composite-shader.d.ts +1 -0
- package/dist/shader/builtin/landscape-composite-shader.d.ts.map +1 -0
- package/dist/shader/builtin/landscape-composite-shader.js +1 -2
- package/dist/shader/builtin/landscape-shader.d.ts +1 -0
- package/dist/shader/builtin/landscape-shader.d.ts.map +1 -0
- package/dist/shader/builtin/landscape-shader.js +1 -2
- package/dist/shader/builtin/standard-shader.d.ts +1 -0
- package/dist/shader/builtin/standard-shader.d.ts.map +1 -0
- package/dist/shader/builtin/standard-shader.js +1 -2
- package/dist/shader/builtin/unlit-shader.d.ts +1 -0
- package/dist/shader/builtin/unlit-shader.d.ts.map +1 -0
- package/dist/shader/builtin/unlit-shader.js +1 -2
- package/dist/shader/index.d.ts +1 -0
- package/dist/shader/index.d.ts.map +1 -0
- package/dist/shader/index.js +1 -2
- package/dist/shader/parameter.d.ts +1 -0
- package/dist/shader/parameter.d.ts.map +1 -0
- package/dist/shader/parameter.js +1 -2
- package/dist/shader/shader.d.ts +1 -0
- package/dist/shader/shader.d.ts.map +1 -0
- package/dist/shader/shader.js +1 -2
- package/dist/shader-nodes/bulge.d.ts +1 -0
- package/dist/shader-nodes/bulge.d.ts.map +1 -0
- package/dist/shader-nodes/bulge.js +1 -2
- package/dist/shader-nodes/depth.d.ts +1 -0
- package/dist/shader-nodes/depth.d.ts.map +1 -0
- package/dist/shader-nodes/depth.js +1 -2
- package/dist/shader-nodes/effects.d.ts +1 -0
- package/dist/shader-nodes/effects.d.ts.map +1 -0
- package/dist/shader-nodes/effects.js +1 -2
- package/dist/shader-nodes/glsl-node.d.ts +2 -1
- package/dist/shader-nodes/glsl-node.d.ts.map +1 -0
- package/dist/shader-nodes/glsl-node.js +1 -2
- package/dist/shader-nodes/index.d.ts +2 -0
- package/dist/shader-nodes/index.d.ts.map +1 -0
- package/dist/shader-nodes/index.js +1 -2
- package/dist/shader-nodes/landscape.d.ts +1 -0
- package/dist/shader-nodes/landscape.d.ts.map +1 -0
- package/dist/shader-nodes/landscape.js +1 -2
- package/dist/shader-nodes/layers.d.ts +1 -0
- package/dist/shader-nodes/layers.d.ts.map +1 -0
- package/dist/shader-nodes/layers.js +1 -2
- package/dist/shader-nodes/math.d.ts +1 -0
- package/dist/shader-nodes/math.d.ts.map +1 -0
- package/dist/shader-nodes/math.js +1 -2
- package/dist/shader-nodes/particle.d.ts +3 -0
- package/dist/shader-nodes/particle.d.ts.map +1 -0
- package/dist/shader-nodes/particle.js +1 -2
- package/dist/shader-nodes/shapes.d.ts +1 -0
- package/dist/shader-nodes/shapes.d.ts.map +1 -0
- package/dist/shader-nodes/shapes.js +1 -2
- package/dist/shader-nodes/texture-sequence.d.ts +2 -1
- package/dist/shader-nodes/texture-sequence.d.ts.map +1 -0
- package/dist/shader-nodes/texture-sequence.js +1 -2
- package/dist/shader-nodes/time.d.ts +1 -0
- package/dist/shader-nodes/time.d.ts.map +1 -0
- package/dist/shader-nodes/time.js +1 -2
- package/dist/shader-nodes/voronoi.d.ts +1 -0
- package/dist/shader-nodes/voronoi.d.ts.map +1 -0
- package/dist/shader-nodes/voronoi.js +1 -2
- package/dist/test/injection.test.d.ts +1 -0
- package/dist/test/injection.test.d.ts.map +1 -0
- package/dist/test/injection.test.js +1 -2
- package/dist/utils/async.d.ts +1 -0
- package/dist/utils/async.d.ts.map +1 -0
- package/dist/utils/async.js +1 -2
- package/dist/utils/buffer.d.ts +1 -0
- package/dist/utils/buffer.d.ts.map +1 -0
- package/dist/utils/buffer.js +1 -2
- package/dist/utils/collections.d.ts +1 -0
- package/dist/utils/collections.d.ts.map +1 -0
- package/dist/utils/collections.js +1 -2
- package/dist/utils/files.d.ts +1 -0
- package/dist/utils/files.d.ts.map +1 -0
- package/dist/utils/files.js +1 -2
- package/dist/utils/materials.d.ts +1 -0
- package/dist/utils/materials.d.ts.map +1 -0
- package/dist/utils/materials.js +1 -2
- package/dist/utils/math.d.ts +1 -0
- package/dist/utils/math.d.ts.map +1 -0
- package/dist/utils/math.js +1 -2
- package/dist/utils/mesh.d.ts +1 -0
- package/dist/utils/mesh.d.ts.map +1 -0
- package/dist/utils/mesh.js +1 -2
- package/dist/utils/polyfill.d.ts +1 -0
- package/dist/utils/polyfill.d.ts.map +1 -0
- package/dist/utils/polyfill.js +1 -2
- package/dist/utils/three/depth-pass.d.ts +1 -0
- package/dist/utils/three/depth-pass.d.ts.map +1 -0
- package/dist/utils/three/depth-pass.js +1 -2
- package/dist/utils/three/gpu-stats-panel.d.ts +1 -0
- package/dist/utils/three/gpu-stats-panel.d.ts.map +1 -0
- package/dist/utils/three/gpu-stats-panel.js +1 -2
- package/dist/utils/three/line-sphere.d.ts +1 -0
- package/dist/utils/three/line-sphere.d.ts.map +1 -0
- package/dist/utils/three/line-sphere.js +1 -2
- package/dist/utils/three/outline-pass.d.ts +1 -0
- package/dist/utils/three/outline-pass.d.ts.map +1 -0
- package/dist/utils/three/outline-pass.js +1 -2
- package/dist/utils/three/positional-audio-helper.d.ts +1 -0
- package/dist/utils/three/positional-audio-helper.d.ts.map +1 -0
- package/dist/utils/three/positional-audio-helper.js +1 -2
- package/dist/utils/three/stats.d.ts +1 -0
- package/dist/utils/three/stats.d.ts.map +1 -0
- package/dist/utils/three/stats.js +1 -2
- package/dist/utils/three/transform-controls.d.ts +1 -0
- package/dist/utils/three/transform-controls.d.ts.map +1 -0
- package/dist/utils/three/transform-controls.js +1 -2
- package/dist/utils/three/traverse.d.ts +1 -0
- package/dist/utils/three/traverse.d.ts.map +1 -0
- package/dist/utils/three/traverse.js +1 -2
- package/dist/utils/type.d.ts +1 -0
- package/dist/utils/type.d.ts.map +1 -0
- package/dist/utils/type.js +1 -2
- package/dist/utils/uuid.d.ts +1 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +1 -2
- package/dist/worker/index.d.ts +1 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +1 -2
- package/package.json +122 -122
- package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"collision-contact.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/services/physics/collision-contact.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,gBAAgB;CAEhC"}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import * as RAPIER from "@dimforge/rapier3d-compat";
|
2
2
|
import { Observable, Subject } from "rxjs";
|
3
|
-
import * as THREE from "three";
|
4
3
|
import { ColorRepresentation, Object3D, Vector3 } from "three";
|
5
4
|
import { CollisionShape } from '../../../index.js';
|
6
5
|
import { AbstractType } from '../../../utils/type.js';
|
7
6
|
import { BaseActor } from '../../actors/actor.js';
|
8
7
|
import { ViewController } from '../render.js';
|
9
8
|
import { World } from '../world.js';
|
9
|
+
import { AbstractPhysicsSystem, ActorPhysicsOptions } from './abstract-physics-system.js';
|
10
10
|
export declare class RayTestResult {
|
11
11
|
actor?: BaseActor;
|
12
12
|
hasHit: boolean;
|
@@ -27,17 +27,11 @@ export declare enum PhysicsBodyType {
|
|
27
27
|
kinematic = 4,
|
28
28
|
kinematicVelocityBased = 8
|
29
29
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
density: number;
|
36
|
-
restitution: number;
|
37
|
-
type: PhysicsBodyType;
|
38
|
-
ignoreForNavMesh: boolean;
|
39
|
-
};
|
40
|
-
export declare class PhysicsSystem {
|
30
|
+
/**
|
31
|
+
* A physics system implementation using the Rapier physics engine.
|
32
|
+
* Handles rigid body physics, collisions, and physics-based character movement.
|
33
|
+
*/
|
34
|
+
export declare class PhysicsSystem extends AbstractPhysicsSystem {
|
41
35
|
viewController: ViewController;
|
42
36
|
private gameWorld;
|
43
37
|
readonly ready: Promise<void>;
|
@@ -58,51 +52,209 @@ export declare class PhysicsSystem {
|
|
58
52
|
constructor(viewController: ViewController, gameWorld: World);
|
59
53
|
private debugMesh;
|
60
54
|
private createDebugMesh;
|
55
|
+
/**
|
56
|
+
* Initializes and starts the physics system.
|
57
|
+
* @returns A promise that resolves when the physics system is ready
|
58
|
+
*/
|
61
59
|
start(): Promise<void>;
|
60
|
+
/**
|
61
|
+
* Renders debug visualization of physics bodies and colliders.
|
62
|
+
* Only active when showDebug is true.
|
63
|
+
*/
|
62
64
|
renderDebug(): void;
|
65
|
+
/**
|
66
|
+
* Sets up the physics world and initializes Rapier.
|
67
|
+
* @private
|
68
|
+
*/
|
63
69
|
private setup;
|
70
|
+
/**
|
71
|
+
* Handles the physics update tick, synchronizing physics bodies with their visual representations.
|
72
|
+
* @private
|
73
|
+
*/
|
64
74
|
private handleTick;
|
65
75
|
/**
|
66
|
-
*
|
67
|
-
*
|
68
|
-
*
|
76
|
+
* Updates the physics world state without advancing time.
|
77
|
+
* Used when physics simulation is paused but physics state needs updating.
|
78
|
+
* @private
|
69
79
|
*/
|
70
80
|
private _updateWorld;
|
81
|
+
/**
|
82
|
+
* Updates the physics simulation for the current frame.
|
83
|
+
* @param deltaTime - Time elapsed since last update in seconds
|
84
|
+
* @private
|
85
|
+
*/
|
71
86
|
private updatePhysics;
|
87
|
+
/**
|
88
|
+
* Performs a raycast test from the camera's perspective.
|
89
|
+
* @param distance - Maximum distance of the raycast
|
90
|
+
* @param result - Optional RayTestResult to store the result
|
91
|
+
* @param options - Optional configuration for the raycast
|
92
|
+
* @returns The result of the raycast test
|
93
|
+
*/
|
72
94
|
private _raycaster;
|
73
95
|
rayTestFromCamera(distance: number, result?: RayTestResult, options?: RayTestOptions): RayTestResult;
|
74
96
|
private _reusableResult;
|
75
97
|
private _raytestDiff;
|
76
98
|
private _raytestDirection;
|
99
|
+
/**
|
100
|
+
* Performs a raycast test between two points in world space.
|
101
|
+
* @param from - Starting point of the ray
|
102
|
+
* @param to - End point of the ray
|
103
|
+
* @param result - Optional RayTestResult to store the result
|
104
|
+
* @param options - Optional configuration for the raycast
|
105
|
+
* @returns The result of the raycast test
|
106
|
+
*/
|
77
107
|
rayTest(from: Vector3, to: Vector3, result?: RayTestResult, options?: RayTestOptions): RayTestResult;
|
108
|
+
/**
|
109
|
+
* Sets the gravity vector for the physics world.
|
110
|
+
* @param x - Gravity force along X axis
|
111
|
+
* @param y - Gravity force along Y axis
|
112
|
+
* @param z - Gravity force along Z axis
|
113
|
+
*/
|
78
114
|
setGravity(x: number, y: number, z: number): void;
|
115
|
+
/**
|
116
|
+
* Gets the current gravity vector of the physics world.
|
117
|
+
* @returns The gravity vector
|
118
|
+
*/
|
79
119
|
getGravity(): Vector3;
|
80
120
|
/**
|
81
|
-
*
|
121
|
+
* Adds static collision bodies to the physics world based on an existing scene hierarchy.
|
122
|
+
* @param object - The root object of the scene to add physics bodies for
|
82
123
|
*/
|
83
124
|
addFromScene(object: Object3D): void;
|
125
|
+
/**
|
126
|
+
* Recursively processes scene objects to add physics bodies.
|
127
|
+
* @param object - The object to process
|
128
|
+
* @private
|
129
|
+
*/
|
84
130
|
private addRecursively;
|
131
|
+
/**
|
132
|
+
* Creates physics bodies for each instance in an instanced mesh.
|
133
|
+
* @param instancedMesh - The instanced mesh to create bodies for
|
134
|
+
* @param collisionShapes - The collision shapes to use for each instance
|
135
|
+
* @private
|
136
|
+
*/
|
85
137
|
private createForInstancedMesh;
|
86
138
|
private readonly controlledActors;
|
139
|
+
/**
|
140
|
+
* Creates a character controller for physics-based character movement.
|
141
|
+
* @param offset - The skin offset for the character controller
|
142
|
+
* @returns A new kinematic character controller
|
143
|
+
*/
|
87
144
|
getCharacterController(offset?: number): RAPIER.KinematicCharacterController;
|
145
|
+
/**
|
146
|
+
* Computes the corrected movement vector for an actor using a character controller.
|
147
|
+
* @param actor - The actor to compute movement for
|
148
|
+
* @param cc - The character controller to use
|
149
|
+
* @param desiredTranslation - The desired movement vector
|
150
|
+
* @param collisionGroup - Optional collision group filter
|
151
|
+
* @returns The corrected movement vector accounting for collisions
|
152
|
+
*/
|
88
153
|
getActorComputedMovement(actor: BaseActor, cc: RAPIER.KinematicCharacterController, desiredTranslation: Vector3, collisionGroup?: number): Vector3;
|
154
|
+
/**
|
155
|
+
* Sets the next kinematic translation for an actor.
|
156
|
+
* @param actor - The actor to update
|
157
|
+
* @param vel - The velocity vector to apply
|
158
|
+
*/
|
89
159
|
setNextKinematicTranslation(actor: BaseActor, vel: Vector3): void;
|
160
|
+
/**
|
161
|
+
* Sets the angular velocity of an actor's physics body.
|
162
|
+
* @param actor - The actor to update
|
163
|
+
* @param velocity - The angular velocity vector to apply
|
164
|
+
*/
|
90
165
|
setAngularVelocity(actor: BaseActor, velocity: Vector3): void;
|
166
|
+
/**
|
167
|
+
* Sets the linear velocity of an actor's physics body.
|
168
|
+
* @param actor - The actor to update
|
169
|
+
* @param velocity - The linear velocity vector to apply
|
170
|
+
*/
|
91
171
|
setLinearVelocity(actor: BaseActor, velocity: Vector3): void;
|
92
|
-
|
93
|
-
|
172
|
+
/**
|
173
|
+
* Gets the current linear velocity of an actor's physics body.
|
174
|
+
* @param actor - The actor to query
|
175
|
+
* @param target - Optional vector to store the result in
|
176
|
+
* @returns The linear velocity vector
|
177
|
+
*/
|
178
|
+
getLinearVelocity(actor: BaseActor, target?: Vector3): Vector3;
|
179
|
+
/**
|
180
|
+
* Gets the current angular velocity of an actor's physics body.
|
181
|
+
* @param actor - The actor to query
|
182
|
+
* @param target - Optional vector to store the result in
|
183
|
+
* @returns The angular velocity vector
|
184
|
+
*/
|
185
|
+
getAngularVelocity(actor: BaseActor, target?: Vector3): Vector3;
|
186
|
+
/**
|
187
|
+
* Sets the linear damping factor for an actor's physics body.
|
188
|
+
* @param actor - The actor to update
|
189
|
+
* @param factor - The damping factor to apply
|
190
|
+
*/
|
94
191
|
setLinearDamping(actor: BaseActor, factor: number): void;
|
192
|
+
/**
|
193
|
+
* Sets the angular damping factor for an actor's physics body.
|
194
|
+
* @param actor - The actor to update
|
195
|
+
* @param factor - The damping factor to apply
|
196
|
+
*/
|
95
197
|
setAngularDamping(actor: BaseActor, factor: number): void;
|
96
|
-
|
198
|
+
/**
|
199
|
+
* Adds physics bodies for a landscape group.
|
200
|
+
* @param object - The landscape group to add physics for
|
201
|
+
* @private
|
202
|
+
*/
|
97
203
|
private addLandscapeGroup;
|
204
|
+
/**
|
205
|
+
* Adds an actor to the physics world with the specified collision shapes and options.
|
206
|
+
* @param actor - The actor to add
|
207
|
+
* @param collisionShapes - Array of collision shapes for the actor
|
208
|
+
* @param options - Physics options for the actor
|
209
|
+
*/
|
98
210
|
addActor<A extends BaseActor>(actor: A, collisionShapes: CollisionShape[], options?: Partial<ActorPhysicsOptions>): void;
|
211
|
+
/**
|
212
|
+
* Applies a torque to an actor's physics body.
|
213
|
+
* @param actor - The actor to apply torque to
|
214
|
+
* @param torque - The torque vector to apply
|
215
|
+
*/
|
99
216
|
applyTorque(actor: BaseActor, torque: Vector3): void;
|
217
|
+
/**
|
218
|
+
* Applies an instantaneous torque impulse to an actor's physics body.
|
219
|
+
* @param actor - The actor to apply the impulse to
|
220
|
+
* @param torqueImpulse - The torque impulse vector to apply
|
221
|
+
*/
|
100
222
|
applyTorqueImpulse(actor: BaseActor, torqueImpulse: Vector3): void;
|
223
|
+
/**
|
224
|
+
* Resets all accumulated forces on an actor's physics body.
|
225
|
+
* @param actor - The actor to reset forces for
|
226
|
+
*/
|
101
227
|
resetForces(actor: BaseActor): void;
|
228
|
+
/**
|
229
|
+
* Resets all accumulated torques on an actor's physics body.
|
230
|
+
* @param actor - The actor to reset torques for
|
231
|
+
*/
|
102
232
|
resetTorques(actor: BaseActor): void;
|
233
|
+
/**
|
234
|
+
* Applies a continuous force to an actor's physics body.
|
235
|
+
* @param actor - The actor to apply force to
|
236
|
+
* @param force - The force vector to apply
|
237
|
+
*/
|
103
238
|
applyForce(actor: BaseActor, force: Vector3): void;
|
239
|
+
/**
|
240
|
+
* Applies an instantaneous force impulse to an actor's physics body.
|
241
|
+
* @param actor - The actor to apply the impulse to
|
242
|
+
* @param force - The force impulse vector to apply
|
243
|
+
*/
|
104
244
|
applyImpulse(actor: BaseActor, force: Vector3): void;
|
245
|
+
/**
|
246
|
+
* Applies a force at a specific local point on an actor's physics body.
|
247
|
+
* @param actor - The actor to apply force to
|
248
|
+
* @param force - The force vector to apply
|
249
|
+
* @param localPoint - The local point at which to apply the force
|
250
|
+
*/
|
105
251
|
applyLocalForce(actor: BaseActor, force: Vector3, localPoint?: Vector3): void;
|
252
|
+
/**
|
253
|
+
* Applies an instantaneous force impulse at a specific local point on an actor's physics body.
|
254
|
+
* @param actor - The actor to apply the impulse to
|
255
|
+
* @param force - The force impulse vector to apply
|
256
|
+
* @param localPoint - The local point at which to apply the impulse
|
257
|
+
*/
|
106
258
|
applyLocalImpulse(actor: BaseActor, force: Vector3, localPoint?: Vector3): void;
|
107
259
|
/**
|
108
260
|
* Apply an impulse on all dynamic physics bodies in the direction away from the given
|
@@ -112,40 +264,147 @@ export declare class PhysicsSystem {
|
|
112
264
|
* @param forceAmount
|
113
265
|
*/
|
114
266
|
private applyRadiusImpulse;
|
267
|
+
/**
|
268
|
+
* Removes an actor from the physics world.
|
269
|
+
* @param actor - The actor to remove
|
270
|
+
*/
|
115
271
|
removeActor(actor: BaseActor): void;
|
272
|
+
/**
|
273
|
+
* Removes the physics body for a specific scene object.
|
274
|
+
* @param object - The object to remove physics for
|
275
|
+
*/
|
116
276
|
removeSceneObject(object: Object3D): void;
|
277
|
+
/**
|
278
|
+
* Activates collision event handling for an actor.
|
279
|
+
* @param actor - The actor to activate events for
|
280
|
+
* @private
|
281
|
+
*/
|
117
282
|
private activateActorEvents;
|
283
|
+
/**
|
284
|
+
* Gets an observable for collision events between actors.
|
285
|
+
* @param self - The actor to observe collisions for
|
286
|
+
* @param predicate - Function to filter collision events
|
287
|
+
* @param whenStarted - Whether to emit on collision start or end
|
288
|
+
* @returns Observable of colliding actors
|
289
|
+
* @private
|
290
|
+
*/
|
118
291
|
private _onCollisionWithActorEvent;
|
119
292
|
/**
|
120
|
-
*
|
121
|
-
*
|
293
|
+
* Gets an observable for when an actor begins contact with any object.
|
294
|
+
* @param self - The actor to observe contacts for
|
295
|
+
* @returns Observable of contact events
|
122
296
|
*/
|
123
297
|
onBeginContact(self: BaseActor): Observable<number>;
|
124
298
|
/**
|
125
|
-
*
|
126
|
-
*
|
299
|
+
* Gets an observable for when an actor ends contact with any object.
|
300
|
+
* @param self - The actor to observe contacts for
|
301
|
+
* @returns Observable of contact events
|
127
302
|
*/
|
128
303
|
onEndContact(self: BaseActor): Observable<number>;
|
304
|
+
/**
|
305
|
+
* Gets an observable that tracks whether an actor is in contact with any object.
|
306
|
+
* @param self - The actor to track contacts for
|
307
|
+
* @returns Observable boolean indicating contact state
|
308
|
+
*/
|
129
309
|
onHasContactChanged(self: BaseActor): Observable<boolean>;
|
310
|
+
/**
|
311
|
+
* Gets an observable for when an actor begins overlapping with actors of a specific type.
|
312
|
+
* @param self - The actor to observe overlaps for
|
313
|
+
* @param actorType - The type of actors to detect overlaps with
|
314
|
+
* @returns Observable of overlapping actors
|
315
|
+
*/
|
130
316
|
onBeginOverlapWithActorType<T extends BaseActor, A extends BaseActor>(self: T, actorType: AbstractType<A>): Observable<A>;
|
317
|
+
/**
|
318
|
+
* Gets an observable for when an actor ends overlapping with actors of a specific type.
|
319
|
+
* @param self - The actor to observe overlaps for
|
320
|
+
* @param actorType - The type of actors to detect overlaps with
|
321
|
+
* @returns Observable of overlapping actors
|
322
|
+
*/
|
131
323
|
onEndOverlapWithActorType<T extends BaseActor, A extends BaseActor>(self: T, actorType: AbstractType<A>): Observable<A>;
|
324
|
+
/**
|
325
|
+
* Gets an observable for when an actor begins overlapping with a specific actor.
|
326
|
+
* @param self - The actor to observe overlaps for
|
327
|
+
* @param actor - The specific actor to detect overlaps with
|
328
|
+
* @returns Observable of overlap events
|
329
|
+
*/
|
132
330
|
onBeginOverlapWithActor<T extends BaseActor, A extends BaseActor>(self: T, actor: A): Observable<A>;
|
331
|
+
/**
|
332
|
+
* Gets an observable for when an actor ends overlapping with a specific actor.
|
333
|
+
* @param self - The actor to observe overlaps for
|
334
|
+
* @param actor - The specific actor to detect overlaps with
|
335
|
+
* @returns Observable of overlap events
|
336
|
+
*/
|
133
337
|
onEndOverlapWithActor<T extends BaseActor, A extends BaseActor>(self: T, actor: A): Observable<A>;
|
338
|
+
/**
|
339
|
+
* Gets an observable for collision events with a specific actor.
|
340
|
+
* @param self - The actor to observe collisions for
|
341
|
+
* @param actor - The specific actor to detect collisions with
|
342
|
+
* @returns Observable of collision events
|
343
|
+
*/
|
134
344
|
onCollisionWithActor<A extends BaseActor, S extends BaseActor>(self: S, actor: A): Observable<A>;
|
345
|
+
/**
|
346
|
+
* Gets an observable for collision events with actors of a specific type.
|
347
|
+
* @param self - The actor to observe collisions for
|
348
|
+
* @param actorType - The type of actors to detect collisions with
|
349
|
+
* @returns Observable of collision events
|
350
|
+
*/
|
135
351
|
onCollisionWithActorType<A extends BaseActor, S extends BaseActor>(self: S, actorType: AbstractType<A>): Observable<A>;
|
352
|
+
/**
|
353
|
+
* Updates the transform of an actor's physics body to match its visual representation.
|
354
|
+
* @param actor - The actor to update
|
355
|
+
*/
|
136
356
|
updateActorTransform(actor: BaseActor): void;
|
357
|
+
/**
|
358
|
+
* Sets up the physics world with default gravity.
|
359
|
+
* @private
|
360
|
+
*/
|
137
361
|
private setupWorld;
|
362
|
+
/**
|
363
|
+
* Gets the contact points between an actor and other objects in a specific direction.
|
364
|
+
* @param actor - The actor to check contacts for
|
365
|
+
* @param direction - The direction to check in
|
366
|
+
* @returns Array of contact points with position and normal information
|
367
|
+
*/
|
138
368
|
getActorContacts(actor: BaseActor, direction: Vector3): {
|
139
369
|
ri: Vector3;
|
140
370
|
rj: Vector3;
|
141
371
|
ni: Vector3;
|
142
372
|
}[];
|
373
|
+
/**
|
374
|
+
* Stops the physics simulation and cleans up resources.
|
375
|
+
*/
|
143
376
|
stop(): void;
|
144
377
|
/**
|
145
|
-
*
|
378
|
+
* Creates a static physics body for a scene object.
|
379
|
+
* @param object - The object to create a body for
|
380
|
+
* @param collisionShapes - The collision shapes to use
|
381
|
+
* @param options - Optional physics settings
|
382
|
+
* @returns The created rigid body
|
383
|
+
* @private
|
146
384
|
*/
|
147
385
|
private createStaticBody;
|
386
|
+
/**
|
387
|
+
* Adds a collision shape to a rigid body.
|
388
|
+
* @param body - The rigid body to add the shape to
|
389
|
+
* @param shapeInfo - The collision shape information
|
390
|
+
* @param object - The object the shape is based on
|
391
|
+
* @returns The created collider
|
392
|
+
* @private
|
393
|
+
*/
|
148
394
|
private addShape;
|
395
|
+
/**
|
396
|
+
* Creates a Rapier collision shape from shape information and scale.
|
397
|
+
* @param shapeInfo - The collision shape information
|
398
|
+
* @param scale - The scale to apply to the shape
|
399
|
+
* @returns The created collider description
|
400
|
+
* @private
|
401
|
+
*/
|
149
402
|
private createShape;
|
403
|
+
/**
|
404
|
+
* Creates a new character collision object
|
405
|
+
* @returns A new RAPIER.CharacterCollision instance
|
406
|
+
*/
|
407
|
+
createCharacterCollision(): RAPIER.CharacterCollision;
|
150
408
|
}
|
151
409
|
export {};
|
410
|
+
//# sourceMappingURL=physics-system.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"physics-system.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/services/physics/physics-system.ts"],"names":[],"mappings":"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"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as e,__metadata as t}from"tslib";import*as i from"@dimforge/rapier3d-compat";import{QueryFilterFlags as s}from"@dimforge/rapier3d-compat";import{BehaviorSubject as o,distinctUntilChanged as n,filter as r,map as a,Subject as c,takeUntil as l}from"rxjs";import*as d from"three";import{ArrowHelper as h,BufferAttribute as u,BufferGeometry as y,Group as p,LineSegments as g,Matrix4 as m,Object3D as f,Quaternion as w,Raycaster as v,Scene as x,Vector3 as B}from"three";import{Service as b}from"typedi";import{AssetMeshInstance as A}from"../../../scene/asset-resource-loader.js";import{BoxCollisionShape as C,CapsuleCollisionShape as D,ConeCollisionShape as z,ConvexPolyhedronCollisionShape as R,CylinderCollisionShape as S,PhysicalShapeMesh as T,PlaneCollisionShape as M,SphereCollisionShape as E,TrimeshCollisionShape as W}from"../../../index.js";import{LandscapeGroup as F}from"../../../scene/landscape/landscape.js";import{ViewController as V}from"../render.js";import{World as _}from"../world.js";import*as I from"three/examples/jsm/utils/BufferGeometryUtils.js";import{calculateEffectiveScale as L}from"../../../utils/three/traverse.js";export class RayTestResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.hitNormal=new B}}export var PhysicsBodyType;!function(e){e[e.dynamic=1]="dynamic",e[e.static=2]="static",e[e.kinematic=4]="kinematic",e[e.kinematicVelocityBased=8]="kinematicVelocityBased"}(PhysicsBodyType||(PhysicsBodyType={}));let P=class{set showDebug(e){this.shouldRenderDebug=e,this.debugMesh&&(this.debugMesh.visible=e)}get showDebug(){return this.shouldRenderDebug}constructor(e,t){this.viewController=e,this.gameWorld=t,this.staticMeshes=new Map,this.staticBodies=new Map,this.actorBodies=new Map,this.bodyActors=new Map,this.collisionEvents=new c,this.beforeStep=new c,this.afterStep=new c,this.shouldRenderDebug=!1,this._raycaster=new v,this._reusableResult=new RayTestResult,this._raytestDiff=new B,this._raytestDirection=new B,this.controlledActors=new Set,this.ready=this.setup()}createDebugMesh(){return new g(new y,new d.LineBasicMaterial({color:255}))}async start(){return await this.ready,this.handleTick(),this.ready}renderDebug(){null==this.debugMesh&&(this.debugMesh=this.createDebugMesh(),this.debugMesh.visible=this.shouldRenderDebug,this.debugMesh.raycast=function(){},this.gameWorld.scene.add(this.debugMesh));const e=this.world.debugRender();this.debugMesh.geometry.setAttribute("position",new u(e.vertices,3))}async setup(){if(null!=this.rapier)throw new Error("Rapier is already estup");this.rapier=await H(),this.eventQueue=new i.EventQueue(!0),this.setupWorld()}handleTick(){this.fixedupdateSub=this.viewController.onUpdate().subscribe((e=>{e=Math.min(.1,e),this.beforeStep.next(e),this.updatePhysics(e),this.afterStep.next(e),this.showDebug&&this.renderDebug(),this.world.bodies.forEach((e=>{if(e.isFixed())return;const t=this.staticMeshes.get(e)??this.bodyActors.get(e)?.object;var i,s;null!=t&&(t.parent instanceof x&&(K(t.position,e.translation()),(e.isDynamic()||e.isKinematic()&&!this.controlledActors.has(this.bodyActors.get(e)?.id))&&(i=t.quaternion,s=e.rotation(),i.x=s.x,i.y=s.y,i.z=s.z,i.w=s.w)))}))}))}_updateWorld(){this.world.timestep=0,this.world.step()}updatePhysics(e){this.world.timestep=e,this.world.step(this.eventQueue),this.eventQueue.drainCollisionEvents(((e,t,i)=>{this.collisionEvents.next({handle1:e,handle2:t,started:i}),this.collisionEvents.next({handle1:t,handle2:e,started:i})}))}rayTestFromCamera(e,t,i){this._raycaster.setFromCamera(U,this.viewController.getCamera());const s=this._raycaster.ray.origin,o=this._raycaster.ray.direction.multiplyScalar(e).add(s);return this.rayTest(s,o,t,i)}rayTest(e,t,s,o){null==s&&(s=this._reusableResult);const n=this._raytestDiff,r=this._raytestDirection;if(n.subVectors(t,e),r.copy(n).normalize(),0===r.length())return console.warn("Ray test called with to and from being equal"),s;const a=new i.Ray(e,r),c=n.length(),l=this.world.castRayAndGetNormal(a,c,!1,void 0,void 0,void 0,null!=o?.excludeActor?this.actorBodies.get(o.excludeActor.id):void 0,o?.excludeTriggers?e=>!e.isSensor():void 0);if(s.hasHit=null!=l,s.hasHit){const t=a.pointAt(l.timeOfImpact);s._internal=l,K(s.hitNormal,l.normal),K(s.hitPoint,t),s.distance=Z.subVectors(s.hitPoint,e).length();const i=this.world.bodies.getAll().find((e=>function(e,t){for(let i=0,s=e.numColliders();i<s;i++){const s=e.collider(i);if(t(s))return s}}(e,(e=>e===l.collider))));s.actor=null!=i?this.bodyActors.get(i):null}if(this.showDebug){const t=new h(r,e,c,o?.debugColor??255);this.gameWorld.scene.add(t),setTimeout((()=>this.gameWorld.scene.remove(t)),o?.debugLifetime??200)}return this._reusableResult}setGravity(e,t,i){this.world.gravity.x=e,this.world.gravity.y=t,this.world.gravity.z=i}getGravity(){return N.set(this.world.gravity.x,this.world.gravity.y,this.world.gravity.z)}addFromScene(e){this.addRecursively(e);for(const e of this.staticBodies.values())Y(e,(e=>e.setActiveEvents(i.ActiveEvents.COLLISION_EVENTS)))}addRecursively(e){if(this.removeSceneObject(e),!function(e){if(null!=e.userData?.src){const t=e.userData?.src;return"actor"===t.type}return!1}(e))if(e instanceof T&&null!=e.collisionShape){const t=this.createStaticBody(e,[e.collisionShape],e.physics);this.staticMeshes.set(t,e),this.staticBodies.set(e,t)}else if(e instanceof A&&!1!==e.userData?.src?.collisionDetection)if(e.children[0]&&e.children[0].instanceMatrix)this.createForInstancedMesh(e.children[0],e.collisionShapes);else{const t=this.createStaticBody(e,e.collisionShapes,e.physics);this.staticMeshes.set(t,e),this.staticBodies.set(e,t)}else e instanceof F?this.addLandscapeGroup(e):(e instanceof p||e instanceof x)&&e.children.forEach((e=>this.addRecursively(e)))}createForInstancedMesh(e,t){const i=new m;for(let s=0;s<e.count;s++){const o=new f;o.matrix.identity(),i.fromArray(e.instanceMatrix.array,16*s),o.applyMatrix4(i);this.createStaticBody(o,t)}}getCharacterController(e=.01){return this.world?.createCharacterController(e)}getActorComputedMovement(e,t,i,o=null){const n=this.actorBodies.get(e.id);this.controlledActors.add(e.id);const r=n.collider(0);t.computeColliderMovement(r,i,s.EXCLUDE_SENSORS,o,$);const a=t.computedMovement();return K(J,a),J}setNextKinematicTranslation(e,t){const i=this.actorBodies.get(e.id),s=i.translation();s.x+=t.x,s.y+=t.y,s.z+=t.z,i?.setNextKinematicTranslation(s)}setAngularVelocity(e,t){const i=this.actorBodies.get(e.id);G.x=t.x,G.y=t.y,G.z=t.z,i?.setAngvel(G,!0)}setLinearVelocity(e,t){const i=this.actorBodies.get(e.id);G.x=t.x,G.y=t.y,G.z=t.z,i?.setLinvel(G,!0)}getLinearVelocity(e,t=new B){const i=this.actorBodies.get(e.id).linvel();return t.x=i.x,t.y=i.y,t.z=i.z,t}getAngularVelocity(e,t=new B){const i=this.actorBodies.get(e.id).angvel();return t.x=i.x,t.y=i.y,t.z=i.z,t}setLinearDamping(e,t){const i=this.actorBodies.get(e.id);i?.setLinearDamping(t)}setAngularDamping(e,t){const i=this.actorBodies.get(e.id);i?.setAngularDamping(t)}createCharacterCollision(){return new i.CharacterCollision}addLandscapeGroup(e){const t=e.userData.src,s=t.landscape.heightMaps;for(const n of e.sections){this.staticBodies.has(n)&&this.world.removeRigidBody(this.staticBodies.get(n));var o=n.getWorldPosition(new B);if(t.landscape.holes&&t.landscape.holes.some((e=>e.m===n.name&&0!==e.w[0]))){const e=n.geometry.clone(),s=n.scale,r=n.geometry.getAttribute("hole"),a=new Float32Array(e.getAttribute("position").array);for(let e=0;e<a.length;e+=3)a[e]*=s.x,a[e+1]*=s.y,a[e+2]*=s.z;const c=e.index;for(let e=0;e<c.count;e+=3){const t=r.getX(c.getX(e)),i=r.getX(c.getY(e)),s=r.getX(c.getZ(e));(t>.5||i>.5||s>.5)&&(c.setX(e,0),c.setY(e,0),c.setZ(e,0))}const l=i.ColliderDesc.trimesh(a,new Uint32Array(e.getIndex().array));if(!1!==t.collisionDetection){const e=this.world.createRigidBody(i.RigidBodyDesc.fixed()),t=new i.Vector3(0,0,0);X(t,o),e.setTranslation(t,!1),this.world.createCollider(l,e),this.staticBodies.set(n,e)}continue}const e=t.landscape.options.density+1,r=t.landscape.options.sectionSize,a=new Array(e);for(let t=0;t<e;t++)a[t]=new Array(e).fill(0);const c=s.find((e=>e.x===n.x&&e.y==n.y));if(null!=c)for(const t of c.points){if(null==a[t.i%e])continue;const i=e-1-Math.floor(t.i/e);i in a[t.i%e]?a[t.i%e][i]=t.y/r:console.warn("wrong index",{points:a,point:t,i:t.i%e,k:i,heightMap:c})}const l=t.landscape.options.density,d=a.flatMap((e=>e.reverse())),h=i.ColliderDesc.heightfield(l,l,new Float32Array(d),new i.Vector3(r,r,r));if(!1!==t.collisionDetection){const e=this.world.createRigidBody(i.RigidBodyDesc.fixed()),t=new i.Vector3(0,0,0);X(t,o),e.setTranslation(t,!1),this.world.createCollider(h,e),this.staticBodies.set(n,e)}}}addActor(e,t,s={}){if(0==t.length)return void console.error("No collision shapes were defined when adding actor to the physics system.");this.removeActor(e);const o=e.object;let n;switch(s.type??PhysicsBodyType.static){case PhysicsBodyType.dynamic:n=i.RigidBodyDesc.dynamic(),n.mass=s.mass??1;break;case PhysicsBodyType.kinematic:n=i.RigidBodyDesc.kinematicPositionBased();break;case PhysicsBodyType.kinematicVelocityBased:n=i.RigidBodyDesc.kinematicVelocityBased();break;default:n=s.isTrigger?i.RigidBodyDesc.kinematicVelocityBased():i.RigidBodyDesc.fixed()}const r=this.world.createRigidBody(n);r.enableCcd(1==s.continousCollisionDetection);for(const e of t)this.addShape(r,e,o);Y(r,(e=>{null!=s.isTrigger&&(e.setSensor(s.isTrigger),e.setActiveCollisionTypes(i.ActiveCollisionTypes.ALL),e.setActiveEvents(i.ActiveEvents.COLLISION_EVENTS)),null!=s.friction&&e.setFriction(s.friction),null!=s.density&&e.setDensity(s.density),null!=s.mass&&e.setMass(s.mass),null!=s.restitution&&e.setRestitution(s.restitution)})),O(r,o),!0===s.ignoreForNavMesh&&(r.userData={ignoreForNavMesh:!0}),this.actorBodies.set(e.id,r),this.bodyActors.set(r,e)}applyTorque(e,t){const i=this.actorBodies.get(e.id);G.x=t.x,G.y=t.y,G.z=t.z,i?.addTorque(G,!0)}applyTorqueImpulse(e,t){const i=this.actorBodies.get(e.id);G.x=t.x,G.y=t.y,G.z=t.z,i?.applyTorqueImpulse(G,!0)}resetForces(e){const t=this.actorBodies.get(e.id);t?.resetForces(!1)}resetTorques(e){const t=this.actorBodies.get(e.id);t?.resetTorques(!1)}applyForce(e,t){const i=this.actorBodies.get(e.id);G.x=t.x,G.y=t.y,G.z=t.z,i?.addForce(G,!0)}applyImpulse(e,t){const i=this.actorBodies.get(e.id);G.x=t.x,G.y=t.y,G.z=t.z,i?.applyImpulse(G,!0)}applyLocalForce(e,t,i){const s=this.actorBodies.get(e.id);X(G,t),null==i?s?.addForce(G,!0):(X(q,i),s?.addForceAtPoint(G,q,!0))}applyLocalImpulse(e,t,i){const s=this.actorBodies.get(e.id);X(G,t),null==i?s.applyImpulse(G,!0):(X(q,i),s.applyImpulseAtPoint(G,q,!0))}applyRadiusImpulse(e,t,s){this.world.bodies.forEach((o=>{if(o.collider(0)?.isSensor())return;if(o.bodyType()!==i.RigidBodyType.Dynamic)return;const n=Q;K(n,o.translation());const r=n.clone().sub(e);if(r.length()>t)return;const a=r.clone().normalize().multiplyScalar(s);G.x=a.x,G.y=a.y,G.z=a.z,o.applyImpulse(G,!0)}))}removeActor(e){if(null==e)return;this.controlledActors.delete(e.id);const t=this.actorBodies.get(e.id);null!=t&&(this.bodyActors.delete(t),this.world.removeRigidBody(t)),this.actorBodies.delete(e.id)}removeRemoved(e){const t=new Set;e.traverse((e=>{t.add(e.uuid)}));for(const[e,i]of this.staticBodies.entries())!t.has(e.uuid)&&this.world.getRigidBody(i.handle)&&(this.staticBodies.delete(e),this.world.removeRigidBody(i))}removeSceneObject(e){if(e instanceof F){for(const t of e.sections)this.removeSceneObject(t);return}let t=this.staticBodies.get(e);null!=t&&this.world.getRigidBody(t.handle)&&this.world.removeRigidBody(t),this.staticBodies.delete(e)}activateActorEvents(e){this.actorBodies.get(e.id)}_onCollisionWithActorEvent(e,t,i){return this.activateActorEvents(e),this.collisionEvents.pipe(l(e.disposed),r((({started:e})=>e===i)),a((({handle1:e,handle2:t,started:i})=>({a1:this.bodyActors.get(this.world.getCollider(e)?.parent()),a2:this.bodyActors.get(this.world.getCollider(t)?.parent()),started:i}))),r((({a1:i,a2:s})=>null!=i&&null!=s&&i.id===e.id&&t(i,s))),a((({a2:e})=>e)))}onBeginContact(e){return this.activateActorEvents(e),this.collisionEvents.pipe(l(e.disposed),r((e=>e.started)),r((({handle1:t})=>{const i=this.bodyActors.get(this.world.getCollider(t)?.parent());return null!=i&&i.id===e.id})),a((e=>e.handle2)))}onEndContact(e){return this.activateActorEvents(e),this.collisionEvents.pipe(l(e.disposed),r((e=>!e.started)),r((({handle1:t})=>{const i=this.bodyActors.get(this.world.getCollider(t)?.parent());return null!=i&&i.id===e.id})),a((e=>e.handle2)))}onHasContactChanged(e){const t=new Set,i=new o(!1);return this.onBeginContact(e).subscribe((e=>{t.add(e),i.next(t.size>0)})),this.onEndContact(e).subscribe((e=>{t.delete(e),i.next(t.size>0)})),i.pipe(n())}onBeginOverlapWithActorType(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>i instanceof t),!0)}onEndOverlapWithActorType(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>i instanceof t),!1)}onBeginOverlapWithActor(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>t.id===i.id),!0)}onEndOverlapWithActor(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>t.id===i.id),!1)}onCollisionWithActor(e,t){return this.onBeginOverlapWithActor(e,t)}onCollisionWithActorType(e,t){return this.onBeginOverlapWithActorType(e,t)}updateActorTransform(e){const t=this.actorBodies.get(e.id);null!=t?O(t,e.object):console.warn("Actor has not been added to physics world",e)}setupWorld(){const e=new i.World({x:0,y:-9.81,z:0});this.world=e}getActorContacts(e,t){const s=this.actorBodies.get(e.id);if(s&&s.numColliders()>0){const o=s.collider(0);let n=o.shape,r=o.translation(),a=o.rotation(),c=t,l=.3;const d=this.world.castShape(r,a,c,n,.1,l,!0,null,null,null,this.actorBodies.get(e.id),(e=>e.shape.type!=i.ShapeType.HeightField));if(null!=d){const e=new B,t=new B,i=new B;return K(e,d.witness2),K(t,d.witness1),K(i,d.normal1),i.negate(),[{ri:e,rj:t,ni:i}]}return[]}return console.warn("Actor is not added to the physics system"),[]}stop(){this.world?.bodies.forEach((e=>this.world.removeRigidBody(e))),this.world?.free(),this.fixedupdateSub?.unsubscribe()}createStaticBody(e,t,s){const o=s?.type===PhysicsBodyType.dynamic?i.RigidBodyDesc.dynamic():i.RigidBodyDesc.fixed(),n=this.world.createRigidBody(o);for(const i of t){if(null==i){console.warn("Collision shape is missing for object",e);continue}const o=this.addShape(n,i,e);null!=s?.friction&&o.setFriction(s.friction),null!=s?.density&&o.setDensity(s.density),null!=s?.mass&&o.setMass(s.mass/t.length),null!=s?.restitution&&o.setRestitution(s.restitution)}return O(n,e),n.userData=e.uuid,n}addShape(e,t,i){const s=i.getWorldScale(ee),o=this.createShape(t,s);null!=t.collisionGroup&&o.setCollisionGroups(t.collisionGroup),o.friction=.1;const n=t.offset.clone().multiply(s);var r,a;X(o.translation,n),r=o.rotation,a=(new w).setFromEuler(t.rotation),r.x=a.x,r.y=a.y,r.z=a.z,r.w=a.w;return this.world.createCollider(o,e)}createShape(e,t){if(e instanceof C)return i.ColliderDesc.cuboid(e.dimensions.x*t.x/2,e.dimensions.y*t.y/2,e.dimensions.z*t.z/2);if(e instanceof D){return i.ColliderDesc.capsule(e.length/2*t.y,e.radius*Math.max(t.z,t.x))}if(e instanceof W){const s=null!=e.geometry.getIndex()?e.geometry:I.mergeVertices(e.geometry),o=new Float32Array(s.getAttribute("position").array);for(let e=0;e<o.length;e+=3)o[e]*=t.x,o[e+1]*=t.y,o[e+2]*=t.z;return i.ColliderDesc.trimesh(o,new Uint32Array(s.getIndex().array))}if(e instanceof R){let s;e.mesh instanceof d.Mesh?s=e.mesh.geometry:e.mesh instanceof d.BufferGeometry?s=e.mesh:console.log("Unknownd shape",{shapeInfo:e});const o=new Float32Array(s.getAttribute("position").array);if(e.mesh instanceof d.Mesh){const t=L(e.mesh);for(let e=0;e<o.length;e+=3)o[e]*=t.x,o[e+1]*=t.y,o[e+2]*=t.z}for(let e=0;e<o.length;e+=3)o[e]*=t.x,o[e+1]*=t.y,o[e+2]*=t.z;const n=o;return i.ColliderDesc.convexHull(n)}if(e instanceof E){const s=2*t.x-t.y-t.z;return Math.abs(s)>.01?this.createShape(new R(new d.SphereGeometry(e.radius).scale(t.x,t.y,t.z)),new B(1,1,1)):i.ColliderDesc.ball(e.radius*Math.max(t.x,t.y,t.z))}return e instanceof S?i.ColliderDesc.cylinder(e.height/2*t.y,e.radiusTop*Math.max(t.z,t.x)):e instanceof z?i.ColliderDesc.cone(e.height*t.y,e.radiusBottom/2*Math.max(t.z,t.x)):e instanceof M?i.ColliderDesc.cuboid(e.width/2*t.x,e.height/2*t.y,.01):(console.error("Unsupported shape",e),i.ColliderDesc.cuboid(1,1,1))}};P=e([b(),t("design:paramtypes",[V,_])],P);export{P as PhysicsSystem};const j=new B,k=new d.Quaternion;function O(e,t){const s=t.getWorldPosition(j),o=t.getWorldQuaternion(k);e.setTranslation(new i.Vector3(s.x,s.y,s.z),!1),e.setRotation(new i.Quaternion(o.x,o.y,o.z,o.w),!1)}const N=new B,G=new i.Vector3(0,0,0),q=new i.Vector3(0,0,0),Q=new B,U=new d.Vector2,H=async()=>{let e=await import("@dimforge/rapier3d-compat");return await e.init(),e};function X(e,t){e.x=t.x,e.y=t.y,e.z=t.z}function K(e,t){e.x=t.x,e.y=t.y,e.z=t.z}function Y(e,t){for(let i=0,s=e.numColliders();i<s;i++){t(e.collider(i))}}const Z=new B,J=new B,$=e=>!e.isSensor(),ee=new B;
|
2
|
-
/*
|
1
|
+
import{__decorate as e,__metadata as t}from"tslib";import*as i from"@dimforge/rapier3d-compat";import{QueryFilterFlags as s}from"@dimforge/rapier3d-compat";import{BehaviorSubject as o,distinctUntilChanged as r,filter as n,map as a,Subject as c,takeUntil as l}from"rxjs";import*as d from"three";import{ArrowHelper as h,BufferAttribute as u,BufferGeometry as y,Group as p,LineSegments as g,Matrix4 as m,Object3D as f,Quaternion as w,Raycaster as v,Scene as x,Vector3 as B}from"three";import{Service as b}from"typedi";import{AssetMeshInstance as A}from"../../../scene/asset-resource-loader.js";import{BoxCollisionShape as C,CapsuleCollisionShape as D,ConeCollisionShape as z,ConvexPolyhedronCollisionShape as R,CylinderCollisionShape as S,PhysicalShapeMesh as T,PlaneCollisionShape as M,SphereCollisionShape as E,TrimeshCollisionShape as W}from"../../../index.js";import{LandscapeGroup as F}from"../../../scene/landscape/landscape.js";import{ViewController as V}from"../render.js";import{World as _}from"../world.js";import*as I from"three/examples/jsm/utils/BufferGeometryUtils.js";import{calculateEffectiveScale as j}from"../../../utils/three/traverse.js";import{AbstractPhysicsSystem as L}from"./abstract-physics-system.js";export class RayTestResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.hitNormal=new B}}export var PhysicsBodyType;!function(e){e[e.dynamic=1]="dynamic",e[e.static=2]="static",e[e.kinematic=4]="kinematic",e[e.kinematicVelocityBased=8]="kinematicVelocityBased"}(PhysicsBodyType||(PhysicsBodyType={}));let P=class extends L{set showDebug(e){this.shouldRenderDebug=e,this.debugMesh&&(this.debugMesh.visible=e)}get showDebug(){return this.shouldRenderDebug}constructor(e,t){super(),this.viewController=e,this.gameWorld=t,this.staticMeshes=new Map,this.staticBodies=new Map,this.actorBodies=new Map,this.bodyActors=new Map,this.collisionEvents=new c,this.beforeStep=new c,this.afterStep=new c,this.shouldRenderDebug=!1,this._raycaster=new v,this._reusableResult=new RayTestResult,this._raytestDiff=new B,this._raytestDirection=new B,this.controlledActors=new Set,this.ready=this.setup()}createDebugMesh(){return new g(new y,new d.LineBasicMaterial({color:255}))}async start(){return await this.ready,this.handleTick(),this.ready}renderDebug(){null==this.debugMesh&&(this.debugMesh=this.createDebugMesh(),this.debugMesh.visible=this.shouldRenderDebug,this.debugMesh.raycast=function(){},this.gameWorld.scene.add(this.debugMesh));const e=this.world.debugRender();this.debugMesh.geometry.setAttribute("position",new u(e.vertices,3))}async setup(){if(null!=this.rapier)throw new Error("Rapier is already estup");this.rapier=await X(),this.eventQueue=new i.EventQueue(!0),this.setupWorld()}handleTick(){this.fixedupdateSub=this.viewController.onUpdate().subscribe((e=>{e=Math.min(.1,e),this.beforeStep.next(e),this.updatePhysics(e),this.afterStep.next(e),this.showDebug&&this.renderDebug(),this.world.bodies.forEach((e=>{if(e.isFixed())return;const t=this.staticMeshes.get(e)??this.bodyActors.get(e)?.object;var i,s;null!=t&&(t.parent instanceof x&&(Y(t.position,e.translation()),(e.isDynamic()||e.isKinematic()&&!this.controlledActors.has(this.bodyActors.get(e)?.id))&&(i=t.quaternion,s=e.rotation(),i.x=s.x,i.y=s.y,i.z=s.z,i.w=s.w)))}))}))}_updateWorld(){this.world.timestep=0,this.world.step()}updatePhysics(e){this.world.timestep=e,this.world.step(this.eventQueue),this.eventQueue.drainCollisionEvents(((e,t,i)=>{this.collisionEvents.next({handle1:e,handle2:t,started:i}),this.collisionEvents.next({handle1:t,handle2:e,started:i})}))}rayTestFromCamera(e,t,i){this._raycaster.setFromCamera(H,this.viewController.getCamera());const s=this._raycaster.ray.origin,o=this._raycaster.ray.direction.multiplyScalar(e).add(s);return this.rayTest(s,o,t,i)}rayTest(e,t,s,o){null==s&&(s=this._reusableResult);const r=this._raytestDiff,n=this._raytestDirection;if(r.subVectors(t,e),n.copy(r).normalize(),0===n.length())return console.warn("Ray test called with to and from being equal"),s;const a=new i.Ray(e,n),c=r.length(),l=this.world.castRayAndGetNormal(a,c,!1,void 0,void 0,void 0,null!=o?.excludeActor?this.actorBodies.get(o.excludeActor.id):void 0,o?.excludeTriggers?e=>!e.isSensor():void 0);if(s.hasHit=null!=l,s.hasHit){const t=a.pointAt(l.timeOfImpact);s._internal=l,Y(s.hitNormal,l.normal),Y(s.hitPoint,t),s.distance=J.subVectors(s.hitPoint,e).length();const i=this.world.bodies.getAll().find((e=>function(e,t){for(let i=0,s=e.numColliders();i<s;i++){const s=e.collider(i);if(t(s))return s}}(e,(e=>e===l.collider))));s.actor=null!=i?this.bodyActors.get(i):null}if(this.showDebug){const t=new h(n,e,c,o?.debugColor??255);this.gameWorld.scene.add(t),setTimeout((()=>this.gameWorld.scene.remove(t)),o?.debugLifetime??200)}return this._reusableResult}setGravity(e,t,i){this.world.gravity.x=e,this.world.gravity.y=t,this.world.gravity.z=i}getGravity(){return G.set(this.world.gravity.x,this.world.gravity.y,this.world.gravity.z)}addFromScene(e){this.addRecursively(e);for(const e of this.staticBodies.values())Z(e,(e=>e.setActiveEvents(i.ActiveEvents.COLLISION_EVENTS)))}addRecursively(e){if(this.removeSceneObject(e),!function(e){if(null!=e.userData?.src){const t=e.userData?.src;return"actor"===t.type}return!1}(e))if(e instanceof T&&null!=e.collisionShape){const t=this.createStaticBody(e,[e.collisionShape],e.physics);this.staticMeshes.set(t,e),this.staticBodies.set(e,t)}else if(e instanceof A&&!1!==e.userData?.src?.collisionDetection)if(e.children[0]&&e.children[0].instanceMatrix)this.createForInstancedMesh(e.children[0],e.collisionShapes);else{const t=this.createStaticBody(e,e.collisionShapes,e.physics);this.staticMeshes.set(t,e),this.staticBodies.set(e,t)}else e instanceof F?this.addLandscapeGroup(e):(e instanceof p||e instanceof x)&&e.children.forEach((e=>this.addRecursively(e)))}createForInstancedMesh(e,t){const i=new m;for(let s=0;s<e.count;s++){const o=new f;o.matrix.identity(),i.fromArray(e.instanceMatrix.array,16*s),o.applyMatrix4(i);this.createStaticBody(o,t)}}getCharacterController(e){return this.world?.createCharacterController(e)}getActorComputedMovement(e,t,i,o=null){const r=this.actorBodies.get(e.id);this.controlledActors.add(e.id);const n=r.collider(0);t.computeColliderMovement(n,i,s.EXCLUDE_SENSORS,o,ee);const a=t.computedMovement();return Y($,a),$}setNextKinematicTranslation(e,t){const i=this.actorBodies.get(e.id),s=i.translation();s.x+=t.x,s.y+=t.y,s.z+=t.z,i?.setNextKinematicTranslation(s)}setAngularVelocity(e,t){const i=this.actorBodies.get(e.id);q.x=t.x,q.y=t.y,q.z=t.z,i?.setAngvel(q,!0)}setLinearVelocity(e,t){const i=this.actorBodies.get(e.id);q.x=t.x,q.y=t.y,q.z=t.z,i?.setLinvel(q,!0)}getLinearVelocity(e,t){const i=this.actorBodies.get(e.id).linvel();return t.x=i.x,t.y=i.y,t.z=i.z,t}getAngularVelocity(e,t){const i=this.actorBodies.get(e.id).angvel();return t.x=i.x,t.y=i.y,t.z=i.z,t}setLinearDamping(e,t){const i=this.actorBodies.get(e.id);i?.setLinearDamping(t)}setAngularDamping(e,t){const i=this.actorBodies.get(e.id);i?.setAngularDamping(t)}addLandscapeGroup(e){const t=e.userData.src,s=t.landscape.heightMaps;for(const r of e.sections){this.staticBodies.has(r)&&this.world.removeRigidBody(this.staticBodies.get(r));var o=r.getWorldPosition(new B);if(t.landscape.holes&&t.landscape.holes.some((e=>e.m===r.name&&0!==e.w[0]))){const e=r.geometry.clone(),s=r.scale,n=r.geometry.getAttribute("hole"),a=new Float32Array(e.getAttribute("position").array);for(let e=0;e<a.length;e+=3)a[e]*=s.x,a[e+1]*=s.y,a[e+2]*=s.z;const c=e.index;for(let e=0;e<c.count;e+=3){const t=n.getX(c.getX(e)),i=n.getX(c.getY(e)),s=n.getX(c.getZ(e));(t>.5||i>.5||s>.5)&&(c.setX(e,0),c.setY(e,0),c.setZ(e,0))}const l=i.ColliderDesc.trimesh(a,new Uint32Array(e.getIndex().array));if(!1!==t.collisionDetection){const e=this.world.createRigidBody(i.RigidBodyDesc.fixed()),t=new i.Vector3(0,0,0);K(t,o),e.setTranslation(t,!1),this.world.createCollider(l,e),this.staticBodies.set(r,e)}continue}const e=t.landscape.options.density+1,n=t.landscape.options.sectionSize,a=new Array(e);for(let t=0;t<e;t++)a[t]=new Array(e).fill(0);const c=s.find((e=>e.x===r.x&&e.y==r.y));if(null!=c)for(const t of c.points){if(null==a[t.i%e])continue;const i=e-1-Math.floor(t.i/e);i in a[t.i%e]?a[t.i%e][i]=t.y/n:console.warn("wrong index",{points:a,point:t,i:t.i%e,k:i,heightMap:c})}const l=t.landscape.options.density,d=a.flatMap((e=>e.reverse())),h=i.ColliderDesc.heightfield(l,l,new Float32Array(d),new i.Vector3(n,n,n));if(!1!==t.collisionDetection){const e=this.world.createRigidBody(i.RigidBodyDesc.fixed()),t=new i.Vector3(0,0,0);K(t,o),e.setTranslation(t,!1),this.world.createCollider(h,e),this.staticBodies.set(r,e)}}}addActor(e,t,s={}){if(0==t.length)return void console.error("No collision shapes were defined when adding actor to the physics system.");this.removeActor(e);const o=e.object;let r;switch(s.type??PhysicsBodyType.static){case PhysicsBodyType.dynamic:r=i.RigidBodyDesc.dynamic(),r.mass=s.mass??1;break;case PhysicsBodyType.kinematic:r=i.RigidBodyDesc.kinematicPositionBased();break;case PhysicsBodyType.kinematicVelocityBased:r=i.RigidBodyDesc.kinematicVelocityBased();break;default:r=s.isTrigger?i.RigidBodyDesc.kinematicVelocityBased():i.RigidBodyDesc.fixed()}const n=this.world.createRigidBody(r);n.enableCcd(1==s.continousCollisionDetection);for(const e of t)this.addShape(n,e,o);Z(n,(e=>{null!=s.isTrigger&&(e.setSensor(s.isTrigger),e.setActiveCollisionTypes(i.ActiveCollisionTypes.ALL),e.setActiveEvents(i.ActiveEvents.COLLISION_EVENTS)),null!=s.friction&&e.setFriction(s.friction),null!=s.density&&e.setDensity(s.density),null!=s.mass&&e.setMass(s.mass),null!=s.restitution&&e.setRestitution(s.restitution)})),N(n,o),!0===s.ignoreForNavMesh&&(n.userData={ignoreForNavMesh:!0}),this.actorBodies.set(e.id,n),this.bodyActors.set(n,e)}applyTorque(e,t){const i=this.actorBodies.get(e.id);q.x=t.x,q.y=t.y,q.z=t.z,i?.addTorque(q,!0)}applyTorqueImpulse(e,t){const i=this.actorBodies.get(e.id);q.x=t.x,q.y=t.y,q.z=t.z,i?.applyTorqueImpulse(q,!0)}resetForces(e){const t=this.actorBodies.get(e.id);t?.resetForces(!1)}resetTorques(e){const t=this.actorBodies.get(e.id);t?.resetTorques(!1)}applyForce(e,t){const i=this.actorBodies.get(e.id);q.x=t.x,q.y=t.y,q.z=t.z,i?.addForce(q,!0)}applyImpulse(e,t){const i=this.actorBodies.get(e.id);q.x=t.x,q.y=t.y,q.z=t.z,i?.applyImpulse(q,!0)}applyLocalForce(e,t,i){const s=this.actorBodies.get(e.id);K(q,t),null==i?s?.addForce(q,!0):(K(Q,i),s?.addForceAtPoint(q,Q,!0))}applyLocalImpulse(e,t,i){const s=this.actorBodies.get(e.id);K(q,t),null==i?s.applyImpulse(q,!0):(K(Q,i),s.applyImpulseAtPoint(q,Q,!0))}applyRadiusImpulse(e,t,s){this.world.bodies.forEach((o=>{if(o.collider(0)?.isSensor())return;if(o.bodyType()!==i.RigidBodyType.Dynamic)return;const r=U;Y(r,o.translation());const n=r.clone().sub(e);if(n.length()>t)return;const a=n.clone().normalize().multiplyScalar(s);q.x=a.x,q.y=a.y,q.z=a.z,o.applyImpulse(q,!0)}))}removeActor(e){if(null==e)return;this.controlledActors.delete(e.id);const t=this.actorBodies.get(e.id);null!=t&&(this.bodyActors.delete(t),this.world.removeRigidBody(t)),this.actorBodies.delete(e.id)}removeRemoved(e){const t=new Set;e.traverse((e=>{t.add(e.uuid)}));for(const[e,i]of this.staticBodies.entries())!t.has(e.uuid)&&this.world.getRigidBody(i.handle)&&(this.staticBodies.delete(e),this.world.removeRigidBody(i))}removeSceneObject(e){if(e instanceof F){for(const t of e.sections)this.removeSceneObject(t);return}let t=this.staticBodies.get(e);null!=t&&this.world.getRigidBody(t.handle)&&this.world.removeRigidBody(t),this.staticBodies.delete(e)}activateActorEvents(e){this.actorBodies.get(e.id)}_onCollisionWithActorEvent(e,t,i){return this.activateActorEvents(e),this.collisionEvents.pipe(l(e.disposed),n((({started:e})=>e===i)),a((({handle1:e,handle2:t,started:i})=>({a1:this.bodyActors.get(this.world.getCollider(e)?.parent()),a2:this.bodyActors.get(this.world.getCollider(t)?.parent()),started:i}))),n((({a1:i,a2:s})=>null!=i&&null!=s&&i.id===e.id&&t(i,s))),a((({a2:e})=>e)))}onBeginContact(e){return this.activateActorEvents(e),this.collisionEvents.pipe(l(e.disposed),n((e=>e.started)),n((({handle1:t})=>{const i=this.bodyActors.get(this.world.getCollider(t)?.parent());return null!=i&&i.id===e.id})),a((e=>e.handle2)))}onEndContact(e){return this.activateActorEvents(e),this.collisionEvents.pipe(l(e.disposed),n((e=>!e.started)),n((({handle1:t})=>{const i=this.bodyActors.get(this.world.getCollider(t)?.parent());return null!=i&&i.id===e.id})),a((e=>e.handle2)))}onHasContactChanged(e){const t=new Set,i=new o(!1);return this.onBeginContact(e).subscribe((e=>{t.add(e),i.next(t.size>0)})),this.onEndContact(e).subscribe((e=>{t.delete(e),i.next(t.size>0)})),i.pipe(r())}onBeginOverlapWithActorType(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>i instanceof t),!0)}onEndOverlapWithActorType(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>i instanceof t),!1)}onBeginOverlapWithActor(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>t.id===i.id),!0)}onEndOverlapWithActor(e,t){return this._onCollisionWithActorEvent(e,((e,i)=>t.id===i.id),!1)}onCollisionWithActor(e,t){return this.onBeginOverlapWithActor(e,t)}onCollisionWithActorType(e,t){return this.onBeginOverlapWithActorType(e,t)}updateActorTransform(e){const t=this.actorBodies.get(e.id);null!=t?N(t,e.object):console.warn("Actor has not been added to physics world",e)}setupWorld(){const e=new i.World({x:0,y:-9.81,z:0});this.world=e}getActorContacts(e,t){const s=this.actorBodies.get(e.id);if(s&&s.numColliders()>0){const o=s.collider(0);let r=o.shape,n=o.translation(),a=o.rotation(),c=t,l=.3;const d=this.world.castShape(n,a,c,r,.1,l,!0,null,null,null,this.actorBodies.get(e.id),(e=>e.shape.type!=i.ShapeType.HeightField));if(null!=d){const e=new B,t=new B,i=new B;return Y(e,d.witness2),Y(t,d.witness1),Y(i,d.normal1),i.negate(),[{ri:e,rj:t,ni:i}]}return[]}return console.warn("Actor is not added to the physics system"),[]}stop(){this.world?.bodies.forEach((e=>this.world.removeRigidBody(e))),this.world?.free(),this.fixedupdateSub?.unsubscribe()}createStaticBody(e,t,s){const o=s?.type===PhysicsBodyType.dynamic?i.RigidBodyDesc.dynamic():i.RigidBodyDesc.fixed(),r=this.world.createRigidBody(o);for(const i of t){if(null==i){console.warn("Collision shape is missing for object",e);continue}const o=this.addShape(r,i,e);null!=s?.friction&&o.setFriction(s.friction),null!=s?.density&&o.setDensity(s.density),null!=s?.mass&&o.setMass(s.mass/t.length),null!=s?.restitution&&o.setRestitution(s.restitution)}return N(r,e),r.userData=e.uuid,r}addShape(e,t,i){const s=i.getWorldScale(te),o=this.createShape(t,s);null!=t.collisionGroup&&o.setCollisionGroups(t.collisionGroup),o.friction=.1;const r=t.offset.clone().multiply(s);var n,a;K(o.translation,r),n=o.rotation,a=(new w).setFromEuler(t.rotation),n.x=a.x,n.y=a.y,n.z=a.z,n.w=a.w;return this.world.createCollider(o,e)}createShape(e,t){if(e instanceof C)return i.ColliderDesc.cuboid(e.dimensions.x*t.x/2,e.dimensions.y*t.y/2,e.dimensions.z*t.z/2);if(e instanceof D){return i.ColliderDesc.capsule(e.length/2*t.y,e.radius*Math.max(t.z,t.x))}if(e instanceof W){const s=null!=e.geometry.getIndex()?e.geometry:I.mergeVertices(e.geometry),o=new Float32Array(s.getAttribute("position").array);for(let e=0;e<o.length;e+=3)o[e]*=t.x,o[e+1]*=t.y,o[e+2]*=t.z;return i.ColliderDesc.trimesh(o,new Uint32Array(s.getIndex().array))}if(e instanceof R){let s;e.mesh instanceof d.Mesh?s=e.mesh.geometry:e.mesh instanceof d.BufferGeometry?s=e.mesh:console.log("Unknownd shape",{shapeInfo:e});const o=new Float32Array(s.getAttribute("position").array);if(e.mesh instanceof d.Mesh){const t=j(e.mesh);for(let e=0;e<o.length;e+=3)o[e]*=t.x,o[e+1]*=t.y,o[e+2]*=t.z}for(let e=0;e<o.length;e+=3)o[e]*=t.x,o[e+1]*=t.y,o[e+2]*=t.z;const r=o;return i.ColliderDesc.convexHull(r)}if(e instanceof E){const s=2*t.x-t.y-t.z;return Math.abs(s)>.01?this.createShape(new R(new d.SphereGeometry(e.radius).scale(t.x,t.y,t.z)),new B(1,1,1)):i.ColliderDesc.ball(e.radius*Math.max(t.x,t.y,t.z))}return e instanceof S?i.ColliderDesc.cylinder(e.height/2*t.y,e.radiusTop*Math.max(t.z,t.x)):e instanceof z?i.ColliderDesc.cone(e.height*t.y,e.radiusBottom/2*Math.max(t.z,t.x)):e instanceof M?i.ColliderDesc.cuboid(e.width/2*t.x,e.height/2*t.y,.01):(console.error("Unsupported shape",e),i.ColliderDesc.cuboid(1,1,1))}createCharacterCollision(){return new i.CharacterCollision}};P=e([b(),t("design:paramtypes",[V,_])],P);export{P as PhysicsSystem};const k=new B,O=new d.Quaternion;function N(e,t){const s=t.getWorldPosition(k),o=t.getWorldQuaternion(O);e.setTranslation(new i.Vector3(s.x,s.y,s.z),!1),e.setRotation(new i.Quaternion(o.x,o.y,o.z,o.w),!1)}const G=new B,q=new i.Vector3(0,0,0),Q=new i.Vector3(0,0,0),U=new B,H=new d.Vector2,X=async()=>{let e=await import("@dimforge/rapier3d-compat");return await e.init(),e};function K(e,t){e.x=t.x,e.y=t.y,e.z=t.z}function Y(e,t){e.x=t.x,e.y=t.y,e.z=t.z}function Z(e,t){for(let i=0,s=e.numColliders();i<s;i++){t(e.collider(i))}}const J=new B,$=new B,ee=e=>!e.isSensor(),te=new B;/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pointer-events.d.ts","sourceRoot":"","sources":["../../../src/gameplay/services/pointer-events.ts"],"names":[],"mappings":"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"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as e}from"tslib";import{Raycaster as i,Vector2 as o}from"three";import{Service as n}from"typedi";import{ViewController as s}from"./render";import{World as r}from"./world";import{inject as c}from"../../gameplay";import{Subject as h,tap as p,map as a,filter as d,takeUntil as l,withLatestFrom as b,mergeMap as P,merge as u,from as j}from"rxjs";let w=class{constructor(){this.view=c(s),this.world=c(r),this.enabled=!1,this.stopped=new h,this.monitoredObjects=new Map,this.useCache=!1,this.cachePointerPosition=new o,this.pointerPosition=new o,this.adjustedPosition=new o,this.raycastIntersectionResult=[],this.raycaster=new i,this.onClick=new h,this.onDoubleClick=new h,this.onPointerMove=new h,this.onPointerDown=new h,this.onPointerUp=new h,this.onPointerEnterObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),p((t=>{null==t&&(e=!1)})),d((t=>null!=t&&!e)),p((()=>{e=!0})),a((e=>({intersection:e,object:t}))))},this.onPointerEnterActor=t=>this.onPointerEnterObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerEnterActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerEnterActor(t)))),this.onPointerLeaveObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),p((t=>{null!=t&&(e=!1)})),d((t=>null==t&&!e)),p((()=>{e=!0})),a((e=>({intersection:e,object:t}))))},this.onPointerLeaveActor=t=>this.onPointerLeaveObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerLeaveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerLeaveActor(t)))),this.onClickObject3D=t=>{const e=this.onPointerDown.pipe(a((()=>this.findIntersection(t))));return this.onPointerUp.pipe(a((()=>this.findIntersection(t)))).pipe(this.tapMonitorObject(t),b(e),d((([t,e])=>null!=t&&null!=e)),a((([e])=>({intersection:e,object:t}))))},this.onClickActor=t=>this.onClickObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onClickActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onClickActor(t)))),this.onPointerDownActor=t=>this.onPointerDownObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerDownActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerDownActor(t)))),this.onPointerDownObject3D=t=>this.onPointerDown.pipe(this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.onPointerUpActor=t=>this.onPointerUpObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerUpActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerUpActor(t)))),this.onPointerUpObject3D=t=>this.onPointerUp.pipe(this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.onPointerMoveActor=t=>this.onPointerMoveObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerMoveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerMoveActor(t)))),this.onPointerMoveObject3D=t=>this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.usingPointerMoveEvents=!1,this.handlers={click:t=>{this.onClick.next(t)},dblclick:t=>{this.onDoubleClick.next(t)},pointermove:t=>{this.onPointerMove.next(t)},pointerup:t=>{this.onPointerUp.next(t)},pointerdown:t=>{this.onPointerDown.next(t)}},this.raycaster.firstHitOnly=!0}start(){this.enabled||(this.enabled=!0,Object.entries(this.handlers).forEach((([t,e])=>{this.view.htmlElement.addEventListener(t,(i=>{("pointermove"!==t||this.usingPointerMoveEvents)&&(this.updateRaycast(i),e(i))}))})),this.view.onLateUpdate().pipe(l(this.stopped)).subscribe((()=>this.useCache=!1)))}stop(){this.enabled=!1,Object.entries(this.handlers).forEach((([t,e])=>{document.removeEventListener(t,e)})),this.stopped.next(!0),this.onClick.complete(),this.onDoubleClick.complete(),this.onPointerMove.complete(),this.onPointerDown.complete(),this.onPointerUp.complete()}addMonitoredObject(t){const e=this.monitoredObjects.get(t)??0;this.monitoredObjects.set(t,e+1)}removeMonitoriedObject(t){const e=this.monitoredObjects.get(t);null!=e&&(e>1?this.monitoredObjects.set(t,e-1):this.monitoredObjects.delete(t))}updateRaycast(t){this.pointerPosition.set(t.x,t.y),this.useCache&&this.cachePointerPosition.equals(this.pointerPosition)||(this.cachePointerPosition.copy(this.pointerPosition),this.useCache=!0,this.adjustedPosition.x=t.offsetX/this.view.htmlElement.offsetWidth*2-1,this.adjustedPosition.y=-t.offsetY/this.view.htmlElement.offsetHeight*2+1,this.raycaster.setFromCamera(this.adjustedPosition,this.view.getCamera()),this.raycastIntersectionResult.length=0,this.raycaster.intersectObject(this.world.scene,!0,this.raycastIntersectionResult))}tapUsingPointerMove(){return p({subscribe:()=>{this.usingPointerMoveEvents=!0},unsubscribe:()=>{}})}tapMonitorObject(t){return p({subscribe:()=>{this.addMonitoredObject(t)},unsubscribe:()=>{this.removeMonitoriedObject(t)}})}findIntersection(t){if(this.raycastIntersectionResult.length>0){let e=this.raycastIntersectionResult[0].object;for(;null!=e;){if(e.uuid===t.uuid)return this.raycastIntersectionResult[0];e=e.parent}}return null}};w=t([n(),e("design:paramtypes",[])],w);export{w as PointerEvents}
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as e}from"tslib";import{Raycaster as i,Vector2 as o}from"three";import{Service as n}from"typedi";import{ViewController as s}from"./render";import{World as r}from"./world";import{inject as c}from"../../gameplay";import{Subject as h,tap as p,map as a,filter as d,takeUntil as l,withLatestFrom as b,mergeMap as P,merge as u,from as j}from"rxjs";let w=class{constructor(){this.view=c(s),this.world=c(r),this.enabled=!1,this.stopped=new h,this.monitoredObjects=new Map,this.useCache=!1,this.cachePointerPosition=new o,this.pointerPosition=new o,this.adjustedPosition=new o,this.raycastIntersectionResult=[],this.raycaster=new i,this.onClick=new h,this.onDoubleClick=new h,this.onPointerMove=new h,this.onPointerDown=new h,this.onPointerUp=new h,this.onPointerEnterObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),p((t=>{null==t&&(e=!1)})),d((t=>null!=t&&!e)),p((()=>{e=!0})),a((e=>({intersection:e,object:t}))))},this.onPointerEnterActor=t=>this.onPointerEnterObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerEnterActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerEnterActor(t)))),this.onPointerLeaveObject3D=t=>{let e=!1;return this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),p((t=>{null!=t&&(e=!1)})),d((t=>null==t&&!e)),p((()=>{e=!0})),a((e=>({intersection:e,object:t}))))},this.onPointerLeaveActor=t=>this.onPointerLeaveObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerLeaveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerLeaveActor(t)))),this.onClickObject3D=t=>{const e=this.onPointerDown.pipe(a((()=>this.findIntersection(t))));return this.onPointerUp.pipe(a((()=>this.findIntersection(t)))).pipe(this.tapMonitorObject(t),b(e),d((([t,e])=>null!=t&&null!=e)),a((([e])=>({intersection:e,object:t}))))},this.onClickActor=t=>this.onClickObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onClickActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onClickActor(t)))),this.onPointerDownActor=t=>this.onPointerDownObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerDownActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerDownActor(t)))),this.onPointerDownObject3D=t=>this.onPointerDown.pipe(this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.onPointerUpActor=t=>this.onPointerUpObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerUpActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerUpActor(t)))),this.onPointerUpObject3D=t=>this.onPointerUp.pipe(this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.onPointerMoveActor=t=>this.onPointerMoveObject3D(t.object).pipe(l(t.disposed),a((({intersection:e})=>({intersection:e,actor:t})))),this.onPointerMoveActorType=t=>u(j(this.world.actors),this.world.actorAdded).pipe(d((e=>e instanceof t)),P((t=>this.onPointerMoveActor(t)))),this.onPointerMoveObject3D=t=>this.onPointerMove.pipe(this.tapUsingPointerMove(),this.tapMonitorObject(t),a((()=>this.findIntersection(t))),d((t=>null!=t)),a((e=>({intersection:e,object:t})))),this.usingPointerMoveEvents=!1,this.handlers={click:t=>{this.onClick.next(t)},dblclick:t=>{this.onDoubleClick.next(t)},pointermove:t=>{this.onPointerMove.next(t)},pointerup:t=>{this.onPointerUp.next(t)},pointerdown:t=>{this.onPointerDown.next(t)}},this.raycaster.firstHitOnly=!0}start(){this.enabled||(this.enabled=!0,Object.entries(this.handlers).forEach((([t,e])=>{this.view.htmlElement.addEventListener(t,(i=>{("pointermove"!==t||this.usingPointerMoveEvents)&&(this.updateRaycast(i),e(i))}))})),this.view.onLateUpdate().pipe(l(this.stopped)).subscribe((()=>this.useCache=!1)))}stop(){this.enabled=!1,Object.entries(this.handlers).forEach((([t,e])=>{document.removeEventListener(t,e)})),this.stopped.next(!0),this.onClick.complete(),this.onDoubleClick.complete(),this.onPointerMove.complete(),this.onPointerDown.complete(),this.onPointerUp.complete()}addMonitoredObject(t){const e=this.monitoredObjects.get(t)??0;this.monitoredObjects.set(t,e+1)}removeMonitoriedObject(t){const e=this.monitoredObjects.get(t);null!=e&&(e>1?this.monitoredObjects.set(t,e-1):this.monitoredObjects.delete(t))}updateRaycast(t){this.pointerPosition.set(t.x,t.y),this.useCache&&this.cachePointerPosition.equals(this.pointerPosition)||(this.cachePointerPosition.copy(this.pointerPosition),this.useCache=!0,this.adjustedPosition.x=t.offsetX/this.view.htmlElement.offsetWidth*2-1,this.adjustedPosition.y=-t.offsetY/this.view.htmlElement.offsetHeight*2+1,this.raycaster.setFromCamera(this.adjustedPosition,this.view.getCamera()),this.raycastIntersectionResult.length=0,this.raycaster.intersectObject(this.world.scene,!0,this.raycastIntersectionResult))}tapUsingPointerMove(){return p({subscribe:()=>{this.usingPointerMoveEvents=!0},unsubscribe:()=>{}})}tapMonitorObject(t){return p({subscribe:()=>{this.addMonitoredObject(t)},unsubscribe:()=>{this.removeMonitoriedObject(t)}})}findIntersection(t){if(this.raycastIntersectionResult.length>0){let e=this.raycastIntersectionResult[0].object;for(;null!=e;){if(e.uuid===t.uuid)return this.raycastIntersectionResult[0];e=e.parent}}return null}};w=t([n(),e("design:paramtypes",[])],w);export{w as PointerEvents};/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/gameplay/services/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAsB,MAAM,MAAM,CAAA;AACrD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAE1D,qBACa,cAAc;IAKb,OAAO,CAAC,IAAI;IAJxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwB;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,SAAgB,aAAa,sBAA4B;gBAErC,IAAI,EAAE,aAAa;IASvC,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAErB;IAED,IAAI,MAAM,IAJM,MAAM,CAMrB;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAE3B;IACD,IAAI,SAAS,IAHQ,OAAO,CAK3B;IAED,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC;IAO/C,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC;IAOnD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAC,WAAW;IAQpC,SAAS,IAAI,MAAM;IAInB,IAAI,WAAW,gBAEd;IAED,cAAc;IAId,gBAAgB;IAIhB,OAAO;IAKP;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,GAAE,KAAK,CAAC,OAA8B,GAAG,KAAK,CAAC,OAAO,GAAC,IAAI;CAuB7G"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as e}from"tslib";import{Service as i}from"typedi";import{Camera as s}from"three";import{RenderingView as r}from"../../rendering.js";import{Subject as n,takeUntil as o}from"rxjs";import*as a from"three";let h=class{constructor(t){this.view=t,this.tick=new n,this.lateTick=new n,this.audioListener=new a.AudioListener,t.onLoop((t=>{this.tick.next(t),this.lateTick.next(t)})),t.camera.add(this.audioListener),window.hology_view=this}set fpsCap(t){this.view.fpsCap=t}get fpsCap(){return this.view.fpsCap}set showStats(t){this.view.showStats=t}get showStats(){return this.view.showStats}onUpdate(t){return null!=t&&this.tick.pipe(o(t.disposed)),this.tick}onLateUpdate(t){return null!=t&&this.lateTick.pipe(o(t.disposed)),this.lateTick}setCamera(t){const e=t instanceof s?t:t.camera.instance;this.view.setCamera(e),e.add(this.audioListener)}getCamera(){return this.view.camera}get htmlElement(){return this.view.container}pauseRendering(){this.view.paused=!0}unpauseRendering(){this.view.paused=!1}dispose(){this.view.stop(),this.audioListener.removeFromParent()}getScreenPosition(t,e=p){const i=this.getCamera();if(i instanceof a.PerspectiveCamera&&(c.setFromProjectionMatrix(i.projectionMatrix),!c.containsPoint(t)))return null;const s=this.view.container.offsetWidth/2,r=this.view.container.offsetHeight/2;return e.copy(t),e.project(this.getCamera()),e.x=e.x*s+s,e.y=-e.y*r+r,e}};h=t([i(),e("design:paramtypes",[r])],h);export{h as ViewController};const p=new a.Vector3,c=new a.Frustum
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as e}from"tslib";import{Service as i}from"typedi";import{Camera as s}from"three";import{RenderingView as r}from"../../rendering.js";import{Subject as n,takeUntil as o}from"rxjs";import*as a from"three";let h=class{constructor(t){this.view=t,this.tick=new n,this.lateTick=new n,this.audioListener=new a.AudioListener,t.onLoop((t=>{this.tick.next(t),this.lateTick.next(t)})),t.camera.add(this.audioListener),window.hology_view=this}set fpsCap(t){this.view.fpsCap=t}get fpsCap(){return this.view.fpsCap}set showStats(t){this.view.showStats=t}get showStats(){return this.view.showStats}onUpdate(t){return null!=t&&this.tick.pipe(o(t.disposed)),this.tick}onLateUpdate(t){return null!=t&&this.lateTick.pipe(o(t.disposed)),this.lateTick}setCamera(t){const e=t instanceof s?t:t.camera.instance;this.view.setCamera(e),e.add(this.audioListener)}getCamera(){return this.view.camera}get htmlElement(){return this.view.container}pauseRendering(){this.view.paused=!0}unpauseRendering(){this.view.paused=!1}dispose(){this.view.stop(),this.audioListener.removeFromParent()}getScreenPosition(t,e=p){const i=this.getCamera();if(i instanceof a.PerspectiveCamera&&(c.setFromProjectionMatrix(i.projectionMatrix),!c.containsPoint(t)))return null;const s=this.view.container.offsetWidth/2,r=this.view.container.offsetHeight/2;return e.copy(t),e.project(this.getCamera()),e.x=e.x*s+s,e.y=-e.y*r+r,e}};h=t([i(),e("design:paramtypes",[r])],h);export{h as ViewController};const p=new a.Vector3,c=new a.Frustum;/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../../src/gameplay/services/world.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,cAAM,0BAA0B;IAClB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAIvC;;;OAGG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,EAG1B;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAAI,OAAO,CAKtB;CAEF;AAED,qBACa,KAAK;IAOJ,OAAO,CAAC,YAAY;IAAgB,OAAO,CAAC,IAAI;IAN5D,SAAgB,MAAM,EAAE,SAAS,EAAE,CAAK;IACxC,SAAgB,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,CAAgB;IACjE,SAAgB,YAAY,EAAE,UAAU,CAAC,SAAS,CAAC,CAAgB;IAC5D,KAAK,EAAE,KAAK,CAAA;IACnB,SAAgB,gBAAgB,6BAA4C;gBAExD,YAAY,EAAE,YAAY,EAAU,IAAI,EAAE,aAAa;IAE9D,UAAU,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;IAM/G,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,KAAK;IAa/D,WAAW,CAAC,KAAK,EAAE,SAAS;IAS5B,eAAe,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC;IAI9E,gBAAgB,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE;CAGzF"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as i}from"tslib";import{Service as e}from"typedi";import{ActorFactory as s}from"../actors/factory.js";import{Vector3 as o}from"three";import{ActorComponent as r}from"../../gameplay/actors/component.js";import{Subject as n}from"rxjs";import{RenderingView as c}from"../../rendering.js";const a=new o;class h{constructor(t){this.view=t}get direction(){return this.view.csm.lightDirection}set intensity(t){this.view.csm.lightIntensity=t,this.view.csm.lights.forEach((t=>t.intensity=this.view.csm.lightIntensity))}get intensity(){return this.view.csm.lightIntensity}get position(){return 0==this.view.csm.lights.length?a:this.view.csm.lights[0].position}}let m=class{constructor(t,i){this.actorFactory=t,this.view=i,this.actors=[],this.actorAdded=new n,this.actorRemoved=new n,this.directionalLight=new h(this.view)}async spawnActor(t,i,e){const s=await this.actorFactory.create(t,i,e);return this.addActor(s,i,e),s}addActor(t,i,e){i&&t.object.position.copy(i),e&&t.object.rotation.copy(e),this.scene.add(t.object),this.actors.push(t),d(t,(t=>t.onBeginPlay())),this.actorAdded.next(t)}removeActor(t){d(t,(t=>t.onEndPlay()));const i=this.actors.indexOf(t);i>=0&&this.actors.splice(i,1),this.scene.remove(t.object),t.disposed.next(!0),this.actorRemoved.next(t)}findActorByType(t,i){return this.actors.find((e=>e instanceof t&&(null==i||e.object.name==i)))}findActorsByType(t,i){return this.actors.filter((e=>e instanceof t&&(null==i||e.object.name==i)))}};m=t([e(),i("design:paramtypes",[s,c])],m);export{m as World};function d(t,i){return i(t),Object.entries(t).filter((([t,i])=>i instanceof r)).forEach((([t,e])=>{d(e,i)}))}
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as i}from"tslib";import{Service as e}from"typedi";import{ActorFactory as s}from"../actors/factory.js";import{Vector3 as o}from"three";import{ActorComponent as r}from"../../gameplay/actors/component.js";import{Subject as n}from"rxjs";import{RenderingView as c}from"../../rendering.js";const a=new o;class h{constructor(t){this.view=t}get direction(){return this.view.csm.lightDirection}set intensity(t){this.view.csm.lightIntensity=t,this.view.csm.lights.forEach((t=>t.intensity=this.view.csm.lightIntensity))}get intensity(){return this.view.csm.lightIntensity}get position(){return 0==this.view.csm.lights.length?a:this.view.csm.lights[0].position}}let m=class{constructor(t,i){this.actorFactory=t,this.view=i,this.actors=[],this.actorAdded=new n,this.actorRemoved=new n,this.directionalLight=new h(this.view)}async spawnActor(t,i,e){const s=await this.actorFactory.create(t,i,e);return this.addActor(s,i,e),s}addActor(t,i,e){i&&t.object.position.copy(i),e&&t.object.rotation.copy(e),this.scene.add(t.object),this.actors.push(t),d(t,(t=>t.onBeginPlay())),this.actorAdded.next(t)}removeActor(t){d(t,(t=>t.onEndPlay()));const i=this.actors.indexOf(t);i>=0&&this.actors.splice(i,1),this.scene.remove(t.object),t.disposed.next(!0),this.actorRemoved.next(t)}findActorByType(t,i){return this.actors.find((e=>e instanceof t&&(null==i||e.object.name==i)))}findActorsByType(t,i){return this.actors.filter((e=>e instanceof t&&(null==i||e.object.name==i)))}};m=t([e(),i("design:paramtypes",[s,c])],m);export{m as World};function d(t,i){return i(t),Object.entries(t).filter((([t,i])=>i instanceof r)).forEach((([t,e])=>{d(e,i)}))}/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
package/dist/index.d.ts
CHANGED
@@ -3,3 +3,4 @@ export { BaseGameController } from './controllers/base-game-controller.js';
|
|
3
3
|
export * from './scene/collision/collision-shape.js';
|
4
4
|
export { AssetMeshInstance } from './scene/asset-resource-loader.js';
|
5
5
|
export { registerWorker, initWorker } from './worker';
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|