@hology/core 0.0.93 → 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 (73) hide show
  1. package/LICENSE.md +14 -14
  2. package/README.md +2 -2
  3. package/dist/effects/vfx/initializsers.d.ts +10 -3
  4. package/dist/effects/vfx/initializsers.d.ts.map +1 -1
  5. package/dist/effects/vfx/initializsers.js +1 -1
  6. package/dist/effects/vfx/rates.d.ts +8 -0
  7. package/dist/effects/vfx/rates.d.ts.map +1 -1
  8. package/dist/effects/vfx/rates.js +1 -1
  9. package/dist/effects/vfx/vfx-defs.d.ts +38 -1
  10. package/dist/effects/vfx/vfx-defs.d.ts.map +1 -1
  11. package/dist/effects/vfx/vfx-defs.js +1 -1
  12. package/dist/effects/vfx/vfx-materializer.d.ts.map +1 -1
  13. package/dist/effects/vfx/vfx-materializer.js +1 -1
  14. package/dist/effects/vfx/vfx-renderers.d.ts +1 -0
  15. package/dist/effects/vfx/vfx-renderers.d.ts.map +1 -1
  16. package/dist/effects/vfx/vfx-renderers.js +1 -1
  17. package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +11 -0
  18. package/dist/gameplay/actors/builtin/navmesh-actor.d.ts.map +1 -1
  19. package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
  20. package/dist/gameplay/ai/behavior-tree/move.js +1 -1
  21. package/dist/gameplay/ai/dynamic-tiled-navmesh.d.ts.map +1 -1
  22. package/dist/gameplay/ai/dynamic-tiled-navmesh.js +1 -1
  23. package/dist/gameplay/ai/navigation.d.ts +8 -0
  24. package/dist/gameplay/ai/navigation.d.ts.map +1 -1
  25. package/dist/gameplay/ai/navigation.js +1 -1
  26. package/dist/gameplay/services/physics/physics-system.d.ts.map +1 -1
  27. package/dist/gameplay/services/physics/physics-system.js +1 -1
  28. package/dist/rendering.d.ts +1 -0
  29. package/dist/rendering.d.ts.map +1 -1
  30. package/dist/rendering.js +1 -1
  31. package/dist/scene/asset-resource-loader.js +1 -1
  32. package/dist/scene/collision/collision-shape-import.d.ts.map +1 -1
  33. package/dist/scene/collision/collision-shape-import.js +1 -1
  34. package/dist/scene/landscape/landscape-manager.d.ts.map +1 -1
  35. package/dist/scene/landscape/landscape-manager.js +1 -1
  36. package/dist/scene/materializer.d.ts +11 -2
  37. package/dist/scene/materializer.d.ts.map +1 -1
  38. package/dist/scene/materializer.js +1 -1
  39. package/dist/scene/model.d.ts +3 -3
  40. package/dist/scene/model.d.ts.map +1 -1
  41. package/dist/scene/objects/prefab.d.ts +8 -0
  42. package/dist/scene/objects/prefab.d.ts.map +1 -0
  43. package/dist/scene/objects/prefab.js +4 -0
  44. package/dist/scene/scene-data-service.d.ts +17 -7
  45. package/dist/scene/scene-data-service.d.ts.map +1 -1
  46. package/dist/scene/scene-data-service.js +1 -1
  47. package/dist/scene/storage/storage.d.ts +9 -8
  48. package/dist/scene/storage/storage.d.ts.map +1 -1
  49. package/dist/scene/storage/storage.js +1 -1
  50. package/dist/shader/builtin/decal-standard-shader.d.ts +24 -0
  51. package/dist/shader/builtin/decal-standard-shader.d.ts.map +1 -0
  52. package/dist/shader/builtin/decal-standard-shader.js +4 -0
  53. package/dist/shader/builtin/decal-unlit-shader.d.ts +12 -0
  54. package/dist/shader/builtin/decal-unlit-shader.d.ts.map +1 -0
  55. package/dist/shader/builtin/decal-unlit-shader.js +4 -0
  56. package/dist/shader/decal-shader.d.ts +7 -0
  57. package/dist/shader/decal-shader.d.ts.map +1 -0
  58. package/dist/shader/decal-shader.js +4 -0
  59. package/dist/shader-nodes/decal.d.ts +8 -0
  60. package/dist/shader-nodes/decal.d.ts.map +1 -0
  61. package/dist/shader-nodes/decal.js +4 -0
  62. package/dist/shader-nodes/depth.d.ts +8 -0
  63. package/dist/shader-nodes/depth.d.ts.map +1 -1
  64. package/dist/shader-nodes/depth.js +1 -1
  65. package/dist/shader-nodes/index.d.ts +1 -0
  66. package/dist/shader-nodes/index.d.ts.map +1 -1
  67. package/dist/shader-nodes/index.js +1 -1
  68. package/dist/shader-nodes/particle.d.ts +4 -2
  69. package/dist/shader-nodes/particle.d.ts.map +1 -1
  70. package/dist/shader-nodes/particle.js +1 -1
  71. package/dist/utils/math.js +1 -1
  72. package/package.json +3 -3
  73. package/tsconfig.tsbuildinfo +1 -1
package/LICENSE.md CHANGED
@@ -1,15 +1,15 @@
1
- # Hology Interactive AB Limited License
2
-
3
- This software package, including all associated files and documentation (the "Software"), is licensed to you (the "Licensee") by Hology Interactive AB for use exclusively with the product "Hology Engine."
4
-
5
- By using, copying, modifying, or distributing the Software, Licensee agrees to be bound by the terms of this license.
6
-
7
- 1. License Grant: Hology Interactive AB grants Licensee a limited, non-exclusive, non-transferable license to use the Software solely for the purpose of developing and running software developed with "Hology Engine."
8
-
9
- 2. Restrictions: Licensee may not use, copy, modify, or distribute the Software for any other purpose, including but not limited to the creation of derivative works, standalone applications, or any products not directly associated with "Hology Engine."
10
-
11
- 3. Ownership: Hology Interactive AB retains all intellectual property rights to the Software. This license does not transfer ownership of the Software to Licensee.
12
-
13
- 4. Warranty Disclaimer: THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE CREATOR OF THIS PACKAGE BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE.
14
-
1
+ # Hology Interactive AB Limited License
2
+
3
+ This software package, including all associated files and documentation (the "Software"), is licensed to you (the "Licensee") by Hology Interactive AB for use exclusively with the product "Hology Engine."
4
+
5
+ By using, copying, modifying, or distributing the Software, Licensee agrees to be bound by the terms of this license.
6
+
7
+ 1. License Grant: Hology Interactive AB grants Licensee a limited, non-exclusive, non-transferable license to use the Software solely for the purpose of developing and running software developed with "Hology Engine."
8
+
9
+ 2. Restrictions: Licensee may not use, copy, modify, or distribute the Software for any other purpose, including but not limited to the creation of derivative works, standalone applications, or any products not directly associated with "Hology Engine."
10
+
11
+ 3. Ownership: Hology Interactive AB retains all intellectual property rights to the Software. This license does not transfer ownership of the Software to Licensee.
12
+
13
+ 4. Warranty Disclaimer: THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE CREATOR OF THIS PACKAGE BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE.
14
+
15
15
  6. Contact: For any inquiries regarding this license, please email hello@hology.app
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Hology Engine Core
2
-
1
+ # Hology Engine Core
2
+
3
3
  For the development with Hology Engine (https://hology.app/)
@@ -9,8 +9,11 @@ export declare class Rotation extends Initializer {
9
9
  constructor(rotation: Vector3);
10
10
  initialize(target: Particle): void;
11
11
  }
12
+ export declare const randomRotationAxis: readonly ["XYZ", "X", "Y", "Z"];
13
+ export type RandomRotationAxis = typeof randomRotationAxis[number];
12
14
  export declare class RandomRotation extends Initializer {
13
- constructor();
15
+ private axis;
16
+ constructor(axis: RandomRotationAxis);
14
17
  initialize(particle: Particle): void;
15
18
  private randomAngle;
16
19
  }
@@ -31,8 +34,12 @@ export declare class InitialScaleComponents extends Initializer {
31
34
  initialize(particle: Particle): void;
32
35
  }
33
36
  export declare class AdditiveVelocity extends Initializer {
34
- private velocity;
35
- constructor(velocity: Vector3);
37
+ private min;
38
+ private max?;
39
+ private minX;
40
+ private minY;
41
+ private minZ;
42
+ constructor(min: Vector3, max?: Vector3);
36
43
  initialize(particle: Particle): void;
37
44
  }
38
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,IAAI;CAG7C;AAGD,qBAAa,QAAS,SAAQ,WAAW;IAC3B,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,OAAO;IACrC,UAAU,CAAC,MAAM,EAAE,QAAQ;CAK5B;AAGD,qBAAa,cAAe,SAAQ,WAAW;;IAE7C,UAAU,CAAE,QAAQ,EAAE,QAAQ;IAI9B,OAAO,CAAC,WAAW;CAGpB;AAGD,qBAAa,YAAa,SAAQ,WAAW;IAC/B,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IACjC,UAAU,CAAC,QAAQ,EAAE,QAAQ;CAG9B;AAED,qBAAa,WAAY,SAAQ,WAAW;IAC9B,OAAO,CAAC,GAAG;IAAU,OAAO,CAAC,GAAG;gBAAxB,GAAG,EAAE,MAAM,EAAU,GAAG,EAAE,MAAM;IACpD,UAAU,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;IACnC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,OAAO;IAErC,UAAU,CAAC,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"@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 class RandomRotation extends e{constructor(){super()}initialize(t){t.rotation.set(this.randomAngle(),this.randomAngle(),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
  */
@@ -15,4 +15,12 @@ export declare class OnceRate extends DelayRate {
15
15
  init(): void;
16
16
  getValue(time: any): number;
17
17
  }
18
+ export declare class ConstantRate extends DelayRate {
19
+ private perSecond;
20
+ private emitted;
21
+ constructor(delay: number, perSecond?: number);
22
+ clone(): ConstantRate;
23
+ init(): void;
24
+ getValue(time: any): number;
25
+ }
18
26
  //# sourceMappingURL=rates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rates.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/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K,SAAI;IAK5C,KAAK;IAGL,IAAI;IAGJ,QAAQ,CAAC,IAAI,KAAA;CAuBd;AAED,qBAAa,YAAa,SAAQ,SAAS;IAGd,OAAO,CAAC,SAAS;IAF5C,OAAO,CAAC,OAAO,CAAI;gBAEP,KAAK,EAAE,MAAM,EAAU,SAAS,SAAI;IAQhD,KAAK;IAGL,IAAI;IAIJ,QAAQ,CAAC,IAAI,KAAA;CAkBd"}
@@ -1,4 +1,4 @@
1
- import{Rate as t}from"@hology/nebula";export{Rate}from"@hology/nebula";export class DelayRate extends t{constructor(t=0,e,s){super(e,s),this.delay=t,this.restart()}restart(){this.nextTime=0,null!=this.delay&&this.delay>0&&(this.startTime=-this.delay)}clone(){return new DelayRate(this.delay,this.numPan,this.timePan)}}export class OnceRate extends DelayRate{constructor(t,e=1){super(t,e,1/0),this.count=e,this.calls=0,this.nextTime=0}clone(){return new OnceRate(this.delay,this.count)}init(){this.restart()}getValue(t){return this.calls++,this.startTime+=t,this.startTime>=this.nextTime?(this.nextTime=1/0,this.count):0}}/*
1
+ import{Rate as t}from"@hology/nebula";export{Rate}from"@hology/nebula";export class DelayRate extends t{constructor(t=0,e,s){super(e,s),this.delay=t,this.restart()}restart(){this.nextTime=0,null!=this.delay&&this.delay>0&&(this.startTime=-this.delay)}clone(){return new DelayRate(this.delay,this.numPan,this.timePan)}}export class OnceRate extends DelayRate{constructor(t,e=1){super(t,e,1/0),this.count=e,this.calls=0,this.nextTime=0}clone(){return new OnceRate(this.delay,this.count)}init(){this.restart()}getValue(t){return this.calls++,this.startTime+=t,this.startTime>=this.nextTime?(this.nextTime=1/0,this.count):0}}export class ConstantRate extends DelayRate{constructor(t,e=1){super(t,e,1),this.perSecond=e,this.emitted=0,this.nextTime=0}clone(){return new ConstantRate(this.delay,this.perSecond)}init(){this.restart(),this.emitted=0}getValue(t){if(this.startTime+=t,this.startTime>=this.nextTime){let t=0;for(;this.emitted+t<this.startTime*this.perSecond;)t++;return this.emitted+=t,t}return 0}}/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -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;
@@ -105,7 +136,9 @@ declare class RotationDef extends BaseIniDef<RotationDef> {
105
136
  make(params?: ParamsType<this>): Initializer;
106
137
  }
107
138
  declare class RandomRotationDef extends BaseIniDef<RandomRotationDef> {
108
- parameters: {};
139
+ parameters: {
140
+ axis: SelectParameterDef<string>;
141
+ };
109
142
  make(params?: ParamsType<this>): Initializer;
110
143
  }
111
144
  declare class InitialScaleDef extends BaseIniDef<InitialScaleDef> {
@@ -240,10 +273,13 @@ declare class WorldCollisionDef extends BaseBevDef<WorldCollisionDef> {
240
273
  }
241
274
  declare const vfxInitializsers: {
242
275
  lifetime: LifetimeDef;
276
+ randomLifetime: RandomLifetimeDef;
243
277
  positionPoint: PositionPointDef;
244
278
  positionBox: PositionBoxDef;
245
279
  positionSphere: PositionSphereDef;
246
280
  positionLine: PositionLineDef;
281
+ positionCircle: PositionCircleDef;
282
+ positionRing: PositionRingDef;
247
283
  rotation: RotationDef;
248
284
  randomRotation: RandomRotationDef;
249
285
  scale: InitialScaleDef;
@@ -251,6 +287,7 @@ declare const vfxInitializsers: {
251
287
  randomScale: RandomScaleDef;
252
288
  mass: MassDef;
253
289
  velocity: VelocityDef;
290
+ randomVelocity: RandomVelocityDef;
254
291
  radialVelocity: RadialVelocityDef;
255
292
  randomDirection: RandomDirectionDef;
256
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,GA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AAA,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 m,LineZone as p,Mass as d,Position as l,RadialVelocity as w,RandomDrift as x,Repulsion as f,Rotate as h,Vector3D as y}from"@hology/nebula";import{AxisDirection as k,AxisPlane as g,Disperse as v,FollowParent as b,LinearDamping as z,MoveOverLife as L,OrientAlongVelocity as T,RotatePosition as j,Scale as R}from"./behaviours.js";import{AdditiveVelocity as V,InitialScale as B,InitialScaleComponents as C,RandomDirection as D,RandomRotation as I,RandomScale as O,Rotation as A}from"./initializsers.js";import{PointZone as K,SphereZone as P}from"./zones.js";import{WorldCollisionBehaviour as S}from"./vfx-collision-behaviour.js";import{Curve2 as Y}from"../../utils/curve.js";class q{build(e={}){const r=M(e,this.parameters);return this.make(r)}}class E{build(e={}){const r=M(e,this.parameters);return this.make(r)}}function F(e,r,t){return{type:"number",default:e,float:!0,min:r,max:t}}function G(e){return{type:"vec3",default:(new t).fromArray(e)}}function H(e){return{type:"color",default:e}}function J(){return{type:"curve",default:Y.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 E{constructor(){super(...arguments),this.parameters={duration:F(1,0,1e5)}}make(e={}){return new m(e.duration)}},positionPoint:new class extends E{constructor(){super(...arguments),this.parameters={position:G([0,0,0])}}make(e={}){const{x:r,y:t,z:s}=e.position;return new l(new K(r,t,s))}},positionBox:new class extends E{constructor(){super(...arguments),this.parameters={position:G([0,0,0]),dimensions:G([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 E{constructor(){super(...arguments),this.parameters={position:G([0,0,0]),radius:F(1)}}make(e={}){const{x:r,y:t,z:s}=e.position;return new l(new P(r,t,s,e.radius))}},positionLine:new class extends E{constructor(){super(...arguments),this.parameters={a:G([0,0,0]),b:G([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 E{constructor(){super(...arguments),this.parameters={rotation:G([0,0,0])}}make(e={}){const{x:r,y:s,z:n}=e.rotation;return new A(new t(r,s,n))}},randomRotation:new class extends E{constructor(){super(...arguments),this.parameters={}}make(e={}){return new I}},scale:new class extends E{constructor(){super(...arguments),this.parameters={scale:F(1)}}make(e={}){return new B(e.scale)}},scaleComponents:new class extends E{constructor(){super(...arguments),this.parameters={scale:G([1,1,1])}}make(e={}){return new C(e.scale)}},randomScale:new class extends E{constructor(){super(...arguments),this.parameters={min:F(1),max:F(1)}}make(e={}){return new O(e.min,e.max)}},mass:new class extends E{constructor(){super(...arguments),this.parameters={min:F(1)}}make(e={}){return new d(e.min)}},velocity:new class extends E{constructor(){super(...arguments),this.parameters={velocity:G([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 E{constructor(){super(...arguments),this.parameters={speed:F(1),direction:G([0,1,0]),spread:F(0)}}make(e={}){return new w(e.speed,new y(e.direction.x,e.direction.y,e.direction.z),e.spread)}},randomDirection:new class extends E{constructor(){super(...arguments),this.parameters={speed:F(1)}}make(e={}){return new D(e.speed)}}},U={force:new class extends q{constructor(){super(...arguments),this.parameters={force:G([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 q{constructor(){super(...arguments),this.parameters={gravity:F(8),easing:J()}}make(e={}){return new u(e.gravity,void 0,N(e.easing))}},repulsion:new class extends q{constructor(){super(...arguments),this.parameters={target:G([0,0,0]),force:F(1),radius:F(1),easing:J()}}make(e={}){const r=new y(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 q{constructor(){super(...arguments),this.parameters={target:G([0,0,0]),force:F(1),radius:F(1),easing:J()}}make(e={}){const r=new y(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 q{constructor(){super(...arguments),this.parameters={a:F(1),b:F(1),ease:J()}}make(e={}){return new R(e.a,e.b,N(e.ease))}},randomDrift:new class extends q{constructor(){super(...arguments),this.parameters={drift:G([1,1,1]),delay:F(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 q{constructor(){super(...arguments),this.parameters={rotation:G([0,0,0]),ease:J()}}make(r={}){const{x:t,y:s,z:n}=r.rotation;return new h(e.degToRad(t),e.degToRad(s),e.degToRad(n),void 0,N(r.ease))}},rotateAdd:new class extends q{constructor(){super(...arguments),this.parameters={rotation:G([0,0,0])}}make(r={}){const{x:t,y:s,z:n}=r.rotation,a=new h(e.degToRad(t),e.degToRad(s),e.degToRad(n),void 0);return a.rotationType="add",a}},changeColor:new class extends q{constructor(){super(...arguments),this.parameters={a:H("#ffffff"),b:H("#ffffff"),ease:J()}}make(e={}){return new o(e.a,e.b,void 0,N(e.ease))}},changeOpacity:new class extends q{constructor(){super(...arguments),this.parameters={a:F(1,0,1),b:F(0,0,1),ease:J()}}make(e={}){return new s(e.a,e.b,void 0,N(e.ease))}},vortex:new class extends q{constructor(){super(...arguments),this.parameters={axis:G([0,1,0]),amount:F(1)}}make(e={}){return new j(e.axis,e.amount)}},moveTo:new class extends q{constructor(){super(...arguments),this.parameters={target:G([0,1,0]),ease:J()}}make(e={}){return new L(e.target.x,e.target.y,e.target.z,N(e.ease))}},linearDamping:new class extends q{constructor(){super(...arguments),this.parameters={factor:F(.1,0,1)}}make(e={}){return new z(e.factor)}},followParent:new class extends q{constructor(){super(...arguments),this.parameters={speed:F(1)}}make(e={}){return new b(e.speed)}},worldCollision:new class extends q{constructor(){super(...arguments),this.parameters={friction:F(1,0,1),bounce:F(1,0,1),lifeLoss:F(0,0)}}make(e={}){return new S(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 +1 @@
1
- {"version":3,"file":"vfx-materializer.d.ts","sourceRoot":"","sources":["../../../src/effects/vfx/vfx-materializer.ts"],"names":[],"mappings":"AAAA,OAAO,MAAiE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAmD,kBAAkB,EAA4T,MAAM,oBAAoB,CAAC;AAEna,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,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AAC,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,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,uniforms as B,varying as k,varyingAttributes as z,varyingVec3 as T,varyingVec4 as V}from"three-shader-graph";import{prepareShapeParameters as j}from"../../scene/materializer.js";import{SerializedParamType as D}from"../../scene/model.js";import{ShapeLibrary as F}from"../../scene/objects/shapes.js";import{fragmentLinearEyeDepth as Q,linearEyeDepth as U}from"../../shader-nodes/depth.js";import{particleEnergyUniformName as L,particleTimeUniformName as H,particleUniforms as q,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 W,OnceRate as O}from"./rates.js";import{StretchedSprite as K}from"./stretched-sprite.js";import{ThreeBlendingMode as X}from"./vfx-asset.js";import{VfxBehaviourLibrary as Y,VfxInitializserLibrary as Z}from"./vfx-defs.js";import{MultiRenderer as _}from"./vfx-renderers.js";import{WorldCollisionBehaviour as $}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 ee(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 ee(e,t,n,m){const T=function(e){let t;switch(e.rate.type){case"continuous":t=new W(e.rate.delay??0,e.rate.count,e.rate.time);break;case"once":t=new O(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):te,n=R(i);let s=n.sample(z.uv);e.flipbook?.enabled&&(s=J(n,w.uv,e.flipbook.columns,e.flipbook.rows,q.time,e.flipbook.fps,e.flipbook.mode));const r=new p("rotation",0),a=new u("color").rgb,l=(new u("opacity").rgb,U.subtract(Q).divide(U));let c=s.x;if("number"==typeof e.softness&&e.softness>0){const t=b(l,v(e.softness));c=c.multiply(t)}const m=A(d,{position:C.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 h=new SpriteNodeShaderMaterial({color:P(a,c).multiply(s),transparent:!0,position:m,uniforms:{color:{value:new o.Color(e.color)}}});h.blending=X[e.blendingMode]??o.NormalBlending;const f=new o.Mesh(new o.PlaneGeometry(1,1),h);return f.name="sprite",f}(e.output,t));break;case"stretchedSprite":L=new i(await async function(e,t){const i=null!=e.texture?await t.getTexture(e.texture):te,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=U.subtract(Q).divide(E(U)),i=b(t,v(e.softness));a=I(a.multiply(i))}const c=A(d,{position:w.position,offset:g("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:{}});m.blending=X[e.blendingMode]??o.NormalBlending;const p=new K(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){const i=F[e.shape];if(null==i)return console.error(`No shape with type ${e.shape}`),new r;const n=j(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))))}));return await Promise.all(s),i.traverse((e=>{})),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 H=new ne;H.parent=n,H.setRate(T),H._space=e.output.space;const G=await Promise.all(e.initializers.filter((e=>null!=Z[e.type])).map((async e=>{const t=Z[e.type],i=await j(e.params??{});return t.build(i)})));G.push(L,new N),H.addInitializers(G);const _=await Promise.all(e.behaviours.filter((e=>null!=Y[e.type])).map((async e=>{const t=Y[e.type];for(const[i,n]of Object.entries(e.params))t.parameters&&null!=t.parameters[i]&&"curve"===t.parameters[i].type&&n.type!==D.Curve&&(n.type=D.Curve);const i=await j(e.params??{});return t.build(i)})).sort(((e,t)=>e instanceof $?1:0)));_.push(new ie);for(const e of _)e instanceof $&&(e.physics=m);H.addBehaviours(_);for(const i of e.children){const e=await ee(i,t,n,m),s=new EmitterPool((()=>{const t=e.clone();return t.onExpired=()=>{const e=H.childEmitters.findIndex((e=>e.id===t.id));-1!=e&&H.childEmitters.splice(e,1),s.release(t)},t})),o=H.eventDispatcher,r=new Map;H.bindEmitterEvent=!0,o.addEventListener("PARTICLE_DEAD",(e=>{const t=r.get(e.id);if(null!=t){const e=H.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(),H.childEmitters.push(t),r.set(e.id,t),t.parentParticle=e,t.system=H.system,t.emit()}))}return H}const te=(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 ie extends t{initialize(e){if(e.body instanceof o.Mesh){const t=e.body.material;t instanceof c&&(null!=t.uniforms[L]||null!=t.uniforms[H]||null!=t.uniforms[G])&&(e.body.material=t.clone())}}mutate(e,t,i){if(this.energize(e,t),e.target instanceof o.Mesh){const t=e.target.material;t instanceof c&&(null!=t.uniforms[L]&&(t.uniforms[L].value=this.energy),null!=t.uniforms[H]&&(t.uniforms[H].value=e.age),null!=t.uniforms[G]&&(t.uniforms[G].value=e.velocity))}}}class ne 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 ne;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,cAAc;IAAY,OAAO,CAAC,KAAK;IAAgB,OAAO,CAAC,IAAI;IAHzH,OAAO,CAAC,cAAc,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B,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(u,Math.PI/-2),p.setFromUnitVectors(a,r),t.quaternion.copy(p)}t.material instanceof a.Material&&(r&&(t.material.opacity=e.alpha,t.material.transparent=!0),s&&null!=t.material.color&&t.material.color.copy(e.color))}}onParticleDead(e){e.target&&(e.target.material&&(e.useAlpha||e.useColor)&&this._materialPool.expire(e.target.material),this._targetPool.expire(e.target),this.container.remove(e.target),e.target=null)}}export 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,p=new a.Quaternion,u=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;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));if(f(e,n.mesh),a&&(n.mesh.setColorAt(e.target,U.copy(e.color)),n.mesh.instanceColor.needsUpdate=!0),r){const t=n.mesh.geometry.getAttribute("particleData");t.setX(e.target,e.alpha),t.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(u,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,13 +1,21 @@
1
1
  import { NavMesh } from 'recast-navigation';
2
+ import { Color } from 'three';
2
3
  import { BaseActor } from "../../";
4
+ import { ActorComponent } from '../../../gameplay';
3
5
  export declare function safeRecastInit(): Promise<boolean | void>;
4
6
  export type NavMeshLoader = {
5
7
  save(): any;
6
8
  };
9
+ export declare class TriggerVolumeMesh extends ActorComponent {
10
+ color: Color;
11
+ private dimensions;
12
+ onInit(): void | Promise<void>;
13
+ }
7
14
  declare class NavMeshActor extends BaseActor {
8
15
  private physics;
9
16
  private view;
10
17
  private world;
18
+ private editorVisualisation;
11
19
  debug: boolean;
12
20
  refreshMs: number;
13
21
  private tileSize;
@@ -15,7 +23,10 @@ declare class NavMeshActor extends BaseActor {
15
23
  walkableSlopeAngle: number;
16
24
  cellSize: number;
17
25
  navMesh: NavMesh;
26
+ private bounds;
27
+ private recreateInterval;
18
28
  onInit(): Promise<void>;
29
+ onEndPlay(): void;
19
30
  private init;
20
31
  }
21
32
  export default NavMeshActor;
@@ -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;AAK5C,OAAO,EAAS,SAAS,EAA2D,MAAM,QAAQ,CAAC;AAcnG,wBAAsB,cAAc,4BASnC;AASD,MAAM,MAAM,aAAa,GAAG;IAO1B,IAAI,QAAE;CACP,CAAA;AAGD,cACM,YAAa,SAAQ,SAAS;IAClC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,KAAK,CAAgB;IAEhB,KAAK,EAAE,OAAO,CAAO;IAElC,S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AM,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 o,Capsule as n,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as c,ShapeType as l,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as f,debounceTime as m,filter as w,firstValueFrom as g,takeUntil as b}from"rxjs";import*as y from"three";import{BufferGeometryUtils as x,ConvexHull as v}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as M,Parameter as S,PhysicsSystem as z,ViewController as j,World as k,inject as A}from"../../";import{DynamicTiledNavMesh as C}from"../../ai/dynamic-tiled-navmesh";import{hasSharedArrayBufferSupport as F,toSharedFloat32Array as G,toSharedUint32Array as P}from"../../../utils/buffer";import{sleepDelay as N}from"../../../utils/async";var V;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(V||(V={}));let D=V.none,I=new f(!1);export async function safeRecastInit(){return D===V.none?(D=V.starting,p().then((()=>{I.next(!0),D=V.started}))):g(I.pipe(w((e=>e))))}const E=new y.Box3(new y.Vector3(-100,-100,-100),new y.Vector3(100,100,100)),H=navigator.hardwareConcurrency??1;let R=!1,T=class extends M{constructor(){super(...arguments),this.physics=A(z),this.view=A(j),this.world=A(k),this.debug=!0,this.refreshMs=4e3,this.tileSize=400,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.cellSize=.2}async onInit(){R||(await safeRecastInit(),R=!0),setTimeout((()=>{this.init()}),1e3)}init(){const e=this.cellSize,t={tileSize:400,walkableClimb:this.walkableClimb/e,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:5,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:e,ch:e,maxSimplificationError:1.3,maxEdgeLen:200},o=new y.Box3;for(const e of this.physics.staticBodies.keys())e.traverse((t=>{t.isMesh&&t.geometry&&(t.geometry.computeBoundingBox(),o.expandByObject(e))}));o.union(E);const n=new C({navMeshBounds:o,recastConfig:t,maxTiles:1024,workers:H,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=n.navMesh,this.object.position.set(0,0,0);const s=this.tileSize*t.cs*2,i=performance.now(),r=new Map,a=new u;a.userData.isDebugDrawer=!0;n.navMesh;const c=()=>{const e=this.view.getCamera().getWorldPosition(new y.Vector3),t=new y.Box3((new y.Vector3).copy(e).subScalar(s),(new y.Vector3).copy(e).addScalar(s)),o=[],n=this.physics.world.bodies;if(null==n)return[];const i=new y.Box3;for(const e of n.getAll())for(let n=0,s=e.numColliders();n<s;n++){const s=e.collider(n);if(s.isSensor()||null!=s.parent().userData&&!0===s.parent().userData.ignoreForNavMesh)continue;const a=e.handle+","+n,c=r.get(a)?.mesh,l=c??U(s);if(q(s,l),null!=l){i.copy(l.geometry.boundingBox),i.min.add(l.position),i.max.add(l.position);const e=i.intersectsBox(t)||!0;r.set(a,{pos:s.translation(),mesh:l}),e&&o.push(l)}}return o},l=new y.Box3,h=new Map,p=new Map;let f=!0,w=performance.now(),g=!1;const x=function(e,t){let o=!1;return(async()=>{for(;!o;)await e(),await N(t)})(),()=>{o=!0}}((async()=>{if(g)return;const e=new y.Box3,t=c();for(const o of t){const t=h.get(o);!0!==t?.equals(o.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(o),h.set(o,o.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const o=n.getTilesForBounds(e);if(0!=o.length){const s=[];for(const o of t)l.setFromObject(o),l.intersectsBox(e)&&s.push(o);console.log("intersecting meshes",s.length),console.time("get positions");let[i,r]=d(s);F&&(i=G(i),r=P(r)),console.timeEnd("get positions");const a=f;f=!1,await Promise.all(o.map((e=>(w=performance.now(),n.buildTile(i,r,e,a).then((()=>{const t=e[0]+","+e[1];p.set(t,(p.get(t)??0)+1),this.debug})))))).then((()=>{this.debug,g=!1}))}else g=!1}),this.refreshMs??1e4);this.disposed.subscribe((()=>x())),n.onNavMeshUpdate.pipe(b(this.disposed),m(200)).subscribe((()=>{a.clear(),a.drawNavMesh(n.navMesh)})),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.position.set(0,0,0),this.object.scale.set(1,1,1),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.add(a)),this.disposed.subscribe((()=>{n?.destroy(),a.removeFromParent(),a.dispose()}));const v=performance.now()-i;v>1e3&&console.warn(`NavMesh update took ${v} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([S(),t("design:type",Boolean)],T.prototype,"debug",void 0),e([S(),t("design:type",Number)],T.prototype,"walkableClimb",void 0),e([S({range:[0,89]}),t("design:type",Number)],T.prototype,"walkableSlopeAngle",void 0),e([S(),t("design:type",Number)],T.prototype,"cellSize",void 0),T=e([B()],T);export default T;function O(e){if(e.shape instanceof c)return function(e){const t=e.shape;if(t.type!==l.HeightField)throw new Error("The provided collider is not a height field.");let o=!1;const n=t,s=n.heights,i=n.nrows,r=n.ncols,a=n.scale.x,c=n.scale.z,h=n.scale.y,p=i+1,u=new y.PlaneGeometry(c,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let f=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[f+1]=s[t*p+e]*h,f+=3,0!=d[f+1]&&(o=!0);if(!o){const e=new y.PlaneGeometry(a,c,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof o)return new y.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new y.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i)return function(e){const t=[];for(let o=0;o<e.length;o+=3)t.push(new y.Vector3(e[o],e[o+1],e[o+2]));const o=(new v).setFromPoints(t),n=[];o.faces.forEach((e=>{const t=e.edge.head().point,o=e.edge.next.head().point,s=e.edge.next.next.head().point;n.push(t.x,t.y,t.z),n.push(o.x,o.y,o.z),n.push(s.x,s.y,s.z)}));const s=new y.BufferGeometry;return s.setAttribute("position",new y.Float32BufferAttribute(n,3)),s}(e.shape.vertices);if(e.shape instanceof h){const t=e.shape.vertices,o=e.shape.indices;let n=new y.BufferGeometry;return n.setAttribute("position",new y.Float32BufferAttribute(t,3)),null!=o?n.setIndex(new y.Uint16BufferAttribute(o,1)):n=x.mergeVertices(n),n.computeVertexNormals(),n}if(e.shape instanceof a){const t=e.shape.halfHeight,o=e.shape.radius;return new y.CylinderGeometry(o,o,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,o=e.shape.radius;return new y.ConeGeometry(o,2*t)}if(e.shape instanceof n){const t=e.shape.halfHeight,o=e.shape.radius;return new y.CapsuleGeometry(o,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function U(e){const t=O(e);if(null==t)return null;const o=W,n=new y.Mesh(t,o);return n.geometry.computeBoundingBox(),n.geometry.scale(1.01,1.01,1.01),n}function q(e,t){const o=e.translation(),n=e.rotation();t.position.set(o.x,o.y,o.z),t.quaternion.set(n.x,n.y,n.z,n.w)}const W=new y.MeshBasicMaterial({wireframe:!1,color:16711680,side:y.FrontSide});/*
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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-tiled-navmesh.d.ts","sourceRoot":"","sources":["../../../src/gameplay/ai/dynamic-tiled-navmesh.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OA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D3C,OAAO,CAAC,QAAQ;IA+BhB,SAAS,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,GAAE,OAAc;IAuE7H,aAAa,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW;IAU3D,uBAAuB,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,GAI/B,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC;IAG3C,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI;IAepC,OAAO;CASV"}
@@ -1,4 +1,4 @@
1
- import{NavMesh as t,NavMeshParams as s,Raw as e,UnsignedCharArray as i,recastConfigDefaults as o,statusToReadableString as n}from"recast-navigation";import{buildConfig as r,buildTile as a}from"./build-tile.js";import{Subject as h}from"rxjs";import{hasWorkerBuilder as l,createWorker as d}from"../../worker/index.js";import{hasSharedArrayBufferSupport as u}from"../../utils/buffer.js";export class DynamicTiledNavMesh{constructor(e){this.navMeshVersion=0,this.onNavMeshUpdate=new h,this.workerRoundRobin=0;const i=e.navMeshBounds.min,n=e.navMeshBounds.max,a=[i.toArray(),n.toArray()],u=e.navMeshBounds.min;this.navMeshBoundsMin=i,this.navMeshBoundsMax=n,this.navMeshBounds=a,this.navMeshOrigin=u,this.cacheId=e.cacheId;const c={...o,...e.recastConfig};this.recastConfig=c;const M=new t,{tileWidth:f,tileHeight:v,tcs:m,maxPolysPerTile:g}=r({recastConfig:c,navMeshBounds:a});this.tileWidth=f,this.tileHeight=v,this.tcs=m;const w=s.create({orig:u,tileWidth:c.tileSize*c.cs,tileHeight:c.tileSize*c.ch,maxTiles:e.maxTiles,maxPolys:g});if(M.initTiled(w),this.navMesh=M,this.workers=[],l())for(let t=0;t<e.workers;t++){const t=d();t.onmessage=t=>{this.onResult(t)},this.workers.push(t)}}onResult(t){const{tileX:s,tileY:o,navMeshData:r}=t.data,a=new i;a.copy(r),this.navMesh.removeTile(this.navMesh.getTileRefAt(s,o,0));const h=this.navMesh.addTile(a,e.Module.DT_TILE_FREE_DATA,0);e.Detour.statusFailed(h.status)&&(console.error(e.Module.RC_LOG_WARNING,`Failed to add tile to nav mesh\n\ttx: ${s}, ty: ${o},status: ${n(h.status)} (${h.status})`),a.destroy()),this.navMeshVersion++,this.onNavMeshUpdate.next([this.navMeshVersion,[s,o]])}buildTile(t,s,[e,i],o=!0){const n=u&&t.buffer instanceof window.SharedArrayBuffer,r=n?t:new Float32Array(t),h=n?s:new Uint32Array(s),l={tileX:e,tileY:i,tileBoundsMin:[this.navMeshBoundsMin.x+e*this.tcs,this.navMeshBoundsMin.y,this.navMeshBoundsMin.z+i*this.tcs],tileBoundsMax:[this.navMeshBoundsMax.x+(e+1)*this.tcs,this.navMeshBoundsMax.y,this.navMeshBoundsMax.z+(i+1)*this.tcs],recastConfig:this.recastConfig,navMeshBounds:this.navMeshBounds,keepIntermediates:!1,positions:r,indices:h};if(this.workers.length>0){this.workerRoundRobin=++this.workerRoundRobin%this.workers.length;return this.workers[this.workerRoundRobin].postMessage(l,n?void 0:[r.buffer,h.buffer]),Promise.resolve()}return new Promise((t=>{requestIdleCallback((()=>{const s=this.cacheId+JSON.stringify({tileX:l.tileX,tileY:l.tileY});if(o){const e=localStorage.getItem(s);if(null!=e){const s=M(e);return this.onResult({data:{tileX:l.tileX,tileY:l.tileY,navMeshData:s}}),void t({})}}else localStorage.removeItem(s);const e=a(l);if(!e.success||!e.data)return;const i=e.data.toTypedArray();localStorage.setItem(s,c(i)),this.onResult({data:{tileX:l.tileX,tileY:l.tileY,navMeshData:i}}),t(e)}))}))}buildAllTiles(t,s){const{tileWidth:e,tileHeight:i}=this;for(let o=0;o<i;o++)for(let i=0;i<e;i++)this.buildTile(t,s,[i,o])}getTileForWorldPosition(t){return[Math.floor((t.x-this.navMeshBoundsMin.x)/this.tcs),Math.floor((t.z-this.navMeshBoundsMin.z)/this.tcs)]}getTilesForBounds(t){const s=this.getTileForWorldPosition(t.min),e=this.getTileForWorldPosition(t.max),i=[];for(let t=s[1];t<=e[1];t++)for(let o=s[0];o<=e[0];o++)i.push([o,t]);return i}destroy(){this.navMesh.destroy();for(const t of this.workers)t.terminate()}}const c=function(t){return btoa(String.fromCharCode(...t))},M=function(t){if(!t)return null;const s=atob(t),e=s.length,i=new Uint8Array(e);for(let t=0;t<e;t++)i[t]=s.charCodeAt(t);return i};/*
1
+ import{NavMesh as t,NavMeshParams as s,Raw as e,UnsignedCharArray as i,recastConfigDefaults as o,statusToReadableString as n}from"recast-navigation";import{buildConfig as r,buildTile as a}from"./build-tile.js";import{Subject as h}from"rxjs";import{hasWorkerBuilder as l,createWorker as d}from"../../worker/index.js";import{hasSharedArrayBufferSupport as u}from"../../utils/buffer.js";const c=[];export class DynamicTiledNavMesh{constructor(e){this.navMeshVersion=0,this.onNavMeshUpdate=new h,this.workerRoundRobin=0;const i=e.navMeshBounds.min,n=e.navMeshBounds.max,a=[i.toArray(),n.toArray()],u=e.navMeshBounds.min;this.navMeshBoundsMin=i,this.navMeshBoundsMax=n,this.navMeshBounds=a,this.navMeshOrigin=u,this.cacheId=e.cacheId;const M={...o,...e.recastConfig};this.recastConfig=M;const f=new t,{tileWidth:v,tileHeight:m,tcs:g,maxPolysPerTile:w}=r({recastConfig:M,navMeshBounds:a});this.tileWidth=v,this.tileHeight=m,this.tcs=g;const B=s.create({orig:u,tileWidth:M.tileSize*M.cs,tileHeight:M.tileSize*M.ch,maxTiles:e.maxTiles,maxPolys:w});if(f.initTiled(B),this.navMesh=f,this.workers=[],l())for(let t=0;t<e.workers;t++){let t=c.pop();void 0===t&&(t=d()),t.onmessage=t=>{this.onResult(t)},this.workers.push(t)}}onResult(t){const{tileX:s,tileY:o,navMeshData:r}=t.data,a=new i;a.copy(r),this.navMesh.removeTile(this.navMesh.getTileRefAt(s,o,0));const h=this.navMesh.addTile(a,e.Module.DT_TILE_FREE_DATA,0);e.Detour.statusFailed(h.status)&&(console.error(e.Module.RC_LOG_WARNING,`Failed to add tile to nav mesh\n\ttx: ${s}, ty: ${o},status: ${n(h.status)} (${h.status})`),a.destroy()),this.navMeshVersion++,this.onNavMeshUpdate.next([this.navMeshVersion,[s,o]])}buildTile(t,s,[e,i],o=!0){const n=u&&t.buffer instanceof window.SharedArrayBuffer,r=n?t:new Float32Array(t),h=n?s:new Uint32Array(s),l={tileX:e,tileY:i,tileBoundsMin:[this.navMeshBoundsMin.x+e*this.tcs,this.navMeshBoundsMin.y,this.navMeshBoundsMin.z+i*this.tcs],tileBoundsMax:[this.navMeshBoundsMax.x+(e+1)*this.tcs,this.navMeshBoundsMax.y,this.navMeshBoundsMax.z+(i+1)*this.tcs],recastConfig:this.recastConfig,navMeshBounds:this.navMeshBounds,keepIntermediates:!1,positions:r,indices:h};if(this.workers.length>0){this.workerRoundRobin=++this.workerRoundRobin%this.workers.length;return this.workers[this.workerRoundRobin].postMessage(l,n?void 0:[r.buffer,h.buffer]),Promise.resolve()}return new Promise((t=>{requestIdleCallback((()=>{const s=this.cacheId+JSON.stringify({tileX:l.tileX,tileY:l.tileY});if(o){const e=localStorage.getItem(s);if(null!=e){const s=f(e);return this.onResult({data:{tileX:l.tileX,tileY:l.tileY,navMeshData:s}}),void t({})}}else localStorage.removeItem(s);const e=a(l);if(!e.success||!e.data)return;const i=e.data.toTypedArray();localStorage.setItem(s,M(i)),this.onResult({data:{tileX:l.tileX,tileY:l.tileY,navMeshData:i}}),t(e)}))}))}buildAllTiles(t,s){const{tileWidth:e,tileHeight:i}=this;for(let o=0;o<i;o++)for(let i=0;i<e;i++)this.buildTile(t,s,[i,o])}getTileForWorldPosition(t){return[Math.floor((t.x-this.navMeshBoundsMin.x)/this.tcs),Math.floor((t.z-this.navMeshBoundsMin.z)/this.tcs)]}getTilesForBounds(t){const s=this.getTileForWorldPosition(t.min),e=this.getTileForWorldPosition(t.max),i=[];for(let t=s[1];t<=e[1];t++)for(let o=s[0];o<=e[0];o++)i.push([o,t]);return i}destroy(){this.navMesh.destroy(),this.onNavMeshUpdate.complete();for(const t of this.workers)t.onmessage=null,c.push(t)}}const M=function(t){return btoa(String.fromCharCode(...t))},f=function(t){if(!t)return null;const s=atob(t),e=s.length,i=new Uint8Array(e);for(let t=0;t<e;t++)i[t]=s.charCodeAt(t);return i};/*
2
2
  * Copyright (©) 2023. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */