three-nebula 11.0.0 → 11.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/three-nebula.cjs +109 -0
- package/dist/three-nebula.cjs.map +1 -0
- package/dist/three-nebula.mjs +2969 -0
- package/dist/three-nebula.mjs.map +1 -0
- package/dist/three-nebula.umd.js +109 -0
- package/dist/three-nebula.umd.js.map +1 -0
- package/package.json +23 -47
- package/specs/01-emitter-hierarchy.md +200 -0
- package/specs/02-determinism-scrubbing.md +188 -0
- package/specs/03-sound-renderer.md +183 -0
- package/specs/04-schema-versioning.md +140 -0
- package/specs/05-content-addressed-assets.md +288 -0
- package/specs/README.md +80 -0
- package/build/cjs/behaviour/Alpha.js +0 -189
- package/build/cjs/behaviour/Attraction.js +0 -189
- package/build/cjs/behaviour/Behaviour.js +0 -253
- package/build/cjs/behaviour/Collision.js +0 -146
- package/build/cjs/behaviour/Color.js +0 -148
- package/build/cjs/behaviour/CrossZone.js +0 -141
- package/build/cjs/behaviour/Force.js +0 -126
- package/build/cjs/behaviour/Gravity.js +0 -78
- package/build/cjs/behaviour/RandomDrift.js +0 -153
- package/build/cjs/behaviour/Repulsion.js +0 -123
- package/build/cjs/behaviour/Rotate.js +0 -265
- package/build/cjs/behaviour/Scale.js +0 -177
- package/build/cjs/behaviour/Spring.js +0 -133
- package/build/cjs/behaviour/constants.js +0 -28
- package/build/cjs/behaviour/index.js +0 -112
- package/build/cjs/behaviour/types.js +0 -33
- package/build/cjs/constants/index.js +0 -61
- package/build/cjs/core/Particle.js +0 -390
- package/build/cjs/core/Pool.js +0 -203
- package/build/cjs/core/System.js +0 -366
- package/build/cjs/core/constants.js +0 -163
- package/build/cjs/core/fromJSON.js +0 -128
- package/build/cjs/core/fromJSONAsync.js +0 -239
- package/build/cjs/core/index.js +0 -32
- package/build/cjs/core/three/Euler.js +0 -233
- package/build/cjs/core/three/Math.js +0 -91
- package/build/cjs/core/three/Matrix4.js +0 -745
- package/build/cjs/core/three/Quaternion.js +0 -451
- package/build/cjs/core/three/Vector3.js +0 -464
- package/build/cjs/core/three/constants.js +0 -298
- package/build/cjs/core/three/index.js +0 -48
- package/build/cjs/core/types.js +0 -13
- package/build/cjs/debug/Debug.js +0 -209
- package/build/cjs/debug/constants.js +0 -19
- package/build/cjs/debug/index.js +0 -24
- package/build/cjs/debug/log.js +0 -38
- package/build/cjs/ease/index.js +0 -149
- package/build/cjs/emitter/Emitter.js +0 -798
- package/build/cjs/emitter/FollowEmitter.js +0 -146
- package/build/cjs/emitter/constants.js +0 -20
- package/build/cjs/emitter/index.js +0 -24
- package/build/cjs/emitter/types.js +0 -11
- package/build/cjs/events/EventDispatcher.js +0 -105
- package/build/cjs/events/constants.js +0 -23
- package/build/cjs/events/index.js +0 -27
- package/build/cjs/index.js +0 -151
- package/build/cjs/initializer/Body.js +0 -122
- package/build/cjs/initializer/BodySprite.js +0 -146
- package/build/cjs/initializer/Initializer.js +0 -109
- package/build/cjs/initializer/InitializerUtil.js +0 -54
- package/build/cjs/initializer/Life.js +0 -106
- package/build/cjs/initializer/Mass.js +0 -101
- package/build/cjs/initializer/Position.js +0 -152
- package/build/cjs/initializer/Radius.js +0 -118
- package/build/cjs/initializer/Rate.js +0 -150
- package/build/cjs/initializer/Rotation.js +0 -95
- package/build/cjs/initializer/Texture.js +0 -139
- package/build/cjs/initializer/Velocity/PolarVelocity.js +0 -102
- package/build/cjs/initializer/Velocity/RadialVelocity.js +0 -111
- package/build/cjs/initializer/Velocity/VectorVelocity.js +0 -108
- package/build/cjs/initializer/Velocity/Velocity.js +0 -94
- package/build/cjs/initializer/Velocity/index.js +0 -32
- package/build/cjs/initializer/constants.js +0 -43
- package/build/cjs/initializer/index.js +0 -108
- package/build/cjs/initializer/types.js +0 -37
- package/build/cjs/math/ArraySpan.js +0 -103
- package/build/cjs/math/Box.js +0 -46
- package/build/cjs/math/ColorSpan.js +0 -113
- package/build/cjs/math/MathUtils.js +0 -57
- package/build/cjs/math/Polar3D.js +0 -115
- package/build/cjs/math/Span.js +0 -88
- package/build/cjs/math/Vector3D.js +0 -76
- package/build/cjs/math/constants.js +0 -35
- package/build/cjs/math/index.js +0 -122
- package/build/cjs/math/integration.js +0 -59
- package/build/cjs/math/types.js +0 -19
- package/build/cjs/renderer/BaseRenderer.js +0 -108
- package/build/cjs/renderer/CustomRenderer.js +0 -65
- package/build/cjs/renderer/GPURenderer/Desktop/index.js +0 -371
- package/build/cjs/renderer/GPURenderer/Desktop/shaders/fragmentShader.js +0 -13
- package/build/cjs/renderer/GPURenderer/Desktop/shaders/index.js +0 -22
- package/build/cjs/renderer/GPURenderer/Desktop/shaders/vertexShader.js +0 -17
- package/build/cjs/renderer/GPURenderer/Mobile/index.js +0 -385
- package/build/cjs/renderer/GPURenderer/Mobile/shaders/fragmentShader.js +0 -13
- package/build/cjs/renderer/GPURenderer/Mobile/shaders/index.js +0 -22
- package/build/cjs/renderer/GPURenderer/Mobile/shaders/vertexShader.js +0 -15
- package/build/cjs/renderer/GPURenderer/common/ParticleBuffer/constants.js +0 -58
- package/build/cjs/renderer/GPURenderer/common/ParticleBuffer/index.js +0 -93
- package/build/cjs/renderer/GPURenderer/common/TextureAtlas/constants.js +0 -9
- package/build/cjs/renderer/GPURenderer/common/TextureAtlas/index.js +0 -221
- package/build/cjs/renderer/GPURenderer/common/constants.js +0 -22
- package/build/cjs/renderer/GPURenderer/common/index.js +0 -38
- package/build/cjs/renderer/GPURenderer/common/shaders/constants.js +0 -9
- package/build/cjs/renderer/GPURenderer/common/stores/Target.js +0 -45
- package/build/cjs/renderer/GPURenderer/common/stores/UniqueList.js +0 -51
- package/build/cjs/renderer/GPURenderer/common/stores/index.js +0 -22
- package/build/cjs/renderer/GPURenderer/index.js +0 -97
- package/build/cjs/renderer/MeshRenderer.js +0 -136
- package/build/cjs/renderer/SpriteRenderer.js +0 -68
- package/build/cjs/renderer/index.js +0 -40
- package/build/cjs/renderer/types.js +0 -21
- package/build/cjs/utils/ColorUtil.js +0 -39
- package/build/cjs/utils/PUID.js +0 -26
- package/build/cjs/utils/THREEUtil.js +0 -40
- package/build/cjs/utils/Util.js +0 -69
- package/build/cjs/utils/index.js +0 -61
- package/build/cjs/utils/uid.js +0 -12
- package/build/cjs/zone/BoxZone.js +0 -178
- package/build/cjs/zone/LineZone.js +0 -101
- package/build/cjs/zone/MeshZone.js +0 -101
- package/build/cjs/zone/PointZone.js +0 -99
- package/build/cjs/zone/ScreenZone.js +0 -164
- package/build/cjs/zone/SphereZone.js +0 -155
- package/build/cjs/zone/Zone.js +0 -172
- package/build/cjs/zone/index.js +0 -56
- package/build/cjs/zone/types.js +0 -21
- package/build/esm/behaviour/Alpha.js +0 -134
- package/build/esm/behaviour/Attraction.js +0 -135
- package/build/esm/behaviour/Behaviour.js +0 -215
- package/build/esm/behaviour/Collision.js +0 -100
- package/build/esm/behaviour/Color.js +0 -101
- package/build/esm/behaviour/CrossZone.js +0 -82
- package/build/esm/behaviour/Force.js +0 -83
- package/build/esm/behaviour/Gravity.js +0 -40
- package/build/esm/behaviour/RandomDrift.js +0 -97
- package/build/esm/behaviour/Repulsion.js +0 -81
- package/build/esm/behaviour/Rotate.js +0 -214
- package/build/esm/behaviour/Scale.js +0 -131
- package/build/esm/behaviour/Spring.js +0 -90
- package/build/esm/behaviour/constants.js +0 -11
- package/build/esm/behaviour/index.js +0 -14
- package/build/esm/behaviour/types.js +0 -14
- package/build/esm/constants/index.js +0 -42
- package/build/esm/core/Particle.js +0 -357
- package/build/esm/core/Pool.js +0 -161
- package/build/esm/core/System.js +0 -320
- package/build/esm/core/constants.js +0 -127
- package/build/esm/core/fromJSON.js +0 -107
- package/build/esm/core/fromJSONAsync.js +0 -210
- package/build/esm/core/index.js +0 -4
- package/build/esm/core/three/Euler.js +0 -224
- package/build/esm/core/three/Math.js +0 -84
- package/build/esm/core/three/Matrix4.js +0 -739
- package/build/esm/core/three/Quaternion.js +0 -445
- package/build/esm/core/three/Vector3.js +0 -457
- package/build/esm/core/three/constants.js +0 -148
- package/build/esm/core/three/index.js +0 -5
- package/build/esm/core/types.js +0 -4
- package/build/esm/debug/Debug.js +0 -195
- package/build/esm/debug/constants.js +0 -7
- package/build/esm/debug/index.js +0 -3
- package/build/esm/debug/log.js +0 -31
- package/build/esm/ease/index.js +0 -113
- package/build/esm/emitter/Emitter.js +0 -708
- package/build/esm/emitter/FollowEmitter.js +0 -97
- package/build/esm/emitter/constants.js +0 -7
- package/build/esm/emitter/index.js +0 -3
- package/build/esm/emitter/types.js +0 -3
- package/build/esm/events/EventDispatcher.js +0 -82
- package/build/esm/events/constants.js +0 -9
- package/build/esm/events/index.js +0 -4
- package/build/esm/index.js +0 -13
- package/build/esm/initializer/Body.js +0 -83
- package/build/esm/initializer/BodySprite.js +0 -108
- package/build/esm/initializer/Initializer.js +0 -84
- package/build/esm/initializer/InitializerUtil.js +0 -48
- package/build/esm/initializer/Life.js +0 -66
- package/build/esm/initializer/Mass.js +0 -60
- package/build/esm/initializer/Position.js +0 -98
- package/build/esm/initializer/Radius.js +0 -75
- package/build/esm/initializer/Rate.js +0 -107
- package/build/esm/initializer/Rotation.js +0 -54
- package/build/esm/initializer/Texture.js +0 -101
- package/build/esm/initializer/Velocity/PolarVelocity.js +0 -63
- package/build/esm/initializer/Velocity/RadialVelocity.js +0 -72
- package/build/esm/initializer/Velocity/VectorVelocity.js +0 -69
- package/build/esm/initializer/Velocity/Velocity.js +0 -52
- package/build/esm/initializer/Velocity/index.js +0 -4
- package/build/esm/initializer/constants.js +0 -26
- package/build/esm/initializer/index.js +0 -12
- package/build/esm/initializer/types.js +0 -16
- package/build/esm/math/ArraySpan.js +0 -62
- package/build/esm/math/Box.js +0 -25
- package/build/esm/math/ColorSpan.js +0 -71
- package/build/esm/math/MathUtils.js +0 -48
- package/build/esm/math/Polar3D.js +0 -81
- package/build/esm/math/Span.js +0 -63
- package/build/esm/math/Vector3D.js +0 -34
- package/build/esm/math/constants.js +0 -24
- package/build/esm/math/index.js +0 -10
- package/build/esm/math/integration.js +0 -47
- package/build/esm/math/types.js +0 -7
- package/build/esm/renderer/BaseRenderer.js +0 -78
- package/build/esm/renderer/CustomRenderer.js +0 -23
- package/build/esm/renderer/GPURenderer/Desktop/index.js +0 -357
- package/build/esm/renderer/GPURenderer/Desktop/shaders/fragmentShader.js +0 -30
- package/build/esm/renderer/GPURenderer/Desktop/shaders/index.js +0 -3
- package/build/esm/renderer/GPURenderer/Desktop/shaders/vertexShader.js +0 -36
- package/build/esm/renderer/GPURenderer/Mobile/index.js +0 -375
- package/build/esm/renderer/GPURenderer/Mobile/shaders/fragmentShader.js +0 -27
- package/build/esm/renderer/GPURenderer/Mobile/shaders/index.js +0 -3
- package/build/esm/renderer/GPURenderer/Mobile/shaders/vertexShader.js +0 -33
- package/build/esm/renderer/GPURenderer/common/ParticleBuffer/constants.js +0 -30
- package/build/esm/renderer/GPURenderer/common/ParticleBuffer/index.js +0 -70
- package/build/esm/renderer/GPURenderer/common/TextureAtlas/constants.js +0 -2
- package/build/esm/renderer/GPURenderer/common/TextureAtlas/index.js +0 -206
- package/build/esm/renderer/GPURenderer/common/constants.js +0 -13
- package/build/esm/renderer/GPURenderer/common/index.js +0 -4
- package/build/esm/renderer/GPURenderer/common/shaders/constants.js +0 -2
- package/build/esm/renderer/GPURenderer/common/stores/Target.js +0 -26
- package/build/esm/renderer/GPURenderer/common/stores/UniqueList.js +0 -29
- package/build/esm/renderer/GPURenderer/common/stores/index.js +0 -3
- package/build/esm/renderer/GPURenderer/index.js +0 -57
- package/build/esm/renderer/MeshRenderer.js +0 -93
- package/build/esm/renderer/SpriteRenderer.js +0 -30
- package/build/esm/renderer/index.js +0 -5
- package/build/esm/renderer/types.js +0 -8
- package/build/esm/utils/ColorUtil.js +0 -32
- package/build/esm/utils/PUID.js +0 -19
- package/build/esm/utils/THREEUtil.js +0 -31
- package/build/esm/utils/Util.js +0 -60
- package/build/esm/utils/index.js +0 -13
- package/build/esm/utils/uid.js +0 -3
- package/build/esm/zone/BoxZone.js +0 -133
- package/build/esm/zone/LineZone.js +0 -61
- package/build/esm/zone/MeshZone.js +0 -60
- package/build/esm/zone/PointZone.js +0 -59
- package/build/esm/zone/ScreenZone.js +0 -116
- package/build/esm/zone/SphereZone.js +0 -113
- package/build/esm/zone/Zone.js +0 -141
- package/build/esm/zone/index.js +0 -7
- package/build/esm/zone/types.js +0 -8
- package/build/three-nebula.js +0 -2
- package/build/three-nebula.js.map +0 -1
|
@@ -0,0 +1,2969 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in e) t(r, i, {
|
|
5
|
+
get: e[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, c = (e, i, o, s) => {
|
|
10
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
+
get: ((e) => i[e]).bind(null, d),
|
|
12
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
+
});
|
|
14
|
+
return e;
|
|
15
|
+
}, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
|
|
16
|
+
value: n,
|
|
17
|
+
enumerable: !0
|
|
18
|
+
}) : a, n)), u = "Behaviour", d = "Alpha", f = "Attraction", p = "Collision", m = "Color", h = "CrossZone", g = "Force", _ = "Gravity", v = "RandomDrift", y = "Repulsion", b = "Rotate", x = "Scale", S = "Spring", C = "Initializer", w = "Body", T = "BodySprite", E = "Texture", D = "Life", O = "Mass", k = "Position", A = "Rotation", j = "Radius", M = "VectorVelocity", N = "PolarVelocity", ee = "RadialVelocity", te = "Rate", P = [T, E], ne = "Zone", re = "BoxZone", ie = "LineZone", ae = "MeshZone", oe = "PointZone", se = "ScreenZone", ce = "SphereZone", le = "BaseRenderer", ue = "CustomRenderer", de = "SpriteRenderer", fe = "MeshRenderer", pe = "GPURenderer", me = "MobileGPURenderer", he = "DesktopGPURenderer", F = 3.142, I = F / 180, ge = "euler", _e = () => !(!process || !process.env || !process.env.NODE_ENV || process.env.NODE_ENV !== "development"), L = {
|
|
19
|
+
easeLinear: function(e) {
|
|
20
|
+
return e;
|
|
21
|
+
},
|
|
22
|
+
easeInQuad: function(e) {
|
|
23
|
+
return e ** 2;
|
|
24
|
+
},
|
|
25
|
+
easeOutQuad: function(e) {
|
|
26
|
+
return -((e - 1) ** 2 - 1);
|
|
27
|
+
},
|
|
28
|
+
easeInOutQuad: function(e) {
|
|
29
|
+
return (e /= .5) < 1 ? .5 * e ** 2 : -.5 * ((e -= 2) * e - 2);
|
|
30
|
+
},
|
|
31
|
+
easeInCubic: function(e) {
|
|
32
|
+
return e ** 3;
|
|
33
|
+
},
|
|
34
|
+
easeOutCubic: function(e) {
|
|
35
|
+
return (e - 1) ** 3 + 1;
|
|
36
|
+
},
|
|
37
|
+
easeInOutCubic: function(e) {
|
|
38
|
+
return (e /= .5) < 1 ? .5 * e ** 3 : .5 * ((e - 2) ** 3 + 2);
|
|
39
|
+
},
|
|
40
|
+
easeInQuart: function(e) {
|
|
41
|
+
return e ** 4;
|
|
42
|
+
},
|
|
43
|
+
easeOutQuart: function(e) {
|
|
44
|
+
return -((e - 1) ** 4 - 1);
|
|
45
|
+
},
|
|
46
|
+
easeInOutQuart: function(e) {
|
|
47
|
+
return (e /= .5) < 1 ? .5 * e ** 4 : -.5 * ((e -= 2) * e ** 3 - 2);
|
|
48
|
+
},
|
|
49
|
+
easeInSine: function(e) {
|
|
50
|
+
return -Math.cos(F / 2 * e) + 1;
|
|
51
|
+
},
|
|
52
|
+
easeOutSine: function(e) {
|
|
53
|
+
return Math.sin(F / 2 * e);
|
|
54
|
+
},
|
|
55
|
+
easeInOutSine: function(e) {
|
|
56
|
+
return -.5 * (Math.cos(F * e) - 1);
|
|
57
|
+
},
|
|
58
|
+
easeInExpo: function(e) {
|
|
59
|
+
return e === 0 ? 0 : 2 ** (10 * (e - 1));
|
|
60
|
+
},
|
|
61
|
+
easeOutExpo: function(e) {
|
|
62
|
+
return e === 1 ? 1 : -(2 ** (-10 * e)) + 1;
|
|
63
|
+
},
|
|
64
|
+
easeInOutExpo: function(e) {
|
|
65
|
+
return e === 0 ? 0 : e === 1 ? 1 : (e /= .5) < 1 ? .5 * 2 ** (10 * (e - 1)) : .5 * (-(2 ** (-10 * --e)) + 2);
|
|
66
|
+
},
|
|
67
|
+
easeInCirc: function(e) {
|
|
68
|
+
return -(Math.sqrt(1 - e * e) - 1);
|
|
69
|
+
},
|
|
70
|
+
easeOutCirc: function(e) {
|
|
71
|
+
return Math.sqrt(1 - (e - 1) ** 2);
|
|
72
|
+
},
|
|
73
|
+
easeInOutCirc: function(e) {
|
|
74
|
+
return (e /= .5) < 1 ? -.5 * (Math.sqrt(1 - e * e) - 1) : .5 * (Math.sqrt(1 - (e -= 2) * e) + 1);
|
|
75
|
+
},
|
|
76
|
+
easeInBack: function(e) {
|
|
77
|
+
var t = 1.70158;
|
|
78
|
+
return e * e * ((t + 1) * e - t);
|
|
79
|
+
},
|
|
80
|
+
easeOutBack: function(e) {
|
|
81
|
+
var t = 1.70158;
|
|
82
|
+
return --e * e * ((t + 1) * e + t) + 1;
|
|
83
|
+
},
|
|
84
|
+
easeInOutBack: function(e) {
|
|
85
|
+
var t = 1.70158;
|
|
86
|
+
return (e /= .5) < 1 ? .5 * (e * e * (((t *= 1.525) + 1) * e - t)) : .5 * ((e -= 2) * e * (((t *= 1.525) + 1) * e + t) + 2);
|
|
87
|
+
}
|
|
88
|
+
}, { easeLinear: ve, easeInQuad: ye, easeOutQuad: be, easeInOutQuad: xe, easeInCubic: Se, easeOutCubic: Ce, easeInOutCubic: we, easeInQuart: Te, easeOutQuart: Ee, easeInOutQuart: De, easeInSine: Oe, easeOutSine: ke, easeInOutSine: Ae, easeInExpo: je, easeOutExpo: Me, easeInOutExpo: Ne, easeInCirc: Pe, easeOutCirc: Fe, easeInOutCirc: Ie, easeInBack: Le, easeOutBack: Re, easeInOutBack: ze } = L, Be = (e) => L[e] ? L[e] : L.easeLinear, R = (e) => L[e] ? L[e] : L.easeLinear, Ve = Infinity, He = ve, Ue = .0167, We = [
|
|
89
|
+
k,
|
|
90
|
+
A,
|
|
91
|
+
D,
|
|
92
|
+
j,
|
|
93
|
+
O,
|
|
94
|
+
w,
|
|
95
|
+
T,
|
|
96
|
+
E,
|
|
97
|
+
N,
|
|
98
|
+
ee,
|
|
99
|
+
M
|
|
100
|
+
], Ge = [
|
|
101
|
+
d,
|
|
102
|
+
f,
|
|
103
|
+
m,
|
|
104
|
+
h,
|
|
105
|
+
g,
|
|
106
|
+
_,
|
|
107
|
+
v,
|
|
108
|
+
y,
|
|
109
|
+
b,
|
|
110
|
+
x,
|
|
111
|
+
S
|
|
112
|
+
], Ke = [
|
|
113
|
+
re,
|
|
114
|
+
ie,
|
|
115
|
+
ae,
|
|
116
|
+
oe,
|
|
117
|
+
ce
|
|
118
|
+
], qe = { getRGB: function(e) {
|
|
119
|
+
var t = {};
|
|
120
|
+
if (typeof e == "number") r = Math.floor(e), t.r = (e >> 16 & 255) / 255, t.g = (e >> 8 & 255) / 255, t.b = (e & 255) / 255;
|
|
121
|
+
else if (typeof e == "string") {
|
|
122
|
+
var n;
|
|
123
|
+
if (n = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(e)) t.r = Math.min(255, parseInt(n[1], 10)) / 255, t.g = Math.min(255, parseInt(n[2], 10)) / 255, t.b = Math.min(255, parseInt(n[3], 10)) / 255;
|
|
124
|
+
else if (n = /^\#([A-Fa-f0-9]+)$/.exec(e)) {
|
|
125
|
+
var r = n[1];
|
|
126
|
+
t.r = parseInt(r.charAt(0) + r.charAt(1), 16) / 255, t.g = parseInt(r.charAt(2) + r.charAt(3), 16) / 255, t.b = parseInt(r.charAt(4) + r.charAt(5), 16) / 255;
|
|
127
|
+
}
|
|
128
|
+
} else t.r = e.r, t.g = e.g, t.b = e.b;
|
|
129
|
+
return t;
|
|
130
|
+
} }, Je = {
|
|
131
|
+
_id: 0,
|
|
132
|
+
_uids: /* @__PURE__ */ new Map(),
|
|
133
|
+
getNewId: function() {
|
|
134
|
+
return `PUID_${++this._id}`;
|
|
135
|
+
},
|
|
136
|
+
id: function(e) {
|
|
137
|
+
if (this._uids.has(e)) return this._uids.get(e);
|
|
138
|
+
let t = this.getNewId();
|
|
139
|
+
return this._uids.set(e, t), t;
|
|
140
|
+
}
|
|
141
|
+
}, Ye = {
|
|
142
|
+
DEG2RAD: Math.PI / 180,
|
|
143
|
+
RAD2DEG: 180 / Math.PI,
|
|
144
|
+
generateUUID: (function() {
|
|
145
|
+
for (var e = [], t = 0; t < 256; t++) e[t] = (t < 16 ? "0" : "") + t.toString(16);
|
|
146
|
+
return function() {
|
|
147
|
+
var t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0, r = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0;
|
|
148
|
+
return (e[t & 255] + e[t >> 8 & 255] + e[t >> 16 & 255] + e[t >> 24 & 255] + "-" + e[n & 255] + e[n >> 8 & 255] + "-" + e[n >> 16 & 15 | 64] + e[n >> 24 & 255] + "-" + e[r & 63 | 128] + e[r >> 8 & 255] + "-" + e[r >> 16 & 255] + e[r >> 24 & 255] + e[i & 255] + e[i >> 8 & 255] + e[i >> 16 & 255] + e[i >> 24 & 255]).toUpperCase();
|
|
149
|
+
};
|
|
150
|
+
})(),
|
|
151
|
+
clamp: function(e, t, n) {
|
|
152
|
+
return Math.max(t, Math.min(n, e));
|
|
153
|
+
},
|
|
154
|
+
euclideanModulo: function(e, t) {
|
|
155
|
+
return (e % t + t) % t;
|
|
156
|
+
},
|
|
157
|
+
mapLinear: function(e, t, n, r, i) {
|
|
158
|
+
return r + (e - t) * (i - r) / (n - t);
|
|
159
|
+
},
|
|
160
|
+
lerp: function(e, t, n) {
|
|
161
|
+
return (1 - n) * e + n * t;
|
|
162
|
+
},
|
|
163
|
+
smoothstep: function(e, t, n) {
|
|
164
|
+
return e <= t ? 0 : e >= n ? 1 : (e = (e - t) / (n - t), e * e * (3 - 2 * e));
|
|
165
|
+
},
|
|
166
|
+
smootherstep: function(e, t, n) {
|
|
167
|
+
return e <= t ? 0 : e >= n ? 1 : (e = (e - t) / (n - t), e * e * e * (e * (e * 6 - 15) + 10));
|
|
168
|
+
},
|
|
169
|
+
randInt: function(e, t) {
|
|
170
|
+
return e + Math.floor(Math.random() * (t - e + 1));
|
|
171
|
+
},
|
|
172
|
+
randFloat: function(e, t) {
|
|
173
|
+
return e + Math.random() * (t - e);
|
|
174
|
+
},
|
|
175
|
+
randFloatSpread: function(e) {
|
|
176
|
+
return e * (.5 - Math.random());
|
|
177
|
+
},
|
|
178
|
+
degToRad: function(e) {
|
|
179
|
+
return e * Ye.DEG2RAD;
|
|
180
|
+
},
|
|
181
|
+
radToDeg: function(e) {
|
|
182
|
+
return e * Ye.RAD2DEG;
|
|
183
|
+
},
|
|
184
|
+
isPowerOfTwo: function(e) {
|
|
185
|
+
return (e & e - 1) == 0 && e !== 0;
|
|
186
|
+
},
|
|
187
|
+
ceilPowerOfTwo: function(e) {
|
|
188
|
+
return 2 ** Math.ceil(Math.log(e) / Math.LN2);
|
|
189
|
+
},
|
|
190
|
+
floorPowerOfTwo: function(e) {
|
|
191
|
+
return 2 ** Math.floor(Math.log(e) / Math.LN2);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/core/three/Quaternion.js
|
|
196
|
+
function z(e, t, n, r) {
|
|
197
|
+
this._x = e || 0, this._y = t || 0, this._z = n || 0, this._w = r === void 0 ? 1 : r;
|
|
198
|
+
}
|
|
199
|
+
Object.assign(z, {
|
|
200
|
+
slerp: function(e, t, n, r) {
|
|
201
|
+
return n.copy(e).slerp(t, r);
|
|
202
|
+
},
|
|
203
|
+
slerpFlat: function(e, t, n, r, i, a, o) {
|
|
204
|
+
var s = n[r + 0], c = n[r + 1], l = n[r + 2], u = n[r + 3], d = i[a + 0], f = i[a + 1], p = i[a + 2], m = i[a + 3];
|
|
205
|
+
if (u !== m || s !== d || c !== f || l !== p) {
|
|
206
|
+
var h = 1 - o, g = s * d + c * f + l * p + u * m, _ = g >= 0 ? 1 : -1, v = 1 - g * g;
|
|
207
|
+
if (v > 2 ** -52) {
|
|
208
|
+
var y = Math.sqrt(v), b = Math.atan2(y, g * _);
|
|
209
|
+
h = Math.sin(h * b) / y, o = Math.sin(o * b) / y;
|
|
210
|
+
}
|
|
211
|
+
var x = o * _;
|
|
212
|
+
if (s = s * h + d * x, c = c * h + f * x, l = l * h + p * x, u = u * h + m * x, h === 1 - o) {
|
|
213
|
+
var S = 1 / Math.sqrt(s * s + c * c + l * l + u * u);
|
|
214
|
+
s *= S, c *= S, l *= S, u *= S;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
e[t] = s, e[t + 1] = c, e[t + 2] = l, e[t + 3] = u;
|
|
218
|
+
}
|
|
219
|
+
}), Object.defineProperties(z.prototype, {
|
|
220
|
+
x: {
|
|
221
|
+
get: function() {
|
|
222
|
+
return this._x;
|
|
223
|
+
},
|
|
224
|
+
set: function(e) {
|
|
225
|
+
this._x = e, this._onChangeCallback();
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
y: {
|
|
229
|
+
get: function() {
|
|
230
|
+
return this._y;
|
|
231
|
+
},
|
|
232
|
+
set: function(e) {
|
|
233
|
+
this._y = e, this._onChangeCallback();
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
z: {
|
|
237
|
+
get: function() {
|
|
238
|
+
return this._z;
|
|
239
|
+
},
|
|
240
|
+
set: function(e) {
|
|
241
|
+
this._z = e, this._onChangeCallback();
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
w: {
|
|
245
|
+
get: function() {
|
|
246
|
+
return this._w;
|
|
247
|
+
},
|
|
248
|
+
set: function(e) {
|
|
249
|
+
this._w = e, this._onChangeCallback();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}), Object.assign(z.prototype, {
|
|
253
|
+
isQuaternion: !0,
|
|
254
|
+
set: function(e, t, n, r) {
|
|
255
|
+
return this._x = e, this._y = t, this._z = n, this._w = r, this._onChangeCallback(), this;
|
|
256
|
+
},
|
|
257
|
+
clone: function() {
|
|
258
|
+
return new this.constructor(this._x, this._y, this._z, this._w);
|
|
259
|
+
},
|
|
260
|
+
copy: function(e) {
|
|
261
|
+
return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;
|
|
262
|
+
},
|
|
263
|
+
setFromEuler: function(e, t) {
|
|
264
|
+
if (!(e && e.isEuler)) throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");
|
|
265
|
+
var n = e._x, r = e._y, i = e._z, a = e.order, o = Math.cos, s = Math.sin, c = o(n / 2), l = o(r / 2), u = o(i / 2), d = s(n / 2), f = s(r / 2), p = s(i / 2);
|
|
266
|
+
return a === "XYZ" ? (this._x = d * l * u + c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u - d * f * p) : a === "YXZ" ? (this._x = d * l * u + c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u + d * f * p) : a === "ZXY" ? (this._x = d * l * u - c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u - d * f * p) : a === "ZYX" ? (this._x = d * l * u - c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u + d * f * p) : a === "YZX" ? (this._x = d * l * u + c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u - d * f * p) : a === "XZY" && (this._x = d * l * u - c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u + d * f * p), t !== !1 && this._onChangeCallback(), this;
|
|
267
|
+
},
|
|
268
|
+
setFromAxisAngle: function(e, t) {
|
|
269
|
+
var n = t / 2, r = Math.sin(n);
|
|
270
|
+
return this._x = e.x * r, this._y = e.y * r, this._z = e.z * r, this._w = Math.cos(n), this._onChangeCallback(), this;
|
|
271
|
+
},
|
|
272
|
+
setFromRotationMatrix: function(e) {
|
|
273
|
+
var t = e.elements, n = t[0], r = t[4], i = t[8], a = t[1], o = t[5], s = t[9], c = t[2], l = t[6], u = t[10], d = n + o + u, f;
|
|
274
|
+
return d > 0 ? (f = .5 / Math.sqrt(d + 1), this._w = .25 / f, this._x = (l - s) * f, this._y = (i - c) * f, this._z = (a - r) * f) : n > o && n > u ? (f = 2 * Math.sqrt(1 + n - o - u), this._w = (l - s) / f, this._x = .25 * f, this._y = (r + a) / f, this._z = (i + c) / f) : o > u ? (f = 2 * Math.sqrt(1 + o - n - u), this._w = (i - c) / f, this._x = (r + a) / f, this._y = .25 * f, this._z = (s + l) / f) : (f = 2 * Math.sqrt(1 + u - n - o), this._w = (a - r) / f, this._x = (i + c) / f, this._y = (s + l) / f, this._z = .25 * f), this._onChangeCallback(), this;
|
|
275
|
+
},
|
|
276
|
+
setFromUnitVectors: function(e, t) {
|
|
277
|
+
var n = 1e-6, r = e.dot(t) + 1;
|
|
278
|
+
return r < n ? (r = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = r) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = r)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = r), this.normalize();
|
|
279
|
+
},
|
|
280
|
+
angleTo: function(e) {
|
|
281
|
+
return 2 * Math.acos(Math.abs(Ye.clamp(this.dot(e), -1, 1)));
|
|
282
|
+
},
|
|
283
|
+
rotateTowards: function(e, t) {
|
|
284
|
+
var n = this.angleTo(e);
|
|
285
|
+
if (n === 0) return this;
|
|
286
|
+
var r = Math.min(1, t / n);
|
|
287
|
+
return this.slerp(e, r), this;
|
|
288
|
+
},
|
|
289
|
+
inverse: function() {
|
|
290
|
+
return this.conjugate();
|
|
291
|
+
},
|
|
292
|
+
conjugate: function() {
|
|
293
|
+
return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
|
|
294
|
+
},
|
|
295
|
+
dot: function(e) {
|
|
296
|
+
return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
|
|
297
|
+
},
|
|
298
|
+
lengthSq: function() {
|
|
299
|
+
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
|
|
300
|
+
},
|
|
301
|
+
length: function() {
|
|
302
|
+
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
|
|
303
|
+
},
|
|
304
|
+
normalize: function() {
|
|
305
|
+
var e = this.length();
|
|
306
|
+
return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x *= e, this._y *= e, this._z *= e, this._w *= e), this._onChangeCallback(), this;
|
|
307
|
+
},
|
|
308
|
+
multiply: function(e, t) {
|
|
309
|
+
return t === void 0 ? this.multiplyQuaternions(this, e) : (console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), this.multiplyQuaternions(e, t));
|
|
310
|
+
},
|
|
311
|
+
premultiply: function(e) {
|
|
312
|
+
return this.multiplyQuaternions(e, this);
|
|
313
|
+
},
|
|
314
|
+
multiplyQuaternions: function(e, t) {
|
|
315
|
+
var n = e._x, r = e._y, i = e._z, a = e._w, o = t._x, s = t._y, c = t._z, l = t._w;
|
|
316
|
+
return this._x = n * l + a * o + r * c - i * s, this._y = r * l + a * s + i * o - n * c, this._z = i * l + a * c + n * s - r * o, this._w = a * l - n * o - r * s - i * c, this._onChangeCallback(), this;
|
|
317
|
+
},
|
|
318
|
+
slerp: function(e, t) {
|
|
319
|
+
if (t === 0) return this;
|
|
320
|
+
if (t === 1) return this.copy(e);
|
|
321
|
+
var n = this._x, r = this._y, i = this._z, a = this._w, o = a * e._w + n * e._x + r * e._y + i * e._z;
|
|
322
|
+
if (o < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, o = -o) : this.copy(e), o >= 1) return this._w = a, this._x = n, this._y = r, this._z = i, this;
|
|
323
|
+
var s = 1 - o * o;
|
|
324
|
+
if (s <= 2 ** -52) {
|
|
325
|
+
var c = 1 - t;
|
|
326
|
+
return this._w = c * a + t * this._w, this._x = c * n + t * this._x, this._y = c * r + t * this._y, this._z = c * i + t * this._z, this.normalize(), this._onChangeCallback(), this;
|
|
327
|
+
}
|
|
328
|
+
var l = Math.sqrt(s), u = Math.atan2(l, o), d = Math.sin((1 - t) * u) / l, f = Math.sin(t * u) / l;
|
|
329
|
+
return this._w = a * d + this._w * f, this._x = n * d + this._x * f, this._y = r * d + this._y * f, this._z = i * d + this._z * f, this._onChangeCallback(), this;
|
|
330
|
+
},
|
|
331
|
+
equals: function(e) {
|
|
332
|
+
return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
|
|
333
|
+
},
|
|
334
|
+
fromArray: function(e, t) {
|
|
335
|
+
return t === void 0 && (t = 0), this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this;
|
|
336
|
+
},
|
|
337
|
+
toArray: function(e, t) {
|
|
338
|
+
return e === void 0 && (e = []), t === void 0 && (t = 0), e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e;
|
|
339
|
+
},
|
|
340
|
+
_onChange: function(e) {
|
|
341
|
+
return this._onChangeCallback = e, this;
|
|
342
|
+
},
|
|
343
|
+
_onChangeCallback: function() {}
|
|
344
|
+
});
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/core/three/Vector3.js
|
|
347
|
+
function B(e, t, n) {
|
|
348
|
+
this.x = e || 0, this.y = t || 0, this.z = n || 0;
|
|
349
|
+
}
|
|
350
|
+
Object.assign(B.prototype, {
|
|
351
|
+
isVector3: !0,
|
|
352
|
+
set: function(e, t, n) {
|
|
353
|
+
return this.x = e, this.y = t, this.z = n, this;
|
|
354
|
+
},
|
|
355
|
+
setScalar: function(e) {
|
|
356
|
+
return this.x = e, this.y = e, this.z = e, this;
|
|
357
|
+
},
|
|
358
|
+
setX: function(e) {
|
|
359
|
+
return this.x = e, this;
|
|
360
|
+
},
|
|
361
|
+
setY: function(e) {
|
|
362
|
+
return this.y = e, this;
|
|
363
|
+
},
|
|
364
|
+
setZ: function(e) {
|
|
365
|
+
return this.z = e, this;
|
|
366
|
+
},
|
|
367
|
+
setComponent: function(e, t) {
|
|
368
|
+
switch (e) {
|
|
369
|
+
case 0:
|
|
370
|
+
this.x = t;
|
|
371
|
+
break;
|
|
372
|
+
case 1:
|
|
373
|
+
this.y = t;
|
|
374
|
+
break;
|
|
375
|
+
case 2:
|
|
376
|
+
this.z = t;
|
|
377
|
+
break;
|
|
378
|
+
default: throw Error("index is out of range: " + e);
|
|
379
|
+
}
|
|
380
|
+
return this;
|
|
381
|
+
},
|
|
382
|
+
getComponent: function(e) {
|
|
383
|
+
switch (e) {
|
|
384
|
+
case 0: return this.x;
|
|
385
|
+
case 1: return this.y;
|
|
386
|
+
case 2: return this.z;
|
|
387
|
+
default: throw Error("index is out of range: " + e);
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
clone: function() {
|
|
391
|
+
return new this.constructor(this.x, this.y, this.z);
|
|
392
|
+
},
|
|
393
|
+
copy: function(e) {
|
|
394
|
+
return this.x = e.x, this.y = e.y, this.z = e.z, this;
|
|
395
|
+
},
|
|
396
|
+
add: function(e, t) {
|
|
397
|
+
return t === void 0 ? (this.x += e.x, this.y += e.y, this.z += e.z, this) : (console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t));
|
|
398
|
+
},
|
|
399
|
+
addScalar: function(e) {
|
|
400
|
+
return this.x += e, this.y += e, this.z += e, this;
|
|
401
|
+
},
|
|
402
|
+
addVectors: function(e, t) {
|
|
403
|
+
return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;
|
|
404
|
+
},
|
|
405
|
+
addScaledVector: function(e, t) {
|
|
406
|
+
return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;
|
|
407
|
+
},
|
|
408
|
+
sub: function(e, t) {
|
|
409
|
+
return t === void 0 ? (this.x -= e.x, this.y -= e.y, this.z -= e.z, this) : (console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t));
|
|
410
|
+
},
|
|
411
|
+
subScalar: function(e) {
|
|
412
|
+
return this.x -= e, this.y -= e, this.z -= e, this;
|
|
413
|
+
},
|
|
414
|
+
subVectors: function(e, t) {
|
|
415
|
+
return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;
|
|
416
|
+
},
|
|
417
|
+
multiply: function(e, t) {
|
|
418
|
+
return t === void 0 ? (this.x *= e.x, this.y *= e.y, this.z *= e.z, this) : (console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), this.multiplyVectors(e, t));
|
|
419
|
+
},
|
|
420
|
+
multiplyScalar: function(e) {
|
|
421
|
+
return this.x *= e, this.y *= e, this.z *= e, this;
|
|
422
|
+
},
|
|
423
|
+
multiplyVectors: function(e, t) {
|
|
424
|
+
return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;
|
|
425
|
+
},
|
|
426
|
+
applyEuler: function() {
|
|
427
|
+
var e = new z();
|
|
428
|
+
return function(t) {
|
|
429
|
+
return t && t.isEuler || console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."), this.applyQuaternion(e.setFromEuler(t));
|
|
430
|
+
};
|
|
431
|
+
}(),
|
|
432
|
+
applyAxisAngle: function() {
|
|
433
|
+
var e = new z();
|
|
434
|
+
return function(t, n) {
|
|
435
|
+
return this.applyQuaternion(e.setFromAxisAngle(t, n));
|
|
436
|
+
};
|
|
437
|
+
}(),
|
|
438
|
+
applyMatrix3: function(e) {
|
|
439
|
+
var t = this.x, n = this.y, r = this.z, i = e.elements;
|
|
440
|
+
return this.x = i[0] * t + i[3] * n + i[6] * r, this.y = i[1] * t + i[4] * n + i[7] * r, this.z = i[2] * t + i[5] * n + i[8] * r, this;
|
|
441
|
+
},
|
|
442
|
+
applyMatrix4: function(e) {
|
|
443
|
+
var t = this.x, n = this.y, r = this.z, i = e.elements, a = 1 / (i[3] * t + i[7] * n + i[11] * r + i[15]);
|
|
444
|
+
return this.x = (i[0] * t + i[4] * n + i[8] * r + i[12]) * a, this.y = (i[1] * t + i[5] * n + i[9] * r + i[13]) * a, this.z = (i[2] * t + i[6] * n + i[10] * r + i[14]) * a, this;
|
|
445
|
+
},
|
|
446
|
+
applyQuaternion: function(e) {
|
|
447
|
+
var t = this.x, n = this.y, r = this.z, i = e.x, a = e.y, o = e.z, s = e.w, c = s * t + a * r - o * n, l = s * n + o * t - i * r, u = s * r + i * n - a * t, d = -i * t - a * n - o * r;
|
|
448
|
+
return this.x = c * s + d * -i + l * -o - u * -a, this.y = l * s + d * -a + u * -i - c * -o, this.z = u * s + d * -o + c * -a - l * -i, this;
|
|
449
|
+
},
|
|
450
|
+
project: function(e) {
|
|
451
|
+
return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
|
|
452
|
+
},
|
|
453
|
+
unproject: function(e) {
|
|
454
|
+
return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
|
|
455
|
+
},
|
|
456
|
+
transformDirection: function(e) {
|
|
457
|
+
var t = this.x, n = this.y, r = this.z, i = e.elements;
|
|
458
|
+
return this.x = i[0] * t + i[4] * n + i[8] * r, this.y = i[1] * t + i[5] * n + i[9] * r, this.z = i[2] * t + i[6] * n + i[10] * r, this.normalize();
|
|
459
|
+
},
|
|
460
|
+
divide: function(e) {
|
|
461
|
+
return this.x /= e.x, this.y /= e.y, this.z /= e.z, this;
|
|
462
|
+
},
|
|
463
|
+
divideScalar: function(e) {
|
|
464
|
+
return this.multiplyScalar(1 / e);
|
|
465
|
+
},
|
|
466
|
+
min: function(e) {
|
|
467
|
+
return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this;
|
|
468
|
+
},
|
|
469
|
+
max: function(e) {
|
|
470
|
+
return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this;
|
|
471
|
+
},
|
|
472
|
+
clamp: function(e, t) {
|
|
473
|
+
return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this;
|
|
474
|
+
},
|
|
475
|
+
clampScalar: function(e, t) {
|
|
476
|
+
return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this;
|
|
477
|
+
},
|
|
478
|
+
clampLength: function(e, t) {
|
|
479
|
+
var n = this.length();
|
|
480
|
+
return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
|
|
481
|
+
},
|
|
482
|
+
floor: function() {
|
|
483
|
+
return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
|
|
484
|
+
},
|
|
485
|
+
ceil: function() {
|
|
486
|
+
return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
|
|
487
|
+
},
|
|
488
|
+
round: function() {
|
|
489
|
+
return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
|
|
490
|
+
},
|
|
491
|
+
roundToZero: function() {
|
|
492
|
+
return this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this;
|
|
493
|
+
},
|
|
494
|
+
negate: function() {
|
|
495
|
+
return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
|
|
496
|
+
},
|
|
497
|
+
dot: function(e) {
|
|
498
|
+
return this.x * e.x + this.y * e.y + this.z * e.z;
|
|
499
|
+
},
|
|
500
|
+
lengthSq: function() {
|
|
501
|
+
return this.x * this.x + this.y * this.y + this.z * this.z;
|
|
502
|
+
},
|
|
503
|
+
length: function() {
|
|
504
|
+
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
|
505
|
+
},
|
|
506
|
+
manhattanLength: function() {
|
|
507
|
+
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
|
|
508
|
+
},
|
|
509
|
+
normalize: function() {
|
|
510
|
+
return this.divideScalar(this.length() || 1);
|
|
511
|
+
},
|
|
512
|
+
setLength: function(e) {
|
|
513
|
+
return this.normalize().multiplyScalar(e);
|
|
514
|
+
},
|
|
515
|
+
lerp: function(e, t) {
|
|
516
|
+
return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this;
|
|
517
|
+
},
|
|
518
|
+
lerpVectors: function(e, t, n) {
|
|
519
|
+
return this.subVectors(t, e).multiplyScalar(n).add(e);
|
|
520
|
+
},
|
|
521
|
+
cross: function(e, t) {
|
|
522
|
+
return t === void 0 ? this.crossVectors(this, e) : (console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."), this.crossVectors(e, t));
|
|
523
|
+
},
|
|
524
|
+
crossVectors: function(e, t) {
|
|
525
|
+
var n = e.x, r = e.y, i = e.z, a = t.x, o = t.y, s = t.z;
|
|
526
|
+
return this.x = r * s - i * o, this.y = i * a - n * s, this.z = n * o - r * a, this;
|
|
527
|
+
},
|
|
528
|
+
projectOnVector: function(e) {
|
|
529
|
+
var t = e.dot(this) / e.lengthSq();
|
|
530
|
+
return this.copy(e).multiplyScalar(t);
|
|
531
|
+
},
|
|
532
|
+
projectOnPlane: function() {
|
|
533
|
+
var e = new B();
|
|
534
|
+
return function(t) {
|
|
535
|
+
return e.copy(this).projectOnVector(t), this.sub(e);
|
|
536
|
+
};
|
|
537
|
+
}(),
|
|
538
|
+
reflect: function() {
|
|
539
|
+
var e = new B();
|
|
540
|
+
return function(t) {
|
|
541
|
+
return this.sub(e.copy(t).multiplyScalar(2 * this.dot(t)));
|
|
542
|
+
};
|
|
543
|
+
}(),
|
|
544
|
+
angleTo: function(e) {
|
|
545
|
+
var t = this.dot(e) / Math.sqrt(this.lengthSq() * e.lengthSq());
|
|
546
|
+
return Math.acos(Ye.clamp(t, -1, 1));
|
|
547
|
+
},
|
|
548
|
+
distanceTo: function(e) {
|
|
549
|
+
return Math.sqrt(this.distanceToSquared(e));
|
|
550
|
+
},
|
|
551
|
+
distanceToSquared: function(e) {
|
|
552
|
+
var t = this.x - e.x, n = this.y - e.y, r = this.z - e.z;
|
|
553
|
+
return t * t + n * n + r * r;
|
|
554
|
+
},
|
|
555
|
+
manhattanDistanceTo: function(e) {
|
|
556
|
+
return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);
|
|
557
|
+
},
|
|
558
|
+
setFromSpherical: function(e) {
|
|
559
|
+
return this.setFromSphericalCoords(e.radius, e.phi, e.theta);
|
|
560
|
+
},
|
|
561
|
+
setFromSphericalCoords: function(e, t, n) {
|
|
562
|
+
var r = Math.sin(t) * e;
|
|
563
|
+
return this.x = r * Math.sin(n), this.y = Math.cos(t) * e, this.z = r * Math.cos(n), this;
|
|
564
|
+
},
|
|
565
|
+
setFromCylindrical: function(e) {
|
|
566
|
+
return this.setFromCylindricalCoords(e.radius, e.theta, e.y);
|
|
567
|
+
},
|
|
568
|
+
setFromCylindricalCoords: function(e, t, n) {
|
|
569
|
+
return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this;
|
|
570
|
+
},
|
|
571
|
+
setFromMatrixPosition: function(e) {
|
|
572
|
+
var t = e.elements;
|
|
573
|
+
return this.x = t[12], this.y = t[13], this.z = t[14], this;
|
|
574
|
+
},
|
|
575
|
+
setFromMatrixScale: function(e) {
|
|
576
|
+
var t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), r = this.setFromMatrixColumn(e, 2).length();
|
|
577
|
+
return this.x = t, this.y = n, this.z = r, this;
|
|
578
|
+
},
|
|
579
|
+
setFromMatrixColumn: function(e, t) {
|
|
580
|
+
return this.fromArray(e.elements, t * 4);
|
|
581
|
+
},
|
|
582
|
+
equals: function(e) {
|
|
583
|
+
return e.x === this.x && e.y === this.y && e.z === this.z;
|
|
584
|
+
},
|
|
585
|
+
fromArray: function(e, t) {
|
|
586
|
+
return t === void 0 && (t = 0), this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this;
|
|
587
|
+
},
|
|
588
|
+
toArray: function(e, t) {
|
|
589
|
+
return e === void 0 && (e = []), t === void 0 && (t = 0), e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e;
|
|
590
|
+
},
|
|
591
|
+
fromBufferAttribute: function(e, t, n) {
|
|
592
|
+
return n !== void 0 && console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this;
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/core/three/Matrix4.js
|
|
597
|
+
function Xe() {
|
|
598
|
+
this.elements = [
|
|
599
|
+
1,
|
|
600
|
+
0,
|
|
601
|
+
0,
|
|
602
|
+
0,
|
|
603
|
+
0,
|
|
604
|
+
1,
|
|
605
|
+
0,
|
|
606
|
+
0,
|
|
607
|
+
0,
|
|
608
|
+
0,
|
|
609
|
+
1,
|
|
610
|
+
0,
|
|
611
|
+
0,
|
|
612
|
+
0,
|
|
613
|
+
0,
|
|
614
|
+
1
|
|
615
|
+
], arguments.length > 0 && console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.");
|
|
616
|
+
}
|
|
617
|
+
Object.assign(Xe.prototype, {
|
|
618
|
+
isMatrix4: !0,
|
|
619
|
+
set: function(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
|
|
620
|
+
var g = this.elements;
|
|
621
|
+
return g[0] = e, g[4] = t, g[8] = n, g[12] = r, g[1] = i, g[5] = a, g[9] = o, g[13] = s, g[2] = c, g[6] = l, g[10] = u, g[14] = d, g[3] = f, g[7] = p, g[11] = m, g[15] = h, this;
|
|
622
|
+
},
|
|
623
|
+
identity: function() {
|
|
624
|
+
return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this;
|
|
625
|
+
},
|
|
626
|
+
clone: function() {
|
|
627
|
+
return new Xe().fromArray(this.elements);
|
|
628
|
+
},
|
|
629
|
+
copy: function(e) {
|
|
630
|
+
var t = this.elements, n = e.elements;
|
|
631
|
+
return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this;
|
|
632
|
+
},
|
|
633
|
+
copyPosition: function(e) {
|
|
634
|
+
var t = this.elements, n = e.elements;
|
|
635
|
+
return t[12] = n[12], t[13] = n[13], t[14] = n[14], this;
|
|
636
|
+
},
|
|
637
|
+
extractBasis: function(e, t, n) {
|
|
638
|
+
return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this;
|
|
639
|
+
},
|
|
640
|
+
makeBasis: function(e, t, n) {
|
|
641
|
+
return this.set(e.x, t.x, n.x, 0, e.y, t.y, n.y, 0, e.z, t.z, n.z, 0, 0, 0, 0, 1), this;
|
|
642
|
+
},
|
|
643
|
+
extractRotation: function() {
|
|
644
|
+
var e = new B();
|
|
645
|
+
return function(t) {
|
|
646
|
+
var n = this.elements, r = t.elements, i = 1 / e.setFromMatrixColumn(t, 0).length(), a = 1 / e.setFromMatrixColumn(t, 1).length(), o = 1 / e.setFromMatrixColumn(t, 2).length();
|
|
647
|
+
return n[0] = r[0] * i, n[1] = r[1] * i, n[2] = r[2] * i, n[3] = 0, n[4] = r[4] * a, n[5] = r[5] * a, n[6] = r[6] * a, n[7] = 0, n[8] = r[8] * o, n[9] = r[9] * o, n[10] = r[10] * o, n[11] = 0, n[12] = 0, n[13] = 0, n[14] = 0, n[15] = 1, this;
|
|
648
|
+
};
|
|
649
|
+
}(),
|
|
650
|
+
makeRotationFromEuler: function(e) {
|
|
651
|
+
e && e.isEuler || console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
|
|
652
|
+
var t = this.elements, n = e.x, r = e.y, i = e.z, a = Math.cos(n), o = Math.sin(n), s = Math.cos(r), c = Math.sin(r), l = Math.cos(i), u = Math.sin(i);
|
|
653
|
+
if (e.order === "XYZ") {
|
|
654
|
+
var d = a * l, f = a * u, p = o * l, m = o * u;
|
|
655
|
+
t[0] = s * l, t[4] = -s * u, t[8] = c, t[1] = f + p * c, t[5] = d - m * c, t[9] = -o * s, t[2] = m - d * c, t[6] = p + f * c, t[10] = a * s;
|
|
656
|
+
} else if (e.order === "YXZ") {
|
|
657
|
+
var h = s * l, g = s * u, _ = c * l, v = c * u;
|
|
658
|
+
t[0] = h + v * o, t[4] = _ * o - g, t[8] = a * c, t[1] = a * u, t[5] = a * l, t[9] = -o, t[2] = g * o - _, t[6] = v + h * o, t[10] = a * s;
|
|
659
|
+
} else if (e.order === "ZXY") {
|
|
660
|
+
var h = s * l, g = s * u, _ = c * l, v = c * u;
|
|
661
|
+
t[0] = h - v * o, t[4] = -a * u, t[8] = _ + g * o, t[1] = g + _ * o, t[5] = a * l, t[9] = v - h * o, t[2] = -a * c, t[6] = o, t[10] = a * s;
|
|
662
|
+
} else if (e.order === "ZYX") {
|
|
663
|
+
var d = a * l, f = a * u, p = o * l, m = o * u;
|
|
664
|
+
t[0] = s * l, t[4] = p * c - f, t[8] = d * c + m, t[1] = s * u, t[5] = m * c + d, t[9] = f * c - p, t[2] = -c, t[6] = o * s, t[10] = a * s;
|
|
665
|
+
} else if (e.order === "YZX") {
|
|
666
|
+
var y = a * s, b = a * c, x = o * s, S = o * c;
|
|
667
|
+
t[0] = s * l, t[4] = S - y * u, t[8] = x * u + b, t[1] = u, t[5] = a * l, t[9] = -o * l, t[2] = -c * l, t[6] = b * u + x, t[10] = y - S * u;
|
|
668
|
+
} else if (e.order === "XZY") {
|
|
669
|
+
var y = a * s, b = a * c, x = o * s, S = o * c;
|
|
670
|
+
t[0] = s * l, t[4] = -u, t[8] = c * l, t[1] = y * u + S, t[5] = a * l, t[9] = b * u - x, t[2] = x * u - b, t[6] = o * l, t[10] = S * u + y;
|
|
671
|
+
}
|
|
672
|
+
return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
|
|
673
|
+
},
|
|
674
|
+
makeRotationFromQuaternion: function() {
|
|
675
|
+
var e = new B(0, 0, 0), t = new B(1, 1, 1);
|
|
676
|
+
return function(n) {
|
|
677
|
+
return this.compose(e, n, t);
|
|
678
|
+
};
|
|
679
|
+
}(),
|
|
680
|
+
lookAt: function() {
|
|
681
|
+
var e = new B(), t = new B(), n = new B();
|
|
682
|
+
return function(r, i, a) {
|
|
683
|
+
var o = this.elements;
|
|
684
|
+
return n.subVectors(r, i), n.lengthSq() === 0 && (n.z = 1), n.normalize(), e.crossVectors(a, n), e.lengthSq() === 0 && (Math.abs(a.z) === 1 ? n.x += 1e-4 : n.z += 1e-4, n.normalize(), e.crossVectors(a, n)), e.normalize(), t.crossVectors(n, e), o[0] = e.x, o[4] = t.x, o[8] = n.x, o[1] = e.y, o[5] = t.y, o[9] = n.y, o[2] = e.z, o[6] = t.z, o[10] = n.z, this;
|
|
685
|
+
};
|
|
686
|
+
}(),
|
|
687
|
+
multiply: function(e, t) {
|
|
688
|
+
return t === void 0 ? this.multiplyMatrices(this, e) : (console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), this.multiplyMatrices(e, t));
|
|
689
|
+
},
|
|
690
|
+
premultiply: function(e) {
|
|
691
|
+
return this.multiplyMatrices(e, this);
|
|
692
|
+
},
|
|
693
|
+
multiplyMatrices: function(e, t) {
|
|
694
|
+
var n = e.elements, r = t.elements, i = this.elements, a = n[0], o = n[4], s = n[8], c = n[12], l = n[1], u = n[5], d = n[9], f = n[13], p = n[2], m = n[6], h = n[10], g = n[14], _ = n[3], v = n[7], y = n[11], b = n[15], x = r[0], S = r[4], C = r[8], w = r[12], T = r[1], E = r[5], D = r[9], O = r[13], k = r[2], A = r[6], j = r[10], M = r[14], N = r[3], ee = r[7], te = r[11], P = r[15];
|
|
695
|
+
return i[0] = a * x + o * T + s * k + c * N, i[4] = a * S + o * E + s * A + c * ee, i[8] = a * C + o * D + s * j + c * te, i[12] = a * w + o * O + s * M + c * P, i[1] = l * x + u * T + d * k + f * N, i[5] = l * S + u * E + d * A + f * ee, i[9] = l * C + u * D + d * j + f * te, i[13] = l * w + u * O + d * M + f * P, i[2] = p * x + m * T + h * k + g * N, i[6] = p * S + m * E + h * A + g * ee, i[10] = p * C + m * D + h * j + g * te, i[14] = p * w + m * O + h * M + g * P, i[3] = _ * x + v * T + y * k + b * N, i[7] = _ * S + v * E + y * A + b * ee, i[11] = _ * C + v * D + y * j + b * te, i[15] = _ * w + v * O + y * M + b * P, this;
|
|
696
|
+
},
|
|
697
|
+
multiplyScalar: function(e) {
|
|
698
|
+
var t = this.elements;
|
|
699
|
+
return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this;
|
|
700
|
+
},
|
|
701
|
+
applyToBufferAttribute: function() {
|
|
702
|
+
var e = new B();
|
|
703
|
+
return function(t) {
|
|
704
|
+
for (var n = 0, r = t.count; n < r; n++) e.x = t.getX(n), e.y = t.getY(n), e.z = t.getZ(n), e.applyMatrix4(this), t.setXYZ(n, e.x, e.y, e.z);
|
|
705
|
+
return t;
|
|
706
|
+
};
|
|
707
|
+
}(),
|
|
708
|
+
determinant: function() {
|
|
709
|
+
var e = this.elements, t = e[0], n = e[4], r = e[8], i = e[12], a = e[1], o = e[5], s = e[9], c = e[13], l = e[2], u = e[6], d = e[10], f = e[14], p = e[3], m = e[7], h = e[11], g = e[15];
|
|
710
|
+
return p * (+i * s * u - r * c * u - i * o * d + n * c * d + r * o * f - n * s * f) + m * (+t * s * f - t * c * d + i * a * d - r * a * f + r * c * l - i * s * l) + h * (+t * c * u - t * o * f - i * a * u + n * a * f + i * o * l - n * c * l) + g * (-r * o * l - t * s * u + t * o * d + r * a * u - n * a * d + n * s * l);
|
|
711
|
+
},
|
|
712
|
+
transpose: function() {
|
|
713
|
+
var e = this.elements, t = e[1];
|
|
714
|
+
return e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this;
|
|
715
|
+
},
|
|
716
|
+
setPosition: function(e, t, n) {
|
|
717
|
+
var r = this.elements;
|
|
718
|
+
return e.isVector3 ? (r[12] = e.x, r[13] = e.y, r[14] = e.z) : (r[12] = e, r[13] = t, r[14] = n), this;
|
|
719
|
+
},
|
|
720
|
+
getInverse: function(e, t) {
|
|
721
|
+
var n = this.elements, r = e.elements, i = r[0], a = r[1], o = r[2], s = r[3], c = r[4], l = r[5], u = r[6], d = r[7], f = r[8], p = r[9], m = r[10], h = r[11], g = r[12], _ = r[13], v = r[14], y = r[15], b = p * v * d - _ * m * d + _ * u * h - l * v * h - p * u * y + l * m * y, x = g * m * d - f * v * d - g * u * h + c * v * h + f * u * y - c * m * y, S = f * _ * d - g * p * d + g * l * h - c * _ * h - f * l * y + c * p * y, C = g * p * u - f * _ * u - g * l * m + c * _ * m + f * l * v - c * p * v, w = i * b + a * x + o * S + s * C;
|
|
722
|
+
if (w === 0) {
|
|
723
|
+
var T = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
|
|
724
|
+
if (t === !0) throw Error(T);
|
|
725
|
+
return console.warn(T), this.identity();
|
|
726
|
+
}
|
|
727
|
+
var E = 1 / w;
|
|
728
|
+
return n[0] = b * E, n[1] = (_ * m * s - p * v * s - _ * o * h + a * v * h + p * o * y - a * m * y) * E, n[2] = (l * v * s - _ * u * s + _ * o * d - a * v * d - l * o * y + a * u * y) * E, n[3] = (p * u * s - l * m * s - p * o * d + a * m * d + l * o * h - a * u * h) * E, n[4] = x * E, n[5] = (f * v * s - g * m * s + g * o * h - i * v * h - f * o * y + i * m * y) * E, n[6] = (g * u * s - c * v * s - g * o * d + i * v * d + c * o * y - i * u * y) * E, n[7] = (c * m * s - f * u * s + f * o * d - i * m * d - c * o * h + i * u * h) * E, n[8] = S * E, n[9] = (g * p * s - f * _ * s - g * a * h + i * _ * h + f * a * y - i * p * y) * E, n[10] = (c * _ * s - g * l * s + g * a * d - i * _ * d - c * a * y + i * l * y) * E, n[11] = (f * l * s - c * p * s - f * a * d + i * p * d + c * a * h - i * l * h) * E, n[12] = C * E, n[13] = (f * _ * o - g * p * o + g * a * m - i * _ * m - f * a * v + i * p * v) * E, n[14] = (g * l * o - c * _ * o - g * a * u + i * _ * u + c * a * v - i * l * v) * E, n[15] = (c * p * o - f * l * o + f * a * u - i * p * u - c * a * m + i * l * m) * E, this;
|
|
729
|
+
},
|
|
730
|
+
scale: function(e) {
|
|
731
|
+
var t = this.elements, n = e.x, r = e.y, i = e.z;
|
|
732
|
+
return t[0] *= n, t[4] *= r, t[8] *= i, t[1] *= n, t[5] *= r, t[9] *= i, t[2] *= n, t[6] *= r, t[10] *= i, t[3] *= n, t[7] *= r, t[11] *= i, this;
|
|
733
|
+
},
|
|
734
|
+
getMaxScaleOnAxis: function() {
|
|
735
|
+
var e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];
|
|
736
|
+
return Math.sqrt(Math.max(t, n, r));
|
|
737
|
+
},
|
|
738
|
+
makeTranslation: function(e, t, n) {
|
|
739
|
+
return this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, n, 0, 0, 0, 1), this;
|
|
740
|
+
},
|
|
741
|
+
makeRotationX: function(e) {
|
|
742
|
+
var t = Math.cos(e), n = Math.sin(e);
|
|
743
|
+
return this.set(1, 0, 0, 0, 0, t, -n, 0, 0, n, t, 0, 0, 0, 0, 1), this;
|
|
744
|
+
},
|
|
745
|
+
makeRotationY: function(e) {
|
|
746
|
+
var t = Math.cos(e), n = Math.sin(e);
|
|
747
|
+
return this.set(t, 0, n, 0, 0, 1, 0, 0, -n, 0, t, 0, 0, 0, 0, 1), this;
|
|
748
|
+
},
|
|
749
|
+
makeRotationZ: function(e) {
|
|
750
|
+
var t = Math.cos(e), n = Math.sin(e);
|
|
751
|
+
return this.set(t, -n, 0, 0, n, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this;
|
|
752
|
+
},
|
|
753
|
+
makeRotationAxis: function(e, t) {
|
|
754
|
+
var n = Math.cos(t), r = Math.sin(t), i = 1 - n, a = e.x, o = e.y, s = e.z, c = i * a, l = i * o;
|
|
755
|
+
return this.set(c * a + n, c * o - r * s, c * s + r * o, 0, c * o + r * s, l * o + n, l * s - r * a, 0, c * s - r * o, l * s + r * a, i * s * s + n, 0, 0, 0, 0, 1), this;
|
|
756
|
+
},
|
|
757
|
+
makeScale: function(e, t, n) {
|
|
758
|
+
return this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this;
|
|
759
|
+
},
|
|
760
|
+
makeShear: function(e, t, n) {
|
|
761
|
+
return this.set(1, t, n, 0, e, 1, n, 0, e, t, 1, 0, 0, 0, 0, 1), this;
|
|
762
|
+
},
|
|
763
|
+
compose: function(e, t, n) {
|
|
764
|
+
var r = this.elements, i = t._x, a = t._y, o = t._z, s = t._w, c = i + i, l = a + a, u = o + o, d = i * c, f = i * l, p = i * u, m = a * l, h = a * u, g = o * u, _ = s * c, v = s * l, y = s * u, b = n.x, x = n.y, S = n.z;
|
|
765
|
+
return r[0] = (1 - (m + g)) * b, r[1] = (f + y) * b, r[2] = (p - v) * b, r[3] = 0, r[4] = (f - y) * x, r[5] = (1 - (d + g)) * x, r[6] = (h + _) * x, r[7] = 0, r[8] = (p + v) * S, r[9] = (h - _) * S, r[10] = (1 - (d + m)) * S, r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1, this;
|
|
766
|
+
},
|
|
767
|
+
decompose: function() {
|
|
768
|
+
var e = new B(), t = new Xe();
|
|
769
|
+
return function(n, r, i) {
|
|
770
|
+
var a = this.elements, o = e.set(a[0], a[1], a[2]).length(), s = e.set(a[4], a[5], a[6]).length(), c = e.set(a[8], a[9], a[10]).length();
|
|
771
|
+
this.determinant() < 0 && (o = -o), n.x = a[12], n.y = a[13], n.z = a[14], t.copy(this);
|
|
772
|
+
var l = 1 / o, u = 1 / s, d = 1 / c;
|
|
773
|
+
return t.elements[0] *= l, t.elements[1] *= l, t.elements[2] *= l, t.elements[4] *= u, t.elements[5] *= u, t.elements[6] *= u, t.elements[8] *= d, t.elements[9] *= d, t.elements[10] *= d, r.setFromRotationMatrix(t), i.x = o, i.y = s, i.z = c, this;
|
|
774
|
+
};
|
|
775
|
+
}(),
|
|
776
|
+
makePerspective: function(e, t, n, r, i, a) {
|
|
777
|
+
a === void 0 && console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
|
|
778
|
+
var o = this.elements, s = 2 * i / (t - e), c = 2 * i / (n - r), l = (t + e) / (t - e), u = (n + r) / (n - r), d = -(a + i) / (a - i), f = -2 * a * i / (a - i);
|
|
779
|
+
return o[0] = s, o[4] = 0, o[8] = l, o[12] = 0, o[1] = 0, o[5] = c, o[9] = u, o[13] = 0, o[2] = 0, o[6] = 0, o[10] = d, o[14] = f, o[3] = 0, o[7] = 0, o[11] = -1, o[15] = 0, this;
|
|
780
|
+
},
|
|
781
|
+
makeOrthographic: function(e, t, n, r, i, a) {
|
|
782
|
+
var o = this.elements, s = 1 / (t - e), c = 1 / (n - r), l = 1 / (a - i), u = (t + e) * s, d = (n + r) * c, f = (a + i) * l;
|
|
783
|
+
return o[0] = 2 * s, o[4] = 0, o[8] = 0, o[12] = -u, o[1] = 0, o[5] = 2 * c, o[9] = 0, o[13] = -d, o[2] = 0, o[6] = 0, o[10] = -2 * l, o[14] = -f, o[3] = 0, o[7] = 0, o[11] = 0, o[15] = 1, this;
|
|
784
|
+
},
|
|
785
|
+
equals: function(e) {
|
|
786
|
+
for (var t = this.elements, n = e.elements, r = 0; r < 16; r++) if (t[r] !== n[r]) return !1;
|
|
787
|
+
return !0;
|
|
788
|
+
},
|
|
789
|
+
fromArray: function(e, t) {
|
|
790
|
+
t === void 0 && (t = 0);
|
|
791
|
+
for (var n = 0; n < 16; n++) this.elements[n] = e[n + t];
|
|
792
|
+
return this;
|
|
793
|
+
},
|
|
794
|
+
toArray: function(e, t) {
|
|
795
|
+
e === void 0 && (e = []), t === void 0 && (t = 0);
|
|
796
|
+
var n = this.elements;
|
|
797
|
+
return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e;
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
//#endregion
|
|
801
|
+
//#region src/core/three/Euler.js
|
|
802
|
+
function V(e, t, n, r) {
|
|
803
|
+
this._x = e || 0, this._y = t || 0, this._z = n || 0, this._order = r || V.DefaultOrder;
|
|
804
|
+
}
|
|
805
|
+
V.RotationOrders = [
|
|
806
|
+
"XYZ",
|
|
807
|
+
"YZX",
|
|
808
|
+
"ZXY",
|
|
809
|
+
"XZY",
|
|
810
|
+
"YXZ",
|
|
811
|
+
"ZYX"
|
|
812
|
+
], V.DefaultOrder = "XYZ", Object.defineProperties(V.prototype, {
|
|
813
|
+
x: {
|
|
814
|
+
get: function() {
|
|
815
|
+
return this._x;
|
|
816
|
+
},
|
|
817
|
+
set: function(e) {
|
|
818
|
+
this._x = e, this._onChangeCallback();
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
y: {
|
|
822
|
+
get: function() {
|
|
823
|
+
return this._y;
|
|
824
|
+
},
|
|
825
|
+
set: function(e) {
|
|
826
|
+
this._y = e, this._onChangeCallback();
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
z: {
|
|
830
|
+
get: function() {
|
|
831
|
+
return this._z;
|
|
832
|
+
},
|
|
833
|
+
set: function(e) {
|
|
834
|
+
this._z = e, this._onChangeCallback();
|
|
835
|
+
}
|
|
836
|
+
},
|
|
837
|
+
order: {
|
|
838
|
+
get: function() {
|
|
839
|
+
return this._order;
|
|
840
|
+
},
|
|
841
|
+
set: function(e) {
|
|
842
|
+
this._order = e, this._onChangeCallback();
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}), Object.assign(V.prototype, {
|
|
846
|
+
isEuler: !0,
|
|
847
|
+
set: function(e, t, n, r) {
|
|
848
|
+
return this._x = e, this._y = t, this._z = n, this._order = r || this._order, this._onChangeCallback(), this;
|
|
849
|
+
},
|
|
850
|
+
clone: function() {
|
|
851
|
+
return new this.constructor(this._x, this._y, this._z, this._order);
|
|
852
|
+
},
|
|
853
|
+
copy: function(e) {
|
|
854
|
+
return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this;
|
|
855
|
+
},
|
|
856
|
+
setFromRotationMatrix: function(e, t, n) {
|
|
857
|
+
var r = Ye.clamp, i = e.elements, a = i[0], o = i[4], s = i[8], c = i[1], l = i[5], u = i[9], d = i[2], f = i[6], p = i[10];
|
|
858
|
+
return t = t || this._order, t === "XYZ" ? (this._y = Math.asin(r(s, -1, 1)), Math.abs(s) < .99999 ? (this._x = Math.atan2(-u, p), this._z = Math.atan2(-o, a)) : (this._x = Math.atan2(f, l), this._z = 0)) : t === "YXZ" ? (this._x = Math.asin(-r(u, -1, 1)), Math.abs(u) < .99999 ? (this._y = Math.atan2(s, p), this._z = Math.atan2(c, l)) : (this._y = Math.atan2(-d, a), this._z = 0)) : t === "ZXY" ? (this._x = Math.asin(r(f, -1, 1)), Math.abs(f) < .99999 ? (this._y = Math.atan2(-d, p), this._z = Math.atan2(-o, l)) : (this._y = 0, this._z = Math.atan2(c, a))) : t === "ZYX" ? (this._y = Math.asin(-r(d, -1, 1)), Math.abs(d) < .99999 ? (this._x = Math.atan2(f, p), this._z = Math.atan2(c, a)) : (this._x = 0, this._z = Math.atan2(-o, l))) : t === "YZX" ? (this._z = Math.asin(r(c, -1, 1)), Math.abs(c) < .99999 ? (this._x = Math.atan2(-u, l), this._y = Math.atan2(-d, a)) : (this._x = 0, this._y = Math.atan2(s, p))) : t === "XZY" ? (this._z = Math.asin(-r(o, -1, 1)), Math.abs(o) < .99999 ? (this._x = Math.atan2(f, l), this._y = Math.atan2(s, a)) : (this._x = Math.atan2(-u, p), this._y = 0)) : console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: " + t), this._order = t, n !== !1 && this._onChangeCallback(), this;
|
|
859
|
+
},
|
|
860
|
+
setFromQuaternion: function() {
|
|
861
|
+
var e = new Xe();
|
|
862
|
+
return function(t, n, r) {
|
|
863
|
+
return e.makeRotationFromQuaternion(t), this.setFromRotationMatrix(e, n, r);
|
|
864
|
+
};
|
|
865
|
+
}(),
|
|
866
|
+
setFromVector3: function(e, t) {
|
|
867
|
+
return this.set(e.x, e.y, e.z, t || this._order);
|
|
868
|
+
},
|
|
869
|
+
reorder: function() {
|
|
870
|
+
var e = new z();
|
|
871
|
+
return function(t) {
|
|
872
|
+
return e.setFromEuler(this), this.setFromQuaternion(e, t);
|
|
873
|
+
};
|
|
874
|
+
}(),
|
|
875
|
+
equals: function(e) {
|
|
876
|
+
return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;
|
|
877
|
+
},
|
|
878
|
+
fromArray: function(e) {
|
|
879
|
+
return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this;
|
|
880
|
+
},
|
|
881
|
+
toArray: function(e, t) {
|
|
882
|
+
return e === void 0 && (e = []), t === void 0 && (t = 0), e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e;
|
|
883
|
+
},
|
|
884
|
+
toVector3: function(e) {
|
|
885
|
+
return e ? e.set(this._x, this._y, this._z) : new B(this._x, this._y, this._z);
|
|
886
|
+
},
|
|
887
|
+
_onChange: function(e) {
|
|
888
|
+
return this._onChangeCallback = e, this;
|
|
889
|
+
},
|
|
890
|
+
_onChangeCallback: function() {}
|
|
891
|
+
});
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region src/utils/THREEUtil.js
|
|
894
|
+
var H = {
|
|
895
|
+
toScreenPos: (function() {
|
|
896
|
+
var e = new B();
|
|
897
|
+
return function(t, n, r) {
|
|
898
|
+
return e.copy(t), e.project(n), e.x = Math.round((e.x + 1) * r.width / 2), e.y = Math.round((-e.y + 1) * r.height / 2), e.z = 0, e;
|
|
899
|
+
};
|
|
900
|
+
})(),
|
|
901
|
+
toSpacePos: (function() {
|
|
902
|
+
var e = new B(), t = new B(), n;
|
|
903
|
+
return function(r, i, a) {
|
|
904
|
+
return e.set(r.x / a.width * 2 - 1, -(r.y / a.height) * 2 + 1, .5), e.unproject(i), t.copy(e.sub(i.position).normalize()), n = -i.position.z / t.z, e.copy(i.position), e.add(t.multiplyScalar(n)), e;
|
|
905
|
+
};
|
|
906
|
+
})()
|
|
907
|
+
}, U = {
|
|
908
|
+
initValue: function(e, t) {
|
|
909
|
+
return e != null && e != null ? e : t;
|
|
910
|
+
},
|
|
911
|
+
isArray: function(e) {
|
|
912
|
+
return Object.prototype.toString.call(e) === "[object Array]";
|
|
913
|
+
},
|
|
914
|
+
destroyArray: function(e) {
|
|
915
|
+
e.length = 0;
|
|
916
|
+
},
|
|
917
|
+
destroyObject: function(e) {
|
|
918
|
+
for (var t in e) delete e[t];
|
|
919
|
+
},
|
|
920
|
+
isUndefined: function() {
|
|
921
|
+
for (var e in arguments) if (arguments[e] !== void 0) return !1;
|
|
922
|
+
return !0;
|
|
923
|
+
},
|
|
924
|
+
setVectorByObj: function(e, t) {
|
|
925
|
+
t.x !== void 0 && (e.position.x = t.x), t.y !== void 0 && (e.position.y = t.y), t.z !== void 0 && (e.position.z = t.z), t.vx !== void 0 && (e.velocity.x = t.vx), t.vy !== void 0 && (e.velocity.y = t.vy), t.vz !== void 0 && (e.velocity.z = t.vz), t.ax !== void 0 && (e.acceleration.x = t.ax), t.ay !== void 0 && (e.acceleration.y = t.ay), t.az !== void 0 && (e.acceleration.z = t.az), t.p !== void 0 && e.position.copy(t.p), t.v !== void 0 && e.velocity.copy(t.v), t.a !== void 0 && e.acceleration.copy(t.a), t.position !== void 0 && e.position.copy(t.position), t.velocity !== void 0 && e.velocity.copy(t.velocity), t.accelerate !== void 0 && e.acceleration.copy(t.accelerate);
|
|
926
|
+
},
|
|
927
|
+
setPrototypeByObj: function(e, t, n) {
|
|
928
|
+
for (var r in t) e.hasOwnProperty(r) && (n ? n.indexOf(r) < 0 && (e[r] = this._getValue(t[r])) : e[r] = this._getValue(t[r]));
|
|
929
|
+
return e;
|
|
930
|
+
},
|
|
931
|
+
_getValue: function(e) {
|
|
932
|
+
return e.constructor.type === "Span" ? e.getValue() : e;
|
|
933
|
+
}
|
|
934
|
+
}, W = [];
|
|
935
|
+
for (let e = 0; e < 256; ++e) W.push((e + 256).toString(16).slice(1));
|
|
936
|
+
function Ze(e, t = 0) {
|
|
937
|
+
return (W[e[t + 0]] + W[e[t + 1]] + W[e[t + 2]] + W[e[t + 3]] + "-" + W[e[t + 4]] + W[e[t + 5]] + "-" + W[e[t + 6]] + W[e[t + 7]] + "-" + W[e[t + 8]] + W[e[t + 9]] + "-" + W[e[t + 10]] + W[e[t + 11]] + W[e[t + 12]] + W[e[t + 13]] + W[e[t + 14]] + W[e[t + 15]]).toLowerCase();
|
|
938
|
+
}
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region node_modules/uuid/dist/esm-browser/rng.js
|
|
941
|
+
var Qe, $e = /* @__PURE__ */ new Uint8Array(16);
|
|
942
|
+
function et() {
|
|
943
|
+
if (!Qe) {
|
|
944
|
+
if (typeof crypto > "u" || !crypto.getRandomValues) throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
945
|
+
Qe = crypto.getRandomValues.bind(crypto);
|
|
946
|
+
}
|
|
947
|
+
return Qe($e);
|
|
948
|
+
}
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region node_modules/uuid/dist/esm-browser/v1.js
|
|
951
|
+
var tt = {};
|
|
952
|
+
function nt(e, t, n) {
|
|
953
|
+
let r, i = e?._v6 ?? !1;
|
|
954
|
+
if (e) {
|
|
955
|
+
let t = Object.keys(e);
|
|
956
|
+
t.length === 1 && t[0] === "_v6" && (e = void 0);
|
|
957
|
+
}
|
|
958
|
+
if (e) r = it(e.random ?? e.rng?.() ?? et(), e.msecs, e.nsecs, e.clockseq, e.node, t, n);
|
|
959
|
+
else {
|
|
960
|
+
let e = Date.now(), a = et();
|
|
961
|
+
rt(tt, e, a), r = it(a, tt.msecs, tt.nsecs, i ? void 0 : tt.clockseq, i ? void 0 : tt.node, t, n);
|
|
962
|
+
}
|
|
963
|
+
return t ?? Ze(r);
|
|
964
|
+
}
|
|
965
|
+
function rt(e, t, n) {
|
|
966
|
+
return e.msecs ?? (e.msecs = -Infinity), e.nsecs ?? (e.nsecs = 0), t === e.msecs ? (e.nsecs++, e.nsecs >= 1e4 && (e.node = void 0, e.nsecs = 0)) : t > e.msecs ? e.nsecs = 0 : t < e.msecs && (e.node = void 0), e.node || (e.node = n.slice(10, 16), e.node[0] |= 1, e.clockseq = (n[8] << 8 | n[9]) & 16383), e.msecs = t, e;
|
|
967
|
+
}
|
|
968
|
+
function it(e, t, n, r, i, a, o = 0) {
|
|
969
|
+
if (e.length < 16) throw Error("Random bytes length must be >= 16");
|
|
970
|
+
if (!a) a = /* @__PURE__ */ new Uint8Array(16), o = 0;
|
|
971
|
+
else if (o < 0 || o + 16 > a.length) throw RangeError(`UUID byte range ${o}:${o + 15} is out of buffer bounds`);
|
|
972
|
+
t ?? (t = Date.now()), n ?? (n = 0), r ?? (r = (e[8] << 8 | e[9]) & 16383), i ?? (i = e.slice(10, 16)), t += 0xb1d069b5400;
|
|
973
|
+
let s = ((t & 268435455) * 1e4 + n) % 4294967296;
|
|
974
|
+
a[o++] = s >>> 24 & 255, a[o++] = s >>> 16 & 255, a[o++] = s >>> 8 & 255, a[o++] = s & 255;
|
|
975
|
+
let c = t / 4294967296 * 1e4 & 268435455;
|
|
976
|
+
a[o++] = c >>> 8 & 255, a[o++] = c & 255, a[o++] = c >>> 24 & 15 | 16, a[o++] = c >>> 16 & 255, a[o++] = r >>> 8 | 128, a[o++] = r & 255;
|
|
977
|
+
for (let e = 0; e < 6; ++e) a[o++] = i[e];
|
|
978
|
+
return a;
|
|
979
|
+
}
|
|
980
|
+
//#endregion
|
|
981
|
+
//#region src/utils/uid.js
|
|
982
|
+
var at = nt, ot = (e, t) => ({
|
|
983
|
+
...e,
|
|
984
|
+
...t
|
|
985
|
+
}), G = {
|
|
986
|
+
randomAToB: function(e, t, n) {
|
|
987
|
+
return n ? (Math.random() * (t - e) >> 0) + e : e + Math.random() * (t - e);
|
|
988
|
+
},
|
|
989
|
+
randomFloating: function(e, t, n) {
|
|
990
|
+
return this.randomAToB(e - t, e + t, n);
|
|
991
|
+
},
|
|
992
|
+
randomZone: function(e) {},
|
|
993
|
+
degreeTransform: function(e) {
|
|
994
|
+
return e * F / 180;
|
|
995
|
+
},
|
|
996
|
+
toColor16: function(e) {
|
|
997
|
+
return "#" + e.toString(16);
|
|
998
|
+
},
|
|
999
|
+
randomColor: function() {
|
|
1000
|
+
return "#" + ("00000" + (Math.random() * 16777216 << 0).toString(16)).slice(-6);
|
|
1001
|
+
},
|
|
1002
|
+
lerp: function(e, t, n) {
|
|
1003
|
+
return t + (e - t) * n;
|
|
1004
|
+
},
|
|
1005
|
+
getNormal: function(e, t) {
|
|
1006
|
+
return e.x == 0 && e.y == 0 ? e.z == 0 ? t.set(1, 0, 1) : t.set(1, 1, -e.y / e.z) : e.x == 0 ? t.set(1, 0, 1) : t.set(-e.y / e.x, 1, 1), t.normalize();
|
|
1007
|
+
},
|
|
1008
|
+
axisRotate: function(e, t, n, r) {
|
|
1009
|
+
var i = Math.cos(r), a = Math.sin(r), o = n.dot(t) * (1 - i);
|
|
1010
|
+
e.copy(n), e.cross(t).scalar(a), e.addValue(t.x * i, t.y * i, t.z * i), e.addValue(n.x * o, n.y * o, n.z * o);
|
|
1011
|
+
}
|
|
1012
|
+
}, st = "ArraySpan", ct = "ColorSpan", lt = "Polar3D", ut = "Span", K = class {
|
|
1013
|
+
constructor(e, t, n) {
|
|
1014
|
+
this._isArray = !1, this.type = ut, U.isArray(e) ? (this._isArray = !0, this.a = e) : (this.a = U.initValue(e, 1), this.b = U.initValue(t, this.a), this._center = U.initValue(n, !1));
|
|
1015
|
+
}
|
|
1016
|
+
getValue(e) {
|
|
1017
|
+
return this._isArray ? this.a[this.a.length * Math.random() >> 0] : this._center ? G.randomFloating(this.a, this.b, e) : G.randomAToB(this.a, this.b, e);
|
|
1018
|
+
}
|
|
1019
|
+
}, q = (e, t, n) => e instanceof K ? e : t === void 0 ? new K(e) : n === void 0 ? new K(e, t) : new K(e, t, n), dt = /* @__PURE__ */ o(((e, t) => {
|
|
1020
|
+
var n = Math.floor, r = Math.random;
|
|
1021
|
+
function i(e, t) {
|
|
1022
|
+
return e + n(r() * (t - e + 1));
|
|
1023
|
+
}
|
|
1024
|
+
t.exports = i;
|
|
1025
|
+
})), ft = /* @__PURE__ */ o(((e, t) => {
|
|
1026
|
+
var n = dt();
|
|
1027
|
+
function r(e) {
|
|
1028
|
+
var t = e.length;
|
|
1029
|
+
return t ? e[n(0, t - 1)] : void 0;
|
|
1030
|
+
}
|
|
1031
|
+
t.exports = r;
|
|
1032
|
+
})), pt = /* @__PURE__ */ o(((e, t) => {
|
|
1033
|
+
function n(e, t) {
|
|
1034
|
+
for (var n = -1, r = e == null ? 0 : e.length, i = Array(r); ++n < r;) i[n] = t(e[n], n, e);
|
|
1035
|
+
return i;
|
|
1036
|
+
}
|
|
1037
|
+
t.exports = n;
|
|
1038
|
+
})), mt = /* @__PURE__ */ o(((e, t) => {
|
|
1039
|
+
var n = pt();
|
|
1040
|
+
function r(e, t) {
|
|
1041
|
+
return n(t, function(t) {
|
|
1042
|
+
return e[t];
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
t.exports = r;
|
|
1046
|
+
})), ht = /* @__PURE__ */ o(((e, t) => {
|
|
1047
|
+
function n(e, t) {
|
|
1048
|
+
for (var n = -1, r = Array(e); ++n < e;) r[n] = t(n);
|
|
1049
|
+
return r;
|
|
1050
|
+
}
|
|
1051
|
+
t.exports = n;
|
|
1052
|
+
})), gt = /* @__PURE__ */ o(((e, t) => {
|
|
1053
|
+
t.exports = typeof global == "object" && global && global.Object === Object && global;
|
|
1054
|
+
})), _t = /* @__PURE__ */ o(((e, t) => {
|
|
1055
|
+
var n = gt(), r = typeof self == "object" && self && self.Object === Object && self;
|
|
1056
|
+
t.exports = n || r || Function("return this")();
|
|
1057
|
+
})), vt = /* @__PURE__ */ o(((e, t) => {
|
|
1058
|
+
t.exports = _t().Symbol;
|
|
1059
|
+
})), yt = /* @__PURE__ */ o(((e, t) => {
|
|
1060
|
+
var n = vt(), r = Object.prototype, i = r.hasOwnProperty, a = r.toString, o = n ? n.toStringTag : void 0;
|
|
1061
|
+
function s(e) {
|
|
1062
|
+
var t = i.call(e, o), n = e[o];
|
|
1063
|
+
try {
|
|
1064
|
+
e[o] = void 0;
|
|
1065
|
+
var r = !0;
|
|
1066
|
+
} catch {}
|
|
1067
|
+
var s = a.call(e);
|
|
1068
|
+
return r && (t ? e[o] = n : delete e[o]), s;
|
|
1069
|
+
}
|
|
1070
|
+
t.exports = s;
|
|
1071
|
+
})), bt = /* @__PURE__ */ o(((e, t) => {
|
|
1072
|
+
var n = Object.prototype.toString;
|
|
1073
|
+
function r(e) {
|
|
1074
|
+
return n.call(e);
|
|
1075
|
+
}
|
|
1076
|
+
t.exports = r;
|
|
1077
|
+
})), xt = /* @__PURE__ */ o(((e, t) => {
|
|
1078
|
+
var n = vt(), r = yt(), i = bt(), a = "[object Null]", o = "[object Undefined]", s = n ? n.toStringTag : void 0;
|
|
1079
|
+
function c(e) {
|
|
1080
|
+
return e == null ? e === void 0 ? o : a : s && s in Object(e) ? r(e) : i(e);
|
|
1081
|
+
}
|
|
1082
|
+
t.exports = c;
|
|
1083
|
+
})), St = /* @__PURE__ */ o(((e, t) => {
|
|
1084
|
+
function n(e) {
|
|
1085
|
+
return typeof e == "object" && !!e;
|
|
1086
|
+
}
|
|
1087
|
+
t.exports = n;
|
|
1088
|
+
})), Ct = /* @__PURE__ */ o(((e, t) => {
|
|
1089
|
+
var n = xt(), r = St(), i = "[object Arguments]";
|
|
1090
|
+
function a(e) {
|
|
1091
|
+
return r(e) && n(e) == i;
|
|
1092
|
+
}
|
|
1093
|
+
t.exports = a;
|
|
1094
|
+
})), wt = /* @__PURE__ */ o(((e, t) => {
|
|
1095
|
+
var n = Ct(), r = St(), i = Object.prototype, a = i.hasOwnProperty, o = i.propertyIsEnumerable;
|
|
1096
|
+
t.exports = n(function() {
|
|
1097
|
+
return arguments;
|
|
1098
|
+
}()) ? n : function(e) {
|
|
1099
|
+
return r(e) && a.call(e, "callee") && !o.call(e, "callee");
|
|
1100
|
+
};
|
|
1101
|
+
})), Tt = /* @__PURE__ */ o(((e, t) => {
|
|
1102
|
+
t.exports = Array.isArray;
|
|
1103
|
+
})), Et = /* @__PURE__ */ o(((e, t) => {
|
|
1104
|
+
function n() {
|
|
1105
|
+
return !1;
|
|
1106
|
+
}
|
|
1107
|
+
t.exports = n;
|
|
1108
|
+
})), Dt = /* @__PURE__ */ o(((e, t) => {
|
|
1109
|
+
var n = _t(), r = Et(), i = typeof e == "object" && e && !e.nodeType && e, a = i && typeof t == "object" && t && !t.nodeType && t, o = a && a.exports === i ? n.Buffer : void 0;
|
|
1110
|
+
t.exports = (o ? o.isBuffer : void 0) || r;
|
|
1111
|
+
})), Ot = /* @__PURE__ */ o(((e, t) => {
|
|
1112
|
+
var n = /^(?:0|[1-9]\d*)$/;
|
|
1113
|
+
function r(e, t) {
|
|
1114
|
+
var r = typeof e;
|
|
1115
|
+
return t = t ?? 9007199254740991, !!t && (r == "number" || r != "symbol" && n.test(e)) && e > -1 && e % 1 == 0 && e < t;
|
|
1116
|
+
}
|
|
1117
|
+
t.exports = r;
|
|
1118
|
+
})), kt = /* @__PURE__ */ o(((e, t) => {
|
|
1119
|
+
function n(e) {
|
|
1120
|
+
return typeof e == "number" && e > -1 && e % 1 == 0 && e <= 9007199254740991;
|
|
1121
|
+
}
|
|
1122
|
+
t.exports = n;
|
|
1123
|
+
})), At = /* @__PURE__ */ o(((e, t) => {
|
|
1124
|
+
var n = xt(), r = kt(), i = St(), a = "[object Arguments]", o = "[object Array]", s = "[object Boolean]", c = "[object Date]", l = "[object Error]", u = "[object Function]", d = "[object Map]", f = "[object Number]", p = "[object Object]", m = "[object RegExp]", h = "[object Set]", g = "[object String]", _ = "[object WeakMap]", v = "[object ArrayBuffer]", y = "[object DataView]", b = "[object Float32Array]", x = "[object Float64Array]", S = "[object Int8Array]", C = "[object Int16Array]", w = "[object Int32Array]", T = "[object Uint8Array]", E = "[object Uint8ClampedArray]", D = "[object Uint16Array]", O = "[object Uint32Array]", k = {};
|
|
1125
|
+
k[b] = k[x] = k[S] = k[C] = k[w] = k[T] = k[E] = k[D] = k[O] = !0, k[a] = k[o] = k[v] = k[s] = k[y] = k[c] = k[l] = k[u] = k[d] = k[f] = k[p] = k[m] = k[h] = k[g] = k[_] = !1;
|
|
1126
|
+
function A(e) {
|
|
1127
|
+
return i(e) && r(e.length) && !!k[n(e)];
|
|
1128
|
+
}
|
|
1129
|
+
t.exports = A;
|
|
1130
|
+
})), jt = /* @__PURE__ */ o(((e, t) => {
|
|
1131
|
+
function n(e) {
|
|
1132
|
+
return function(t) {
|
|
1133
|
+
return e(t);
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
t.exports = n;
|
|
1137
|
+
})), Mt = /* @__PURE__ */ o(((e, t) => {
|
|
1138
|
+
var n = gt(), r = typeof e == "object" && e && !e.nodeType && e, i = r && typeof t == "object" && t && !t.nodeType && t, a = i && i.exports === r && n.process;
|
|
1139
|
+
t.exports = function() {
|
|
1140
|
+
try {
|
|
1141
|
+
return i && i.require && i.require("util").types || a && a.binding && a.binding("util");
|
|
1142
|
+
} catch {}
|
|
1143
|
+
}();
|
|
1144
|
+
})), Nt = /* @__PURE__ */ o(((e, t) => {
|
|
1145
|
+
var n = At(), r = jt(), i = Mt(), a = i && i.isTypedArray;
|
|
1146
|
+
t.exports = a ? r(a) : n;
|
|
1147
|
+
})), Pt = /* @__PURE__ */ o(((e, t) => {
|
|
1148
|
+
var n = ht(), r = wt(), i = Tt(), a = Dt(), o = Ot(), s = Nt(), c = Object.prototype.hasOwnProperty;
|
|
1149
|
+
function l(e, t) {
|
|
1150
|
+
var l = i(e), u = !l && r(e), d = !l && !u && a(e), f = !l && !u && !d && s(e), p = l || u || d || f, m = p ? n(e.length, String) : [], h = m.length;
|
|
1151
|
+
for (var g in e) (t || c.call(e, g)) && !(p && (g == "length" || d && (g == "offset" || g == "parent") || f && (g == "buffer" || g == "byteLength" || g == "byteOffset") || o(g, h))) && m.push(g);
|
|
1152
|
+
return m;
|
|
1153
|
+
}
|
|
1154
|
+
t.exports = l;
|
|
1155
|
+
})), Ft = /* @__PURE__ */ o(((e, t) => {
|
|
1156
|
+
var n = Object.prototype;
|
|
1157
|
+
function r(e) {
|
|
1158
|
+
var t = e && e.constructor;
|
|
1159
|
+
return e === (typeof t == "function" && t.prototype || n);
|
|
1160
|
+
}
|
|
1161
|
+
t.exports = r;
|
|
1162
|
+
})), It = /* @__PURE__ */ o(((e, t) => {
|
|
1163
|
+
function n(e, t) {
|
|
1164
|
+
return function(n) {
|
|
1165
|
+
return e(t(n));
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
t.exports = n;
|
|
1169
|
+
})), Lt = /* @__PURE__ */ o(((e, t) => {
|
|
1170
|
+
t.exports = It()(Object.keys, Object);
|
|
1171
|
+
})), Rt = /* @__PURE__ */ o(((e, t) => {
|
|
1172
|
+
var n = Ft(), r = Lt(), i = Object.prototype.hasOwnProperty;
|
|
1173
|
+
function a(e) {
|
|
1174
|
+
if (!n(e)) return r(e);
|
|
1175
|
+
var t = [];
|
|
1176
|
+
for (var a in Object(e)) i.call(e, a) && a != "constructor" && t.push(a);
|
|
1177
|
+
return t;
|
|
1178
|
+
}
|
|
1179
|
+
t.exports = a;
|
|
1180
|
+
})), zt = /* @__PURE__ */ o(((e, t) => {
|
|
1181
|
+
function n(e) {
|
|
1182
|
+
var t = typeof e;
|
|
1183
|
+
return e != null && (t == "object" || t == "function");
|
|
1184
|
+
}
|
|
1185
|
+
t.exports = n;
|
|
1186
|
+
})), Bt = /* @__PURE__ */ o(((e, t) => {
|
|
1187
|
+
var n = xt(), r = zt(), i = "[object AsyncFunction]", a = "[object Function]", o = "[object GeneratorFunction]", s = "[object Proxy]";
|
|
1188
|
+
function c(e) {
|
|
1189
|
+
if (!r(e)) return !1;
|
|
1190
|
+
var t = n(e);
|
|
1191
|
+
return t == a || t == o || t == i || t == s;
|
|
1192
|
+
}
|
|
1193
|
+
t.exports = c;
|
|
1194
|
+
})), Vt = /* @__PURE__ */ o(((e, t) => {
|
|
1195
|
+
var n = Bt(), r = kt();
|
|
1196
|
+
function i(e) {
|
|
1197
|
+
return e != null && r(e.length) && !n(e);
|
|
1198
|
+
}
|
|
1199
|
+
t.exports = i;
|
|
1200
|
+
})), Ht = /* @__PURE__ */ o(((e, t) => {
|
|
1201
|
+
var n = Pt(), r = Rt(), i = Vt();
|
|
1202
|
+
function a(e) {
|
|
1203
|
+
return i(e) ? n(e) : r(e);
|
|
1204
|
+
}
|
|
1205
|
+
t.exports = a;
|
|
1206
|
+
})), Ut = /* @__PURE__ */ o(((e, t) => {
|
|
1207
|
+
var n = mt(), r = Ht();
|
|
1208
|
+
function i(e) {
|
|
1209
|
+
return e == null ? [] : n(e, r(e));
|
|
1210
|
+
}
|
|
1211
|
+
t.exports = i;
|
|
1212
|
+
})), Wt = /* @__PURE__ */ o(((e, t) => {
|
|
1213
|
+
var n = ft(), r = Ut();
|
|
1214
|
+
function i(e) {
|
|
1215
|
+
return n(r(e));
|
|
1216
|
+
}
|
|
1217
|
+
t.exports = i;
|
|
1218
|
+
})), Gt = /* @__PURE__ */ l((/* @__PURE__ */ o(((e, t) => {
|
|
1219
|
+
var n = ft(), r = Wt(), i = Tt();
|
|
1220
|
+
function a(e) {
|
|
1221
|
+
return (i(e) ? n : r)(e);
|
|
1222
|
+
}
|
|
1223
|
+
t.exports = a;
|
|
1224
|
+
})))()), Kt = class extends K {
|
|
1225
|
+
constructor(e) {
|
|
1226
|
+
super(), this.type = st, this.items = Array.isArray(e) ? e : [e];
|
|
1227
|
+
}
|
|
1228
|
+
getValue() {
|
|
1229
|
+
return (0, Gt.default)(this.items);
|
|
1230
|
+
}
|
|
1231
|
+
}, qt = (e) => e ? e instanceof Kt ? e : new Kt(e) : null, Jt = class extends K {
|
|
1232
|
+
constructor(e) {
|
|
1233
|
+
super(), this.type = ct, this.shouldRandomize = e === "random", this.colors = Array.isArray(e) ? e : [e];
|
|
1234
|
+
}
|
|
1235
|
+
getValue() {
|
|
1236
|
+
return this.shouldRandomize ? G.randomColor() : (0, Gt.default)(this.colors);
|
|
1237
|
+
}
|
|
1238
|
+
}, Yt = (e) => (e || (console.warn(`Invalid colors argument ${e} passed to createColorSpan. Defaulting to 'random'.`), e = "random"), e instanceof Jt ? e : new Jt(e)), Xt = class {
|
|
1239
|
+
constructor(e, t, n, r, i, a) {
|
|
1240
|
+
this.type = "Box", this.x = e, this.y = t, this.z = n, this.width = r, this.height = i, this.depth = a, this.bottom = this.y + this.height, this.right = this.x + this.width, this.right = this.x + this.width;
|
|
1241
|
+
}
|
|
1242
|
+
contains(e, t, n) {
|
|
1243
|
+
return e <= this.right && e >= this.x && t <= this.bottom && t >= this.y && n <= this.depth && n >= this.z;
|
|
1244
|
+
}
|
|
1245
|
+
}, Zt = "EULER", Qt = "RUNGE_KUTTA_2", $t = "RUNGE_KUTTA_4", en = "VERLET", tn = (e, t, n) => {
|
|
1246
|
+
e.sleep || (e.old.position.copy(e.position), e.old.velocity.copy(e.velocity), e.acceleration.scalar(1 / e.mass), e.velocity.add(e.acceleration.scalar(t)), e.position.add(e.old.velocity.scalar(t)), n && e.velocity.scalar(n ** (t / .0167)), e.acceleration.clear());
|
|
1247
|
+
}, nn = (e, t, n, r = Zt) => {
|
|
1248
|
+
switch (r) {
|
|
1249
|
+
case Zt:
|
|
1250
|
+
tn(e, t, n);
|
|
1251
|
+
break;
|
|
1252
|
+
default: tn(e, t, n);
|
|
1253
|
+
}
|
|
1254
|
+
}, J = class extends B {
|
|
1255
|
+
clear() {
|
|
1256
|
+
return this.x = 0, this.y = 0, this.z = 0, this;
|
|
1257
|
+
}
|
|
1258
|
+
scalar(e) {
|
|
1259
|
+
return this.x *= e, this.y *= e, this.z *= e, this;
|
|
1260
|
+
}
|
|
1261
|
+
addValue(e, t, n) {
|
|
1262
|
+
return this.x += e, this.y += t, this.z += n, this;
|
|
1263
|
+
}
|
|
1264
|
+
toString() {
|
|
1265
|
+
return "x:" + this.x + "y:" + this.y + "z:" + this.z;
|
|
1266
|
+
}
|
|
1267
|
+
eulerFromDir(e) {
|
|
1268
|
+
return new V().setFromVector3(e);
|
|
1269
|
+
}
|
|
1270
|
+
}, rn = class e {
|
|
1271
|
+
constructor(e, t, n) {
|
|
1272
|
+
this.type = lt, this.radius = e || 1, this.phi = n || 0, this.theta = t || 0;
|
|
1273
|
+
}
|
|
1274
|
+
set(e, t, n) {
|
|
1275
|
+
return this.radius = e || 1, this.phi = n || 0, this.theta = t || 0, this;
|
|
1276
|
+
}
|
|
1277
|
+
setRadius(e) {
|
|
1278
|
+
return this.radius = e, this;
|
|
1279
|
+
}
|
|
1280
|
+
setPhi(e) {
|
|
1281
|
+
return this.phi = e, this;
|
|
1282
|
+
}
|
|
1283
|
+
setTheta(e) {
|
|
1284
|
+
return this.theta = e, this;
|
|
1285
|
+
}
|
|
1286
|
+
copy(e) {
|
|
1287
|
+
return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this;
|
|
1288
|
+
}
|
|
1289
|
+
toVector3D() {
|
|
1290
|
+
return new J(this.getX(), this.getY(), this.getZ());
|
|
1291
|
+
}
|
|
1292
|
+
getX() {
|
|
1293
|
+
return this.radius * Math.sin(this.theta) * Math.cos(this.phi);
|
|
1294
|
+
}
|
|
1295
|
+
getY() {
|
|
1296
|
+
return -this.radius * Math.sin(this.theta) * Math.sin(this.phi);
|
|
1297
|
+
}
|
|
1298
|
+
getZ() {
|
|
1299
|
+
return this.radius * Math.cos(this.theta);
|
|
1300
|
+
}
|
|
1301
|
+
normalize() {
|
|
1302
|
+
return this.radius = 1, this;
|
|
1303
|
+
}
|
|
1304
|
+
equals(e) {
|
|
1305
|
+
return e.radius === this.radius && e.phi === this.phi && e.theta === this.theta;
|
|
1306
|
+
}
|
|
1307
|
+
clear() {
|
|
1308
|
+
return this.radius = 0, this.phi = 0, this.theta = 0, this;
|
|
1309
|
+
}
|
|
1310
|
+
clone() {
|
|
1311
|
+
return new e(this.radius, this.phi, this.theta);
|
|
1312
|
+
}
|
|
1313
|
+
}, an = "Particle", on = "Pool", sn = "System", cn = class {
|
|
1314
|
+
constructor(e) {
|
|
1315
|
+
this.id = `particle-${at()}`, this.type = an, this.life = Ve, this.age = 0, this.energy = 1, this.dead = !1, this.sleep = !1, this.body = null, this.parent = null, this.mass = 1, this.radius = 10, this.alpha = 1, this.scale = 1, this.useColor = !1, this.useAlpha = !1, this.easing = He, this.position = new J(), this.velocity = new J(), this.acceleration = new J(), this.old = {}, this.old.position = this.position.clone(), this.old.velocity = this.velocity.clone(), this.old.acceleration = this.acceleration.clone(), this.behaviours = [], this.transform = {}, this.color = {
|
|
1316
|
+
r: 0,
|
|
1317
|
+
g: 0,
|
|
1318
|
+
b: 0
|
|
1319
|
+
}, this.rotation = new J(), this.distanceToCamera = 0, U.setPrototypeByObj(this, e);
|
|
1320
|
+
}
|
|
1321
|
+
getDirection() {
|
|
1322
|
+
return Math.atan2(this.velocity.x, -this.velocity.y) * (180 / F);
|
|
1323
|
+
}
|
|
1324
|
+
reset() {
|
|
1325
|
+
return this.life = Ve, this.age = 0, this.energy = 1, this.dead = !1, this.sleep = !1, this.body = null, this.parent = null, this.mass = 1, this.radius = 10, this.alpha = 1, this.scale = 1, this.useColor = !1, this.useAlpha = !1, this.easing = He, this.position.set(0, 0, 0), this.velocity.set(0, 0, 0), this.acceleration.set(0, 0, 0), this.old.position.set(0, 0, 0), this.old.velocity.set(0, 0, 0), this.old.acceleration.set(0, 0, 0), this.color.r = 0, this.color.g = 0, this.color.b = 0, this.rotation.clear(), U.destroyObject(this.transform), this.removeAllBehaviours(), this;
|
|
1326
|
+
}
|
|
1327
|
+
update(e, t) {
|
|
1328
|
+
if (!this.sleep) {
|
|
1329
|
+
this.age += e;
|
|
1330
|
+
let n = this.behaviours.length;
|
|
1331
|
+
for (; n--;) this.behaviours[n].applyBehaviour(this, e, t);
|
|
1332
|
+
}
|
|
1333
|
+
if (this.age >= this.life) this.destroy();
|
|
1334
|
+
else {
|
|
1335
|
+
let e = this.easing(this.age / this.life);
|
|
1336
|
+
this.energy = Math.max(1 - e, 0);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
addBehaviour(e) {
|
|
1340
|
+
this.behaviours.push(e), e.initialize(this);
|
|
1341
|
+
}
|
|
1342
|
+
addBehaviours(e) {
|
|
1343
|
+
let t = e.length;
|
|
1344
|
+
for (; t--;) this.addBehaviour(e[t]);
|
|
1345
|
+
}
|
|
1346
|
+
removeBehaviour(e) {
|
|
1347
|
+
let t = this.behaviours.indexOf(e);
|
|
1348
|
+
t > -1 && this.behaviours.splice(t, 1);
|
|
1349
|
+
}
|
|
1350
|
+
removeAllBehaviours() {
|
|
1351
|
+
U.destroyArray(this.behaviours);
|
|
1352
|
+
}
|
|
1353
|
+
destroy() {
|
|
1354
|
+
this.removeAllBehaviours(), this.energy = 0, this.dead = !0, this.parent = null;
|
|
1355
|
+
}
|
|
1356
|
+
}, Y = class {
|
|
1357
|
+
constructor() {
|
|
1358
|
+
this.type = on, this.cID = 0, this.list = {};
|
|
1359
|
+
}
|
|
1360
|
+
create(e, ...t) {
|
|
1361
|
+
if (!this.canCreateNewObject(e)) throw Error("The pool is unable to create or clone the object supplied");
|
|
1362
|
+
if (this.cID++, this.canInstantiateObject(e)) return new e(...t);
|
|
1363
|
+
if (this.canCloneObject(e)) return e.clone();
|
|
1364
|
+
}
|
|
1365
|
+
canInstantiateObject(e) {
|
|
1366
|
+
return typeof e == "function";
|
|
1367
|
+
}
|
|
1368
|
+
canCloneObject(e) {
|
|
1369
|
+
return e.clone && typeof e.clone == "function";
|
|
1370
|
+
}
|
|
1371
|
+
canCreateNewObject(e) {
|
|
1372
|
+
return !!(this.canInstantiateObject(e) || this.canCloneObject(e));
|
|
1373
|
+
}
|
|
1374
|
+
getCount() {
|
|
1375
|
+
var e = 0;
|
|
1376
|
+
for (var t in this.list) e += this.list[t].length;
|
|
1377
|
+
return e++;
|
|
1378
|
+
}
|
|
1379
|
+
get(e, ...t) {
|
|
1380
|
+
var n, r = e.__puid || Je.id(e);
|
|
1381
|
+
return n = this.list[r] && this.list[r].length > 0 ? this.list[r].pop() : this.create(e, ...t), n.__puid = e.__puid || r, n;
|
|
1382
|
+
}
|
|
1383
|
+
expire(e) {
|
|
1384
|
+
return this._getList(e.__puid).push(e);
|
|
1385
|
+
}
|
|
1386
|
+
destroy() {
|
|
1387
|
+
for (var e in this.list) this.list[e].length = 0, delete this.list[e];
|
|
1388
|
+
}
|
|
1389
|
+
_getList(e) {
|
|
1390
|
+
return e = e || "default", this.list[e] || (this.list[e] = []), this.list[e];
|
|
1391
|
+
}
|
|
1392
|
+
}, ln = class {
|
|
1393
|
+
constructor() {
|
|
1394
|
+
this.listeners = null;
|
|
1395
|
+
}
|
|
1396
|
+
set listeners(e) {
|
|
1397
|
+
this._listeners = e;
|
|
1398
|
+
}
|
|
1399
|
+
get listeners() {
|
|
1400
|
+
return this._listeners;
|
|
1401
|
+
}
|
|
1402
|
+
addEventListener(e, t) {
|
|
1403
|
+
return this.listeners ? this.removeEventListener(e, t) : this.listeners = {}, this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(t), t;
|
|
1404
|
+
}
|
|
1405
|
+
removeEventListener(e, t) {
|
|
1406
|
+
if (this.listeners && this.listeners[e]) {
|
|
1407
|
+
for (var n = this.listeners[e], r = 0, i = n.length; r < i; r++) if (n[r] == t) {
|
|
1408
|
+
i == 1 ? delete this.listeners[e] : n.splice(r, 1);
|
|
1409
|
+
break;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
removeAllEventListeners(e) {
|
|
1414
|
+
e ? this.listeners && delete this.listeners[e] : this.listeners = null;
|
|
1415
|
+
}
|
|
1416
|
+
dispatchEvent(e, t) {
|
|
1417
|
+
var n = !1, r = this.listeners;
|
|
1418
|
+
if (e && r) {
|
|
1419
|
+
var i = r[e];
|
|
1420
|
+
if (!i) return n;
|
|
1421
|
+
i = i.slice();
|
|
1422
|
+
for (var a, o = i.length; o--;) a = i[o], n = n || a(t);
|
|
1423
|
+
}
|
|
1424
|
+
return !!n;
|
|
1425
|
+
}
|
|
1426
|
+
hasEventListener(e) {
|
|
1427
|
+
var t = this.listeners;
|
|
1428
|
+
return !!(t && t[e]);
|
|
1429
|
+
}
|
|
1430
|
+
}, un = "SYSTEM_UPDATE", dn = "PARTICLE_CREATED", fn = "PARTICLE_UPDATE", pn = "PARTICLE_DEAD", mn = "EMITTER_ADDED", hn = "EMITTER_REMOVED", gn = "EMITTER_DEAD", _n = "SYSTEM_UPDATE_AFTER", vn = ln, X = class {
|
|
1431
|
+
constructor(e = C, t = !0) {
|
|
1432
|
+
this.type = e, this.isEnabled = t;
|
|
1433
|
+
}
|
|
1434
|
+
init(e, t) {
|
|
1435
|
+
this.isEnabled && (t ? (this.initialize(t), t.hasBeenInitialized = !0) : (this.initialize(e), e.hasBeenInitialized = !0));
|
|
1436
|
+
}
|
|
1437
|
+
reset() {}
|
|
1438
|
+
initialize(e) {}
|
|
1439
|
+
static requiresWebGlApi() {
|
|
1440
|
+
return !1;
|
|
1441
|
+
}
|
|
1442
|
+
static fromJSON(e) {}
|
|
1443
|
+
}, yn = class e extends X {
|
|
1444
|
+
constructor(e, t, n, r = !0) {
|
|
1445
|
+
super(w, r), this.body = qt(e), this.w = t, this.h = n || t;
|
|
1446
|
+
}
|
|
1447
|
+
initialize(e) {
|
|
1448
|
+
var t = this.body.getValue();
|
|
1449
|
+
this.w ? e.body = {
|
|
1450
|
+
width: this.w,
|
|
1451
|
+
height: this.h,
|
|
1452
|
+
body: t
|
|
1453
|
+
} : e.body = t;
|
|
1454
|
+
}
|
|
1455
|
+
static fromJSON(t) {
|
|
1456
|
+
let { body: n, width: r, height: i, isEnabled: a = !0 } = t;
|
|
1457
|
+
return new e(n, r, i, a);
|
|
1458
|
+
}
|
|
1459
|
+
}, bn = {
|
|
1460
|
+
AdditiveBlending: 2,
|
|
1461
|
+
CustomBlending: 5,
|
|
1462
|
+
MultiplyBlending: 4,
|
|
1463
|
+
NoBlending: 0,
|
|
1464
|
+
NormalBlending: 1,
|
|
1465
|
+
SubtractiveBlending: 3
|
|
1466
|
+
}, xn = {
|
|
1467
|
+
color: 16711680,
|
|
1468
|
+
blending: 2,
|
|
1469
|
+
fog: !0
|
|
1470
|
+
}, Sn = {
|
|
1471
|
+
...xn,
|
|
1472
|
+
blending: "AdditiveBlending"
|
|
1473
|
+
}, Cn = class e extends X {
|
|
1474
|
+
constructor(e, t, n = xn, r = !0) {
|
|
1475
|
+
super(T, r);
|
|
1476
|
+
let { Sprite: i, SpriteMaterial: a, TextureLoader: o } = e;
|
|
1477
|
+
this.materialProperties = ot(xn, n), new o().load(t, (e) => {
|
|
1478
|
+
this.texture = e, this.material = new a({
|
|
1479
|
+
map: e,
|
|
1480
|
+
...this.materialProperties
|
|
1481
|
+
}), this.sprite = new i(this.material);
|
|
1482
|
+
}, void 0, (e) => {
|
|
1483
|
+
throw Error(e);
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
initialize(e) {
|
|
1487
|
+
e.body = this.sprite;
|
|
1488
|
+
}
|
|
1489
|
+
static fromJSON(t, n) {
|
|
1490
|
+
let { texture: r, materialProperties: i = Sn, isEnabled: a = !0 } = t;
|
|
1491
|
+
return new e(n, r, ot(Sn, ((e) => {
|
|
1492
|
+
let { blending: t } = e;
|
|
1493
|
+
return {
|
|
1494
|
+
...e,
|
|
1495
|
+
blending: t ? bn[t] : bn[Sn.blending]
|
|
1496
|
+
};
|
|
1497
|
+
})(i)), a);
|
|
1498
|
+
}
|
|
1499
|
+
}, wn = new V(), Tn = {
|
|
1500
|
+
particleEuler: null,
|
|
1501
|
+
initialize: function(e, t, n) {
|
|
1502
|
+
let r = n.length;
|
|
1503
|
+
for (; r--;) n[r].init(e, t);
|
|
1504
|
+
e.bindEmitter && this.bindEmitter(e, t);
|
|
1505
|
+
},
|
|
1506
|
+
bindEmitter: function(e, t) {
|
|
1507
|
+
let { rotation: { x: n, y: r, z: i } } = e;
|
|
1508
|
+
t.position.add(e.position), t.velocity.add(e.velocity), t.acceleration.add(e.acceleration), t.velocity.applyEuler(wn.set(n, r, i));
|
|
1509
|
+
}
|
|
1510
|
+
}, En = class e extends X {
|
|
1511
|
+
constructor(e, t, n, r = !0) {
|
|
1512
|
+
super(D, r), this.lifePan = q(e, t, n);
|
|
1513
|
+
}
|
|
1514
|
+
initialize(e) {
|
|
1515
|
+
this.lifePan.a == Infinity || this.lifePan.a == "infi" ? e.life = Infinity : e.life = this.lifePan.getValue();
|
|
1516
|
+
}
|
|
1517
|
+
static fromJSON(t) {
|
|
1518
|
+
let { min: n, max: r, center: i = !1, isEnabled: a = !0 } = t;
|
|
1519
|
+
return new e(n, r, i, a);
|
|
1520
|
+
}
|
|
1521
|
+
}, Dn = class e extends X {
|
|
1522
|
+
constructor(e, t, n = !1, r = !0) {
|
|
1523
|
+
super(O, r), this.massPan = q(e, t, n);
|
|
1524
|
+
}
|
|
1525
|
+
initialize(e) {
|
|
1526
|
+
e.mass = this.massPan.getValue();
|
|
1527
|
+
}
|
|
1528
|
+
static fromJSON(t) {
|
|
1529
|
+
let { min: n, max: r, center: i = !1, isEnabled: a = !0 } = t;
|
|
1530
|
+
return new e(n, r, i, a);
|
|
1531
|
+
}
|
|
1532
|
+
}, On = class {
|
|
1533
|
+
constructor(e = ne) {
|
|
1534
|
+
this.type = e, this.vector = new J(0, 0, 0), this.random = 0, this.crossType = "dead", this.log = !0, this.supportsCrossing = !0;
|
|
1535
|
+
}
|
|
1536
|
+
getPosition() {
|
|
1537
|
+
return null;
|
|
1538
|
+
}
|
|
1539
|
+
crossing(e) {
|
|
1540
|
+
if (!this.supportsCrossing) return console.warn(`${this.constructor.name} does not support the crossing method`);
|
|
1541
|
+
switch (this.crossType) {
|
|
1542
|
+
case "bound":
|
|
1543
|
+
this._bound(e);
|
|
1544
|
+
break;
|
|
1545
|
+
case "cross":
|
|
1546
|
+
this._cross(e);
|
|
1547
|
+
break;
|
|
1548
|
+
case "dead":
|
|
1549
|
+
this._dead(e);
|
|
1550
|
+
break;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
isBoxZone() {
|
|
1554
|
+
return !1;
|
|
1555
|
+
}
|
|
1556
|
+
isLineZone() {
|
|
1557
|
+
return !1;
|
|
1558
|
+
}
|
|
1559
|
+
isMeshZone() {
|
|
1560
|
+
return !1;
|
|
1561
|
+
}
|
|
1562
|
+
isPointZone() {
|
|
1563
|
+
return !1;
|
|
1564
|
+
}
|
|
1565
|
+
isScreenZone() {
|
|
1566
|
+
return !1;
|
|
1567
|
+
}
|
|
1568
|
+
isSphereZone() {
|
|
1569
|
+
return !1;
|
|
1570
|
+
}
|
|
1571
|
+
_dead(e) {}
|
|
1572
|
+
_bound(e) {}
|
|
1573
|
+
_cross(e) {}
|
|
1574
|
+
}, kn = class extends On {
|
|
1575
|
+
constructor(e, t, n, r, i, a) {
|
|
1576
|
+
super(re);
|
|
1577
|
+
var o, s, c, l, u, r;
|
|
1578
|
+
U.isUndefined(t, n, r, i, a) ? (o = s = c = 0, l = u = r = e || 100) : U.isUndefined(r, i, a) ? (o = s = c = 0, l = e, u = t, r = n) : (o = e, s = t, c = n, l = r, u = i, r = a), this.x = o, this.y = s, this.z = c, this.width = l, this.height = u, this.depth = r, this.friction = .85, this.max = 6;
|
|
1579
|
+
}
|
|
1580
|
+
isBoxZone() {
|
|
1581
|
+
return !0;
|
|
1582
|
+
}
|
|
1583
|
+
getPosition() {
|
|
1584
|
+
return this.vector.x = this.x + G.randomAToB(-.5, .5) * this.width, this.vector.y = this.y + G.randomAToB(-.5, .5) * this.height, this.vector.z = this.z + G.randomAToB(-.5, .5) * this.depth, this.vector;
|
|
1585
|
+
}
|
|
1586
|
+
_dead(e) {
|
|
1587
|
+
(e.position.x + e.radius < this.x - this.width / 2 || e.position.x - e.radius > this.x + this.width / 2) && (e.dead = !0), (e.position.y + e.radius < this.y - this.height / 2 || e.position.y - e.radius > this.y + this.height / 2) && (e.dead = !0), (e.position.z + e.radius < this.z - this.depth / 2 || e.position.z - e.radius > this.z + this.depth / 2) && (e.dead = !0);
|
|
1588
|
+
}
|
|
1589
|
+
_bound(e) {
|
|
1590
|
+
e.position.x - e.radius < this.x - this.width / 2 ? (e.position.x = this.x - this.width / 2 + e.radius, e.velocity.x *= -this.friction, this._static(e, "x")) : e.position.x + e.radius > this.x + this.width / 2 && (e.position.x = this.x + this.width / 2 - e.radius, e.velocity.x *= -this.friction, this._static(e, "x")), e.position.y - e.radius < this.y - this.height / 2 ? (e.position.y = this.y - this.height / 2 + e.radius, e.velocity.y *= -this.friction, this._static(e, "y")) : e.position.y + e.radius > this.y + this.height / 2 && (e.position.y = this.y + this.height / 2 - e.radius, e.velocity.y *= -this.friction, this._static(e, "y")), e.position.z - e.radius < this.z - this.depth / 2 ? (e.position.z = this.z - this.depth / 2 + e.radius, e.velocity.z *= -this.friction, this._static(e, "z")) : e.position.z + e.radius > this.z + this.depth / 2 && (e.position.z = this.z + this.depth / 2 - e.radius, e.velocity.z *= -this.friction, this._static(e, "z"));
|
|
1591
|
+
}
|
|
1592
|
+
_static(e, t) {
|
|
1593
|
+
e.velocity[t] * e.acceleration[t] > 0 || Math.abs(e.velocity[t]) < Math.abs(e.acceleration[t]) * .0167 * this.max && (e.velocity[t] = 0, e.acceleration[t] = 0);
|
|
1594
|
+
}
|
|
1595
|
+
_cross(e) {
|
|
1596
|
+
e.position.x + e.radius < this.x - this.width / 2 && e.velocity.x <= 0 ? e.position.x = this.x + this.width / 2 + e.radius : e.position.x - e.radius > this.x + this.width / 2 && e.velocity.x >= 0 && (e.position.x = this.x - this.width / 2 - e.radius), e.position.y + e.radius < this.y - this.height / 2 && e.velocity.y <= 0 ? e.position.y = this.y + this.height / 2 + e.radius : e.position.y - e.radius > this.y + this.height / 2 && e.velocity.y >= 0 && (e.position.y = this.y - this.height / 2 - e.radius), e.position.z + e.radius < this.z - this.depth / 2 && e.velocity.z <= 0 ? e.position.z = this.z + this.depth / 2 + e.radius : e.position.z - e.radius > this.z + this.depth / 2 && e.velocity.z >= 0 && (e.position.z = this.z - this.depth / 2 - e.radius);
|
|
1597
|
+
}
|
|
1598
|
+
}, An = class extends On {
|
|
1599
|
+
constructor(e, t, n, r, i, a) {
|
|
1600
|
+
super(ie), e instanceof J ? (this.x1 = e.x, this.y1 = e.y, this.z1 = e.z, this.x2 = r.x, this.y2 = r.y, this.z2 = r.z) : (this.x1 = e, this.y1 = t, this.z1 = n, this.x2 = r, this.y2 = i, this.z2 = a), this.supportsCrossing = !1;
|
|
1601
|
+
}
|
|
1602
|
+
isLineZone() {
|
|
1603
|
+
return !0;
|
|
1604
|
+
}
|
|
1605
|
+
getPosition() {
|
|
1606
|
+
return this.random = Math.random(), this.vector.x = this.x1 + this.random * (this.x2 - this.x1), this.vector.y = this.y1 + this.random * (this.y2 - this.y1), this.vector.z = this.z1 + this.random * (this.z2 - this.z1), this.vector;
|
|
1607
|
+
}
|
|
1608
|
+
}, jn = class extends On {
|
|
1609
|
+
constructor(e, t = 1, n) {
|
|
1610
|
+
if (super(ae), this.geometry = null, this.scale = t, this.supportsCrossing = !1, e.type && e.type === "Geometry" && (this.geometry = e), e.geometry && (this.geometry = e.geometry), !this.geometry) throw Error("MeshZone unable to set geometry from the supplied bounds");
|
|
1611
|
+
this.geometry.isBufferGeometry && (this.geometry = new n().fromBufferGeometry(this.geometry));
|
|
1612
|
+
}
|
|
1613
|
+
isMeshZone() {
|
|
1614
|
+
return !0;
|
|
1615
|
+
}
|
|
1616
|
+
getPosition() {
|
|
1617
|
+
let e = this.geometry.vertices, t = e[e.length * Math.random() >> 0];
|
|
1618
|
+
return this.vector.x = t.x * this.scale, this.vector.y = t.y * this.scale, this.vector.z = t.z * this.scale, this.vector;
|
|
1619
|
+
}
|
|
1620
|
+
}, Mn = class extends On {
|
|
1621
|
+
constructor(e, t, n) {
|
|
1622
|
+
super(oe);
|
|
1623
|
+
var r = U.isUndefined(e, t, n) ? 0 : e;
|
|
1624
|
+
this.x = r, this.y = r, this.z = r, this.supportsCrossing = !1;
|
|
1625
|
+
}
|
|
1626
|
+
isPointZone() {
|
|
1627
|
+
return !0;
|
|
1628
|
+
}
|
|
1629
|
+
getPosition() {
|
|
1630
|
+
return this.vector.x = this.x, this.vector.y = this.y, this.vector.z = this.z, this.vector;
|
|
1631
|
+
}
|
|
1632
|
+
}, Nn = class extends On {
|
|
1633
|
+
constructor(e, t, n, r) {
|
|
1634
|
+
super(se), this.camera = e, this.renderer = t, this.dis = n || 20, r = r || "1234";
|
|
1635
|
+
for (var i = 1; i < 5; i++) this["d" + i] = r.indexOf(i + "") >= 0;
|
|
1636
|
+
}
|
|
1637
|
+
isScreenZone() {
|
|
1638
|
+
return !0;
|
|
1639
|
+
}
|
|
1640
|
+
_dead(e) {
|
|
1641
|
+
var t = H.toScreenPos(e.position, this.camera, this.renderer.domElement), n = this.renderer.domElement;
|
|
1642
|
+
(t.y + e.radius < -this.dis && this.d1 || t.y - e.radius > n.height + this.dis && this.d3) && (e.dead = !0), (t.x + e.radius < -this.dis && this.d4 || t.x - e.radius > n.width + this.dis && this.d2) && (e.dead = !0);
|
|
1643
|
+
}
|
|
1644
|
+
_bound(e) {
|
|
1645
|
+
var t = H.toScreenPos(e.position, this.camera, this.renderer.domElement), n = this.renderer.domElement;
|
|
1646
|
+
(t.y + e.radius < -this.dis || t.y - e.radius > n.height + this.dis) && (e.velocity.y *= -1), (t.x + e.radius < -this.dis || t.x - e.radius > n.width + this.dis) && (e.velocity.y *= -1);
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
Nn.prototype.getPosition = (function() {
|
|
1650
|
+
var e = new J(), t;
|
|
1651
|
+
return function() {
|
|
1652
|
+
return t = this.renderer.domElement, e.x = Math.random() * t.width, e.y = Math.random() * t.height, this.vector.copy(H.toSpacePos(e, this.camera, t)), this.vector;
|
|
1653
|
+
};
|
|
1654
|
+
})(), Nn.prototype._cross = (function() {
|
|
1655
|
+
var e = new J();
|
|
1656
|
+
return function(t) {
|
|
1657
|
+
var n = H.toScreenPos(t.position, this.camera, this.renderer.domElement), r = this.renderer.domElement;
|
|
1658
|
+
n.y + t.radius < -this.dis ? (e.x = n.x, e.y = r.height + this.dis + t.radius, t.position.y = H.toSpacePos(e, this.camera, r).y) : n.y - t.radius > r.height + this.dis && (e.x = n.x, e.y = -this.dis - t.radius, t.position.y = H.toSpacePos(e, this.camera, r).y), n.x + t.radius < -this.dis ? (e.y = n.y, e.x = r.width + this.dis + t.radius, t.position.x = H.toSpacePos(e, this.camera, r).x) : n.x - t.radius > r.width + this.dis && (e.y = n.y, e.x = -this.dis - t.radius, t.position.x = H.toSpacePos(e, this.camera, r).x);
|
|
1659
|
+
};
|
|
1660
|
+
})();
|
|
1661
|
+
//#endregion
|
|
1662
|
+
//#region src/zone/SphereZone.js
|
|
1663
|
+
var Pn = class extends On {
|
|
1664
|
+
constructor(e, t, n, r) {
|
|
1665
|
+
super(ce);
|
|
1666
|
+
let i, a;
|
|
1667
|
+
U.isUndefined(t, n, r) ? (i = 0, a = e || 100) : (i = e, a = r), this.x = i, this.y = i, this.z = i, this.radius = a, this.the = this.phi = 0;
|
|
1668
|
+
}
|
|
1669
|
+
isSphereZone() {
|
|
1670
|
+
return !0;
|
|
1671
|
+
}
|
|
1672
|
+
_dead(e) {
|
|
1673
|
+
e.position.distanceTo(this) - e.radius > this.radius && (e.dead = !0);
|
|
1674
|
+
}
|
|
1675
|
+
_cross() {
|
|
1676
|
+
console.warn(`${this.constructor.name} does not support the _cross method`);
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
Pn.prototype.getPosition = (function() {
|
|
1680
|
+
var e, t, n;
|
|
1681
|
+
return function() {
|
|
1682
|
+
return this.random = Math.random(), n = this.random * this.radius, e = F * Math.random(), t = F * 2 * Math.random(), this.vector.x = this.x + n * Math.sin(e) * Math.cos(t), this.vector.y = this.y + n * Math.sin(t) * Math.sin(e), this.vector.z = this.z + n * Math.cos(e), this.vector;
|
|
1683
|
+
};
|
|
1684
|
+
})(), Pn.prototype._bound = (function() {
|
|
1685
|
+
var e = new J(), t = new J(), n;
|
|
1686
|
+
return function(r) {
|
|
1687
|
+
r.position.distanceTo(this) + r.radius >= this.radius && (e.copy(r.position).sub(this).normalize(), t.copy(r.velocity), n = 2 * t.dot(e), r.velocity.sub(e.scalar(n)));
|
|
1688
|
+
};
|
|
1689
|
+
})();
|
|
1690
|
+
//#endregion
|
|
1691
|
+
//#region src/zone/index.js
|
|
1692
|
+
var Fn = /* @__PURE__ */ s({
|
|
1693
|
+
BoxZone: () => kn,
|
|
1694
|
+
LineZone: () => An,
|
|
1695
|
+
MeshZone: () => jn,
|
|
1696
|
+
PointZone: () => Mn,
|
|
1697
|
+
ScreenZone: () => Nn,
|
|
1698
|
+
SphereZone: () => Pn
|
|
1699
|
+
}), In = class e extends X {
|
|
1700
|
+
constructor() {
|
|
1701
|
+
super(k), this.reset.apply(this, arguments);
|
|
1702
|
+
}
|
|
1703
|
+
reset() {
|
|
1704
|
+
this.zones ? this.zones.length = 0 : this.zones = [], this.zones = this.zones.concat(Array.prototype.slice.call(arguments));
|
|
1705
|
+
}
|
|
1706
|
+
addZone() {
|
|
1707
|
+
this.zones = this.zones.concat(Array.prototype.slice.call(arguments));
|
|
1708
|
+
}
|
|
1709
|
+
static fromJSON(t) {
|
|
1710
|
+
let { zoneType: n, ...r } = t;
|
|
1711
|
+
if (!Ke.includes(n)) throw Error(`The zone type ${n} is invalid or not yet supported`);
|
|
1712
|
+
return new e(new Fn[n](...Object.values(r)));
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
In.prototype.initialize = (function() {
|
|
1716
|
+
let e;
|
|
1717
|
+
return function(t) {
|
|
1718
|
+
e = this.zones[Math.random() * this.zones.length >> 0], e.getPosition(), t.position.x = e.vector.x, t.position.y = e.vector.y, t.position.z = e.vector.z;
|
|
1719
|
+
};
|
|
1720
|
+
})();
|
|
1721
|
+
//#endregion
|
|
1722
|
+
//#region src/initializer/Rotation.js
|
|
1723
|
+
var Ln = class e extends X {
|
|
1724
|
+
constructor(e, t, n, r = !0, i = !0) {
|
|
1725
|
+
super(A, i), this.rotation = new B(e, t, n), this.useEmitterRotation = r;
|
|
1726
|
+
}
|
|
1727
|
+
initialize(e) {
|
|
1728
|
+
this.useEmitterRotation ? e.rotation.copy(e.parent.rotation).add(this.rotation) : e.rotation.copy(this.rotation);
|
|
1729
|
+
}
|
|
1730
|
+
static fromJSON(t) {
|
|
1731
|
+
let { x: n, y: r, z: i, useEmitterRotation: a = !0, isEnabled: o = !0 } = t;
|
|
1732
|
+
return new e(n, r, i, a, o);
|
|
1733
|
+
}
|
|
1734
|
+
}, Rn = class e extends X {
|
|
1735
|
+
constructor(e, t, n = !1, r = !0) {
|
|
1736
|
+
super(j, r), this.radius = q(e, t, n);
|
|
1737
|
+
}
|
|
1738
|
+
reset(e, t, n = !1) {
|
|
1739
|
+
this.radius = q(e, t, n);
|
|
1740
|
+
}
|
|
1741
|
+
initialize(e) {
|
|
1742
|
+
e.radius = this.radius.getValue(), e.transform.oldRadius = e.radius;
|
|
1743
|
+
}
|
|
1744
|
+
static fromJSON(t) {
|
|
1745
|
+
let { width: n, height: r, center: i = !1, isEnabled: a = !0 } = t;
|
|
1746
|
+
return new e(n, r, i, a);
|
|
1747
|
+
}
|
|
1748
|
+
}, zn = class e extends X {
|
|
1749
|
+
constructor(e = 1, t = 1) {
|
|
1750
|
+
super(te), this.numPan = q(e), this.timePan = q(t), this.startTime = 0, this.nextTime = 0, this.init();
|
|
1751
|
+
}
|
|
1752
|
+
init() {
|
|
1753
|
+
this.startTime = 0, this.nextTime = this.timePan.getValue();
|
|
1754
|
+
}
|
|
1755
|
+
getValue(e) {
|
|
1756
|
+
return this.startTime += e, this.startTime >= this.nextTime ? (this.init(), this.numPan.b == 1 ? +(this.numPan.getValue("Float") > .5) : this.numPan.getValue("Int")) : 0;
|
|
1757
|
+
}
|
|
1758
|
+
static fromJSON(t) {
|
|
1759
|
+
let { particlesMin: n, particlesMax: r, perSecondMin: i, perSecondMax: a } = t;
|
|
1760
|
+
return new e(new K(n, r), new K(i, a));
|
|
1761
|
+
}
|
|
1762
|
+
}, Bn = class e extends X {
|
|
1763
|
+
constructor(e, t, n = xn, r = !0) {
|
|
1764
|
+
super(E, r);
|
|
1765
|
+
let { Sprite: i, SpriteMaterial: a } = e;
|
|
1766
|
+
this.materialProperties = ot(xn, n), this.texture = t, this.material = new a({
|
|
1767
|
+
map: t,
|
|
1768
|
+
...this.materialProperties
|
|
1769
|
+
}), this.sprite = new i(this.material);
|
|
1770
|
+
}
|
|
1771
|
+
initialize(e) {
|
|
1772
|
+
e.body = this.sprite;
|
|
1773
|
+
}
|
|
1774
|
+
static fromJSON(t, n) {
|
|
1775
|
+
let { loadedTexture: r, materialProperties: i = Sn, isEnabled: a = !0 } = t;
|
|
1776
|
+
return new e(n, r, ot(Sn, ((e) => {
|
|
1777
|
+
let { blending: t } = e;
|
|
1778
|
+
return {
|
|
1779
|
+
...e,
|
|
1780
|
+
blending: t ? bn[t] : bn[Sn.blending]
|
|
1781
|
+
};
|
|
1782
|
+
})(i)), a);
|
|
1783
|
+
}
|
|
1784
|
+
}, Vn = class extends X {
|
|
1785
|
+
constructor(e, t = !0) {
|
|
1786
|
+
super(e, t), this.dirVec = new J(0, 0, 0);
|
|
1787
|
+
}
|
|
1788
|
+
normalize(e) {
|
|
1789
|
+
return e * 100;
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
Vn.prototype.initialize = (function() {
|
|
1793
|
+
var e, t = new J(0, 0, 1), n = new J(0, 0, 0);
|
|
1794
|
+
return function(r) {
|
|
1795
|
+
return e = this.tha * Math.random(), this._useV && this.dirVec.copy(this.dir).scalar(this.radiusPan.getValue()), G.getNormal(this.dirVec, t), n.copy(this.dirVec).applyAxisAngle(t, e), n.applyAxisAngle(this.dirVec.normalize(), Math.random() * F * 2), r.velocity.copy(n), this;
|
|
1796
|
+
};
|
|
1797
|
+
})();
|
|
1798
|
+
//#endregion
|
|
1799
|
+
//#region src/initializer/Velocity/PolarVelocity.js
|
|
1800
|
+
var Hn = class e extends Vn {
|
|
1801
|
+
constructor(e, t, n = !0) {
|
|
1802
|
+
super(N, n), this.tha = t * I, this.dirVec = e.toVector3D(), this._useV = !1;
|
|
1803
|
+
}
|
|
1804
|
+
static fromJSON(t) {
|
|
1805
|
+
let { polarRadius: n, polarTheta: r, polarPhi: i, velocityTheta: a, isEnabled: o = !0 } = t;
|
|
1806
|
+
return new e(new rn(n, r, i), a, o);
|
|
1807
|
+
}
|
|
1808
|
+
}, Un = class e extends Vn {
|
|
1809
|
+
constructor(e, t, n, r = !0) {
|
|
1810
|
+
super(ee, r), this.radiusPan = q(e), this.dir = t.clone().normalize(), this.tha = n * I, this._useV = !0;
|
|
1811
|
+
}
|
|
1812
|
+
static fromJSON(t) {
|
|
1813
|
+
let { radius: n, x: r, y: i, z: a, theta: o, isEnabled: s = !0 } = t;
|
|
1814
|
+
return new e(n, new J(r, i, a), o, s);
|
|
1815
|
+
}
|
|
1816
|
+
}, Wn = class e extends Vn {
|
|
1817
|
+
constructor(e, t, n = !0) {
|
|
1818
|
+
super(M, n), this.radiusPan = q(1), this.dir = e.clone(), this.tha = t * I, this._useV = !0;
|
|
1819
|
+
}
|
|
1820
|
+
static fromJSON(t) {
|
|
1821
|
+
let { x: n, y: r, z: i, theta: a, isEnabled: o = !0 } = t;
|
|
1822
|
+
return new e(new J(n, r, i), a, o);
|
|
1823
|
+
}
|
|
1824
|
+
}, Gn = /* @__PURE__ */ s({
|
|
1825
|
+
Body: () => yn,
|
|
1826
|
+
BodySprite: () => Cn,
|
|
1827
|
+
InitializerUtil: () => Tn,
|
|
1828
|
+
Life: () => En,
|
|
1829
|
+
Mass: () => Dn,
|
|
1830
|
+
PolarVelocity: () => Hn,
|
|
1831
|
+
Position: () => In,
|
|
1832
|
+
RadialVelocity: () => Un,
|
|
1833
|
+
Radius: () => Rn,
|
|
1834
|
+
Rate: () => zn,
|
|
1835
|
+
Rotation: () => Ln,
|
|
1836
|
+
Texture: () => Bn,
|
|
1837
|
+
VectorVelocity: () => Wn
|
|
1838
|
+
}), Kn = .006, qn = new zn(1, .1), Jn = /* @__PURE__ */ l((/* @__PURE__ */ o(((e, t) => {
|
|
1839
|
+
var n = xt(), r = St(), i = "[object Number]";
|
|
1840
|
+
function a(e) {
|
|
1841
|
+
return typeof e == "number" || r(e) && n(e) == i;
|
|
1842
|
+
}
|
|
1843
|
+
t.exports = a;
|
|
1844
|
+
})))()), Yn = "Emitter", Xn = "FollowEmitter", Zn = class extends cn {
|
|
1845
|
+
constructor(e) {
|
|
1846
|
+
super(e), this.type = Yn, this.particles = [], this.initializers = [], this.behaviours = [], this.emitterBehaviours = [], this.currentEmitTime = 0, this.totalEmitTimes = -1, this.damping = Kn, this.bindEmitter = !0, this.bindEmitterEvent = !1, this.rate = qn, this.isEmitting = !1, this.id = `emitter-${at()}`, this.cID = 0, this.name = "Emitter", this.index = void 0, this.eventDispatcher = new vn();
|
|
1847
|
+
}
|
|
1848
|
+
dispatch(e, t = this) {
|
|
1849
|
+
this.eventDispatcher.dispatchEvent(e, t);
|
|
1850
|
+
}
|
|
1851
|
+
setRate(e) {
|
|
1852
|
+
return this.rate = e, this;
|
|
1853
|
+
}
|
|
1854
|
+
setPosition(e = {}) {
|
|
1855
|
+
let { position: t } = this, { x: n = t.x, y: r = t.y, z: i = t.z } = e;
|
|
1856
|
+
return this.position.set(n, r, i), this;
|
|
1857
|
+
}
|
|
1858
|
+
setRotation(e = {}) {
|
|
1859
|
+
let { rotation: t } = this, { x: n = t.x, y: r = t.y, z: i = t.z } = e;
|
|
1860
|
+
return this.rotation.set(n, r, i), this;
|
|
1861
|
+
}
|
|
1862
|
+
emit(e = Infinity, t = Infinity) {
|
|
1863
|
+
return this.currentEmitTime = 0, this.totalEmitTimes = (0, Jn.default)(e) ? e : Infinity, e === 1 ? this.life = e : this.life = (0, Jn.default)(t) ? t : Infinity, this.rate.init(), this.isEmitting = !0, this;
|
|
1864
|
+
}
|
|
1865
|
+
experimental_emit() {
|
|
1866
|
+
let { isEmitting: e, totalEmitTimes: t, life: n } = this;
|
|
1867
|
+
return e || (this.currentEmitTime = 0, t || this.setTotalEmitTimes(Infinity), n || this.setLife(Infinity), this.rate.init(), this.isEmitting = !0), this;
|
|
1868
|
+
}
|
|
1869
|
+
setTotalEmitTimes(e = Infinity) {
|
|
1870
|
+
return this.totalEmitTimes = (0, Jn.default)(e) ? e : Infinity, this;
|
|
1871
|
+
}
|
|
1872
|
+
setLife(e = Infinity) {
|
|
1873
|
+
return this.totalEmitTimes === 1 ? this.life = this.totalEmitTimes : this.life = (0, Jn.default)(e) ? e : Infinity, this;
|
|
1874
|
+
}
|
|
1875
|
+
stopEmit() {
|
|
1876
|
+
this.totalEmitTimes = -1, this.currentEmitTime = 0, this.isEmitting = !1;
|
|
1877
|
+
}
|
|
1878
|
+
removeAllParticles() {
|
|
1879
|
+
let e = this.particles.length;
|
|
1880
|
+
for (; e--;) this.particles[e].dead = !0;
|
|
1881
|
+
}
|
|
1882
|
+
addInitializer(e) {
|
|
1883
|
+
return this.initializers.push(e), this;
|
|
1884
|
+
}
|
|
1885
|
+
addInitializers(e) {
|
|
1886
|
+
let t = e.length;
|
|
1887
|
+
for (; t--;) this.addInitializer(e[t]);
|
|
1888
|
+
return this;
|
|
1889
|
+
}
|
|
1890
|
+
setInitializers(e) {
|
|
1891
|
+
return this.initializers = e, this;
|
|
1892
|
+
}
|
|
1893
|
+
removeInitializer(e) {
|
|
1894
|
+
let t = this.initializers.indexOf(e);
|
|
1895
|
+
return t > -1 && this.initializers.splice(t, 1), this;
|
|
1896
|
+
}
|
|
1897
|
+
removeAllInitializers() {
|
|
1898
|
+
return U.destroyArray(this.initializers), this;
|
|
1899
|
+
}
|
|
1900
|
+
addBehaviour(e) {
|
|
1901
|
+
return this.behaviours.push(e), this;
|
|
1902
|
+
}
|
|
1903
|
+
addBehaviours(e) {
|
|
1904
|
+
let t = e.length;
|
|
1905
|
+
for (; t--;) this.addBehaviour(e[t]);
|
|
1906
|
+
return this;
|
|
1907
|
+
}
|
|
1908
|
+
setBehaviours(e) {
|
|
1909
|
+
return this.behaviours = e, this;
|
|
1910
|
+
}
|
|
1911
|
+
removeBehaviour(e) {
|
|
1912
|
+
let t = this.behaviours.indexOf(e);
|
|
1913
|
+
return t > -1 && this.behaviours.splice(t, 1), this;
|
|
1914
|
+
}
|
|
1915
|
+
removeAllBehaviours() {
|
|
1916
|
+
return U.destroyArray(this.behaviours), this;
|
|
1917
|
+
}
|
|
1918
|
+
addEmitterBehaviour(e) {
|
|
1919
|
+
return this.emitterBehaviours.push(e), e.initialize(this), this;
|
|
1920
|
+
}
|
|
1921
|
+
addEmitterBehaviours(e) {
|
|
1922
|
+
let t = e.length;
|
|
1923
|
+
for (; t--;) this.addEmitterBehaviour(e[t]);
|
|
1924
|
+
return this;
|
|
1925
|
+
}
|
|
1926
|
+
setEmitterBehaviours(e) {
|
|
1927
|
+
let t = e.length;
|
|
1928
|
+
this.emitterBehaviours = e;
|
|
1929
|
+
for (let e = 0; e < t; e++) this.emitterBehaviours[e].initialize(this);
|
|
1930
|
+
return this;
|
|
1931
|
+
}
|
|
1932
|
+
removeEmitterBehaviour(e) {
|
|
1933
|
+
let t = this.emitterBehaviours.indexOf(e);
|
|
1934
|
+
return t > -1 && this.emitterBehaviours.splice(t, 1), this;
|
|
1935
|
+
}
|
|
1936
|
+
removeAllEmitterBehaviours() {
|
|
1937
|
+
return U.destroyArray(this.emitterBehaviours), this;
|
|
1938
|
+
}
|
|
1939
|
+
addOnEmitterDeadEventListener(e) {
|
|
1940
|
+
return this.eventDispatcher.addEventListener(`${this.id}_${gn}`, () => e()), this;
|
|
1941
|
+
}
|
|
1942
|
+
createParticle() {
|
|
1943
|
+
let e = this.parent.pool.get(cn), t = this.particles.length;
|
|
1944
|
+
return this.setupParticle(e, t), this.parent && this.parent.dispatch("PARTICLE_CREATED", e), this.bindEmitterEvent && this.dispatch("PARTICLE_CREATED", e), e;
|
|
1945
|
+
}
|
|
1946
|
+
setupParticle(e, t) {
|
|
1947
|
+
let { initializers: n, behaviours: r } = this;
|
|
1948
|
+
Tn.initialize(this, e, n), e.addBehaviours(r), e.parent = this, e.index = t, this.particles.push(e);
|
|
1949
|
+
}
|
|
1950
|
+
update(e) {
|
|
1951
|
+
if (!this.isEmitting && this.particles.length === 0) return;
|
|
1952
|
+
this.age += e, (this.dead || this.age >= this.life) && this.destroy(), this.isEmitting && this.generate(e), this.integrate(e);
|
|
1953
|
+
let t = this.particles.length;
|
|
1954
|
+
for (; t--;) {
|
|
1955
|
+
let e = this.particles[t];
|
|
1956
|
+
e.dead && (this.parent && this.parent.dispatch("PARTICLE_DEAD", e), this.bindEmitterEvent && this.dispatch("PARTICLE_DEAD", e), this.parent.pool.expire(e.reset()), this.particles.splice(t, 1), this.particles.length === 0 && this.parent && this.parent.dispatch("SYSTEM_UPDATE"));
|
|
1957
|
+
}
|
|
1958
|
+
this.updateEmitterBehaviours(e);
|
|
1959
|
+
}
|
|
1960
|
+
updateEmitterBehaviours(e) {
|
|
1961
|
+
if (this.sleep) return;
|
|
1962
|
+
let t = this.emitterBehaviours.length;
|
|
1963
|
+
for (let n = 0; n < t; n++) this.emitterBehaviours[n].applyBehaviour(this, e, n);
|
|
1964
|
+
}
|
|
1965
|
+
integrate(e) {
|
|
1966
|
+
let t = this.parent ? this.parent.integrationType : Zt, n = 1 - this.damping;
|
|
1967
|
+
nn(this, e, n, t);
|
|
1968
|
+
let r = this.particles.length;
|
|
1969
|
+
for (; r--;) {
|
|
1970
|
+
let i = this.particles[r];
|
|
1971
|
+
i.update(e, r), nn(i, e, n, t), this.parent && this.parent.dispatch("PARTICLE_UPDATE", i), this.bindEmitterEvent && this.dispatch("PARTICLE_UPDATE", i);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
generate(e) {
|
|
1975
|
+
if (this.totalEmitTimes === 1) {
|
|
1976
|
+
let e = this.rate.getValue(99999);
|
|
1977
|
+
for (e > 0 && (this.cID = e); e--;) this.createParticle();
|
|
1978
|
+
this.totalEmitTimes = 0;
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
if (this.currentEmitTime += e, this.currentEmitTime < this.totalEmitTimes) {
|
|
1982
|
+
let t = this.rate.getValue(e);
|
|
1983
|
+
for (t > 0 && (this.cID = t); t--;) this.createParticle();
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
destroy() {
|
|
1987
|
+
this.dead = !0, this.energy = 0, this.totalEmitTimes = -1, this.particles.length == 0 && (this.isEmitting = !1, this.removeAllInitializers(), this.removeAllBehaviours(), this.dispatch(`${this.id}_${gn}`), this.parent && this.parent.removeEmitter(this));
|
|
1988
|
+
}
|
|
1989
|
+
}, Qn = Infinity, $n = 1e3, er = ve, tr = .03, nr = "dead", Z = class {
|
|
1990
|
+
constructor(e = Infinity, t = er, n = u, r = !0) {
|
|
1991
|
+
this.type = n, this.isEnabled = r, this.id = `behaviour-${at()}`, this.life = e, this.easing = t, this.age = 0, this.energy = 1, this.dead = !1;
|
|
1992
|
+
}
|
|
1993
|
+
reset(e = Qn, t = er) {
|
|
1994
|
+
this.life = e, this.easing = t || er;
|
|
1995
|
+
}
|
|
1996
|
+
set life(e) {
|
|
1997
|
+
this._life = (0, Jn.default)(e) ? e : Qn;
|
|
1998
|
+
}
|
|
1999
|
+
get life() {
|
|
2000
|
+
return this._life;
|
|
2001
|
+
}
|
|
2002
|
+
normalizeForce(e) {
|
|
2003
|
+
return e.scalar(100);
|
|
2004
|
+
}
|
|
2005
|
+
normalizeValue(e) {
|
|
2006
|
+
return e * 100;
|
|
2007
|
+
}
|
|
2008
|
+
initialize(e) {}
|
|
2009
|
+
applyBehaviour(e, t, n) {
|
|
2010
|
+
this.isEnabled && this.mutate(e, t, n);
|
|
2011
|
+
}
|
|
2012
|
+
mutate(e, t, n) {}
|
|
2013
|
+
energize(e, t) {
|
|
2014
|
+
if (this.dead) return;
|
|
2015
|
+
if (this.age += t, this.age >= this.life) {
|
|
2016
|
+
this.energy = 0, this.dead = !0;
|
|
2017
|
+
return;
|
|
2018
|
+
}
|
|
2019
|
+
let n = this.easing(e.age / e.life);
|
|
2020
|
+
this.energy = Math.max(1 - n, 0);
|
|
2021
|
+
}
|
|
2022
|
+
destroy() {}
|
|
2023
|
+
fromJSON(e) {}
|
|
2024
|
+
}, rr = class e extends Z {
|
|
2025
|
+
constructor(e = 1, t = null, n, r, i = !0) {
|
|
2026
|
+
super(n, r, d, i), this.alphaA = e, this.alphaB = t, this.reset(e, t);
|
|
2027
|
+
}
|
|
2028
|
+
get same() {
|
|
2029
|
+
return this._same;
|
|
2030
|
+
}
|
|
2031
|
+
set same(e) {
|
|
2032
|
+
this._same = e;
|
|
2033
|
+
}
|
|
2034
|
+
reset(e = 1, t = null, n, r) {
|
|
2035
|
+
this.same = t == null, this.alphaA = q(e), this.alphaB = q(t), n && super.reset(n, r);
|
|
2036
|
+
}
|
|
2037
|
+
initialize(e) {
|
|
2038
|
+
e.useAlpha = !0, e.transform.alphaA = this.alphaA.getValue(), e.transform.alphaB = this.same ? e.transform.alphaA : this.alphaB.getValue();
|
|
2039
|
+
}
|
|
2040
|
+
mutate(e, t, n) {
|
|
2041
|
+
this.energize(e, t, n), e.alpha = G.lerp(e.transform.alphaA, e.transform.alphaB, this.energy), e.alpha < .002 && (e.alpha = 0);
|
|
2042
|
+
}
|
|
2043
|
+
static fromJSON(t) {
|
|
2044
|
+
let { alphaA: n, alphaB: r, life: i, easing: a, isEnabled: o = !0 } = t;
|
|
2045
|
+
return new e(n, r, i, R(a), o);
|
|
2046
|
+
}
|
|
2047
|
+
}, ir = class e extends Z {
|
|
2048
|
+
constructor(e = new J(), t = 100, n = $n, r = Qn, i = er, a = !0) {
|
|
2049
|
+
super(r, i, f, a), this.targetPosition = e, this.radius = n, this.force = this.normalizeValue(t), this.radiusSq = this.radius * this.radius, this.attractionForce = new J(), this.lengthSq = 0;
|
|
2050
|
+
}
|
|
2051
|
+
reset(e = new J(), t = 100, n = $n, r, i) {
|
|
2052
|
+
this.targetPosition = e, this.radius = n, this.force = this.normalizeValue(t), this.radiusSq = this.radius * this.radius, this.attractionForce = new J(), this.lengthSq = 0, r && super.reset(r, i);
|
|
2053
|
+
}
|
|
2054
|
+
mutate(e, t, n) {
|
|
2055
|
+
this.energize(e, t, n), this.attractionForce.copy(this.targetPosition), this.attractionForce.sub(e.position), this.lengthSq = this.attractionForce.lengthSq(), this.lengthSq > 4e-6 && this.lengthSq < this.radiusSq && (this.attractionForce.normalize(), this.attractionForce.scalar(1 - this.lengthSq / this.radiusSq), this.attractionForce.scalar(this.force), e.acceleration.add(this.attractionForce));
|
|
2056
|
+
}
|
|
2057
|
+
static fromJSON(t) {
|
|
2058
|
+
let { x: n, y: r, z: i, force: a, radius: o, life: s, easing: c, isEnabled: l = !0 } = t;
|
|
2059
|
+
return new e(new J(n, r, i), a, o, s, R(c), l);
|
|
2060
|
+
}
|
|
2061
|
+
}, ar = class extends Z {
|
|
2062
|
+
constructor(e, t, n, r, i, a = !0) {
|
|
2063
|
+
super(r, i, p, a), this.reset(e, t, n);
|
|
2064
|
+
}
|
|
2065
|
+
reset(e, t, n, r, i) {
|
|
2066
|
+
this.emitter = e, this.useMass = t, this.onCollide = n, this.particles = [], this.delta = new J(), r && super.reset(r, i);
|
|
2067
|
+
}
|
|
2068
|
+
mutate(e, t, n) {
|
|
2069
|
+
let r = this.emitter ? this.emitter.particles.slice(n) : this.particles.slice(n), i, a, o, s, c, l, u = r.length;
|
|
2070
|
+
for (; u--;) i = r[u], i != e && (this.delta.copy(i.position).sub(e.position), a = this.delta.lengthSq(), s = e.radius + i.radius, a <= s * s && (o = s - Math.sqrt(a), o += .5, c = this._getAverageMass(e, i), l = this._getAverageMass(i, e), e.position.add(this.delta.clone().normalize().scalar(o * -c)), i.position.add(this.delta.normalize().scalar(o * l)), this.onCollide && this.onCollide(e, i)));
|
|
2071
|
+
}
|
|
2072
|
+
_getAverageMass(e, t) {
|
|
2073
|
+
return this.useMass ? t.mass / (e.mass + t.mass) : .5;
|
|
2074
|
+
}
|
|
2075
|
+
fromJSON(e) {}
|
|
2076
|
+
}, or = class e extends Z {
|
|
2077
|
+
constructor(e, t, n, r, i = !0) {
|
|
2078
|
+
super(n, r, m, i), this.reset(e, t);
|
|
2079
|
+
}
|
|
2080
|
+
get same() {
|
|
2081
|
+
return this._same;
|
|
2082
|
+
}
|
|
2083
|
+
set same(e) {
|
|
2084
|
+
this._same = e;
|
|
2085
|
+
}
|
|
2086
|
+
reset(e, t, n, r) {
|
|
2087
|
+
this.same = t == null, this.colorA = Yt(e), this.colorB = Yt(t), n && super.reset(n, r);
|
|
2088
|
+
}
|
|
2089
|
+
initialize(e) {
|
|
2090
|
+
e.transform.colorA = qe.getRGB(this.colorA.getValue()), e.useColor = !0, e.transform.colorB = this.same ? e.transform.colorA : qe.getRGB(this.colorB.getValue());
|
|
2091
|
+
}
|
|
2092
|
+
mutate(e, t, n) {
|
|
2093
|
+
this.energize(e, t, n), this._same ? (e.color.r = e.transform.colorA.r, e.color.g = e.transform.colorA.g, e.color.b = e.transform.colorA.b) : (e.color.r = G.lerp(e.transform.colorA.r, e.transform.colorB.r, this.energy), e.color.g = G.lerp(e.transform.colorA.g, e.transform.colorB.g, this.energy), e.color.b = G.lerp(e.transform.colorA.b, e.transform.colorB.b, this.energy));
|
|
2094
|
+
}
|
|
2095
|
+
static fromJSON(t) {
|
|
2096
|
+
let { colorA: n, colorB: r, life: i, easing: a, isEnabled: o = !0 } = t;
|
|
2097
|
+
return new e(n, r, i, R(a), o);
|
|
2098
|
+
}
|
|
2099
|
+
}, sr = class e extends Z {
|
|
2100
|
+
constructor(e, t, n, r, i) {
|
|
2101
|
+
super(n, r, h, i), this.reset(e, t);
|
|
2102
|
+
}
|
|
2103
|
+
reset(e, t = nr, n, r) {
|
|
2104
|
+
this.zone = e, this.zone.crossType = t, n && super.reset(n, r);
|
|
2105
|
+
}
|
|
2106
|
+
mutate(e, t, n) {
|
|
2107
|
+
this.energize(e, t, n), this.zone.crossing.call(this.zone, e);
|
|
2108
|
+
}
|
|
2109
|
+
static fromJSON(t) {
|
|
2110
|
+
let { zoneType: n, zoneParams: r, crossType: i, life: a, easing: o, isEnabled: s = !0 } = t, c = new Fn[n](...Object.values(r));
|
|
2111
|
+
return new e(c, i, a, R(o), s);
|
|
2112
|
+
}
|
|
2113
|
+
}, cr = class e extends Z {
|
|
2114
|
+
constructor(e, t, n, r, i, a = !0) {
|
|
2115
|
+
super(r, i, g, a), this.reset(e, t, n);
|
|
2116
|
+
}
|
|
2117
|
+
reset(e, t, n) {
|
|
2118
|
+
this.force = this.normalizeForce(new J(e, t, n)), this.force.id = Math.random();
|
|
2119
|
+
}
|
|
2120
|
+
mutate(e, t, n) {
|
|
2121
|
+
this.energize(e, t, n), e.acceleration.add(this.force);
|
|
2122
|
+
}
|
|
2123
|
+
static fromJSON(t) {
|
|
2124
|
+
let { fx: n, fy: r, fz: i, life: a, easing: o, isEnabled: s = !0 } = t;
|
|
2125
|
+
return new e(n, r, i, a, R(o), s);
|
|
2126
|
+
}
|
|
2127
|
+
}, lr = class e extends cr {
|
|
2128
|
+
constructor(e, t, n, r = !0) {
|
|
2129
|
+
super(0, -e, 0, t, n, r), this.type = _;
|
|
2130
|
+
}
|
|
2131
|
+
static fromJSON(t) {
|
|
2132
|
+
let { gravity: n, life: r, easing: i, isEnabled: a = !0 } = t;
|
|
2133
|
+
return new e(n, r, R(i), a);
|
|
2134
|
+
}
|
|
2135
|
+
}, ur = class e extends Z {
|
|
2136
|
+
constructor(e, t, n, r = tr, i, a, o = !0) {
|
|
2137
|
+
super(i, a, v, o), this.reset(e, t, n, r), this.time = 0;
|
|
2138
|
+
}
|
|
2139
|
+
reset(e, t, n, r = tr, i, a) {
|
|
2140
|
+
this.randomForce = this.normalizeForce(new J(e, t, n)), this.delayPan = q(r), this.time = 0, i && super.reset(i, a);
|
|
2141
|
+
}
|
|
2142
|
+
mutate(e, t, n) {
|
|
2143
|
+
if (this.energize(e, t, n), this.time += t, this.time >= this.delayPan.getValue()) {
|
|
2144
|
+
let t = G.randomAToB(-this.randomForce.x, this.randomForce.x), n = G.randomAToB(-this.randomForce.y, this.randomForce.y), r = G.randomAToB(-this.randomForce.z, this.randomForce.z);
|
|
2145
|
+
e.acceleration.addValue(t, n, r), this.time = 0;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
static fromJSON(t) {
|
|
2149
|
+
let { x: n, y: r, z: i, delay: a, life: o, easing: s, isEnabled: c = !0 } = t;
|
|
2150
|
+
return new e(n, r, i, a, o, R(s), c);
|
|
2151
|
+
}
|
|
2152
|
+
}, dr = class e extends ir {
|
|
2153
|
+
constructor(e, t, n, r, i, a = !0) {
|
|
2154
|
+
super(e, t, n, r, i, a), this.force *= -1, this.type = y;
|
|
2155
|
+
}
|
|
2156
|
+
reset(e, t, n, r, i) {
|
|
2157
|
+
super.reset(e, t, n, r, i), this.force *= -1;
|
|
2158
|
+
}
|
|
2159
|
+
static fromJSON(t) {
|
|
2160
|
+
let { x: n, y: r, z: i, force: a, radius: o, life: s, easing: c, isEnabled: l = !0 } = t;
|
|
2161
|
+
return new e(new J(n, r, i), a, o, s, R(c), l);
|
|
2162
|
+
}
|
|
2163
|
+
}, fr = class e extends Z {
|
|
2164
|
+
constructor(e, t, n, r, i, a = !0) {
|
|
2165
|
+
super(r, i, b, a), this.reset(e, t, n);
|
|
2166
|
+
}
|
|
2167
|
+
get rotationType() {
|
|
2168
|
+
return this._rotationType;
|
|
2169
|
+
}
|
|
2170
|
+
set rotationType(e) {
|
|
2171
|
+
this._rotationType = e;
|
|
2172
|
+
}
|
|
2173
|
+
reset(e, t, n, r, i) {
|
|
2174
|
+
this.x = e || 0, this.y = t || 0, this.z = n || 0, e === void 0 || e == "same" ? this.rotationType = "same" : t == null ? this.rotationType = "set" : n === void 0 ? this.rotationType = "to" : (this.rotationType = "add", this.x = q(this.x * I), this.y = q(this.y * I), this.z = q(this.z * I)), r && super.reset(r, i);
|
|
2175
|
+
}
|
|
2176
|
+
initialize(e) {
|
|
2177
|
+
switch (this.rotationType) {
|
|
2178
|
+
case "same": break;
|
|
2179
|
+
case "set":
|
|
2180
|
+
this._setRotation(e.rotation, this.x);
|
|
2181
|
+
break;
|
|
2182
|
+
case "to":
|
|
2183
|
+
e.transform.fR = e.transform.fR || new J(), e.transform.tR = e.transform.tR || new J(), this._setRotation(e.transform.fR, this.x), this._setRotation(e.transform.tR, this.y);
|
|
2184
|
+
break;
|
|
2185
|
+
case "add":
|
|
2186
|
+
e.transform.addR = new J(this.x.getValue(), this.y.getValue(), this.z.getValue());
|
|
2187
|
+
break;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
_setRotation(e, t) {
|
|
2191
|
+
if (e = e || new J(), t == "random") {
|
|
2192
|
+
var n = G.randomAToB(-F, F), r = G.randomAToB(-F, F), i = G.randomAToB(-F, F);
|
|
2193
|
+
e.set(n, r, i);
|
|
2194
|
+
} else t instanceof J && e.copy(t);
|
|
2195
|
+
}
|
|
2196
|
+
mutate(e, t, n) {
|
|
2197
|
+
switch (this.energize(e, t, n), this.rotationType) {
|
|
2198
|
+
case "same":
|
|
2199
|
+
e.rotation || (e.rotation = new J()), e.rotation.copy(e.velocity);
|
|
2200
|
+
break;
|
|
2201
|
+
case "set": break;
|
|
2202
|
+
case "to":
|
|
2203
|
+
e.rotation.x = G.lerp(e.transform.fR.x, e.transform.tR.x, this.energy), e.rotation.y = G.lerp(e.transform.fR.y, e.transform.tR.y, this.energy), e.rotation.z = G.lerp(e.transform.fR.z, e.transform.tR.z, this.energy);
|
|
2204
|
+
break;
|
|
2205
|
+
case "add":
|
|
2206
|
+
e.rotation.add(e.transform.addR);
|
|
2207
|
+
break;
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
static fromJSON(t) {
|
|
2211
|
+
let { x: n, y: r, z: i, life: a, easing: o, isEnabled: s = !0 } = t;
|
|
2212
|
+
return new e(n, r, i, a, R(o), s);
|
|
2213
|
+
}
|
|
2214
|
+
}, pr = class e extends Z {
|
|
2215
|
+
constructor(e, t, n, r, i = !0) {
|
|
2216
|
+
super(n, r, x, i), this.reset(e, t);
|
|
2217
|
+
}
|
|
2218
|
+
get same() {
|
|
2219
|
+
return this._same;
|
|
2220
|
+
}
|
|
2221
|
+
set same(e) {
|
|
2222
|
+
this._same = e;
|
|
2223
|
+
}
|
|
2224
|
+
reset(e, t, n, r) {
|
|
2225
|
+
this.same = t == null, this.scaleA = q(e || 1), this.scaleB = q(t), n && super.reset(n, r);
|
|
2226
|
+
}
|
|
2227
|
+
initialize(e) {
|
|
2228
|
+
e.transform.scaleA = this.scaleA.getValue(), e.transform.oldRadius = e.radius, e.transform.scaleB = this.same ? e.transform.scaleA : this.scaleB.getValue();
|
|
2229
|
+
}
|
|
2230
|
+
mutate(e, t, n) {
|
|
2231
|
+
this.energize(e, t, n), e.scale = G.lerp(e.transform.scaleA, e.transform.scaleB, this.energy), e.scale < 5e-4 && (e.scale = 0), e.radius = e.transform.oldRadius * e.scale;
|
|
2232
|
+
}
|
|
2233
|
+
static fromJSON(t) {
|
|
2234
|
+
let { scaleA: n, scaleB: r, life: i, easing: a, isEnabled: o = !0 } = t;
|
|
2235
|
+
return new e(n, r, i, R(a), o);
|
|
2236
|
+
}
|
|
2237
|
+
}, mr = class e extends Z {
|
|
2238
|
+
constructor(e, t, n, r, i, a, o, s = !0) {
|
|
2239
|
+
super(a, o, S, s), this.reset(e, t, n, r, i);
|
|
2240
|
+
}
|
|
2241
|
+
reset(e, t, n, r, i) {
|
|
2242
|
+
this.pos ? this.pos.set(e, t, n) : this.pos = new J(e, t, n), this.spring = r || .1, this.friction = i || .98;
|
|
2243
|
+
}
|
|
2244
|
+
mutate(e, t, n) {
|
|
2245
|
+
this.energize(e, t, n), e.velocity.x += (this.pos.x - e.position.x) * this.spring, e.velocity.y += (this.pos.y - e.position.y) * this.spring, e.velocity.z += (this.pos.z - e.position.z) * this.spring;
|
|
2246
|
+
}
|
|
2247
|
+
static fromJSON(t) {
|
|
2248
|
+
let { x: n, y: r, z: i, spring: a, friction: o, life: s, easing: c, isEnabled: l = !0 } = t;
|
|
2249
|
+
return new e(n, r, i, a, o, s, R(c), l);
|
|
2250
|
+
}
|
|
2251
|
+
}, hr = /* @__PURE__ */ s({
|
|
2252
|
+
Alpha: () => rr,
|
|
2253
|
+
Attraction: () => ir,
|
|
2254
|
+
Behaviour: () => Z,
|
|
2255
|
+
Collision: () => ar,
|
|
2256
|
+
Color: () => or,
|
|
2257
|
+
CrossZone: () => sr,
|
|
2258
|
+
Force: () => cr,
|
|
2259
|
+
Gravity: () => lr,
|
|
2260
|
+
RandomDrift: () => ur,
|
|
2261
|
+
Repulsion: () => dr,
|
|
2262
|
+
Rotate: () => fr,
|
|
2263
|
+
Scale: () => pr,
|
|
2264
|
+
Spring: () => mr
|
|
2265
|
+
}), gr = (e) => zn.fromJSON(e), _r = (e, t) => {
|
|
2266
|
+
let n = [];
|
|
2267
|
+
return e.forEach((e) => {
|
|
2268
|
+
let { type: r, properties: i } = e;
|
|
2269
|
+
if (!We.includes(r)) throw Error(`The initializer type ${r} is invalid or not yet supported`);
|
|
2270
|
+
P.includes(r) ? n.push(Gn[r].fromJSON(i, t)) : n.push(Gn[r].fromJSON(i));
|
|
2271
|
+
}), n;
|
|
2272
|
+
}, vr = (e) => {
|
|
2273
|
+
let t = [];
|
|
2274
|
+
return e.forEach((e) => {
|
|
2275
|
+
let { type: n, properties: r } = e;
|
|
2276
|
+
if (!Ge.includes(n)) throw Error(`The behaviour type ${n} is invalid or not yet supported`);
|
|
2277
|
+
t.push(hr[n].fromJSON(r));
|
|
2278
|
+
}), t;
|
|
2279
|
+
}, yr = (e, t, n, r) => {
|
|
2280
|
+
let { preParticles: i = 500, integrationType: a = ge, emitters: o = [] } = e, s = new n(t, i, a);
|
|
2281
|
+
return o.forEach((e) => {
|
|
2282
|
+
let n = new r(), { rate: i, rotation: a, initializers: o, behaviours: c, emitterBehaviours: l = [], position: u, totalEmitTimes: d = Infinity, life: f = Infinity, damping: p = Kn } = e;
|
|
2283
|
+
n.damping = p, n.setRate(gr(i)).setRotation(a).setInitializers(_r(o, t)).setBehaviours(vr(c)).setEmitterBehaviours(vr(l)).setPosition(u).emit(d, f), s.addEmitter(n);
|
|
2284
|
+
}), s;
|
|
2285
|
+
}, br = { shouldAutoEmit: !0 }, xr = (e) => zn.fromJSON(e), Sr = (e, t) => new Promise((n, r) => {
|
|
2286
|
+
if (!e.length) return n([]);
|
|
2287
|
+
let i = e.length, a = Array(i), o = 0, s = (e, t) => {
|
|
2288
|
+
if (a[e] = t, o += 1, o === i) return n(a);
|
|
2289
|
+
};
|
|
2290
|
+
e.forEach((e, n) => {
|
|
2291
|
+
let { type: i, properties: a } = e;
|
|
2292
|
+
if (!We.includes(i)) return r(`The initializer type ${i} is invalid or not yet supported`);
|
|
2293
|
+
if (a.texture) {
|
|
2294
|
+
new t.TextureLoader().load(a.texture, (e) => s(n, Bn.fromJSON({
|
|
2295
|
+
...a,
|
|
2296
|
+
loadedTexture: e
|
|
2297
|
+
}, t)), void 0, r);
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
s(n, P.includes(i) ? Gn[i].fromJSON(a, t) : Gn[i].fromJSON(a));
|
|
2301
|
+
});
|
|
2302
|
+
}), Cr = (e) => new Promise((t, n) => {
|
|
2303
|
+
if (!e.length) return t([]);
|
|
2304
|
+
let r = e.length, i = [];
|
|
2305
|
+
e.forEach((e) => {
|
|
2306
|
+
let { type: a, properties: o } = e;
|
|
2307
|
+
if (!Ge.includes(a)) return n(`The behaviour type ${a} is invalid or not yet supported`);
|
|
2308
|
+
if (i.push(hr[a].fromJSON(o)), i.length === r) return t(i);
|
|
2309
|
+
});
|
|
2310
|
+
}), wr = (e, t, n, r) => new Promise((i, a) => {
|
|
2311
|
+
if (!e.length) return i([]);
|
|
2312
|
+
let o = e.length;
|
|
2313
|
+
if (!o) return i([]);
|
|
2314
|
+
let s = Array(o), c = 0;
|
|
2315
|
+
e.forEach((e, l) => {
|
|
2316
|
+
let u = new t(), { rate: d, rotation: f, initializers: p, behaviours: m, emitterBehaviours: h = [], position: g, totalEmitTimes: _ = Infinity, life: v = Infinity, damping: y = Kn } = e;
|
|
2317
|
+
u.damping = y, u.setRate(xr(d)).setRotation(f).setPosition(g), Sr(p, n).then((e) => (u.setInitializers(e), Cr(m))).then((e) => (u.setBehaviours(e), Cr(h))).then((e) => (u.setEmitterBehaviours(e), Promise.resolve(u))).then((e) => {
|
|
2318
|
+
if (s[l] = r ? e.emit(_, v) : e.setTotalEmitTimes(_).setLife(v), c += 1, c === o) return i(s);
|
|
2319
|
+
}).catch(a);
|
|
2320
|
+
});
|
|
2321
|
+
}), Tr = (e, t, n, r, i = {}) => new Promise((a, o) => {
|
|
2322
|
+
let { preParticles: s = 500, integrationType: c = ge, emitters: l = [] } = e, u = new n(s, c), { shouldAutoEmit: d } = {
|
|
2323
|
+
...br,
|
|
2324
|
+
...i
|
|
2325
|
+
};
|
|
2326
|
+
wr(l, r, t, d).then((e) => {
|
|
2327
|
+
let t = e.length;
|
|
2328
|
+
if (!t) return a(u);
|
|
2329
|
+
e.forEach((e) => {
|
|
2330
|
+
u.addEmitter(e), u.emitters.length === t && a(u);
|
|
2331
|
+
});
|
|
2332
|
+
}).catch(o);
|
|
2333
|
+
}), Er = class e {
|
|
2334
|
+
constructor(e = 500, t = Zt) {
|
|
2335
|
+
this.type = sn, this.canUpdate = !0, this.preParticles = e, this.integrationType = t, this.emitters = [], this.renderers = [], this.pool = new Y(), this.eventDispatcher = new vn();
|
|
2336
|
+
}
|
|
2337
|
+
static fromJSON(t, n) {
|
|
2338
|
+
return yr(t, n, e, Zn);
|
|
2339
|
+
}
|
|
2340
|
+
static fromJSONAsync(t, n, r) {
|
|
2341
|
+
return Tr(t, n, e, Zn, r);
|
|
2342
|
+
}
|
|
2343
|
+
dispatch(e, t = this) {
|
|
2344
|
+
this.eventDispatcher.dispatchEvent(e, t);
|
|
2345
|
+
}
|
|
2346
|
+
addRenderer(e) {
|
|
2347
|
+
return this.renderers.push(e), e.init(this), this;
|
|
2348
|
+
}
|
|
2349
|
+
removeRenderer(e) {
|
|
2350
|
+
return this.renderers.splice(this.renderers.indexOf(e), 1), e.remove(this), this;
|
|
2351
|
+
}
|
|
2352
|
+
addEmitter(e) {
|
|
2353
|
+
let t = this.emitters.length;
|
|
2354
|
+
return e.parent = this, e.index = t, this.emitters.push(e), this.dispatch(mn, e), this;
|
|
2355
|
+
}
|
|
2356
|
+
removeEmitter(e) {
|
|
2357
|
+
return e.parent === this ? (e.parent = null, e.index = void 0, this.emitters.splice(this.emitters.indexOf(e), 1), this.dispatch(hn, e), this) : this;
|
|
2358
|
+
}
|
|
2359
|
+
emit({ onStart: e, onUpdate: t, onEnd: n }) {
|
|
2360
|
+
e && e(), t && this.eventDispatcher.addEventListener(un, t);
|
|
2361
|
+
let r = this.emitters.map((e) => {
|
|
2362
|
+
let { life: t } = e;
|
|
2363
|
+
return t === Infinity ? (n && n(), e.experimental_emit(), Promise.resolve()) : new Promise((t) => {
|
|
2364
|
+
e.addOnEmitterDeadEventListener(() => {
|
|
2365
|
+
n && n(), t();
|
|
2366
|
+
}), e.experimental_emit();
|
|
2367
|
+
});
|
|
2368
|
+
});
|
|
2369
|
+
try {
|
|
2370
|
+
return Promise.all(r);
|
|
2371
|
+
} catch (e) {
|
|
2372
|
+
console.warn(e);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
update(e = Ue) {
|
|
2376
|
+
let t = e || .0167;
|
|
2377
|
+
if (this.canUpdate) {
|
|
2378
|
+
if (t > 0) {
|
|
2379
|
+
let e = this.emitters.length;
|
|
2380
|
+
for (; e--;) {
|
|
2381
|
+
let n = this.emitters[e];
|
|
2382
|
+
n.update(t), n.particles.length && this.dispatch("SYSTEM_UPDATE");
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
this.dispatch(_n);
|
|
2386
|
+
}
|
|
2387
|
+
return Promise.resolve();
|
|
2388
|
+
}
|
|
2389
|
+
getCount() {
|
|
2390
|
+
let e = this.emitters.length, t = 0, n;
|
|
2391
|
+
for (n = 0; n < e; n++) t += this.emitters[n].particles.length;
|
|
2392
|
+
return t;
|
|
2393
|
+
}
|
|
2394
|
+
destroy() {
|
|
2395
|
+
let e = this.emitters.length;
|
|
2396
|
+
this.canUpdate = !1;
|
|
2397
|
+
for (let t = 0; t < e; t++) this.emitters[t] && this.emitters[t].destroy(), delete this.emitters[t];
|
|
2398
|
+
for (let t = 0; t < e; t++) this.renderers[t] && this.renderers[t].destroy && (this.renderers[t].destroy(), delete this.renderers[t]);
|
|
2399
|
+
this.emitters.length = 0, this.pool.destroy(), this.canUpdate = !0;
|
|
2400
|
+
}
|
|
2401
|
+
}, Dr = {
|
|
2402
|
+
addEventListener: function(e, t) {
|
|
2403
|
+
return e.eventDispatcher.addEventListener("SYSTEM_UPDATE", t), this;
|
|
2404
|
+
},
|
|
2405
|
+
drawZone: function(e, t, n, r = {}) {
|
|
2406
|
+
let { width: i = 15, height: a = 15, depth: o = 15, radius: s = 15, x: c = 0, y: l = 0, z: u = 0 } = r, d;
|
|
2407
|
+
r.isPointZone() && (d = new e.SphereGeometry(15)), r.isLineZone(), r.isBoxZone() && (d = new e.BoxGeometry(i, a, o)), r.isSphereZone() && (d = new e.SphereGeometry(s, 15, 15)), r.isMeshZone() && (d = r.geometry.geometry ? r.geometry.geometry.clone() : r.geometry.clone()), d || (d = new e.BoxGeometry(i, a, o));
|
|
2408
|
+
let f = new e.MeshBasicMaterial({
|
|
2409
|
+
color: "#2194ce",
|
|
2410
|
+
wireframe: !0
|
|
2411
|
+
}), p = new e.Mesh(d.clone(), f);
|
|
2412
|
+
n.add(p), this.addEventListener(t, function() {
|
|
2413
|
+
p.position.set(c, l, u);
|
|
2414
|
+
});
|
|
2415
|
+
},
|
|
2416
|
+
drawEmitter: function(e, t, n, r, i) {
|
|
2417
|
+
let a = new e.OctahedronGeometry(15), o = new e.MeshBasicMaterial({
|
|
2418
|
+
color: i || "#aaa",
|
|
2419
|
+
wireframe: !0
|
|
2420
|
+
}), s = new e.Mesh(a.clone(), o);
|
|
2421
|
+
n.add(s), this.addEventListener(t, function() {
|
|
2422
|
+
s.position.copy(r.position), s.rotation.set(r.rotation.x, r.rotation.y, r.rotation.z);
|
|
2423
|
+
});
|
|
2424
|
+
},
|
|
2425
|
+
renderInfo: (function() {
|
|
2426
|
+
function e(e, t) {
|
|
2427
|
+
var n = e == "material" ? "_materialPool" : "_targetPool";
|
|
2428
|
+
return t.renderers[0][n].cID;
|
|
2429
|
+
}
|
|
2430
|
+
function t(e) {
|
|
2431
|
+
var t = e.emitters[0];
|
|
2432
|
+
return Math.round(t.p.x) + "," + Math.round(t.p.y) + "," + Math.round(t.p.z);
|
|
2433
|
+
}
|
|
2434
|
+
return function(n, r) {
|
|
2435
|
+
this.addInfo(r);
|
|
2436
|
+
var i = "";
|
|
2437
|
+
switch (this._infoType) {
|
|
2438
|
+
case 2:
|
|
2439
|
+
i += "emitter:" + n.emitters.length + "<br>", i += "em speed:" + n.emitters[0].cID + "<br>", i += "pos:" + t(n);
|
|
2440
|
+
break;
|
|
2441
|
+
case 3:
|
|
2442
|
+
i += n.renderers[0].name + "<br>", i += "target:" + e("target") + "<br>", i += "material:" + e("material");
|
|
2443
|
+
break;
|
|
2444
|
+
default: i += "particles:" + n.getCount() + "<br>", i += "pool:" + n.pool.getCount() + "<br>", i += "total:" + (n.getCount() + n.pool.getCount());
|
|
2445
|
+
}
|
|
2446
|
+
this._infoCon.innerHTML = i;
|
|
2447
|
+
};
|
|
2448
|
+
})(),
|
|
2449
|
+
addInfo: (function() {
|
|
2450
|
+
return function(e) {
|
|
2451
|
+
var t = this;
|
|
2452
|
+
if (!this._infoCon) {
|
|
2453
|
+
this._infoCon = document.createElement("div"), this._infoCon.style.cssText = [
|
|
2454
|
+
"position:fixed;bottom:0px;left:0;cursor:pointer;",
|
|
2455
|
+
"opacity:0.9;z-index:10000;padding:10px;font-size:12px;",
|
|
2456
|
+
"width:120px;height:50px;background-color:#002;color:#0ff;"
|
|
2457
|
+
].join(""), this._infoType = 1, this._infoCon.addEventListener("click", function() {
|
|
2458
|
+
t._infoType++, t._infoType > 3 && (t._infoType = 1);
|
|
2459
|
+
}, !1);
|
|
2460
|
+
var n, r;
|
|
2461
|
+
switch (e) {
|
|
2462
|
+
case 2:
|
|
2463
|
+
n = "#201", r = "#f08";
|
|
2464
|
+
break;
|
|
2465
|
+
case 3:
|
|
2466
|
+
n = "#020", r = "#0f0";
|
|
2467
|
+
break;
|
|
2468
|
+
default: n = "#002", r = "#0ff";
|
|
2469
|
+
}
|
|
2470
|
+
this._infoCon.style["background-color"] = n, this._infoCon.style.color = r;
|
|
2471
|
+
}
|
|
2472
|
+
this._infoCon.parentNode || document.body.appendChild(this._infoCon);
|
|
2473
|
+
};
|
|
2474
|
+
})()
|
|
2475
|
+
};
|
|
2476
|
+
//#endregion
|
|
2477
|
+
//#region src/debug/log.js
|
|
2478
|
+
function Or() {
|
|
2479
|
+
let e = 0;
|
|
2480
|
+
if (window.console && window.console.trace) {
|
|
2481
|
+
var t = Array.prototype.slice.call(arguments);
|
|
2482
|
+
if ((arguments[0] + "").indexOf("+") == 0) {
|
|
2483
|
+
var n = parseInt(arguments[0]);
|
|
2484
|
+
e < n && (t.shift(), console.trace.apply(console, t), e++);
|
|
2485
|
+
} else t.unshift("+15"), this.apply(console, t);
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
//#endregion
|
|
2489
|
+
//#region src/emitter/FollowEmitter.js
|
|
2490
|
+
var kr = class extends Zn {
|
|
2491
|
+
constructor(e, t, n) {
|
|
2492
|
+
super(n), this.type = Xn, this.mouseTarget = U.initValue(e, window), this.ease = U.initValue(t, .7), this._allowEmitting = !1, this.initEventHandler();
|
|
2493
|
+
}
|
|
2494
|
+
initEventHandler() {
|
|
2495
|
+
var e = this;
|
|
2496
|
+
this.mousemoveHandler = function(t) {
|
|
2497
|
+
e.mousemove.call(e, t);
|
|
2498
|
+
}, this.mousedownHandler = function(t) {
|
|
2499
|
+
e.mousedown.call(e, t);
|
|
2500
|
+
}, this.mouseupHandler = function(t) {
|
|
2501
|
+
e.mouseup.call(e, t);
|
|
2502
|
+
}, this.mouseTarget.addEventListener("mousemove", this.mousemoveHandler, !1);
|
|
2503
|
+
}
|
|
2504
|
+
emit() {
|
|
2505
|
+
this._allowEmitting = !0;
|
|
2506
|
+
}
|
|
2507
|
+
stopEmit() {
|
|
2508
|
+
this._allowEmitting = !1;
|
|
2509
|
+
}
|
|
2510
|
+
setCameraAndCanvas(e, t) {
|
|
2511
|
+
this.camera = e, this.canvas = t;
|
|
2512
|
+
}
|
|
2513
|
+
mousemove(e) {
|
|
2514
|
+
e.layerX || e.layerX == 0 ? (this.position.x += (e.layerX - this.position.x) * this.ease, this.position.y += (e.layerY - this.position.y) * this.ease) : (e.offsetX || e.offsetX == 0) && (this.position.x += (e.offsetX - this.position.x) * this.ease, this.position.y += (e.offsetY - this.position.y) * this.ease), this.position.copy(H.toSpacePos(this.position, this.camera, this.canvas)), this._allowEmitting && super.emit("once");
|
|
2515
|
+
}
|
|
2516
|
+
destroy() {
|
|
2517
|
+
super.destroy(), this.mouseTarget.removeEventListener("mousemove", this.mousemoveHandler, !1);
|
|
2518
|
+
}
|
|
2519
|
+
}, Ar = class {
|
|
2520
|
+
constructor(e = le) {
|
|
2521
|
+
this.type = e;
|
|
2522
|
+
}
|
|
2523
|
+
init(e) {
|
|
2524
|
+
var t = this;
|
|
2525
|
+
this.system = e, this.system.eventDispatcher.addEventListener(un, function(e) {
|
|
2526
|
+
t.onSystemUpdate.call(t, e);
|
|
2527
|
+
}), this.system.eventDispatcher.addEventListener(dn, function(e) {
|
|
2528
|
+
t.onParticleCreated.call(t, e);
|
|
2529
|
+
}), this.system.eventDispatcher.addEventListener(fn, function(e) {
|
|
2530
|
+
t.onParticleUpdate.call(t, e);
|
|
2531
|
+
}), this.system.eventDispatcher.addEventListener(pn, function(e) {
|
|
2532
|
+
t.onParticleDead.call(t, e);
|
|
2533
|
+
}), this.logRendererType();
|
|
2534
|
+
}
|
|
2535
|
+
remove() {
|
|
2536
|
+
this.system = null;
|
|
2537
|
+
}
|
|
2538
|
+
onParticleCreated(e) {}
|
|
2539
|
+
onParticleUpdate(e) {}
|
|
2540
|
+
onParticleDead(e) {}
|
|
2541
|
+
onSystemUpdate(e) {}
|
|
2542
|
+
logRendererType() {
|
|
2543
|
+
_e && console.log(`${this.type}`);
|
|
2544
|
+
}
|
|
2545
|
+
}, jr = class extends Ar {
|
|
2546
|
+
constructor() {
|
|
2547
|
+
super(ue), this.targetPool = new Y(), this.materialPool = new Y();
|
|
2548
|
+
}
|
|
2549
|
+
onSystemUpdate() {}
|
|
2550
|
+
onParticleCreated(e) {}
|
|
2551
|
+
onParticleUpdate(e) {}
|
|
2552
|
+
onParticleDead(e) {}
|
|
2553
|
+
}, Mr = class extends Ar {
|
|
2554
|
+
constructor(e, t) {
|
|
2555
|
+
super(fe), this.container = e, this._targetPool = new Y(), this._materialPool = new Y(), this._body = new t.Mesh(new t.BoxGeometry(50, 50, 50), new t.MeshLambertMaterial({ color: "#ff0000" }));
|
|
2556
|
+
}
|
|
2557
|
+
isThreeSprite(e) {
|
|
2558
|
+
return e.target.isSprite;
|
|
2559
|
+
}
|
|
2560
|
+
onSystemUpdate() {}
|
|
2561
|
+
onParticleCreated(e) {
|
|
2562
|
+
e.target || (e.body || (e.body = this._body), e.target = this._targetPool.get(e.body), (e.useAlpha || e.useColor) && (e.target.material.__puid = Je.id(e.body.material), e.target.material = this._materialPool.get(e.target.material))), e.target && (e.target.position.copy(e.position), this.container.add(e.target));
|
|
2563
|
+
}
|
|
2564
|
+
onParticleUpdate(e) {
|
|
2565
|
+
let { target: t, useAlpha: n, useColor: r } = e;
|
|
2566
|
+
t && (t.position.copy(e.position), this.rotate(e), this.scale(e), n && (t.material.opacity = e.alpha, t.material.transparent = !0), r && t.material.color.copy(e.color));
|
|
2567
|
+
}
|
|
2568
|
+
rotate(e) {
|
|
2569
|
+
e.target.rotation.set(e.rotation.x, e.rotation.y, e.rotation.z);
|
|
2570
|
+
}
|
|
2571
|
+
scale(e) {
|
|
2572
|
+
e.target.scale.set(e.scale, e.scale, e.scale);
|
|
2573
|
+
}
|
|
2574
|
+
onParticleDead(e) {
|
|
2575
|
+
e.target && ((e.useAlpha || e.useColor) && this._materialPool.expire(e.target.material), this._targetPool.expire(e.target), this.container.remove(e.target), e.target = null);
|
|
2576
|
+
}
|
|
2577
|
+
}, Nr = class extends Mr {
|
|
2578
|
+
constructor(e, t) {
|
|
2579
|
+
super(e, t), this.type = de, this._body = new t.Sprite(new t.SpriteMaterial({ color: 16777215 }));
|
|
2580
|
+
}
|
|
2581
|
+
rotate(e) {
|
|
2582
|
+
e.target.material.rotation = e.rotation.z;
|
|
2583
|
+
}
|
|
2584
|
+
scale(e) {
|
|
2585
|
+
e.target.scale.set(e.scale * e.radius, e.scale * e.radius, 1);
|
|
2586
|
+
}
|
|
2587
|
+
}, Pr = 1e4, Fr = [
|
|
2588
|
+
12,
|
|
2589
|
+
4,
|
|
2590
|
+
4,
|
|
2591
|
+
16
|
|
2592
|
+
].reduce((e, t) => e + t), Ir = {
|
|
2593
|
+
position: 3,
|
|
2594
|
+
rotation: 1,
|
|
2595
|
+
size: 1,
|
|
2596
|
+
color: 4,
|
|
2597
|
+
alpha: 1,
|
|
2598
|
+
texID: 2
|
|
2599
|
+
};
|
|
2600
|
+
[
|
|
2601
|
+
3,
|
|
2602
|
+
1,
|
|
2603
|
+
1,
|
|
2604
|
+
4,
|
|
2605
|
+
1,
|
|
2606
|
+
2
|
|
2607
|
+
].reduce((e, t) => e + t);
|
|
2608
|
+
//#endregion
|
|
2609
|
+
//#region src/renderer/GPURenderer/common/constants.js
|
|
2610
|
+
var Lr = {
|
|
2611
|
+
blending: "AdditiveBlending",
|
|
2612
|
+
baseColor: 16777215,
|
|
2613
|
+
depthTest: !0,
|
|
2614
|
+
depthWrite: !1,
|
|
2615
|
+
transparent: !0,
|
|
2616
|
+
maxParticles: Pr,
|
|
2617
|
+
shouldDebugTextureAtlas: !1,
|
|
2618
|
+
shouldForceDesktopRenderer: !1,
|
|
2619
|
+
shouldForceMobileRenderer: !1
|
|
2620
|
+
}, Rr = class {
|
|
2621
|
+
constructor(e) {
|
|
2622
|
+
this.position = new e.Vector3(), this.rotation = new e.Vector3(), this.size = 0, this.color = new e.Color(), this.alpha = 0, this.texture = null, this.index = 0;
|
|
2623
|
+
}
|
|
2624
|
+
reset() {
|
|
2625
|
+
this.position.set(0, 0, 0), this.rotation.set(0, 0, 0), this.size = 0, this.color.setRGB(0, 0, 0), this.alpha = 0, this.texture = null;
|
|
2626
|
+
}
|
|
2627
|
+
}, zr = class {
|
|
2628
|
+
constructor(e = Infinity) {
|
|
2629
|
+
this.max = e, this.count = 0, this._items = {};
|
|
2630
|
+
}
|
|
2631
|
+
add(e) {
|
|
2632
|
+
this._items[e] === void 0 && (this._items[e] = this.count++);
|
|
2633
|
+
}
|
|
2634
|
+
find(e) {
|
|
2635
|
+
return this._items[e];
|
|
2636
|
+
}
|
|
2637
|
+
destroy() {
|
|
2638
|
+
this._items = {}, this.count = 0;
|
|
2639
|
+
}
|
|
2640
|
+
}, Br, Vr = class {
|
|
2641
|
+
constructor(e = Pr, t) {
|
|
2642
|
+
Br = t, this.maxParticles = e, this.createInterleavedBuffer().createBufferGeometry();
|
|
2643
|
+
}
|
|
2644
|
+
createInterleavedBuffer() {
|
|
2645
|
+
let e = new ArrayBuffer(this.maxParticles * Fr);
|
|
2646
|
+
return this.interleavedBuffer = new Br.InterleavedBuffer(new Float32Array(e), Fr), this;
|
|
2647
|
+
}
|
|
2648
|
+
createBufferGeometry() {
|
|
2649
|
+
this.geometry = new Br.BufferGeometry();
|
|
2650
|
+
let { interleavedBuffer: e, geometry: t } = this;
|
|
2651
|
+
return Object.keys(Ir).reduce((n, r) => {
|
|
2652
|
+
let i = Ir[r];
|
|
2653
|
+
return t.setAttribute(r, new Br.InterleavedBufferAttribute(e, i, n)), n += i;
|
|
2654
|
+
}, 0), this;
|
|
2655
|
+
}
|
|
2656
|
+
get buffer() {
|
|
2657
|
+
return this.interleavedBuffer;
|
|
2658
|
+
}
|
|
2659
|
+
get stride() {
|
|
2660
|
+
return Fr;
|
|
2661
|
+
}
|
|
2662
|
+
};
|
|
2663
|
+
//#endregion
|
|
2664
|
+
//#region node_modules/potpack/index.mjs
|
|
2665
|
+
function Hr(e) {
|
|
2666
|
+
let t = 0, n = 0;
|
|
2667
|
+
for (let r of e) t += r.w * r.h, n = Math.max(n, r.w);
|
|
2668
|
+
e.sort((e, t) => t.h - e.h);
|
|
2669
|
+
let r = [{
|
|
2670
|
+
x: 0,
|
|
2671
|
+
y: 0,
|
|
2672
|
+
w: Math.max(Math.ceil(Math.sqrt(t / .95)), n),
|
|
2673
|
+
h: Infinity
|
|
2674
|
+
}], i = 0, a = 0;
|
|
2675
|
+
for (let t of e) for (let e = r.length - 1; e >= 0; e--) {
|
|
2676
|
+
let n = r[e];
|
|
2677
|
+
if (!(t.w > n.w || t.h > n.h)) {
|
|
2678
|
+
if (t.x = n.x, t.y = n.y, a = Math.max(a, t.y + t.h), i = Math.max(i, t.x + t.w), t.w === n.w && t.h === n.h) {
|
|
2679
|
+
let t = r.pop();
|
|
2680
|
+
e < r.length && (r[e] = t);
|
|
2681
|
+
} else t.h === n.h ? (n.x += t.w, n.w -= t.w) : t.w === n.w ? (n.y += t.h, n.h -= t.h) : (r.push({
|
|
2682
|
+
x: n.x + t.w,
|
|
2683
|
+
y: n.y,
|
|
2684
|
+
w: n.w - t.w,
|
|
2685
|
+
h: t.h
|
|
2686
|
+
}), n.y += t.h, n.h -= t.h);
|
|
2687
|
+
break;
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
return {
|
|
2691
|
+
w: i,
|
|
2692
|
+
h: a,
|
|
2693
|
+
fill: t / (i * a) || 0
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
//#endregion
|
|
2697
|
+
//#region src/renderer/GPURenderer/common/TextureAtlas/index.js
|
|
2698
|
+
var Ur = class {
|
|
2699
|
+
constructor(e, t) {
|
|
2700
|
+
let { three: n, type: r } = e, i = new Float32Array(256 * 4), a = this.ctx = document.createElement("canvas").getContext("2d"), { canvas: o } = a;
|
|
2701
|
+
this.shouldDebug = t, this.rendererType = r, this.indexData = i, this.canvas = o, this.entries = [], r === "DesktopGPURenderer" && (this.atlasIndex = new n.DataTexture(i, 256, 1, n.RGBAFormat, n.FloatType)), o.width = o.height = 256, t && this.debug(o, a), this.atlasTexture = new n.CanvasTexture(o), this.atlasTexture.flipY = !1, e.material.uniforms.uTexture.value = this.atlasTexture, r === "DesktopGPURenderer" && (e.material.uniforms.atlasIndex.value = this.atlasIndex), e.material.uniformsNeedUpdate = !0;
|
|
2702
|
+
}
|
|
2703
|
+
log(...e) {
|
|
2704
|
+
_e && console.log(...e);
|
|
2705
|
+
}
|
|
2706
|
+
debug() {
|
|
2707
|
+
let { canvas: e, ctx: t } = this, n = e.width;
|
|
2708
|
+
t.fillStyle = "purple", t.fillRect(0, 0, n, n), t.fillStyle = "green", t.fillRect(0, n, n, n), t.fillStyle = "blue", t.fillRect(n, 0, n, n), t.fillStyle = "orange", t.fillRect(n, n, n, n), t.fillStyle = "yellow", t.font = e.width + "px Verdana", t.fillText("top row", 100, 500), t.fillStyle = "pink", t.fillText("bottom row", 100, 1500), e.style.position = "absolute", e.style.width = e.style.height = "300px", e.style.left = e.style.top = "0px", e.style.zIndex = 100, document.body.appendChild(e);
|
|
2709
|
+
}
|
|
2710
|
+
addTexture(e) {
|
|
2711
|
+
this.log("Adding texture to atlas:", e.uuid), e.textureIndex = this.entries.length, this.entries.push({ texture: e }), this.needsUpdate = !0;
|
|
2712
|
+
}
|
|
2713
|
+
update() {
|
|
2714
|
+
if (!this.needsUpdate) return;
|
|
2715
|
+
let { entries: e, canvas: t, indexData: n, ctx: r, atlasIndex: i, atlasTexture: a, rendererType: o } = this;
|
|
2716
|
+
for (let t = 0; t < e.length; t++) if (!e[t].texture.image) return;
|
|
2717
|
+
this.needsUpdate = !1;
|
|
2718
|
+
for (let t = 0; t < e.length; t++) {
|
|
2719
|
+
let n = e[t], { texture: r } = n, { width: i, height: a } = r.image;
|
|
2720
|
+
n.w = i, n.h = a;
|
|
2721
|
+
}
|
|
2722
|
+
let s = Hr(e);
|
|
2723
|
+
this.log("Rebuilt atlas:", s), (t.width != s.w || t.height != s.h) && (t.width = s.w, t.height = s.h);
|
|
2724
|
+
for (let i = 0; i < e.length; i++) {
|
|
2725
|
+
let e = this.entries[i], a = e.texture.textureIndex * 4;
|
|
2726
|
+
o === "DesktopGPURenderer" && (n[a + 0] = e.x / t.width, n[a + 1] = e.y / t.height, n[a + 2] = (e.x + e.w) / t.width, n[a + 3] = (e.y + e.h) / t.height), o === "MobileGPURenderer" && (n[a + 0] = e.x / (t.width + 1), n[a + 1] = e.y / (t.height + 1), n[a + 2] = (e.x + e.w) / (t.width + 1), n[a + 3] = (e.y + e.h) / (t.height + 1)), r.drawImage(e.texture.image, e.x, e.y, e.w, e.h);
|
|
2727
|
+
}
|
|
2728
|
+
o === "DesktopGPURenderer" && (i.needsUpdate = !0), a.needsUpdate = !0;
|
|
2729
|
+
}
|
|
2730
|
+
destroy() {
|
|
2731
|
+
let { atlasIndex: e, atlasTexture: t, canvas: n } = this;
|
|
2732
|
+
t.dispose(), e && e.dispose(), this.shouldDebug && n.remove(), this.entries = [];
|
|
2733
|
+
}
|
|
2734
|
+
}, Wr = () => "\n uniform vec3 baseColor;\n uniform sampler2D uTexture;\n uniform sampler2D atlasIndex;\n\n varying float vRotation;\n varying vec3 targetColor;\n varying float targetAlpha;\n varying vec4 tileRect;\n varying float tileID;\n\n void main() {\n gl_FragColor = vec4(baseColor * targetColor, targetAlpha);\n\n vec2 uv = gl_PointCoord;\n uv = mix(tileRect.xy, tileRect.zw, gl_PointCoord);\n\n float mid = 0.5;\n uv = vec2(\n cos(vRotation) * (uv.x - mid) - sin(vRotation) * (uv.y - mid) + mid,\n cos(vRotation) * (uv.y - mid) + sin(vRotation) * (uv.x - mid) + mid\n );\n\n gl_FragColor = gl_FragColor * texture2D(uTexture, uv);\n\n }\n", Gr = "600.0", Kr = () => `
|
|
2735
|
+
uniform sampler2D uTexture;
|
|
2736
|
+
//atlasIndex is a 256x1 float texture of tile rectangles as r=minx g=miny b=maxx a=maxy
|
|
2737
|
+
uniform sampler2D atlasIndex;
|
|
2738
|
+
|
|
2739
|
+
attribute float size;
|
|
2740
|
+
attribute vec3 color;
|
|
2741
|
+
attribute float alpha;
|
|
2742
|
+
attribute float texID;
|
|
2743
|
+
attribute float rotation;
|
|
2744
|
+
|
|
2745
|
+
varying float vRotation;
|
|
2746
|
+
varying vec3 targetColor;
|
|
2747
|
+
varying float targetAlpha;
|
|
2748
|
+
varying vec4 tileRect;
|
|
2749
|
+
varying float tileID;
|
|
2750
|
+
|
|
2751
|
+
void main() {
|
|
2752
|
+
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
2753
|
+
targetColor = color;
|
|
2754
|
+
targetAlpha = alpha;
|
|
2755
|
+
vRotation = rotation;
|
|
2756
|
+
|
|
2757
|
+
tileID = texID;
|
|
2758
|
+
//get the tile rectangle from the atlasIndex texture..
|
|
2759
|
+
tileRect = texture2D(atlasIndex, vec2((tileID + 0.5) / 256.0, 0.5));
|
|
2760
|
+
|
|
2761
|
+
gl_PointSize = ((size * ${Gr}) / -mvPosition.z);
|
|
2762
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
2763
|
+
}
|
|
2764
|
+
`, Q, qr = class extends Ar {
|
|
2765
|
+
constructor(e, t, n = Lr) {
|
|
2766
|
+
super(he), Q = this.three = t;
|
|
2767
|
+
let { camera: r, maxParticles: i, baseColor: a, blending: o, depthTest: s, depthWrite: c, transparent: l, shouldDebugTextureAtlas: u } = {
|
|
2768
|
+
...Lr,
|
|
2769
|
+
...n
|
|
2770
|
+
}, d = new Vr(i, Q), f = new Q.ShaderMaterial({
|
|
2771
|
+
uniforms: {
|
|
2772
|
+
baseColor: { value: new Q.Color(a) },
|
|
2773
|
+
uTexture: { value: null },
|
|
2774
|
+
atlasIndex: { value: null }
|
|
2775
|
+
},
|
|
2776
|
+
vertexShader: Kr(),
|
|
2777
|
+
fragmentShader: Wr(),
|
|
2778
|
+
blending: Q[o],
|
|
2779
|
+
depthTest: s,
|
|
2780
|
+
depthWrite: c,
|
|
2781
|
+
transparent: l
|
|
2782
|
+
});
|
|
2783
|
+
this.container = e, this.camera = r, this.targetPool = new Y(), this.uniqueList = new zr(i), this.particleBuffer = d, this.buffer = d.buffer, this.stride = d.stride, this.geometry = d.geometry, this.material = f, this.points = new Q.Points(this.geometry, this.material), this.points.frustumCulled = !1, this.shouldDebugTextureAtlas = u, this.container.add(this.points);
|
|
2784
|
+
}
|
|
2785
|
+
onSystemUpdate(e) {
|
|
2786
|
+
super.onSystemUpdate(e), this.buffer.needsUpdate = !0, this.textureAtlas && this.textureAtlas.update();
|
|
2787
|
+
}
|
|
2788
|
+
onParticleCreated(e) {
|
|
2789
|
+
e.target || (e.target = this.targetPool.get(Rr, Q), this.uniqueList.add(e.id)), this.updateTarget(e).mapParticleTargetPropsToPoint(e);
|
|
2790
|
+
}
|
|
2791
|
+
onParticleUpdate(e) {
|
|
2792
|
+
e.target && this.updateTarget(e).mapParticleTargetPropsToPoint(e);
|
|
2793
|
+
}
|
|
2794
|
+
onParticleDead(e) {
|
|
2795
|
+
e.target && (e.target.reset(), this.mapParticleTargetPropsToPoint(e), e.target = null);
|
|
2796
|
+
}
|
|
2797
|
+
updateTarget(e) {
|
|
2798
|
+
let { position: t, rotation: n, scale: r, radius: i, color: a, alpha: o, body: s, id: c } = e, { r: l, g: u, b: d } = a;
|
|
2799
|
+
if (e.target.position.copy(t), e.target.rotation.copy(n), e.target.size = r * i, e.target.color.setRGB(l, u, d), e.target.alpha = o, e.target.index = this.uniqueList.find(c), s && s instanceof Q.Sprite) {
|
|
2800
|
+
let { map: t } = s.material;
|
|
2801
|
+
e.target.texture = t, e.target.textureIndex = this.getTextureID(t, this.shouldDebugTextureAtlas);
|
|
2802
|
+
}
|
|
2803
|
+
return this;
|
|
2804
|
+
}
|
|
2805
|
+
mapParticleTargetPropsToPoint(e) {
|
|
2806
|
+
return this.updatePointPosition(e).updatePointSize(e).updatePointRotation(e).updatePointColor(e).updatePointAlpha(e).updatePointTextureIndex(e), this;
|
|
2807
|
+
}
|
|
2808
|
+
updatePointPosition(e) {
|
|
2809
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.position;
|
|
2810
|
+
return r.array[i.index * n + a + 0] = i.position.x, r.array[i.index * n + a + 1] = i.position.y, r.array[i.index * n + a + 2] = i.position.z, this;
|
|
2811
|
+
}
|
|
2812
|
+
updatePointSize(e) {
|
|
2813
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.size;
|
|
2814
|
+
return r.array[i.index * n + a + 0] = i.size, this;
|
|
2815
|
+
}
|
|
2816
|
+
updatePointRotation(e) {
|
|
2817
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.rotation;
|
|
2818
|
+
return r.array[i.index * n + a + 0] = i.rotation.z, this;
|
|
2819
|
+
}
|
|
2820
|
+
updatePointColor(e) {
|
|
2821
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.color;
|
|
2822
|
+
return r.array[i.index * n + a + 0] = i.color.r, r.array[i.index * n + a + 1] = i.color.g, r.array[i.index * n + a + 2] = i.color.b, this;
|
|
2823
|
+
}
|
|
2824
|
+
updatePointAlpha(e) {
|
|
2825
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.alpha;
|
|
2826
|
+
return r.array[i.index * n + a + 0] = i.alpha, this;
|
|
2827
|
+
}
|
|
2828
|
+
updatePointTextureIndex(e) {
|
|
2829
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.texID;
|
|
2830
|
+
return r.array[i.index * n + a + 0] = i.textureIndex, this;
|
|
2831
|
+
}
|
|
2832
|
+
getTextureID(e, t) {
|
|
2833
|
+
return e.textureIndex === void 0 && (this.textureAtlas || (this.textureAtlas = new Ur(this, t)), this.textureAtlas.addTexture(e)), e.textureIndex;
|
|
2834
|
+
}
|
|
2835
|
+
destroy() {
|
|
2836
|
+
let { container: e, points: t, textureAtlas: n, uniqueList: r } = this;
|
|
2837
|
+
e.remove(t), r.destroy(), n && n.destroy();
|
|
2838
|
+
}
|
|
2839
|
+
}, Jr = () => "\n uniform vec3 baseColor;\n uniform sampler2D uTexture;\n\n varying float vRotation;\n varying vec3 targetColor;\n varying float targetAlpha;\n varying vec4 tileRect;\n\n void main() {\n gl_FragColor = vec4(baseColor * targetColor, targetAlpha);\n\n vec2 uv = gl_PointCoord;\n uv = mix(tileRect.xy, tileRect.zw, gl_PointCoord);\n\n float mid = 0.5;\n uv = vec2(\n cos(vRotation) * (uv.x - mid) - sin(vRotation) * (uv.y - mid) + mid,\n cos(vRotation) * (uv.y - mid) + sin(vRotation) * (uv.x - mid) + mid\n );\n \n gl_FragColor = gl_FragColor * texture2D(uTexture, uv);\n }\n", Yr = () => `
|
|
2840
|
+
uniform sampler2D uTexture;
|
|
2841
|
+
uniform vec2 atlasDim;
|
|
2842
|
+
|
|
2843
|
+
attribute float size;
|
|
2844
|
+
attribute vec3 color;
|
|
2845
|
+
attribute float alpha;
|
|
2846
|
+
attribute vec2 texID;
|
|
2847
|
+
attribute float rotation;
|
|
2848
|
+
|
|
2849
|
+
varying float vRotation;
|
|
2850
|
+
varying vec3 targetColor;
|
|
2851
|
+
varying float targetAlpha;
|
|
2852
|
+
varying vec4 tileRect;
|
|
2853
|
+
|
|
2854
|
+
void main() {
|
|
2855
|
+
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
2856
|
+
targetColor = color;
|
|
2857
|
+
targetAlpha = alpha;
|
|
2858
|
+
vRotation = rotation;
|
|
2859
|
+
|
|
2860
|
+
vec2 tmin = floor(texID) / atlasDim;
|
|
2861
|
+
vec2 tmax = fract(texID);
|
|
2862
|
+
tileRect = vec4(tmin,tmax);
|
|
2863
|
+
|
|
2864
|
+
gl_PointSize = ((size * ${Gr}) / -mvPosition.z);
|
|
2865
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
2866
|
+
}
|
|
2867
|
+
`, $, Xr = class extends Ar {
|
|
2868
|
+
constructor(e, t, n = Lr) {
|
|
2869
|
+
super(me), $ = this.three = t;
|
|
2870
|
+
let { camera: r, maxParticles: i, baseColor: a, blending: o, depthTest: s, depthWrite: c, transparent: l, shouldDebugTextureAtlas: u } = {
|
|
2871
|
+
...Lr,
|
|
2872
|
+
...n
|
|
2873
|
+
}, d = new Vr(i, $), f = new $.ShaderMaterial({
|
|
2874
|
+
uniforms: {
|
|
2875
|
+
baseColor: { value: new $.Color(a) },
|
|
2876
|
+
uTexture: { value: null },
|
|
2877
|
+
FFatlasIndex: { value: null },
|
|
2878
|
+
atlasDim: { value: new $.Vector2() }
|
|
2879
|
+
},
|
|
2880
|
+
vertexShader: Yr(),
|
|
2881
|
+
fragmentShader: Jr(),
|
|
2882
|
+
blending: $[o],
|
|
2883
|
+
depthTest: s,
|
|
2884
|
+
depthWrite: c,
|
|
2885
|
+
transparent: l
|
|
2886
|
+
});
|
|
2887
|
+
this.camera = r, this.targetPool = new Y(), this.uniqueList = new zr(i), this.particleBuffer = d, this.buffer = d.buffer, this.stride = d.stride, this.geometry = d.geometry, this.material = f, this.points = new $.Points(this.geometry, this.material), this.points.frustumCulled = !1, this.shouldDebugTextureAtlas = u, e.add(this.points);
|
|
2888
|
+
}
|
|
2889
|
+
onSystemUpdate(e) {
|
|
2890
|
+
super.onSystemUpdate(e), this.buffer.needsUpdate = !0;
|
|
2891
|
+
let { textureAtlas: t } = this;
|
|
2892
|
+
t && (t.update(), this.material.uniforms.atlasDim.value.set(t.atlasTexture.image.width, t.atlasTexture.image.height));
|
|
2893
|
+
}
|
|
2894
|
+
onParticleCreated(e) {
|
|
2895
|
+
e.target || (e.target = this.targetPool.get(Rr, $), this.uniqueList.add(e.id)), this.updateTarget(e).mapParticleTargetPropsToPoint(e);
|
|
2896
|
+
}
|
|
2897
|
+
onParticleUpdate(e) {
|
|
2898
|
+
e.target && this.updateTarget(e).mapParticleTargetPropsToPoint(e);
|
|
2899
|
+
}
|
|
2900
|
+
onParticleDead(e) {
|
|
2901
|
+
e.target && (e.target.reset(), this.mapParticleTargetPropsToPoint(e), e.target = null);
|
|
2902
|
+
}
|
|
2903
|
+
updateTarget(e) {
|
|
2904
|
+
let { position: t, rotation: n, scale: r, radius: i, color: a, alpha: o, body: s, id: c } = e, { r: l, g: u, b: d } = a;
|
|
2905
|
+
if (e.target.position.copy(t), e.target.rotation.copy(n), e.target.size = r * i, e.target.color.setRGB(l, u, d), e.target.alpha = o, e.target.index = this.uniqueList.find(c), s && s instanceof $.Sprite) {
|
|
2906
|
+
let { map: t } = s.material;
|
|
2907
|
+
e.target.texture = t, e.target.textureIndex = this.getTextureID(t, this.shouldDebugTextureAtlas);
|
|
2908
|
+
}
|
|
2909
|
+
return this;
|
|
2910
|
+
}
|
|
2911
|
+
mapParticleTargetPropsToPoint(e) {
|
|
2912
|
+
return this.updatePointPosition(e).updatePointSize(e).updatePointRotation(e).updatePointColor(e).updatePointAlpha(e).updatePointTextureIndex(e), this;
|
|
2913
|
+
}
|
|
2914
|
+
updatePointPosition(e) {
|
|
2915
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.position;
|
|
2916
|
+
return r.array[i.index * n + a + 0] = i.position.x, r.array[i.index * n + a + 1] = i.position.y, r.array[i.index * n + a + 2] = i.position.z, this;
|
|
2917
|
+
}
|
|
2918
|
+
updatePointSize(e) {
|
|
2919
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.size;
|
|
2920
|
+
return r.array[i.index * n + a + 0] = i.size, this;
|
|
2921
|
+
}
|
|
2922
|
+
updatePointRotation(e) {
|
|
2923
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.rotation;
|
|
2924
|
+
return r.array[i.index * n + a + 0] = i.rotation.z, this;
|
|
2925
|
+
}
|
|
2926
|
+
updatePointColor(e) {
|
|
2927
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.color;
|
|
2928
|
+
return r.array[i.index * n + a + 0] = i.color.r, r.array[i.index * n + a + 1] = i.color.g, r.array[i.index * n + a + 2] = i.color.b, this;
|
|
2929
|
+
}
|
|
2930
|
+
updatePointAlpha(e) {
|
|
2931
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.alpha;
|
|
2932
|
+
return r.array[i.index * n + a + 0] = i.alpha, this;
|
|
2933
|
+
}
|
|
2934
|
+
updatePointTextureIndex(e) {
|
|
2935
|
+
let { geometry: t, stride: n, buffer: r } = this, { target: i } = e, { offset: a } = t.attributes.texID, o = i.index * n + a + 0;
|
|
2936
|
+
{
|
|
2937
|
+
let e = i.textureIndex * 4, t = this.textureAtlas, n = t.indexData, a = n[e++], s = n[e++], c = n[e++], l = n[e++];
|
|
2938
|
+
r.array[o] = (a * t.atlasTexture.image.width | 0) + c, r.array[o + 1] = (s * t.atlasTexture.image.height | 0) + l;
|
|
2939
|
+
}
|
|
2940
|
+
return this;
|
|
2941
|
+
}
|
|
2942
|
+
getTextureID(e, t) {
|
|
2943
|
+
return e.textureIndex === void 0 && (this.textureAtlas || (this.textureAtlas = new Ur(this, t)), this.textureAtlas.addTexture(e)), e.textureIndex;
|
|
2944
|
+
}
|
|
2945
|
+
destroy() {
|
|
2946
|
+
let { container: e, points: t, textureAtlas: n, uniqueList: r } = this;
|
|
2947
|
+
e.remove(t), r.destroy(), n && n.destroy();
|
|
2948
|
+
}
|
|
2949
|
+
}, Zr = class extends Ar {
|
|
2950
|
+
constructor(e, t, n = Lr) {
|
|
2951
|
+
super(pe);
|
|
2952
|
+
let { shouldForceDesktopRenderer: r, shouldForceMobileRenderer: i } = n, a = [
|
|
2953
|
+
e,
|
|
2954
|
+
t,
|
|
2955
|
+
n
|
|
2956
|
+
];
|
|
2957
|
+
return r ? new qr(...a) : i || !this.isFloatingPointTextureSupported() ? new Xr(...a) : new qr(...a);
|
|
2958
|
+
}
|
|
2959
|
+
isFloatingPointTextureSupported() {
|
|
2960
|
+
let e = document.createElement("canvas");
|
|
2961
|
+
if (window.WebGL2RenderingContext && e.getContext("webgl2")) return !0;
|
|
2962
|
+
let t = !!e.getContext("webgl").getExtension("OES_texture_float");
|
|
2963
|
+
return e.remove(), t;
|
|
2964
|
+
}
|
|
2965
|
+
}, Qr = Er;
|
|
2966
|
+
//#endregion
|
|
2967
|
+
export { rr as Alpha, Kt as ArraySpan, ir as Attraction, Z as Behaviour, yn as Body, Cn as BodySprite, Xt as Box, kn as BoxZone, ar as Collision, or as Color, Jt as ColorSpan, qe as ColorUtil, sr as CrossZone, jr as CustomRenderer, Dr as Debug, Zn as Emitter, kr as FollowEmitter, cr as Force, Zr as GPURenderer, lr as Gravity, Zt as INTEGRATION_TYPE_EULER, Qt as INTEGRATION_TYPE_RK2, $t as INTEGRATION_TYPE_RK4, en as INTEGRATION_TYPE_VERLET, Tn as InitializerUtil, En as Life, An as LineZone, Dn as Mass, G as MathUtils, Mr as MeshRenderer, jn as MeshZone, Je as PUID, cn as Particle, Mn as PointZone, rn as Polar3D, Hn as PolarVelocity, Y as Pool, In as Position, Un as RadialVelocity, Rn as Radius, ur as RandomDrift, zn as Rate, dr as Repulsion, fr as Rotate, Ln as Rotation, pr as Scale, Nn as ScreenZone, K as Span, Pn as SphereZone, mr as Spring, Nr as SpriteRenderer, Er as System, H as THREEUtil, Bn as Texture, U as Util, J as Vector3D, Wn as VectorVelocity, qt as createArraySpan, Yt as createColorSpan, q as createSpan, Qr as default, L as ease, Le as easeInBack, Pe as easeInCirc, Se as easeInCubic, je as easeInExpo, ze as easeInOutBack, Ie as easeInOutCirc, we as easeInOutCubic, Ne as easeInOutExpo, xe as easeInOutQuad, De as easeInOutQuart, Ae as easeInOutSine, ye as easeInQuad, Te as easeInQuart, Oe as easeInSine, ve as easeLinear, Re as easeOutBack, Fe as easeOutCirc, Ce as easeOutCubic, Me as easeOutExpo, be as easeOutQuad, Ee as easeOutQuart, ke as easeOutSine, R as getEasingByName, nn as integrate, Or as log, Be as setEasingByName, at as uid, ot as withDefaults };
|
|
2968
|
+
|
|
2969
|
+
//# sourceMappingURL=three-nebula.mjs.map
|