@hology/core 0.0.31 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/csm.d.ts +1 -1
- package/dist/csm.js +1 -1
- package/dist/effects/vfx/index.d.ts +2 -2
- package/dist/effects/vfx/index.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +14 -7
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-actor.d.ts +2 -2
- package/dist/effects/vfx/vfx-actor.js +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +3 -3
- package/dist/effects/vfx/vfx-asset.js +1 -1
- package/dist/effects/vfx/vfx-defs.d.ts +5 -2
- package/dist/effects/vfx/vfx-defs.js +1 -1
- package/dist/effects/vfx/vfx-materializer.d.ts +2 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/effects/vfx/vfx-param.d.ts +1 -1
- package/dist/gameplay/actors/actor.d.ts +1 -1
- package/dist/gameplay/actors/actor.js +1 -1
- package/dist/gameplay/actors/builtin/camera-actor.d.ts +3 -3
- package/dist/gameplay/actors/builtin/camera-actor.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -3
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts +4 -4
- package/dist/gameplay/actors/builtin/components/character/character-movement copy.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +4 -4
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
- package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +2 -2
- package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/scene-component.d.ts +1 -1
- package/dist/gameplay/actors/builtin/components/scene-component.js +1 -1
- package/dist/gameplay/actors/builtin/index.d.ts +4 -4
- package/dist/gameplay/actors/builtin/index.js +1 -1
- package/dist/gameplay/actors/builtin/positional-audio-actor.d.ts +6 -5
- package/dist/gameplay/actors/builtin/positional-audio-actor.js +1 -1
- package/dist/gameplay/actors/builtin/spawn-point.d.ts +3 -3
- package/dist/gameplay/actors/builtin/spawn-point.js +1 -1
- package/dist/gameplay/actors/builtin/trigger-volume.d.ts +4 -4
- package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
- package/dist/gameplay/actors/camera/camera-component.d.ts +2 -2
- package/dist/gameplay/actors/camera/camera-component.js +1 -1
- package/dist/gameplay/actors/camera/third-party-camera-component.d.ts +5 -5
- package/dist/gameplay/actors/camera/third-party-camera-component.js +1 -1
- package/dist/gameplay/actors/component.d.ts +1 -1
- package/dist/gameplay/actors/component.js +1 -1
- package/dist/gameplay/actors/factory.d.ts +3 -3
- package/dist/gameplay/actors/factory.js +1 -1
- package/dist/gameplay/actors/index.d.ts +10 -10
- package/dist/gameplay/actors/index.js +1 -1
- package/dist/gameplay/actors/internal/component-init.d.ts +2 -2
- package/dist/gameplay/actors/internal/component-init.js +1 -1
- package/dist/gameplay/actors/internal/container-map.d.ts +1 -1
- package/dist/gameplay/animation/anim-sm.js +1 -1
- package/dist/gameplay/index.d.ts +14 -13
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.d.ts +4 -2
- package/dist/gameplay/initiate.js +1 -1
- package/dist/gameplay/inject.js +1 -1
- package/dist/gameplay/input/index.d.ts +3 -3
- package/dist/gameplay/input/index.js +1 -1
- package/dist/gameplay/input/input-service.d.ts +1 -1
- package/dist/gameplay/input/input-service.js +1 -1
- package/dist/gameplay/input/input.js +1 -1
- package/dist/gameplay/services/asset-loader.d.ts +6 -4
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/physics-system.d.ts +5 -5
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/pointer-events.d.ts +58 -0
- package/dist/gameplay/services/pointer-events.js +5 -0
- package/dist/gameplay/services/render.d.ts +3 -3
- package/dist/gameplay/services/render.js +1 -1
- package/dist/gameplay/services/world.d.ts +5 -2
- package/dist/gameplay/services/world.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/rendering.d.ts +7 -1
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +2 -2
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/assets-provider.d.ts +1 -1
- package/dist/scene/bootstrap.d.ts +7 -7
- package/dist/scene/bootstrap.js +1 -1
- package/dist/scene/collision/collision-shape-import.d.ts +1 -1
- package/dist/scene/collision/collision-shape-import.js +1 -1
- package/dist/scene/landscape/landscape-manager.d.ts +6 -6
- package/dist/scene/landscape/landscape-manager.js +1 -1
- package/dist/scene/landscape/landscape.js +1 -1
- package/dist/scene/landscape/utils.d.ts +1 -1
- package/dist/scene/landscape/utils.js +1 -1
- package/dist/scene/materializer.d.ts +10 -10
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/materials/grass-foliage.d.ts +2 -2
- package/dist/scene/materials/grass-foliage.js +1 -1
- package/dist/scene/materials/grass.d.ts +1 -1
- package/dist/scene/materials/grass.js +1 -1
- package/dist/scene/materials/water.d.ts +1 -1
- package/dist/scene/materials/water.js +1 -1
- package/dist/scene/model.d.ts +6 -5
- package/dist/scene/objects/shapes.d.ts +3 -3
- package/dist/scene/objects/shapes.js +1 -1
- package/dist/scene/runtime-asset-service.d.ts +3 -3
- package/dist/scene/runtime-asset-service.js +1 -1
- package/dist/scene/runtime-backend-service.d.ts +1 -1
- package/dist/scene/runtime-backend-service.js +1 -1
- package/dist/scene/scene-data-service.d.ts +1 -1
- package/dist/scene/scene-data-service.js +1 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/index.d.ts +2 -2
- package/dist/shader/builtin/index.js +1 -1
- package/dist/shader/builtin/lambert-shader.d.ts +1 -1
- package/dist/shader/builtin/lambert-shader.js +1 -1
- package/dist/shader/builtin/standard-shader.d.ts +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/index.d.ts +3 -2
- package/dist/shader/index.js +1 -1
- package/dist/shader/parameter.d.ts +4 -4
- package/dist/shader/parameter.js +1 -1
- package/dist/shader/shader.d.ts +4 -4
- package/dist/shader/shader.js +1 -1
- package/dist/shader-nodes/effects.js +1 -1
- package/dist/shader-nodes/index.d.ts +9 -9
- package/dist/shader-nodes/index.js +1 -1
- package/dist/shader-nodes/layers.js +1 -1
- package/dist/test/injection.test.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/three/depth-pass.js +1 -1
- package/dist/utils/three/outline-pass.d.ts +2 -2
- package/dist/utils/three/transform-controls.d.ts +2 -2
- package/dist/utils/three/traverse.d.ts +1 -0
- package/dist/utils/three/traverse.js +1 -1
- package/package.json +7 -8
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cannon/CannonUtils.d.ts +0 -17
- package/dist/utils/cannon/CannonUtils.js +0 -5
- package/dist/utils/cannon/three-to-cannon/ConvexHull.d.ts +0 -47
- package/dist/utils/cannon/three-to-cannon/ConvexHull.js +0 -5
- package/dist/utils/cannon/three-to-cannon/index.d.ts +0 -63
- package/dist/utils/cannon/three-to-cannon/index.js +0 -5
- package/dist/utils/cannon/three-to-cannon/utils.d.ts +0 -9
- package/dist/utils/cannon/three-to-cannon/utils.js +0 -5
package/dist/csm.d.ts
CHANGED
package/dist/csm.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import*as e from"three";const n=e.Object3D.prototype.add,
|
1
|
+
import*as e from"three";const n=e.Object3D.prototype.add,r=new WeakMap,a=new WeakMap;export const CSMUtil=new class{constructor(){this.renderingView=null}onBeforeCompile(n,r){n.defines=n.defines||{},n.defines.USE_CSM=1,n.defines.CSM_CASCADES=this.renderingView.csm.cascades;const a=this.renderingView.camera instanceof e.PerspectiveCamera?this.renderingView.camera.far:Number.MAX_SAFE_INTEGER,t=this.renderingView.camera instanceof e.PerspectiveCamera?this.renderingView.camera.near:0,i=Math.min(a,this.renderingView.csm.maxFar),s=[];this.renderingView.csm.getExtendedBreaks(s),r.uniforms.CSM_cascades={value:s},r.uniforms.cameraNear={value:t},r.uniforms.shadowFar={value:i}}patchThreeAdd(){const t=this.renderingView;r.set(t.scene,t.csm),e.Object3D.prototype.add=function(...t){let i=this;for(;null!=i.parent;)i=i.parent;const s=i,c=r.get(s);if(null==c)return n.apply(this,arguments),this;a.has(s)||a.set(s,new WeakSet);const o=a.get(s);function d(e){e&&!o.has(e)&&(o.add(e),c?.setupMaterial(e))}return t.forEach((n=>n?.traverse((n=>{if(n instanceof e.Mesh||n instanceof e.SkinnedMesh)if(n.material instanceof Array)for(const e of n.material)d(e);else d(n.material)})))),n.apply(this,arguments),this}}};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from './vfx-asset';
|
2
|
-
export * from './vfx-materializer';
|
1
|
+
export * from './vfx-asset.js';
|
2
|
+
export * from './vfx-materializer.js';
|
@@ -1,29 +1,34 @@
|
|
1
1
|
import { Vector3 } from "three";
|
2
|
-
import
|
3
|
-
|
2
|
+
import { Emitter, Particle } from "three-nebula";
|
3
|
+
declare const Rotation_base: any;
|
4
|
+
export declare class Rotation extends Rotation_base {
|
4
5
|
private rotation;
|
5
6
|
constructor(rotation: Vector3);
|
6
7
|
init(emitter: Emitter, particle: Particle): void;
|
7
8
|
}
|
8
|
-
|
9
|
+
declare const InitialScale_base: any;
|
10
|
+
export declare class InitialScale extends InitialScale_base {
|
9
11
|
private scale;
|
10
12
|
constructor(scale: number);
|
11
13
|
init(emitter: Emitter, particle: Particle): void;
|
12
14
|
}
|
13
|
-
|
15
|
+
declare const AdditiveVelocity_base: any;
|
16
|
+
export declare class AdditiveVelocity extends AdditiveVelocity_base {
|
14
17
|
private velocity;
|
15
18
|
constructor(velocity: Vector3);
|
16
19
|
init(emitter: Emitter, particle: Particle): void;
|
17
20
|
}
|
18
|
-
|
21
|
+
declare const RandomDirection_base: any;
|
22
|
+
export declare class RandomDirection extends RandomDirection_base {
|
19
23
|
private speed;
|
20
24
|
constructor(speed: number);
|
21
25
|
init(emitter: Emitter, particle: Particle): void;
|
22
26
|
}
|
27
|
+
declare const RandomComponentsDirection_base: any;
|
23
28
|
/**
|
24
29
|
* Restrict randomness with two vectors
|
25
30
|
*/
|
26
|
-
export declare class RandomComponentsDirection extends
|
31
|
+
export declare class RandomComponentsDirection extends RandomComponentsDirection_base {
|
27
32
|
private speed;
|
28
33
|
private min;
|
29
34
|
private max;
|
@@ -33,7 +38,8 @@ export declare class RandomComponentsDirection extends Initializer {
|
|
33
38
|
constructor(speed: number, min: Vector3, max: Vector3);
|
34
39
|
init(emitter: Emitter, particle: Particle): void;
|
35
40
|
}
|
36
|
-
|
41
|
+
declare const RandomVelocity_base: any;
|
42
|
+
export declare class RandomVelocity extends RandomVelocity_base {
|
37
43
|
private min;
|
38
44
|
private max;
|
39
45
|
private x;
|
@@ -42,3 +48,4 @@ export declare class RandomVelocity extends Initializer {
|
|
42
48
|
constructor(min: Vector3, max: Vector3);
|
43
49
|
init(emitter: Emitter, particle: Particle): void;
|
44
50
|
}
|
51
|
+
export {};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{Vector3 as t}from"three";import
|
1
|
+
import{Vector3 as t}from"three";import{Span as e,Position as i}from"three-nebula";export class Rotation extends(Object.getPrototypeOf(i)){constructor(t){super(),this.rotation=t}init(t,e){"number"!=typeof e.rotation&&e.rotation.copy(this.rotation)}}export class InitialScale extends(Object.getPrototypeOf(i)){constructor(t){super(),this.scale=t}init(t,e){e.scale=this.scale}}export class AdditiveVelocity extends(Object.getPrototypeOf(i)){constructor(t){super(),this.velocity=t}init(t,e){e.velocity.x+=this.velocity.x,e.velocity.y+=this.velocity.y,e.velocity.z+=this.velocity.z}}export class RandomDirection extends(Object.getPrototypeOf(i)){constructor(t){super(),this.speed=t}init(t,e){s.set(2*Math.random()-1,2*Math.random()-1,2*Math.random()-1).normalize().multiplyScalar(this.speed),e.velocity.x+=s.x,e.velocity.y+=s.y,e.velocity.z+=s.z}}export class RandomComponentsDirection extends(Object.getPrototypeOf(i)){constructor(t,i,s){super(),this.speed=t,this.min=i,this.max=s,this.x=new e(this.min.x,this.max.x),this.y=new e(this.min.y,this.max.y),this.z=new e(this.min.z,this.max.z)}init(t,e){s.set(this.x.getValue(),this.y.getValue(),this.z.getValue()).normalize().multiplyScalar(this.speed),e.velocity.x+=s.x,e.velocity.y+=s.y,e.velocity.z+=s.z}}export class RandomVelocity extends(Object.getPrototypeOf(i)){constructor(t,i){super(),this.min=t,this.max=i,this.x=new e(this.min.x,this.max.x),this.y=new e(this.min.y,this.max.y),this.z=new e(this.min.z,this.max.z)}init(t,e){e.velocity.x+=this.x.getValue(),e.velocity.y+=this.y.getValue(),e.velocity.z+=this.z.getValue()}}const s=new t;
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { BaseActor } from
|
2
|
-
import { VfxAsset } from
|
1
|
+
import { BaseActor } from '../../gameplay/index.js';
|
2
|
+
import { VfxAsset } from '../../scene/model.js';
|
3
3
|
export declare class VfxActor extends BaseActor {
|
4
4
|
/**
|
5
5
|
* A multiplier for the speed of the visual effect.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{
|
1
|
+
import{__decorate as s}from"tslib";import{Actor as t,BaseActor as e,AssetLoader as i,inject as o,World as r}from"../../gameplay/index.js";import{Rate as a}from"three-nebula";import{materializeVfx as h}from"./vfx-materializer.js";import*as m from"three";let d=class extends e{constructor(){super(...arguments),this.timescale=1,this.paused=!1,this.assetLoader=o(i),this.world=o(r),this._worldPos=new m.Vector3,this.max=0}async fromAsset(s){null!=this.system&&(this.system.destroy(),this.system.emitters.forEach((s=>s.reset()))),this.sourceAsset=s,this.disposeSystem&&this.disposeSystem();const{system:t,dispose:e}=await h(s,this.world.scene,{getAsset:s=>this.assetLoader.getAsset(s),getMaterial:s=>this.assetLoader.getMaterialByAssetId(s),getTexture:s=>this.assetLoader.getTextureByAssetId(s),getMesh:s=>this.assetLoader.getModelByAssetId(s).then((s=>s.scene))});this.system=t,this.disposeSystem=e}play(){this.paused=!1;this.system.emitters.every((s=>s.dead))&&this.restart()}pause(){this.paused=!0}stop(){this.system.emitters.forEach((s=>{const t=s.rate;t instanceof a&&(console.log("set rate to infinity",t),t.nextTime=1/0)}))}restart(){for(const s of this.system.emitters){s.rate.nextTime=0,s.removeAllParticles()}}onUpdate(s){this.paused||(this.object.getWorldPosition(this._worldPos),this.system?.emitters.forEach((s=>{s.setPosition(this._worldPos)})),this.system?.update(s*this.timescale))}getParticleCount(){return this.system?.getCount()??0}onEndPlay(){this.stop(),console.log("end play"),null!=this.disposeSystem&&this.disposeSystem()}};d=s([t()],d);export{d as VfxActor};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { LibraryShapeType } from
|
2
|
-
import { AssetId, CustomParamValue, SerializedParamType } from
|
3
|
-
import { LibraryVfxBehaviourType, LibraryVfxInitalizerType } from './vfx-defs';
|
1
|
+
import { LibraryShapeType } from '../../scene/objects/shapes.js';
|
2
|
+
import { AssetId, CustomParamValue, SerializedParamType } from '../../scene/model.js';
|
3
|
+
import { LibraryVfxBehaviourType, LibraryVfxInitalizerType } from './vfx-defs.js';
|
4
4
|
import * as THREE from "three";
|
5
5
|
export type OnceRateData = {
|
6
6
|
type: 'once';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{SerializedParamType as t}from"../../scene/model";import*as e from"three";import{randomString as i}from"../../utils/math";export const BlendingModes=["additive","subtractive","multiply","normal"];export const ThreeBlendingMode={normal:e.NormalBlending,additive:e.AdditiveBlending,subtractive:e.SubtractiveBlending,multiply:e.MultiplyBlending};export function EmitterDataConstructor(){return{id:i(),name:"Emitter",rate:{type:"continuous",count:1,time:.5},position:[0,0,0],rotation:[0,0,0],initializers:[{id:i(),type:"lifetime",params:{duration:{type:t.Number,value:1}}}],behaviours:[],children:[],output:{type:"sprite",texture:null,color:"#ffffff",blendingMode:"normal"}}}
|
1
|
+
import{SerializedParamType as t}from"../../scene/model.js";import*as e from"three";import{randomString as i}from"../../utils/math.js";export const BlendingModes=["additive","subtractive","multiply","normal"];export const ThreeBlendingMode={normal:e.NormalBlending,additive:e.AdditiveBlending,subtractive:e.SubtractiveBlending,multiply:e.MultiplyBlending};export function EmitterDataConstructor(){return{id:i(),name:"Emitter",rate:{type:"continuous",count:1,time:.5},position:[0,0,0],rotation:[0,0,0],initializers:[{id:i(),type:"lifetime",params:{duration:{type:t.Number,value:1}}}],behaviours:[],children:[],output:{type:"sprite",texture:null,color:"#ffffff",blendingMode:"normal"}}}
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { Vector2, Vector3 } from "three";
|
2
|
-
import { Behaviour } from "three-nebula";
|
3
|
-
|
2
|
+
import { Behaviour, Emitter, Particle } from "three-nebula";
|
3
|
+
declare const Initializer_base: any;
|
4
|
+
declare class Initializer extends Initializer_base {
|
5
|
+
init(emitter: Emitter, particle: Particle): void;
|
6
|
+
}
|
4
7
|
type HexColor = `#${string}`;
|
5
8
|
export type ShapeParameterDef<T = boolean | number | string | Vector3 | Vector2 | HexColor> = {
|
6
9
|
type: T extends number ? 'number' : T extends HexColor ? 'color' : T extends string ? 'string' | 'select' : T extends Vector2 ? 'vec2' : T extends Vector3 ? 'vec3' : T extends boolean ? 'boolean' : never;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{Color as e,MathUtils as r,Vector2 as t,Vector3 as s}from"three";import{Life as n,Force as a,Gravity as o,Scale as i,RandomDrift as c,Color as u,Alpha as
|
1
|
+
import{Color as e,MathUtils as r,Vector2 as t,Vector3 as s}from"three";import{Life as n,Force as a,Gravity as o,Scale as i,RandomDrift as c,Color as u,Alpha as p,Rotate as m,Mass as d,ease as l,Position as f,BoxZone as w,LineZone as x}from"three-nebula";import{LinearDamping as y,MoveOverLife as h,RotatePosition as b}from"./behaviours.js";import{AdditiveVelocity as k,InitialScale as v,RandomDirection as z,Rotation as g}from"./initializsers.js";import{SphereZone as L,PointZone as j}from"./zones.js";Object.getPrototypeOf(n);class O{build(e={}){const r=R(e,this.parameters);return this.make(r)}}class V{build(e={}){const r=R(e,this.parameters);return this.make(r)}}function B(e,r,t){return{type:"number",default:e,float:!0,min:r,max:t}}function T(e){return{type:"vec3",default:(new s).fromArray(e)}}function D(e){return{type:"color",default:e}}function I(){return{type:"select",opts:Array.from(Object.keys(l)).map((e=>e.substring(4))),default:"Linear"}}function R(e,r){const t={};for(let s in r)null==e[s]?t[s]=r[s].default:t[s]=e[s];return t}function A(e){return null!=e?l["ease"+e]:l.easeLinear}const C={lifetime:new class extends V{constructor(){var e;super(...arguments),this.parameters={duration:(e=1,{type:"number",default:e})}}make(e={}){return new n(e.duration)}},positionPoint:new class extends V{constructor(){super(...arguments),this.parameters={position:T([0,0,0])}}make(e={}){const{x:r,y:t,z:s}=e.position;return new f(new j(r,t,s))}},positionBox:new class extends V{constructor(){super(...arguments),this.parameters={position:T([0,0,0]),dimensions:T([0,0,0])}}make(e={}){const{x:r,y:t,z:s}=e.position,{x:n,y:a,z:o}=e.dimensions;return new f(new w(r,t,s,n,a,o))}},positionSphere:new class extends V{constructor(){super(...arguments),this.parameters={position:T([0,0,0]),radius:B(1)}}make(e={}){const{x:r,y:t,z:s}=e.position;return new f(new L(r,t,s,e.radius))}},positionLine:new class extends V{constructor(){super(...arguments),this.parameters={a:T([0,0,0]),b:T([0,0,1])}}make(e={}){const{x:r,y:t,z:s}=e.a,{x:n,y:a,z:o}=e.b;return new f(new x(r,t,s,n,a,o))}},rotation:new class extends V{constructor(){super(...arguments),this.parameters={rotation:T([0,0,0])}}make(e={}){const{x:r,y:t,z:n}=e.rotation;return new g(new s(r,t,n))}},scale:new class extends V{constructor(){super(...arguments),this.parameters={scale:B(1)}}make(e={}){return new v(e.scale)}},mass:new class extends V{constructor(){super(...arguments),this.parameters={min:B(1)}}make(e={}){return new d(e.min)}},velocity:new class extends V{constructor(){super(...arguments),this.parameters={velocity:T([0,0,0])}}make(e={}){const{x:r,y:t,z:n}=e.velocity;return new k(new s(r,t,n))}},randomDirection:new class extends V{constructor(){super(...arguments),this.parameters={speed:B(1)}}make(e={}){return new z(e.speed)}}},K={force:new class extends O{constructor(){super(...arguments),this.parameters={force:T([0,0,0]),ease:I()}}make(e={}){return new a(e.force.x,e.force.y,e.force.z,void 0,A(e.ease))}},gravity:new class extends O{constructor(){super(...arguments),this.parameters={gravity:B(8)}}make(e={}){return new o(e.gravity)}},scale:new class extends O{constructor(){super(...arguments),this.parameters={a:B(1),b:B(1),ease:I()}}make(e={}){return new i(e.a,e.b,void 0,A(e.ease))}},randomDrift:new class extends O{constructor(){super(...arguments),this.parameters={drift:T([1,1,1]),delay:B(0),ease:I()}}make(e={}){return new c(e.drift.x,e.drift.y,e.drift.z,e.delay,void 0,A(e.ease))}},rotate:new class extends O{constructor(){super(...arguments),this.parameters={rotation:T([0,0,0]),ease:I()}}make(e={}){const{x:t,y:s,z:n}=e.rotation;return new m(r.degToRad(t),r.degToRad(s),r.degToRad(n),void 0,A(e.ease))}},changeColor:new class extends O{constructor(){super(...arguments),this.parameters={a:D("#ffffff"),b:D("#ffffff"),ease:I()}}make(r={}){return new u(new e(r.a),new e(r.b),void 0,A(r.ease))}},changeOpacity:new class extends O{constructor(){super(...arguments),this.parameters={a:B(1,0,1),b:B(0,0,1),ease:I()}}make(e={}){return new p(e.a,e.b,void 0,A(e.ease))}},vortex:new class extends O{constructor(){super(...arguments),this.parameters={axis:T([0,1,0]),amount:B(1)}}make(e={}){return new b(e.axis,e.amount)}},moveTo:new class extends O{constructor(){super(...arguments),this.parameters={target:T([0,1,0]),ease:I()}}make(e={}){return new h(e.target.x,e.target.y,e.target.z,A(e.ease))}},linearDamping:new class extends O{constructor(){super(...arguments),this.parameters={factor:B(.1,0,1)}}make(e={}){return new y(e.factor)}}};export const VfxInitializserLibrary=C;export const VfxInitializserLibraryKeys=Object.keys(VfxInitializserLibrary);export const VfxBehaviourLibrary=K;export const VfxBehaviourLibraryKeys=Object.keys(VfxBehaviourLibrary);
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,8 +1,9 @@
|
|
1
|
-
import { VfxAsset } from
|
1
|
+
import { Asset, VfxAsset } from '../../scene/model.js';
|
2
2
|
import { Object3D } from "three";
|
3
3
|
import * as THREE from 'three';
|
4
4
|
import System, { MeshRenderer, Rate } from "three-nebula";
|
5
5
|
export type VfxAssetProvider = {
|
6
|
+
getAsset(assetId: string): Promise<Asset>;
|
6
7
|
getTexture(assetId: string): Promise<THREE.Texture>;
|
7
8
|
getMesh(assetId: string): Promise<THREE.Object3D>;
|
8
9
|
getMaterial(assetId: string): Promise<THREE.Material>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{
|
1
|
+
import{Object3D as e}from"three";import*as t from"three";import a,{Behaviour as r,Body as n,BoxZone as o,Emitter as i,Force as s,Life as l,Mass as m,MeshRenderer as c,PUID as d,PointZone as u,Position as w,RadialVelocity as p,Radius as h,Rate as f,Rotate as g,Scale as A,Span as y,Vector3D as M,ease as x}from"three-nebula";import{RotatePosition as b}from"./behaviours.js";import{OnceRate as I}from"./rates.js";import{VfxBehaviourLibrary as S,VfxInitializserLibrary as B}from"./vfx-defs.js";import{ThreeBlendingMode as E}from"./vfx-asset.js";import{ShapeLibrary as P}from"../../scene/objects/shapes.js";import{prepareShapeParameters as R,shapeDefaultColor as v}from"../../scene/materializer.js";import{particleEnergyUniformName as Q,particleVelcoityUniformName as U}from"../../shader-nodes/particle.js";import{NodeShaderMaterial as V}from"three-shader-graph";class j extends c{scale(e){e.target instanceof t.Sprite?e.target.scale.set(e.scale*e.radius,e.scale*e.radius,1):super.scale(e)}rotate(e){e.target.material.rotation=e.rotation.z}onParticleCreated(a){a.target||(a.target=this._targetPool.get(a.body),(a.useAlpha||a.useColor)&&(a.target instanceof t.Mesh||a.target instanceof t.Sprite&&a.target.material instanceof t.Material)&&(a.target.material.__puid=d.id(a.body.material),a.target.material=this._materialPool.get(a.target.material))),a.target&&a.target instanceof e&&(a.target.position.set(a.position.x,a.position.y,a.position.z),this.container.add(a.target))}onParticleUpdate(e){const{target:a,useAlpha:r,useColor:n,rotation:o}=e;a&&(a.position.copy(e.position),this.isThreeSprite(e)||a.rotation.set(o.x,o.y,o.z),this.scale(e),a.material instanceof t.Material&&(r&&(a.material.opacity=e.alpha,a.material.transparent=!0),n&&a.material.color.copy(e.color)))}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 async function materializeVfx(r,o,s){let l=o;if(!0!==r.vfx.localSpace)for(;null!=l.parent;)l=l.parent;const m=new e;m.name="particle system",l.add(m);const c=new j(m,t),d=(new t.Mesh(new t.BoxGeometry(.3,.3,.3),new t.MeshStandardMaterial({color:16777215})),new a),u=await Promise.all(r.vfx.emitters.map((async a=>{let r,o;switch(a.rate.type){case"continuous":r=new f(a.rate.count,a.rate.time);break;case"once":r=new I(a.rate.count);break;default:console.warn(`Failed to configure rate for emitter: ${JSON.stringify(a)}`),r=new f(0,1/0)}switch(a.output.type){case"sprite":o=new n(await async function(e,a){const r=null!=e.texture?await a.getTexture(e.texture):k;var n=new t.SpriteMaterial({map:r,color:e.color??16777215,blending:E[e.blendingMode]??t.NormalBlending,fog:!0,transparent:!0});return new t.Sprite(n)}(a.output,s));break;case"shape":o=new n(await async function(a,r){const n=P[a.shape];if(null==n)return console.error(`No shape with type ${a.shape}`),new e;const o=R(a.params??{}),i=n.geometry(o),s=null!=a.material?await r.getMaterial(a.material):new t.MeshStandardMaterial({color:v});return new t.Mesh(i,s)}(a.output,s));break;case"mesh":o=new n(await async function(a,r){if(null==a.assetId)return console.warn("Can't use mesh as particle without asset id"),new e;const n=await r.getMesh(a.assetId),o=await r.getAsset(a.assetId),i=[];if(null!=o.materialAssignments)for(const e of o.materialAssignments)n.traverse((a=>{a instanceof t.Mesh&&a.material instanceof t.Material&&a.material.color instanceof t.Color&&(a.material.name!=e.name&&null!=e.name||"#"+a.material.color.getHexString()!==e.color||i.push(r.getMaterial(e.materialId).then((e=>a.material=e))))}));return await Promise.all(i),n.traverse((e=>{})),n}(a.output,s));break;default:console.error("Failed to create particly system body: "+JSON.stringify(a))}const l=(new i).setRate(r),m=await Promise.all(a.initializers.filter((e=>null!=B[e.type])).map((async e=>{const t=B[e.type],a=await R(e.params??{});return t.build(a)})));m.push(o),l.addInitializers(m);const c=await Promise.all(a.behaviours.filter((e=>null!=S[e.type])).map((async e=>{const t=S[e.type],a=await R(e.params??{});return t.build(a)})));return c.push(new C),l.addBehaviours(c),l.emit()})));return u.forEach((e=>d.addEmitter(e))),d.addRenderer(c).emit({onEnd:()=>{console.log("ended")}}),{system:d,dispose:()=>m.removeFromParent()}}const k=(new t.TextureLoader).load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJkSURBVHjaxJeJbusgEEW94S1L//83X18M2MSuLd2pbqc4wZGqRLrKBsyZhQHny7Jk73xVL8xpVhWrcmiB5lX+6GJ5YgQ2owbAm8oIwH1VgKZUmGcRqKGGPgtEQQAzGR8hQ59fAmhJHSAagigJ4E7GPWRXOYC6owAd1JM6wDQPADyMWUqZRMqmAojHp1Vn6EQQEgUNMJLnUjMyJsM49wygBkAPw9dVFwXRkncCIIW3GRgoTQUZn6HxCMAFEFd8TwEQ78X4rHbILoAUmeT+RFG4UhQ6MiIAE4W/UsYFjuVjAIa2nIY4q1R0GFtQWG3E84lqw2GO2QOoCKBVu0BAPgDSU0eUDjjQenNkV/AW/pWChhpMTelo1a64AOKM30vk18GzTHXCNtI/Knz3DFBgsUqBGIjTInXRY1yA9xkVoqW5tVq3pDR9A0hfF5BSARmVnh7RMDCaIdcNgbPBkgzn1Bu+SfIEFSpSBmkxyrMicb0fAEuCZrWnN89veA/4XcakrPcjBWzkTuLjlbfTQPOlBhz+HwkqqPXmPQDdrQItxE1moGof1S74j/8txk8EHhTQrAE8qlwfqS5yukm1x/rAJ9Jiaa6nyATqD78aUVBhFo8b1V4DdTXdCW+IxA1zB4JhiOhZMEWO1HqnvdoHZ4FAMIhV9REF8FiUm0jsYPEJx/Fm/N8OhH90HI9YRHesWbXXZwAShU8qThe7H8YAuJmw5yOd989uRINKRTJAhoF8jbqrHKfeCYdIISZfSq26bk/K+yO3YvfKrVgiwQBHnwt8ynPB25+M8hceTt/ybPhnryJ78+tLgAEAuCFyiQgQB30AAAAASUVORK5CYII=");export function materializeVfxOld(r,d){let S=d;if(!0!==r.vfx.localSpace)for(;null!=S.parent;)S=S.parent;const B=new e;B.name="particle system",S.add(B);const E=new c(B,t),P=new t.Mesh(new t.BoxGeometry(.3,.3,.3),new t.MeshStandardMaterial({color:16777215})),R=new f(new y(3,9),new y(.02,.15)),v=new i,Q=new a;v.setLife(4).setRate(R).addInitializers([new m(1),new h(1),new l(1),new n(P),new w(new o(.5)),new p(10,new M(0,0,1),30)]).addBehaviours([new b(new t.Vector3(0,0,1),4),new s(0,0,.1),new g("random",2.5*-Math.PI,2*Math.PI,1,x.easeOutCubic),new A(1,.2)]).emit();const U=new I,V=(new i).setLife(5).addInitializers([new m(1),new h(1),new l(3),new n(P),new w(new u(0,0,0))]).addBehaviours([new A(4,6,void 0,x.easeOutExpo)]).setRate(U).emit();return U.nextTime=0,Q.addEmitter(v).addEmitter(V).addRenderer(E).emit({onEnd:()=>{console.log("ended")}}),{system:Q,rate:R,renderer:E,dispose:()=>B.removeFromParent()}}class C extends r{initialize(e){if(e.body instanceof t.Mesh){const t=e.body.material;t instanceof V&&(null!=t.uniforms[Q]||null!=t.uniforms[U])&&(e.body.material=t.clone())}}mutate(e,a,r){if(e.target instanceof t.Mesh){const t=e.target.material;t instanceof V&&(null!=t.uniforms[Q]&&(t.uniforms[Q].value=this.energy),null!=t.uniforms[U]&&(t.uniforms[U].value=e.velocity))}}}
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Subject } from "rxjs";
|
2
2
|
import { Object3D } from "three";
|
3
3
|
import { Constructable } from "typedi";
|
4
|
-
import { ActorComponent, ComponentAttachProps } from
|
4
|
+
import { ActorComponent, ComponentAttachProps } from './component.js';
|
5
5
|
export declare function Actor(): (targetConstructor: any) => void;
|
6
6
|
export type ActorId = number;
|
7
7
|
/**
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as e}from"tslib";import o,{ignore as i}from"@plumier/reflect";import{Subject as n,skipWhile as
|
1
|
+
import{__decorate as t,__metadata as e}from"tslib";import o,{ignore as i}from"@plumier/reflect";import{Subject as n,skipWhile as s}from"rxjs";import{Group as r}from"three";import a,{Service as p}from"typedi";import{ActorComponent as c}from"./component.js";import{initComponents as d}from"./internal/component-init.js";import{activeContainerInstance as m,containerRefMap as h}from"./internal/container-map.js";import{randomString as l}from"../../utils/math.js";import{inject as u}from"../inject.js";import{ViewController as f}from"../services/render.js";export function Actor(){const t=p({transient:!0});return function(e){e.__isActor=!0,t(e),o.noop()(e),o.parameterProperties()(e)}}let U=0;export class BaseActor{get position(){return this.object?.position}get quaternion(){return this.object?.quaternion}get rotation(){return this.object?.rotation}onInit(){}onBeginPlay(){}onEndPlay(){}onUpdate(t){}onLateUpdate(t){}constructor(){this.id=++U,this.__isInitialised=!1,this.object=new r,this.disposed=new n,this.onUpdate!==BaseActor.prototype.onUpdate&&u(f).onUpdate(this).pipe(s((()=>!this.__isInitialised))).subscribe((t=>this.onUpdate(t))),this.onLateUpdate!==BaseActor.prototype.onLateUpdate&&u(f).onLateUpdate(this).pipe(s((()=>!this.__isInitialised))).subscribe((t=>this.onLateUpdate(t)))}attach(t,e){const o=m.value,i=h.get(this)??m.value??a.of("default");m.value=i;const n=l();i.set({id:n,type:t,transient:!0});const s=i.get(n);if(m.value=o,null!=e)for(const t of Object.keys(e))s[t]=e[t];return this.__isInitialised&&(s.actor=this,s.onInit(),d(s,this)),s}getComponent(t){for(const e of Object.values(this))if(e instanceof t)return e}}t([i(),e("design:type",Object),e("design:paramtypes",[])],BaseActor.prototype,"position",null),t([i(),e("design:type",Object),e("design:paramtypes",[])],BaseActor.prototype,"quaternion",null),t([i(),e("design:type",Object),e("design:paramtypes",[])],BaseActor.prototype,"rotation",null);export function _setupActorUpdateEventHandlers(){this.onUpdate!==c.prototype.onUpdate&&u(f).onUpdate(this.actor).pipe(s((()=>!this.actor.__isInitialised))).subscribe((t=>this.onUpdate(t))),this.onLateUpdate!==c.prototype.onLateUpdate&&u(f).onLateUpdate(this.actor).pipe(s((()=>!this.actor.__isInitialised))).subscribe((t=>this.onLateUpdate(t)))}
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { BaseActor } from
|
2
|
-
import { CameraComponent } from
|
3
|
-
import { ActorComponent } from
|
1
|
+
import { BaseActor } from '../actor.js';
|
2
|
+
import { CameraComponent } from '../camera/camera-component.js';
|
3
|
+
import { ActorComponent } from '../component.js';
|
4
4
|
export declare class CameraMesh extends ActorComponent {
|
5
5
|
private arrowColor;
|
6
6
|
onInit(): void | Promise<void>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as e,__metadata as o}from"tslib";import{ArrowHelper as r,ConeGeometry as t,EdgesGeometry as a,LineBasicMaterial as
|
1
|
+
import{__decorate as e,__metadata as o}from"tslib";import{ArrowHelper as r,ConeGeometry as t,EdgesGeometry as a,LineBasicMaterial as s,LineSegments as n,MeshStandardMaterial as l,Vector3 as i}from"three";import{Actor as c,BaseActor as m}from"../actor.js";import{CameraComponent as p}from"../camera/camera-component.js";import{ActorComponent as d,Attach as w,Component as y}from"../component.js";let h=class extends d{constructor(){super(...arguments),this.arrowColor=16101442}onInit(){const e=new t(1,1,4);e.rotateX(Math.PI/2),e.rotateZ(Math.PI/4),e.scale(1,9/16,1);const o=new a(e),c=(new l({color:3355443}),new n(o,new s({color:16777215}))),m=new r(new i(0,0,-1),new i(0,0,0),1.2,this.arrowColor,.15,.2);c.add(m),m.layers.disableAll(),m.layers.enable(19),m.traverse((e=>{e.layers.disableAll(),e.layers.enable(19)})),this.actor.object.add(c)}};h=e([y({inEditor:!0,editorOnly:!0})],h);export{h as CameraMesh};let b=class extends m{};e([w(),o("design:type",p)],b.prototype,"camera",void 0),e([w(),o("design:type",h)],b.prototype,"mesh",void 0),b=e([c()],b);export{b as CameraActor};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ActorComponent } from
|
2
|
-
import { AnimationStateMachine } from
|
3
|
-
import { BoneLayer } from
|
1
|
+
import { ActorComponent } from '../../../component.js';
|
2
|
+
import { AnimationStateMachine } from '../../../../animation/anim-sm.js';
|
3
|
+
import { BoneLayer } from '../../../../animation/root-motion.js';
|
4
4
|
import { AnimationAction, AnimationClip, Bone, Object3D } from "three";
|
5
5
|
export declare class CharacterAnimationComponent extends ActorComponent {
|
6
6
|
private viewController;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{ActorComponent as i,Component as e}from"../../../component";import{RootMotionClip as r}from"../../../../animation/root-motion";import{inject as
|
1
|
+
import{__decorate as t}from"tslib";import{ActorComponent as i,Component as e}from"../../../component.js";import{RootMotionClip as r}from"../../../../animation/root-motion.js";import{inject as s}from"../../../../inject.js";import{ViewController as o}from"../../../../services/render.js";import{AnimationMixer as n,Bone as p,LoopOnce as l}from"three";let h=class extends i{constructor(){super(...arguments),this.viewController=s(o),this.stateMachines=[],this.upperStateMachines=[],this.fadeTime=.2,this.movementSpeed=null,this.upperBodyTimer=0,this.upperBodyOverride=!1,this.fullBodyTimer=0,this.currentFullBodyPriority=-1,this.currentUpperBodyPriority=-1,this.getFullBodyClip=c((t=>t.uuid),(t=>u(this.fullBodyMask,t))),this.getUpperBodyClip=c((t=>t.uuid),(t=>u(this.upperBodyMask,t)))}onInit(){this.viewController.onUpdate(this.actor).subscribe((t=>this.updateInternal(t)))}getRootMotionAction(){if(this.fullBodyAction.getClip()instanceof r)return this.fullBodyAction}setup(t,i,e){null!=i&&(this.upperBodyMask=a(i),this.fullBodyMask=function(t,i){const e=new Set(a(i).map((t=>t.uuid))),r=[];return t.traverse((t=>{(t instanceof p||t.isBone)&&!e.has(t.uuid)&&r.push(t)})),r}(function(t){let i;return t.traverse((t=>{(t instanceof p||t.isBone)&&null==i&&(i=t)})),i}(t),i)),null!=this.mixer&&this.mixer.stopAllAction(),this.mixer=new n(t)}updateStateMachines(t){this.stateMachines.forEach((i=>{i.step(t);const e=i.current.clip;null!=e&&this.play(e,{priority:0})})),this.upperStateMachines.forEach((i=>{i.step(t);const e=i.current.clip;null!=e?this.playUpper(e,{priority:0}):this.play(this.fullBodyClip)}))}updateInternal(t){null!=this.mixer&&(this.upperBodyTimer+=t,this.fullBodyTimer+=t,this.upperBodyAction&&this.upperBodyOverride&&this.upperBodyAction.getClip().duration-2*this.fadeTime<this.upperBodyTimer&&(this.upperBodyOverride=!1,null!=this.fullBodyClip&&this.transition(this.upperBodyAction,this.getUpperBodyClip(this.fullBodyClip))),this.fullBodyAction&&this.fullBodyAction.loop===l&&this.fullBodyAction.getClip().duration-2*this.fadeTime<this.fullBodyTimer&&(this.currentFullBodyPriority=-1),this.updateStateMachines(t),this.syncMovementSpeed(this.fullBodyAction),this.upperBodyOverride||this.syncMovementSpeed(this.upperBodyAction),this.mixer.update(t))}syncMovementSpeed(t){if(null!=t){const i=t.getClip();i instanceof r&&i.fixedInPlace&&null!=this.movementSpeed&&(t.timeScale=i.duration/i.displacement*this.movementSpeed)}}playStateMachine(t){this.stateMachines.push(t)}playUpperStateMachine(t){this.upperStateMachines.push(t)}removeStateMachine(t){this.stateMachines.splice(this.stateMachines.indexOf(t))}removeUpperStateMachine(t){this.upperStateMachines.splice(this.upperStateMachines.indexOf(t))}playUpper(t,i={}){const e=i?.priority??1;e<this.currentUpperBodyPriority||(this.currentUpperBodyPriority=e,this.upperBodyAction=this.transition(this.upperBodyAction,this.getUpperBodyClip(t),i),this.upperBodyTimer=0,this.upperBodyOverride=!0)}play(t,i={}){!function(t,i){if(!1===t||"function"==typeof t&&!1===t())throw new Error(i)}(null!=this.mixer,"Can't play animation before setup is called");const e=i.priority??1;e<this.currentFullBodyPriority||(this.currentFullBodyPriority=e,this.fullBodyTimer=0,this.upperBodyOverride||(this.upperBodyAction=this.transition(this.upperBodyAction,this.getUpperBodyClip(t),i)),this.fullBodyClip=t,this.fullBodyAction=this.transition(this.fullBodyAction,this.getFullBodyClip(t),i),this.fullBodyAction.getClip().uuid==this.upperBodyAction.getClip().uuid&&this.upperBodyAction.syncWith(this.fullBodyAction))}onActionDone(t){return new Promise((i=>{const e=r=>{r.target===t&&(i(r.target),this.mixer.removeEventListener("finished",e))};this.mixer.addEventListener("finished",e)}))}transition(t,i,e={}){if(null!=t&&t.getClip().uuid===i.uuid)return t;if(t){const e=t,r=t=this.mixer.clipAction(i);r.play(),r.enabled=!0,r.setEffectiveTimeScale(1),r.setEffectiveWeight(1),r.time=0,e.crossFadeTo(r,this.fadeTime,!0)}else t=this.mixer.clipAction(i),t?.fadeIn(.3),t?.play();return!1===e.loop&&(t.setLoop(l,1),t.clampWhenFinished=!0,t.reset()),t}};h=t([e()],h);export{h as CharacterAnimationComponent};function u(t,i){if(null==t)return i;const e=i.clone(),r=new Set(t.map((t=>t.name)));return e.tracks=e.tracks.filter((t=>r.has(t.name.split(".")[0]))),e}function a(t){return t.flatMap((t=>function(t){const i=[];return t.traverse((t=>{i.push(t)})),i}(t))).filter((t=>t instanceof p))}function c(t,i){const e=new Map;return(r,...s)=>{const o=t(r);return e.has(o)||e.set(o,i(r,...s)),e.get(o)}}
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { ActionInput, AxisInput, RotationInput } from
|
2
|
-
import { PhysicsSystem } from
|
1
|
+
import { ActionInput, AxisInput, RotationInput } from '../../../../../gameplay/input/index.js';
|
2
|
+
import { PhysicsSystem } from '../../../../../gameplay/services/physics/physics-system.js';
|
3
3
|
import { Vector3 } from "three";
|
4
|
-
import { ActorComponent } from
|
5
|
-
import { CharacterMovementMode } from
|
4
|
+
import { ActorComponent } from '../../../component.js';
|
5
|
+
import { CharacterMovementMode } from './modes.js';
|
6
6
|
export declare class CharacterMovementComponent extends ActorComponent {
|
7
7
|
private physicsSystem;
|
8
8
|
readonly directionInput: AxisInput;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as i}from"tslib";import{ActionInput as s,AxisInput as e,RotationInput as o}from"../../../../../gameplay/input";import{PhysicsSystem as n,RayTestResult as r}from"../../../../../gameplay/services/physics/physics-system";import{toDegrees as a}from"../../../../../utils/math";import{Vector3 as h}from"three";import{ActorComponent as
|
1
|
+
import{__decorate as t,__metadata as i}from"tslib";import{ActionInput as s,AxisInput as e,RotationInput as o}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as n,RayTestResult as r}from"../../../../../gameplay/services/physics/physics-system.js";import{toDegrees as a}from"../../../../../utils/math.js";import{Vector3 as h,MathUtils as l}from"three";import{ActorComponent as c,Component as p}from"../../../component.js";import{CharacterMovementMode as y}from"./modes.js";import{CapsuleCollisionShape as m}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as d}from"rxjs";import{PhysicsBodyType as u}from"../../../../services/physics/physics-system.js";let g=class extends c{constructor(t){super(),this.physicsSystem=t,this.directionInput=new e,this.jumpInput=new s,this.sprintInput=new s,this.rotationInput=new o,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=10,this.maxWalkingSlopeAngle=70,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2.5,this.colliderRadius=.5,this.velocity=new h,this.mode=y.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new r}onInit(){this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:u.kinematic}),this.rotationInput.rotation.copy(this.actor.rotation);let t=this.rotationInput.rotation.y;const i=new h,s=new h,e=new h,o=new h,n=new h;let c=0;this.physicsSystem.afterStep.pipe(d(this.disposed)).subscribe((r=>{this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;let a=t-this.rotationInput.rotation.y;t=this.rotationInput.rotation.y,e.copy(this.actor.position),o.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const p=o.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed,m=o.clone().applyAxisAngle(new h(0,1,0),this.rotationInput.rotation.y);this.mode===y.walking&&(0!==m.length()?(c=Math.min(p,c),c=l.lerp(c,p,4*r)):c=0,n.copy(m).multiplyScalar(c),this.pressedJump&&(this.mode=y.falling,this.velocity.copy(n),this.velocity.y=this.jumpVelocity)),this.mode===y.falling&&(this.velocity.y+=r*this.getEffectiveGravity(),n.copy(this.velocity),n.add(m.clone().multiplyScalar(p*this.fallingMovementControl*r)),this.fallingReorientation&&n.applyAxisAngle(new h(0,1,0),-a)),s.copy(n).normalize(),i.copy(n),this.actor.rotation.y-=a;const d=this.actor.position.add(n.multiplyScalar(r));this.moveTo(d),f(),this.isGrounded?this.velocity.y<=0&&(this.mode=y.walking,this.velocity.y=0):(this.mode=y.falling,this.velocity.copy(i)),this.mode===y.walking&&v(r),x(r),this.horizontalSpeed=c}));const p=new h(0,1,0),m=new h(0,-.1,0),g=new h,S=new h,f=()=>{const t=this.colliderHeight+2*this.colliderRadius;this.physicsSystem.rayTest(g.addVectors(this.actor.position,p.set(0,t/4,0)),S.addVectors(this.actor.position,m),this.rayTestResult,{excludeActor:this.actor})},v=t=>{if(this.isGrounded){const s=Math.acos(this.rayTestResult.hitNormal.y),o=this.rayTestResult.hitPoint.y;if(a(s)<this.maxWalkingSlopeAngle){this.actor.position.y=o;const s=this.actor.position.sub(e).normalize().multiplyScalar(i.length()*t);this.moveTo(e.clone().add(s))}}},w=new r,x=t=>{const i=this.physicsSystem.getActorContacts(this.actor,s).filter((t=>a(Math.acos(-t.ni.y))>this.maxWalkingSlopeAngle));if(i.length>0){if(i[0].ni.clone().dot(s)<=0)return;this.moveTo(e);const o=i[0].rj.clone(),n=this.getWallDirection(i[0].ni,s);if(!this.physicsSystem.rayTest(o,n.clone().multiplyScalar(this.colliderRadius).add(o),w,{debugColor:0}).hasHit){const i=s.dot(n),e=n.multiplyScalar(this.horizontalSpeed*i);e.y+=this.velocity.y,e.multiplyScalar(t);const o=this.actor.position.clone().add(e);this.moveTo(o)}}}}getWallDirection(t,i){const s=t.clone().negate().cross(new h(0,1,0));return s.dot(i)<0?s.negate():s}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}get isGrounded(){return this.rayTestResult.hasHit}createCollisionShape(){const t=new m(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2,t}step(t){}performMovement(t){}};g=t([p(),i("design:paramtypes",[n])],g);export{g as CharacterMovementComponent};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { ActionInput, AxisInput, RotationInput } from
|
2
|
-
import { PhysicsSystem } from
|
1
|
+
import { ActionInput, AxisInput, RotationInput } from '../../../../../gameplay/input/index.js';
|
2
|
+
import { PhysicsSystem } from '../../../../../gameplay/services/physics/physics-system.js';
|
3
3
|
import { Vector3, AnimationAction } from 'three';
|
4
|
-
import { ActorComponent } from
|
5
|
-
import { CharacterMovementMode } from
|
4
|
+
import { ActorComponent } from '../../../component.js';
|
5
|
+
import { CharacterMovementMode } from './modes.js';
|
6
6
|
export declare class CharacterMovementComponent extends ActorComponent {
|
7
7
|
private physicsSystem;
|
8
8
|
readonly directionInput: AxisInput;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as i}from"tslib";import{ActionInput as o,AxisInput as e,RotationInput as s}from"../../../../../gameplay/input";import{PhysicsSystem as n,RayTestResult as
|
1
|
+
import{__decorate as t,__metadata as i}from"tslib";import{ActionInput as o,AxisInput as e,RotationInput as s}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as n,RayTestResult as a}from"../../../../../gameplay/services/physics/physics-system.js";import{MathUtils as r,Vector3 as l}from"three";import{ActorComponent as c,Component as h}from"../../../component.js";import{CharacterMovementMode as p}from"./modes.js";import{CapsuleCollisionShape as m}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as y}from"rxjs";import{PhysicsBodyType as u}from"../../../../services/physics/physics-system.js";import{RootMotionClip as d}from"../../../../../gameplay/animation/root-motion.js";const g=new l,S=new l,f=1/30;let v=class extends c{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}constructor(t){super(),this.physicsSystem=t,this.directionInput=new e,this.jumpInput=new o,this.sprintInput=new o,this.rotationInput=new s,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=r.degToRad(70),this.maxSlopeClimbAngle=r.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.velocity=new l,this.mode=p.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new a,this.resetRootMotion=!1;const i=this.cc=this.physicsSystem.getCharacterController(.1);i.enableSnapToGround(.1),i.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:u.kinematic,continousCollisionDetection:!0,friction:1}),this.rotationInput.rotation.copy(this.actor.rotation);let i=this.rotationInput.rotation.y;const o=new l,e=new l,s=new l,n=new l,a=new l,c=new l;let h=0,m=null;const v=new l,w=new l,x=new l,I=new l;this.physicsSystem.beforeStep.pipe(y(this.disposed)).subscribe((y=>{if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof d){const t=this.rootMotionInterpolant;this.resetRootMotion&&(v.fromArray(t.evaluate(0)),this.resetRootMotion=!1),I.fromArray(t.evaluate(this.rootMotionAction.time)),w.subVectors(I,v),v.copy(I),this.rootMotionAction.getRoot().getWorldScale(x),w.multiply(x)}}y>f&&(y=f);const u=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=w.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated&&this.directionInput.vertical>=0;let b=i-this.rotationInput.rotation.y;i=this.rotationInput.rotation.y,s.copy(this.actor.position),n.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const T=n.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed;c.copy(n).applyAxisAngle(A,this.rotationInput.rotation.y),this.mode===p.walking?(0!==c.length()?(h=Math.min(T,h),h=r.lerp(h,T,4*y)):h=0,a.copy(c).multiplyScalar(h),this.pressedJump&&(this.mode=p.falling,this.velocity.copy(a),this.velocity.y=this.jumpVelocity),a.y=y*this.getEffectiveGravity()):this.mode===p.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=p.falling,this.velocity.copy(a),this.velocity.y=this.jumpVelocity),this.velocity.y+=y*this.getEffectiveGravity(),a.copy(this.velocity),a.add(c.clone().multiplyScalar(T*this.fallingMovementControl*y)),this.fallingReorientation&&a.applyAxisAngle(new l(0,1,0),-b)),e.copy(a).normalize(),o.copy(a),this.actor.rotation.y-=b,a.length(),u?(w.applyAxisAngle(A,this.actor.rotation.y),w.y+=y*this.getEffectiveGravity(),g.copy(w)):g.copy(a).multiplyScalar(y),S.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,g)),this.physicsSystem.setNextKinematicTranslation(this.actor,S);let j=function(t){if(t.numComputedCollisions()>0){const i=t.computedCollision(0);M.x=i.normal2.x,M.y=i.normal2.y,M.z=i.normal2.z;const o=M.angleTo(A);M.x=i.normal1.x,M.y=i.normal1.y,M.z=i.normal1.z;const e=M.angleTo(A);return!(o<100)&&e>t.minSlopeSlideAngle()}return!1}(t);u||(!t.computedGrounded()||j?this.mode!==p.falling&&(null==m?m=performance.now():performance.now()-m>100&&(this.mode=p.falling,this.velocity.copy(o))):this.velocity.y<=0&&(this.mode,p.falling,this.mode=p.walking,this.velocity.y=0,m=null)),this.mode,p.walking,this.horizontalSpeed=h}))}setRootMotionAction(t){const i=t?.getClip();if(i instanceof d){this.rootMotionAction=t,this.resetRootMotion=!0;const o=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(o)}}getWallDirection(t,i){const o=t.clone().negate().cross(A);return o.dot(i)<0?o.negate():o}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}get isGrounded(){return this.rayTestResult.hasHit}createCollisionShape(){const t=new m(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2,t}step(t){}performMovement(t){}};v=t([h({inEditor:!1}),i("design:paramtypes",[n])],v);export{v as CharacterMovementComponent};const A=new l(0,1,0),M=new l;
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { PhysicsBodyType, PhysicsSystem } from
|
1
|
+
import { PhysicsBodyType, PhysicsSystem } from '../../../../gameplay/services/physics/physics-system.js';
|
2
2
|
import { Euler, Object3D, Vector3 } from "three";
|
3
|
-
import { ActorComponent } from
|
3
|
+
import { ActorComponent } from '../../component.js';
|
4
4
|
export declare class MeshComponent<TObj extends Object3D = Object3D> extends ActorComponent {
|
5
5
|
private physicsSystem;
|
6
6
|
object: TObj;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t,__metadata as s}from"tslib";import{PhysicsBodyType as i,PhysicsSystem as e}from"../../../../gameplay/services/physics/physics-system";import{AssetMeshInstance as o}from"../../../../scene/asset-resource-loader";import{PhysicalShapeMesh as
|
1
|
+
import{__decorate as t,__metadata as s}from"tslib";import{PhysicsBodyType as i,PhysicsSystem as e}from"../../../../gameplay/services/physics/physics-system.js";import{AssetMeshInstance as o}from"../../../../scene/asset-resource-loader.js";import{PhysicalShapeMesh as r}from"../../../../index.js";import{Parameter as n}from"../../../../shader/parameter.js";import{Euler as c,Object3D as h,Vector3 as p}from"three";import{ActorComponent as a,Component as l}from"../../component.js";import{firstValueFrom as m}from"rxjs";const y={friction:.1,mass:0,bodyType:i.static,continousCollisionDetection:!1};let d=class extends a{constructor(t){super(),this.physicsSystem=t,this.position=new p,this.rotation=new c,this.scale=new p(1,1,1),this.mass=y.mass,this.friction=y.friction,this.bodyType=i.static,this.continousCollisionDetection=y.continousCollisionDetection}onInit(){null!=this.object&&(this.currentMesh=this.object,this.updateMesh()),m(this.disposed).then((()=>{this.physicsSystem.removeActor(this.actor)}))}setObject(t){null!=this.currentMesh&&this.actor.object.remove(this.currentMesh),this.object=this.currentMesh=t,this.updateMesh()}updateMesh(){this.currentMesh.position.copy(this.position),this.currentMesh.rotation.copy(this.rotation),this.currentMesh.scale.copy(this.scale);const t=this.getCollisionShapes();t.length>0&&this.physicsSystem.addActor(this.actor,t,{...y,isTrigger:!1,mass:this.mass,friction:this.friction,type:this.bodyType,continousCollisionDetection:this.continousCollisionDetection}),this.actor.object.add(this.currentMesh)}getCollisionShapes(){return this.currentMesh instanceof o?this.currentMesh.collisionShapes:this.currentMesh instanceof r?[this.currentMesh.collisionShape]:"collisionShape"in this.currentMesh?(console.error("Could not understand wehre to get collision shapes from. This is likely due to an import issue"),[this.currentMesh.collisionShape]):[]}};t([n({type:h}),s("design:type",Object)],d.prototype,"object",void 0),t([n(),s("design:type",p)],d.prototype,"position",void 0),t([n(),s("design:type",c)],d.prototype,"rotation",void 0),t([n(),s("design:type",p)],d.prototype,"scale",void 0),t([n(),s("design:type",Number)],d.prototype,"mass",void 0),t([n(),s("design:type",Number)],d.prototype,"friction",void 0),t([n({options:[{name:"Static",value:i.static},{name:"Dynamic",value:i.dynamic}]}),s("design:type",Number)],d.prototype,"bodyType",void 0),d=t([l({inEditor:!0}),s("design:paramtypes",[e])],d);export{d as MeshComponent};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{Group as r}from"three";import{ActorComponent as e,Component as n}from"../../component";let o=class extends e{constructor(){super(...arguments),this.container=new r}set parent(t){this._parent=t,t.container.add(this.container)}get parent(){return this._parent}};o=t([n()],o);export{o as SceneComponent};
|
1
|
+
import{__decorate as t}from"tslib";import{Group as r}from"three";import{ActorComponent as e,Component as n}from"../../component.js";let o=class extends e{constructor(){super(...arguments),this.container=new r}set parent(t){this._parent=t,t.container.add(this.container)}get parent(){return this._parent}};o=t([n()],o);export{o as SceneComponent};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { CameraActor } from './camera-actor';
|
2
|
-
import { PositionalAudioActor } from './positional-audio-actor';
|
3
|
-
import { SpawnPoint } from './spawn-point';
|
4
|
-
import { TriggerVolume } from './trigger-volume';
|
1
|
+
import { CameraActor } from './camera-actor.js';
|
2
|
+
import { PositionalAudioActor } from './positional-audio-actor.js';
|
3
|
+
import { SpawnPoint } from './spawn-point.js';
|
4
|
+
import { TriggerVolume } from './trigger-volume.js';
|
5
5
|
declare const _default: {
|
6
6
|
Camera: typeof CameraActor;
|
7
7
|
SpawnPoint: typeof SpawnPoint;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{CameraActor as o}from"./camera-actor";import{PositionalAudioActor as r}from"./positional-audio-actor";import{SpawnPoint as i}from"./spawn-point";import{TriggerVolume as t}from"./trigger-volume";export default{Camera:o,SpawnPoint:i,TriggerVolume:t,PositionalAudio:r};
|
1
|
+
import{CameraActor as o}from"./camera-actor.js";import{PositionalAudioActor as r}from"./positional-audio-actor.js";import{SpawnPoint as i}from"./spawn-point.js";import{TriggerVolume as t}from"./trigger-volume.js";export default{Camera:o,SpawnPoint:i,TriggerVolume:t,PositionalAudio:r};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,19 +1,20 @@
|
|
1
1
|
import * as THREE from "three";
|
2
|
-
import { BaseActor } from
|
3
|
-
import { ActorComponent } from '../component';
|
2
|
+
import { BaseActor } from '../actor.js';
|
3
|
+
import { ActorComponent } from '../component.js';
|
4
4
|
export declare class PositionalAudioActor extends BaseActor {
|
5
5
|
audio: PositionalAudioComponent;
|
6
6
|
}
|
7
7
|
export declare class PositionalAudioComponent extends ActorComponent {
|
8
8
|
private audioBuffer;
|
9
|
+
private volume;
|
10
|
+
private loop;
|
11
|
+
private autoPlay;
|
9
12
|
private refDistance;
|
10
13
|
private rollofFactor;
|
11
14
|
private maxDistance;
|
12
|
-
private directionalInnerAngle;
|
13
|
-
private directionalOuterAngle;
|
14
|
-
private directionalOuterGain;
|
15
15
|
private view;
|
16
16
|
readonly sound: THREE.PositionalAudio;
|
17
17
|
private visualisation;
|
18
18
|
onInit(): void | Promise<void>;
|
19
|
+
onEndPlay(): void;
|
19
20
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as
|
1
|
+
import{__decorate as o,__metadata as t}from"tslib";import*as s from"three";import{Actor as i,BaseActor as e}from"../actor.js";import{ActorComponent as n,Component as r,attach as a}from"../component.js";import{Parameter as d}from"../../../shader/index.js";import{ViewController as u}from"../../services/render.js";import{inject as l}from"../../inject.js";import{PositionalAudioHelper as p}from"../../../utils/three/positional-audio-helper.js";let h=class extends e{constructor(){super(...arguments),this.audio=a(c)}};h=o([i()],h);export{h as PositionalAudioActor};let m=class extends n{onInit(){const o=(new s.TextureLoader).load("assets/audio.png"),t=new s.SpriteMaterial({map:o}),i=new s.Sprite(t);this.actor.object.add(i),this.helper=new p(this.positionalAudio)}};m=o([r({inEditor:!0,editorOnly:!0})],m);let c=class extends n{constructor(){super(...arguments),this.volume=1,this.loop=!1,this.autoPlay=!0,this.view=l(u),this.sound=new s.PositionalAudio(this.view.audioListener),this.visualisation=a(m,{positionalAudio:this.sound})}onInit(){this.sound.setBuffer(this.audioBuffer),null!=this.refDistance&&this.sound.setRefDistance(Math.max(this.refDistance,0)),null!=this.rollofFactor&&this.sound.setRolloffFactor(this.rollofFactor),null!=this.maxDistance&&this.sound.setMaxDistance(this.maxDistance),null!=this.volume?this.sound.setVolume(Math.max(this.volume,0)):this.sound.setVolume(0),this.sound.loop=this.loop??!1,this.visualisation?.helper?.update(),this.actor.object.add(this.sound),this.autoPlay&&this.sound?.play(),this.disposed.subscribe((()=>{this.sound.isPlaying&&(this.sound?.stop(),console.log(this.sound.getVolume(),this.volume)),this.sound.removeFromParent()})),console.log(this.sound)}onEndPlay(){this.sound.isPlaying&&(this.sound?.stop(),this.sound.loop=!1),this.sound.removeFromParent()}};o([d(),t("design:type",AudioBuffer)],c.prototype,"audioBuffer",void 0),o([d({range:[0,1]}),t("design:type",Number)],c.prototype,"volume",void 0),o([d(),t("design:type",Boolean)],c.prototype,"loop",void 0),o([d(),t("design:type",Boolean)],c.prototype,"autoPlay",void 0),o([d({range:[0,1e3]}),t("design:type",Number)],c.prototype,"refDistance",void 0),o([d(),t("design:type",Number)],c.prototype,"rollofFactor",void 0),o([d(),t("design:type",Number)],c.prototype,"maxDistance",void 0),c=o([r({inEditor:!0})],c);export{c as PositionalAudioComponent};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { BaseActor } from
|
2
|
-
import { ActorComponent } from
|
3
|
-
import { Type } from
|
1
|
+
import { BaseActor } from '../actor.js';
|
2
|
+
import { ActorComponent } from '../component.js';
|
3
|
+
import { Type } from '../../../utils/type.js';
|
4
4
|
export declare class SpawnPointMesh extends ActorComponent {
|
5
5
|
onInit(): void | Promise<void>;
|
6
6
|
}
|