@hology/core 0.0.234 → 0.0.235
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/csm.d.ts +2 -2
- package/dist/data/surface-definition.js +1 -1
- package/dist/effects/sequence/sequence-action.d.ts +4 -4
- package/dist/effects/sequence/sequence-animation-retiming.d.ts +1 -1
- package/dist/effects/sequence/sequence-data.d.ts +3 -2
- package/dist/effects/sequence/sequence-definitions.d.ts +2 -2
- package/dist/effects/sequence/sequence-event.d.ts +1 -1
- package/dist/effects/sequence/sequence-locator.d.ts +1 -1
- package/dist/effects/sequence/sequence-ops.d.ts +1 -1
- package/dist/effects/sequence/sequence-player.d.ts +8 -7
- package/dist/effects/sequence/sequence-transform.d.ts +1 -1
- package/dist/effects/sequence/sequence-value-lane.d.ts +2 -2
- package/dist/effects/vfx/behaviours.d.ts +2 -1
- package/dist/effects/vfx/initializsers.d.ts +2 -1
- package/dist/effects/vfx/rates.d.ts +1 -1
- package/dist/effects/vfx/trail-renderer.d.ts +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +4 -3
- package/dist/effects/vfx/vfx-binding-runtime.d.ts +2 -2
- package/dist/effects/vfx/vfx-collision-behaviour.d.ts +3 -2
- package/dist/effects/vfx/vfx-defs.d.ts +5 -3
- package/dist/effects/vfx/vfx-input-runtime.d.ts +1 -1
- package/dist/effects/vfx/vfx-materializer.d.ts +7 -7
- package/dist/effects/vfx/vfx-param.d.ts +3 -3
- package/dist/effects/vfx/vfx-renderers.d.ts +4 -3
- package/dist/effects/vfx/vfx-renderers.js +1 -1
- package/dist/effects/vfx/vfx-service.d.ts +1 -1
- package/dist/effects/vfx/vfx-service.js +1 -1
- package/dist/game-component/game-component.d.ts +1 -1
- package/dist/gameplay/actors/builtin/components/editor-sprite-component.d.ts +1 -1
- package/dist/gameplay/actors/builtin/components/editor-sprite-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/volume-editor-component.d.ts +1 -1
- package/dist/gameplay/actors/builtin/components/volume-editor-component.js +1 -1
- package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +1 -1
- package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
- package/dist/gameplay/actors/builtin/post-process-volume-actor.d.ts +1 -1
- package/dist/gameplay/actors/builtin/post-process-volume-actor.js +1 -1
- package/dist/gameplay/actors/component.d.ts +2 -2
- package/dist/gameplay/actors/controller/actor-controller.d.ts +1 -1
- package/dist/gameplay/actors/controller/actor-controller.js +1 -1
- package/dist/gameplay/actors/internal/component-init.d.ts +1 -1
- package/dist/gameplay/actors/internal/container-map.d.ts +2 -2
- package/dist/gameplay/ai/behavior-tree/move.d.ts +3 -3
- package/dist/gameplay/ai/behavior-tree/move.js +1 -1
- package/dist/gameplay/ai/build-tile.d.ts +2 -1
- package/dist/gameplay/ai/dynamic-tiled-navmesh.d.ts +4 -3
- package/dist/gameplay/ai/navigation.js +1 -1
- package/dist/gameplay/animation/anim-sm.d.ts +1 -1
- package/dist/gameplay/animation/retarget.d.ts +2 -1
- package/dist/gameplay/animation/root-motion.d.ts +2 -1
- package/dist/gameplay/event-graph/runtime-assets.d.ts +1 -1
- package/dist/gameplay/initiate.d.ts +5 -5
- package/dist/gameplay/inject.d.ts +1 -1
- package/dist/gameplay/net/browser/index.d.ts +3 -2
- package/dist/gameplay/net/browser/index.js +1 -1
- package/dist/gameplay/net/net-session.d.ts +2 -2
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/game-time-scheduler.d.ts +1 -1
- package/dist/gameplay/services/physics/abstract-physics-system.d.ts +7 -7
- package/dist/gameplay/services/pointer-events.d.ts +2 -2
- package/dist/gameplay/services/pointer-events.js +1 -1
- package/dist/gameplay/services/world.d.ts +1 -1
- package/dist/gameplay/services/world.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/rendering/cluster-generator.d.ts +2 -1
- package/dist/rendering/fog/fog-volume-actor.d.ts +1 -1
- package/dist/rendering/fog/fog-volume-actor.js +1 -1
- package/dist/rendering/fog/fog-volume-object.d.ts +2 -1
- package/dist/rendering/fog/volumetric-fog-pass.d.ts +4 -2
- package/dist/rendering/fog/volumetric-fog-pass.js +1 -1
- package/dist/rendering/light-probes/light-volume-capture.d.ts +2 -1
- package/dist/rendering/motion-vector-node.d.ts +2 -1
- package/dist/rendering/node-material-webgpu-resolver.d.ts +2 -1
- package/dist/rendering/post-process-effect.d.ts +1 -1
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +5 -4
- package/dist/scene/assets-provider.d.ts +2 -2
- package/dist/scene/batched-mesh-2.d.ts +1 -1
- package/dist/scene/bootstrap.d.ts +8 -7
- package/dist/scene/collision/collision-shape-import.d.ts +3 -3
- package/dist/scene/collision/collision-shape.d.ts +2 -1
- package/dist/scene/custom-param-deserialize.d.ts +1 -1
- package/dist/scene/custom-param-runtime-types.d.ts +2 -1
- package/dist/scene/landscape/landscape-manager.d.ts +6 -6
- package/dist/scene/landscape/landscape-manager.js +1 -1
- package/dist/scene/landscape/utils.d.ts +2 -2
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/materials/grass-foliage.d.ts +2 -2
- package/dist/scene/materials/grass.d.ts +1 -1
- package/dist/scene/materials/utils/material-painting.d.ts +2 -1
- package/dist/scene/materials/water.d.ts +1 -1
- package/dist/scene/model.d.ts +1 -1
- package/dist/scene/objects/prefab.d.ts +3 -3
- package/dist/scene/objects/shapes.d.ts +4 -2
- package/dist/scene/runtime-asset-service.d.ts +2 -2
- package/dist/scene/runtime-backend-service.d.ts +2 -2
- package/dist/scene/runtime-bundled-backend-service.d.ts +3 -3
- package/dist/scene/scatter/painted-scatter-manager.d.ts +1 -1
- package/dist/scene/scatter/surface-scatter-manager.d.ts +4 -4
- package/dist/scene/scene-data-service.d.ts +1 -1
- package/dist/scene/surface-query.d.ts +2 -2
- package/dist/scene/surface-query.js +1 -1
- package/dist/shader/builtin/decal-unlit-shader.js +1 -1
- package/dist/shader/builtin/index.d.ts +1 -1
- package/dist/shader/decal-shader.d.ts +3 -2
- package/dist/shader/graph/compiler.d.ts +1 -1
- package/dist/shader/parameter.d.ts +8 -8
- package/dist/shader/post-process-shader.d.ts +2 -1
- package/dist/shader/shader.d.ts +6 -5
- package/dist/shader/trail-shader.d.ts +3 -2
- package/dist/shader/trail-shader.js +1 -1
- package/dist/shader/uv-nodes.d.ts +2 -2
- package/dist/shader-nodes/bulge.d.ts +1 -1
- package/dist/shader-nodes/curve-sample.d.ts +2 -2
- package/dist/shader-nodes/depth.d.ts +3 -3
- package/dist/shader-nodes/dither.d.ts +1 -1
- package/dist/shader-nodes/effects.d.ts +1 -1
- package/dist/shader-nodes/glsl-node.d.ts +1 -1
- package/dist/shader-nodes/gradient-sample.d.ts +1 -1
- package/dist/shader-nodes/landscape.d.ts +1 -1
- package/dist/shader-nodes/layers.d.ts +1 -1
- package/dist/shader-nodes/material-flags.d.ts +1 -1
- package/dist/shader-nodes/particle.d.ts +1 -1
- package/dist/shader-nodes/pom.d.ts +2 -1
- package/dist/shader-nodes/pom.js +1 -1
- package/dist/shader-nodes/scene-sample.d.ts +2 -1
- package/dist/shader-nodes/shapes.d.ts +1 -1
- package/dist/shader-nodes/texture-sequence.d.ts +1 -1
- package/dist/shader-nodes/time.d.ts +1 -1
- package/dist/shader-nodes/voronoi.d.ts +1 -1
- package/dist/shader-nodes/wgsl-node.d.ts +1 -1
- package/dist/utils/materials.d.ts +1 -1
- package/dist/utils/mesh.d.ts +1 -1
- package/dist/utils/obb-utils.d.ts +2 -1
- package/dist/utils/three/cleanup.d.ts +1 -1
- package/dist/utils/three/depth-pass.d.ts +1 -1
- package/dist/utils/three/traverse.d.ts +2 -1
- package/dist/worker/index.js +1 -1
- package/package.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/csm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as r}from"tslib";import{DataAssetDefinition as s}from"../shader";let t=class{};t=r([s("base.surface",{abstract:!0})],t);export{t as BaseSurfaceDefinition};/*
|
|
1
|
+
import{__decorate as r}from"tslib";import{DataAssetDefinition as s}from"../shader/index.js";let t=class{};t=r([s("base.surface",{abstract:!0})],t);export{t as BaseSurfaceDefinition};/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SequenceRole } from './sequence-data.js';
|
|
2
|
-
import { BaseActor } from '../../gameplay/actors/actor.js';
|
|
3
|
-
import { Object3D } from 'three';
|
|
4
|
-
import { SequenceLocatorReader } from './sequence-locator.js';
|
|
1
|
+
import type { SequenceRole } from './sequence-data.js';
|
|
2
|
+
import type { BaseActor } from '../../gameplay/actors/actor.js';
|
|
3
|
+
import type { Object3D } from 'three';
|
|
4
|
+
import type { SequenceLocatorReader } from './sequence-locator.js';
|
|
5
5
|
import type { Observable } from 'rxjs';
|
|
6
6
|
/**
|
|
7
7
|
* SequenceAction is used to play, pause, stop, etc. a sequence.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { AnimationClipInstance, AnimationClipRetiming, AnimationClipRetimingMode, AnimationClipRetimingPoint } from './sequence-data.js';
|
|
2
|
+
import type { AnimationClipInstance, AnimationClipRetiming, AnimationClipRetimingMode, AnimationClipRetimingPoint } from './sequence-data.js';
|
|
3
3
|
export declare const MAX_ANIMATION_CLIP_RETIME_POINTS = 3;
|
|
4
4
|
export interface AnimationClipRetimingControlPoint extends AnimationClipRetimingPoint {
|
|
5
5
|
implicit: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AssetId, CustomParamValue
|
|
2
|
-
import {
|
|
1
|
+
import type { AssetId, CustomParamValue } from '../../scene/model.js';
|
|
2
|
+
import { SerializedParamType } from '../../scene/model.js';
|
|
3
|
+
import type { AudioParameterId } from './audio-parameters.js';
|
|
3
4
|
import type { CameraShakeSettings } from '../../gameplay/services/camera-shake.js';
|
|
4
5
|
import type { PostProcessEffectStage } from '../../rendering/post-process-effect.js';
|
|
5
6
|
export interface SequencePropertyOption {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnimationClipInstance, PropertySubTrackOptions, MaterialSubTrackOptions, SequenceTrack, SequenceTrackType, SubTrack, SubTrackType } from './sequence-data.js';
|
|
2
|
-
import { AudioParameterId } from './audio-parameters.js';
|
|
1
|
+
import type { AnimationClipInstance, PropertySubTrackOptions, MaterialSubTrackOptions, SequenceTrack, SequenceTrackType, SubTrack, SubTrackType } from './sequence-data.js';
|
|
2
|
+
import type { AudioParameterId } from './audio-parameters.js';
|
|
3
3
|
import { SerializedParamType } from '../../scene/model.js';
|
|
4
4
|
export type SequenceTrackRuntimeEvaluator = 'object' | 'locator' | 'camera' | 'cameraShake' | 'postProcess' | 'audio' | 'vfx' | 'spawn' | 'group';
|
|
5
5
|
export type SequenceSubTrackRuntimeEvaluator = 'transform' | 'animation' | 'visibility' | 'parameter' | 'event';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import type { ParameterOptions, ParameterType, PropertyParameter } from '../../shader/parameter.js';
|
|
3
|
-
import { Type } from '../../utils/type.js';
|
|
3
|
+
import type { Type } from '../../utils/type.js';
|
|
4
4
|
/**
|
|
5
5
|
* Metadata about a sequence event method on an actor
|
|
6
6
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimationClipInstance, PropertyKeyframe, SequenceData, SequenceEventData, SequenceTrack, SubTrack, SubTrackType, TransformKeyframe, VisibilityKeyframe } from './sequence-data.js';
|
|
1
|
+
import type { AnimationClipInstance, PropertyKeyframe, SequenceData, SequenceEventData, SequenceTrack, SubTrack, SubTrackType, TransformKeyframe, VisibilityKeyframe } from './sequence-data.js';
|
|
2
2
|
export interface SequenceTrackReference {
|
|
3
3
|
trackId: string;
|
|
4
4
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
-
import { AnimationAction
|
|
4
|
-
import {
|
|
3
|
+
import type { AnimationAction } from 'three';
|
|
4
|
+
import { AnimationMixer, Euler, Object3D, Vector3 } from 'three';
|
|
5
|
+
import type { VfxService } from '../../effects/vfx/vfx-service.js';
|
|
5
6
|
import { BaseActor } from '../../gameplay/actors/actor.js';
|
|
6
|
-
import { ActorFactory } from '../../gameplay/actors/factory.js';
|
|
7
|
-
import { AssetLoader } from '../../gameplay/services/asset-loader.js';
|
|
7
|
+
import type { ActorFactory } from '../../gameplay/actors/factory.js';
|
|
8
|
+
import type { AssetLoader } from '../../gameplay/services/asset-loader.js';
|
|
8
9
|
import type { World } from '../../gameplay/services/world.js';
|
|
9
|
-
import { PrefabInstance } from '../../scene/objects/prefab.js';
|
|
10
|
-
import { SequenceData, SequenceRole, SequenceTrack } from './sequence-data.js';
|
|
11
|
-
import { SequenceLocatorReader, SequenceLocatorSnapshot } from './sequence-locator.js';
|
|
10
|
+
import type { PrefabInstance } from '../../scene/objects/prefab.js';
|
|
11
|
+
import type { SequenceData, SequenceRole, SequenceTrack } from './sequence-data.js';
|
|
12
|
+
import type { SequenceLocatorReader, SequenceLocatorSnapshot } from './sequence-locator.js';
|
|
12
13
|
import { CharacterAnimationComponent } from '../../gameplay/actors/index.js';
|
|
13
14
|
import type { ViewController } from '../../gameplay/services/render.js';
|
|
14
15
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Vector3 } from 'three';
|
|
2
|
-
import { TransformKeyframe } from './sequence-data.js';
|
|
2
|
+
import type { TransformKeyframe } from './sequence-data.js';
|
|
3
3
|
export type TransformPositionTangentDirection = 'in' | 'out';
|
|
4
4
|
/** Evaluates transform position keys without allocating in the playback path. */
|
|
5
5
|
export declare function evaluateTransformPosition(keyframes: readonly TransformKeyframe[], time: number, target: Vector3): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CustomParamValue } from '../../scene/model.js';
|
|
2
|
-
import { InterpolationMode, PropertyKeyframe } from './sequence-data.js';
|
|
1
|
+
import type { CustomParamValue } from '../../scene/model.js';
|
|
2
|
+
import type { InterpolationMode, PropertyKeyframe } from './sequence-data.js';
|
|
3
3
|
export interface TimedSequenceItem {
|
|
4
4
|
time: number;
|
|
5
5
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import type { Emitter, Particle } from "@hology/nebula";
|
|
3
|
+
import { Behaviour } from "@hology/nebula";
|
|
3
4
|
import * as THREE from 'three';
|
|
4
5
|
export type EasingFunction = (x: number) => number;
|
|
5
6
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Vector3, Color } from "three";
|
|
2
|
-
import { Emitter, Particle
|
|
2
|
+
import type { Emitter, Particle } from "@hology/nebula";
|
|
3
|
+
import { Initializer } from "@hology/nebula";
|
|
3
4
|
export declare class DefaultInitializer extends Initializer {
|
|
4
5
|
init(emitter: Emitter, particle: Particle): void;
|
|
5
6
|
initialize(target: Emitter | Particle): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import { NodeShaderMaterial } from 'three-shader-graph';
|
|
3
|
-
import { OutputTextureSetting } from '../../gameplay';
|
|
3
|
+
import type { OutputTextureSetting } from '../../gameplay/index.js';
|
|
4
4
|
export declare const trailUV: import("three-shader-graph").Vec2Node;
|
|
5
5
|
export declare const trailDragUV: import("three-shader-graph").Vec2Node;
|
|
6
6
|
export declare class Trail extends THREE.Object3D {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { LibraryShapeType } from '../../scene/objects/shapes.js';
|
|
2
|
-
import { AssetId, CustomParamValue
|
|
3
|
-
import {
|
|
1
|
+
import type { LibraryShapeType } from '../../scene/objects/shapes.js';
|
|
2
|
+
import type { AssetId, CustomParamValue } from '../../scene/model.js';
|
|
3
|
+
import { SerializedParamType } from '../../scene/model.js';
|
|
4
|
+
import type { LibraryVfxBehaviourType, LibraryVfxInitalizerType } from './vfx-defs.js';
|
|
4
5
|
export type OnceRateData = {
|
|
5
6
|
type: 'once';
|
|
6
7
|
count: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Behaviour, Initializer } from "@hology/nebula";
|
|
2
|
-
import { CustomParamValue } from "../../scene/model.js";
|
|
3
|
-
import { VfxInputRuntime } from "./vfx-input-runtime.js";
|
|
2
|
+
import type { CustomParamValue } from "../../scene/model.js";
|
|
3
|
+
import type { VfxInputRuntime } from "./vfx-input-runtime.js";
|
|
4
4
|
export type VfxBindingMode = 'spawn' | 'live';
|
|
5
5
|
export type VfxBindableParameterType = 'number' | 'color' | 'string' | 'select' | 'vec2' | 'vec3' | 'curve' | 'animationclip' | 'boolean';
|
|
6
6
|
export type VfxBindableParameterDefinition = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Particle } from "@hology/nebula";
|
|
2
|
+
import { Behaviour, Emitter } from "@hology/nebula";
|
|
3
|
+
import type { PhysicsSystem } from "../../gameplay/services/physics/physics-system.js";
|
|
3
4
|
export declare class WorldCollisionBehaviour extends Behaviour {
|
|
4
5
|
private physics;
|
|
5
6
|
private bounce;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { AnimationClip
|
|
2
|
-
import {
|
|
1
|
+
import type { AnimationClip } from "three";
|
|
2
|
+
import { Vector2, Vector3 } from "three";
|
|
3
|
+
import type { Behaviour, Initializer } from "@hology/nebula";
|
|
4
|
+
import { Alpha, Attraction, Color as ChangeColor, Force, Gravity, Life, Mass, Position, RadialVelocity, RandomDrift, Repulsion, Rotate } from "@hology/nebula";
|
|
3
5
|
import { Disperse, FollowParent, LinearDamping, MoveOverLife, RotatePosition, Scale, ScaleComponents } from './behaviours.js';
|
|
4
6
|
import { AdditiveVelocity, InitialScale, InitialScaleComponents, RandomColor, RandomDirection, RandomScale, Rotation } from './initializsers.js';
|
|
5
7
|
import { Curve2 } from "../../utils/curve.js";
|
|
6
|
-
import { VfxBindingAdapter, VfxBindingMode, VfxBoundBehaviourDefinition, VfxBoundInitializerDefinition } from "./vfx-binding-runtime.js";
|
|
8
|
+
import type { VfxBindingAdapter, VfxBindingMode, VfxBoundBehaviourDefinition, VfxBoundInitializerDefinition } from "./vfx-binding-runtime.js";
|
|
7
9
|
type HexColor = `#${string}`;
|
|
8
10
|
export type ShapeParameterDef<T = boolean | number | string | Vector3 | Vector2 | HexColor | Curve2 | AnimationClip> = {
|
|
9
11
|
type: T extends number ? 'number' : T extends HexColor ? 'color' : T extends string ? 'string' | 'select' : T extends Vector2 ? 'vec2' : T extends Vector3 ? 'vec3' : T extends Curve2 ? 'curve' : T extends AnimationClip ? 'animationclip' : T extends boolean ? 'boolean' : never;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import System from "@hology/nebula";
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { Object3D } from "three";
|
|
4
|
-
import { PhysicsSystem } from '../../gameplay/services/physics/physics-system.js';
|
|
5
|
-
import { ViewController } from '../../gameplay/services/render.js';
|
|
6
|
-
import { Asset, VfxAsset } from '../../scene/model.js';
|
|
7
|
-
import { ShaderProvider } from "../../gameplay/services/shader-provider.js";
|
|
8
|
-
import { AssetResourceLoader } from "../../scene/asset-resource-loader.js";
|
|
9
|
-
import { AssetsProvider } from "../../scene/assets-provider.js";
|
|
10
|
-
import { VfxInputRuntime } from "./vfx-input-runtime.js";
|
|
4
|
+
import type { PhysicsSystem } from '../../gameplay/services/physics/physics-system.js';
|
|
5
|
+
import type { ViewController } from '../../gameplay/services/render.js';
|
|
6
|
+
import type { Asset, VfxAsset } from '../../scene/model.js';
|
|
7
|
+
import type { ShaderProvider } from "../../gameplay/services/shader-provider.js";
|
|
8
|
+
import type { AssetResourceLoader } from "../../scene/asset-resource-loader.js";
|
|
9
|
+
import type { AssetsProvider } from "../../scene/assets-provider.js";
|
|
10
|
+
import type { VfxInputRuntime } from "./vfx-input-runtime.js";
|
|
11
11
|
export type VfxAssetProvider = {
|
|
12
12
|
getAsset(assetId: string): Promise<Asset>;
|
|
13
13
|
getTexture(assetId: string): Promise<THREE.Texture>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VfxActor } from './vfx-actor.js';
|
|
2
|
-
import { ActorProvider } from "../../scene/materializer.js";
|
|
3
|
-
import { VfxAsset } from "../../scene/model.js";
|
|
4
|
-
import { Object3D } from 'three';
|
|
2
|
+
import type { ActorProvider } from "../../scene/materializer.js";
|
|
3
|
+
import type { VfxAsset } from "../../scene/model.js";
|
|
4
|
+
import type { Object3D } from 'three';
|
|
5
5
|
import { BaseActor } from '../../gameplay/actors/actor.js';
|
|
6
6
|
export declare class VisualEffect {
|
|
7
7
|
private actorProvider;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Particle } from '@hology/nebula';
|
|
2
|
+
import { CustomRenderer, MeshRenderer } from '@hology/nebula';
|
|
2
3
|
import * as THREE from 'three';
|
|
3
4
|
import { Object3D } from 'three';
|
|
4
|
-
import { ViewController } from '../../gameplay/services/render.js';
|
|
5
|
-
import { OutputTextureSetting } from './vfx-asset.js';
|
|
5
|
+
import type { ViewController } from '../../gameplay/services/render.js';
|
|
6
|
+
import type { OutputTextureSetting } from './vfx-asset.js';
|
|
6
7
|
export declare class MultiRenderer extends CustomRenderer {
|
|
7
8
|
private worldContainer;
|
|
8
9
|
private localContainer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{CustomRenderer as e,MeshRenderer as t,PUID as r}from"@hology/nebula";import*as a from"three";import{InstancedBufferAttribute as o,Object3D as n}from"three";import{NodeShaderMaterial as i}from"three-shader-graph";import{StretchedSprite as s}from"./stretched-sprite.js";import{Trail as l}from"./trail-renderer.js";import{SpriteNodeShaderMaterial as c}from"../../shader/sprite-shader";import{particleEnergyUniformName as d}from"../../shader-nodes/particle";import{AssetMeshInstance as m}from"../../scene/asset-resource-loader.js";import{markMaterialUniformValuesNeedUpdate as u}from"../../rendering/node-material-webgpu-resolver.js";var h;!function(e){e[e.mesh=0]="mesh",e[e.instanced=1]="instanced",e[e.sprite=2]="sprite",e[e.stretchedBillboard=3]="stretchedBillboard",e[e.trail=4]="trail"}(h||(h={}));export class MultiRenderer extends e{constructor(e,t,r,a){super(),this.worldContainer=e,this.localContainer=t,this.three=r,this.view=a,this.localRenderers=[],this.worldRenderers=[]}onSystemUpdate(){for(const e of this.worldRenderers)e?.onSystemUpdate();for(const e of this.localRenderers)e?.onSystemUpdate()}onParticleCreated(e){e.target=null,this.getRenderer(e)?.onParticleCreated(e)}onParticleUpdate(e){this.getRenderer(e)?.onParticleUpdate(e)}onParticleDead(e){this.getRenderer(e)?.onParticleDead(e),e._renderer=null}getRenderer(e){if(e._renderer)return e._renderer;const t=(null!=e?.parent?e?.parent._space:null)??"world",r="world"===t?this.worldContainer:this.localContainer,o="world"===t?this.worldRenderers:this.localRenderers;return"trail"===e.body.type?(null==o[h.trail]&&(o[h.trail]=new TrailRenderer(r,this.three)),e._renderer=o[h.trail]):e.body instanceof s?(null==o[h.stretchedBillboard]&&(o[h.stretchedBillboard]=new StretchedSpriteInstancedRenderer(r,this.three,this.view)),e._renderer=o[h.stretchedBillboard]):e.body instanceof a.Sprite?(null==o[h.sprite]&&(o[h.sprite]=new CombinedRenderer(r,this.three)),e._renderer=o[h.sprite]):e.body instanceof a.Mesh&&0==e.body.children.length&&e.body.material instanceof i?(null==o[h.instanced]&&(o[h.instanced]=new InstancedRenderer(r,this.three,this.view)),e._renderer=o[h.instanced]):e.body instanceof a.Object3D?(null==o[h.mesh]&&(o[h.mesh]=new CombinedRenderer(r,this.three)),e._renderer=o[h.mesh]):void 0}dispose(){this.localRenderers.forEach(e=>{e instanceof InstancedRenderer&&e.dispose()}),this.worldRenderers.forEach(e=>{e instanceof InstancedRenderer&&e.dispose()})}}export class TrailRenderer extends t{constructor(){super(...arguments),this.trails=[]}dispose(){}onSystemUpdate(){for(const e of this.trails)e.update()}onParticleCreated(e){const t=e.body,r=new l(this.container,!1),o=new n;this.container.add(o),o.updateMatrixWorld(),o.updateWorldMatrix(!0,!0);const i=t.material?.clone()??l.createBaseMaterial(t.texture,t.scrollSpeed,t.opacityChannel,t.billboard??!1);i.uniforms.taper&&(i.uniforms.taper.value=t.taper??!1);const s=new a.Color(t.color??0).multiplyScalar(t.intensity??1),c=new a.Color(t.colorEnd??0).multiplyScalar(t.intensityEnd??t.intensity??1);i.uniforms.headColor&&i.uniforms.tailColor&&(i.uniforms.headColor.value=new a.Vector4(s.r,s.g,s.b,t.opacityStart??1),i.uniforms.tailColor.value=new a.Vector4(c.r,c.g,c.b,t.opacityEnd??1)),i.uniforms.color&&null==i.uniforms.headColor&&(i.uniforms.color.value=s),i.uniforms.opacity&&null==i.uniforms.headColor&&(i.uniforms.opacity.value=t.opacityStart??1),t.bloom&&(i.userData.hasBloom=!0),r.initialize(i,Math.round(t.length??10),!1,t.width,null,o,t.billboard??!1),null!=t.renderOrder&&null!=r.mesh&&(r.mesh.renderOrder=t.renderOrder);const d=e.rotation;o.rotation.set(d.x,d.y,d.z);e.scale;r.activate(),this.trails.push(r),e.target=o}onParticleUpdate(e){const t=e.target;t.position.copy(e.position);const r=e.body;let a=v;e.old&&e.old.position?a.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z):a.copy(e.velocity),a.lengthSq()>1e-8?a.normalize():a.copy(U);const o=P;o.setFromUnitVectors(a,U),t.rotation.set(0,0,0),t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.applyQuaternion(o);const n=this.trails.findIndex(e=>e.targetObject.id===t.id);if(-1!=n){const t=this.trails[n];if(e.useAlpha){if(t.material.uniforms.headColor&&t.material.uniforms.tailColor){t.material.uniforms.headColor.value.setW((r.opacityStart??1)*e.alpha);t.material.uniforms.tailColor.value.setW((r.opacityEnd??1)*e.alpha)}null!=t.material.uniforms.opacity&&(t.material.uniforms.opacity.value=e.alpha)}e.useColor&&null!=t.material.uniforms.color&&t.material.uniforms.color.value.copy(e.color),null!=t.material.uniforms[d]&&(t.material.uniforms[d].value=e.energy),u(t.material)}}onParticleDead(e){const t=e.target,r=this.trails.findIndex(e=>e.targetObject.id===t.id);if(-1!=r){const e=this.trails[r];e.removeFromParent(),e.mesh.removeFromParent(),e.targetObject.removeFromParent(),t.removeFromParent(),this.trails.splice(r,1)}}}export class CombinedRenderer extends t{dispose(){}scale(e){const t=e.transform.initialScale;e.target instanceof a.Sprite?null!=t?e.target.scale.set(t.x*e.scale*e.radius,t.y*e.scale*e.radius,1):e.target.scale.set(e.scale*e.radius,e.scale*e.radius,1):null!=t?e.target.scale.set(t.x*e.scale,t.y*e.scale,t.z*e.scale):super.scale(e)}rotate(e){e.target.material.rotation=e.rotation.z}onParticleCreated(e){e.target||(e.target=this._targetPool.get(e.body),(e.useAlpha||e.useColor)&&(e.target instanceof a.Mesh||e.target instanceof a.Sprite&&e.target.material instanceof a.Material)&&(e.target.material.__puid=r.id(e.body.material),e.target.material=this._materialPool.get(e.target.material))),e.target&&e.target instanceof n&&(e.target.position.set(e.position.x,e.position.y,e.position.z),this.container.add(e.target))}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:o,rotation:i}=e;if(t){if(t.position.copy(e.position),this.isThreeSprite(e)||(t instanceof a.Mesh&&t.material instanceof c?e.target.material.rotation=e.rotation.z:t.rotation.set(i.x,i.y,i.z)),this.scale(e),e.transform&&e.transform.orientAlongVelocity&&t instanceof n){const r=p.set(e.velocity.x,e.velocity.y,e.velocity.z).normalize(),a=t.getWorldDirection(f);a.applyAxisAngle(y,Math.PI/-2),g.setFromUnitVectors(a,r),t.quaternion.copy(g)}(r||o)&&this.applyUniforms(t,e)}}applyUniforms(e,t){if(e instanceof m&&e.traverse(r=>r!==e&&this.applyUniforms(r,t)),e instanceof a.Mesh){let r=!1;t.useAlpha&&(e.material instanceof c&&null!=e.material.uniforms.opacity&&(e.material.uniforms.opacity.value=t.alpha,r=!0),e.material instanceof a.ShaderMaterial&&null!=e.material.uniforms.opacity?(e.material.uniforms.opacity.value=t.alpha,r=!0):(e.material.opacity=t.alpha,r=!0),e.material.transparent=!0),t.useColor&&(null!=e.material.color?(e.material.color.copy(t.color),r=!0):e.material instanceof a.ShaderMaterial&&null!=e.material.uniforms.color&&(e.material.uniforms.color.value=t.color,r=!0)),r&&u(e.material)}}onParticleDead(e){e.target&&(e.target.material&&(e.useAlpha||e.useColor)&&this._materialPool.expire(e.target.material),this._targetPool.expire(e.target),this.container.remove(e.target),e.target=null)}}export class StretchedSpriteInstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach(e=>e.mesh.geometry.dispose())}onSystemUpdate(){for(const e of this.meshes){const t=e.mesh.geometry.getAttribute("offset"),r=e.mesh.geometry.getAttribute("size"),o=e.mesh.geometry.getAttribute("velocity"),n=e.mesh.geometry.getAttribute("rotation"),i=e.mesh.geometry.getAttribute("particleColor");let s=0;for(const l of e.particles){if(null==l||l.dead)continue;if(l.useColor||l.color instanceof a.Color){const e=S.copy(l.color).getRGB(z);i.setXYZW(s,e.r,e.g,e.b,1),i.needsUpdate=!0}l.useAlpha&&(i.setW(s,l.alpha),i.needsUpdate=!0),"number"==typeof l.rotation?n.setX(s,l.rotation):n.setX(s,l.rotation.x);const e=l.position;if(t.setXYZ(s,e.x,e.y,e.z),"number"!=typeof l.scale)throw new Error("Particle scale is not a number");r.setXYZ(s,l.scale,l.scale,l.scale);let c=l.body.scaleFactor;0===c&&(c=.001);const d=1,m=l.velocity;o.setXYZW(s,m.x*c,m.y*c,m.z*c,d),s++}s>0&&(t.clearUpdateRanges(),t.addUpdateRange(0,3*s),t.needsUpdate=!0,r.clearUpdateRanges(),r.addUpdateRange(0,3*s),r.needsUpdate=!0,i.clearUpdateRanges(),i.addUpdateRange(0,4*s),i.needsUpdate=!0,o.clearUpdateRanges(),o.addUpdateRange(0,4*s),o.needsUpdate=!0,n.clearUpdateRanges(),n.addUpdateRange(0,s),n.needsUpdate=!0)}}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate,r=t.timePan.a;if(!Number.isFinite(r)||r<=0)return t.numPan.b*this.calcMaxCount(e.parent.parentParticle);return Math.min(t.numPan.b*Math.ceil(e.life/Math.min(Math.max(t.timePan.a,.01),1)),1e5)*this.calcMaxCount(e.parent.parentParticle)}onParticleCreated(e){if(e.body instanceof s&&null==e.target){const t=e.body;let r=this.meshes.find(e=>e.mesh.material.uuid===t.material.uuid);if(null==r){const n=this.calcMaxCount(e),i=new a.InstancedBufferGeometry;i.setIndex(t.geometry.getIndex()),i.setAttribute("position",t.geometry.getAttribute("position")),t.geometry.hasAttribute("normal")&&i.setAttribute("normal",t.geometry.getAttribute("normal")),i.setAttribute("uv",t.geometry.getAttribute("uv"));const s=new o(new Float32Array(3*n),3);s.setUsage(a.DynamicDrawUsage),i.setAttribute("offset",s);const l=new o(new Float32Array(4*n),4);if(l.setUsage(a.DynamicDrawUsage),i.setAttribute("particleColor",l),t.material instanceof c){const e=new a.Color(t.material.color);for(let t=0;t<l.count;t++)l.setXYZW(t,e.r,e.g,e.b,1)}const d=new o(new Float32Array(3*n),3);d.setUsage(a.DynamicDrawUsage),i.setAttribute("size",d);const m=new o(new Float32Array(4*n),4);m.setUsage(a.DynamicDrawUsage),i.setAttribute("velocity",m);const u=new o(new Float32Array(4*n),1);u.setUsage(a.DynamicDrawUsage),i.setAttribute("rotation",u),r={mesh:new a.Mesh(i,t.material),indices:new Float32Array(n),particles:[]},r.mesh.renderOrder=t.renderOrder,this.meshes.push(r),this.container.add(r.mesh)}let n=r.indices.findIndex(e=>0===e);n<0&&(n=function(e){let t=e[0],r=0;for(let a=1;a<e.length;a++)e[a]<t&&(t=e[a],r=a);return r}(r.indices)),r.indices[n]=performance.now(),e.target=n,r.particles[n]=e}}onParticleUpdate(e){}onParticleDead(e){const t=e.body;let r=this.meshes.find(e=>e.mesh.material.uuid===t.material.uuid);if(r){const t=r.mesh.geometry.getAttribute("size");t.setXYZ(e.target,0,0,0),t.needsUpdate=!0,r.particles[e.target]=null,r.indices[e.target]=0}e.target=null}}const p=new a.Vector3,f=new a.Vector3,g=new a.Quaternion,y=new a.Vector3(1,0,0),b=1e5;function w(e){return Number.isFinite(e)?Math.min(Math.max(Math.ceil(e),1),b):b}export class InstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach(e=>e.mesh.dispose())}onSystemUpdate(){for(const e of this.meshes)e.mesh.material.transparent&&e.mesh.material.blending===a.NormalBlending&&F(e,this.view.getCamera())}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate,r=t.timePan.a,a=t.numPan.b,o=e.parent.parentParticle;if(!Number.isFinite(r)||r<=0)return w(a*this.calcMaxCount(o));return w(a*Math.ceil(e.life/Math.min(Math.max(r,.01),1))*this.calcMaxCount(o))}onParticleCreated(e){if(e.body instanceof a.Sprite)return;const t=e.body;let r=this.meshes.find(e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid);if(null==r){const o=this.calcMaxCount(e);r={mesh:new a.InstancedMesh(t.geometry,t.material,o),indices:new Array(o).fill(null),particles:[],sortOrder:new Array(o),sortDistances:new Float32Array(o),sortedMatrices:new Float32Array(16*o),sortedColors:new Float32Array(4*o),sortedParticleData:new Float32Array(3*o),sortedRotations:new Float32Array(o),sortedParticles:new Array(o),sortedIndices:new Array(o)},r.mesh.renderOrder=t.renderOrder,r.mesh.userData.webGpuCacheMaterial=!0;const n=new Float32Array(4*o);n.fill(1),r.mesh.instanceColor=new a.InstancedBufferAttribute(n,4),r.mesh.setColorAt(0,S.setScalar(1)),r.mesh.instanceColor.needsUpdate=!0,r.mesh.material.defines.USE_INSTANCING="",r.mesh.material.needsUpdate=!0;const i=new Float32Array(3*o);M.makeScale(0,0,0);for(let e=0;e<o;e++)i[3*e+0]=1,i[3*e+1]=1,i[3*e+2]=1,r.mesh.instanceMatrix.array.set(M.elements,16*e);r.mesh.instanceMatrix.needsUpdate=!0,r.mesh.geometry.setAttribute("particleData",new a.InstancedBufferAttribute(i,3));const s=new a.InstancedBufferAttribute(new Float32Array(o),1);s.setUsage(a.DynamicDrawUsage),r.mesh.geometry.setAttribute("rotation",s),this.meshes.push(r),this.container.add(r.mesh)}let o=r.indices.findIndex(e=>null==e);if(o<0&&(o=r.indices.indexOf(Math.min(...r.indices))),o<0||o>=r.mesh.instanceMatrix.count)return void(e.target=null);const n=r.particles[o];if(null!=n&&n!==e&&(n.target=null),r.indices[o]=performance.now(),e.target=o,r.particles[o]=e,r.mesh.count<=o&&(r.mesh.count=o+1),"number"==typeof e.target){e.transform.initialScale;const t=e.body;let r=this.meshes.find(e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid);C(e,r.mesh),e.useAlpha&&(r.mesh.material.transparent||(r.mesh.material.transparent=!0,r.mesh.material.needsUpdate=!0))}}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:a,rotation:o}=e;if(null==t)return;const n=e.body,i=this.meshes.find(e=>e.mesh.geometry.uuid===n.geometry.uuid&&e.mesh.material.uuid===n.material.uuid);if(null==i)return;if(!A(i,e))return void(e.target=null);if(i.mesh.frustumCulled=!1,C(e,i.mesh),a){S.copy(e.color);const t=i.mesh.instanceColor.array,r=e.target*i.mesh.instanceColor.itemSize;t[r+0]=S.r,t[r+1]=S.g,t[r+2]=S.b,i.mesh.instanceColor.itemSize>=4&&(t[r+3]=1),i.mesh.instanceColor.needsUpdate=!0}const s=i.mesh.geometry.getAttribute("particleData");r&&s.setX(e.target,e.alpha),s.setY(e.target,e.energy),s.needsUpdate=!0;const l=i.mesh.geometry.getAttribute("rotation");l.setX(e.target,o.z),l.needsUpdate=!0}onParticleDead(e){if(null!=e.target){const t=e.body,r=this.meshes.find(e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid);if(null==r)return;if(!A(r,e))return void(e.target=null);r.indices[e.target]=null,r.particles[e.target]=null,e.scale=0,C(e,r.mesh),r.mesh.instanceMatrix.needsUpdate=!0,e.target=null}}}const x=new n;function A(e,t){const r=t.target;return"number"==typeof r&&Number.isInteger(r)&&r>=0&&r<e.mesh.instanceMatrix.count&&e.particles[r]===t}function C(e,t){if(!Number.isInteger(e.target)||e.target<0||e.target>=t.instanceMatrix.count)return;if(v.set(e.position.x,e.position.y,e.position.z),e.transform&&e.transform.orientAlongVelocity){const r=p.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z).normalize();t.getMatrixAt(e.target,x.matrix);const a=x.getWorldDirection(R);a.applyAxisAngle(y,Math.PI/-2),P.setFromUnitVectors(a,r)}else D.set(e.rotation.x,e.rotation.y,e.rotation.z),P.setFromEuler(D);const r=e.transform.initialScale;null!=r?R.set(r.x*e.scale,r.y*e.scale,r.z*e.scale):R.set(e.scale,e.scale,e.scale),M.compose(v,P,R),t.instanceMatrix.array.set(M.elements,16*e.target),t.instanceMatrix.needsUpdate=!0}const U=new a.Vector3(0,0,-1),M=new a.Matrix4,P=new a.Quaternion,v=new a.Vector3,R=new a.Vector3,D=new a.Euler,S=new a.Color(0),z={r:0,g:0,b:0};function F(e,t){const r=e.mesh,a=r.instanceMatrix.array,o=r.instanceColor.array,n=r.geometry.getAttribute("particleData"),i=n.array,s=r.geometry.getAttribute("rotation"),l=s.array,c=r.worldToLocal(t.getWorldPosition(I));let d=0;for(let t=0;t<e.particles.length;t++){if(null==e.particles[t])continue;const r=16*t,o=a[r+12]-c.x,n=a[r+13]-c.y,i=a[r+14]-c.z;e.sortDistances[t]=o*o+n*n+i*i,e.sortOrder[d++]=t}e.sortOrder.length=d,e.sortOrder.sort((t,r)=>e.sortDistances[r]-e.sortDistances[t]);for(let t=0;t<d;t++){const r=e.sortOrder[t];for(let o=0;o<16;o++)e.sortedMatrices[16*t+o]=a[16*r+o];for(let a=0;a<4;a++)e.sortedColors[4*t+a]=o[4*r+a];for(let a=0;a<3;a++)e.sortedParticleData[3*t+a]=i[3*r+a];e.sortedRotations[t]=l[r],e.sortedParticles[t]=e.particles[r],e.sortedIndices[t]=e.indices[r]}for(let t=0;t<d;t++){const r=e.sortedParticles[t];e.particles[t]=r,e.indices[t]=e.sortedIndices[t],l[t]=e.sortedRotations[t],r.target=t}for(let t=d;t<e.indices.length;t++)e.particles[t]=null,e.indices[t]=null;for(let t=0;t<16*d;t++)a[t]=e.sortedMatrices[t];for(let t=0;t<4*d;t++)o[t]=e.sortedColors[t];for(let t=0;t<3*d;t++)i[t]=e.sortedParticleData[t];r.count=d,r.instanceMatrix.needsUpdate=!0,r.instanceColor.needsUpdate=!0,n.needsUpdate=!0,s.needsUpdate=!0}export{F as sortInstancedMeshByDistance};const I=new a.Vector3;/*
|
|
1
|
+
import{CustomRenderer as e,MeshRenderer as t,PUID as r}from"@hology/nebula";import*as a from"three";import{InstancedBufferAttribute as o,Object3D as n}from"three";import{NodeShaderMaterial as i}from"three-shader-graph";import{StretchedSprite as s}from"./stretched-sprite.js";import{Trail as l}from"./trail-renderer.js";import{SpriteNodeShaderMaterial as c}from"../../shader/sprite-shader.js";import{particleEnergyUniformName as d}from"../../shader-nodes/particle.js";import{AssetMeshInstance as m}from"../../scene/asset-resource-loader.js";import{markMaterialUniformValuesNeedUpdate as u}from"../../rendering/node-material-webgpu-resolver.js";var h;!function(e){e[e.mesh=0]="mesh",e[e.instanced=1]="instanced",e[e.sprite=2]="sprite",e[e.stretchedBillboard=3]="stretchedBillboard",e[e.trail=4]="trail"}(h||(h={}));export class MultiRenderer extends e{constructor(e,t,r,a){super(),this.worldContainer=e,this.localContainer=t,this.three=r,this.view=a,this.localRenderers=[],this.worldRenderers=[]}onSystemUpdate(){for(const e of this.worldRenderers)e?.onSystemUpdate();for(const e of this.localRenderers)e?.onSystemUpdate()}onParticleCreated(e){e.target=null,this.getRenderer(e)?.onParticleCreated(e)}onParticleUpdate(e){this.getRenderer(e)?.onParticleUpdate(e)}onParticleDead(e){this.getRenderer(e)?.onParticleDead(e),e._renderer=null}getRenderer(e){if(e._renderer)return e._renderer;const t=(null!=e?.parent?e?.parent._space:null)??"world",r="world"===t?this.worldContainer:this.localContainer,o="world"===t?this.worldRenderers:this.localRenderers;return"trail"===e.body.type?(null==o[h.trail]&&(o[h.trail]=new TrailRenderer(r,this.three)),e._renderer=o[h.trail]):e.body instanceof s?(null==o[h.stretchedBillboard]&&(o[h.stretchedBillboard]=new StretchedSpriteInstancedRenderer(r,this.three,this.view)),e._renderer=o[h.stretchedBillboard]):e.body instanceof a.Sprite?(null==o[h.sprite]&&(o[h.sprite]=new CombinedRenderer(r,this.three)),e._renderer=o[h.sprite]):e.body instanceof a.Mesh&&0==e.body.children.length&&e.body.material instanceof i?(null==o[h.instanced]&&(o[h.instanced]=new InstancedRenderer(r,this.three,this.view)),e._renderer=o[h.instanced]):e.body instanceof a.Object3D?(null==o[h.mesh]&&(o[h.mesh]=new CombinedRenderer(r,this.three)),e._renderer=o[h.mesh]):void 0}dispose(){this.localRenderers.forEach(e=>{e instanceof InstancedRenderer&&e.dispose()}),this.worldRenderers.forEach(e=>{e instanceof InstancedRenderer&&e.dispose()})}}export class TrailRenderer extends t{constructor(){super(...arguments),this.trails=[]}dispose(){}onSystemUpdate(){for(const e of this.trails)e.update()}onParticleCreated(e){const t=e.body,r=new l(this.container,!1),o=new n;this.container.add(o),o.updateMatrixWorld(),o.updateWorldMatrix(!0,!0);const i=t.material?.clone()??l.createBaseMaterial(t.texture,t.scrollSpeed,t.opacityChannel,t.billboard??!1);i.uniforms.taper&&(i.uniforms.taper.value=t.taper??!1);const s=new a.Color(t.color??0).multiplyScalar(t.intensity??1),c=new a.Color(t.colorEnd??0).multiplyScalar(t.intensityEnd??t.intensity??1);i.uniforms.headColor&&i.uniforms.tailColor&&(i.uniforms.headColor.value=new a.Vector4(s.r,s.g,s.b,t.opacityStart??1),i.uniforms.tailColor.value=new a.Vector4(c.r,c.g,c.b,t.opacityEnd??1)),i.uniforms.color&&null==i.uniforms.headColor&&(i.uniforms.color.value=s),i.uniforms.opacity&&null==i.uniforms.headColor&&(i.uniforms.opacity.value=t.opacityStart??1),t.bloom&&(i.userData.hasBloom=!0),r.initialize(i,Math.round(t.length??10),!1,t.width,null,o,t.billboard??!1),null!=t.renderOrder&&null!=r.mesh&&(r.mesh.renderOrder=t.renderOrder);const d=e.rotation;o.rotation.set(d.x,d.y,d.z);e.scale;r.activate(),this.trails.push(r),e.target=o}onParticleUpdate(e){const t=e.target;t.position.copy(e.position);const r=e.body;let a=v;e.old&&e.old.position?a.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z):a.copy(e.velocity),a.lengthSq()>1e-8?a.normalize():a.copy(U);const o=P;o.setFromUnitVectors(a,U),t.rotation.set(0,0,0),t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.applyQuaternion(o);const n=this.trails.findIndex(e=>e.targetObject.id===t.id);if(-1!=n){const t=this.trails[n];if(e.useAlpha){if(t.material.uniforms.headColor&&t.material.uniforms.tailColor){t.material.uniforms.headColor.value.setW((r.opacityStart??1)*e.alpha);t.material.uniforms.tailColor.value.setW((r.opacityEnd??1)*e.alpha)}null!=t.material.uniforms.opacity&&(t.material.uniforms.opacity.value=e.alpha)}e.useColor&&null!=t.material.uniforms.color&&t.material.uniforms.color.value.copy(e.color),null!=t.material.uniforms[d]&&(t.material.uniforms[d].value=e.energy),u(t.material)}}onParticleDead(e){const t=e.target,r=this.trails.findIndex(e=>e.targetObject.id===t.id);if(-1!=r){const e=this.trails[r];e.removeFromParent(),e.mesh.removeFromParent(),e.targetObject.removeFromParent(),t.removeFromParent(),this.trails.splice(r,1)}}}export class CombinedRenderer extends t{dispose(){}scale(e){const t=e.transform.initialScale;e.target instanceof a.Sprite?null!=t?e.target.scale.set(t.x*e.scale*e.radius,t.y*e.scale*e.radius,1):e.target.scale.set(e.scale*e.radius,e.scale*e.radius,1):null!=t?e.target.scale.set(t.x*e.scale,t.y*e.scale,t.z*e.scale):super.scale(e)}rotate(e){e.target.material.rotation=e.rotation.z}onParticleCreated(e){e.target||(e.target=this._targetPool.get(e.body),(e.useAlpha||e.useColor)&&(e.target instanceof a.Mesh||e.target instanceof a.Sprite&&e.target.material instanceof a.Material)&&(e.target.material.__puid=r.id(e.body.material),e.target.material=this._materialPool.get(e.target.material))),e.target&&e.target instanceof n&&(e.target.position.set(e.position.x,e.position.y,e.position.z),this.container.add(e.target))}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:o,rotation:i}=e;if(t){if(t.position.copy(e.position),this.isThreeSprite(e)||(t instanceof a.Mesh&&t.material instanceof c?e.target.material.rotation=e.rotation.z:t.rotation.set(i.x,i.y,i.z)),this.scale(e),e.transform&&e.transform.orientAlongVelocity&&t instanceof n){const r=p.set(e.velocity.x,e.velocity.y,e.velocity.z).normalize(),a=t.getWorldDirection(f);a.applyAxisAngle(y,Math.PI/-2),g.setFromUnitVectors(a,r),t.quaternion.copy(g)}(r||o)&&this.applyUniforms(t,e)}}applyUniforms(e,t){if(e instanceof m&&e.traverse(r=>r!==e&&this.applyUniforms(r,t)),e instanceof a.Mesh){let r=!1;t.useAlpha&&(e.material instanceof c&&null!=e.material.uniforms.opacity&&(e.material.uniforms.opacity.value=t.alpha,r=!0),e.material instanceof a.ShaderMaterial&&null!=e.material.uniforms.opacity?(e.material.uniforms.opacity.value=t.alpha,r=!0):(e.material.opacity=t.alpha,r=!0),e.material.transparent=!0),t.useColor&&(null!=e.material.color?(e.material.color.copy(t.color),r=!0):e.material instanceof a.ShaderMaterial&&null!=e.material.uniforms.color&&(e.material.uniforms.color.value=t.color,r=!0)),r&&u(e.material)}}onParticleDead(e){e.target&&(e.target.material&&(e.useAlpha||e.useColor)&&this._materialPool.expire(e.target.material),this._targetPool.expire(e.target),this.container.remove(e.target),e.target=null)}}export class StretchedSpriteInstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach(e=>e.mesh.geometry.dispose())}onSystemUpdate(){for(const e of this.meshes){const t=e.mesh.geometry.getAttribute("offset"),r=e.mesh.geometry.getAttribute("size"),o=e.mesh.geometry.getAttribute("velocity"),n=e.mesh.geometry.getAttribute("rotation"),i=e.mesh.geometry.getAttribute("particleColor");let s=0;for(const l of e.particles){if(null==l||l.dead)continue;if(l.useColor||l.color instanceof a.Color){const e=S.copy(l.color).getRGB(z);i.setXYZW(s,e.r,e.g,e.b,1),i.needsUpdate=!0}l.useAlpha&&(i.setW(s,l.alpha),i.needsUpdate=!0),"number"==typeof l.rotation?n.setX(s,l.rotation):n.setX(s,l.rotation.x);const e=l.position;if(t.setXYZ(s,e.x,e.y,e.z),"number"!=typeof l.scale)throw new Error("Particle scale is not a number");r.setXYZ(s,l.scale,l.scale,l.scale);let c=l.body.scaleFactor;0===c&&(c=.001);const d=1,m=l.velocity;o.setXYZW(s,m.x*c,m.y*c,m.z*c,d),s++}s>0&&(t.clearUpdateRanges(),t.addUpdateRange(0,3*s),t.needsUpdate=!0,r.clearUpdateRanges(),r.addUpdateRange(0,3*s),r.needsUpdate=!0,i.clearUpdateRanges(),i.addUpdateRange(0,4*s),i.needsUpdate=!0,o.clearUpdateRanges(),o.addUpdateRange(0,4*s),o.needsUpdate=!0,n.clearUpdateRanges(),n.addUpdateRange(0,s),n.needsUpdate=!0)}}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate,r=t.timePan.a;if(!Number.isFinite(r)||r<=0)return t.numPan.b*this.calcMaxCount(e.parent.parentParticle);return Math.min(t.numPan.b*Math.ceil(e.life/Math.min(Math.max(t.timePan.a,.01),1)),1e5)*this.calcMaxCount(e.parent.parentParticle)}onParticleCreated(e){if(e.body instanceof s&&null==e.target){const t=e.body;let r=this.meshes.find(e=>e.mesh.material.uuid===t.material.uuid);if(null==r){const n=this.calcMaxCount(e),i=new a.InstancedBufferGeometry;i.setIndex(t.geometry.getIndex()),i.setAttribute("position",t.geometry.getAttribute("position")),t.geometry.hasAttribute("normal")&&i.setAttribute("normal",t.geometry.getAttribute("normal")),i.setAttribute("uv",t.geometry.getAttribute("uv"));const s=new o(new Float32Array(3*n),3);s.setUsage(a.DynamicDrawUsage),i.setAttribute("offset",s);const l=new o(new Float32Array(4*n),4);if(l.setUsage(a.DynamicDrawUsage),i.setAttribute("particleColor",l),t.material instanceof c){const e=new a.Color(t.material.color);for(let t=0;t<l.count;t++)l.setXYZW(t,e.r,e.g,e.b,1)}const d=new o(new Float32Array(3*n),3);d.setUsage(a.DynamicDrawUsage),i.setAttribute("size",d);const m=new o(new Float32Array(4*n),4);m.setUsage(a.DynamicDrawUsage),i.setAttribute("velocity",m);const u=new o(new Float32Array(4*n),1);u.setUsage(a.DynamicDrawUsage),i.setAttribute("rotation",u),r={mesh:new a.Mesh(i,t.material),indices:new Float32Array(n),particles:[]},r.mesh.renderOrder=t.renderOrder,this.meshes.push(r),this.container.add(r.mesh)}let n=r.indices.findIndex(e=>0===e);n<0&&(n=function(e){let t=e[0],r=0;for(let a=1;a<e.length;a++)e[a]<t&&(t=e[a],r=a);return r}(r.indices)),r.indices[n]=performance.now(),e.target=n,r.particles[n]=e}}onParticleUpdate(e){}onParticleDead(e){const t=e.body;let r=this.meshes.find(e=>e.mesh.material.uuid===t.material.uuid);if(r){const t=r.mesh.geometry.getAttribute("size");t.setXYZ(e.target,0,0,0),t.needsUpdate=!0,r.particles[e.target]=null,r.indices[e.target]=0}e.target=null}}const p=new a.Vector3,f=new a.Vector3,g=new a.Quaternion,y=new a.Vector3(1,0,0),b=1e5;function w(e){return Number.isFinite(e)?Math.min(Math.max(Math.ceil(e),1),b):b}export class InstancedRenderer extends t{constructor(e,t,r){super(e,t),this.view=r,this.meshes=[]}dispose(){this.meshes.forEach(e=>e.mesh.dispose())}onSystemUpdate(){for(const e of this.meshes)e.mesh.material.transparent&&e.mesh.material.blending===a.NormalBlending&&F(e,this.view.getCamera())}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate,r=t.timePan.a,a=t.numPan.b,o=e.parent.parentParticle;if(!Number.isFinite(r)||r<=0)return w(a*this.calcMaxCount(o));return w(a*Math.ceil(e.life/Math.min(Math.max(r,.01),1))*this.calcMaxCount(o))}onParticleCreated(e){if(e.body instanceof a.Sprite)return;const t=e.body;let r=this.meshes.find(e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid);if(null==r){const o=this.calcMaxCount(e);r={mesh:new a.InstancedMesh(t.geometry,t.material,o),indices:new Array(o).fill(null),particles:[],sortOrder:new Array(o),sortDistances:new Float32Array(o),sortedMatrices:new Float32Array(16*o),sortedColors:new Float32Array(4*o),sortedParticleData:new Float32Array(3*o),sortedRotations:new Float32Array(o),sortedParticles:new Array(o),sortedIndices:new Array(o)},r.mesh.renderOrder=t.renderOrder,r.mesh.userData.webGpuCacheMaterial=!0;const n=new Float32Array(4*o);n.fill(1),r.mesh.instanceColor=new a.InstancedBufferAttribute(n,4),r.mesh.setColorAt(0,S.setScalar(1)),r.mesh.instanceColor.needsUpdate=!0,r.mesh.material.defines.USE_INSTANCING="",r.mesh.material.needsUpdate=!0;const i=new Float32Array(3*o);M.makeScale(0,0,0);for(let e=0;e<o;e++)i[3*e+0]=1,i[3*e+1]=1,i[3*e+2]=1,r.mesh.instanceMatrix.array.set(M.elements,16*e);r.mesh.instanceMatrix.needsUpdate=!0,r.mesh.geometry.setAttribute("particleData",new a.InstancedBufferAttribute(i,3));const s=new a.InstancedBufferAttribute(new Float32Array(o),1);s.setUsage(a.DynamicDrawUsage),r.mesh.geometry.setAttribute("rotation",s),this.meshes.push(r),this.container.add(r.mesh)}let o=r.indices.findIndex(e=>null==e);if(o<0&&(o=r.indices.indexOf(Math.min(...r.indices))),o<0||o>=r.mesh.instanceMatrix.count)return void(e.target=null);const n=r.particles[o];if(null!=n&&n!==e&&(n.target=null),r.indices[o]=performance.now(),e.target=o,r.particles[o]=e,r.mesh.count<=o&&(r.mesh.count=o+1),"number"==typeof e.target){e.transform.initialScale;const t=e.body;let r=this.meshes.find(e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid);C(e,r.mesh),e.useAlpha&&(r.mesh.material.transparent||(r.mesh.material.transparent=!0,r.mesh.material.needsUpdate=!0))}}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:a,rotation:o}=e;if(null==t)return;const n=e.body,i=this.meshes.find(e=>e.mesh.geometry.uuid===n.geometry.uuid&&e.mesh.material.uuid===n.material.uuid);if(null==i)return;if(!A(i,e))return void(e.target=null);if(i.mesh.frustumCulled=!1,C(e,i.mesh),a){S.copy(e.color);const t=i.mesh.instanceColor.array,r=e.target*i.mesh.instanceColor.itemSize;t[r+0]=S.r,t[r+1]=S.g,t[r+2]=S.b,i.mesh.instanceColor.itemSize>=4&&(t[r+3]=1),i.mesh.instanceColor.needsUpdate=!0}const s=i.mesh.geometry.getAttribute("particleData");r&&s.setX(e.target,e.alpha),s.setY(e.target,e.energy),s.needsUpdate=!0;const l=i.mesh.geometry.getAttribute("rotation");l.setX(e.target,o.z),l.needsUpdate=!0}onParticleDead(e){if(null!=e.target){const t=e.body,r=this.meshes.find(e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid);if(null==r)return;if(!A(r,e))return void(e.target=null);r.indices[e.target]=null,r.particles[e.target]=null,e.scale=0,C(e,r.mesh),r.mesh.instanceMatrix.needsUpdate=!0,e.target=null}}}const x=new n;function A(e,t){const r=t.target;return"number"==typeof r&&Number.isInteger(r)&&r>=0&&r<e.mesh.instanceMatrix.count&&e.particles[r]===t}function C(e,t){if(!Number.isInteger(e.target)||e.target<0||e.target>=t.instanceMatrix.count)return;if(v.set(e.position.x,e.position.y,e.position.z),e.transform&&e.transform.orientAlongVelocity){const r=p.set(e.position.x-e.old.position.x,e.position.y-e.old.position.y,e.position.z-e.old.position.z).normalize();t.getMatrixAt(e.target,x.matrix);const a=x.getWorldDirection(R);a.applyAxisAngle(y,Math.PI/-2),P.setFromUnitVectors(a,r)}else D.set(e.rotation.x,e.rotation.y,e.rotation.z),P.setFromEuler(D);const r=e.transform.initialScale;null!=r?R.set(r.x*e.scale,r.y*e.scale,r.z*e.scale):R.set(e.scale,e.scale,e.scale),M.compose(v,P,R),t.instanceMatrix.array.set(M.elements,16*e.target),t.instanceMatrix.needsUpdate=!0}const U=new a.Vector3(0,0,-1),M=new a.Matrix4,P=new a.Quaternion,v=new a.Vector3,R=new a.Vector3,D=new a.Euler,S=new a.Color(0),z={r:0,g:0,b:0};function F(e,t){const r=e.mesh,a=r.instanceMatrix.array,o=r.instanceColor.array,n=r.geometry.getAttribute("particleData"),i=n.array,s=r.geometry.getAttribute("rotation"),l=s.array,c=r.worldToLocal(t.getWorldPosition(I));let d=0;for(let t=0;t<e.particles.length;t++){if(null==e.particles[t])continue;const r=16*t,o=a[r+12]-c.x,n=a[r+13]-c.y,i=a[r+14]-c.z;e.sortDistances[t]=o*o+n*n+i*i,e.sortOrder[d++]=t}e.sortOrder.length=d,e.sortOrder.sort((t,r)=>e.sortDistances[r]-e.sortDistances[t]);for(let t=0;t<d;t++){const r=e.sortOrder[t];for(let o=0;o<16;o++)e.sortedMatrices[16*t+o]=a[16*r+o];for(let a=0;a<4;a++)e.sortedColors[4*t+a]=o[4*r+a];for(let a=0;a<3;a++)e.sortedParticleData[3*t+a]=i[3*r+a];e.sortedRotations[t]=l[r],e.sortedParticles[t]=e.particles[r],e.sortedIndices[t]=e.indices[r]}for(let t=0;t<d;t++){const r=e.sortedParticles[t];e.particles[t]=r,e.indices[t]=e.sortedIndices[t],l[t]=e.sortedRotations[t],r.target=t}for(let t=d;t<e.indices.length;t++)e.particles[t]=null,e.indices[t]=null;for(let t=0;t<16*d;t++)a[t]=e.sortedMatrices[t];for(let t=0;t<4*d;t++)o[t]=e.sortedColors[t];for(let t=0;t<3*d;t++)i[t]=e.sortedParticleData[t];r.count=d,r.instanceMatrix.needsUpdate=!0,r.instanceColor.needsUpdate=!0,n.needsUpdate=!0,s.needsUpdate=!0}export{F as sortInstancedMeshByDistance};const I=new a.Vector3;/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -2,7 +2,7 @@ import { Object3D } from 'three';
|
|
|
2
2
|
import { BaseActor } from '../../gameplay/actors/actor.js';
|
|
3
3
|
import { VfxActor } from './vfx-actor.js';
|
|
4
4
|
import { Asset, AssetId } from '../../scene/model.js';
|
|
5
|
-
import { VfxPool } from './vfx-param';
|
|
5
|
+
import { VfxPool } from './vfx-param.js';
|
|
6
6
|
export type VfxSpawnOptions = {
|
|
7
7
|
inputs?: Record<string, unknown>;
|
|
8
8
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as t}from"tslib";import{ActorFactory as s}from"../../gameplay/actors/factory.js";import{AssetLoader as e}from"../../gameplay/services/asset-loader.js";import{BaseActor as o}from"../../gameplay/actors/actor.js";import{inject as r}from"../../gameplay/inject.js";import{Service as a}from"typedi";import{World as c}from"../../gameplay/services/world.js";import{VfxActor as i}from"./vfx-actor.js";import{VfxPool as m}from"./vfx-param";let l=class{constructor(){this.pools=new Map,this.actorFactory=r(s),this.assetService=r(e),this.world=r(c)}async createFromAssetId(t,s=this.world.scene,e){const o=await this.assetService.getAsset(t);return this.createFromAsset(o,s,e)}async createFromAsset(t,s=this.world.scene,e){const r=await this.actorFactory.create(i);return s instanceof o?s.object.add(r.object):s.add(r.object),await r.fromAsset(t,e?.inputs),r}async createPoolFromAssetId(t,s=this.world.scene){const e=await this.assetService.getAsset(t);return this.createPoolFromAsset(e,s)}async createPoolFromAsset(t,s=this.world.scene){let e;return this.pools.has(t.id)||(e=new m(()=>this.createFromAsset(t,s)),this.pools.set(t.id,e)),e}clearPool(t){this.pools.delete(t)}};l=t([a()],l);export{l as VfxService};/*
|
|
1
|
+
import{__decorate as t}from"tslib";import{ActorFactory as s}from"../../gameplay/actors/factory.js";import{AssetLoader as e}from"../../gameplay/services/asset-loader.js";import{BaseActor as o}from"../../gameplay/actors/actor.js";import{inject as r}from"../../gameplay/inject.js";import{Service as a}from"typedi";import{World as c}from"../../gameplay/services/world.js";import{VfxActor as i}from"./vfx-actor.js";import{VfxPool as m}from"./vfx-param.js";let l=class{constructor(){this.pools=new Map,this.actorFactory=r(s),this.assetService=r(e),this.world=r(c)}async createFromAssetId(t,s=this.world.scene,e){const o=await this.assetService.getAsset(t);return this.createFromAsset(o,s,e)}async createFromAsset(t,s=this.world.scene,e){const r=await this.actorFactory.create(i);return s instanceof o?s.object.add(r.object):s.add(r.object),await r.fromAsset(t,e?.inputs),r}async createPoolFromAssetId(t,s=this.world.scene){const e=await this.assetService.getAsset(t);return this.createPoolFromAsset(e,s)}async createPoolFromAsset(t,s=this.world.scene){let e;return this.pools.has(t.id)||(e=new m(()=>this.createFromAsset(t,s)),this.pools.set(t.id,e)),e}clearPool(t){this.pools.delete(t)}};l=t([a()],l);export{l as VfxService};/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActorComponent } from '../../../../gameplay/actors/component';
|
|
1
|
+
import { ActorComponent } from '../../../../gameplay/actors/component.js';
|
|
2
2
|
export declare class EditorSpriteComponent extends ActorComponent {
|
|
3
3
|
/**
|
|
4
4
|
* Path to the file for exmaple 'assets/audio.png'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as t}from"tslib";import{UnscaledSprite as e}from"../../../../utils/three/unscaled-sprite";import{ActorComponent as r,Component as o}from"../../../../gameplay/actors/component";import*as i from"three";let
|
|
1
|
+
import{__decorate as t}from"tslib";import{UnscaledSprite as e}from"../../../../utils/three/unscaled-sprite.js";import{ActorComponent as r,Component as o}from"../../../../gameplay/actors/component.js";import*as i from"three";let s=class extends r{onInit(){if(null==this.file)return;const t=(new i.TextureLoader).load(this.file),r=new i.SpriteMaterial({map:t,alphaTest:.5}),o=new e(r);this.actor.object.add(o)}};s=t([o({inEditor:!0,editorOnly:!0})],s);export{s as EditorSpriteComponent};/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as
|
|
1
|
+
import{__decorate as s,__metadata as i}from"tslib";import{Parameter as e}from"../../../../shader/index.js";import{ActorComponent as t,Component as o}from"../../../../gameplay/actors/component.js";import{Mesh as n,EdgesGeometry as r,LineSegments as h,LineBasicMaterial as m,Vector3 as l,BoxGeometry as c,MeshBasicMaterial as d,Group as p,Color as a}from"three";let w=class extends t{constructor(){super(...arguments),this.color=new a(16777215),this.dimensions=new l(1,1,1),this.mesh=new p}onInit(){const s=new c(this.dimensions.x,this.dimensions.y,this.dimensions.z),i=new r(s),e=new h(i,new m({color:this.color}));new n(s,new d({color:this.color,transparent:!0,opacity:.3,visible:!1}));this.mesh.add(e),this.actor.object.add(this.mesh)}set visible(s){this.mesh.visible=s}get visible(){return this.mesh.visible}};s([e(),i("design:type",a)],w.prototype,"color",void 0),w=s([o({inEditor:!0,editorOnly:!0})],w);export{w as TriggerVolumeMesh};/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as s,Cone as o,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as l,ShapeType as c,TriMesh as h}from"@dimforge/rapier3d-simd-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,Subject as f,debounceTime as w,filter as b,firstValueFrom as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as M}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as S,Parameter as z,PhysicsSystem as
|
|
1
|
+
import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as s,Cone as o,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as l,ShapeType as c,TriMesh as h}from"@dimforge/rapier3d-simd-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,Subject as f,debounceTime as w,filter as b,firstValueFrom as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as M}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as S,Parameter as z,PhysicsSystem as j,ViewController as A,World as k,attach as C,inject as P}from"../../index.js";import{sleepDelay as F}from"../../../utils/async.js";import{hasSharedArrayBufferSupport as I,toSharedFloat32Array as D,toSharedUint32Array as V}from"../../../utils/buffer.js";import{DynamicTiledNavMesh as G,MAX_NAV_MESH_WORKERS as N}from"../../ai/dynamic-tiled-navmesh.js";import{TriggerVolumeMesh as H}from"./components/volume-editor-component.js";var E;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(E||(E={}));let T=E.none,R=new m(!1);export async function safeRecastInit(){return T===E.none?(T=E.starting,p().then(()=>{R.next(!0),T=E.started})):g(R.pipe(b(e=>e)))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const U=Math.max(1,Math.min(N,(navigator.hardwareConcurrency??2)-1));let q=!1,O=class extends S{constructor(){super(...arguments),this.physics=P(j),this.view=P(A),this.world=P(k),this.editorVisualisation=C(H),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.walkableHeight=2,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){q||(await safeRecastInit(),q=!0),setTimeout(()=>{this.init()},10),this.recreateInterval=setInterval(()=>{if("_hology_transform_group"===this.object.parent?.name)return;J.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new f,this.init())},2e3)}onEndPlay(){clearInterval(this.recreateInterval)}applySceneParameters(e,t){return!(null==this.debugDrawer||!t.has("debug")||"boolean"!=typeof e.debug)&&(this.debugDrawer.visible=e.debug,!0)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale);const e=this.bounds.max.x-this.bounds.min.x,t=this.bounds.max.z-this.bounds.min.z,n=Math.max(1,Math.min(e,t)),s=Math.min(400,Math.max(50,Math.ceil(n/2))),o=Math.max(this.cellSize,.01),i={tileSize:Math.max(32,Math.floor(s/o)),walkableClimb:this.walkableClimb/o,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:this.walkableHeight/o,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:o,ch:o,maxSimplificationError:1.3,maxEdgeLen:200},r=new G({navMeshBounds:this.bounds,recastConfig:i,maxTiles:1024,workers:U,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=r.navMesh;const a=this.tileSize*i.cs*2,l=performance.now(),c=new Map,h=new u;h.userData.isDebugDrawer=!0,this.debugDrawer=h;r.navMesh;const p=this.bounds,m=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(a),(new x.Vector3).copy(e).addScalar(a)),n=[],s=this.physics.world.bodies;if(null==s)return[];const o=new x.Box3;for(const e of s.getAll())for(let s=0,i=e.numColliders();s<i;s++){const i=e.collider(s);if(i.isSensor()||null!=i.parent().userData&&!0===i.parent().userData.ignoreForNavMesh)continue;const r=e.handle+","+s,a=c.get(r)?.mesh,l=a??X(i);if($(i,l),null!=l){o.copy(l.geometry.boundingBox),o.min.add(l.position),o.max.add(l.position);const e=o.intersectsBox(t)||!0,s=o.intersectsBox(this.bounds);c.set(r,{pos:i.translation(),mesh:l}),e&&s&&n.push(l)}}return n},f=new x.Box3,b=new Map,g=new Map;let v=!0,M=performance.now(),B=!1;const S=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await F(t)})(),()=>{n=!0}}(async()=>{if(B)return;const e=new x.Box3,t=m();for(const n of t){const t=b.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),b.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=r.getTilesForBounds(e);n.length>500&&console.warn("Too many tiles to update. Consider increasing tile size");const s=n.slice(0,500);if(0!=s.length){const n=[];for(const s of t)f.setFromObject(s),f.intersectsBox(e)&&n.push(s);let[o,i]=d(n);i=function(e,t,n){const s=new x.Vector3,o=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let o=0;o<3;o++){const a=3*t[i+o];if(s.fromArray(e,a),!n.containsPoint(s)){r=!1;break}}r&&o.push(t[i],t[i+1],t[i+2])}return new Uint32Array(o)}(o,i,p),I&&(o=D(o),i=V(i));const a=v;v=!1,await Promise.all(s.map(e=>(M=performance.now(),r.buildTile(o,i,e,a).then(()=>{const t=e[0]+","+e[1];g.set(t,(g.get(t)??0)+1),this.debug})))).then(()=>{this.debug,B=!1})}else B=!1},this.refreshMs??1e4);this.disposed.subscribe(()=>S()),r.onNavMeshUpdate.pipe(y(this.disposed),w(200)).subscribe(()=>{h.clear(),h.drawNavMesh(r.navMesh)}),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(h)),this.disposed.subscribe(()=>{r?.destroy(),h.removeFromParent(),h.dispose()});const z=performance.now()-l;z>1e3&&console.warn(`NavMesh update took ${z} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([z(),t("design:type",Boolean)],O.prototype,"debug",void 0),e([z(),t("design:type",Number)],O.prototype,"walkableClimb",void 0),e([z({range:[0,89]}),t("design:type",Number)],O.prototype,"walkableSlopeAngle",void 0),e([z(),t("design:type",Number)],O.prototype,"walkableHeight",void 0),e([z({range:[.01,10]}),t("design:type",Number)],O.prototype,"cellSize",void 0),O=e([B()],O);export default O;const W=new Map,_=new WeakMap;function L(e){if(e.shape instanceof l)return function(e){const t=e.shape;if(t.type!==c.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const s=t,o=s.heights,i=s.nrows,r=s.ncols,a=s.scale.x,l=s.scale.z,h=s.scale.y,p=i+1,u=new x.PlaneGeometry(l,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[m+1]=o[t*p+e]*h,m+=3,0!=d[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,l,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i){const t=function(e){const t=_.get(e);if(void 0!==t)return t;const n=new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>>2);let s=2166136261;for(let e=0;e<n.length;e++)s=Math.imul(s^n[e],16777619)>>>0;return _.set(e,s),s}(e.shape.vertices);let n=W.get(t);return n||(n=function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new M).setFromPoints(t),s=[];n.faces.forEach(e=>{const t=e.edge.head().point,n=e.edge.next.head().point,o=e.edge.next.next.head().point;s.push(t.x,t.y,t.z),s.push(n.x,n.y,n.z),s.push(o.x,o.y,o.z)});const o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(s,3)),o}(e.shape.vertices),W.set(t,n)),n}if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?s.setIndex(new x.Uint16BufferAttribute(n,1)):s=v.mergeVertices(s),s.computeVertexNormals(),s}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function X(e){const t=L(e);if(null==t)return null;const n=K,s=new x.Mesh(t,n);return s.geometry.computeBoundingBox(),s.geometry.scale(1.01,1.01,1.01),s}function $(e,t){const n=e.translation(),s=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(s.x,s.y,s.z,s.w)}const J=new x.Box3,K=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as t,__metadata as e}from"tslib";import{Actor as o,attach as i,BaseActor as p,Component as n,inject as r,Parameter as s}from"
|
|
1
|
+
import{__decorate as t,__metadata as e}from"tslib";import{Actor as o,attach as i,BaseActor as p,Component as n,inject as r,Parameter as s}from"../../index.js";import{Texture as a}from"three";import{tonemapMappings as d}from"../../../rendering/tone-mapping.js";import{OBB as l}from"three/examples/jsm/math/OBB.js";import{Vector3 as g}from"three";import*as u from"three";import{RenderingView as y}from"../../../rendering.js";import{TriggerVolumeMesh as h}from"./components/volume-editor-component.js";import{ActorComponent as m}from"../../actors/component.js";const b=[0,2],v=[-1,1];function f(t,e){return{optional:!0,type:g,group:t,label:e,range:b,precision:3,stepSize:.01,defaultValue:new g(1,1,1),editorInput:"colorGrade"}}function c(t,e){return{optional:!0,type:g,group:t,label:e,range:v,precision:3,stepSize:.01,defaultValue:new g(0,0,0),editorInput:"colorGrade"}}let w=class extends m{};t([s({options:d,optional:!0,group:"Tone Mapping",label:"Tone Mapping"}),e("design:type",Number)],w.prototype,"tonemapMapping",void 0),t([s({optional:!0,group:"Tone Mapping",label:"Tone Mapping Exposure",defaultValue:1}),e("design:type",Number)],w.prototype,"tonemapExposure",void 0),t([s({optional:!0}),e("design:type",a)],w.prototype,"envTexture",void 0),t([s({optional:!0,defaultValue:1}),e("design:type",Number)],w.prototype,"envIntensity",void 0),t([s({optional:!0,group:"Lens",defaultValue:0}),e("design:type",Number)],w.prototype,"vignetteIntensity",void 0),t([s({optional:!0,group:"Color Correction",defaultValue:new u.Color(16777215)}),e("design:type",u.Color)],w.prototype,"colorTint",void 0),t([s({optional:!0,group:"Color Correction",defaultValue:0}),e("design:type",Number)],w.prototype,"colorTintIntensity",void 0),t([s({optional:!0,group:"Depth of Field"}),e("design:type",Number)],w.prototype,"depthFocus",void 0),t([s({optional:!0,group:"Depth of Field"}),e("design:type",Number)],w.prototype,"depthAperture",void 0),t([s({optional:!0,group:"Depth of Field"}),e("design:type",Number)],w.prototype,"depthMaxBlur",void 0),t([s({optional:!0,range:[1e3,4e4],precision:.1,group:"White Balance",defaultValue:6500}),e("design:type",Number)],w.prototype,"temperature",void 0),t([s({optional:!0,range:[-1,1],group:"White Balance",defaultValue:0}),e("design:type",Number)],w.prototype,"temperatureTint",void 0),t([s(f("Global","Saturation")),e("design:type",g)],w.prototype,"globalSaturation",void 0),t([s(f("Global","Contrast")),e("design:type",g)],w.prototype,"globalContrast",void 0),t([s(f("Global","Gamma")),e("design:type",g)],w.prototype,"globalGamma",void 0),t([s(f("Global","Gain")),e("design:type",g)],w.prototype,"globalGain",void 0),t([s(c("Global","Offset")),e("design:type",g)],w.prototype,"globalOffset",void 0),t([s(f("Shadows","Saturation")),e("design:type",g)],w.prototype,"shadowsSaturation",void 0),t([s(f("Shadows","Contrast")),e("design:type",g)],w.prototype,"shadowsContrast",void 0),t([s(f("Shadows","Gamma")),e("design:type",g)],w.prototype,"shadowsGamma",void 0),t([s(f("Shadows","Gain")),e("design:type",g)],w.prototype,"shadowsGain",void 0),t([s(c("Shadows","Offset")),e("design:type",g)],w.prototype,"shadowsOffset",void 0),t([s({optional:!0,group:"Shadows",label:"Max",range:[0,1],precision:3,stepSize:.01,defaultValue:.09}),e("design:type",Number)],w.prototype,"shadowsMax",void 0),t([s(f("Midtones","Saturation")),e("design:type",g)],w.prototype,"midtonesSaturation",void 0),t([s(f("Midtones","Contrast")),e("design:type",g)],w.prototype,"midtonesContrast",void 0),t([s(f("Midtones","Gamma")),e("design:type",g)],w.prototype,"midtonesGamma",void 0),t([s(f("Midtones","Gain")),e("design:type",g)],w.prototype,"midtonesGain",void 0),t([s(c("Midtones","Offset")),e("design:type",g)],w.prototype,"midtonesOffset",void 0),t([s(f("Highlights","Saturation")),e("design:type",g)],w.prototype,"highlightsSaturation",void 0),t([s(f("Highlights","Contrast")),e("design:type",g)],w.prototype,"highlightsContrast",void 0),t([s(f("Highlights","Gamma")),e("design:type",g)],w.prototype,"highlightsGamma",void 0),t([s(f("Highlights","Gain")),e("design:type",g)],w.prototype,"highlightsGain",void 0),t([s(c("Highlights","Offset")),e("design:type",g)],w.prototype,"highlightsOffset",void 0),t([s({optional:!0,group:"Highlights",label:"Min",range:[0,1],precision:3,stepSize:.01,defaultValue:.5}),e("design:type",Number)],w.prototype,"highlightsMin",void 0),t([s({label:"LUT",optional:!0,group:"LUT"}),e("design:type",a)],w.prototype,"lut",void 0),t([s({label:"LUT Intensity",range:[0,1],optional:!0,group:"LUT",defaultValue:0}),e("design:type",Number)],w.prototype,"lutIntensity",void 0),w=t([n()],w);export{w as PostProcessSettings};let G=class extends p{constructor(){super(),this.settings=i(w),this.bounded=!1,this.priority=0,this.blendWeight=1,this.blendRadius=0,this.box=new l(void 0,new u.Vector3(.5,.5,.5)),this.view=r(y),this.editorView=i(h),this.disposed.subscribe(()=>{this.view.removePostProcessVolume(this)})}onInit(){this.view.addPostProcessVolume(this),this.editorView.visible=this.bounded}containsPoint(t){return!this.bounded||(this.resetBox(),this.box.containsPoint(t))}distanceToPoint(t){return this.bounded?(this.resetBox(),this.box.clampPoint(t,S),S.distanceTo(t)):0}resetBox(){const t=this.box;t.center.set(0,0,0),t.halfSize.set(.5,.5,.5),t.rotation.copy(x.rotation),t.applyMatrix4(this.object.matrixWorld)}};t([s(),e("design:type",Boolean)],G.prototype,"bounded",void 0),t([s({precision:0}),e("design:type",Number)],G.prototype,"priority",void 0),t([s({range:[0,1]}),e("design:type",Number)],G.prototype,"blendWeight",void 0),t([s(),e("design:type",Number)],G.prototype,"blendRadius",void 0),G=t([o(),e("design:paramtypes",[])],G);export{G as PostProcessVolume};const x=new l,S=new g;/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Constructable } from 'typedi';
|
|
2
|
-
import { BaseActor } from './actor.js';
|
|
1
|
+
import type { Constructable } from 'typedi';
|
|
2
|
+
import type { BaseActor } from './actor.js';
|
|
3
3
|
export { getComponentClassById, getComponentClassId, getRegisteredComponentClasses, } from './type-registry.js';
|
|
4
4
|
export type ActorComponentParams<T extends ActorComponent> = {
|
|
5
5
|
[K in Exclude<keyof T, keyof ActorComponent> as T[K] extends (...args: any[]) => any ? never : K]: T[K];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{BaseActor as o}from"../actor";export class ActorController extends o{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BasePlayerController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BaseAIController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}/*
|
|
1
|
+
import{BaseActor as o}from"../actor.js";export class ActorController extends o{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BasePlayerController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BaseAIController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseActor } from '../actor.js';
|
|
1
|
+
import type { BaseActor } from '../actor.js';
|
|
2
2
|
import { ActorComponent } from '../component.js';
|
|
3
3
|
export declare function initComponents(a: BaseActor | ActorComponent, actor: BaseActor, inEditor?: boolean): Promise<any[]>;
|
|
4
4
|
export declare function initComponentsSync(a: BaseActor | ActorComponent, actor: BaseActor, inEditor?: boolean): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ContainerInstance } from "typedi";
|
|
2
|
-
import { BaseActor } from '../actor.js';
|
|
1
|
+
import type { ContainerInstance } from "typedi";
|
|
2
|
+
import type { BaseActor } from '../actor.js';
|
|
3
3
|
export declare const containerRefMap: WeakMap<BaseActor, ContainerInstance>;
|
|
4
4
|
export declare const activeContainerInstance: {
|
|
5
5
|
value: any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
|
-
import type { CharacterMovementLike } from "../../../gameplay/actors";
|
|
3
|
-
import { Navigation } from "../navigation";
|
|
4
|
-
import { LeafNode, NodeState } from "./bt";
|
|
2
|
+
import type { CharacterMovementLike } from "../../../gameplay/actors/index.js";
|
|
3
|
+
import type { Navigation } from "../navigation.js";
|
|
4
|
+
import { LeafNode, NodeState } from "./bt.js";
|
|
5
5
|
export declare class CharacterMoveToNode extends LeafNode {
|
|
6
6
|
private navigation;
|
|
7
7
|
private movement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Vector3 as t}from"three";import{LeafNode as e,NodeState as o}from"./bt";export class CharacterMoveToNode extends e{constructor(t,e){super(),this.navigation=t,this.movement=e,this.distanceFrom=.5}tick(t){const e=this.movement.actor.object.position,i=null!=this.target?this.target():null;if(null==i)return this.movement.directionInput.vector.set(0,0),o.FAILURE;if(e.distanceTo(i)<this.distanceFrom)return this.movement.directionInput.vector.set(0,0),o.SUCCESS;const{success:
|
|
1
|
+
import{Vector3 as t}from"three";import{LeafNode as e,NodeState as o}from"./bt.js";export class CharacterMoveToNode extends e{constructor(t,e){super(),this.navigation=t,this.movement=e,this.distanceFrom=.5}tick(t){const e=this.movement.actor.object.position,i=null!=this.target?this.target():null;if(null==i)return this.movement.directionInput.vector.set(0,0),o.FAILURE;if(e.distanceTo(i)<this.distanceFrom)return this.movement.directionInput.vector.set(0,0),o.SUCCESS;const{success:s,path:r}=this.navigation.findPath(e,i);if(!s||r.length<2)return o.FAILURE;const c=r[1],a=n.subVectors(c,e);return a.y=0,a.normalize(),this.movement.rotationInput.rotation.y=Math.atan2(a.x,a.z),this.movement.directionInput.togglePositiveY(!0),o.RUNNING}}const n=new t;/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|