@hology/core 0.0.95 → 0.0.96

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.
Files changed (48) hide show
  1. package/dist/effects/vfx/initializsers.d.ts +6 -2
  2. package/dist/effects/vfx/initializsers.d.ts.map +1 -1
  3. package/dist/effects/vfx/initializsers.js +1 -1
  4. package/dist/effects/vfx/vfx-actor.d.ts +1 -1
  5. package/dist/effects/vfx/vfx-defs.d.ts +35 -0
  6. package/dist/effects/vfx/vfx-defs.d.ts.map +1 -1
  7. package/dist/effects/vfx/vfx-defs.js +1 -1
  8. package/dist/effects/vfx/vfx-materializer.d.ts +2 -1
  9. package/dist/effects/vfx/vfx-materializer.d.ts.map +1 -1
  10. package/dist/effects/vfx/vfx-materializer.js +1 -1
  11. package/dist/effects/vfx/vfx-renderers.d.ts +1 -0
  12. package/dist/effects/vfx/vfx-renderers.d.ts.map +1 -1
  13. package/dist/effects/vfx/vfx-renderers.js +1 -1
  14. package/dist/gameplay/actors/builtin/navmesh-actor.d.ts.map +1 -1
  15. package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
  16. package/dist/gameplay/ai/behavior-tree/move.js +1 -1
  17. package/dist/gameplay/ai/navigation.d.ts +8 -0
  18. package/dist/gameplay/ai/navigation.d.ts.map +1 -1
  19. package/dist/gameplay/ai/navigation.js +1 -1
  20. package/dist/rendering.d.ts +1 -0
  21. package/dist/rendering.d.ts.map +1 -1
  22. package/dist/rendering.js +1 -1
  23. package/dist/scene/landscape/landscape-manager.d.ts.map +1 -1
  24. package/dist/scene/landscape/landscape-manager.js +1 -1
  25. package/dist/scene/materializer.d.ts.map +1 -1
  26. package/dist/scene/materializer.js +1 -1
  27. package/dist/scene/model.d.ts +1 -1
  28. package/dist/scene/model.d.ts.map +1 -1
  29. package/dist/shader/builtin/decal-standard-shader.d.ts +24 -0
  30. package/dist/shader/builtin/decal-standard-shader.d.ts.map +1 -0
  31. package/dist/shader/builtin/decal-standard-shader.js +4 -0
  32. package/dist/shader/builtin/decal-unlit-shader.d.ts +12 -0
  33. package/dist/shader/builtin/decal-unlit-shader.d.ts.map +1 -0
  34. package/dist/shader/builtin/decal-unlit-shader.js +4 -0
  35. package/dist/shader/decal-shader.d.ts +7 -0
  36. package/dist/shader/decal-shader.d.ts.map +1 -0
  37. package/dist/shader/decal-shader.js +4 -0
  38. package/dist/shader-nodes/decal.d.ts +8 -0
  39. package/dist/shader-nodes/decal.d.ts.map +1 -0
  40. package/dist/shader-nodes/decal.js +4 -0
  41. package/dist/shader-nodes/depth.d.ts +8 -0
  42. package/dist/shader-nodes/depth.d.ts.map +1 -1
  43. package/dist/shader-nodes/depth.js +1 -1
  44. package/dist/shader-nodes/index.d.ts +1 -0
  45. package/dist/shader-nodes/index.d.ts.map +1 -1
  46. package/dist/shader-nodes/index.js +1 -1
  47. package/package.json +3 -3
  48. package/tsconfig.tsbuildinfo +1 -1
@@ -34,8 +34,12 @@ export declare class InitialScaleComponents extends Initializer {
34
34
  initialize(particle: Particle): void;
35
35
  }
36
36
  export declare class AdditiveVelocity extends Initializer {
37
- private velocity;
38
- constructor(velocity: Vector3);
37
+ private min;
38
+ private max?;
39
+ private minX;
40
+ private minY;
41
+ private minZ;
42
+ constructor(min: Vector3, max?: Vector3);
39
43
  initialize(particle: Particle): void;
40
44
  }
41
45
  export declare class RandomDirection extends Initializer {
@@ -1 +1 @@
1
- {"version":3,"file":"initializsers.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/initializsers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAA6B,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE3F,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IAIzC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG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AU,CAAC,QAAQ,EAAE,QAAQ;CAG9B;AAGD,qBAAa,sBAAuB,SAAQ,WAAW;IACzC,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,OAAO;IAClC,UAAU,CAAE,QAAQ,EAAE,QAAQ;CAG/B;AAED,qBAAa,gBAAiB,SAAQ,WAAW;IAKnC,OAAO,CAAC,GAAG;IAAW,OAAO,CAAC,GAAG,CAAC;IAJ9C,OAAO,CAAC,IAAI,CAAsC;IAClD,OAAO,CAAC,IAAI,CAAsC;IAClD,OAAO,CAAC,IAAI,CAAsC;gBAE9B,GAAG,EAAE,OAAO,EAAU,GAAG,CAAC,EAAE,OAAO;IAEvD,UAAU,CAAC,QAAQ,EAAE,QAAQ;CAK9B;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAClC,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAEjC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI;CAO7C;AAED;;GAEG;AAcH,qBAAa,cAAe,SAAQ,WAAW;IAIjC,OAAO,CAAC,GAAG;IAAW,OAAO,CAAC,GAAG;IAH7C,OAAO,CAAC,CAAC,CAAmC;IAC5C,OAAO,CAAC,CAAC,CAAmC;IAC5C,OAAO,CAAC,CAAC,CAAmC;gBACxB,GAAG,EAAE,OAAO,EAAU,GAAG,EAAE,OAAO;IACtD,UAAU,CAAC,MAAM,EAAE,QAAQ;CAM5B"}
@@ -1,4 +1,4 @@
1
- import{Vector3 as t}from"three";import{Span as i,Initializer as e}from"@hology/nebula";export class DefaultInitializer extends e{init(t,i){i.parent=t}initialize(t){}}export class Rotation extends e{constructor(t){super(),this.rotation=t}initialize(t){"number"!=typeof t.rotation&&t.rotation.copy(this.rotation)}}export const randomRotationAxis=["XYZ","X","Y","Z"];export class RandomRotation extends e{constructor(t){super(),this.axis=t}initialize(t){switch(this.axis){case"XYZ":t.rotation.set(this.randomAngle(),this.randomAngle(),this.randomAngle());break;case"X":t.rotation.x=this.randomAngle();break;case"Y":t.rotation.y=this.randomAngle();break;case"Z":t.rotation.z=this.randomAngle()}}randomAngle(){return 2*Math.PI*Math.random()}}export class InitialScale extends e{constructor(t){super(),this.scale=t}initialize(t){t.scale=this.scale}}export class RandomScale extends e{constructor(t,i){super(),this.min=t,this.max=i}initialize(t){var i,e;t.scale=(i=this.min,e=this.max,Math.random()*(e-i)+i)}}export class InitialScaleComponents extends e{constructor(t){super(),this.scale=t}initialize(t){t.transform.initialScale=this.scale}}export class AdditiveVelocity extends e{constructor(t){super(),this.velocity=t}initialize(t){t.velocity.x+=this.velocity.x,t.velocity.y+=this.velocity.y,t.velocity.z+=this.velocity.z}}export class RandomDirection extends e{constructor(t){super(),this.speed=t}initialize(t){s.set(2*Math.random()-1,2*Math.random()-1,2*Math.random()-1).normalize().multiplyScalar(this.speed),t.velocity.x+=s.x,t.velocity.y+=s.y,t.velocity.z+=s.z}}export class RandomVelocity extends e{constructor(t,e){super(),this.min=t,this.max=e,this.x=new i(this.min.x,this.max.x),this.y=new i(this.min.y,this.max.y),this.z=new i(this.min.z,this.max.z)}initialize(t){t.velocity.x+=this.x.getValue(),t.velocity.y+=this.y.getValue(),t.velocity.z+=this.z.getValue()}}const s=new t;/*
1
+ import{Vector3 as t}from"three";import{Span as i,Initializer as e,createSpan as s}from"@hology/nebula";export class DefaultInitializer extends e{init(t,i){i.parent=t}initialize(t){}}export class Rotation extends e{constructor(t){super(),this.rotation=t}initialize(t){"number"!=typeof t.rotation&&t.rotation.copy(this.rotation)}}export const randomRotationAxis=["XYZ","X","Y","Z"];export class RandomRotation extends e{constructor(t){super(),this.axis=t}initialize(t){switch(this.axis){case"XYZ":t.rotation.set(this.randomAngle(),this.randomAngle(),this.randomAngle());break;case"X":t.rotation.x=this.randomAngle();break;case"Y":t.rotation.y=this.randomAngle();break;case"Z":t.rotation.z=this.randomAngle()}}randomAngle(){return 2*Math.PI*Math.random()}}export class InitialScale extends e{constructor(t){super(),this.scale=t}initialize(t){t.scale=this.scale}}export class RandomScale extends e{constructor(t,i){super(),this.min=t,this.max=i}initialize(t){var i,e;t.scale=(i=this.min,e=this.max,Math.random()*(e-i)+i)}}export class InitialScaleComponents extends e{constructor(t){super(),this.scale=t}initialize(t){t.transform.initialScale=this.scale}}export class AdditiveVelocity extends e{constructor(t,i){super(),this.min=t,this.max=i,this.minX=s(this.min.x,this.max?.x),this.minY=s(this.min.y,this.max?.y),this.minZ=s(this.min.z,this.max?.z)}initialize(t){t.velocity.x+=this.minX.getValue(),t.velocity.y+=this.minY.getValue(),t.velocity.z+=this.minZ.getValue()}}export class RandomDirection extends e{constructor(t){super(),this.speed=t}initialize(t){a.set(2*Math.random()-1,2*Math.random()-1,2*Math.random()-1).normalize().multiplyScalar(this.speed),t.velocity.x+=a.x,t.velocity.y+=a.y,t.velocity.z+=a.z}}export class RandomVelocity extends e{constructor(t,e){super(),this.min=t,this.max=e,this.x=new i(this.min.x,this.max.x),this.y=new i(this.min.y,this.max.y),this.z=new i(this.min.z,this.max.z)}initialize(t){t.velocity.x+=this.x.getValue(),t.velocity.y+=this.y.getValue(),t.velocity.z+=this.z.getValue()}}const a=new t;/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -36,7 +36,7 @@ export declare class VfxActor extends BaseActor {
36
36
  * The container is a child of the actor so still objects move along with the actor
37
37
  *
38
38
  */
39
- getParticleCount(): any;
39
+ getParticleCount(): number;
40
40
  onEndPlay(): void;
41
41
  }
42
42
  //# sourceMappingURL=vfx-actor.d.ts.map
@@ -45,12 +45,26 @@ declare class LifetimeDef extends BaseIniDef<LifetimeDef> {
45
45
  };
46
46
  make(params?: ParamsType<this>): Initializer;
47
47
  }
48
+ declare class RandomLifetimeDef extends BaseIniDef<RandomLifetimeDef> {
49
+ parameters: {
50
+ minDuration: FloatParameterDef;
51
+ maxDuration: FloatParameterDef;
52
+ };
53
+ make(params?: ParamsType<this>): Initializer;
54
+ }
48
55
  declare class VelocityDef extends BaseIniDef<VelocityDef> {
49
56
  parameters: {
50
57
  velocity: ShapeParameterDef<Vector3>;
51
58
  };
52
59
  make(params?: ParamsType<this>): Initializer;
53
60
  }
61
+ declare class RandomVelocityDef extends BaseIniDef<RandomVelocityDef> {
62
+ parameters: {
63
+ min: ShapeParameterDef<Vector3>;
64
+ max: ShapeParameterDef<Vector3>;
65
+ };
66
+ make(params?: ParamsType<this>): Initializer;
67
+ }
54
68
  declare class PositionPointDef extends BaseIniDef<PositionPointDef> {
55
69
  parameters: {
56
70
  position: ShapeParameterDef<Vector3>;
@@ -78,6 +92,23 @@ declare class PositionLineDef extends BaseIniDef<PositionLineDef> {
78
92
  };
79
93
  make(params?: ParamsType<this>): Initializer;
80
94
  }
95
+ declare class PositionCircleDef extends BaseIniDef<PositionCircleDef> {
96
+ parameters: {
97
+ position: ShapeParameterDef<Vector3>;
98
+ rotation: ShapeParameterDef<Vector3>;
99
+ radius: FloatParameterDef;
100
+ };
101
+ make(params?: ParamsType<this>): Initializer;
102
+ }
103
+ declare class PositionRingDef extends BaseIniDef<PositionRingDef> {
104
+ parameters: {
105
+ position: ShapeParameterDef<Vector3>;
106
+ rotation: ShapeParameterDef<Vector3>;
107
+ radius: FloatParameterDef;
108
+ thickness: FloatParameterDef;
109
+ };
110
+ make(params?: ParamsType<this>): Initializer;
111
+ }
81
112
  declare class RadialVelocityDef extends BaseIniDef<RadialVelocityDef> {
82
113
  parameters: {
83
114
  speed: FloatParameterDef;
@@ -242,10 +273,13 @@ declare class WorldCollisionDef extends BaseBevDef<WorldCollisionDef> {
242
273
  }
243
274
  declare const vfxInitializsers: {
244
275
  lifetime: LifetimeDef;
276
+ randomLifetime: RandomLifetimeDef;
245
277
  positionPoint: PositionPointDef;
246
278
  positionBox: PositionBoxDef;
247
279
  positionSphere: PositionSphereDef;
248
280
  positionLine: PositionLineDef;
281
+ positionCircle: PositionCircleDef;
282
+ positionRing: PositionRingDef;
249
283
  rotation: RotationDef;
250
284
  randomRotation: RandomRotationDef;
251
285
  scale: InitialScaleDef;
@@ -253,6 +287,7 @@ declare const vfxInitializsers: {
253
287
  randomScale: RandomScaleDef;
254
288
  mass: MassDef;
255
289
  velocity: VelocityDef;
290
+ randomVelocity: RandomVelocityDef;
256
291
  radialVelocity: RadialVelocityDef;
257
292
  randomDirection: RandomDirectionDef;
258
293
  };
@@ -1 +1 @@
1
- {"version":3,"file":"vfx-defs.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/vfx-defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,EAAqB,SAAS,EAAgE,WAAW,EAAsG,MAAM,gBAAgB,CAAA;AAK5O,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAM7C,KAAK,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAA;AAE5B,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,IAAI;IACrG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,QAAQ,GAC3B,CAAC,SAAS,QAAQ,GAAG,OAAO,GAC5B,CAAC,SAAS,MAAM,GAAG,QAAQ,GAAC,QAAQ,GACpC,CAAC,SAAS,OAAO,GAAG,MAAM,GAC1B,CAAC,SAAS,OAAO,GAAG,MAAM,GAC1B,CAAC,SAAS,MAAM,GAAG,OAAO,GAC1B,CAAC,SAAS,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC;CACZ,CAAA;AAED,KAAK,iBAAiB,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG;IACnD,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CA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AAQ,UAAU,CAAC,aAAa,CAAC;IACnD,UAAU;;;;;MAMT;IACD,IAAI,CAAC,MAAM,GAAE,UAAU,CAAC,IAAI,CAAM,GAAG,SAAS;CAI/C;AAGD,cAAM,SAAU,SAAQ,UAAU,CAAC,SAAS,CAAC;IAC3C,UAAU;;;MAGT;IACD,IAAI,CAAC,MAAM,GAAE,UAAU,CAAC,IAAI,CAAM,GAAG,SAAS;CAG/C;AAED,cAAM,gBAAiB,SAAQ,UAAU,CAAC,gBAAgB,CAAC;IACzD,UAAU;;MAET;IACD,IAAI,CAAC,MAAM,GAAE,UAAU,CAAC,IAAI,CAAM,GAAG,SAAS;CAK/C;AAED,cAAM,iBAAkB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC3D,UAAU;;;;MAMT;IACD,IAAI,CAAC,MAAM,GAAE,UAAU,CAAC,IAAI,CAAM,GAAG,SAAS;CAK/C;AAeD,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CAmBrB,CAAA;AAED,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;CAwBlB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,gBAAgB,CAAA;AACpE,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,wBAAwB,EAAE,qBAAqB,CAAoB,CAAA;AAC/G,eAAO,MAAM,0BAA0B,EAA0C,wBAAwB,EAAE,CAAA;AAE3G,MAAM,MAAM,uBAAuB,GAAG,MAAM,OAAO,aAAa,CAAA;AAChE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,uBAAuB,EAAE,mBAAmB,CAAiB,CAAA;AACtG,eAAO,MAAM,uBAAuB,EAAuC,uBAAuB,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
- import{MathUtils as e,Vector2 as r,Vector3 as t}from"three";import{Alpha as s,Attraction as n,BoxZone as a,Color as o,ease as i,Force as c,Gravity as u,Life as d,LineZone as p,Mass as m,Position as l,RadialVelocity as w,RandomDrift as x,Repulsion as f,Rotate as y,Vector3D as h}from"@hology/nebula";import{AxisDirection as g,AxisPlane as k,Disperse as v,FollowParent as b,LinearDamping as z,MoveOverLife as T,OrientAlongVelocity as R,RotatePosition as L,Scale as j}from"./behaviours.js";import{AdditiveVelocity as V,InitialScale as B,InitialScaleComponents as C,RandomDirection as D,RandomRotation as I,randomRotationAxis as O,RandomScale as A,Rotation as K}from"./initializsers.js";import{PointZone as P,SphereZone as S}from"./zones.js";import{WorldCollisionBehaviour as Y}from"./vfx-collision-behaviour.js";import{Curve2 as X}from"../../utils/curve.js";class Z{build(e={}){const r=M(e,this.parameters);return this.make(r)}}class q{build(e={}){const r=M(e,this.parameters);return this.make(r)}}function E(e,r,t){return{type:"number",default:e,float:!0,min:r,max:t}}function F(e){return{type:"vec3",default:(new t).fromArray(e)}}function G(e){return{type:"color",default:e}}function H(e,r){return{type:"select",opts:e,default:r}}function J(){return{type:"curve",default:X.linear()}}function M(e,r){const t={};for(let s in r)null==e[s]?t[s]=r[s].default:t[s]=e[s];return t}function N(e){return r=>e.getY(r)}const Q={lifetime:new class extends q{constructor(){super(...arguments),this.parameters={duration:E(1,0,1e5)}}make(e={}){return new d(e.duration)}},positionPoint:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0])}}make(e={}){const{x:r,y:t,z:s}=e.position;return new l(new P(r,t,s))}},positionBox:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0]),dimensions:F([0,0,0])}}make(e={}){const{x:r,y:t,z:s}=e.position,{x:n,y:o,z:i}=e.dimensions;return new l(new a(r,t,s,n,o,i))}},positionSphere:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0]),radius:E(1)}}make(e={}){const{x:r,y:t,z:s}=e.position;return new l(new S(r,t,s,e.radius))}},positionLine:new class extends q{constructor(){super(...arguments),this.parameters={a:F([0,0,0]),b:F([0,0,1])}}make(e={}){const{x:r,y:t,z:s}=e.a,{x:n,y:a,z:o}=e.b;return new l(new p(r,t,s,n,a,o))}},rotation:new class extends q{constructor(){super(...arguments),this.parameters={rotation:F([0,0,0])}}make(r={}){const{x:s,y:n,z:a}=r.rotation;return new K(new t(e.degToRad(s),e.degToRad(n),e.degToRad(a)))}},randomRotation:new class extends q{constructor(){super(...arguments),this.parameters={axis:H(O,"XYZ")}}make(e={}){return new I(e.axis)}},scale:new class extends q{constructor(){super(...arguments),this.parameters={scale:E(1)}}make(e={}){return new B(e.scale)}},scaleComponents:new class extends q{constructor(){super(...arguments),this.parameters={scale:F([1,1,1])}}make(e={}){return new C(e.scale)}},randomScale:new class extends q{constructor(){super(...arguments),this.parameters={min:E(1),max:E(1)}}make(e={}){return new A(e.min,e.max)}},mass:new class extends q{constructor(){super(...arguments),this.parameters={min:E(1)}}make(e={}){return new m(e.min)}},velocity:new class extends q{constructor(){super(...arguments),this.parameters={velocity:F([0,0,0])}}make(e={}){const{x:r,y:s,z:n}=e.velocity;return new V(new t(r,s,n))}},radialVelocity:new class extends q{constructor(){super(...arguments),this.parameters={speed:E(1),direction:F([0,1,0]),spread:E(0)}}make(e={}){return new w(e.speed,new h(e.direction.x,e.direction.y,e.direction.z),e.spread)}},randomDirection:new class extends q{constructor(){super(...arguments),this.parameters={speed:E(1)}}make(e={}){return new D(e.speed)}}},U={force:new class extends Z{constructor(){super(...arguments),this.parameters={force:F([0,0,0]),ease:J()}}make(e={}){return new c(e.force.x,e.force.y,e.force.z,void 0,N(e.ease))}},gravity:new class extends Z{constructor(){super(...arguments),this.parameters={gravity:E(8),easing:J()}}make(e={}){return new u(e.gravity,void 0,N(e.easing))}},repulsion:new class extends Z{constructor(){super(...arguments),this.parameters={target:F([0,0,0]),force:E(1),radius:E(1),easing:J()}}make(e={}){const r=new h(e.target.x,e.target.y,e.target.z);return new f(r,e.force,e.radius,void 0,N(e.easing))}},attraction:new class extends Z{constructor(){super(...arguments),this.parameters={target:F([0,0,0]),force:E(1),radius:E(1),easing:J()}}make(e={}){const r=new h(e.target.x,e.target.y,e.target.z);return new n(r,e.force,e.radius,void 0,N(e.easing))}},scale:new class extends Z{constructor(){super(...arguments),this.parameters={a:E(1),b:E(1),ease:J()}}make(e={}){return new j(e.a,e.b,N(e.ease))}},randomDrift:new class extends Z{constructor(){super(...arguments),this.parameters={drift:F([1,1,1]),delay:E(0),ease:J()}}make(e={}){return new x(e.drift.x,e.drift.y,e.drift.z,e.delay,void 0,N(e.ease))}},rotate:new class extends Z{constructor(){super(...arguments),this.parameters={rotation:F([0,0,0]),ease:J()}}make(r={}){const{x:t,y:s,z:n}=r.rotation;return new y(e.degToRad(t),e.degToRad(s),e.degToRad(n),void 0,N(r.ease))}},rotateAdd:new class extends Z{constructor(){super(...arguments),this.parameters={rotation:F([0,0,0])}}make(r={}){const{x:t,y:s,z:n}=r.rotation,a=new y(e.degToRad(t),e.degToRad(s),e.degToRad(n),void 0);return a.rotationType="add",a}},changeColor:new class extends Z{constructor(){super(...arguments),this.parameters={a:G("#ffffff"),b:G("#ffffff"),ease:J()}}make(e={}){return new o(e.a,e.b,void 0,N(e.ease))}},changeOpacity:new class extends Z{constructor(){super(...arguments),this.parameters={a:E(1,0,1),b:E(0,0,1),ease:J()}}make(e={}){return new s(e.a,e.b,void 0,N(e.ease))}},vortex:new class extends Z{constructor(){super(...arguments),this.parameters={axis:F([0,1,0]),amount:E(1)}}make(e={}){return new L(e.axis,e.amount)}},moveTo:new class extends Z{constructor(){super(...arguments),this.parameters={target:F([0,1,0]),ease:J()}}make(e={}){return new T(e.target.x,e.target.y,e.target.z,N(e.ease))}},linearDamping:new class extends Z{constructor(){super(...arguments),this.parameters={factor:E(.1,0,1)}}make(e={}){return new z(e.factor)}},followParent:new class extends Z{constructor(){super(...arguments),this.parameters={speed:E(1)}}make(e={}){return new b(e.speed)}},worldCollision:new class extends Z{constructor(){super(...arguments),this.parameters={friction:E(1,0,1),bounce:E(1,0,1),lifeLoss:E(0,0)}}make(e={}){return new Y(null,e.bounce,e.friction,e.lifeLoss)}}};export const VfxInitializserLibrary=Q;export const VfxInitializserLibraryKeys=Object.keys(VfxInitializserLibrary);export const VfxBehaviourLibrary=U;export const VfxBehaviourLibraryKeys=Object.keys(VfxBehaviourLibrary);/*
1
+ import{MathUtils as e,Vector2 as r,Vector3 as t}from"three";import{Alpha as s,Attraction as n,BoxZone as a,CircleZone as o,Color as i,ease as c,Force as u,Gravity as d,Life as m,LineZone as p,Mass as l,Position as w,RadialVelocity as x,RandomDrift as f,Repulsion as h,Rotate as y,Vector3D as g}from"@hology/nebula";import{AxisDirection as k,AxisPlane as v,Disperse as z,FollowParent as b,LinearDamping as R,MoveOverLife as T,OrientAlongVelocity as L,RotatePosition as V,Scale as j}from"./behaviours.js";import{AdditiveVelocity as D,InitialScale as C,InitialScaleComponents as B,RandomDirection as I,RandomRotation as O,randomRotationAxis as A,RandomScale as K,Rotation as P}from"./initializsers.js";import{PointZone as S,SphereZone as Y}from"./zones.js";import{WorldCollisionBehaviour as M}from"./vfx-collision-behaviour.js";import{Curve2 as X}from"../../utils/curve.js";class Z{build(e={}){const r=N(e,this.parameters);return this.make(r)}}class q{build(e={}){const r=N(e,this.parameters);return this.make(r)}}function E(e,r,t){return{type:"number",default:e,float:!0,min:r,max:t}}function F(e){return{type:"vec3",default:(new t).fromArray(e)}}function G(e){return{type:"color",default:e}}function H(e,r){return{type:"select",opts:e,default:r}}function J(){return{type:"curve",default:X.linear()}}function N(e,r){const t={};for(let s in r)null==e[s]?t[s]=r[s].default:t[s]=e[s];return t}function Q(e){return r=>e.getY(r)}const U={lifetime:new class extends q{constructor(){super(...arguments),this.parameters={duration:E(1,0,1e5)}}make(e={}){return new m(e.duration)}},randomLifetime:new class extends q{constructor(){super(...arguments),this.parameters={minDuration:E(1,0,1e5),maxDuration:E(2,0,1e5)}}make(e={}){return new m(e.minDuration,e.maxDuration)}},positionPoint:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0])}}make(e={}){const{x:r,y:t,z:s}=e.position;return new w(new S(r,t,s))}},positionBox:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0]),dimensions:F([0,0,0])}}make(e={}){const{x:r,y:t,z:s}=e.position,{x:n,y:o,z:i}=e.dimensions;return new w(new a(r,t,s,n,o,i))}},positionSphere:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0]),radius:E(1)}}make(e={}){const{x:r,y:t,z:s}=e.position;return new w(new Y(r,t,s,e.radius))}},positionLine:new class extends q{constructor(){super(...arguments),this.parameters={a:F([0,0,0]),b:F([0,0,1])}}make(e={}){const{x:r,y:t,z:s}=e.a,{x:n,y:a,z:o}=e.b;return new w(new p(r,t,s,n,a,o))}},positionCircle:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0]),rotation:F([0,0,0]),radius:E(1,0,1e4)}}make(r={}){const{x:t,y:s,z:n}=r.position,{x:a,y:i,z:c}=r.rotation;return new w(new o(t,s,n,r.radius,0,e.degToRad(a),e.degToRad(i),e.degToRad(c)))}},positionRing:new class extends q{constructor(){super(...arguments),this.parameters={position:F([0,0,0]),rotation:F([0,0,0]),radius:E(1,0,1e4),thickness:E(.2,0,1e4)}}make(r={}){const{x:t,y:s,z:n}=r.position,{x:a,y:i,z:c}=r.rotation;return new w(new o(t,s,n,r.radius,Math.max(r.thickness,1e-4),e.degToRad(a),e.degToRad(i),e.degToRad(c)))}},rotation:new class extends q{constructor(){super(...arguments),this.parameters={rotation:F([0,0,0])}}make(r={}){const{x:s,y:n,z:a}=r.rotation;return new P(new t(e.degToRad(s),e.degToRad(n),e.degToRad(a)))}},randomRotation:new class extends q{constructor(){super(...arguments),this.parameters={axis:H(A,"XYZ")}}make(e={}){return new O(e.axis)}},scale:new class extends q{constructor(){super(...arguments),this.parameters={scale:E(1)}}make(e={}){return new C(e.scale)}},scaleComponents:new class extends q{constructor(){super(...arguments),this.parameters={scale:F([1,1,1])}}make(e={}){return new B(e.scale)}},randomScale:new class extends q{constructor(){super(...arguments),this.parameters={min:E(1),max:E(1)}}make(e={}){return new K(e.min,e.max)}},mass:new class extends q{constructor(){super(...arguments),this.parameters={min:E(1)}}make(e={}){return new l(e.min)}},velocity:new class extends q{constructor(){super(...arguments),this.parameters={velocity:F([0,0,0])}}make(e={}){const{x:r,y:s,z:n}=e.velocity;return new D(new t(r,s,n))}},randomVelocity:new class extends q{constructor(){super(...arguments),this.parameters={min:F([0,0,0]),max:F([0,0,0])}}make(e={}){return new D(e.min,e.max)}},radialVelocity:new class extends q{constructor(){super(...arguments),this.parameters={speed:E(1),direction:F([0,1,0]),spread:E(0)}}make(e={}){return new x(e.speed,new g(e.direction.x,e.direction.y,e.direction.z),e.spread)}},randomDirection:new class extends q{constructor(){super(...arguments),this.parameters={speed:E(1)}}make(e={}){return new I(e.speed)}}},W={force:new class extends Z{constructor(){super(...arguments),this.parameters={force:F([0,0,0]),ease:J()}}make(e={}){return new u(e.force.x,e.force.y,e.force.z,void 0,Q(e.ease))}},gravity:new class extends Z{constructor(){super(...arguments),this.parameters={gravity:E(8),easing:J()}}make(e={}){return new d(e.gravity,void 0,Q(e.easing))}},repulsion:new class extends Z{constructor(){super(...arguments),this.parameters={target:F([0,0,0]),force:E(1),radius:E(1),easing:J()}}make(e={}){const r=new g(e.target.x,e.target.y,e.target.z);return new h(r,e.force,e.radius,void 0,Q(e.easing))}},attraction:new class extends Z{constructor(){super(...arguments),this.parameters={target:F([0,0,0]),force:E(1),radius:E(1),easing:J()}}make(e={}){const r=new g(e.target.x,e.target.y,e.target.z);return new n(r,e.force,e.radius,void 0,Q(e.easing))}},scale:new class extends Z{constructor(){super(...arguments),this.parameters={a:E(1),b:E(1),ease:J()}}make(e={}){return new j(e.a,e.b,Q(e.ease))}},randomDrift:new class extends Z{constructor(){super(...arguments),this.parameters={drift:F([1,1,1]),delay:E(0),ease:J()}}make(e={}){return new f(e.drift.x,e.drift.y,e.drift.z,e.delay,void 0,Q(e.ease))}},rotate:new class extends Z{constructor(){super(...arguments),this.parameters={rotation:F([0,0,0]),ease:J()}}make(r={}){const{x:t,y:s,z:n}=r.rotation;return new y(e.degToRad(t),e.degToRad(s),e.degToRad(n),void 0,Q(r.ease))}},rotateAdd:new class extends Z{constructor(){super(...arguments),this.parameters={rotation:F([0,0,0])}}make(r={}){const{x:t,y:s,z:n}=r.rotation,a=new y(e.degToRad(t),e.degToRad(s),e.degToRad(n),void 0);return a.rotationType="add",a}},changeColor:new class extends Z{constructor(){super(...arguments),this.parameters={a:G("#ffffff"),b:G("#ffffff"),ease:J()}}make(e={}){return new i(e.a,e.b,void 0,Q(e.ease))}},changeOpacity:new class extends Z{constructor(){super(...arguments),this.parameters={a:E(1,0,1),b:E(0,0,1),ease:J()}}make(e={}){return new s(e.a,e.b,void 0,Q(e.ease))}},vortex:new class extends Z{constructor(){super(...arguments),this.parameters={axis:F([0,1,0]),amount:E(1)}}make(e={}){return new V(e.axis,e.amount)}},moveTo:new class extends Z{constructor(){super(...arguments),this.parameters={target:F([0,1,0]),ease:J()}}make(e={}){return new T(e.target.x,e.target.y,e.target.z,Q(e.ease))}},linearDamping:new class extends Z{constructor(){super(...arguments),this.parameters={factor:E(.1,0,1e3)}}make(e={}){return new R(e.factor)}},followParent:new class extends Z{constructor(){super(...arguments),this.parameters={speed:E(1)}}make(e={}){return new b(e.speed)}},worldCollision:new class extends Z{constructor(){super(...arguments),this.parameters={friction:E(1,0,1),bounce:E(1,0,1),lifeLoss:E(0,0)}}make(e={}){return new M(null,e.bounce,e.friction,e.lifeLoss)}}};export const VfxInitializserLibrary=U;export const VfxInitializserLibraryKeys=Object.keys(VfxInitializserLibrary);export const VfxBehaviourLibrary=W;export const VfxBehaviourLibraryKeys=Object.keys(VfxBehaviourLibrary);/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,3 +1,4 @@
1
+ import System from "@hology/nebula";
1
2
  import * as THREE from 'three';
2
3
  import { Object3D } from "three";
3
4
  import { NodeShaderMaterial } from "three-shader-graph";
@@ -11,7 +12,7 @@ export type VfxAssetProvider = {
11
12
  };
12
13
  export declare function materializeVfx(asset: VfxAsset, target: Object3D, assetProvider: VfxAssetProvider, view: ViewController, physics: PhysicsSystem): Promise<{
13
14
  container: THREE.Object3D<THREE.Object3DEventMap>;
14
- system: any;
15
+ system: System;
15
16
  dispose: () => void;
16
17
  }>;
17
18
  export declare class SpriteNodeShaderMaterial extends NodeShaderMaterial {
@@ -1 +1 @@
1
- {"version":3,"file":"vfx-materializer.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/vfx-materializer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAmD,kBAAkB,EAA0U,MAAM,oBAAoB,CAAC;AAEjb,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAE,KAAK,EAAuB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgB5E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IACzC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACnD,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACjD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;CACtD,CAAA;AAGD,wBAAsB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa;;;;GAyDpJ;AA8YD,qBAAa,wBAAyB,SAAQ,kBAAkB;IAE9D,IAAI,KAAK,IAGQ,KAAK,CAAC,mBAAmB,CADzC;IACD,IAAI,KAA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EAAE,aAAa,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa;;;;GAyDpJ;AA8YD,qBAAa,wBAAyB,SAAQ,kBAAkB;IAE9D,IAAI,KAAK,IAGQ,KAAK,CAAC,mBAAmB,CADzC;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,mBAAmB,EAEzC;IACD,IAAI,QAAQ,IAGQ,MAAM,CADzB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAEzB;CACF;AAoSD,qBAAa,WAAW,CAAC,CAAC;IAIZ,OAAO,CAAC,OAAO;IAF3B,SAAS,EAAE,CAAC,EAAE,CAAK;gBAEC,OAAO,EAAE,MAAM,CAAC;IAEpC;;;OAGG;IACH,GAAG,IAAI,CAAC;IAQR;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC;IAMnB,OAAO;CAGR"}
@@ -1,4 +1,4 @@
1
- import e,{Behaviour as t,Body as i,Emitter as n,Rate as s}from"@hology/nebula";import*as o from"three";import{Object3D as r}from"three";import{AttributeVec3Node as a,AttributeVec4Node as l,NodeShaderMaterial as c,RgbNode as m,UniformFloatNode as p,UniformVec3Node as u,Vec3ExpressionNode as h,Vec4Node as d,attributeFloat as f,attributeVec3 as y,attributeVec4 as g,attributes as w,float as v,glslFunction as A,lambertMaterial as x,log as E,pow as b,rgb as M,rgba as P,saturate as I,standardMaterial as S,textureSampler2d as R,transformed as C,uniformFloat as B,uniforms as j,varying as k,varyingAttributes as z,varyingVec3 as T,varyingVec4 as V}from"three-shader-graph";import{prepareShapeParameters as D}from"../../scene/materializer.js";import{SerializedParamType as F}from"../../scene/model.js";import{ShapeLibrary as Q}from"../../scene/objects/shapes.js";import{fragmentLinearEyeDepth as U,linearEyeDepth as W}from"../../shader-nodes/depth.js";import{particleEnergyUniformName as L,particleTimeUniformName as q,particleUniforms as H,particleVelcoityUniformName as G}from"../../shader-nodes/particle.js";import{sampleFlipbook as J}from"../../shader-nodes/texture-sequence.js";import{DefaultInitializer as N}from"./initializsers.js";import{DelayRate as O,OnceRate as K}from"./rates.js";import{StretchedSprite as X}from"./stretched-sprite.js";import{ThreeBlendingMode as Y}from"./vfx-asset.js";import{VfxBehaviourLibrary as Z,VfxInitializserLibrary as _}from"./vfx-defs.js";import{MultiRenderer as $}from"./vfx-renderers.js";import{WorldCollisionBehaviour as ee}from"./vfx-collision-behaviour.js";export async function materializeVfx(t,i,n,s,a){let l=i;for(;null!=l.parent;)l=l.parent;const c=new r;c.name="particle system local",i.add(c);const m=new r;m.name="particle system world",l.add(m);const p=new $(m,c,o,s),u=new e;return(await Promise.all(t.vfx.emitters.map((async e=>{const t=await te(e,n,u,a);return t.setParentRecursive(u),t.emit()})))).forEach((e=>u.addEmitter(e))),u.addRenderer(p).emit({onEnd:()=>{}}),{container:m,system:u,dispose:()=>{m.removeFromParent(),c.removeFromParent(),p.dispose()}}}async function te(e,t,n,m){const T=function(e){let t;switch(e.rate.type){case"continuous":t=new O(e.rate.delay??0,e.rate.count,e.rate.time);break;case"once":t=new K(e.rate.delay??0,e.rate.count);break;default:console.warn(`Failed to configure rate for emitter: ${JSON.stringify(e)}`),t=new s(0,1/0)}return t}(e);let L;switch(e.output.type){case"sprite":L=new i(await async function(e,t){const i=null!=e.texture?await t.getTexture(e.texture):ie,n=R(i);let s=n.sample(z.uv);e.flipbook?.enabled&&(s=J(n,w.uv,e.flipbook.columns,e.flipbook.rows,H.time,e.flipbook.fps,e.flipbook.mode));const r=new p("rotation",0),a=new u("color").rgb,l=B("opacity",1),c=W.subtract(U).divide(W);let m=s.x.multiply(l);if("number"==typeof e.softness&&e.softness>0){const t=b(c,v(e.softness));m=m.multiply(t)}const h=A(d,{position:C.position,modelViewMatrix:j.modelViewMatrix,rotation:r},"\n vec2 center = vec2(0.5, 0.5);\n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n // Using scale form instance matrix instead of modelMatrix\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n // This times 2 on scale seem to make it appear like when using regular sprites. \n // Not sure if this is correct though.\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * (scale);\n\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return projectionMatrix * mvPosition;\n ");var f=new SpriteNodeShaderMaterial({color:P(a,m).multiply(s),transparent:!0,position:h,uniforms:{color:{value:new o.Color(e.color)}}});f.blending=Y[e.blendingMode]??o.NormalBlending;const y=new o.Mesh(new o.PlaneGeometry(1,1),f);return y.name="sprite",y}(e.output,t));break;case"stretchedSprite":L=new i(await async function(e,t){const i=null!=e.texture?await t.getTexture(e.texture):ie,n=R(i).sample(z.uv),s=V(new l("color")),r=s.rgb;let a=s.w;if("number"==typeof e.softness&&e.softness>0){const t=W.subtract(U).divide(E(W)),i=b(t,v(e.softness));a=I(a.multiply(i))}const c=A(d,{position:w.position,offset:g("offset"),modelViewMatrix:j.modelViewMatrix,velocity:g("velocity"),size:y("size"),rotation:f("rotation")},"\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n\n vec4 mvPosition = modelViewMatrix * vec4( offset , 1.0 );\n vec3 viewVelocity = normalMatrix * velocity.xyz;\n float vlength = length(viewVelocity); \n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, viewVelocity)) * avgSize; \n mvPosition.xyz -= (position.x + 0.5) * viewVelocity * (1.0 + lengthFactor / vlength) * avgSize;\n return projectionMatrix * mvPosition;\n ");var m=new SpriteNodeShaderMaterial({color:P(r,a).multiply(n),transparent:!0,position:c,uniforms:{}});m.blending=Y[e.blendingMode]??o.NormalBlending;const p=new X(new o.PlaneGeometry(1,1),m);return p.scaleFactor=e.scale,p}(e.output,t));break;case"shape":L=new i(await async function(e,t){if(null==e.shape)return console.log("Shape is null"),new r;const i=Q[e.shape];if(null==i)return console.error(`No shape with type ${e.shape}`),new r;const n=D(e.params??{}),s=i.geometry(n),l=null!=e.material?function(e){const t=k(new h("instanceColor")).rgb,i=k(new a("particleData")).x;let n;if(e instanceof o.MeshStandardMaterial||e instanceof o.MeshLambertMaterial||e instanceof o.MeshBasicMaterial){let s=t.multiply(M(e.color));null!=e.map&&(s=s.multiply(R(e.map).sample(z.uv).rgb)),e instanceof o.MeshStandardMaterial?n=new c({color:S({color:s,emissive:M(e.emissive),emissiveIntensity:v(e.emissiveIntensity),roughness:e.roughness,metalness:e.metalness}).rgb.rgba(1),transparent:e.transparent}):e instanceof o.MeshLambertMaterial?n=new c({color:x({color:s}).rgb.rgba(i),transparent:e.transparent}):e instanceof o.MeshBasicMaterial&&(n=new c({color:s,transparent:e.transparent}))}null!=n&&(!0===e.userData?.hasBloom&&null!=n&&(n.userData.hasBloom=!0),n.side=e.side,n.transparent=e.transparent);return n??e}(await t.getMaterial(e.material)):function(){const e=k(new h("instanceColor")).rgb,t=k(new a("particleData")).x;return new c({color:x({color:e}).rgb.rgba(t),transparent:!0})}();return new o.Mesh(s,l)}(e.output,t));break;case"mesh":L=new i(await async function(e,t){if(null==e.assetId)return console.warn("Can't use mesh as particle without asset id"),new r;const i=await t.getMesh(e.assetId),n=await t.getAsset(e.assetId),s=[];if(null!=n.materialAssignments)for(const e of n.materialAssignments)i.traverse((i=>{i instanceof o.Mesh&&i.material instanceof o.Material&&i.material.color instanceof o.Color&&(i.material.name!=e.name&&null!=e.name||"#"+i.material.color.getHexString()!==e.color||s.push(t.getMaterial(e.materialId).then((e=>i.material=e))))}));await Promise.all(s);const a=[];if(i.traverse((e=>{e instanceof o.Mesh&&a.push(e)})),1===a.length){const e=a[0];return e.updateWorldMatrix(!0,!0),e.updateMatrixWorld(),e.matrix.copy(e.matrixWorld),e.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.removeFromParent(),e}return i}(e.output,t));break;case"trail":L=new i({type:"trail",taper:e.output.taper,headGeometry:null,dragTexture:!1,color:e.output.color,colorEnd:e.output.colorEnd,length:e.output.length,opacityStart:e.output.opacityStart,opacityEnd:e.output.opacityEnd,bloom:e.output.bloom});break;default:console.error("Failed to create particly system body: "+JSON.stringify(e))}const q=new se;q.parent=n,q.setRate(T),q._space=e.output.space;const G=await Promise.all(e.initializers.filter((e=>null!=_[e.type])).map((async e=>{const t=_[e.type],i=await D(e.params??{});return t.build(i)})));G.push(L,new N),q.addInitializers(G);const $=await Promise.all(e.behaviours.filter((e=>null!=Z[e.type])).map((async e=>{const t=Z[e.type];for(const[i,n]of Object.entries(e.params))t.parameters&&null!=t.parameters[i]&&"curve"===t.parameters[i].type&&n.type!==F.Curve&&(n.type=F.Curve);const i=await D(e.params??{});return t.build(i)})).sort(((e,t)=>e instanceof ee?1:0)));$.push(new ne);for(const e of $)e instanceof ee&&(e.physics=m);q.addBehaviours($);for(const i of e.children){const e=await te(i,t,n,m),s=new EmitterPool((()=>{const t=e.clone();return t.onExpired=()=>{const e=q.childEmitters.findIndex((e=>e.id===t.id));-1!=e&&q.childEmitters.splice(e,1),s.release(t)},t})),o=q.eventDispatcher,r=new Map;q.bindEmitterEvent=!0,o.addEventListener("PARTICLE_DEAD",(e=>{const t=r.get(e.id);if(null!=t){const e=q.childEmitters.findIndex((e=>e.id===t.id));null!=e&&t.stopEmit()}}));let a="PARTICLE_CREATED";if("spawnEvent"in i)switch(i.spawnEvent){case"collision":a="PARTICLE_COLLISION";break;case"start":a="PARTICLE_CREATED"}o.addEventListener(a,(e=>{const t=s.get();t.age=0,t.totalEmitTimes=-1,t.particles.length=0,t.currentEmitTime=0,t.cID=0,t.eventDispatcher.removeAllEventListeners(),q.childEmitters.push(t),r.set(e.id,t),t.parentParticle=e,t.system=q.system,t.emit()}))}return q}const ie=(new o.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 class SpriteNodeShaderMaterial extends c{get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get rotation(){return this.uniforms.rotation.value}set rotation(e){this.uniforms.rotation.value=e}}(new o.SpriteMaterial).rotation;class ne extends t{initialize(e){e.body instanceof o.Object3D&&e.body.traverse((e=>{if(e instanceof o.Mesh){const t=e.material;t instanceof c&&(null!=t.uniforms[L]||null!=t.uniforms[q]||t.uniforms[G])}}))}mutate(e,t,i){this.energize(e,t),e.target instanceof r&&e.target.traverse((t=>{if(t instanceof o.Mesh){const i=t.material;i instanceof c&&(null!=i.uniforms[L]&&(i.uniforms[L].value=this.energy),null!=i.uniforms[q]&&(i.uniforms[q].value=e.age),null!=i.uniforms[G]&&(i.uniforms[G].value=e.velocity))}}))}}class se extends n{constructor(){super(...arguments),this.childEmitters=[],this.bindEmitterEvent=!1,this.onExpired=()=>{}}update(e){if(!this.isEmitting&&0===this.particles.length)return;this.age+=e,(this.dead||this.age>=this.life)&&this.destroy(),this.generate(e),this.integrate(e);let t=this.particles.length;for(;t--;){const e=this.particles[t];e.dead&&(this.system&&this.system.dispatch("PARTICLE_DEAD",e),this.bindEmitterEvent&&this.dispatch("PARTICLE_DEAD",e),this.system.pool.expire(e.reset()),this.particles.splice(t,1))}this.updateEmitterBehaviours(e),this.updateChildren(e),this.isEmitting||0!==this.particles.length||this.onExpired()}updateChildren(e){for(const t of this.childEmitters)null!=t.parentParticle?t.position.copy(t.parentParticle.position):t.setPosition(this.position),t.update(e)}clone(){const e=new se;return e.setRate(this.rate.clone()),e.behaviours=this.behaviours,e.initializers=this.initializers,e._space=this._space,e.body=this.body,e.parent=this.parent,e.system=this.system,e}setParentRecursive(e){this.system=e,this.childEmitters.forEach((t=>t.setParentRecursive(e)))}}export class EmitterPool{constructor(e){this.creator=e,this.instances=[]}get(){0==this.instances.length&&this.instances.push(this.creator());return this.instances.pop()}release(e){this.instances.push(e)}dispose(){this.instances.length=0}}/*
1
+ import e,{Behaviour as t,Body as i,Emitter as n,Rate as s}from"@hology/nebula";import*as o from"three";import{Object3D as r}from"three";import{AttributeVec3Node as a,AttributeVec4Node as l,NodeShaderMaterial as c,RgbNode as m,UniformFloatNode as p,UniformVec3Node as u,Vec3ExpressionNode as h,Vec4Node as d,attributeFloat as f,attributeVec3 as y,attributeVec4 as g,attributes as w,float as v,glslFunction as A,lambertMaterial as x,log as E,pow as b,rgb as M,rgba as P,saturate as I,standardMaterial as S,textureSampler2d as T,transformed as R,uniformFloat as C,uniforms as B,varying as j,varyingAttributes as k,varyingVec3 as z,varyingVec4 as V}from"three-shader-graph";import{prepareShapeParameters as D}from"../../scene/materializer.js";import{SerializedParamType as F}from"../../scene/model.js";import{ShapeLibrary as Q}from"../../scene/objects/shapes.js";import{fragmentLinearEyeDepth as U,linearEyeDepth as W}from"../../shader-nodes/depth.js";import{particleEnergyUniformName as L,particleTimeUniformName as q,particleUniforms as H,particleVelcoityUniformName as G}from"../../shader-nodes/particle.js";import{sampleFlipbook as J}from"../../shader-nodes/texture-sequence.js";import{DefaultInitializer as N}from"./initializsers.js";import{DelayRate as O,OnceRate as K}from"./rates.js";import{StretchedSprite as X}from"./stretched-sprite.js";import{ThreeBlendingMode as Y}from"./vfx-asset.js";import{VfxBehaviourLibrary as Z,VfxInitializserLibrary as _}from"./vfx-defs.js";import{MultiRenderer as $}from"./vfx-renderers.js";import{WorldCollisionBehaviour as ee}from"./vfx-collision-behaviour.js";export async function materializeVfx(t,i,n,s,a){let l=i;for(;null!=l.parent;)l=l.parent;const c=new r;c.name="particle system local",i.add(c);const m=new r;m.name="particle system world",l.add(m);const p=new $(m,c,o,s),u=new e;return(await Promise.all(t.vfx.emitters.map((async e=>{const t=await te(e,n,u,a);return t.setParentRecursive(u),t.emit()})))).forEach((e=>u.addEmitter(e))),u.addRenderer(p).emit({onEnd:()=>{}}),{container:m,system:u,dispose:()=>{m.removeFromParent(),c.removeFromParent(),p.dispose()}}}async function te(e,t,n,m){const z=function(e){let t;switch(e.rate.type){case"continuous":t=new O(e.rate.delay??0,e.rate.count,e.rate.time);break;case"once":t=new K(e.rate.delay??0,e.rate.count);break;default:console.warn(`Failed to configure rate for emitter: ${JSON.stringify(e)}`),t=new s(0,1/0)}return t}(e);let L;switch(e.output.type){case"sprite":L=new i(await async function(e,t){const i=null!=e.texture?await t.getTexture(e.texture):ie,n=T(i);let s=n.sample(k.uv);e.flipbook?.enabled&&(s=J(n,w.uv,e.flipbook.columns,e.flipbook.rows,H.time,e.flipbook.fps,e.flipbook.mode));const r=new p("rotation",0),a=new u("color").rgb,l=C("opacity",1),c=W.subtract(U).divide(W);let m=s.x.multiply(l);if("number"==typeof e.softness&&e.softness>0){const t=b(c,v(e.softness));m=m.multiply(t)}const h=A(d,{position:R.position,modelViewMatrix:B.modelViewMatrix,rotation:r},"\n vec2 center = vec2(0.5, 0.5);\n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n // Using scale form instance matrix instead of modelMatrix\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n // This times 2 on scale seem to make it appear like when using regular sprites. \n // Not sure if this is correct though.\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * (scale);\n\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return projectionMatrix * mvPosition;\n ");var f=new SpriteNodeShaderMaterial({color:P(a,m).multiply(s),transparent:!0,position:h,uniforms:{color:{value:new o.Color(e.color)}}});f.blending=Y[e.blendingMode]??o.NormalBlending;const y=new o.Mesh(new o.PlaneGeometry(1,1),f);return y.name="sprite",y}(e.output,t));break;case"stretchedSprite":L=new i(await async function(e,t){const i=null!=e.texture?await t.getTexture(e.texture):ie,n=T(i).sample(k.uv),s=V(new l("color")),r=s.rgb;let a=s.w;if("number"==typeof e.softness&&e.softness>0){const t=W.subtract(U).divide(E(W)),i=b(t,v(e.softness));a=I(a.multiply(i))}const c=A(d,{position:w.position,offset:y("offset"),modelViewMatrix:B.modelViewMatrix,velocity:g("velocity"),size:y("size"),rotation:f("rotation")},"\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n\n vec4 mvPosition = modelViewMatrix * vec4( offset , 1.0 );\n vec3 viewVelocity = normalMatrix * velocity.xyz;\n float vlength = length(viewVelocity); \n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, viewVelocity)) * avgSize; \n mvPosition.xyz -= (position.x + 0.5) * viewVelocity * (1.0 + lengthFactor / vlength) * avgSize;\n return projectionMatrix * mvPosition;\n ");var m=new SpriteNodeShaderMaterial({color:P(r,a).multiply(n),transparent:!0,position:c,uniforms:{color:{value:new o.Color(e.color)}}});m.blending=Y[e.blendingMode]??o.NormalBlending;const p=new X(new o.PlaneGeometry(1,1),m);return p.scaleFactor=e.scale,p}(e.output,t));break;case"shape":L=new i(await async function(e,t){if(null==e.shape)return console.log("Shape is null"),new r;const i=Q[e.shape];if(null==i)return console.error(`No shape with type ${e.shape}`),new r;const n=D(e.params??{}),s=i.geometry(n),l=null!=e.material?function(e){const t=j(new h("instanceColor")).rgb;let i,n=j(new a("particleData")).x;if(e instanceof o.MeshStandardMaterial||e instanceof o.MeshLambertMaterial||e instanceof o.MeshBasicMaterial){let s=t.multiply(M(e.color));null!=e.map&&(s=s.multiply(T(e.map).sample(k.uv).rgb)),null!=e.alphaMap&&(n=n.multiply(T(e.alphaMap).sample(k.uv).r)),e instanceof o.MeshStandardMaterial?i=new c({color:S({color:s,emissive:M(e.emissive),emissiveIntensity:v(e.emissiveIntensity),roughness:e.roughness,metalness:e.metalness}).rgb.rgba(n),transparent:e.transparent,alphaTest:e.alphaTest}):e instanceof o.MeshLambertMaterial?i=new c({color:x({color:s}).rgb.rgba(n),transparent:e.transparent,alphaTest:e.alphaTest}):e instanceof o.MeshBasicMaterial&&(i=new c({color:s.rgb.rgba(n),transparent:e.transparent,alphaTest:e.alphaTest}))}null!=i&&(!0===e.userData?.hasBloom&&null!=i&&(i.userData.hasBloom=!0),i.side=e.side,i.transparent=e.transparent);return i??e}(await t.getMaterial(e.material)):function(){const e=j(new h("instanceColor")).rgb,t=j(new a("particleData")).x;return new c({color:x({color:e}).rgb.rgba(t),transparent:!0})}();return new o.Mesh(s,l)}(e.output,t));break;case"mesh":L=new i(await async function(e,t){if(null==e.assetId)return console.warn("Can't use mesh as particle without asset id"),new r;const i=await t.getMesh(e.assetId),n=await t.getAsset(e.assetId),s=[];if(null!=n.materialAssignments)for(const e of n.materialAssignments)i.traverse((i=>{i instanceof o.Mesh&&i.material instanceof o.Material&&i.material.color instanceof o.Color&&(i.material.name!=e.name&&null!=e.name||"#"+i.material.color.getHexString()!==e.color||s.push(t.getMaterial(e.materialId).then((e=>i.material=e))))}));await Promise.all(s);const a=[];if(i.traverse((e=>{e instanceof o.Mesh&&a.push(e)})),1===a.length){const e=a[0];return e.updateWorldMatrix(!0,!0),e.updateMatrixWorld(),e.matrix.copy(e.matrixWorld),e.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.removeFromParent(),e}return i}(e.output,t));break;case"trail":L=new i({type:"trail",taper:e.output.taper,headGeometry:null,dragTexture:!1,color:e.output.color,colorEnd:e.output.colorEnd,length:e.output.length,opacityStart:e.output.opacityStart,opacityEnd:e.output.opacityEnd,bloom:e.output.bloom});break;default:console.error("Failed to create particly system body: "+JSON.stringify(e))}const q=new se;q.parent=n,q.setRate(z),q._space=e.output.space;const G=await Promise.all(e.initializers.filter((e=>null!=_[e.type])).map((async e=>{const t=_[e.type],i=await D(e.params??{});return t.build(i)})));G.push(L,new N),q.addInitializers(G);const $=await Promise.all(e.behaviours.filter((e=>null!=Z[e.type])).map((async e=>{const t=Z[e.type];for(const[i,n]of Object.entries(e.params))t.parameters&&null!=t.parameters[i]&&"curve"===t.parameters[i].type&&n.type!==F.Curve&&(n.type=F.Curve);const i=await D(e.params??{});return t.build(i)})).sort(((e,t)=>e instanceof ee?1:0)));$.push(new ne);for(const e of $)e instanceof ee&&(e.physics=m);q.addBehaviours($);for(const i of e.children){const e=await te(i,t,n,m),s=new EmitterPool((()=>{const t=e.clone();return t.onExpired=()=>{const e=q.childEmitters.findIndex((e=>e.id===t.id));-1!=e&&q.childEmitters.splice(e,1),s.release(t)},t})),o=q.eventDispatcher,r=new Map;q.bindEmitterEvent=!0,o.addEventListener("PARTICLE_DEAD",(e=>{const t=r.get(e.id);if(null!=t){const e=q.childEmitters.findIndex((e=>e.id===t.id));null!=e&&t.stopEmit()}}));let a="PARTICLE_CREATED";if("spawnEvent"in i)switch(i.spawnEvent){case"collision":a="PARTICLE_COLLISION";break;case"start":a="PARTICLE_CREATED"}o.addEventListener(a,(e=>{const t=s.get();t.age=0,t.totalEmitTimes=-1,t.particles.length=0,t.currentEmitTime=0,t.cID=0,t.eventDispatcher.removeAllEventListeners(),q.childEmitters.push(t),r.set(e.id,t),t.parentParticle=e,t.system=q.system,t.emit()}))}return q}const ie=(new o.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 class SpriteNodeShaderMaterial extends c{get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get rotation(){return this.uniforms.rotation.value}set rotation(e){this.uniforms.rotation.value=e}}(new o.SpriteMaterial).rotation;class ne extends t{initialize(e){e.body instanceof o.Object3D&&e.body.traverse((e=>{if(e instanceof o.Mesh){const t=e.material;t instanceof c&&(null!=t.uniforms[L]||null!=t.uniforms[q]||t.uniforms[G])}}))}mutate(e,t,i){this.energize(e,t),e.target instanceof r&&e.target.traverse((t=>{if(t instanceof o.Mesh){const i=t.material;i instanceof c&&(null!=i.uniforms[L]&&(i.uniforms[L].value=this.energy),null!=i.uniforms[q]&&(i.uniforms[q].value=e.age),null!=i.uniforms[G]&&(i.uniforms[G].value=e.velocity))}}))}}class se extends n{constructor(){super(...arguments),this.childEmitters=[],this.bindEmitterEvent=!1,this.onExpired=()=>{}}update(e){if(!this.isEmitting&&0===this.particles.length)return;this.age+=e,(this.dead||this.age>=this.life)&&this.destroy(),this.generate(e),this.integrate(e);let t=this.particles.length;for(;t--;){const e=this.particles[t];e.dead&&(this.system&&this.system.dispatch("PARTICLE_DEAD",e),this.bindEmitterEvent&&this.dispatch("PARTICLE_DEAD",e),this.system.pool.expire(e.reset()),this.particles.splice(t,1))}this.updateEmitterBehaviours(e),this.updateChildren(e),this.isEmitting||0!==this.particles.length||this.onExpired()}updateChildren(e){for(const t of this.childEmitters)null!=t.parentParticle?t.position.copy(t.parentParticle.position):t.setPosition(this.position),t.update(e)}clone(){const e=new se;return e.setRate(this.rate.clone()),e.behaviours=this.behaviours,e.initializers=this.initializers,e._space=this._space,e.body=this.body,e.parent=this.parent,e.system=this.system,e}setParentRecursive(e){this.system=e,this.childEmitters.forEach((t=>t.setParentRecursive(e)))}}export class EmitterPool{constructor(e){this.creator=e,this.instances=[]}get(){0==this.instances.length&&this.instances.push(this.creator());return this.instances.pop()}release(e){this.instances.push(e)}dispose(){this.instances.length=0}}/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -55,6 +55,7 @@ export declare class StretchedSpriteInstancedRenderer extends MeshRenderer {
55
55
  constructor(container: THREE.Object3D, three: typeof THREE, view: ViewController);
56
56
  dispose(): void;
57
57
  onSystemUpdate(): void;
58
+ private calcMaxCount;
58
59
  private meshes;
59
60
  onParticleCreated(particle: Particle & {
60
61
  body?: MeshRenderer['_body'];
@@ -1 +1 @@
1
- {"version":3,"file":"vfx-renderers.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/vfx-renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAQ,QAAQ,EAA4B,MAAM,gBAAgB,CAAA;AACvG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAA4B,QAAQ,EAAE,MAAM,OAAO,CAAA;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAS/C,qBAAa,aAAc,SAAQ,cAAc;IAInC,OAAO,CAAC,cAAc;IAAY,OAAO,CAAC,cAA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QAAC,MAAM,EAAE,GAAG,CAAA;KAAC;IAmFlF,gBAAgB,CAAC,QAAQ,KAAA;IAIzB,cAAc,CAAC,QAAQ,KAAA;CAcxB;AAOD,KAAK,iBAAiB,GAAG;IAAC,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,QAAQ,EAAE,CAAA;CAAC,CAAA;AAEpI,qBAAa,iBAAkB,SAAQ,YAAY;IAEW,OAAO,CAAC,IAAI;gBAA5D,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,KAAK,EAAU,IAAI,EAAE,cAAc;IAGxF,OAAO;IAIP,cAAc;IAUd,OAAO,CAAC,MAAM,CAA0B;IAExC,OAAO,CAAC,YAAY;IAWpB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAAC,IAAI,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAC;IAsElF,gBAAgB,CAAC,QAAQ,KAAA;IAuCzB,cAAc,CAAC,QAAQ,KAAA;CAiBxB;AA+CD;;;;;GAKG;AACH,iBAAS,2BAA2B,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAqExF;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
@@ -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 s,Object3D as i}from"three";import{NodeShaderMaterial as n}from"three-shader-graph";import{SpriteNodeShaderMaterial as o}from"../../effects/vfx/vfx-materializer";import{StretchedSprite as l}from"./stretched-sprite.js";import{Trail as c}from"./trail-renderer.js";var d;!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"}(d||(d={}));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){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,s="world"===t?this.worldRenderers:this.localRenderers;return"trail"===e.body.type?(null==s[d.trail]&&(s[d.trail]=new TrailRenderer(r,this.three)),e._renderer=s[d.trail]):e.body instanceof l?(null==s[d.stretchedBillboard]&&(s[d.stretchedBillboard]=new StretchedSpriteInstancedRenderer(r,this.three,this.view)),e._renderer=s[d.stretchedBillboard]):e.body instanceof a.Sprite||e.body instanceof a.Mesh&&"sprite"===e.body.name?(null==s[d.sprite]&&(s[d.sprite]=new CombinedRenderer(r,this.three)),e._renderer=s[d.sprite]):e.body instanceof a.Mesh&&0==e.body.children.length&&e.body.material instanceof n?(null==s[d.instanced]&&(s[d.instanced]=new InstancedRenderer(r,this.three,this.view)),e._renderer=s[d.instanced]):e.body instanceof a.Object3D?(null==s[d.mesh]&&(s[d.mesh]=new CombinedRenderer(r,this.three)),e._renderer=s[d.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 c(this.container,!0),s=new i,n=c.createBaseMaterial();n.uniforms.taper.value=t.taper??!1;const o=new a.Color(t.color??0),l=new a.Color(t.colorEnd??0);n.uniforms.headColor.value.set(o.r,o.g,o.b,t.opacityStart??1),n.uniforms.tailColor.value.set(l.r,l.g,l.b,t.opacityEnd??1),t.bloom&&(n.userData.hasBloom=!0),r.initialize(n,Math.round(t.length??10),!1,0,null,s);const d=e.rotation;s.rotation.set(d.x,d.y,d.z);e.scale;r.activate(),this.trails.push(r),e.target=s}onParticleUpdate(e){const t=e.target;t.position.copy(e.position);e.velocity.clone().normalize();const r=this.trails.findIndex((e=>e.targetObject.id===t.id));if(-1!=r){const t=this.trails[r];if(e.useAlpha){t.material.uniforms.headColor.value.setW(e.alpha);t.material.uniforms.tailColor.value.setW(e.alpha)}}}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(),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 i&&(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:s,rotation:n}=e;if(t){if(t.position.copy(e.position),this.isThreeSprite(e)||(t instanceof a.Mesh&&t.material instanceof o?e.target.material.rotation=e.rotation.z:t.rotation.set(n.x,n.y,n.z)),this.scale(e),e.transform&&e.transform.orientAlongVelocity&&t instanceof i){const r=m.set(e.velocity.x,e.velocity.y,e.velocity.z).normalize(),a=t.getWorldDirection(h);a.applyAxisAngle(p,Math.PI/-2),u.setFromUnitVectors(a,r),t.quaternion.copy(u)}t.material instanceof a.Material&&(r&&(t.material instanceof o&&null!=t.material.uniforms.opacity&&(t.material.uniforms.opacity.value=e.alpha,t.material.uniformsNeedUpdate=!0),t.material.opacity=e.alpha,t.material.transparent=!0),s&&(null!=t.material.color?t.material.color.copy(e.color):t.material instanceof a.ShaderMaterial&&null!=t.material.uniforms.color&&(t.material.uniforms.color.value=e.color,t.material.uniformsNeedUpdate=!0)))}}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"),s=e.mesh.geometry.getAttribute("velocity"),i=e.mesh.geometry.getAttribute("rotation"),n=e.mesh.geometry.getAttribute("color");let o=0;for(const l of e.particles){if(null==l||l.dead)continue;if(l.useColor||l.color instanceof a.Color){const e=U.copy(l.color).getRGB(M);n.setXYZW(o,e.r,e.g,e.b,1),n.needsUpdate=!0}l.useAlpha&&(n.setW(o,l.alpha),n.needsUpdate=!0),"number"==typeof l.rotation?i.setX(o,l.rotation):i.setX(o,l.rotation.x);const e=l.position;if(t.setXYZ(o,e.x,e.y,e.z),"number"!=typeof l.scale)throw new Error("Particle scale is not a number");r.setXYZ(o,l.scale,l.scale,l.scale);let c=l.body.scaleFactor;0===c&&(c=.001);const d=1,m=l.velocity;s.setXYZW(o,m.x*c,m.y*c,m.z*c,d),o++}o>0&&(t.clearUpdateRanges(),t.addUpdateRange(0,3*o),t.needsUpdate=!0,r.clearUpdateRanges(),r.addUpdateRange(0,3*o),r.needsUpdate=!0,n.clearUpdateRanges(),n.addUpdateRange(0,4*o),n.needsUpdate=!0,s.clearUpdateRanges(),s.addUpdateRange(0,4*o),s.needsUpdate=!0,i.clearUpdateRanges(),i.addUpdateRange(0,o),i.needsUpdate=!0)}}onParticleCreated(e){if(e.body instanceof l&&null==e.target){const t=e.body;let r=this.meshes.find((e=>e.mesh.material.uuid===t.material.uuid));if(null==r){const i=P(e),n=new a.InstancedBufferGeometry;n.setIndex(t.geometry.getIndex()),n.setAttribute("position",t.geometry.getAttribute("position")),t.geometry.hasAttribute("normal")&&n.setAttribute("normal",t.geometry.getAttribute("normal")),n.setAttribute("uv",t.geometry.getAttribute("uv"));const o=new s(new Float32Array(3*i),3);o.setUsage(a.DynamicDrawUsage),n.setAttribute("offset",o);const l=new s(new Float32Array(4*i),4);l.setUsage(a.DynamicDrawUsage),n.setAttribute("color",l);const c=new s(new Float32Array(3*i),3);c.setUsage(a.DynamicDrawUsage),n.setAttribute("size",c);const d=new s(new Float32Array(4*i),4);d.setUsage(a.DynamicDrawUsage),n.setAttribute("velocity",d);const m=new s(new Float32Array(4*i),1);m.setUsage(a.DynamicDrawUsage),n.setAttribute("rotation",m),r={mesh:new a.Mesh(n,t.material),indices:new Float32Array(i),particles:[]},this.meshes.push(r),this.container.add(r.mesh)}let i=r.indices.findIndex((e=>0===e));i<0&&(i=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[i]=performance.now(),e.target=i,r.particles[i]=e}}onParticleUpdate(e){}onParticleDead(e){const t=e.body;let r=this.meshes.find((e=>e.mesh.material.uuid===t.material.uuid));r&&(r.particles[e.target]=null,r.indices[e.target]=0),e.target=null}}const m=new a.Vector3,h=new a.Vector3,u=new a.Quaternion,p=new a.Vector3(1,0,0);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);}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate;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 a.Sprite)){if(null==e.target){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 s=this.calcMaxCount(e);r={mesh:new a.InstancedMesh(t.geometry,t.material,s),indices:new Array(s).fill(null),particles:[]},r.mesh.setColorAt(0,U.setScalar(1)),r.mesh.instanceColor.needsUpdate=!0,r.mesh.material.defines.USE_INSTANCING="";const i=new Float32Array(3*s);y.makeScale(0,0,0);for(let e=0;e<s;e++)i[3*e+0]=1,i[3*e+1]=1,r.mesh.setMatrixAt(e,y);r.mesh.instanceMatrix.needsUpdate=!0,r.mesh.geometry.setAttribute("particleData",new a.InstancedBufferAttribute(i,3)),this.meshes.push(r),this.container.add(r.mesh)}let s=r.indices.findIndex((e=>null==e));s<0&&(s=r.indices.indexOf(Math.min(...r.indices))),r.indices[s]=performance.now(),e.target=s,r.particles[s]=e}if("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));f(e,r.mesh),e.useAlpha&&(r.mesh.material.transparent=!0)}}}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:a,rotation:s}=e;if(null==t)return;const i=e.body;let n=this.meshes.find((e=>e.mesh.geometry.uuid===i.geometry.uuid&&e.mesh.material.uuid===i.material.uuid));f(e,n.mesh),a&&(n.mesh.setColorAt(e.target,U.copy(e.color)),n.mesh.instanceColor.needsUpdate=!0);const o=n.mesh.geometry.getAttribute("particleData");r&&o.setX(e.target,e.alpha),o.setY(e.target,e.energy),o.needsUpdate=!0}onParticleDead(e){if(null!=e.target){const t=e.body;let r=this.meshes.find((e=>e.mesh.geometry.uuid===t.geometry.uuid&&e.mesh.material.uuid===t.material.uuid));r.indices[e.target]=null,e.scale=0,f(e,r.mesh),r.mesh.instanceMatrix.needsUpdate=!0,e.target=null}}}const g=new i;function f(e,t){if(w.set(e.position.x,e.position.y,e.position.z),e.transform&&e.transform.orientAlongVelocity){const r=m.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,g.matrix);const a=g.getWorldDirection(x);a.applyAxisAngle(p,Math.PI/-2),b.setFromUnitVectors(a,r)}else A.set(e.rotation.x,e.rotation.y,e.rotation.z),b.setFromEuler(A);const r=e.transform.initialScale;null!=r?x.set(r.x*e.scale,r.y*e.scale,r.z*e.scale):x.set(e.scale,e.scale,e.scale),y.compose(w,b,x),t.setMatrixAt(e.target,y),t.instanceMatrix.needsUpdate=!0}const y=new a.Matrix4,b=new a.Quaternion,w=new a.Vector3,x=new a.Vector3,A=new a.Euler,U=new a.Color(0),M={r:0,g:0,b:0};function C(e,t){const r=e.mesh,s=r.count,i=[],n=r.geometry.getAttribute("particleData"),o=new a.Vector3;for(let l=0;l<s;l++){const s=new a.Matrix4,c=new a.Color;r.getMatrixAt(l,s),r.getColorAt(l,c);const d=n.getX(l);o.setFromMatrixPosition(s);const m=o.distanceTo(t.position);i.push({index:l,distance:m,matrix:s,particle:e.particles[l],color:c,pdx:d})}i.sort(((e,t)=>t.distance-e.distance));for(let e=0;e<s;e++){const t=i[e].matrix;null==i[e].particle&&t.makeScale(0,0,0),r.setMatrixAt(e,t),r.setColorAt(e,i[e].color),n.setX(e,i[e].pdx)}r.instanceMatrix.needsUpdate=!0}export{C as sortInstancedMeshByDistance};function P(e){const t=null!=e.parent.parentParticle?P(e.parent.parentParticle):1,r=e.parent.rate;return Math.min(Math.ceil(r.numPan.b/Math.min(Math.max(r.timePan.a,.01),1)),1e5)*e.life*t}/*
1
+ import{CustomRenderer as e,MeshRenderer as t,PUID as r}from"@hology/nebula";import*as a from"three";import{InstancedBufferAttribute as s,Object3D as i}from"three";import{NodeShaderMaterial as n}from"three-shader-graph";import{SpriteNodeShaderMaterial as o}from"../../effects/vfx/vfx-materializer";import{StretchedSprite as l}from"./stretched-sprite.js";import{Trail as c}from"./trail-renderer.js";var d;!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"}(d||(d={}));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){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,s="world"===t?this.worldRenderers:this.localRenderers;return"trail"===e.body.type?(null==s[d.trail]&&(s[d.trail]=new TrailRenderer(r,this.three)),e._renderer=s[d.trail]):e.body instanceof l?(null==s[d.stretchedBillboard]&&(s[d.stretchedBillboard]=new StretchedSpriteInstancedRenderer(r,this.three,this.view)),e._renderer=s[d.stretchedBillboard]):e.body instanceof a.Sprite||e.body instanceof a.Mesh&&"sprite"===e.body.name?(null==s[d.sprite]&&(s[d.sprite]=new CombinedRenderer(r,this.three)),e._renderer=s[d.sprite]):e.body instanceof a.Mesh&&0==e.body.children.length&&e.body.material instanceof n?(null==s[d.instanced]&&(s[d.instanced]=new InstancedRenderer(r,this.three,this.view)),e._renderer=s[d.instanced]):e.body instanceof a.Object3D?(null==s[d.mesh]&&(s[d.mesh]=new CombinedRenderer(r,this.three)),e._renderer=s[d.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 c(this.container,!0),s=new i,n=c.createBaseMaterial();n.uniforms.taper.value=t.taper??!1;const o=new a.Color(t.color??0),l=new a.Color(t.colorEnd??0);n.uniforms.headColor.value.set(o.r,o.g,o.b,t.opacityStart??1),n.uniforms.tailColor.value.set(l.r,l.g,l.b,t.opacityEnd??1),t.bloom&&(n.userData.hasBloom=!0),r.initialize(n,Math.round(t.length??10),!1,0,null,s);const d=e.rotation;s.rotation.set(d.x,d.y,d.z);e.scale;r.activate(),this.trails.push(r),e.target=s}onParticleUpdate(e){const t=e.target;t.position.copy(e.position);e.velocity.clone().normalize();const r=this.trails.findIndex((e=>e.targetObject.id===t.id));if(-1!=r){const t=this.trails[r];if(e.useAlpha){t.material.uniforms.headColor.value.setW(e.alpha);t.material.uniforms.tailColor.value.setW(e.alpha)}}}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(),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 i&&(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:s,rotation:n}=e;if(t){if(t.position.copy(e.position),this.isThreeSprite(e)||(t instanceof a.Mesh&&t.material instanceof o?e.target.material.rotation=e.rotation.z:t.rotation.set(n.x,n.y,n.z)),this.scale(e),e.transform&&e.transform.orientAlongVelocity&&t instanceof i){const r=m.set(e.velocity.x,e.velocity.y,e.velocity.z).normalize(),a=t.getWorldDirection(h);a.applyAxisAngle(p,Math.PI/-2),u.setFromUnitVectors(a,r),t.quaternion.copy(u)}t.material instanceof a.Material&&(r&&(t.material instanceof o&&null!=t.material.uniforms.opacity&&(t.material.uniforms.opacity.value=e.alpha,t.material.uniformsNeedUpdate=!0),t.material.opacity=e.alpha,t.material.transparent=!0),s&&(null!=t.material.color?t.material.color.copy(e.color):t.material instanceof a.ShaderMaterial&&null!=t.material.uniforms.color&&(t.material.uniforms.color.value=e.color,t.material.uniformsNeedUpdate=!0)))}}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"),s=e.mesh.geometry.getAttribute("velocity"),i=e.mesh.geometry.getAttribute("rotation"),n=e.mesh.geometry.getAttribute("color");let o=0;for(const l of e.particles){if(null==l||l.dead)continue;if(l.useColor||l.color instanceof a.Color){const e=U.copy(l.color).getRGB(C);n.setXYZW(o,e.r,e.g,e.b,1),n.needsUpdate=!0}l.useAlpha&&(n.setW(o,l.alpha),n.needsUpdate=!0),"number"==typeof l.rotation?i.setX(o,l.rotation):i.setX(o,l.rotation.x);const e=l.position;if(t.setXYZ(o,e.x,e.y,e.z),"number"!=typeof l.scale)throw new Error("Particle scale is not a number");r.setXYZ(o,l.scale,l.scale,l.scale);let c=l.body.scaleFactor;0===c&&(c=.001);const d=1,m=l.velocity;s.setXYZW(o,m.x*c,m.y*c,m.z*c,d),o++}o>0&&(t.clearUpdateRanges(),t.addUpdateRange(0,3*o),t.needsUpdate=!0,r.clearUpdateRanges(),r.addUpdateRange(0,3*o),r.needsUpdate=!0,n.clearUpdateRanges(),n.addUpdateRange(0,4*o),n.needsUpdate=!0,s.clearUpdateRanges(),s.addUpdateRange(0,4*o),s.needsUpdate=!0,i.clearUpdateRanges(),i.addUpdateRange(0,o),i.needsUpdate=!0)}}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate;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 l&&null==e.target){const t=e.body;let r=this.meshes.find((e=>e.mesh.material.uuid===t.material.uuid));if(null==r){const i=this.calcMaxCount(e),n=new a.InstancedBufferGeometry;n.setIndex(t.geometry.getIndex()),n.setAttribute("position",t.geometry.getAttribute("position")),t.geometry.hasAttribute("normal")&&n.setAttribute("normal",t.geometry.getAttribute("normal")),n.setAttribute("uv",t.geometry.getAttribute("uv"));const l=new s(new Float32Array(3*i),3);l.setUsage(a.DynamicDrawUsage),n.setAttribute("offset",l);const c=new s(new Float32Array(4*i),4);if(c.setUsage(a.DynamicDrawUsage),n.setAttribute("color",c),t.material instanceof o){const e=new a.Color(t.material.color);for(let t=0;t<c.count;t++)c.setXYZW(t,e.r,e.g,e.b,1)}const d=new s(new Float32Array(3*i),3);d.setUsage(a.DynamicDrawUsage),n.setAttribute("size",d);const m=new s(new Float32Array(4*i),4);m.setUsage(a.DynamicDrawUsage),n.setAttribute("velocity",m);const h=new s(new Float32Array(4*i),1);h.setUsage(a.DynamicDrawUsage),n.setAttribute("rotation",h),r={mesh:new a.Mesh(n,t.material),indices:new Float32Array(i),particles:[]},this.meshes.push(r),this.container.add(r.mesh)}let i=r.indices.findIndex((e=>0===e));i<0&&(i=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[i]=performance.now(),e.target=i,r.particles[i]=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 m=new a.Vector3,h=new a.Vector3,u=new a.Quaternion,p=new a.Vector3(1,0,0);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);}calcMaxCount(e){if(null==e)return 1;const t=e.parent.rate;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 a.Sprite)){if(null==e.target){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 s=this.calcMaxCount(e);r={mesh:new a.InstancedMesh(t.geometry,t.material,s),indices:new Array(s).fill(null),particles:[]},r.mesh.setColorAt(0,U.setScalar(1)),r.mesh.instanceColor.needsUpdate=!0,r.mesh.material.defines.USE_INSTANCING="";const i=new Float32Array(3*s);y.makeScale(0,0,0);for(let e=0;e<s;e++)i[3*e+0]=1,i[3*e+1]=1,r.mesh.setMatrixAt(e,y);r.mesh.instanceMatrix.needsUpdate=!0,r.mesh.geometry.setAttribute("particleData",new a.InstancedBufferAttribute(i,3)),this.meshes.push(r),this.container.add(r.mesh)}let s=r.indices.findIndex((e=>null==e));s<0&&(s=r.indices.indexOf(Math.min(...r.indices))),r.indices[s]=performance.now(),e.target=s,r.particles[s]=e}if("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));f(e,r.mesh),e.useAlpha&&(r.mesh.material.transparent=!0)}}}onParticleUpdate(e){const{target:t,useAlpha:r,useColor:a,rotation:s}=e;if(null==t)return;const i=e.body,n=this.meshes.find((e=>e.mesh.geometry.uuid===i.geometry.uuid&&e.mesh.material.uuid===i.material.uuid));if(null==n)return;f(e,n.mesh),a&&(n.mesh.setColorAt(e.target,U.copy(e.color)),n.mesh.instanceColor.needsUpdate=!0);const o=n.mesh.geometry.getAttribute("particleData");r&&o.setX(e.target,e.alpha),o.setY(e.target,e.energy),o.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;r.indices[e.target]=null,e.scale=0,f(e,r.mesh),r.mesh.instanceMatrix.needsUpdate=!0,e.target=null}}}const g=new i;function f(e,t){if(w.set(e.position.x,e.position.y,e.position.z),e.transform&&e.transform.orientAlongVelocity){const r=m.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,g.matrix);const a=g.getWorldDirection(x);a.applyAxisAngle(p,Math.PI/-2),b.setFromUnitVectors(a,r)}else A.set(e.rotation.x,e.rotation.y,e.rotation.z),b.setFromEuler(A);const r=e.transform.initialScale;null!=r?x.set(r.x*e.scale,r.y*e.scale,r.z*e.scale):x.set(e.scale,e.scale,e.scale),y.compose(w,b,x),t.setMatrixAt(e.target,y),t.instanceMatrix.needsUpdate=!0}const y=new a.Matrix4,b=new a.Quaternion,w=new a.Vector3,x=new a.Vector3,A=new a.Euler,U=new a.Color(0),C={r:0,g:0,b:0};function M(e,t){const r=e.mesh,s=r.count,i=[],n=r.geometry.getAttribute("particleData"),o=new a.Vector3;for(let l=0;l<s;l++){const s=new a.Matrix4,c=new a.Color;r.getMatrixAt(l,s),r.getColorAt(l,c);const d=n.getX(l);o.setFromMatrixPosition(s);const m=o.distanceTo(t.position);i.push({index:l,distance:m,matrix:s,particle:e.particles[l],color:c,pdx:d})}i.sort(((e,t)=>t.distance-e.distance));for(let e=0;e<s;e++){const t=i[e].matrix;null==i[e].particle&&t.makeScale(0,0,0),r.setMatrixAt(e,t),r.setColorAt(e,i[e].color),n.setX(e,i[e].pdx)}r.instanceMatrix.needsUpdate=!0}export{M as sortInstancedMeshByDistance};/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"navmesh-actor.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/builtin/navmesh-actor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAuG,KAAK,EAAC,MAAM,OAAO,CAAC;AAElI,OAAO,EAAS,SAAS,EAAmE,MAAM,QAAQ,CAAC;AAI3G,OAAO,EAAY,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAW5D,wBAAsB,cAAc,4BASnC;AASD,MAAM,MAAM,aAAa,GAAG;IAO1B,IAAI,QAAE;CACP,CAAA;AAED,qBACa,iBAAkB,SAAQ,cAAc;IAEtC,KAAK,EAAE,KAAK,CAAsB;IAE/C,OAAO,CAAC,UAAU,CAA8B;IAEhD,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAY/B;AAGD,cACM,YAAa,SAAQ,SAAS;IAClC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,mBAAmB,CAA4B;IAE1C,KAAK,EAAE,OAAO,CAAO;IAElC,SAAS,EAAE,MAAM,CAAO;IAIxB,OAAO,CA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IAG/C,OAAO,EAAE,OAAO,CAAA;IACvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,gBAAgB,CAAgB;IAGlC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA6B7B,SAAS,IAAI,IAAI;IAIjB,OAAO,CAAC,IAAI;CAyPb;AAED,eAAe,YAAY,CAAA"}
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as o,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as c,ShapeType as l,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as d,getPositionsAndIndices as u}from"@recast-navigation/three";import{BehaviorSubject as m,debounceTime as f,filter as w,firstValueFrom as g,Subject as b,takeUntil as y}from"rxjs";import*as x from"three";import{Mesh as v,EdgesGeometry as B,LineSegments as M,LineBasicMaterial as S,Vector3 as z,BoxGeometry as A,MeshBasicMaterial as C,Group as j,Color as k}from"three";import{BufferGeometryUtils as I,ConvexHull as F}from"three/examples/jsm/Addons.js";import{Actor as P,BaseActor as V,Parameter as G,PhysicsSystem as N,ViewController as D,World as E,attach as H,inject as R}from"../../";import{DynamicTiledNavMesh as T}from"../../ai/dynamic-tiled-navmesh";import{hasSharedArrayBufferSupport as U,toSharedFloat32Array as q,toSharedUint32Array as O}from"../../../utils/buffer";import{sleepDelay as _}from"../../../utils/async";import{Component as W,ActorComponent as X}from"../../../gameplay";var L;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(L||(L={}));let $=L.none,J=new m(!1);export async function safeRecastInit(){return $===L.none?($=L.starting,p().then((()=>{J.next(!0),$=L.started}))):g(J.pipe(w((e=>e))))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const K=navigator.hardwareConcurrency??1;let Q=class extends X{constructor(){super(...arguments),this.color=new k(16777215),this.dimensions=new z(1,1,1)}onInit(){const e=new A(this.dimensions.x,this.dimensions.y,this.dimensions.z),t=new B(e),n=new M(t,new S({color:this.color})),o=(new v(e,new C({color:this.color,transparent:!0,opacity:.3,visible:!1})),new j);o.add(n),this.actor.object.add(o)}};e([G(),t("design:type",k)],Q.prototype,"color",void 0),Q=e([W({inEditor:!0,editorOnly:!0})],Q);export{Q as TriggerVolumeMesh};let Y=!1,Z=class extends V{constructor(){super(...arguments),this.physics=R(N),this.view=R(D),this.world=R(E),this.editorVisualisation=H(Q),this.debug=!0,this.refreshMs=4e3,this.tileSize=400,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){Y||(await safeRecastInit(),Y=!0),setTimeout((()=>{this.init()}),10),this.recreateInterval=setInterval((()=>{if("_hology_transform_group"===this.object.parent?.name)return;oe.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new b,this.init())}),1e3)}onEndPlay(){clearInterval(this.recreateInterval)}init(){const e=Math.max(this.cellSize,.01),t={tileSize:400,walkableClimb:this.walkableClimb/e,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:5,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:e,ch:e,maxSimplificationError:1.3,maxEdgeLen:200};this.bounds.setFromCenterAndSize(this.position,this.object.scale);const n=new T({navMeshBounds:this.bounds,recastConfig:t,maxTiles:1024,workers:K,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=n.navMesh;const o=this.tileSize*t.cs*2,s=performance.now(),i=new Map,r=new d;r.userData.isDebugDrawer=!0;n.navMesh;const a=this.bounds,c=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(o),(new x.Vector3).copy(e).addScalar(o)),n=[],s=this.physics.world.bodies;if(null==s)return[];const r=new x.Box3;for(const e of s.getAll())for(let o=0,s=e.numColliders();o<s;o++){const s=e.collider(o);if(s.isSensor()||null!=s.parent().userData&&!0===s.parent().userData.ignoreForNavMesh)continue;const a=e.handle+","+o,c=i.get(a)?.mesh,l=c??te(s);if(ne(s,l),null!=l){r.copy(l.geometry.boundingBox),r.min.add(l.position),r.max.add(l.position);const e=r.intersectsBox(t)||!0,o=r.intersectsBox(this.bounds);i.set(a,{pos:s.translation(),mesh:l}),e&&o&&n.push(l)}}return n},l=new x.Box3,h=new Map,p=new Map;let m=!0,w=performance.now(),g=!1;const b=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await _(t)})(),()=>{n=!0}}((async()=>{if(g)return;const e=new x.Box3,t=c();for(const n of t){const t=h.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),h.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const o=n.getTilesForBounds(e);if(0!=o.length){const s=[];for(const n of t)l.setFromObject(n),l.intersectsBox(e)&&s.push(n);console.log("intersecting meshes",s.length);let[i,r]=u(s);r=function(e,t,n){const o=new x.Vector3,s=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let s=0;s<3;s++){const a=3*t[i+s];if(o.fromArray(e,a),!n.containsPoint(o)){r=!1;break}}r&&s.push(t[i],t[i+1],t[i+2])}return new Uint32Array(s)}(i,r,a),U&&(i=q(i),r=O(r));const c=m;m=!1,await Promise.all(o.map((e=>(w=performance.now(),n.buildTile(i,r,e,c).then((()=>{const t=e[0]+","+e[1];p.set(t,(p.get(t)??0)+1),this.debug})))))).then((()=>{this.debug,g=!1}))}else g=!1}),this.refreshMs??1e4);this.disposed.subscribe((()=>b())),n.onNavMeshUpdate.pipe(y(this.disposed),f(200)).subscribe((()=>{r.clear(),r.drawNavMesh(n.navMesh)})),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(r)),this.disposed.subscribe((()=>{n?.destroy(),r.removeFromParent(),r.dispose()}));const v=performance.now()-s;v>1e3&&console.warn(`NavMesh update took ${v} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([G(),t("design:type",Boolean)],Z.prototype,"debug",void 0),e([G(),t("design:type",Number)],Z.prototype,"walkableClimb",void 0),e([G({range:[0,89]}),t("design:type",Number)],Z.prototype,"walkableSlopeAngle",void 0),e([G({range:[.01,10]}),t("design:type",Number)],Z.prototype,"cellSize",void 0),Z=e([P()],Z);export default Z;function ee(e){if(e.shape instanceof c)return function(e){const t=e.shape;if(t.type!==l.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const o=t,s=o.heights,i=o.nrows,r=o.ncols,a=o.scale.x,c=o.scale.z,h=o.scale.y,p=i+1,d=new x.PlaneGeometry(c,a,r,i);d.rotateX(-Math.PI/2);const u=d.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)u[m+1]=s[t*p+e]*h,m+=3,0!=u[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,c,2,2);return e.rotateX(-Math.PI/2),e}return d}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i)return function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new F).setFromPoints(t),o=[];n.faces.forEach((e=>{const t=e.edge.head().point,n=e.edge.next.head().point,s=e.edge.next.next.head().point;o.push(t.x,t.y,t.z),o.push(n.x,n.y,n.z),o.push(s.x,s.y,s.z)}));const s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(o,3)),s}(e.shape.vertices);if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?o.setIndex(new x.Uint16BufferAttribute(n,1)):o=I.mergeVertices(o),o.computeVertexNormals(),o}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function te(e){const t=ee(e);if(null==t)return null;const n=se,o=new x.Mesh(t,n);return o.geometry.computeBoundingBox(),o.geometry.scale(1.01,1.01,1.01),o}function ne(e,t){const n=e.translation(),o=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(o.x,o.y,o.z,o.w)}const oe=new x.Box3,se=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as o,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as c,ShapeType as l,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as d,getPositionsAndIndices as u}from"@recast-navigation/three";import{BehaviorSubject as m,debounceTime as f,filter as w,firstValueFrom as b,Subject as g,takeUntil as y}from"rxjs";import*as x from"three";import{Mesh as v,EdgesGeometry as B,LineSegments as M,LineBasicMaterial as S,Vector3 as z,BoxGeometry as A,MeshBasicMaterial as C,Group as j,Color as k}from"three";import{BufferGeometryUtils as I,ConvexHull as F}from"three/examples/jsm/Addons.js";import{Actor as P,BaseActor as V,Parameter as G,PhysicsSystem as N,ViewController as D,World as E,attach as H,inject as R}from"../../";import{DynamicTiledNavMesh as T}from"../../ai/dynamic-tiled-navmesh";import{hasSharedArrayBufferSupport as U,toSharedFloat32Array as q,toSharedUint32Array as O}from"../../../utils/buffer";import{sleepDelay as _}from"../../../utils/async";import{Component as W,ActorComponent as X}from"../../../gameplay";var L;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(L||(L={}));let $=L.none,J=new m(!1);export async function safeRecastInit(){return $===L.none?($=L.starting,p().then((()=>{J.next(!0),$=L.started}))):b(J.pipe(w((e=>e))))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const K=navigator.hardwareConcurrency??1;let Q=class extends X{constructor(){super(...arguments),this.color=new k(16777215),this.dimensions=new z(1,1,1)}onInit(){const e=new A(this.dimensions.x,this.dimensions.y,this.dimensions.z),t=new B(e),n=new M(t,new S({color:this.color})),o=(new v(e,new C({color:this.color,transparent:!0,opacity:.3,visible:!1})),new j);o.add(n),this.actor.object.add(o)}};e([G(),t("design:type",k)],Q.prototype,"color",void 0),Q=e([W({inEditor:!0,editorOnly:!0})],Q);export{Q as TriggerVolumeMesh};let Y=!1,Z=class extends V{constructor(){super(...arguments),this.physics=R(N),this.view=R(D),this.world=R(E),this.editorVisualisation=H(Q),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){Y||(await safeRecastInit(),Y=!0),setTimeout((()=>{this.init()}),10),this.recreateInterval=setInterval((()=>{if("_hology_transform_group"===this.object.parent?.name)return;oe.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new g,this.init())}),1e3)}onEndPlay(){clearInterval(this.recreateInterval)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale),console.log(this.bounds);const e=Math.min(Math.ceil(Math.min(this.bounds.max.x-this.bounds.min.x,this.bounds.max.z-this.bounds.min.z)),400),t=Math.max(this.cellSize,.01),n={tileSize:e,walkableClimb:this.walkableClimb/t,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:5,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:t,ch:t,maxSimplificationError:1.3,maxEdgeLen:200},o=new T({navMeshBounds:this.bounds,recastConfig:n,maxTiles:1024,workers:K,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=o.navMesh;const s=this.tileSize*n.cs*2,i=performance.now(),r=new Map,a=new d;a.userData.isDebugDrawer=!0;o.navMesh;const c=this.bounds,l=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(s),(new x.Vector3).copy(e).addScalar(s)),n=[],o=this.physics.world.bodies;if(null==o)return[];const i=new x.Box3;for(const e of o.getAll())for(let o=0,s=e.numColliders();o<s;o++){const s=e.collider(o);if(s.isSensor()||null!=s.parent().userData&&!0===s.parent().userData.ignoreForNavMesh)continue;const a=e.handle+","+o,c=r.get(a)?.mesh,l=c??te(s);if(ne(s,l),null!=l){i.copy(l.geometry.boundingBox),i.min.add(l.position),i.max.add(l.position);const e=i.intersectsBox(t)||!0,o=i.intersectsBox(this.bounds);r.set(a,{pos:s.translation(),mesh:l}),e&&o&&n.push(l)}}return n},h=new x.Box3,p=new Map,m=new Map;let w=!0,b=performance.now(),g=!1;const v=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await _(t)})(),()=>{n=!0}}((async()=>{if(g)return;const e=new x.Box3,t=l();for(const n of t){const t=p.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),p.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=o.getTilesForBounds(e);if(0!=n.length){const s=[];for(const n of t)h.setFromObject(n),h.intersectsBox(e)&&s.push(n);console.log("intersecting meshes",s.length);let[i,r]=u(s);r=function(e,t,n){const o=new x.Vector3,s=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let s=0;s<3;s++){const a=3*t[i+s];if(o.fromArray(e,a),!n.containsPoint(o)){r=!1;break}}r&&s.push(t[i],t[i+1],t[i+2])}return new Uint32Array(s)}(i,r,c),U&&(i=q(i),r=O(r));const a=w;w=!1,await Promise.all(n.map((e=>(b=performance.now(),o.buildTile(i,r,e,a).then((()=>{const t=e[0]+","+e[1];m.set(t,(m.get(t)??0)+1),this.debug})))))).then((()=>{this.debug,g=!1}))}else g=!1}),this.refreshMs??1e4);this.disposed.subscribe((()=>v())),o.onNavMeshUpdate.pipe(y(this.disposed),f(200)).subscribe((()=>{a.clear(),a.drawNavMesh(o.navMesh)})),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(a)),this.disposed.subscribe((()=>{o?.destroy(),a.removeFromParent(),a.dispose()}));const B=performance.now()-i;B>1e3&&console.warn(`NavMesh update took ${B} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([G(),t("design:type",Boolean)],Z.prototype,"debug",void 0),e([G(),t("design:type",Number)],Z.prototype,"walkableClimb",void 0),e([G({range:[0,89]}),t("design:type",Number)],Z.prototype,"walkableSlopeAngle",void 0),e([G({range:[.01,10]}),t("design:type",Number)],Z.prototype,"cellSize",void 0),Z=e([P()],Z);export default Z;function ee(e){if(e.shape instanceof c)return function(e){const t=e.shape;if(t.type!==l.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const o=t,s=o.heights,i=o.nrows,r=o.ncols,a=o.scale.x,c=o.scale.z,h=o.scale.y,p=i+1,d=new x.PlaneGeometry(c,a,r,i);d.rotateX(-Math.PI/2);const u=d.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)u[m+1]=s[t*p+e]*h,m+=3,0!=u[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,c,2,2);return e.rotateX(-Math.PI/2),e}return d}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i)return function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new F).setFromPoints(t),o=[];n.faces.forEach((e=>{const t=e.edge.head().point,n=e.edge.next.head().point,s=e.edge.next.next.head().point;o.push(t.x,t.y,t.z),o.push(n.x,n.y,n.z),o.push(s.x,s.y,s.z)}));const s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(o,3)),s}(e.shape.vertices);if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?o.setIndex(new x.Uint16BufferAttribute(n,1)):o=I.mergeVertices(o),o.computeVertexNormals(),o}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function te(e){const t=ee(e);if(null==t)return null;const n=se,o=new x.Mesh(t,n);return o.geometry.computeBoundingBox(),o.geometry.scale(1.01,1.01,1.01),o}function ne(e,t){const n=e.translation(),o=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(o.x,o.y,o.z,o.w)}const oe=new x.Box3,se=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{Vector3 as t}from"three";import{LeafNode as o,NodeState as e}from"./bt";import{clamp as n}from"../../../utils/math";export class CharacterMoveToNode extends o{constructor(t,o){super(),this.navigation=t,this.movement=o,this.distanceFrom=.5}tick(t){const o=this.movement.actor.object.position,c=null!=this.target?this.target():null;if(null==c)return this.movement.directionInput.vector.set(0,0),e.FAILURE;if(o.distanceTo(c)<this.distanceFrom)return this.movement.directionInput.vector.set(0,0),e.SUCCESS;const{success:m,path:a}=this.navigation.findPath(o,c);if(!m)return console.log("Move to: Failed to find path"),e.FAILURE;const h=a[1],l=i.subVectors(h,o);l.y=0,l.normalize(),this.movement.actor.object.getWorldDirection(r).normalize();const u=r.angleTo(l);s.crossVectors(r,l);const v=s.y<0?-u:u;return this.movement.rotationInput.rotation.y+=n(v,-.1,.1),this.movement.directionInput.togglePositiveY(!0),e.RUNNING}}const i=new t,r=new t,s=new t;/*
1
+ import{Vector3 as t}from"three";import{LeafNode as o,NodeState as e}from"./bt";import{clamp as n}from"../../../utils/math";export class CharacterMoveToNode extends o{constructor(t,o){super(),this.navigation=t,this.movement=o,this.distanceFrom=.5}tick(t){const o=this.movement.actor.object.position,c=null!=this.target?this.target():null;if(null==c)return this.movement.directionInput.vector.set(0,0),e.FAILURE;if(o.distanceTo(c)<this.distanceFrom)return this.movement.directionInput.vector.set(0,0),e.SUCCESS;const{success:m,path:a}=this.navigation.findPath(o,c);if(!m)return e.FAILURE;const h=a[1],u=i.subVectors(h,o);u.y=0,u.normalize(),this.movement.actor.object.getWorldDirection(r).normalize();const l=r.angleTo(u);s.crossVectors(r,u);const v=s.y<0?-l:l;return this.movement.rotationInput.rotation.y+=n(v,-.1,.1),this.movement.directionInput.togglePositiveY(!0),e.RUNNING}}const i=new t,r=new t,s=new t;/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -17,5 +17,13 @@ export declare class Navigation {
17
17
  * Returns null if it can't be found or if nav mesh has not been generated
18
18
  */
19
19
  findClosestPoint(position: Vector3): Vector3 | null;
20
+ findRandomPoint(): {
21
+ success: boolean;
22
+ randomPoint: Vector3;
23
+ };
24
+ findRandomPointAroundCircle(position: Vector3, radius: number): {
25
+ success: boolean;
26
+ randomPoint: Vector3;
27
+ };
20
28
  }
21
29
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/gameplay/ai/navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC,qBACa,UAAU;IACrB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,KAAK,CAAC,CAAc;IAC5B,OAAO,CAAC,KAAK,CAAgB;;IAwB7B,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,EAAE,CAAA;KAAC;IAoB3E;;;OAGG;IACH,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,GAAC,IAAI;CAYlD"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/gameplay/ai/navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC,qBACa,UAAU;IACrB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,KAAK,CAAC,CAAc;IAC5B,OAAO,CAAC,KAAK,CAAgB;;IAwB7B,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,EAAE,CAAA;KAAC;IAoB3E;;;OAGG;IACH,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,GAAC,IAAI;IAajD,eAAe;;;;IAaf,2BAA2B,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;;;;CAY9D"}
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as e}from"tslib";import{NavMeshQuery as s}from"recast-navigation";import{Vector3 as n}from"three";import{inject as r,Service as o,World as i}from"../";import h,{safeRecastInit as u}from"../actors/builtin/navmesh-actor";let a=class{constructor(){this.world=r(i),u().then((()=>{const t=this.world.actors.find((t=>t instanceof h));null!=t&&(this.navMeshActor=t,this.query=null),this.world.actorAdded.subscribe((t=>{t instanceof h&&(this.navMeshActor=t,this.query=null)})),this.world.actorRemoved.subscribe((t=>{t instanceof h&&t.id===this.navMeshActor?.id&&(this.navMeshActor=null,this.query=null)}))}))}ensureQuery(){null==this.query&&null!=this.navMeshActor&&null!=this.navMeshActor.navMesh&&(this.query=new s(this.navMeshActor.navMesh))}findPath(t,e){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),l;const s=this.findClosestPoint(t);if(null==s)return d("Start point could not be found on NavMesh",t),l;const{success:r,error:o,path:i}=this.query.computePath(s,e);return r?{success:!0,path:i.map((t=>new n(t.x,t.y,t.z)))}:(d("Failed to generate path",o),l)}findClosestPoint(t){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),null;const{success:e,point:s}=this.query.findClosestPoint(t);return e?new n(s.x,s.y,s.z):null}};a=t([o(),e("design:paramtypes",[])],a);export{a as Navigation};const l={success:!1,path:[]};let c=new Set;function d(t,...e){c.has(t)||(c.add(t),setTimeout((()=>c.delete(t)),2e3),console.warn(t,...e))}/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{NavMeshQuery as n}from"recast-navigation";import{Vector3 as s}from"three";import{inject as r,Service as o,World as i}from"../";import u,{safeRecastInit as a}from"../actors/builtin/navmesh-actor";let h=class{constructor(){this.world=r(i),a().then((()=>{const e=this.world.actors.find((e=>e instanceof u));null!=e&&(this.navMeshActor=e,this.query=null),this.world.actorAdded.subscribe((e=>{e instanceof u&&(this.navMeshActor=e,this.query=null)})),this.world.actorRemoved.subscribe((e=>{e instanceof u&&e.id===this.navMeshActor?.id&&(this.navMeshActor=null,this.query=null)}))}))}ensureQuery(){null==this.query&&null!=this.navMeshActor&&null!=this.navMeshActor.navMesh&&(this.query=new n(this.navMeshActor.navMesh))}findPath(e,t){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),c;const n=this.findClosestPoint(e);if(null==n)return d("Start point could not be found on NavMesh",e),c;const{success:r,error:o,path:i}=this.query.computePath(n,t);return r?{success:!0,path:i.map((e=>new s(e.x,e.y,e.z)))}:(d("Failed to generate path",o),c)}findClosestPoint(e){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),null;const{success:t,point:n}=this.query.findClosestPoint(e);return t?new s(n.x,n.y,n.z):null}findRandomPoint(){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),null;const e=this.query.findRandomPoint();return{success:e.success,randomPoint:(new s).copy(e.randomPoint)}}findRandomPointAroundCircle(e,t){if(this.ensureQuery(),null==this.query)return d("NavMesh has not been generated yet"),null;const n=this.query.findRandomPointAroundCircle(e,t);return{success:n.success,randomPoint:(new s).copy(n.randomPoint)}}};h=e([o(),t("design:paramtypes",[])],h);export{h as Navigation};const c={success:!1,path:[]};let l=new Set;function d(e,...t){l.has(e)||(l.add(e),setTimeout((()=>l.delete(e)),2e3),console.warn(e,...t))}/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -31,6 +31,7 @@ export declare class RenderingView {
31
31
  csm: CSM | null;
32
32
  fpsCap: number | null;
33
33
  aoPass: GTAOPass;
34
+ private bloomPass;
34
35
  setPaused(value: boolean): void;
35
36
  resolutionScale: number;
36
37
  maxPixelRatio: number;
@@ -1 +1 @@
1
- {"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,EAKN,QAAQ,EAIR,aAAa,EACb,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAGpD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AA6CzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,EAAE,CAAC,EAAE;QACH,OAAO,EAAE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