@hology/core 0.0.91 → 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 +1 -0
- package/dist/gameplay/services/physics/abstract-physics-system.d.ts.map +1 -0
- package/dist/gameplay/services/physics/abstract-physics-system.js +1 -2
- 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 +1 -0
- 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":"character-movement.d.ts","sourceRoot":"","sources":["../../../../../../src/gameplay/actors/builtin/components/character/character-movement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAiB,MAAM,4DAA4D,CAAC;AAC1G,OAAO,EAAoB,OAAO,EAAwB,eAAe,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,cAAc,EAAa,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAkBnD,qBACa,0BAA2B,SAAQ,cAAc;IA0D9C,OAAO,CAAC,aAAa;IAvDjC,QAAQ,CAAC,cAAc,YAAkB;IACzC,QAAQ,CAAC,SAAS,cAAoB;IACtC,QAAQ,CAAC,WAAW,cAAoB;IACxC,QAAQ,CAAC,aAAa,gBAAsB;IAGrC,eAAe,SAAI;IAGnB,QAAQ,SAAI;IACZ,iBAAiB,SAAI;IACrB,cAAc,SAAK;IACnB,YAAY,SAAI;IAChB,sBAAsB,SAAK;IAC3B,oBAAoB,UAAQ;IAC5B,eAAe,EAAE,MAAM,CAAO;IAC9B,cAAc,EAAE,MAAM,CAAI;IAC1B,cAAc,EAAE,MAAM,CAAK;IAC3B,SAAS,UAAQ;IACjB,IAAI,SAAK;IACT,YAAY,UAAO;IACnB,kBAAkB,SAAyB;IAC3C,kBAAkB,SAAyB;IAC3C,4BAA4B,UAAO;IAC1C,oCAAoC;IAC7B,kBAAkB,UAAQ;IACjC,IAAW,gBAAgB,IACW,MAAM,CADuB;IACnE,IAAW,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAA4G;IACxJ,IAAW,sBAAsB,IAAI,OAAO,CAAmD;IAC/F,IAAW,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAA8F;IAChJ,IAAW,iBAAiB,IACY,MAAM,CADuB;IACrE,IAAW,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAA4G;IAC1J,IAAW,YAAY,IACW,MAAM,CAD2B;IACnE,IAAW,YAAY,CAAC,QAAQ,EAAE,MAAM,EAA0C;IAClF,IAAW,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAiC;IACnE,IAAW,MAAM,IADW,MAAM,CACa;IAC/C,IAAW,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAA0C;IACrF,IAAW,iBAAiB,IADS,MAAM,CAC0B;IAErE;;;;OAIG;IACI,OAAO,UAAO;IAGrB,QAAQ,CAAC,QAAQ,UAAgB;IACjC,IAAI,wBAAgC;IACpC,WAAW,UAAQ;IACnB,WAAW,UAAQ;IAEnB,OAAO,CAAC,EAAE,CAAqC;IAC/C,OAAO,CAAC,aAAa,CAAsB;gBAEvB,aAAa,EAAE,aAAa;IAOhD,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,qBAAqB,CAAwB;IAErD;;;OAGG;IACI,yBAAyB,UAAQ;IAExC,mEAAmE;IAC5D,cAAc,UAAO;IAE5B,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA4R9B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,gBAAgB,CAAiB;IAClC,mBAAmB,CAAC,MAAM,EAAE,eAAe;IAUlD,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,MAAM;IAKP,mBAAmB;IAI1B,OAAO,CAAC,aAAa;IAkBrB,IAAW,UAAU,YAEpB;IAED,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,IAAI;IA8BZ,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,WAAW;CAQtB"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as i}from"tslib";import{ActionInput as e,AxisInput as o,RotationInput as s}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as n,RayTestResult as r}from"../../../../../gameplay/services/physics/physics-system.js";import{MathUtils as a,Vector3 as c,ArrowHelper as l}from"three";import{ActorComponent as h,Component as p}from"../../../component.js";import{CharacterMovementMode as m}from"./modes.js";import{CapsuleCollisionShape as d}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as u}from"rxjs";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import g from"@dimforge/rapier3d-compat";import{RootMotionClip as f}from"../../../../../gameplay/animation/root-motion.js";import*as S from"three";import{clamp as w}from"../../../../../utils/math.js";const v=new c,M=new c,A=1/30,x=-131071;let I=class extends h{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(t){super(),this.physicsSystem=t,this.directionInput=new o,this.jumpInput=new e,this.sprintInput=new e,this.rotationInput=new s,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=a.degToRad(70),this.maxSlopeClimbAngle=a.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.characterCollision=!1,this.enabled=!0,this.velocity=new c,this.mode=m.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new r,this.resetRootMotion=!1,this.rotateToMovementDirection=!1,this.smoothRotation=!0;const i=this.cc=this.physicsSystem.getCharacterController(.1);i.enableSnapToGround(.1),i.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:y.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation);let i=this.rotationInput.rotation.y;const e=new c,o=new c,s=new c,n=new c(0,0,1),r=new c,l=new c,h=new c;let p=0,d=null;const g=new c,I=new c,C=new c,j=new c,R=this.characterCollision?null:x;this.physicsSystem.beforeStep.pipe(u(this.disposed)).subscribe((u=>{if(this.checkGrounded(u),!this.enabled)return;if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof f){const t=this.rootMotionInterpolant;this.resetRootMotion&&(g.fromArray(t.evaluate(0)),this.resetRootMotion=!1),j.fromArray(t.evaluate(this.rootMotionAction.time)),I.subVectors(j,g),g.copy(j),this.rootMotionAction.getRoot().getWorldScale(C),I.multiply(C)}}u>A&&(u=A);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=I.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;let x=this.rotationInput.rotation.y-i;s.copy(this.actor.position),r.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const G=!this.rotateToMovementDirection&&r.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed;if(h.set(0,0,0),this.rotateToMovementDirection){if(r.lengthSq()>0){z.setFromUnitVectors(n.clone().normalize(),r.clone().normalize()),n.copy(r);const t=(x%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,e=Math.abs(t),o=this.smoothRotation?w(10*u*t,-e,e):t;k.setFromEuler(F.set(0,o,0)),z.multiply(k),this.actor.object.applyQuaternion(z),h.copy(this.actor.object.getWorldDirection(H).normalize()),i+=o}}else h.copy(r).applyAxisAngle(b,this.rotationInput.rotation.y),i=this.rotationInput.rotation.y,this.actor.rotation.y+=x;if(this.mode===m.walking?(0!==h.length()?(p=Math.min(G,p),p=a.lerp(p,G,4*u)):p=0,l.copy(h).multiplyScalar(p),this.pressedJump&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),l.y=.016*this.getEffectiveGravity()):this.mode===m.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),this.velocity.y+=u*this.getEffectiveGravity(),l.copy(this.velocity),l.add(h.clone().multiplyScalar(G*this.fallingMovementControl*u)),this.fallingReorientation&&l.applyAxisAngle(new c(0,1,0),x)),o.copy(l).normalize(),e.copy(l),l.length(),y?(I.applyAxisAngle(b,this.actor.rotation.y),I.y+=u*this.getEffectiveGravity(),v.copy(I)):v.copy(l).multiplyScalar(u),this.isGrounded&&this.mode===m.walking&&(this.rayTestResult.distance>t.offset()||(v.y=0),this.physicsSystem.getActorComputedMovement(this.actor,t,v,R),t.computedCollision(0,D),null!=D&&null!=D.normal1)){const i=(new S.Vector3).copy(D.normal1);Math.acos(i.dot(b))>t.maxSlopeClimbAngle()&&(v.y=.016*this.getEffectiveGravity()*.5)}M.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,v,R)),this.physicsSystem.setNextKinematicTranslation(this.actor,M);let E=function(t){if(t.numComputedCollisions()>0){const i=t.computedCollision(0);T.x=i.normal2.x,T.y=i.normal2.y,T.z=i.normal2.z;const e=T.angleTo(b);T.x=i.normal1.x,T.y=i.normal1.y,T.z=i.normal1.z;const o=T.angleTo(b);return!(e<100)&&o>t.minSlopeSlideAngle()}return!1}(t);y||this.isGrounded&&!E||this.mode!==m.falling&&(null==d?d=performance.now():performance.now()-d>100&&(this.mode=m.falling,this.velocity.copy(e))),this.isGrounded&&this.velocity.y<=0&&(this.mode,m.falling,this.mode=m.walking,this.velocity.y=0,d=null),this.mode,m.walking,this.horizontalSpeed=p}))}debugDirection(){const t=new l(v,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout((()=>{t.removeFromParent()}),30);const i=new l(M,this.actor.position,1,16711680);this.actor.object.parent.add(i),setTimeout((()=>{i.removeFromParent()}),30)}setRootMotionAction(t){const i=t?.getClip();if(i instanceof f){this.rootMotionAction=t,this.resetRootMotion=!0;const e=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(e)}}getWallDirection(t,i){const e=t.clone().negate().cross(b);return e.dot(i)<0?e.negate():e}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}checkGrounded(t){this.colliderHeight,this.colliderRadius;G.y=-.05,this.physicsSystem.rayTest(C.addVectors(this.actor.position,R.set(0,this.offset,0)),j.addVectors(this.actor.position,G),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new d(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=x,t}step(t){}performMovement(t){}arrowHelper(t,i,e){const o=new l(t,i,1,e);this.actor.object.parent.add(o),setTimeout((()=>{o.removeFromParent()}),30)}};I=t([p({inEditor:!1}),i("design:paramtypes",[n])],I);export{I as CharacterMovementComponent};const b=new c(0,1,0),T=new c;const C=new c,j=new c,R=new c(0,1,0),G=new c(0,-.1,0),D=(new c(0,-1,0),new g.CharacterCollision),z=new S.Quaternion,k=new S.Quaternion,F=new S.Euler,H=new S.Vector3
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as i}from"tslib";import{ActionInput as e,AxisInput as o,RotationInput as s}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as n,RayTestResult as r}from"../../../../../gameplay/services/physics/physics-system.js";import{MathUtils as a,Vector3 as c,ArrowHelper as l}from"three";import{ActorComponent as h,Component as p}from"../../../component.js";import{CharacterMovementMode as m}from"./modes.js";import{CapsuleCollisionShape as d}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as u}from"rxjs";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import g from"@dimforge/rapier3d-compat";import{RootMotionClip as f}from"../../../../../gameplay/animation/root-motion.js";import*as S from"three";import{clamp as w}from"../../../../../utils/math.js";const v=new c,M=new c,A=1/30,x=-131071;let I=class extends h{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(t){super(),this.physicsSystem=t,this.directionInput=new o,this.jumpInput=new e,this.sprintInput=new e,this.rotationInput=new s,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=a.degToRad(70),this.maxSlopeClimbAngle=a.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.characterCollision=!1,this.enabled=!0,this.velocity=new c,this.mode=m.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new r,this.resetRootMotion=!1,this.rotateToMovementDirection=!1,this.smoothRotation=!0;const i=this.cc=this.physicsSystem.getCharacterController(.1);i.enableSnapToGround(.1),i.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:y.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation);let i=this.rotationInput.rotation.y;const e=new c,o=new c,s=new c,n=new c(0,0,1),r=new c,l=new c,h=new c;let p=0,d=null;const g=new c,I=new c,C=new c,j=new c,R=this.characterCollision?null:x;this.physicsSystem.beforeStep.pipe(u(this.disposed)).subscribe((u=>{if(this.checkGrounded(u),!this.enabled)return;if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof f){const t=this.rootMotionInterpolant;this.resetRootMotion&&(g.fromArray(t.evaluate(0)),this.resetRootMotion=!1),j.fromArray(t.evaluate(this.rootMotionAction.time)),I.subVectors(j,g),g.copy(j),this.rootMotionAction.getRoot().getWorldScale(C),I.multiply(C)}}u>A&&(u=A);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=I.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;let x=this.rotationInput.rotation.y-i;s.copy(this.actor.position),r.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const G=!this.rotateToMovementDirection&&r.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed;if(h.set(0,0,0),this.rotateToMovementDirection){if(r.lengthSq()>0){z.setFromUnitVectors(n.clone().normalize(),r.clone().normalize()),n.copy(r);const t=(x%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,e=Math.abs(t),o=this.smoothRotation?w(10*u*t,-e,e):t;k.setFromEuler(F.set(0,o,0)),z.multiply(k),this.actor.object.applyQuaternion(z),h.copy(this.actor.object.getWorldDirection(H).normalize()),i+=o}}else h.copy(r).applyAxisAngle(b,this.rotationInput.rotation.y),i=this.rotationInput.rotation.y,this.actor.rotation.y+=x;if(this.mode===m.walking?(0!==h.length()?(p=Math.min(G,p),p=a.lerp(p,G,4*u)):p=0,l.copy(h).multiplyScalar(p),this.pressedJump&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),l.y=.016*this.getEffectiveGravity()):this.mode===m.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),this.velocity.y+=u*this.getEffectiveGravity(),l.copy(this.velocity),l.add(h.clone().multiplyScalar(G*this.fallingMovementControl*u)),this.fallingReorientation&&l.applyAxisAngle(new c(0,1,0),x)),o.copy(l).normalize(),e.copy(l),l.length(),y?(I.applyAxisAngle(b,this.actor.rotation.y),I.y+=u*this.getEffectiveGravity(),v.copy(I)):v.copy(l).multiplyScalar(u),this.isGrounded&&this.mode===m.walking&&(this.rayTestResult.distance>t.offset()||(v.y=0),this.physicsSystem.getActorComputedMovement(this.actor,t,v,R),t.computedCollision(0,D),null!=D&&null!=D.normal1)){const i=(new S.Vector3).copy(D.normal1);Math.acos(i.dot(b))>t.maxSlopeClimbAngle()&&(v.y=.016*this.getEffectiveGravity()*.5)}M.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,v,R)),this.physicsSystem.setNextKinematicTranslation(this.actor,M);let E=function(t){if(t.numComputedCollisions()>0){const i=t.computedCollision(0);T.x=i.normal2.x,T.y=i.normal2.y,T.z=i.normal2.z;const e=T.angleTo(b);T.x=i.normal1.x,T.y=i.normal1.y,T.z=i.normal1.z;const o=T.angleTo(b);return!(e<100)&&o>t.minSlopeSlideAngle()}return!1}(t);y||this.isGrounded&&!E||this.mode!==m.falling&&(null==d?d=performance.now():performance.now()-d>100&&(this.mode=m.falling,this.velocity.copy(e))),this.isGrounded&&this.velocity.y<=0&&(this.mode,m.falling,this.mode=m.walking,this.velocity.y=0,d=null),this.mode,m.walking,this.horizontalSpeed=p}))}debugDirection(){const t=new l(v,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout((()=>{t.removeFromParent()}),30);const i=new l(M,this.actor.position,1,16711680);this.actor.object.parent.add(i),setTimeout((()=>{i.removeFromParent()}),30)}setRootMotionAction(t){const i=t?.getClip();if(i instanceof f){this.rootMotionAction=t,this.resetRootMotion=!0;const e=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(e)}}getWallDirection(t,i){const e=t.clone().negate().cross(b);return e.dot(i)<0?e.negate():e}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}checkGrounded(t){this.colliderHeight,this.colliderRadius;G.y=-.05,this.physicsSystem.rayTest(C.addVectors(this.actor.position,R.set(0,this.offset,0)),j.addVectors(this.actor.position,G),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new d(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=x,t}step(t){}performMovement(t){}arrowHelper(t,i,e){const o=new l(t,i,1,e);this.actor.object.parent.add(o),setTimeout((()=>{o.removeFromParent()}),30)}};I=t([p({inEditor:!1}),i("design:paramtypes",[n])],I);export{I as CharacterMovementComponent};const b=new c(0,1,0),T=new c;const C=new c,j=new c,R=new c(0,1,0),G=new c(0,-.1,0),D=(new c(0,-1,0),new g.CharacterCollision),z=new S.Quaternion,k=new S.Quaternion,F=new S.Euler,H=new S.Vector3;/*
|
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":"modes.d.ts","sourceRoot":"","sources":["../../../../../../src/gameplay/actors/builtin/components/character/modes.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;GAWG;AAEH,oBAAY,qBAAqB;IAC7B,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,MAAM,IAAA;CACT"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
export var CharacterMovementMode;!function(e){e[e.walking=0]="walking",e[e.swimming=1]="swimming",e[e.falling=2]="falling",e[e.flying=3]="flying"}(CharacterMovementMode||(CharacterMovementMode={}))
|
2
|
-
/*
|
1
|
+
export var CharacterMovementMode;!function(e){e[e.walking=0]="walking",e[e.swimming=1]="swimming",e[e.falling=2]="falling",e[e.flying=3]="flying"}(CharacterMovementMode||(CharacterMovementMode={}));/*
|
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":"mesh-component.d.ts","sourceRoot":"","sources":["../../../../../src/gameplay/actors/builtin/components/mesh-component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACd,MAAM,yDAAyD,CAAA;AAIhE,OAAO,EAAE,KAAK,EAAQ,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,cAAc,EAAa,MAAM,oBAAoB,CAAA;AAU9D,qBACa,aAAa,CAAC,IAAI,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,cAAc;IAkCrE,OAAO,CAAC,aAAa;IA9BjC,MAAM,EAAE,IAAI,CAAA;IAGZ,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAgB;IAG1C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAc;IAGtC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAqB;IAG5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAA6B;IAGlD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAiC;IAM1D,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAyB;IAG3D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAQ;IAEnC,QAAQ,CAAC,2BAA2B,EAAE,OAAO,CAAoD;IAEjG,OAAO,CAAC,WAAW,CAAM;gBAEL,aAAa,EAAE,aAAa;IAIhD,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAUvB,SAAS,CAAC,WAAW,EAAE,IAAI;IAQlC,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,kBAAkB;CAc3B"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as s}from"tslib";import{PhysicsBodyType as i,PhysicsSystem as e}from"../../../../gameplay/services/physics/physics-system.js";import{AssetMeshInstance as o}from"../../../../scene/asset-resource-loader.js";import{PhysicalShapeMesh as r}from"../../../../index.js";import{Parameter as n}from"../../../../shader/parameter.js";import{Euler as c,Object3D as h,Vector3 as p}from"three";import{ActorComponent as a,Component as l}from"../../component.js";import{firstValueFrom as y}from"rxjs";const m={friction:.1,mass:0,bodyType:i.static,continousCollisionDetection:!1};let d=class extends a{constructor(t){super(),this.physicsSystem=t,this.position=new p,this.rotation=new c,this.scale=new p(1,1,1),this.mass=m.mass,this.friction=m.friction,this.bodyType=i.static,this.isTrigger=!1,this.continousCollisionDetection=m.continousCollisionDetection}onInit(){null!=this.object&&(this.currentMesh=this.object,this.updateMesh()),y(this.disposed).then((()=>{this.physicsSystem.removeActor(this.actor)}))}setObject(t){null!=this.currentMesh&&this.actor.object.remove(this.currentMesh),this.object=this.currentMesh=t,this.updateMesh()}updateMesh(){this.currentMesh.position.copy(this.position),this.currentMesh.rotation.copy(this.rotation),this.currentMesh.scale.copy(this.scale);const t=this.getCollisionShapes();t.length>0&&this.physicsSystem.addActor(this.actor,t,{...m,isTrigger:this.isTrigger??!1,mass:this.mass,friction:this.friction,type:this.bodyType,continousCollisionDetection:this.continousCollisionDetection}),this.actor.object.add(this.currentMesh)}getCollisionShapes(){return this.currentMesh instanceof o?this.currentMesh.collisionShapes:this.currentMesh instanceof r?[this.currentMesh.collisionShape]:"collisionShape"in this.currentMesh?(console.error("Could not understand wehre to get collision shapes from. This is likely due to an import issue"),[this.currentMesh.collisionShape]):[]}};t([n({type:h}),s("design:type",Object)],d.prototype,"object",void 0),t([n(),s("design:type",p)],d.prototype,"position",void 0),t([n(),s("design:type",c)],d.prototype,"rotation",void 0),t([n(),s("design:type",p)],d.prototype,"scale",void 0),t([n(),s("design:type",Number)],d.prototype,"mass",void 0),t([n(),s("design:type",Number)],d.prototype,"friction",void 0),t([n({options:[{name:"Static",value:i.static},{name:"Dynamic",value:i.dynamic}]}),s("design:type",Number)],d.prototype,"bodyType",void 0),t([n(),s("design:type",Boolean)],d.prototype,"isTrigger",void 0),d=t([l({inEditor:!0}),s("design:paramtypes",[e])],d);export{d as MeshComponent}
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as s}from"tslib";import{PhysicsBodyType as i,PhysicsSystem as e}from"../../../../gameplay/services/physics/physics-system.js";import{AssetMeshInstance as o}from"../../../../scene/asset-resource-loader.js";import{PhysicalShapeMesh as r}from"../../../../index.js";import{Parameter as n}from"../../../../shader/parameter.js";import{Euler as c,Object3D as h,Vector3 as p}from"three";import{ActorComponent as a,Component as l}from"../../component.js";import{firstValueFrom as y}from"rxjs";const m={friction:.1,mass:0,bodyType:i.static,continousCollisionDetection:!1};let d=class extends a{constructor(t){super(),this.physicsSystem=t,this.position=new p,this.rotation=new c,this.scale=new p(1,1,1),this.mass=m.mass,this.friction=m.friction,this.bodyType=i.static,this.isTrigger=!1,this.continousCollisionDetection=m.continousCollisionDetection}onInit(){null!=this.object&&(this.currentMesh=this.object,this.updateMesh()),y(this.disposed).then((()=>{this.physicsSystem.removeActor(this.actor)}))}setObject(t){null!=this.currentMesh&&this.actor.object.remove(this.currentMesh),this.object=this.currentMesh=t,this.updateMesh()}updateMesh(){this.currentMesh.position.copy(this.position),this.currentMesh.rotation.copy(this.rotation),this.currentMesh.scale.copy(this.scale);const t=this.getCollisionShapes();t.length>0&&this.physicsSystem.addActor(this.actor,t,{...m,isTrigger:this.isTrigger??!1,mass:this.mass,friction:this.friction,type:this.bodyType,continousCollisionDetection:this.continousCollisionDetection}),this.actor.object.add(this.currentMesh)}getCollisionShapes(){return this.currentMesh instanceof o?this.currentMesh.collisionShapes:this.currentMesh instanceof r?[this.currentMesh.collisionShape]:"collisionShape"in this.currentMesh?(console.error("Could not understand wehre to get collision shapes from. This is likely due to an import issue"),[this.currentMesh.collisionShape]):[]}};t([n({type:h}),s("design:type",Object)],d.prototype,"object",void 0),t([n(),s("design:type",p)],d.prototype,"position",void 0),t([n(),s("design:type",c)],d.prototype,"rotation",void 0),t([n(),s("design:type",p)],d.prototype,"scale",void 0),t([n(),s("design:type",Number)],d.prototype,"mass",void 0),t([n(),s("design:type",Number)],d.prototype,"friction",void 0),t([n({options:[{name:"Static",value:i.static},{name:"Dynamic",value:i.dynamic}]}),s("design:type",Number)],d.prototype,"bodyType",void 0),t([n(),s("design:type",Boolean)],d.prototype,"isTrigger",void 0),d=t([l({inEditor:!0}),s("design:paramtypes",[e])],d);export{d as MeshComponent};/*
|
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":"scene-component.d.ts","sourceRoot":"","sources":["../../../../../src/gameplay/actors/builtin/components/scene-component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAa,MAAM,oBAAoB,CAAC;AAG/D,qBACa,cAAe,SAAQ,cAAc;IAChD,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,OAAO,CAAgB;IAC/B,IAAW,MAAM,CAAC,MAAM,EAAE,cAAc,EAGvC;IACD,IAAW,MAAM,IAJS,cAAc,CAIG;CAC5C"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{Group as r}from"three";import{ActorComponent as e,Component as n}from"../../component.js";let o=class extends e{constructor(){super(...arguments),this.container=new r}set parent(t){this._parent=t,t.container.add(this.container)}get parent(){return this._parent}};o=t([n()],o);export{o as SceneComponent}
|
2
|
-
/*
|
1
|
+
import{__decorate as t}from"tslib";import{Group as r}from"three";import{ActorComponent as e,Component as n}from"../../component.js";let o=class extends e{constructor(){super(...arguments),this.container=new r}set parent(t){this._parent=t,t.container.add(this.container)}get parent(){return this._parent}};o=t([n()],o);export{o as SceneComponent};/*
|
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":"index.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;;;;;;;;AAEpD,wBAMC"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{CameraActor as o}from"./camera-actor.js";import r from"./navmesh-actor.js";import{PositionalAudioActor as a}from"./positional-audio-actor.js";import{SpawnPoint as i}from"./spawn-point.js";import{TriggerVolume as m}from"./trigger-volume.js";export default{Camera:o,SpawnPoint:i,TriggerVolume:m,PositionalAudio:a,NavMesh:r}
|
2
|
-
/*
|
1
|
+
import{CameraActor as o}from"./camera-actor.js";import r from"./navmesh-actor.js";import{PositionalAudioActor as a}from"./positional-audio-actor.js";import{SpawnPoint as i}from"./spawn-point.js";import{TriggerVolume as m}from"./trigger-volume.js";export default{Camera:o,SpawnPoint:i,TriggerVolume:m,PositionalAudio:a,NavMesh:r};/*
|
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":"navmesh-actor.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/navmesh-actor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK5C,OAAO,EAAS,SAAS,EAA2D,MAAM,QAAQ,CAAC;AAcnG,wBAAsB,cAAc,4BASnC;AASD,MAAM,MAAM,aAAa,GAAG;IAO1B,IAAI,QAAE;CACP,CAAA;AAGD,cACM,YAAa,SAAQ,SAAS;IAClC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,KAAK,CAAgB;IAEhB,KAAK,EAAE,OAAO,CAAO;IAElC,SAAS,EAAE,MAAM,CAAO;IAIxB,OAAO,CAAC,QAAQ,CAAc;IAIjB,aAAa,EAAE,MAAM,CAAK;IACV,kBAAkB,EAAE,MAAM,CAAK;IAI/C,QAAQ,EAAE,MAAM,CAAM;IAG5B,OAAO,EAAE,OAAO,CAAA;IAEjB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAY7B,OAAO,CAAC,IAAI;CA4Ob;AAED,eAAe,YAAY,CAAA"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as e,__metadata as t}from"tslib";import{Ball as o,Capsule as n,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as c,ShapeType as l,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as f,debounceTime as m,filter as w,firstValueFrom as g,takeUntil as b}from"rxjs";import*as y from"three";import{BufferGeometryUtils as x,ConvexHull as v}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as M,Parameter as S,PhysicsSystem as z,ViewController as j,World as k,inject as A}from"../../";import{DynamicTiledNavMesh as C}from"../../ai/dynamic-tiled-navmesh";import{hasSharedArrayBufferSupport as F,toSharedFloat32Array as G,toSharedUint32Array as P}from"../../../utils/buffer";import{sleepDelay as N}from"../../../utils/async";var V;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(V||(V={}));let D=V.none,I=new f(!1);export async function safeRecastInit(){return D===V.none?(D=V.starting,p().then((()=>{I.next(!0),D=V.started}))):g(I.pipe(w((e=>e))))}const E=new y.Box3(new y.Vector3(-100,-100,-100),new y.Vector3(100,100,100)),H=navigator.hardwareConcurrency??1;let R=!1,T=class extends M{constructor(){super(...arguments),this.physics=A(z),this.view=A(j),this.world=A(k),this.debug=!0,this.refreshMs=4e3,this.tileSize=400,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.cellSize=.2}async onInit(){R||(await safeRecastInit(),R=!0),setTimeout((()=>{this.init()}),1e3)}init(){const e=this.cellSize,t={tileSize:400,walkableClimb:this.walkableClimb/e,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:5,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:e,ch:e,maxSimplificationError:1.3,maxEdgeLen:200},o=new y.Box3;for(const e of this.physics.staticBodies.keys())e.traverse((t=>{t.isMesh&&t.geometry&&(t.geometry.computeBoundingBox(),o.expandByObject(e))}));o.union(E);const n=new C({navMeshBounds:o,recastConfig:t,maxTiles:1024,workers:H,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=n.navMesh,this.object.position.set(0,0,0);const s=this.tileSize*t.cs*2,i=performance.now(),r=new Map,a=new u;a.userData.isDebugDrawer=!0;n.navMesh;const c=()=>{const e=this.view.getCamera().getWorldPosition(new y.Vector3),t=new y.Box3((new y.Vector3).copy(e).subScalar(s),(new y.Vector3).copy(e).addScalar(s)),o=[],n=this.physics.world.bodies;if(null==n)return[];const i=new y.Box3;for(const e of n.getAll())for(let n=0,s=e.numColliders();n<s;n++){const s=e.collider(n);if(s.isSensor()||null!=s.parent().userData&&!0===s.parent().userData.ignoreForNavMesh)continue;const a=e.handle+","+n,c=r.get(a)?.mesh,l=c??U(s);if(q(s,l),null!=l){i.copy(l.geometry.boundingBox),i.min.add(l.position),i.max.add(l.position);const e=i.intersectsBox(t)||!0;r.set(a,{pos:s.translation(),mesh:l}),e&&o.push(l)}}return o},l=new y.Box3,h=new Map,p=new Map;let f=!0,w=performance.now(),g=!1;const x=function(e,t){let o=!1;return(async()=>{for(;!o;)await e(),await N(t)})(),()=>{o=!0}}((async()=>{if(g)return;const e=new y.Box3,t=c();for(const o of t){const t=h.get(o);!0!==t?.equals(o.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(o),h.set(o,o.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const o=n.getTilesForBounds(e);if(0!=o.length){const s=[];for(const o of t)l.setFromObject(o),l.intersectsBox(e)&&s.push(o);console.log("intersecting meshes",s.length),console.time("get positions");let[i,r]=d(s);F&&(i=G(i),r=P(r)),console.timeEnd("get positions");const a=f;f=!1,await Promise.all(o.map((e=>(w=performance.now(),n.buildTile(i,r,e,a).then((()=>{const t=e[0]+","+e[1];p.set(t,(p.get(t)??0)+1),this.debug})))))).then((()=>{this.debug,g=!1}))}else g=!1}),this.refreshMs??1e4);this.disposed.subscribe((()=>x())),n.onNavMeshUpdate.pipe(b(this.disposed),m(200)).subscribe((()=>{a.clear(),a.drawNavMesh(n.navMesh)})),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.position.set(0,0,0),this.object.scale.set(1,1,1),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.add(a)),this.disposed.subscribe((()=>{n?.destroy(),a.removeFromParent(),a.dispose()}));const v=performance.now()-i;v>1e3&&console.warn(`NavMesh update took ${v} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([S(),t("design:type",Boolean)],T.prototype,"debug",void 0),e([S(),t("design:type",Number)],T.prototype,"walkableClimb",void 0),e([S({range:[0,89]}),t("design:type",Number)],T.prototype,"walkableSlopeAngle",void 0),e([S(),t("design:type",Number)],T.prototype,"cellSize",void 0),T=e([B()],T);export default T;function O(e){if(e.shape instanceof c)return function(e){const t=e.shape;if(t.type!==l.HeightField)throw new Error("The provided collider is not a height field.");let o=!1;const n=t,s=n.heights,i=n.nrows,r=n.ncols,a=n.scale.x,c=n.scale.z,h=n.scale.y,p=i+1,u=new y.PlaneGeometry(c,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let f=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[f+1]=s[t*p+e]*h,f+=3,0!=d[f+1]&&(o=!0);if(!o){const e=new y.PlaneGeometry(a,c,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof o)return new y.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new y.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i)return function(e){const t=[];for(let o=0;o<e.length;o+=3)t.push(new y.Vector3(e[o],e[o+1],e[o+2]));const o=(new v).setFromPoints(t),n=[];o.faces.forEach((e=>{const t=e.edge.head().point,o=e.edge.next.head().point,s=e.edge.next.next.head().point;n.push(t.x,t.y,t.z),n.push(o.x,o.y,o.z),n.push(s.x,s.y,s.z)}));const s=new y.BufferGeometry;return s.setAttribute("position",new y.Float32BufferAttribute(n,3)),s}(e.shape.vertices);if(e.shape instanceof h){const t=e.shape.vertices,o=e.shape.indices;let n=new y.BufferGeometry;return n.setAttribute("position",new y.Float32BufferAttribute(t,3)),null!=o?n.setIndex(new y.Uint16BufferAttribute(o,1)):n=x.mergeVertices(n),n.computeVertexNormals(),n}if(e.shape instanceof a){const t=e.shape.halfHeight,o=e.shape.radius;return new y.CylinderGeometry(o,o,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,o=e.shape.radius;return new y.ConeGeometry(o,2*t)}if(e.shape instanceof n){const t=e.shape.halfHeight,o=e.shape.radius;return new y.CapsuleGeometry(o,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function U(e){const t=O(e);if(null==t)return null;const o=W,n=new y.Mesh(t,o);return n.geometry.computeBoundingBox(),n.geometry.scale(1.01,1.01,1.01),n}function q(e,t){const o=e.translation(),n=e.rotation();t.position.set(o.x,o.y,o.z),t.quaternion.set(n.x,n.y,n.z,n.w)}const W=new y.MeshBasicMaterial({wireframe:!1,color:16711680,side:y.FrontSide})
|
2
|
-
/*
|
1
|
+
import{__decorate as e,__metadata as t}from"tslib";import{Ball as o,Capsule as n,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as c,ShapeType as l,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as f,debounceTime as m,filter as w,firstValueFrom as g,takeUntil as b}from"rxjs";import*as y from"three";import{BufferGeometryUtils as x,ConvexHull as v}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as M,Parameter as S,PhysicsSystem as z,ViewController as j,World as k,inject as A}from"../../";import{DynamicTiledNavMesh as C}from"../../ai/dynamic-tiled-navmesh";import{hasSharedArrayBufferSupport as F,toSharedFloat32Array as G,toSharedUint32Array as P}from"../../../utils/buffer";import{sleepDelay as N}from"../../../utils/async";var V;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(V||(V={}));let D=V.none,I=new f(!1);export async function safeRecastInit(){return D===V.none?(D=V.starting,p().then((()=>{I.next(!0),D=V.started}))):g(I.pipe(w((e=>e))))}const E=new y.Box3(new y.Vector3(-100,-100,-100),new y.Vector3(100,100,100)),H=navigator.hardwareConcurrency??1;let R=!1,T=class extends M{constructor(){super(...arguments),this.physics=A(z),this.view=A(j),this.world=A(k),this.debug=!0,this.refreshMs=4e3,this.tileSize=400,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.cellSize=.2}async onInit(){R||(await safeRecastInit(),R=!0),setTimeout((()=>{this.init()}),1e3)}init(){const e=this.cellSize,t={tileSize:400,walkableClimb:this.walkableClimb/e,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:5,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:e,ch:e,maxSimplificationError:1.3,maxEdgeLen:200},o=new y.Box3;for(const e of this.physics.staticBodies.keys())e.traverse((t=>{t.isMesh&&t.geometry&&(t.geometry.computeBoundingBox(),o.expandByObject(e))}));o.union(E);const n=new C({navMeshBounds:o,recastConfig:t,maxTiles:1024,workers:H,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=n.navMesh,this.object.position.set(0,0,0);const s=this.tileSize*t.cs*2,i=performance.now(),r=new Map,a=new u;a.userData.isDebugDrawer=!0;n.navMesh;const c=()=>{const e=this.view.getCamera().getWorldPosition(new y.Vector3),t=new y.Box3((new y.Vector3).copy(e).subScalar(s),(new y.Vector3).copy(e).addScalar(s)),o=[],n=this.physics.world.bodies;if(null==n)return[];const i=new y.Box3;for(const e of n.getAll())for(let n=0,s=e.numColliders();n<s;n++){const s=e.collider(n);if(s.isSensor()||null!=s.parent().userData&&!0===s.parent().userData.ignoreForNavMesh)continue;const a=e.handle+","+n,c=r.get(a)?.mesh,l=c??U(s);if(q(s,l),null!=l){i.copy(l.geometry.boundingBox),i.min.add(l.position),i.max.add(l.position);const e=i.intersectsBox(t)||!0;r.set(a,{pos:s.translation(),mesh:l}),e&&o.push(l)}}return o},l=new y.Box3,h=new Map,p=new Map;let f=!0,w=performance.now(),g=!1;const x=function(e,t){let o=!1;return(async()=>{for(;!o;)await e(),await N(t)})(),()=>{o=!0}}((async()=>{if(g)return;const e=new y.Box3,t=c();for(const o of t){const t=h.get(o);!0!==t?.equals(o.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(o),h.set(o,o.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const o=n.getTilesForBounds(e);if(0!=o.length){const s=[];for(const o of t)l.setFromObject(o),l.intersectsBox(e)&&s.push(o);console.log("intersecting meshes",s.length),console.time("get positions");let[i,r]=d(s);F&&(i=G(i),r=P(r)),console.timeEnd("get positions");const a=f;f=!1,await Promise.all(o.map((e=>(w=performance.now(),n.buildTile(i,r,e,a).then((()=>{const t=e[0]+","+e[1];p.set(t,(p.get(t)??0)+1),this.debug})))))).then((()=>{this.debug,g=!1}))}else g=!1}),this.refreshMs??1e4);this.disposed.subscribe((()=>x())),n.onNavMeshUpdate.pipe(b(this.disposed),m(200)).subscribe((()=>{a.clear(),a.drawNavMesh(n.navMesh)})),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.position.set(0,0,0),this.object.scale.set(1,1,1),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.add(a)),this.disposed.subscribe((()=>{n?.destroy(),a.removeFromParent(),a.dispose()}));const v=performance.now()-i;v>1e3&&console.warn(`NavMesh update took ${v} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([S(),t("design:type",Boolean)],T.prototype,"debug",void 0),e([S(),t("design:type",Number)],T.prototype,"walkableClimb",void 0),e([S({range:[0,89]}),t("design:type",Number)],T.prototype,"walkableSlopeAngle",void 0),e([S(),t("design:type",Number)],T.prototype,"cellSize",void 0),T=e([B()],T);export default T;function O(e){if(e.shape instanceof c)return function(e){const t=e.shape;if(t.type!==l.HeightField)throw new Error("The provided collider is not a height field.");let o=!1;const n=t,s=n.heights,i=n.nrows,r=n.ncols,a=n.scale.x,c=n.scale.z,h=n.scale.y,p=i+1,u=new y.PlaneGeometry(c,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let f=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[f+1]=s[t*p+e]*h,f+=3,0!=d[f+1]&&(o=!0);if(!o){const e=new y.PlaneGeometry(a,c,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof o)return new y.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new y.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i)return function(e){const t=[];for(let o=0;o<e.length;o+=3)t.push(new y.Vector3(e[o],e[o+1],e[o+2]));const o=(new v).setFromPoints(t),n=[];o.faces.forEach((e=>{const t=e.edge.head().point,o=e.edge.next.head().point,s=e.edge.next.next.head().point;n.push(t.x,t.y,t.z),n.push(o.x,o.y,o.z),n.push(s.x,s.y,s.z)}));const s=new y.BufferGeometry;return s.setAttribute("position",new y.Float32BufferAttribute(n,3)),s}(e.shape.vertices);if(e.shape instanceof h){const t=e.shape.vertices,o=e.shape.indices;let n=new y.BufferGeometry;return n.setAttribute("position",new y.Float32BufferAttribute(t,3)),null!=o?n.setIndex(new y.Uint16BufferAttribute(o,1)):n=x.mergeVertices(n),n.computeVertexNormals(),n}if(e.shape instanceof a){const t=e.shape.halfHeight,o=e.shape.radius;return new y.CylinderGeometry(o,o,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,o=e.shape.radius;return new y.ConeGeometry(o,2*t)}if(e.shape instanceof n){const t=e.shape.halfHeight,o=e.shape.radius;return new y.CapsuleGeometry(o,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function U(e){const t=O(e);if(null==t)return null;const o=W,n=new y.Mesh(t,o);return n.geometry.computeBoundingBox(),n.geometry.scale(1.01,1.01,1.01),n}function q(e,t){const o=e.translation(),n=e.rotation();t.position.set(o.x,o.y,o.z),t.quaternion.set(n.x,n.y,n.z,n.w)}const W=new y.MeshBasicMaterial({wireframe:!1,color:16711680,side:y.FrontSide});/*
|
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":"positional-audio-actor.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/positional-audio-actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAS,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,cAAc,EAA6B,MAAM,iBAAiB,CAAC;AAO5E,qBACa,oBAAqB,SAAQ,SAAS;IACjD,KAAK,EAAE,wBAAwB,CAAmC;CACnE;AA2BD,qBACa,wBAAyB,SAAQ,cAAc;IAC7C,OAAO,CAAC,WAAW,CAAa;IAKlB,OAAO,CAAC,MAAM,CAAY;IACxC,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAgB;IACf,OAAO,CAAC,WAAW,CAAQ;IAC5C,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,WAAW,CAAQ;IAKxC,OAAO,CAAC,IAAI,CAAyB;IAErC,SAAgB,KAAK,wBAAsD;IAE3E,OAAO,CAAC,aAAa,CAAmE;IAExF,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA6C9B,SAAS,IAAI,IAAI;CAQlB"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as o,__metadata as t}from"tslib";import*as s from"three";import{Actor as i,BaseActor as e}from"../actor.js";import{ActorComponent as n,Component as r,attach as a}from"../component.js";import{Parameter as d}from"../../../shader/index.js";import{ViewController as u}from"../../services/render.js";import{inject as l}from"../../inject.js";import{PositionalAudioHelper as p}from"../../../utils/three/positional-audio-helper.js";let h=class extends e{constructor(){super(...arguments),this.audio=a(c)}};h=o([i()],h);export{h as PositionalAudioActor};let m=class extends n{onInit(){const o=(new s.TextureLoader).load("assets/audio.png"),t=new s.SpriteMaterial({map:o}),i=new s.Sprite(t);this.actor.object.add(i),this.helper=new p(this.positionalAudio)}};m=o([r({inEditor:!0,editorOnly:!0})],m);let c=class extends n{constructor(){super(...arguments),this.volume=1,this.loop=!1,this.autoPlay=!0,this.view=l(u),this.sound=new s.PositionalAudio(this.view.audioListener),this.visualisation=a(m,{positionalAudio:this.sound})}onInit(){this.sound.setBuffer(this.audioBuffer),null!=this.refDistance&&this.sound.setRefDistance(Math.max(this.refDistance,0)),null!=this.rollofFactor&&this.sound.setRolloffFactor(this.rollofFactor),null!=this.maxDistance&&this.sound.setMaxDistance(this.maxDistance),null!=this.volume?this.sound.setVolume(Math.max(this.volume,0)):this.sound.setVolume(0),this.sound.loop=this.loop??!1,this.visualisation?.helper?.update(),this.actor.object.add(this.sound),this.autoPlay&&this.sound?.play(),this.disposed.subscribe((()=>{this.sound.isPlaying&&(this.sound?.stop(),console.log(this.sound.getVolume(),this.volume)),this.sound.removeFromParent()})),console.log(this.sound)}onEndPlay(){this.sound.isPlaying&&(this.sound?.stop(),this.sound.loop=!1),this.sound.removeFromParent()}};o([d(),t("design:type",AudioBuffer)],c.prototype,"audioBuffer",void 0),o([d({range:[0,1]}),t("design:type",Number)],c.prototype,"volume",void 0),o([d(),t("design:type",Boolean)],c.prototype,"loop",void 0),o([d(),t("design:type",Boolean)],c.prototype,"autoPlay",void 0),o([d({range:[0,1e3]}),t("design:type",Number)],c.prototype,"refDistance",void 0),o([d(),t("design:type",Number)],c.prototype,"rollofFactor",void 0),o([d(),t("design:type",Number)],c.prototype,"maxDistance",void 0),c=o([r({inEditor:!0})],c);export{c as PositionalAudioComponent}
|
2
|
-
/*
|
1
|
+
import{__decorate as o,__metadata as t}from"tslib";import*as s from"three";import{Actor as i,BaseActor as e}from"../actor.js";import{ActorComponent as n,Component as r,attach as a}from"../component.js";import{Parameter as d}from"../../../shader/index.js";import{ViewController as u}from"../../services/render.js";import{inject as l}from"../../inject.js";import{PositionalAudioHelper as p}from"../../../utils/three/positional-audio-helper.js";let h=class extends e{constructor(){super(...arguments),this.audio=a(c)}};h=o([i()],h);export{h as PositionalAudioActor};let m=class extends n{onInit(){const o=(new s.TextureLoader).load("assets/audio.png"),t=new s.SpriteMaterial({map:o}),i=new s.Sprite(t);this.actor.object.add(i),this.helper=new p(this.positionalAudio)}};m=o([r({inEditor:!0,editorOnly:!0})],m);let c=class extends n{constructor(){super(...arguments),this.volume=1,this.loop=!1,this.autoPlay=!0,this.view=l(u),this.sound=new s.PositionalAudio(this.view.audioListener),this.visualisation=a(m,{positionalAudio:this.sound})}onInit(){this.sound.setBuffer(this.audioBuffer),null!=this.refDistance&&this.sound.setRefDistance(Math.max(this.refDistance,0)),null!=this.rollofFactor&&this.sound.setRolloffFactor(this.rollofFactor),null!=this.maxDistance&&this.sound.setMaxDistance(this.maxDistance),null!=this.volume?this.sound.setVolume(Math.max(this.volume,0)):this.sound.setVolume(0),this.sound.loop=this.loop??!1,this.visualisation?.helper?.update(),this.actor.object.add(this.sound),this.autoPlay&&this.sound?.play(),this.disposed.subscribe((()=>{this.sound.isPlaying&&(this.sound?.stop(),console.log(this.sound.getVolume(),this.volume)),this.sound.removeFromParent()})),console.log(this.sound)}onEndPlay(){this.sound.isPlaying&&(this.sound?.stop(),this.sound.loop=!1),this.sound.removeFromParent()}};o([d(),t("design:type",AudioBuffer)],c.prototype,"audioBuffer",void 0),o([d({range:[0,1]}),t("design:type",Number)],c.prototype,"volume",void 0),o([d(),t("design:type",Boolean)],c.prototype,"loop",void 0),o([d(),t("design:type",Boolean)],c.prototype,"autoPlay",void 0),o([d({range:[0,1e3]}),t("design:type",Number)],c.prototype,"refDistance",void 0),o([d(),t("design:type",Number)],c.prototype,"rollofFactor",void 0),o([d(),t("design:type",Number)],c.prototype,"maxDistance",void 0),c=o([r({inEditor:!0})],c);export{c as PositionalAudioComponent};/*
|
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":"spawn-point.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/spawn-point.ts"],"names":[],"mappings":"AAWA,OAAO,EAAS,SAAS,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAa,cAAc,EAAkB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAA;AAI3D,qBACa,cAAe,SAAQ,cAAc;IAChD,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB/B;AAED,qBACa,UAAW,SAAQ,SAAS;IACvC,OAAO,CAAC,IAAI,CAAyC;IAErD,SAAS,CAAC,QAAQ,CAAC,KAAK,QAAgB;IAExC,UAAU,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAG3D"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{ArrowHelper as o,Vector3 as r,Euler as e}from"three";import{Actor as s,BaseActor as i}from"../actor.js";import{Component as n,ActorComponent as m,attach as p}from"../component.js";import{World as c}from"../../../gameplay/services/world.js";import{inject as a}from"../../../gameplay/inject.js";import{createLineSphere as l}from"../../../utils/three/line-sphere.js";let d=class extends m{onInit(){const t=l(1);this.actor.object.add(t);const e=new o(new r(0,0,1),new r,1,1268122,.3,.3);this.actor.object.add(e)}};d=t([n({inEditor:!0,editorOnly:!0})],d);export{d as SpawnPointMesh};let h=class extends i{constructor(){super(...arguments),this.mesh=p(d),this.world=a(c)}spawnActor(t){return this.world.spawnActor(t,this.position,new e(0,this.rotation.y,0,"XYZ"))}};h=t([s()],h);export{h as SpawnPoint}
|
2
|
-
/*
|
1
|
+
import{__decorate as t}from"tslib";import{ArrowHelper as o,Vector3 as r,Euler as e}from"three";import{Actor as s,BaseActor as i}from"../actor.js";import{Component as n,ActorComponent as m,attach as p}from"../component.js";import{World as c}from"../../../gameplay/services/world.js";import{inject as a}from"../../../gameplay/inject.js";import{createLineSphere as l}from"../../../utils/three/line-sphere.js";let d=class extends m{onInit(){const t=l(1);this.actor.object.add(t);const e=new o(new r(0,0,1),new r,1,1268122,.3,.3);this.actor.object.add(e)}};d=t([n({inEditor:!0,editorOnly:!0})],d);export{d as SpawnPointMesh};let h=class extends i{constructor(){super(...arguments),this.mesh=p(d),this.world=a(c)}spawnActor(t){return this.world.spawnActor(t,this.position,new e(0,this.rotation.y,0,"XYZ"))}};h=t([s()],h);export{h as SpawnPoint};/*
|
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":"trigger-volume.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/trigger-volume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmG,OAAO,EAA+C,KAAK,EAAE,MAAM,OAAO,CAAC;AACrL,OAAO,EAAS,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAa,cAAc,EAAkB,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGzE,OAAO,EAAkB,UAAU,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG9C,qBACa,iBAAkB,SAAQ,cAAc;IACtC,KAAK,EAAE,KAAK,CAAsB;IAE/C,OAAO,CAAC,UAAU,CAA8B;IAEhD,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAY/B;AAED,qBACa,sBAAuB,SAAQ,cAAc;IAO5C,OAAO,CAAC,aAAa;IANjC,SAAgB,UAAU,EAAE,OAAO,CAAqB;IACxD,SAAgB,MAAM,EAAE,OAAO,CAAqB;IAGpD,OAAO,CAAC,UAAU,CAA+C;gBAE7C,aAAa,EAAE,aAAa;IAIzC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAe9B,uBAAuB,CAAC,CAAC,SAAS,SAAS,EAChD,KAAK,EAAE,CAAC,GACP,UAAU,CAAC,CAAC,CAAC;IAIT,qBAAqB,CAAC,CAAC,SAAS,SAAS,EAC9C,KAAK,EAAE,CAAC,GACP,UAAU,CAAC,CAAC,CAAC;IAIT,2BAA2B,CAAC,CAAC,SAAS,SAAS,EACpD,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,GACjB,UAAU,CAAC,CAAC,CAAC;IAIT,yBAAyB,CAAC,CAAC,SAAS,SAAS,EAClD,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,GACjB,UAAU,CAAC,CAAC,CAAC;CAGjB;AAED,qBACa,aAAc,SAAQ,SAAS;IAC1C,OAAO,yBAAiC;CACzC"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as s}from"tslib";import{EdgesGeometry as i,LineSegments as e,LineBasicMaterial as o,Vector3 as r,BoxGeometry as n,Mesh as h,MeshBasicMaterial as c,Group as p,Color as m}from"three";import{Actor as a,BaseActor as d}from"../actor.js";import{Component as l,ActorComponent as y,attach as f}from"../component.js";import{PhysicsSystem as w}from"../../services/physics/physics-system.js";import{BoxCollisionShape as v}from"../../../scene/collision/collision-shape.js";import{Parameter as O}from"../../../shader/parameter.js";import{firstValueFrom as g}from"rxjs";let u=class extends y{constructor(){super(...arguments),this.color=new m(16777215),this.dimensions=new r(1,1,1)}onInit(){const t=new n(this.dimensions.x,this.dimensions.y,this.dimensions.z),s=new i(t),r=new e(s,new o({color:this.color})),m=(new h(t,new c({color:this.color,transparent:!0,opacity:.3,visible:!1})),new p);m.add(r),this.actor.object.add(m)}};t([O(),s("design:type",m)],u.prototype,"color",void 0),u=t([l({inEditor:!0,editorOnly:!0})],u);export{u as TriggerVolumeMesh};let A=class extends y{constructor(t){super(),this.physicsSystem=t,this.dimensions=new r(1,1,1),this.offset=new r(0,0,0),this.editorMesh=f(u)}onInit(){this.physicsSystem.addActor(this.actor,[new v(this.dimensions).withOffset(this.offset)],{isTrigger:!0}),g(this.disposed).then((()=>{this.physicsSystem.removeActor(this.actor)}))}onBeginOverlapWithActor(t){return this.physicsSystem.onBeginOverlapWithActor(this.actor,t)}onEndOverlapWithActor(t){return this.physicsSystem.onEndOverlapWithActor(this.actor,t)}onBeginOverlapWithActorType(t){return this.physicsSystem.onBeginOverlapWithActorType(this.actor,t)}onEndOverlapWithActorType(t){return this.physicsSystem.onEndOverlapWithActorType(this.actor,t)}};A=t([l({inEditor:!0,editorOnly:!1}),s("design:paramtypes",[w])],A);export{A as TriggerVolumeComponent};let x=class extends d{constructor(){super(...arguments),this.trigger=f(A)}};x=t([a()],x);export{x as TriggerVolume}
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as s}from"tslib";import{EdgesGeometry as i,LineSegments as e,LineBasicMaterial as o,Vector3 as r,BoxGeometry as n,Mesh as h,MeshBasicMaterial as c,Group as p,Color as m}from"three";import{Actor as a,BaseActor as d}from"../actor.js";import{Component as l,ActorComponent as y,attach as f}from"../component.js";import{PhysicsSystem as w}from"../../services/physics/physics-system.js";import{BoxCollisionShape as v}from"../../../scene/collision/collision-shape.js";import{Parameter as O}from"../../../shader/parameter.js";import{firstValueFrom as g}from"rxjs";let u=class extends y{constructor(){super(...arguments),this.color=new m(16777215),this.dimensions=new r(1,1,1)}onInit(){const t=new n(this.dimensions.x,this.dimensions.y,this.dimensions.z),s=new i(t),r=new e(s,new o({color:this.color})),m=(new h(t,new c({color:this.color,transparent:!0,opacity:.3,visible:!1})),new p);m.add(r),this.actor.object.add(m)}};t([O(),s("design:type",m)],u.prototype,"color",void 0),u=t([l({inEditor:!0,editorOnly:!0})],u);export{u as TriggerVolumeMesh};let A=class extends y{constructor(t){super(),this.physicsSystem=t,this.dimensions=new r(1,1,1),this.offset=new r(0,0,0),this.editorMesh=f(u)}onInit(){this.physicsSystem.addActor(this.actor,[new v(this.dimensions).withOffset(this.offset)],{isTrigger:!0}),g(this.disposed).then((()=>{this.physicsSystem.removeActor(this.actor)}))}onBeginOverlapWithActor(t){return this.physicsSystem.onBeginOverlapWithActor(this.actor,t)}onEndOverlapWithActor(t){return this.physicsSystem.onEndOverlapWithActor(this.actor,t)}onBeginOverlapWithActorType(t){return this.physicsSystem.onBeginOverlapWithActorType(this.actor,t)}onEndOverlapWithActorType(t){return this.physicsSystem.onEndOverlapWithActorType(this.actor,t)}};A=t([l({inEditor:!0,editorOnly:!1}),s("design:paramtypes",[w])],A);export{A as TriggerVolumeComponent};let x=class extends d{constructor(){super(...arguments),this.trigger=f(A)}};x=t([a()],x);export{x as TriggerVolume};/*
|
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":"camera-component.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/camera/camera-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmG,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAEpJ,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AAOpE,qBACa,eAAgB,SAAQ,cAAc;IAUrC,OAAO,CAAC,cAAc;IATd,IAAI,EAAE,MAAM,CAAc;IAC1B,GAAG,EAAE,MAAM,CAAa;IACxB,SAAS,EAAE,MAAM,CAAqB;IAE1D,OAAO,CAAC,SAAS,CAAiC;IAElD,OAAO,CAAC,MAAM,CAA6F;IACpG,QAAQ,EAAE,iBAAiB,CAA0E;gBAExF,cAAc,EAAE,cAAc;IAElD,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAM/B;AAKD,qBACa,UAAW,SAAQ,cAAc;IAC1C,OAAO,CAAC,UAAU,CAAW;IAC7B,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAwBjC"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as e,__metadata as t}from"tslib";import{ArrowHelper as r,ConeGeometry as i,EdgesGeometry as s,LineBasicMaterial as o,LineSegments as n,MeshStandardMaterial as a,PerspectiveCamera as l,Vector3 as h}from"three";import{Parameter as d}from"../../../shader/parameter.js";import{ViewController as c}from"../../services/render.js";import{ActorComponent as p,attach as w,Component as m}from"../component.js";const v=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let b=class extends p{constructor(e){super(),this.viewController=e,this.near=.5,this.far=500,this.viewAngle=v?30:45,this.debugMesh=w(y),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.instance=new l(this.viewAngle,this.aspect,this.near,this.far)}onInit(){this.actor.object.add(this.instance),this.instance.near=this.near,this.instance.far=this.far,this.instance.fov=this.viewAngle}};e([d(),t("design:type",Number)],b.prototype,"near",void 0),e([d(),t("design:type",Number)],b.prototype,"far",void 0),e([d(),t("design:type",Number)],b.prototype,"viewAngle",void 0),b=e([m({inEditor:!0}),t("design:paramtypes",[c])],b);export{b as CameraComponent};let y=class extends p{constructor(){super(...arguments),this.arrowColor=16101442}onInit(){const e=new i(1,1,4);e.rotateX(Math.PI/2),e.rotateZ(Math.PI/4),e.scale(1,9/16,1);const t=new s(e),l=(new a({color:3355443}),new n(t,new o({color:16777215}))),d=new r(new h(0,0,-1),new h(0,0,0),1.2,this.arrowColor,.15,.2);l.add(d),d.layers.disableAll(),d.layers.enable(19),d.traverse((e=>{e.layers.disableAll(),e.layers.enable(19)})),this.actor.object.add(l)}};y=e([m({inEditor:!0,editorOnly:!0})],y);export{y as CameraMesh}
|
2
|
-
/*
|
1
|
+
import{__decorate as e,__metadata as t}from"tslib";import{ArrowHelper as r,ConeGeometry as i,EdgesGeometry as s,LineBasicMaterial as o,LineSegments as n,MeshStandardMaterial as a,PerspectiveCamera as l,Vector3 as h}from"three";import{Parameter as d}from"../../../shader/parameter.js";import{ViewController as c}from"../../services/render.js";import{ActorComponent as p,attach as w,Component as m}from"../component.js";const v=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let b=class extends p{constructor(e){super(),this.viewController=e,this.near=.5,this.far=500,this.viewAngle=v?30:45,this.debugMesh=w(y),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.instance=new l(this.viewAngle,this.aspect,this.near,this.far)}onInit(){this.actor.object.add(this.instance),this.instance.near=this.near,this.instance.far=this.far,this.instance.fov=this.viewAngle}};e([d(),t("design:type",Number)],b.prototype,"near",void 0),e([d(),t("design:type",Number)],b.prototype,"far",void 0),e([d(),t("design:type",Number)],b.prototype,"viewAngle",void 0),b=e([m({inEditor:!0}),t("design:paramtypes",[c])],b);export{b as CameraComponent};let y=class extends p{constructor(){super(...arguments),this.arrowColor=16101442}onInit(){const e=new i(1,1,4);e.rotateX(Math.PI/2),e.rotateZ(Math.PI/4),e.scale(1,9/16,1);const t=new s(e),l=(new a({color:3355443}),new n(t,new o({color:16777215}))),d=new r(new h(0,0,-1),new h(0,0,0),1.2,this.arrowColor,.15,.2);l.add(d),d.layers.disableAll(),d.layers.enable(19),d.traverse((e=>{e.layers.disableAll(),e.layers.enable(19)})),this.actor.object.add(l)}};y=e([m({inEditor:!0,editorOnly:!0})],y);export{y as CameraMesh};/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -52,3 +52,4 @@ export declare class ThirdPersonCameraComponent extends ActorComponent {
|
|
52
52
|
/** @deprecated Use ThirdPersonCameraComponent. No difference just renamed */
|
53
53
|
export declare class ThirdPartyCameraComponent extends ThirdPersonCameraComponent {
|
54
54
|
}
|
55
|
+
//# sourceMappingURL=third-person-camera-component.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"third-person-camera-component.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/camera/third-person-camera-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA6B,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAqB,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAiB,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAiB,MAAM,0CAA0C,CAAC;AAUxF;;;GAGG;AACH,qBACa,0BAA2B,SAAQ,cAAc;IA+BhD,OAAO,CAAC,cAAc;IAAkB,OAAO,CAAC,aAAa;IA7BzE,OAAO,CAAC,MAAM,CAA6F;IACvF,IAAI,EAAE,MAAM,CAAc;IAC1B,GAAG,EAAE,MAAM,CAAa;IACxB,SAAS,EAAE,MAAM,CAAqB;IACnD,MAAM,EAAE,iBAAiB,CAA0E;IAEnG,QAAQ,EAAE,MAAM,CAAI;IACpB,WAAW,EAAE,MAAM,CAAM;IACzB,WAAW,SAAgB;IAC3B,MAAM,SAAI;IACV,OAAO,SAAK;IACZ,OAAO,SAAM;IACb,YAAY,EAAE,OAAO,CAAO;IAC5B,eAAe,SAAI;IAE1B,OAAO,CAAC,oBAAoB,CAAK;IACjC,OAAO,CAAC,kBAAkB,CAA4C;IAEtE,SAAgB,aAAa,0BAAwD;IACrF,SAAgB,SAAS,eAA4B;IAErD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2C;IAEjE,WAAW,UAAO;IAEzB,OAAO,CAAC,KAAK,CAAgB;gBAET,cAAc,EAAE,cAAc,EAAU,aAAa,EAAE,aAAa;IAEjF,aAAa,UAAQ;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtB,QAAQ;IAuBR,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI5C,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,MAAM,CAAqB;IAC5B,UAAU;IAkBjB,OAAO,CAAC,wBAAwB,CAAO;IAEhC,UAAU;IAOjB,OAAO,CAAC,WAAW,CAIlB;IAED,OAAO,CAAC,SAAS,CAIhB;IAED,OAAO,CAAC,mBAAmB,CAK1B;IAED,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,iBAAiB;IA0CzB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,oBAAoB;CAgB7B;AAcD,8EAA8E;AAC9E,qBAAa,yBAA0B,SAAQ,0BAA0B;CAAG"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as e}from"tslib";import{ActorComponent as i,Component as s}from"../component.js";import{Vector3 as o,MathUtils as n,PerspectiveCamera as a}from"three";import{ViewController as r}from"../../services/render.js";import{DecimalInput as h,RestrictedRotationInput as c}from"../../input/index.js";import{PhysicsSystem as d,RayTestResult as m}from"../../services/physics/physics-system.js";import{Parameter as l}from"../../../shader/parameter.js";import{World as p}from"../../services/world.js";import{inject as u}from"../../inject.js";const f=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let w=class extends i{constructor(t,e){super(),this.viewController=t,this.physicsSystem=e,this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=f?30:45,this.camera=new a(this.viewAngle,this.aspect,this.near,this.far),this.distance=9,this.minDistance=1.5,this.maxDistance=this.distance,this.height=3,this.offsetX=-1,this.offsetZ=1.5,this.autoActivate=!0,this.bounceBackSpeed=5,this.collisionCheckRadius=.5,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new c(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new h(1,0,1),this.offset=new o,this.lookAtOffset=new o(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=u(p),this.isMouseLocked=!1,this.canvas=null,this.pointerLockInactivatedAt=null,this.onMouseDown=t=>{this.isMouseLocked||"mouse"!==t.pointerType||this.hideCursor()},this.onKeyDown=t=>{"Escape"===t.key&&this.showCursor()},this.onPointerLockChange=()=>{null!=document.pointerLockElement||null!=document.mozPointerLockElement||this.showCursor()}}async onInit(){this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.autoActivate&&this.activate()}activate(){this.viewController.setCamera(this.camera);const t=this.element;null!=document.body.requestPointerLock&&(t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.disposed.subscribe((()=>{t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1)})))}onLateUpdate(t){this.setFromRotation(t)}get element(){return this.viewController.htmlElement}hideCursor(){null!=this.pointerLockInactivatedAt&&performance.now()-this.pointerLockInactivatedAt<1600||(this.element.style.cursor="none",null==this.canvas&&(this.canvas=this.element.getElementsByTagName("canvas")[0]),this.canvas&&(this.canvas.requestPointerLock(),this.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.checkForCollision(t);const e=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*this.zoomInput.value,this.minDistance)),i=Math.cos(this.rotationInput.rotation.x)*e,s=this.fixedBehind?0:this.rotationInput.rotation.y;this.offset.x=Math.sin(-s)*i,this.offset.y=Math.sin(this.rotationInput.rotation.x)*e+2,this.offset.z=Math.cos(-s)*-i,this.offset.add(this.lookAtOffset),this.updateCameraPosition()}checkForCollision(t){const e=this.getLookAtPosition(),i=y;let s=!1,o=this.distance;const a=new m,r=this.camera.getWorldPosition(g);for(let t=-1;t<=1;t++){const n=k.subVectors(r,e);i.copy(r).add(n.multiplyScalar(1.2)),i.x+=t*this.collisionCheckRadius,this.physicsSystem.rayTest(e,i,a,{debugLifetime:0,excludeActor:this.actor,excludeTriggers:!0}),a.hasHit&&a.distance<this.distance&&(o=Math.min(a.distance,o),s
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as e}from"tslib";import{ActorComponent as i,Component as s}from"../component.js";import{Vector3 as o,MathUtils as n,PerspectiveCamera as a}from"three";import{ViewController as r}from"../../services/render.js";import{DecimalInput as h,RestrictedRotationInput as c}from"../../input/index.js";import{PhysicsSystem as d,RayTestResult as m}from"../../services/physics/physics-system.js";import{Parameter as l}from"../../../shader/parameter.js";import{World as p}from"../../services/world.js";import{inject as u}from"../../inject.js";const f=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let w=class extends i{constructor(t,e){super(),this.viewController=t,this.physicsSystem=e,this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=f?30:45,this.camera=new a(this.viewAngle,this.aspect,this.near,this.far),this.distance=9,this.minDistance=1.5,this.maxDistance=this.distance,this.height=3,this.offsetX=-1,this.offsetZ=1.5,this.autoActivate=!0,this.bounceBackSpeed=5,this.collisionCheckRadius=.5,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new c(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new h(1,0,1),this.offset=new o,this.lookAtOffset=new o(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=u(p),this.isMouseLocked=!1,this.canvas=null,this.pointerLockInactivatedAt=null,this.onMouseDown=t=>{this.isMouseLocked||"mouse"!==t.pointerType||this.hideCursor()},this.onKeyDown=t=>{"Escape"===t.key&&this.showCursor()},this.onPointerLockChange=()=>{null!=document.pointerLockElement||null!=document.mozPointerLockElement||this.showCursor()}}async onInit(){this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.autoActivate&&this.activate()}activate(){this.viewController.setCamera(this.camera);const t=this.element;null!=document.body.requestPointerLock&&(t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.disposed.subscribe((()=>{t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1)})))}onLateUpdate(t){this.setFromRotation(t)}get element(){return this.viewController.htmlElement}hideCursor(){null!=this.pointerLockInactivatedAt&&performance.now()-this.pointerLockInactivatedAt<1600||(this.element.style.cursor="none",null==this.canvas&&(this.canvas=this.element.getElementsByTagName("canvas")[0]),this.canvas&&(this.canvas.requestPointerLock(),this.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.checkForCollision(t);const e=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*this.zoomInput.value,this.minDistance)),i=Math.cos(this.rotationInput.rotation.x)*e,s=this.fixedBehind?0:this.rotationInput.rotation.y;this.offset.x=Math.sin(-s)*i,this.offset.y=Math.sin(this.rotationInput.rotation.x)*e+2,this.offset.z=Math.cos(-s)*-i,this.offset.add(this.lookAtOffset),this.updateCameraPosition()}checkForCollision(t){const e=this.getLookAtPosition(),i=y;let s=!1,o=this.distance;const a=new m,r=this.camera.getWorldPosition(g);for(let t=-1;t<=1;t++){const n=k.subVectors(r,e);i.copy(r).add(n.multiplyScalar(1.2)),i.x+=t*this.collisionCheckRadius,this.physicsSystem.rayTest(e,i,a,{debugLifetime:0,excludeActor:this.actor,excludeTriggers:!0}),a.hasHit&&a.distance<this.distance&&(o=Math.min(a.distance,o),s||(s=a.hasHit))}s||(this.restrictedDistance=n.lerp(this.restrictedDistance,this.distance,n.clamp(this.bounceBackSpeed*t,0,1)))}getLookAtPosition(){const t=v;return t.set(0,0,0),t.y=this.height,t.add(this.lookAtOffset),t.applyMatrix4(this.actor.object.matrixWorld),t}updateCameraPosition(){this.fixedBehind?(this.actor.object.updateWorldMatrix(!0,!1),this.camera.position.set(this.offset.x,this.offset.y,this.offset.z),this.camera.rotation.set(0,0,0),this.camera.scale.set(1,1,1),this.camera.applyMatrix4(this.actor.object.matrix)):this.camera.position.copy(this.actor.position).add(this.offset);const t=this.getLookAtPosition();this.camera.lookAt(t)}};t([l(),e("design:type",Number)],w.prototype,"near",void 0),t([l(),e("design:type",Number)],w.prototype,"far",void 0),t([l(),e("design:type",Number)],w.prototype,"viewAngle",void 0),w=t([s(),e("design:paramtypes",[r,d])],w);export{w as ThirdPersonCameraComponent};const v=new o,y=new o,k=(new o,new o),g=new o;export class ThirdPartyCameraComponent extends w{}/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -39,3 +39,4 @@ export type ComponentAttachProps<T> = Partial<Omit<{
|
|
39
39
|
}, keyof ActorComponent>>;
|
40
40
|
export declare function Attach<T extends ActorComponent>(props?: ComponentAttachProps<T>, type?: Constructable<T>): (target: Object, propertyName: string | Symbol, index?: number) => void;
|
41
41
|
export declare function attach<T extends ActorComponent>(type: Constructable<T>, props?: ComponentAttachProps<T>): T;
|
42
|
+
//# sourceMappingURL=component.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/gameplay/actors/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,aAAa,EAAqB,MAAM,QAAQ,CAAC;AACtF,OAAO,EAAE,SAAS,EAAkC,MAAM,YAAY,CAAA;AAItE,8BAAsB,cAAc,CAAC,SAAS,SAAS,SAAS,GAAG,SAAS;IACnE,KAAK,EAAE,SAAS,CAAA;;IAMvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,GAAC,IAAI;IAC5B,WAAW,IAAI,IAAI;IACnB,SAAS,IAAI,IAAI;IACjB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IACjC;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAErC,IAAI,QAAQ,iCAEX;IAED,SAAS,CAAC,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC;CAGvG;AAGD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;OAOG;IACH,QAAQ,EAAE,OAAO,CAAA;IAEjB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,wBAAgB,SAAS,CAAC,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAwC,oCAQlG;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,EAAE,MAAM,cAAc,CAAC,CAAC,CAAA;AAGnG,wBAAgB,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,GAAE,oBAAoB,CAAC,CAAC,CAAM,EAAE,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,YAClF,MAAM,gBAAgB,MAAM,GAAG,MAAM,UAAU,MAAM,KAAG,IAAI,CAetF;AAGD,wBAAgB,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAY3G"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{Container as t,Service as n,Inject as o}from"typedi";import{_setupActorUpdateEventHandlers as e}from"./actor.js";import{activeContainerInstance as r}from"./internal/container-map.js";import{randomString as i}from"../../utils/math.js";export class ActorComponent{constructor(){e.call(this)}onInit(){}onBeginPlay(){}onEndPlay(){}onUpdate(t){}onLateUpdate(t){}get disposed(){return this.actor.disposed}attach(t,n){return this.actor.attach(t,n)}}ActorComponent.__isActorComponent=!0;export function Component(t={inEditor:!1,editorOnly:!1}){const o=n({transient:!0});return function(n){n.__inEditor=t.inEditor,n.__onlyEditor=t.editorOnly,o(n)}}export function Attach(n={},e){return function(r,i,a){if(null==r)return void Reflect.defineMetadata("design:type",e,e.prototype,i);const c=e??Reflect.getMetadata("design:type",r,i);o((()=>c))(r,i,a);const s=t.handlers.find((t=>t.object===r&&t.propertyName===i&&t.index===a)),d=s.value;s.value=t=>{const o=d(t);return Object.assign(o,n)}}}export function attach(n,o){const e=r.value??t.of("default"),a=i();e.set({id:a,type:n,transient:!0});const c=e.get(a);if(null!=o)for(const t of Object.keys(o))c[t]=o[t];return c}
|
2
|
-
/*
|
1
|
+
import{Container as t,Service as n,Inject as o}from"typedi";import{_setupActorUpdateEventHandlers as e}from"./actor.js";import{activeContainerInstance as r}from"./internal/container-map.js";import{randomString as i}from"../../utils/math.js";export class ActorComponent{constructor(){e.call(this)}onInit(){}onBeginPlay(){}onEndPlay(){}onUpdate(t){}onLateUpdate(t){}get disposed(){return this.actor.disposed}attach(t,n){return this.actor.attach(t,n)}}ActorComponent.__isActorComponent=!0;export function Component(t={inEditor:!1,editorOnly:!1}){const o=n({transient:!0});return function(n){n.__inEditor=t.inEditor,n.__onlyEditor=t.editorOnly,o(n)}}export function Attach(n={},e){return function(r,i,a){if(null==r)return void Reflect.defineMetadata("design:type",e,e.prototype,i);const c=e??Reflect.getMetadata("design:type",r,i);o((()=>c))(r,i,a);const s=t.handlers.find((t=>t.object===r&&t.propertyName===i&&t.index===a)),d=s.value;s.value=t=>{const o=d(t);return Object.assign(o,n)}}}export function attach(n,o){const e=r.value??t.of("default"),a=i();e.set({id:a,type:n,transient:!0});const c=e.get(a);if(null!=o)for(const t of Object.keys(o))c[t]=o[t];return c}/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -10,3 +10,4 @@ export declare class ActorFactory implements ActorProvider<BaseActor> {
|
|
10
10
|
create<T extends BaseActor>(type: Constructable<T>, position?: Vector3, rotation?: Euler, delayInit?: boolean): Promise<T>;
|
11
11
|
initActor(actor: BaseActor): Promise<void>;
|
12
12
|
}
|
13
|
+
//# sourceMappingURL=factory.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/gameplay/actors/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAMvC,qBACa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IAC/C,OAAO,CAAC,SAAS;IAAqB,OAAO,CAAC,GAAG;gBAAzC,SAAS,EAAE,iBAAiB,EAAU,GAAG,EAAE,iBAAiB;IACnE,MAAM,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAiC1H,SAAS,CAAC,KAAK,EAAE,SAAS;CAMxC"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as i}from"tslib";import{ContainerInstance as n}from"typedi";import{Service as o}from"typedi";import{initComponents as e}from"./internal/component-init.js";import{activeContainerInstance as r,containerRefMap as a}from"./internal/container-map.js";let s=class{constructor(t,i){this.container=t,this.env=i}async create(t,i,n,o){const e=this.container;r.value=e;const s=(1e4*Math.random()).toString();e.set({id:s,type:t,transient:!0});const c=e.get(s);return r.value=null,e.remove(t),a.set(c,e),i&&c.object.position.copy(i),n&&c.object.rotation.copy(n),!0!==o&&await this.initActor(c),c}async initActor(t){await e(t,t,this.env.inEditor??!1),await t.onInit(),t.__isInitialised=!0}};s=t([o(),i("design:paramtypes",[n,Object])],s);export{s as ActorFactory}
|
2
|
-
/*
|
1
|
+
import{__decorate as t,__metadata as i}from"tslib";import{ContainerInstance as n}from"typedi";import{Service as o}from"typedi";import{initComponents as e}from"./internal/component-init.js";import{activeContainerInstance as r,containerRefMap as a}from"./internal/container-map.js";let s=class{constructor(t,i){this.container=t,this.env=i}async create(t,i,n,o){const e=this.container;r.value=e;const s=(1e4*Math.random()).toString();e.set({id:s,type:t,transient:!0});const c=e.get(s);return r.value=null,e.remove(t),a.set(c,e),i&&c.object.position.copy(i),n&&c.object.rotation.copy(n),!0!==o&&await this.initActor(c),c}async initActor(t){await e(t,t,this.env.inEditor??!1),await t.onInit(),t.__isInitialised=!0}};s=t([o(),i("design:paramtypes",[n,Object])],s);export{s as ActorFactory};/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -8,3 +8,4 @@ export * from './builtin/components/mesh-component.js';
|
|
8
8
|
export * from './builtin/components/character/character-movement.js';
|
9
9
|
export * from './builtin/components/character/modes.js';
|
10
10
|
export * from './builtin/components/character/character-animation.js';
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gameplay/actors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAA;AACjH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AACpG,cAAc,wCAAwC,CAAA;AACtD,cAAc,sDAAsD,CAAA;AACpE,cAAc,yCAAyC,CAAA;AACvD,cAAc,uDAAuD,CAAA"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
export{CameraActor}from"./builtin/camera-actor.js";export{CameraComponent}from"./camera/camera-component.js";export{ThirdPersonCameraComponent,ThirdPartyCameraComponent}from"./camera/third-person-camera-component.js";export{SpawnPoint}from"./builtin/spawn-point.js";export{TriggerVolume,TriggerVolumeComponent}from"./builtin/trigger-volume.js";export{PositionalAudioActor,PositionalAudioComponent}from"./builtin/positional-audio-actor.js";export*from"./builtin/components/mesh-component.js";export*from"./builtin/components/character/character-movement.js";export*from"./builtin/components/character/modes.js";export*from"./builtin/components/character/character-animation.js"
|
2
|
-
/*
|
1
|
+
export{CameraActor}from"./builtin/camera-actor.js";export{CameraComponent}from"./camera/camera-component.js";export{ThirdPersonCameraComponent,ThirdPartyCameraComponent}from"./camera/third-person-camera-component.js";export{SpawnPoint}from"./builtin/spawn-point.js";export{TriggerVolume,TriggerVolumeComponent}from"./builtin/trigger-volume.js";export{PositionalAudioActor,PositionalAudioComponent}from"./builtin/positional-audio-actor.js";export*from"./builtin/components/mesh-component.js";export*from"./builtin/components/character/character-movement.js";export*from"./builtin/components/character/modes.js";export*from"./builtin/components/character/character-animation.js";/*
|
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":"component-init.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/internal/component-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIhD,wBAAsB,cAAc,CAAC,CAAC,EAAE,SAAS,GAAC,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,UAAQ,kBAoCnG"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{ActorComponent as o}from"../component.js";const n=new WeakMap;export async function initComponents(t,c,i=!1){const r=[];for(const s of Object.values(t))if(s instanceof o||null!=s?.constructor&&!0===s.constructor.__isActorComponent){if(i&&!s.constructor.__inEditor)continue;if(!i&&s.constructor.__onlyEditor)continue;const o=s;if(o.actor=c,n.has(o))continue;n.set(o,!0),await o.onInit(),r.push(initComponents(s,c,i))}return Promise.all(r)}
|
2
|
-
/*
|
1
|
+
import{ActorComponent as o}from"../component.js";const n=new WeakMap;export async function initComponents(t,c,i=!1){const r=[];for(const s of Object.values(t))if(s instanceof o||null!=s?.constructor&&!0===s.constructor.__isActorComponent){if(i&&!s.constructor.__inEditor)continue;if(!i&&s.constructor.__onlyEditor)continue;const o=s;if(o.actor=c,n.has(o))continue;n.set(o,!0),await o.onInit(),r.push(initComponents(s,c,i))}return Promise.all(r)}/*
|
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":"container-map.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/internal/container-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,eAAO,MAAM,eAAe,uCAA8C,CAAA;AAE1E,eAAO,MAAM,uBAAuB;;CAEnC,CAAA"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
export const containerRefMap=new WeakMap;export const activeContainerInstance={value:null}
|
2
|
-
/*
|
1
|
+
export const containerRefMap=new WeakMap;export const activeContainerInstance={value:null};/*
|
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":"bt.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/ai/behavior-tree/bt.ts"],"names":[],"mappings":"AAAA,8BAAsB,IAAI;IACxB;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CACrC;AAED,oBAAY,SAAS;IACnB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,8BAAsB,QAAS,SAAQ,IAAI;CAE1C;AAED,qBAAa,UAAW,SAAQ,QAAQ;IACtC,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,MAAM,SAAS;IAKnC,IAAI,IAAI,SAAS;CAGlB;AAED,qBAAa,WAAY,SAAQ,QAAQ;IACvC,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,MAAM,OAAO;IAKjC,IAAI,IAAI,SAAS;CAIlB;AAED,qBAAa,QAAS,SAAQ,QAAQ;IACpC,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,MAAM,OAAO;IAKjC,IAAI,IAAI,SAAS;CAIlB;AA8BD,qBAAa,aAAc,SAAQ,QAAQ;IACzC,OAAO,CAAC,SAAS,CAAe;gBAEpB,SAAS,EAAE,MAAM,OAAO;IAKpC,IAAI,IAAI,SAAS;CAGlB;AAED,8BAAsB,aAAc,SAAQ,IAAI;IAC9C,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAK;IAE/B,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAG3B;AAKD,qBAAa,YAAa,SAAQ,aAAa;IAC7C,OAAO,CAAC,OAAO,CAAY;IAC3B,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAoB3B,KAAK;CAGN;AAED,qBAAa,YAAa,SAAQ,aAAa;IAC7C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAS5B;AAED,8BAAsB,aAAc,SAAQ,IAAI;IAC9C,SAAS,CAAC,KAAK,EAAE,IAAI,CAAA;gBAET,KAAK,EAAE,IAAI;CAIxB;AAED,qBAAa,YAAa,SAAQ,aAAa;IAC7C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAS5B;AAED,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,OAAO,CAAY;gBAEf,KAAK,EAAE,IAAI,EAAE,KAAK,GAAE,MAAiB;IAKjD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAW5B;AAED,qBAAa,UAAW,SAAQ,aAAa;gBAC/B,KAAK,EAAE,IAAI;IAIvB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAI5B;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,SAAS,CAAe;gBAEpB,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;IAKjD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAU5B;AAED,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,KAAK,EAAE,IAAI;IAIvB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAO5B;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,aAAa;IAC1C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,OAAO,CAAsB;gBAEzB,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM;IAKtC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAe5B;AAWD;;;GAGG;AACH,qBAAa,cAAe,SAAQ,aAAa;IAC/C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,OAAO,CAAsB;gBAEzB,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM;IAKtC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAkB5B;AAED,qBAAa,QAAS,SAAQ,QAAQ;IAIxB,OAAO,CAAC,QAAQ;IAAU,OAAO,CAAC,QAAQ,CAAC;IAHvD,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,KAAK,CAAwB;gBAEjB,QAAQ,EAAE,MAAM,EAAU,QAAQ,CAAC,EAAE,MAAM;IAK/D,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAe3B,KAAK;CAON;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,aAAa;IAGpB,OAAO,CAAC,YAAY;IAF7C,OAAO,CAAC,iBAAiB,CAAsB;gBAEnC,KAAK,EAAE,IAAI,EAAU,YAAY,EAAE,MAAM;IAIrD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAgB5B;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,aAAa;IAC1C,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,SAAS,CAAsB;gBAE3B,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM;IAKzC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAa5B;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,aAAa;IAC3D,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,WAAW,CAAQ;gBAEf,OAAO,EAAE,MAAM,EAAE;IAM7B,OAAO,CAAC,cAAc;IAYtB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAI5B;AAED;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,aAAa;IAC1C,OAAO,CAAC,SAAS,CAAe;gBAEpB,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;IAKjD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAM5B;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAc5B;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAc5B;AAED,qBAAa,YAAa,SAAQ,aAAa;IACpB,OAAO,CAAC,QAAQ;gBAA7B,KAAK,EAAE,IAAI,EAAU,QAAQ,EAAE,MAAM;IAIjD,OAAO,CAAC,iBAAiB,CAAI;IAE7B,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAQ5B"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
export class Node{}export var NodeState;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILURE=1]="FAILURE",t[t.RUNNING=2]="RUNNING"}(NodeState||(NodeState={}));export class LeafNode extends Node{}export class ActionNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action()}}export class SuccessNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action(),NodeState.SUCCESS}}export class FailNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action(),NodeState.FAILURE}}export class ConditionNode extends LeafNode{constructor(t){super(),this.condition=t}tick(){return this.condition()?NodeState.SUCCESS:NodeState.FAILURE}}export class CompositeNode extends Node{constructor(){super(...arguments),this.children=[]}addChild(t){this.children.push(t)}}export class SequenceNode extends CompositeNode{constructor(){super(...arguments),this.current=0}tick(t){if(0===this.children.length)return this.reset(),NodeState.SUCCESS;const e=this.children[this.current].tick(t);if(e===NodeState.FAILURE)return this.reset(),NodeState.FAILURE;if(e===NodeState.SUCCESS){if(this.current==this.children.length-1)return this.reset(),NodeState.SUCCESS;this.current++}return NodeState.SUCCESS}reset(){this.current=0}}export class SelectorNode extends CompositeNode{tick(t){for(const e of this.children){const s=e.tick(t);if(s!==NodeState.FAILURE)return s}return NodeState.FAILURE}}export class DecoratorNode extends Node{constructor(t){super(),this.child=t}}export class InverterNode extends DecoratorNode{tick(t){const e=this.child.tick(t);return e===NodeState.SUCCESS?NodeState.FAILURE:e===NodeState.FAILURE?NodeState.SUCCESS:e}}export class RepeatTimesNode extends DecoratorNode{constructor(t,e=1/0){super(t),this.counter=0,this.limit=e}tick(t){for(;this.counter<this.limit;){if(this.child.tick(t)===NodeState.RUNNING)return NodeState.RUNNING;this.counter++}return this.counter=0,NodeState.SUCCESS}}export class RepeatNode extends DecoratorNode{constructor(t){super(t)}tick(t){return this.child.tick(t),NodeState.RUNNING}}export class RepeatUntilNode extends DecoratorNode{constructor(t,e){super(t),this.condition=e}tick(t){if(this.condition())return NodeState.SUCCESS;return this.child.tick(t)===NodeState.FAILURE?NodeState.FAILURE:NodeState.RUNNING}}export class RepeatUntilFailNode extends DecoratorNode{constructor(t){super(t)}tick(t){return this.child.tick(t)===NodeState.FAILURE?NodeState.FAILURE:NodeState.RUNNING}}export class DelayNode extends DecoratorNode{constructor(t,e){super(t),this.state=NodeState.RUNNING,this.elapsed=null,this.delay=e}tick(t){return null===this.elapsed&&(this.elapsed=0),this.elapsed+=1e3*t,this.elapsed>=this.delay&&(this.state=this.child.tick(t),this.state!==NodeState.RUNNING&&(this.elapsed=null)),this.state}}export class DelayAfterNode extends DecoratorNode{constructor(t,e){super(t),this.state=NodeState.RUNNING,this.elapsed=null,this.delay=e}tick(t){if(null==this.elapsed){if(this.state=this.child.tick(t),this.state===NodeState.RUNNING)return this.state;this.elapsed=0}return this.elapsed+=1e3*t,this.elapsed<this.delay?NodeState.RUNNING:(this.elapsed=null,this.state)}}export class WaitNode extends LeafNode{constructor(t,e){super(),this.delayMin=t,this.delayMax=e,this.elapsed=null,this.delay=this.delayMin,this.reset()}tick(t){return null===this.elapsed&&(this.elapsed=0),this.elapsed+=1e3*t,this.elapsed>=this.delay?(this.elapsed=null,this.reset(),NodeState.SUCCESS):NodeState.RUNNING}reset(){null!=this.delayMax?this.delay=(this.delayMax-this.delayMin)*Math.random()+this.delayMin:this.delay=this.delayMin}}export class CooldownNode extends DecoratorNode{constructor(t,e){super(t),this.cooldownTime=e,this.lastExecutionTime=null}tick(t){const e=Date.now();if(null===this.lastExecutionTime||e-this.lastExecutionTime>=this.cooldownTime){const s=this.child.tick(t);return s===NodeState.SUCCESS&&(this.lastExecutionTime=e),s}return NodeState.FAILURE}}export class TimerNode extends DecoratorNode{constructor(t,e){super(t),this.startTime=null,this.duration=e}tick(t){null===this.startTime&&(this.startTime=Date.now());return Date.now()-this.startTime<this.duration?this.child.tick(t):(this.startTime=null,NodeState.FAILURE)}}export class WeightedRandomSelectorNode extends CompositeNode{constructor(t){super(),this.weights=t,this.totalWeight=this.weights.reduce(((t,e)=>t+e),0)}getRandomIndex(){let t=Math.random()*this.totalWeight;for(let e=0;e<this.weights.length;e++)if(t-=this.weights[e],t<=0)return e;return this.weights.length-1}tick(t){const e=this.getRandomIndex();return this.children[e].tick(t)}}export class GuardNode extends DecoratorNode{constructor(t,e){super(t),this.condition=e}tick(t){return this.condition()?this.child.tick(t):NodeState.FAILURE}}export class ParallelSelectorNode extends CompositeNode{tick(t){let e=!0;for(const s of this.children){const i=s.tick(t);if(i===NodeState.SUCCESS)return NodeState.SUCCESS;i===NodeState.RUNNING&&(e=!1)}return e?NodeState.FAILURE:NodeState.RUNNING}}export class ParallelSequenceNode extends CompositeNode{tick(t){let e=!0;for(const s of this.children){const i=s.tick(t);if(i===NodeState.FAILURE)return NodeState.FAILURE;i===NodeState.RUNNING&&(e=!1)}return e?NodeState.SUCCESS:NodeState.RUNNING}}export class ThrottleNode extends DecoratorNode{constructor(t,e){super(t),this.duration=e,this.timeSinceLastTick=0}tick(t){return 0===this.timeSinceLastTick||this.timeSinceLastTick>this.duration?(this.timeSinceLastTick=t,this.child.tick(this.timeSinceLastTick)):(this.timeSinceLastTick+=t,NodeState.RUNNING)}}
|
2
|
-
/*
|
1
|
+
export class Node{}export var NodeState;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILURE=1]="FAILURE",t[t.RUNNING=2]="RUNNING"}(NodeState||(NodeState={}));export class LeafNode extends Node{}export class ActionNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action()}}export class SuccessNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action(),NodeState.SUCCESS}}export class FailNode extends LeafNode{constructor(t){super(),this.action=t}tick(){return this.action(),NodeState.FAILURE}}export class ConditionNode extends LeafNode{constructor(t){super(),this.condition=t}tick(){return this.condition()?NodeState.SUCCESS:NodeState.FAILURE}}export class CompositeNode extends Node{constructor(){super(...arguments),this.children=[]}addChild(t){this.children.push(t)}}export class SequenceNode extends CompositeNode{constructor(){super(...arguments),this.current=0}tick(t){if(0===this.children.length)return this.reset(),NodeState.SUCCESS;const e=this.children[this.current].tick(t);if(e===NodeState.FAILURE)return this.reset(),NodeState.FAILURE;if(e===NodeState.SUCCESS){if(this.current==this.children.length-1)return this.reset(),NodeState.SUCCESS;this.current++}return NodeState.SUCCESS}reset(){this.current=0}}export class SelectorNode extends CompositeNode{tick(t){for(const e of this.children){const s=e.tick(t);if(s!==NodeState.FAILURE)return s}return NodeState.FAILURE}}export class DecoratorNode extends Node{constructor(t){super(),this.child=t}}export class InverterNode extends DecoratorNode{tick(t){const e=this.child.tick(t);return e===NodeState.SUCCESS?NodeState.FAILURE:e===NodeState.FAILURE?NodeState.SUCCESS:e}}export class RepeatTimesNode extends DecoratorNode{constructor(t,e=1/0){super(t),this.counter=0,this.limit=e}tick(t){for(;this.counter<this.limit;){if(this.child.tick(t)===NodeState.RUNNING)return NodeState.RUNNING;this.counter++}return this.counter=0,NodeState.SUCCESS}}export class RepeatNode extends DecoratorNode{constructor(t){super(t)}tick(t){return this.child.tick(t),NodeState.RUNNING}}export class RepeatUntilNode extends DecoratorNode{constructor(t,e){super(t),this.condition=e}tick(t){if(this.condition())return NodeState.SUCCESS;return this.child.tick(t)===NodeState.FAILURE?NodeState.FAILURE:NodeState.RUNNING}}export class RepeatUntilFailNode extends DecoratorNode{constructor(t){super(t)}tick(t){return this.child.tick(t)===NodeState.FAILURE?NodeState.FAILURE:NodeState.RUNNING}}export class DelayNode extends DecoratorNode{constructor(t,e){super(t),this.state=NodeState.RUNNING,this.elapsed=null,this.delay=e}tick(t){return null===this.elapsed&&(this.elapsed=0),this.elapsed+=1e3*t,this.elapsed>=this.delay&&(this.state=this.child.tick(t),this.state!==NodeState.RUNNING&&(this.elapsed=null)),this.state}}export class DelayAfterNode extends DecoratorNode{constructor(t,e){super(t),this.state=NodeState.RUNNING,this.elapsed=null,this.delay=e}tick(t){if(null==this.elapsed){if(this.state=this.child.tick(t),this.state===NodeState.RUNNING)return this.state;this.elapsed=0}return this.elapsed+=1e3*t,this.elapsed<this.delay?NodeState.RUNNING:(this.elapsed=null,this.state)}}export class WaitNode extends LeafNode{constructor(t,e){super(),this.delayMin=t,this.delayMax=e,this.elapsed=null,this.delay=this.delayMin,this.reset()}tick(t){return null===this.elapsed&&(this.elapsed=0),this.elapsed+=1e3*t,this.elapsed>=this.delay?(this.elapsed=null,this.reset(),NodeState.SUCCESS):NodeState.RUNNING}reset(){null!=this.delayMax?this.delay=(this.delayMax-this.delayMin)*Math.random()+this.delayMin:this.delay=this.delayMin}}export class CooldownNode extends DecoratorNode{constructor(t,e){super(t),this.cooldownTime=e,this.lastExecutionTime=null}tick(t){const e=Date.now();if(null===this.lastExecutionTime||e-this.lastExecutionTime>=this.cooldownTime){const s=this.child.tick(t);return s===NodeState.SUCCESS&&(this.lastExecutionTime=e),s}return NodeState.FAILURE}}export class TimerNode extends DecoratorNode{constructor(t,e){super(t),this.startTime=null,this.duration=e}tick(t){null===this.startTime&&(this.startTime=Date.now());return Date.now()-this.startTime<this.duration?this.child.tick(t):(this.startTime=null,NodeState.FAILURE)}}export class WeightedRandomSelectorNode extends CompositeNode{constructor(t){super(),this.weights=t,this.totalWeight=this.weights.reduce(((t,e)=>t+e),0)}getRandomIndex(){let t=Math.random()*this.totalWeight;for(let e=0;e<this.weights.length;e++)if(t-=this.weights[e],t<=0)return e;return this.weights.length-1}tick(t){const e=this.getRandomIndex();return this.children[e].tick(t)}}export class GuardNode extends DecoratorNode{constructor(t,e){super(t),this.condition=e}tick(t){return this.condition()?this.child.tick(t):NodeState.FAILURE}}export class ParallelSelectorNode extends CompositeNode{tick(t){let e=!0;for(const s of this.children){const i=s.tick(t);if(i===NodeState.SUCCESS)return NodeState.SUCCESS;i===NodeState.RUNNING&&(e=!1)}return e?NodeState.FAILURE:NodeState.RUNNING}}export class ParallelSequenceNode extends CompositeNode{tick(t){let e=!0;for(const s of this.children){const i=s.tick(t);if(i===NodeState.FAILURE)return NodeState.FAILURE;i===NodeState.RUNNING&&(e=!1)}return e?NodeState.SUCCESS:NodeState.RUNNING}}export class ThrottleNode extends DecoratorNode{constructor(t,e){super(t),this.duration=e,this.timeSinceLastTick=0}tick(t){return 0===this.timeSinceLastTick||this.timeSinceLastTick>this.duration?(this.timeSinceLastTick=t,this.child.tick(this.timeSinceLastTick)):(this.timeSinceLastTick+=t,NodeState.RUNNING)}}/*
|
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":"move.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/ai/behavior-tree/move.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AA2B1C,qBAAa,mBAAoB,SAAQ,QAAQ;IAM7C,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,QAAQ;IANlB,4DAA4D;IACrD,YAAY,SAAM;IAClB,MAAM,EAAE,MAAM,OAAO,GAAC,IAAI,GAAC,SAAS,CAAA;gBAGjC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,0BAA0B;IAK9C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;CAgD5B"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{Vector3 as t}from"three";import{LeafNode as o,NodeState as e}from"./bt";import{clamp as n}from"../../../utils/math";export class CharacterMoveToNode extends o{constructor(t,o){super(),this.navigation=t,this.movement=o,this.distanceFrom=.5}tick(t){const o=this.movement.actor.object.position,c=null!=this.target?this.target():null;if(null==c)return this.movement.directionInput.vector.set(0,0),e.FAILURE;if(o.distanceTo(c)<this.distanceFrom)return this.movement.directionInput.vector.set(0,0),e.SUCCESS;const{success:m,path:a}=this.navigation.findPath(o,c);if(!m)return console.log("Move to: Failed to find path"),e.FAILURE;const h=a[1],l=i.subVectors(h,o);l.y=0,l.normalize(),this.movement.actor.object.getWorldDirection(r).normalize();const u=r.angleTo(l);s.crossVectors(r,l);const v=s.y<0?-u:u;return this.movement.rotationInput.rotation.y+=n(v,-.1,.1),this.movement.directionInput.togglePositiveY(!0),e.RUNNING}}const i=new t,r=new t,s=new t
|
2
|
-
/*
|
1
|
+
import{Vector3 as t}from"three";import{LeafNode as o,NodeState as e}from"./bt";import{clamp as n}from"../../../utils/math";export class CharacterMoveToNode extends o{constructor(t,o){super(),this.navigation=t,this.movement=o,this.distanceFrom=.5}tick(t){const o=this.movement.actor.object.position,c=null!=this.target?this.target():null;if(null==c)return this.movement.directionInput.vector.set(0,0),e.FAILURE;if(o.distanceTo(c)<this.distanceFrom)return this.movement.directionInput.vector.set(0,0),e.SUCCESS;const{success:m,path:a}=this.navigation.findPath(o,c);if(!m)return console.log("Move to: Failed to find path"),e.FAILURE;const h=a[1],l=i.subVectors(h,o);l.y=0,l.normalize(),this.movement.actor.object.getWorldDirection(r).normalize();const u=r.angleTo(l);s.crossVectors(r,l);const v=s.y<0?-u:u;return this.movement.rotationInput.rotation.y+=n(v,-.1,.1),this.movement.directionInput.togglePositiveY(!0),e.RUNNING}}const i=new t,r=new t,s=new t;/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|
@@ -48,3 +48,4 @@ export type BuildTileMeshResult = ({
|
|
48
48
|
};
|
49
49
|
export declare const buildTile: ({ positions, indices, navMeshBounds, recastConfig, tileX, tileY, tileBoundsMin, tileBoundsMax, keepIntermediates, }: BuildTileMeshProps) => BuildTileMeshResult;
|
50
50
|
export {};
|
51
|
+
//# sourceMappingURL=build-tile.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"build-tile.d.ts","sourceRoot":"","sources":["../../../src/gameplay/ai/build-tile.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EACjB,YAAY,EA4Bb,MAAM,yBAAyB,CAAA;AA+BhC,KAAK,gBAAgB,GAAG;IACtB,YAAY,EAAE,YAAY,CAAA;IAC1B,aAAa,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,CAAC,CAAA;CACtD,CAAA;AAED,eAAO,MAAM,WAAW,0EAA2E,gBAAgB;;;;;;;;;;;;;;CAiDlH,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,kBAAkB,CAAC,EAAE,wBAAwB,CAAA;IAC7C,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,EAAE,WAAW,CAAA;IACpB,YAAY,EAAE,YAAY,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,YAAY,CAAA;IAC3B,aAAa,EAAE,YAAY,CAAA;IAC3B,aAAa,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;IAC3C,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAC9B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAC3C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CACpC,GAAG;IACF,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,YAAY,EAAE,kBAAkB,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,SAAS,wHAUnB,kBAAkB,KAAG,mBA6SvB,CAAA"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import{NavMeshCreateParams as e,Raw as t,RecastBuildContext as i,TriangleAreasArray as l,TrianglesArray as o,VerticesArray as r,allocCompactHeightfield as a,allocContourSet as s,allocHeightfield as n,allocPolyMesh as d,allocPolyMeshDetail as c,buildCompactHeightfield as h,buildContours as g,buildDistanceField as m,buildPolyMesh as u,buildPolyMeshDetail as b,buildRegions as f,calcGridSize as S,cloneRcConfig as R,createHeightfield as w,createNavMeshData as p,createRcConfig as C,erodeWalkableArea as M,filterLedgeSpans as _,filterLowHangingWalkableObstacles as x,filterWalkableLowHeightSpans as A,freeCompactHeightfield as k,freeContourSet as y,freeHeightfield as z,markWalkableTriangles as E,rasterizeTriangles as v,vec3 as T}from"@recast-navigation/core";import{dtIlog2 as B,dtNextPow2 as O}from"@recast-navigation/generators";import*as P from"three";export const buildConfig=({recastConfig:e,navMeshBounds:[t,i]})=>{const l=C(e),o=S(t,i,l.cs);l.width=o.width,l.height=o.height,l.minRegionArea=l.minRegionArea*l.minRegionArea,l.mergeRegionArea=l.mergeRegionArea*l.mergeRegionArea,l.tileSize=Math.floor(l.tileSize),l.borderSize=l.walkableRadius+3,l.width=l.tileSize+2*l.borderSize,l.height=l.tileSize+2*l.borderSize,l.detailSampleDist=l.detailSampleDist<.9?0:l.cs*l.detailSampleDist,l.detailSampleMaxError=l.ch*l.detailSampleMaxError;const r=Math.floor(l.tileSize),a=Math.floor((o.width+r-1)/r),s=Math.floor((o.height+r-1)/r),n=l.tileSize*l.cs,d=T.fromArray(t);let c=Math.min(Math.floor(B(O(a*s))),14);c>14&&(c=14);const h=22-c;return{config:l,orig:d,tileBits:c,polyBits:h,maxTiles:1<<c,maxPolysPerTile:1<<h,tcs:n,tileWidth:a,tileHeight:s}};export const buildTile=({positions:S,indices:C,navMeshBounds:T,recastConfig:B,tileX:O,tileY:H,tileBoundsMin:L,tileBoundsMax:G,keepIntermediates:D})=>{const $=new i,F=S,V=C.length,W=new r;W.copy(F);const I=C,K=C.length/3;(new o).copy(I);const X={tileX:O,tileY:H},Y=()=>{D||(X.compactHeightfield&&k(X.compactHeightfield),X.heightfield&&z(X.heightfield),X.contourSet&&y(X.contourSet))},N=e=>($.log(t.Module.RC_LOG_ERROR,e),Y(),{success:!1,error:e,tileIntermediates:X,buildContext:$}),{config:U}=buildConfig({recastConfig:B,navMeshBounds:T}),j=R(U),q=[...L],J=[...G];q[0]-=j.borderSize*j.cs,q[2]-=j.borderSize*j.cs,J[0]+=j.borderSize*j.cs,J[2]+=j.borderSize*j.cs,j.set_bmin(0,q[0]),j.set_bmin(1,q[1]),j.set_bmin(2,q[2]),j.set_bmax(0,J[0]),j.set_bmax(1,J[1]),j.set_bmax(2,J[2]),$.resetTimers(),$.startTimer(t.Module.RC_TIMER_TOTAL),$.log(t.Module.RC_LOG_PROGRESS,`Building tile at x: ${O}, y: ${H}`),$.log(t.Module.RC_LOG_PROGRESS,` - ${U.width} x ${U.height} cells`),$.log(t.Module.RC_LOG_PROGRESS,` - ${V/1e3}fK verts, ${K/1e3}K tris`);const Q=n();if(X.heightfield=Q,!w($,Q,j.width,j.height,q,J,j.cs,j.ch))return N("Could not create heightfield");const Z=((e,t,i)=>{const l=[],o=new P.Vector3,r=new P.Vector3,a=new P.Vector3,s=new P.Triangle;for(let n=0;n<t.length;n+=3){const d=t[n],c=t[n+1],h=t[n+2];o.fromArray(e,3*d),r.fromArray(e,3*c),a.fromArray(e,3*h),s.set(o,r,a),s.intersectsBox(i)&&l.push(d,c,h)}return l})(S,C,new P.Box3(new P.Vector3(q[0],q[1],q[2]),new P.Vector3(J[0],J[1],J[2]))),ee=Z.length/3,te=new o;te.copy(Z);const ie=new l;ie.resize(ee),E($,j.walkableSlopeAngle,W,V,te,ee,ie);const le=v($,W,V,te,ie,ee,Q,j.walkableClimb);if(ie.destroy(),!le)return N("Could not rasterize triangles");x($,j.walkableClimb,Q),_($,j.walkableHeight,j.walkableClimb,Q),A($,j.walkableHeight,Q);const oe=a();if(X.compactHeightfield=oe,!h($,j.walkableHeight,j.walkableClimb,Q,oe))return N("Could not build compact heightfield");if(D||(z(X.heightfield),X.heightfield=void 0),!M($,j.walkableRadius,oe))return N("Could not erode walkable area");if(!m($,oe))return N("Failed to build distance field");if(!f($,oe,j.borderSize,j.minRegionArea,j.mergeRegionArea))return N("Failed to build regions");const re=s();if(X.contourSet=re,!g($,oe,j.maxSimplificationError,j.maxEdgeLen,re,t.Module.RC_CONTOUR_TESS_WALL_EDGES))return N("Failed to create contours");const ae=d();if(!u($,re,j.maxVertsPerPoly,ae))return N("Failed to triangulate contours");const se=c();if(!b($,ae,oe,j.detailSampleDist,j.detailSampleMaxError,se))return N("Failed to build detail mesh");D||(k(oe),X.compactHeightfield=void 0,y(re),X.contourSet=void 0);for(let e=0;e<ae.npolys();e++)ae.areas(e)==t.Recast.WALKABLE_AREA&&ae.setAreas(e,0),0==ae.areas(e)&&ae.setFlags(e,1);const ne=new e;ne.setPolyMeshCreateParams(ae),ne.setPolyMeshDetailCreateParams(se),ne.setWalkableHeight(j.walkableHeight),ne.setWalkableRadius(j.walkableRadius),ne.setWalkableClimb(j.walkableClimb),ne.setCellSize(j.cs),ne.setCellHeight(j.ch),ne.setBuildBvTree(!0),ne.setTileX(O),ne.setTileY(H);const de=p(ne);return de.success?($.log(t.Module.RC_LOG_PROGRESS,`>> Polymesh: ${ae.nverts()} vertices ${ae.npolys()} polygons`),Y(),{success:!0,data:de.navMeshData,tileIntermediates:X,buildContext:$}):N("Failed to create Detour navmesh data")}
|
2
|
-
/*
|
1
|
+
import{NavMeshCreateParams as e,Raw as t,RecastBuildContext as i,TriangleAreasArray as l,TrianglesArray as o,VerticesArray as r,allocCompactHeightfield as a,allocContourSet as s,allocHeightfield as n,allocPolyMesh as d,allocPolyMeshDetail as c,buildCompactHeightfield as h,buildContours as g,buildDistanceField as m,buildPolyMesh as u,buildPolyMeshDetail as b,buildRegions as f,calcGridSize as S,cloneRcConfig as R,createHeightfield as w,createNavMeshData as p,createRcConfig as C,erodeWalkableArea as M,filterLedgeSpans as _,filterLowHangingWalkableObstacles as x,filterWalkableLowHeightSpans as A,freeCompactHeightfield as k,freeContourSet as y,freeHeightfield as z,markWalkableTriangles as E,rasterizeTriangles as v,vec3 as T}from"@recast-navigation/core";import{dtIlog2 as B,dtNextPow2 as O}from"@recast-navigation/generators";import*as P from"three";export const buildConfig=({recastConfig:e,navMeshBounds:[t,i]})=>{const l=C(e),o=S(t,i,l.cs);l.width=o.width,l.height=o.height,l.minRegionArea=l.minRegionArea*l.minRegionArea,l.mergeRegionArea=l.mergeRegionArea*l.mergeRegionArea,l.tileSize=Math.floor(l.tileSize),l.borderSize=l.walkableRadius+3,l.width=l.tileSize+2*l.borderSize,l.height=l.tileSize+2*l.borderSize,l.detailSampleDist=l.detailSampleDist<.9?0:l.cs*l.detailSampleDist,l.detailSampleMaxError=l.ch*l.detailSampleMaxError;const r=Math.floor(l.tileSize),a=Math.floor((o.width+r-1)/r),s=Math.floor((o.height+r-1)/r),n=l.tileSize*l.cs,d=T.fromArray(t);let c=Math.min(Math.floor(B(O(a*s))),14);c>14&&(c=14);const h=22-c;return{config:l,orig:d,tileBits:c,polyBits:h,maxTiles:1<<c,maxPolysPerTile:1<<h,tcs:n,tileWidth:a,tileHeight:s}};export const buildTile=({positions:S,indices:C,navMeshBounds:T,recastConfig:B,tileX:O,tileY:H,tileBoundsMin:L,tileBoundsMax:G,keepIntermediates:D})=>{const $=new i,F=S,V=C.length,W=new r;W.copy(F);const I=C,K=C.length/3;(new o).copy(I);const X={tileX:O,tileY:H},Y=()=>{D||(X.compactHeightfield&&k(X.compactHeightfield),X.heightfield&&z(X.heightfield),X.contourSet&&y(X.contourSet))},N=e=>($.log(t.Module.RC_LOG_ERROR,e),Y(),{success:!1,error:e,tileIntermediates:X,buildContext:$}),{config:U}=buildConfig({recastConfig:B,navMeshBounds:T}),j=R(U),q=[...L],J=[...G];q[0]-=j.borderSize*j.cs,q[2]-=j.borderSize*j.cs,J[0]+=j.borderSize*j.cs,J[2]+=j.borderSize*j.cs,j.set_bmin(0,q[0]),j.set_bmin(1,q[1]),j.set_bmin(2,q[2]),j.set_bmax(0,J[0]),j.set_bmax(1,J[1]),j.set_bmax(2,J[2]),$.resetTimers(),$.startTimer(t.Module.RC_TIMER_TOTAL),$.log(t.Module.RC_LOG_PROGRESS,`Building tile at x: ${O}, y: ${H}`),$.log(t.Module.RC_LOG_PROGRESS,` - ${U.width} x ${U.height} cells`),$.log(t.Module.RC_LOG_PROGRESS,` - ${V/1e3}fK verts, ${K/1e3}K tris`);const Q=n();if(X.heightfield=Q,!w($,Q,j.width,j.height,q,J,j.cs,j.ch))return N("Could not create heightfield");const Z=((e,t,i)=>{const l=[],o=new P.Vector3,r=new P.Vector3,a=new P.Vector3,s=new P.Triangle;for(let n=0;n<t.length;n+=3){const d=t[n],c=t[n+1],h=t[n+2];o.fromArray(e,3*d),r.fromArray(e,3*c),a.fromArray(e,3*h),s.set(o,r,a),s.intersectsBox(i)&&l.push(d,c,h)}return l})(S,C,new P.Box3(new P.Vector3(q[0],q[1],q[2]),new P.Vector3(J[0],J[1],J[2]))),ee=Z.length/3,te=new o;te.copy(Z);const ie=new l;ie.resize(ee),E($,j.walkableSlopeAngle,W,V,te,ee,ie);const le=v($,W,V,te,ie,ee,Q,j.walkableClimb);if(ie.destroy(),!le)return N("Could not rasterize triangles");x($,j.walkableClimb,Q),_($,j.walkableHeight,j.walkableClimb,Q),A($,j.walkableHeight,Q);const oe=a();if(X.compactHeightfield=oe,!h($,j.walkableHeight,j.walkableClimb,Q,oe))return N("Could not build compact heightfield");if(D||(z(X.heightfield),X.heightfield=void 0),!M($,j.walkableRadius,oe))return N("Could not erode walkable area");if(!m($,oe))return N("Failed to build distance field");if(!f($,oe,j.borderSize,j.minRegionArea,j.mergeRegionArea))return N("Failed to build regions");const re=s();if(X.contourSet=re,!g($,oe,j.maxSimplificationError,j.maxEdgeLen,re,t.Module.RC_CONTOUR_TESS_WALL_EDGES))return N("Failed to create contours");const ae=d();if(!u($,re,j.maxVertsPerPoly,ae))return N("Failed to triangulate contours");const se=c();if(!b($,ae,oe,j.detailSampleDist,j.detailSampleMaxError,se))return N("Failed to build detail mesh");D||(k(oe),X.compactHeightfield=void 0,y(re),X.contourSet=void 0);for(let e=0;e<ae.npolys();e++)ae.areas(e)==t.Recast.WALKABLE_AREA&&ae.setAreas(e,0),0==ae.areas(e)&&ae.setFlags(e,1);const ne=new e;ne.setPolyMeshCreateParams(ae),ne.setPolyMeshDetailCreateParams(se),ne.setWalkableHeight(j.walkableHeight),ne.setWalkableRadius(j.walkableRadius),ne.setWalkableClimb(j.walkableClimb),ne.setCellSize(j.cs),ne.setCellHeight(j.ch),ne.setBuildBvTree(!0),ne.setTileX(O),ne.setTileY(H);const de=p(ne);return de.success?($.log(t.Module.RC_LOG_PROGRESS,`>> Polymesh: ${ae.nverts()} vertices ${ae.npolys()} polygons`),Y(),{success:!0,data:de.navMeshData,tileIntermediates:X,buildContext:$}):N("Failed to create Detour navmesh data")};/*
|
3
2
|
* Copyright (©) 2023. All rights reserved.
|
4
3
|
* See the LICENSE.md file for details.
|
5
4
|
*/
|