@hology/core 0.0.234 → 0.0.236
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 +7 -3
- package/dist/effects/vfx/vfx-defs.js +1 -1
- 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/character/character-movement-like.d.ts +2 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +13 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/root-motion-constraint.d.ts +7 -0
- package/dist/gameplay/actors/builtin/components/character/root-motion-constraint.js +4 -0
- 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/index.d.ts +1 -0
- package/dist/gameplay/actors/index.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/node-material-webgpu-resolver.js +1 -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/test/character-root-motion-constraint.test.d.ts +2 -0
- package/dist/test/character-root-motion-constraint.test.js +4 -0
- package/dist/test/node-material-webgpu-resolver.test.js +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 +3 -2
- 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;
|
|
@@ -119,6 +121,7 @@ declare class PositionCircleDef extends BaseIniDef<PositionCircleDef> {
|
|
|
119
121
|
position: ShapeParameterDef<Vector3>;
|
|
120
122
|
rotation: ShapeParameterDef<Vector3>;
|
|
121
123
|
radius: FloatParameterDef;
|
|
124
|
+
angle: FloatParameterDef;
|
|
122
125
|
};
|
|
123
126
|
bindingAdapter: VfxBindingAdapter<Position>;
|
|
124
127
|
make(params?: ParamsType<this>): Initializer;
|
|
@@ -129,6 +132,7 @@ declare class PositionRingDef extends BaseIniDef<PositionRingDef> {
|
|
|
129
132
|
rotation: ShapeParameterDef<Vector3>;
|
|
130
133
|
radius: FloatParameterDef;
|
|
131
134
|
thickness: FloatParameterDef;
|
|
135
|
+
angle: FloatParameterDef;
|
|
132
136
|
};
|
|
133
137
|
bindingAdapter: VfxBindingAdapter<Position>;
|
|
134
138
|
make(params?: ParamsType<this>): Initializer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LoopOnce as e,LoopPingPong as t,LoopRepeat as s,MathUtils as n,Vector2 as r,Vector3 as a}from"three";import{Alpha as i,Attraction as o,BoxZone as c,CircleZone as p,Color as u,ease as d,Force as m,Gravity as l,Life as w,LineZone as f,Mass as h,Position as x,RadialVelocity as g,RandomDrift as b,Repulsion as y,Rotate as k,Vector3D as v}from"@hology/nebula";import{AnimationBehavior as A,AxisDirection as z,AxisPlane as R,Disperse as L,FollowParent as C,LinearDamping as D,MoveOverLife as S,OrientAlongVelocity as T,RotatePosition as V,Scale as j,ScaleComponents as Y}from"./behaviours.js";import{AdditiveVelocity as B,AlignRotation as F,alignRotationAxes as O,alignRotationModes as P,InitialScale as X,InitialScaleComponents as Z,RandomColor as I,RandomDirection as M,RandomRotation as K,randomRotationAxis as W,RandomScale as q,Rotation as E}from"./initializsers.js";import{PointZone as G,SphereZone as H}from"./zones.js";import{WorldCollisionBehaviour as J}from"./vfx-collision-behaviour.js";import{Curve2 as N}from"../../utils/curve.js";import{liveBindingAdapter as Q,spawnBindingAdapter as U}from"./vfx-binding-runtime.js";class ${build(e={}){const t=pe(e,this.parameters);return this.make(t)}}class _{build(e={}){const t=pe(e,this.parameters);return this.make(t)}}function ee(e,t,s){return{type:"number",default:e,float:!0,min:t,max:s}}function te(e,t,s,n){return{...ee(e,s,n),bindable:t}}function se(e){return{type:"boolean",default:e}}function ne(e){return{type:"vec3",default:(new a).fromArray(e)}}function re(e,t){return{...ne(e),bindable:t}}function ae(e){return{type:"color",default:e}}function ie(e,t){return{...ae(e),bindable:t}}function oe(e,t){return{type:"select",opts:e,default:t}}function ce(){return{type:"curve",default:N.linear()}}function pe(e,t){const s={};for(let n in t)null==e[n]?s[n]=t[n].default:s[n]=e[n];return s}function ue(e){return new v(e.x,e.y,e.z)}function de(e){return new a(n.degToRad(e.x),n.degToRad(e.y),n.degToRad(e.z))}function me(e){const{x:t,y:s,z:n}=e;return new G(t,s,n)}function le(e,t){const{x:s,y:n,z:r}=e,{x:a,y:i,z:o}=t;return new c(s,n,r,a,i,o)}function we(e,t,s=!1){const{x:n,y:r,z:a}=e;return new H(n,r,a,t,s)}function fe(e,t){return new f(e.x,e.y,e.z,t.x,t.y,t.z)}function he(e,t,s,r=0){return new p(e.x,e.y,e.z,s,r,n.degToRad(t.x),n.degToRad(t.y),n.degToRad(t.z))}function xe(e){return t=>e.getY(t)}const ge={lifetime:new class extends _{constructor(){super(...arguments),this.parameters={duration:te(1,"spawn",0,1e5)},this.bindingAdapter=U((e,t)=>{e.resetLife(t.duration)})}make(e={}){return new w(e.duration)}},randomLifetime:new class extends _{constructor(){super(...arguments),this.parameters={minDuration:te(1,"spawn",0,1e5),maxDuration:te(2,"spawn",0,1e5)},this.bindingAdapter=U((e,t)=>{e.resetLife(t.minDuration,t.maxDuration)})}make(e={}){return new w(e.minDuration,e.maxDuration)}},positionPoint:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{e.reset(me(t.position))})}make(e={}){return new x(me(e.position))}},positionBox:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),dimensions:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{e.reset(le(t.position,t.dimensions))})}make(e={}){return new x(le(e.position,e.dimensions))}},positionSphere:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),radius:te(1,"spawn"),surface:se(!1)},this.bindingAdapter=U((e,t)=>{e.reset(we(t.position,t.radius,t.surface))})}make(e={}){return new x(we(e.position,e.radius,e.surface))}},positionLine:new class extends _{constructor(){super(...arguments),this.parameters={a:re([0,0,0],"spawn"),b:re([0,0,1],"spawn")},this.bindingAdapter=U((e,t)=>{e.reset(fe(t.a,t.b))})}make(e={}){return new x(fe(e.a,e.b))}},positionCircle:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),rotation:re([0,0,0],"spawn"),radius:te(1,"spawn",0,1e4)},this.bindingAdapter=U((e,t)=>{e.reset(he(t.position,t.rotation,t.radius))})}make(e={}){return new x(he(e.position,e.rotation,e.radius))}},positionRing:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),rotation:re([0,0,0],"spawn"),radius:te(1,"spawn",0,1e4),thickness:te(.2,"spawn",0,1e4)},this.bindingAdapter=U((e,t)=>{e.reset(he(t.position,t.rotation,t.radius,Math.max(t.thickness,1e-4)))})}make(e={}){return new x(he(e.position,e.rotation,e.radius,Math.max(e.thickness,1e-4)))}},rotation:new class extends _{constructor(){super(...arguments),this.parameters={rotation:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{e.setRotation(de(t.rotation))})}make(e={}){return new E(de(e.rotation))}},randomRotation:new class extends _{constructor(){super(...arguments),this.parameters={axis:oe(W,"XYZ")}}make(e={}){return new K(e.axis)}},scale:new class extends _{constructor(){super(...arguments),this.parameters={scale:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.setScale(t.scale)})}make(e={}){return new X(e.scale)}},scaleComponents:new class extends _{constructor(){super(...arguments),this.parameters={scale:re([1,1,1],"spawn")},this.bindingAdapter=U((e,t)=>{e.setScaleComponents(t.scale)})}make(e={}){return new Z(e.scale)}},randomScale:new class extends _{constructor(){super(...arguments),this.parameters={min:te(1,"spawn"),max:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.setRange(t.min,t.max)})}make(e={}){return new q(e.min,e.max)}},randomColor:new class extends _{constructor(){super(...arguments),this.parameters={a:ie("#ffffff","spawn"),b:ie("#ffffff","spawn")},this.bindingAdapter=U((e,t)=>{e.setRange(t.a,t.b)})}make(e={}){return new I(e.a,e.b)}},mass:new class extends _{constructor(){super(...arguments),this.parameters={min:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.resetMass(t.min)})}make(e={}){return new h(e.min)}},velocity:new class extends _{constructor(){super(...arguments),this.parameters={velocity:re([0,0,0],"spawn")},this.bindingAdapter={buildBound:e=>new B(()=>e.get("velocity"))}}make(e={}){const{x:t,y:s,z:n}=e.velocity;return new B(new a(t,s,n))}},randomVelocity:new class extends _{constructor(){super(...arguments),this.parameters={min:re([0,0,0],"spawn"),max:re([0,0,0],"spawn")},this.bindingAdapter={buildBound:e=>new B(()=>e.get("min"),()=>e.get("max"))}}make(e={}){return new B(e.min,e.max)}},radialVelocity:new class extends _{constructor(){super(...arguments),this.parameters={speed:te(1,"spawn"),direction:re([0,1,0],"spawn"),spread:te(0,"spawn")},this.bindingAdapter=U((e,t)=>{e.resetRadialVelocity(t.speed,ue(t.direction),t.spread)})}make(e={}){return new g(e.speed,ue(e.direction),e.spread)}},randomDirection:new class extends _{constructor(){super(...arguments),this.parameters={speed:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.setSpeed(t.speed)})}make(e={}){return new M(e.speed)}},alignRotation:new class extends _{constructor(){super(...arguments),this.parameters={mode:oe(P,"AwayFromCenter"),axis:oe(O,"+Y"),offset:ne([0,0,0]),center:ne([0,0,0])}}make(e={}){return new F(e.axis,e.mode,de(e.offset),e.center)}}},be={force:new class extends ${constructor(){super(...arguments),this.parameters={force:re([0,0,0],"live"),ease:ce()},this.bindingAdapter=Q((e,t)=>{const s=t.force;e.setForce(s.x,s.y,s.z)})}make(e={}){return new m(e.force.x,e.force.y,e.force.z,void 0,xe(e.ease))}},gravity:new class extends ${constructor(){super(...arguments),this.parameters={gravity:te(8,"live"),easing:ce()},this.bindingAdapter=Q((e,t)=>{e.setForce(0,-t.gravity,0)})}make(e={}){return new l(e.gravity,void 0,xe(e.easing))}},repulsion:new class extends ${constructor(){super(...arguments),this.parameters={target:re([0,0,0],"live"),force:te(1,"live"),radius:te(1,"live"),easing:ce()},this.bindingAdapter=Q((e,t)=>{e.resetAttraction(ue(t.target),t.force,t.radius)})}make(e={}){const t=ue(e.target);return new y(t,e.force,e.radius,void 0,xe(e.easing))}},attraction:new class extends ${constructor(){super(...arguments),this.parameters={target:re([0,0,0],"live"),force:te(1,"live"),radius:te(1,"live"),easing:ce()},this.bindingAdapter=Q((e,t)=>{e.resetAttraction(ue(t.target),t.force,t.radius)})}make(e={}){const t=ue(e.target);return new o(t,e.force,e.radius,void 0,xe(e.easing))}},scale:new class extends ${constructor(){super(...arguments),this.parameters={a:te(1,"spawn"),b:te(1,"spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.setScaleRange(t.a,t.b)})}make(e={}){return new j(e.a,e.b,xe(e.ease))}},scaleComponents:new class extends ${constructor(){super(...arguments),this.parameters={a:re([1,1,1],"spawn"),b:re([1,1,1],"spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.setScaleRange(t.a,t.b)})}make(e={}){return new Y(e.a,e.b,xe(e.ease))}},randomDrift:new class extends ${constructor(){super(...arguments),this.parameters={drift:re([1,1,1],"live"),delay:te(0,"live"),ease:ce()},this.bindingAdapter=Q((e,t)=>{const s=t.drift;e.setDrift(s.x,s.y,s.z,t.delay)})}make(e={}){return new b(e.drift.x,e.drift.y,e.drift.z,e.delay,void 0,xe(e.ease))}},disperse:new class extends ${constructor(){super(...arguments),this.parameters={distance:te(1,"spawn"),axis:oe(["XYZ","XZ","XY","YZ"],"XYZ"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.setDistance(t.distance)})}make(e={}){return new L(e.distance,R[e.axis.toLowerCase()],xe(e.ease))}},rotate:new class extends ${constructor(){super(...arguments),this.parameters={rotation:re([0,0,0],"spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{const s=de(t.rotation);e.resetRotation(s.x,s.y,s.z)})}make(e={}){const t=de(e.rotation);return new k(t.x,t.y,t.z,void 0,xe(e.ease))}},rotateAdd:new class extends ${constructor(){super(...arguments),this.parameters={rotation:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{const s=de(t.rotation);e.resetRotation(s.x,s.y,s.z)})}make(e={}){const t=de(e.rotation),s=new k(t.x,t.y,t.z,void 0);return s.rotationType="add",s}},changeColor:new class extends ${constructor(){super(...arguments),this.parameters={a:ie("#ffffff","spawn"),b:ie("#ffffff","spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.resetColor(t.a,t.b)})}make(e={}){return new u(e.a,e.b,void 0,xe(e.ease))}},changeOpacity:new class extends ${constructor(){super(...arguments),this.parameters={a:te(1,"spawn",0,1),b:te(0,"spawn",0,1),ease:ce()},this.bindingAdapter=U((e,t)=>{e.resetAlpha(t.a,t.b)})}make(e={}){return new i(e.a,e.b,void 0,xe(e.ease))}},vortex:new class extends ${constructor(){super(...arguments),this.parameters={axis:re([0,1,0],"live"),amount:te(1,"live")},this.bindingAdapter=Q((e,t)=>{e.setAxisAngle(t.axis,t.amount)})}make(e={}){return new V(e.axis,e.amount)}},moveTo:new class extends ${constructor(){super(...arguments),this.parameters={target:re([0,1,0],"live"),ease:ce()},this.bindingAdapter=Q((e,t)=>{const s=t.target;e.setTarget(s.x,s.y,s.z)})}make(e={}){return new S(e.target.x,e.target.y,e.target.z,xe(e.ease))}},linearDamping:new class extends ${constructor(){super(...arguments),this.parameters={factor:te(.1,"live",0,1e3)},this.bindingAdapter=Q((e,t)=>{e.setFactor(t.factor)})}make(e={}){return new D(e.factor)}},followParent:new class extends ${constructor(){super(...arguments),this.parameters={speed:te(0,"live")},this.bindingAdapter=Q((e,t)=>{e.setSpeed(t.speed)})}make(e={}){return new C(e.speed)}},worldCollision:new class extends ${constructor(){super(...arguments),this.parameters={friction:ee(1,0,1),bounce:ee(1,0,1),lifeLoss:ee(0,0)}}make(e={}){return new J(null,e.bounce,e.friction,e.lifeLoss)}},animation:new class extends ${constructor(){super(...arguments),this.parameters={clip:{type:"animationclip",default:null},timeScale:ee(1,0,10),weight:ee(1,0,1),loop:oe(["Once","Repeat","PingPong"],"Once"),clampWhenFinished:{...se(!0),requires:{loop:"Once"}}}}make(n={}){let r=e;return"Repeat"===n.loop?r=s:"PingPong"===n.loop&&(r=t),new A(n.clip,n.timeScale,n.weight,r,n.clampWhenFinished,d.easeLinear)}}};export const VfxInitializserLibrary=ge;export const VfxInitializserLibraryKeys=Object.keys(VfxInitializserLibrary);export const VfxBehaviourLibrary=be;export const VfxBehaviourLibraryKeys=Object.keys(VfxBehaviourLibrary);/*
|
|
1
|
+
import{LoopOnce as e,LoopPingPong as t,LoopRepeat as n,MathUtils as s,Vector2 as r,Vector3 as a}from"three";import{Alpha as i,Attraction as o,BoxZone as c,CircleZone as p,Color as d,ease as u,Force as l,Gravity as m,Life as w,LineZone as f,Mass as h,Position as x,RadialVelocity as g,RandomDrift as b,Repulsion as y,Rotate as k,Vector3D as v}from"@hology/nebula";import{AnimationBehavior as A,AxisDirection as z,AxisPlane as R,Disperse as L,FollowParent as C,LinearDamping as D,MoveOverLife as S,OrientAlongVelocity as T,RotatePosition as V,Scale as j,ScaleComponents as Y}from"./behaviours.js";import{AdditiveVelocity as B,AlignRotation as F,alignRotationAxes as O,alignRotationModes as P,InitialScale as X,InitialScaleComponents as Z,RandomColor as I,RandomDirection as M,RandomRotation as K,randomRotationAxis as W,RandomScale as q,Rotation as E}from"./initializsers.js";import{PointZone as G,SphereZone as H}from"./zones.js";import{WorldCollisionBehaviour as J}from"./vfx-collision-behaviour.js";import{Curve2 as N}from"../../utils/curve.js";import{liveBindingAdapter as Q,spawnBindingAdapter as U}from"./vfx-binding-runtime.js";class ${build(e={}){const t=pe(e,this.parameters);return this.make(t)}}class _{build(e={}){const t=pe(e,this.parameters);return this.make(t)}}function ee(e,t,n){return{type:"number",default:e,float:!0,min:t,max:n}}function te(e,t,n,s){return{...ee(e,n,s),bindable:t}}function ne(e){return{type:"boolean",default:e}}function se(e){return{type:"vec3",default:(new a).fromArray(e)}}function re(e,t){return{...se(e),bindable:t}}function ae(e){return{type:"color",default:e}}function ie(e,t){return{...ae(e),bindable:t}}function oe(e,t){return{type:"select",opts:e,default:t}}function ce(){return{type:"curve",default:N.linear()}}function pe(e,t){const n={};for(let s in t)null==e[s]?n[s]=t[s].default:n[s]=e[s];return n}function de(e){return new v(e.x,e.y,e.z)}function ue(e){return new a(s.degToRad(e.x),s.degToRad(e.y),s.degToRad(e.z))}function le(e){const{x:t,y:n,z:s}=e;return new G(t,n,s)}function me(e,t){const{x:n,y:s,z:r}=e,{x:a,y:i,z:o}=t;return new c(n,s,r,a,i,o)}function we(e,t,n=!1){const{x:s,y:r,z:a}=e;return new H(s,r,a,t,n)}function fe(e,t){return new f(e.x,e.y,e.z,t.x,t.y,t.z)}function he(e,t,n,r=0,a=360){return new p(e.x,e.y,e.z,n,r,s.degToRad(t.x),s.degToRad(t.y),s.degToRad(t.z),s.degToRad(a))}function xe(e){return t=>e.getY(t)}const ge={lifetime:new class extends _{constructor(){super(...arguments),this.parameters={duration:te(1,"spawn",0,1e5)},this.bindingAdapter=U((e,t)=>{e.resetLife(t.duration)})}make(e={}){return new w(e.duration)}},randomLifetime:new class extends _{constructor(){super(...arguments),this.parameters={minDuration:te(1,"spawn",0,1e5),maxDuration:te(2,"spawn",0,1e5)},this.bindingAdapter=U((e,t)=>{e.resetLife(t.minDuration,t.maxDuration)})}make(e={}){return new w(e.minDuration,e.maxDuration)}},positionPoint:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{e.reset(le(t.position))})}make(e={}){return new x(le(e.position))}},positionBox:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),dimensions:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{e.reset(me(t.position,t.dimensions))})}make(e={}){return new x(me(e.position,e.dimensions))}},positionSphere:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),radius:te(1,"spawn"),surface:ne(!1)},this.bindingAdapter=U((e,t)=>{e.reset(we(t.position,t.radius,t.surface))})}make(e={}){return new x(we(e.position,e.radius,e.surface))}},positionLine:new class extends _{constructor(){super(...arguments),this.parameters={a:re([0,0,0],"spawn"),b:re([0,0,1],"spawn")},this.bindingAdapter=U((e,t)=>{e.reset(fe(t.a,t.b))})}make(e={}){return new x(fe(e.a,e.b))}},positionCircle:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),rotation:re([0,0,0],"spawn"),radius:te(1,"spawn",0,1e4),angle:te(360,"spawn",0,360)},this.bindingAdapter=U((e,t)=>{e.reset(he(t.position,t.rotation,t.radius,0,t.angle))})}make(e={}){return new x(he(e.position,e.rotation,e.radius,0,e.angle))}},positionRing:new class extends _{constructor(){super(...arguments),this.parameters={position:re([0,0,0],"spawn"),rotation:re([0,0,0],"spawn"),radius:te(1,"spawn",0,1e4),thickness:te(.2,"spawn",0,1e4),angle:te(360,"spawn",0,360)},this.bindingAdapter=U((e,t)=>{e.reset(he(t.position,t.rotation,t.radius,Math.max(t.thickness,1e-4),t.angle))})}make(e={}){return new x(he(e.position,e.rotation,e.radius,Math.max(e.thickness,1e-4),e.angle))}},rotation:new class extends _{constructor(){super(...arguments),this.parameters={rotation:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{e.setRotation(ue(t.rotation))})}make(e={}){return new E(ue(e.rotation))}},randomRotation:new class extends _{constructor(){super(...arguments),this.parameters={axis:oe(W,"XYZ")}}make(e={}){return new K(e.axis)}},scale:new class extends _{constructor(){super(...arguments),this.parameters={scale:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.setScale(t.scale)})}make(e={}){return new X(e.scale)}},scaleComponents:new class extends _{constructor(){super(...arguments),this.parameters={scale:re([1,1,1],"spawn")},this.bindingAdapter=U((e,t)=>{e.setScaleComponents(t.scale)})}make(e={}){return new Z(e.scale)}},randomScale:new class extends _{constructor(){super(...arguments),this.parameters={min:te(1,"spawn"),max:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.setRange(t.min,t.max)})}make(e={}){return new q(e.min,e.max)}},randomColor:new class extends _{constructor(){super(...arguments),this.parameters={a:ie("#ffffff","spawn"),b:ie("#ffffff","spawn")},this.bindingAdapter=U((e,t)=>{e.setRange(t.a,t.b)})}make(e={}){return new I(e.a,e.b)}},mass:new class extends _{constructor(){super(...arguments),this.parameters={min:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.resetMass(t.min)})}make(e={}){return new h(e.min)}},velocity:new class extends _{constructor(){super(...arguments),this.parameters={velocity:re([0,0,0],"spawn")},this.bindingAdapter={buildBound:e=>new B(()=>e.get("velocity"))}}make(e={}){const{x:t,y:n,z:s}=e.velocity;return new B(new a(t,n,s))}},randomVelocity:new class extends _{constructor(){super(...arguments),this.parameters={min:re([0,0,0],"spawn"),max:re([0,0,0],"spawn")},this.bindingAdapter={buildBound:e=>new B(()=>e.get("min"),()=>e.get("max"))}}make(e={}){return new B(e.min,e.max)}},radialVelocity:new class extends _{constructor(){super(...arguments),this.parameters={speed:te(1,"spawn"),direction:re([0,1,0],"spawn"),spread:te(0,"spawn")},this.bindingAdapter=U((e,t)=>{e.resetRadialVelocity(t.speed,de(t.direction),t.spread)})}make(e={}){return new g(e.speed,de(e.direction),e.spread)}},randomDirection:new class extends _{constructor(){super(...arguments),this.parameters={speed:te(1,"spawn")},this.bindingAdapter=U((e,t)=>{e.setSpeed(t.speed)})}make(e={}){return new M(e.speed)}},alignRotation:new class extends _{constructor(){super(...arguments),this.parameters={mode:oe(P,"AwayFromCenter"),axis:oe(O,"+Y"),offset:se([0,0,0]),center:se([0,0,0])}}make(e={}){return new F(e.axis,e.mode,ue(e.offset),e.center)}}},be={force:new class extends ${constructor(){super(...arguments),this.parameters={force:re([0,0,0],"live"),ease:ce()},this.bindingAdapter=Q((e,t)=>{const n=t.force;e.setForce(n.x,n.y,n.z)})}make(e={}){return new l(e.force.x,e.force.y,e.force.z,void 0,xe(e.ease))}},gravity:new class extends ${constructor(){super(...arguments),this.parameters={gravity:te(8,"live"),easing:ce()},this.bindingAdapter=Q((e,t)=>{e.setForce(0,-t.gravity,0)})}make(e={}){return new m(e.gravity,void 0,xe(e.easing))}},repulsion:new class extends ${constructor(){super(...arguments),this.parameters={target:re([0,0,0],"live"),force:te(1,"live"),radius:te(1,"live"),easing:ce()},this.bindingAdapter=Q((e,t)=>{e.resetAttraction(de(t.target),t.force,t.radius)})}make(e={}){const t=de(e.target);return new y(t,e.force,e.radius,void 0,xe(e.easing))}},attraction:new class extends ${constructor(){super(...arguments),this.parameters={target:re([0,0,0],"live"),force:te(1,"live"),radius:te(1,"live"),easing:ce()},this.bindingAdapter=Q((e,t)=>{e.resetAttraction(de(t.target),t.force,t.radius)})}make(e={}){const t=de(e.target);return new o(t,e.force,e.radius,void 0,xe(e.easing))}},scale:new class extends ${constructor(){super(...arguments),this.parameters={a:te(1,"spawn"),b:te(1,"spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.setScaleRange(t.a,t.b)})}make(e={}){return new j(e.a,e.b,xe(e.ease))}},scaleComponents:new class extends ${constructor(){super(...arguments),this.parameters={a:re([1,1,1],"spawn"),b:re([1,1,1],"spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.setScaleRange(t.a,t.b)})}make(e={}){return new Y(e.a,e.b,xe(e.ease))}},randomDrift:new class extends ${constructor(){super(...arguments),this.parameters={drift:re([1,1,1],"live"),delay:te(0,"live"),ease:ce()},this.bindingAdapter=Q((e,t)=>{const n=t.drift;e.setDrift(n.x,n.y,n.z,t.delay)})}make(e={}){return new b(e.drift.x,e.drift.y,e.drift.z,e.delay,void 0,xe(e.ease))}},disperse:new class extends ${constructor(){super(...arguments),this.parameters={distance:te(1,"spawn"),axis:oe(["XYZ","XZ","XY","YZ"],"XYZ"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.setDistance(t.distance)})}make(e={}){return new L(e.distance,R[e.axis.toLowerCase()],xe(e.ease))}},rotate:new class extends ${constructor(){super(...arguments),this.parameters={rotation:re([0,0,0],"spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{const n=ue(t.rotation);e.resetRotation(n.x,n.y,n.z)})}make(e={}){const t=ue(e.rotation);return new k(t.x,t.y,t.z,void 0,xe(e.ease))}},rotateAdd:new class extends ${constructor(){super(...arguments),this.parameters={rotation:re([0,0,0],"spawn")},this.bindingAdapter=U((e,t)=>{const n=ue(t.rotation);e.resetRotation(n.x,n.y,n.z)})}make(e={}){const t=ue(e.rotation),n=new k(t.x,t.y,t.z,void 0);return n.rotationType="add",n}},changeColor:new class extends ${constructor(){super(...arguments),this.parameters={a:ie("#ffffff","spawn"),b:ie("#ffffff","spawn"),ease:ce()},this.bindingAdapter=U((e,t)=>{e.resetColor(t.a,t.b)})}make(e={}){return new d(e.a,e.b,void 0,xe(e.ease))}},changeOpacity:new class extends ${constructor(){super(...arguments),this.parameters={a:te(1,"spawn",0,1),b:te(0,"spawn",0,1),ease:ce()},this.bindingAdapter=U((e,t)=>{e.resetAlpha(t.a,t.b)})}make(e={}){return new i(e.a,e.b,void 0,xe(e.ease))}},vortex:new class extends ${constructor(){super(...arguments),this.parameters={axis:re([0,1,0],"live"),amount:te(1,"live")},this.bindingAdapter=Q((e,t)=>{e.setAxisAngle(t.axis,t.amount)})}make(e={}){return new V(e.axis,e.amount)}},moveTo:new class extends ${constructor(){super(...arguments),this.parameters={target:re([0,1,0],"live"),ease:ce()},this.bindingAdapter=Q((e,t)=>{const n=t.target;e.setTarget(n.x,n.y,n.z)})}make(e={}){return new S(e.target.x,e.target.y,e.target.z,xe(e.ease))}},linearDamping:new class extends ${constructor(){super(...arguments),this.parameters={factor:te(.1,"live",0,1e3)},this.bindingAdapter=Q((e,t)=>{e.setFactor(t.factor)})}make(e={}){return new D(e.factor)}},followParent:new class extends ${constructor(){super(...arguments),this.parameters={speed:te(0,"live")},this.bindingAdapter=Q((e,t)=>{e.setSpeed(t.speed)})}make(e={}){return new C(e.speed)}},worldCollision:new class extends ${constructor(){super(...arguments),this.parameters={friction:ee(1,0,1),bounce:ee(1,0,1),lifeLoss:ee(0,0)}}make(e={}){return new J(null,e.bounce,e.friction,e.lifeLoss)}},animation:new class extends ${constructor(){super(...arguments),this.parameters={clip:{type:"animationclip",default:null},timeScale:ee(1,0,10),weight:ee(1,0,1),loop:oe(["Once","Repeat","PingPong"],"Once"),clampWhenFinished:{...ne(!0),requires:{loop:"Once"}}}}make(s={}){let r=e;return"Repeat"===s.loop?r=n:"PingPong"===s.loop&&(r=t),new A(s.clip,s.timeScale,s.weight,r,s.clampWhenFinished,u.easeLinear)}}};export const VfxInitializserLibrary=ge;export const VfxInitializserLibraryKeys=Object.keys(VfxInitializserLibrary);export const VfxBehaviourLibrary=be;export const VfxBehaviourLibraryKeys=Object.keys(VfxBehaviourLibrary);/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -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
|
*/
|
|
@@ -3,6 +3,7 @@ import type { ActionInput, AxisInput, RotationInput } from "../../../../../gamep
|
|
|
3
3
|
import type { BaseActor } from "../../../actor.js";
|
|
4
4
|
import type { RootMotionActionOptions } from "./old-character-movement.js";
|
|
5
5
|
import type { CharacterMovementMode } from "./modes.js";
|
|
6
|
+
import type { RootMotionConstraintHandle } from "./character-movement.js";
|
|
6
7
|
export type CharacterMovementLike = {
|
|
7
8
|
readonly actor: BaseActor;
|
|
8
9
|
readonly directionInput: AxisInput;
|
|
@@ -22,6 +23,7 @@ export type CharacterMovementLike = {
|
|
|
22
23
|
readonly slideSurfaceNormal?: Vector3;
|
|
23
24
|
applyImpulse(impulse: Vector3): void;
|
|
24
25
|
setRootMotionAction(action: AnimationAction, options?: RootMotionActionOptions): void;
|
|
26
|
+
addRootMotionTargetConstraint?(targetPosition: Vector3, minimumHorizontalDistance: number): RootMotionConstraintHandle;
|
|
25
27
|
readonly isDefaultCharacterMovementComponent?: boolean;
|
|
26
28
|
};
|
|
27
29
|
export declare function getCharacterMovementLike(actor: BaseActor): CharacterMovementLike | undefined;
|
|
@@ -36,6 +36,13 @@ export type NetCharacterMovementRuntimeState = {
|
|
|
36
36
|
prevInputDirection: Vector3;
|
|
37
37
|
prevRotateToMovementDirection: boolean;
|
|
38
38
|
};
|
|
39
|
+
export type RootMotionTargetConstraint = {
|
|
40
|
+
readonly targetPosition: Vector3;
|
|
41
|
+
readonly minimumHorizontalDistance: number;
|
|
42
|
+
};
|
|
43
|
+
export type RootMotionConstraintHandle = {
|
|
44
|
+
dispose(): void;
|
|
45
|
+
};
|
|
39
46
|
export declare class CharacterMovementComponent extends ActorComponent {
|
|
40
47
|
readonly isDefaultCharacterMovementComponent = true;
|
|
41
48
|
readonly directionInput: AxisInput;
|
|
@@ -152,6 +159,7 @@ export declare class CharacterMovementComponent extends ActorComponent {
|
|
|
152
159
|
private rootMotionInterpolant;
|
|
153
160
|
private rootMotionRootBone;
|
|
154
161
|
private rootMotionOptions;
|
|
162
|
+
private readonly rootMotionTargetConstraints;
|
|
155
163
|
private resetRootMotion;
|
|
156
164
|
private nextMoveSequence;
|
|
157
165
|
private clientMoveTime;
|
|
@@ -175,6 +183,11 @@ export declare class CharacterMovementComponent extends ActorComponent {
|
|
|
175
183
|
getEffectiveGravity(): number;
|
|
176
184
|
get isGrounded(): boolean;
|
|
177
185
|
setRootMotionAction(action: AnimationAction, options?: RootMotionActionOptions): void;
|
|
186
|
+
/**
|
|
187
|
+
* Prevent root motion from approaching a moving target closer than the
|
|
188
|
+
* requested horizontal distance.
|
|
189
|
+
*/
|
|
190
|
+
addRootMotionTargetConstraint(targetPosition: Vector3, minimumHorizontalDistance: number): RootMotionConstraintHandle;
|
|
178
191
|
serverMove(payload: Uint8Array): void;
|
|
179
192
|
clientMoveAck(payload: Uint8Array): void;
|
|
180
193
|
clientMoveCorrection(payload: Uint8Array): void;
|