sparcoon 0.7.3 → 0.9.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/README.md +124 -76
- package/dist/artifact/FXArtifact.d.ts +120 -0
- package/dist/artifact/FXArtifact.js +1 -0
- package/dist/coreLayout.d.ts +22 -0
- package/dist/coreLayout.js +32 -0
- package/dist/editor/index.d.ts +8 -0
- package/dist/editor/index.js +17 -0
- package/dist/effect/FXEffect.d.ts +77 -0
- package/dist/effect/FXEffect.js +454 -0
- package/dist/effect/FXEffectSampling.Internal.d.ts +24 -0
- package/dist/effect/FXEffectSampling.Internal.js +165 -0
- package/dist/effect/FXEffectSpec.d.ts +115 -0
- package/dist/effect/FXEffectSpec.js +1 -0
- package/dist/emitter/FXEmitter.Internal.d.ts +23 -58
- package/dist/emitter/FXEmitter.Internal.js +13 -29
- package/dist/emitter/FXEmitter.d.ts +54 -46
- package/dist/emitter/FXEmitter.js +357 -186
- package/dist/emitter/FXFromArtifactsOptions.d.ts +13 -0
- package/dist/emitter/FXFromArtifactsOptions.js +1 -0
- package/dist/emitter/FXObjectMotion.Internal.d.ts +33 -0
- package/dist/emitter/FXObjectMotion.Internal.js +87 -0
- package/dist/emitter/FXSimulationHolder.d.ts +1 -0
- package/dist/emitter/FXSimulationHolder.js +43 -0
- package/dist/index.d.ts +11 -39
- package/dist/index.js +13 -36
- package/dist/instancedParticle/FXInstancedParticle.d.ts +1 -22
- package/dist/instancedParticle/FXInstancedParticle.js +145 -85
- package/dist/instancedParticle/glTypeInfo.d.ts +5 -0
- package/dist/instancedParticle/glTypeInfo.js +3 -0
- package/dist/instancedParticle/primitiveGeometry.d.ts +10 -0
- package/dist/instancedParticle/primitiveGeometry.js +30 -0
- package/dist/miscellaneous/asserts.d.ts +1 -18
- package/dist/miscellaneous/asserts.js +21 -28
- package/dist/miscellaneous/fxMath.d.ts +26 -0
- package/dist/miscellaneous/fxMath.js +261 -0
- package/dist/miscellaneous/math.d.ts +2 -7
- package/dist/miscellaneous/math.js +8 -9
- package/dist/miscellaneous/texture/fxDataTexture.d.ts +26 -0
- package/dist/miscellaneous/texture/fxDataTexture.js +20 -0
- package/dist/render/FXArtifactMaterial.Internal.d.ts +16 -0
- package/dist/render/FXArtifactMaterial.Internal.js +944 -0
- package/dist/render/FXArtifactMaterial.d.ts +1 -0
- package/dist/render/FXArtifactMaterial.js +79 -0
- package/dist/render/FXMaterialOptions.d.ts +27 -0
- package/dist/render/FXMaterialOptions.js +5 -0
- package/dist/render/FXMesh.d.ts +47 -0
- package/dist/render/FXMesh.js +99 -0
- package/dist/render/FXMeshMaterial.d.ts +40 -0
- package/dist/render/FXMeshMaterial.js +77 -0
- package/dist/world/FXWorld.d.ts +52 -0
- package/dist/world/FXWorld.js +104 -0
- package/package.json +49 -29
- package/dist/_virtual/2d.js +0 -3
- package/dist/_virtual/3d.js +0 -3
- package/dist/_virtual/4d.js +0 -3
- package/dist/_virtual/mod.js +0 -5
- package/dist/_virtual/mod2.js +0 -3
- package/dist/emitter/behavior/FXBehavior.d.ts +0 -24
- package/dist/emitter/behavior/FXBehavior.js +0 -10
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.d.ts +0 -23
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.js +0 -72
- package/dist/emitter/behavior/FXBehaviorPointForce.d.ts +0 -36
- package/dist/emitter/behavior/FXBehaviorPointForce.js +0 -94
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.d.ts +0 -24
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.js +0 -55
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.d.ts +0 -20
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.js +0 -48
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.d.ts +0 -25
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.js +0 -67
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.d.ts +0 -19
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.js +0 -41
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.d.ts +0 -20
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.js +0 -50
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.d.ts +0 -25
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.js +0 -76
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.d.ts +0 -22
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.js +0 -55
- package/dist/emitter/spawn/FXSpawn.d.ts +0 -11
- package/dist/emitter/spawn/FXSpawn.js +0 -10
- package/dist/emitter/spawn/FXSpawnBox.d.ts +0 -18
- package/dist/emitter/spawn/FXSpawnBox.js +0 -50
- package/dist/emitter/spawn/FXSpawnLifetime.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnLifetime.js +0 -44
- package/dist/emitter/spawn/FXSpawnOffset.d.ts +0 -21
- package/dist/emitter/spawn/FXSpawnOffset.js +0 -49
- package/dist/emitter/spawn/FXSpawnPoint.d.ts +0 -18
- package/dist/emitter/spawn/FXSpawnPoint.js +0 -46
- package/dist/emitter/spawn/FXSpawnRotation.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnRotation.js +0 -42
- package/dist/emitter/spawn/FXSpawnScale.d.ts +0 -22
- package/dist/emitter/spawn/FXSpawnScale.js +0 -56
- package/dist/emitter/spawn/FXSpawnSphere.d.ts +0 -36
- package/dist/emitter/spawn/FXSpawnSphere.js +0 -87
- package/dist/emitter/spawn/FXSpawnTorque.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnTorque.js +0 -42
- package/dist/emitter/spawn/FXSpawnVelocity.d.ts +0 -29
- package/dist/emitter/spawn/FXSpawnVelocity.js +0 -91
- package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +0 -2
- package/dist/instancedParticle/shared.d.ts +0 -19
- package/dist/instancedParticle/shared.js +0 -116
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.d.ts +0 -24
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.js +0 -275
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.d.ts +0 -75
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.js +0 -63
- package/dist/materials/FXMaterial/FXBlending.Internal.d.ts +0 -24
- package/dist/materials/FXMaterial/FXBlending.Internal.js +0 -64
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.d.ts +0 -4
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.js +0 -144
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.d.ts +0 -4
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.js +0 -175
- package/dist/materials/FXMaterial/FXMaterial.d.ts +0 -70
- package/dist/materials/FXMaterial/FXMaterial.js +0 -51
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.d.ts +0 -7
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.js +0 -103
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.d.ts +0 -7
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.js +0 -21
- package/dist/miscellaneous/color/FXColor.Internal.d.ts +0 -7
- package/dist/miscellaneous/color/FXColor.Internal.js +0 -42
- package/dist/miscellaneous/color/FXColor.d.ts +0 -234
- package/dist/miscellaneous/color/FXColor.js +0 -636
- package/dist/miscellaneous/curve/FXCurve1D.Internal.d.ts +0 -20
- package/dist/miscellaneous/curve/FXCurve1D.d.ts +0 -17
- package/dist/miscellaneous/curve/FXCurve1D.js +0 -94
- package/dist/miscellaneous/miscellaneous.d.ts +0 -34
- package/dist/miscellaneous/miscellaneous.js +0 -85
- package/dist/miscellaneous/texture/FXTextureView.Internal.d.ts +0 -49
- package/dist/miscellaneous/texture/FXTextureView.Internal.js +0 -6
- package/dist/miscellaneous/texture/FXTextureView.d.ts +0 -72
- package/dist/miscellaneous/texture/FXTextureView.js +0 -234
- package/dist/miscellaneous/webglCapabilities.d.ts +0 -1
- package/dist/miscellaneous/webglCapabilities.js +0 -45
- package/dist/node_modules/fast-simplex-noise/lib/2d.js +0 -93
- package/dist/node_modules/fast-simplex-noise/lib/3d.js +0 -142
- package/dist/node_modules/fast-simplex-noise/lib/4d.js +0 -196
- package/dist/node_modules/fast-simplex-noise/lib/mod.js +0 -24
- package/dist/nodes/FXNode.d.ts +0 -5
- package/dist/nodes/FXNode.js +0 -10
- package/dist/nodes/blending/FXNodeBlending.d.ts +0 -6
- package/dist/nodes/blending/FXNodeBlending.js +0 -9
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.d.ts +0 -19
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.js +0 -65
- package/dist/nodes/color/FXNodeColor.d.ts +0 -6
- package/dist/nodes/color/FXNodeColor.js +0 -9
- package/dist/nodes/color/FXNodeColorOverLife.d.ts +0 -22
- package/dist/nodes/color/FXNodeColorOverLife.js +0 -64
- package/dist/nodes/color/FXNodeSphericalClip.d.ts +0 -21
- package/dist/nodes/color/FXNodeSphericalClip.js +0 -54
- package/dist/nodes/normal/FXNodeFlatNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeFlatNormal.js +0 -16
- package/dist/nodes/normal/FXNodeNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeNormal.js +0 -9
- package/dist/nodes/normal/FXNodeSphericalNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeSphericalNormal.js +0 -23
- package/dist/nodes/texture/FXNodeAnimatedTexture.d.ts +0 -52
- package/dist/nodes/texture/FXNodeAnimatedTexture.js +0 -151
- package/dist/nodes/texture/FXNodeStaticTexture.d.ts +0 -20
- package/dist/nodes/texture/FXNodeStaticTexture.js +0 -67
- package/dist/nodes/texture/FXNodeTexture.d.ts +0 -6
- package/dist/nodes/texture/FXNodeTexture.js +0 -9
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { MathUtils } from 'three';
|
|
2
|
-
import { assertValidNonNegativeNumber, assertValidNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
-
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
-
import { FXSpawn } from './FXSpawn.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Spawns particles at random positions within a spherical shell
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* The `angle` parameter controls the polar spread from the equatorial plane:
|
|
11
|
-
* - `0` - flat disk (XZ plane only)
|
|
12
|
-
* - `Math.PI / 2` - full sphere
|
|
13
|
-
* - Values in between produce a spherical band
|
|
14
|
-
*/
|
|
15
|
-
class FXSpawnSphere extends FXSpawn {
|
|
16
|
-
/**
|
|
17
|
-
* @param innerRadius - Minimum spawn radius; must be non-negative. Defaults to `0`
|
|
18
|
-
* @param outerRadius - Maximum spawn radius; must be non-negative. Defaults to `1`
|
|
19
|
-
* @param angle - Polar half-angle from equatorial plane in radians. Defaults to `Math.PI / 2`
|
|
20
|
-
*/
|
|
21
|
-
constructor(innerRadius = 0, outerRadius = 1, angle = Math.PI / 2) {
|
|
22
|
-
super();
|
|
23
|
-
/** @internal */
|
|
24
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
25
|
-
this._private_innerRadiusInternal = innerRadius;
|
|
26
|
-
this._private_outerRadiusInternal = outerRadius;
|
|
27
|
-
this._private_angleInternal = angle;
|
|
28
|
-
assertValidNonNegativeNumber(innerRadius, "FXSpawnSphere.constructor.innerRadius");
|
|
29
|
-
assertValidNonNegativeNumber(outerRadius, "FXSpawnSphere.constructor.outerRadius");
|
|
30
|
-
assertValidNumber(angle, "FXSpawnSphere.constructor.angle");
|
|
31
|
-
}
|
|
32
|
-
/** Minimum spawn radius */
|
|
33
|
-
get innerRadius() {
|
|
34
|
-
return this._private_innerRadiusInternal;
|
|
35
|
-
}
|
|
36
|
-
/** Maximum spawn radius */
|
|
37
|
-
get outerRadius() {
|
|
38
|
-
return this._private_outerRadiusInternal;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Polar half-angle from the equatorial plane.
|
|
42
|
-
* - `0` - flat disk
|
|
43
|
-
* - `Math.PI / 2` - full sphere
|
|
44
|
-
*/
|
|
45
|
-
get angle() {
|
|
46
|
-
return this._private_angleInternal;
|
|
47
|
-
}
|
|
48
|
-
set innerRadius(value) {
|
|
49
|
-
assertValidNonNegativeNumber(value, "FXSpawnSphere.innerRadius");
|
|
50
|
-
this._private_innerRadiusInternal = value;
|
|
51
|
-
}
|
|
52
|
-
set outerRadius(value) {
|
|
53
|
-
assertValidNonNegativeNumber(value, "FXSpawnSphere.outerRadius");
|
|
54
|
-
this._private_outerRadiusInternal = value;
|
|
55
|
-
}
|
|
56
|
-
set angle(value) {
|
|
57
|
-
assertValidNumber(value, "FXSpawnSphere.angle");
|
|
58
|
-
this._private_angleInternal = value;
|
|
59
|
-
}
|
|
60
|
-
/** @internal */
|
|
61
|
-
spawn(properties, instanceBegin, instanceEnd) {
|
|
62
|
-
const { builtin } = properties;
|
|
63
|
-
const { array, itemSize } = builtin;
|
|
64
|
-
const inner = this._private_innerRadiusInternal;
|
|
65
|
-
const outer = this._private_outerRadiusInternal;
|
|
66
|
-
const sinAngle = Math.sin(this._private_angleInternal);
|
|
67
|
-
// Volume-uniform radius sampling within the shell
|
|
68
|
-
const inner3 = inner * inner * inner;
|
|
69
|
-
const outer3 = outer * outer * outer;
|
|
70
|
-
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
71
|
-
// Uniform volume-weighted radius
|
|
72
|
-
const r = Math.cbrt(MathUtils.randFloat(inner3, outer3));
|
|
73
|
-
// Uniform sampling on spherical zone:
|
|
74
|
-
// cosTheta in [-sinAngle, sinAngle] gives latitude range [-angle, +angle]
|
|
75
|
-
const cosTheta = MathUtils.randFloat(-sinAngle, sinAngle);
|
|
76
|
-
const sinTheta = Math.sqrt(1 - cosTheta * cosTheta);
|
|
77
|
-
const phi = MathUtils.randFloat(0, Math.PI * 2);
|
|
78
|
-
const itemOffset = i * itemSize;
|
|
79
|
-
array[itemOffset + BUILTIN_OFFSET_POSITION_X] = r * sinTheta * Math.cos(phi);
|
|
80
|
-
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] = r * cosTheta;
|
|
81
|
-
array[itemOffset + BUILTIN_OFFSET_POSITION_Z] = r * sinTheta * Math.sin(phi);
|
|
82
|
-
}
|
|
83
|
-
builtin.needsUpdate = true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { FXSpawnSphere };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
2
|
-
import { FXSpawn } from "./FXSpawn";
|
|
3
|
-
/**
|
|
4
|
-
* Assigns a random initial angular velocity to each spawned particle
|
|
5
|
-
*/
|
|
6
|
-
export declare class FXSpawnTorque extends FXSpawn<{
|
|
7
|
-
builtin: "Matrix4";
|
|
8
|
-
}> {
|
|
9
|
-
private torqueInternal;
|
|
10
|
-
/**
|
|
11
|
-
* @param torque - Angular velocity range in radians/second. Defaults to `{ min: -Math.PI, max: Math.PI }`
|
|
12
|
-
*/
|
|
13
|
-
constructor(torque?: FXRangeConfig);
|
|
14
|
-
/** Angular velocity range in radians/second */
|
|
15
|
-
get torque(): FXRange;
|
|
16
|
-
set torque(value: FXRangeConfig);
|
|
17
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { MathUtils } from 'three';
|
|
2
|
-
import { assertValidNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
-
import { FXSpawn } from './FXSpawn.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Assigns a random initial angular velocity to each spawned particle
|
|
8
|
-
*/
|
|
9
|
-
class FXSpawnTorque extends FXSpawn {
|
|
10
|
-
/**
|
|
11
|
-
* @param torque - Angular velocity range in radians/second. Defaults to `{ min: -Math.PI, max: Math.PI }`
|
|
12
|
-
*/
|
|
13
|
-
constructor(torque = { min: -Math.PI, max: Math.PI }) {
|
|
14
|
-
super();
|
|
15
|
-
/** @internal */
|
|
16
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
17
|
-
this._private_torqueInternal = resolveFXRangeConfig(torque);
|
|
18
|
-
assertValidNumber(this._private_torqueInternal.min, "FXSpawnTorque.constructor.torque.min");
|
|
19
|
-
assertValidNumber(this._private_torqueInternal.max, "FXSpawnTorque.constructor.torque.max");
|
|
20
|
-
}
|
|
21
|
-
/** Angular velocity range in radians/second */
|
|
22
|
-
get torque() {
|
|
23
|
-
return this._private_torqueInternal;
|
|
24
|
-
}
|
|
25
|
-
set torque(value) {
|
|
26
|
-
this._private_torqueInternal = resolveFXRangeConfig(value);
|
|
27
|
-
assertValidNumber(this._private_torqueInternal.min, "FXSpawnTorque.torque.min");
|
|
28
|
-
assertValidNumber(this._private_torqueInternal.max, "FXSpawnTorque.torque.max");
|
|
29
|
-
}
|
|
30
|
-
/** @internal */
|
|
31
|
-
spawn(properties, instanceBegin, instanceEnd) {
|
|
32
|
-
const { builtin } = properties;
|
|
33
|
-
const { array, itemSize } = builtin;
|
|
34
|
-
const { min: torqueMin, max: torqueMax } = this._private_torqueInternal;
|
|
35
|
-
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
36
|
-
array[i * itemSize + BUILTIN_OFFSET_TORQUE] = MathUtils.randFloat(torqueMin, torqueMax);
|
|
37
|
-
}
|
|
38
|
-
builtin.needsUpdate = true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { FXSpawnTorque };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from "three";
|
|
2
|
-
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
3
|
-
import { FXSpawn } from "./FXSpawn";
|
|
4
|
-
/**
|
|
5
|
-
* Assigns a random initial velocity to each spawned particle within a cone around a direction axis
|
|
6
|
-
*/
|
|
7
|
-
export declare class FXSpawnVelocity extends FXSpawn<{
|
|
8
|
-
builtin: "Matrix4";
|
|
9
|
-
}> {
|
|
10
|
-
private angleInternal;
|
|
11
|
-
private magnitudeInternal;
|
|
12
|
-
private readonly directionInternal;
|
|
13
|
-
/**
|
|
14
|
-
* @param direction - Cone axis; normalized automatically. Defaults to `(0, 1, 0)`
|
|
15
|
-
* @param angle - Cone half-angle range in radians; `{ min: 0, max: 0 }` fires in a straight line.
|
|
16
|
-
* Defaults to `{ min: 0, max: Math.PI }`
|
|
17
|
-
* @param magnitude - Speed range in units/second. Defaults to `{ min: -1, max: 1 }`
|
|
18
|
-
*/
|
|
19
|
-
constructor(direction?: Vector3, angle?: FXRangeConfig, magnitude?: FXRangeConfig);
|
|
20
|
-
/** Cone axis (always normalized) */
|
|
21
|
-
get direction(): Vector3;
|
|
22
|
-
/** Cone half-angle range in radians */
|
|
23
|
-
get angle(): FXRange;
|
|
24
|
-
/** Speed range in units/second */
|
|
25
|
-
get magnitude(): FXRange;
|
|
26
|
-
set direction(value: Vector3);
|
|
27
|
-
set angle(value: FXRangeConfig);
|
|
28
|
-
set magnitude(value: FXRangeConfig);
|
|
29
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Vector3, MathUtils } from 'three';
|
|
2
|
-
import { assertValidNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
-
import { FXSpawn } from './FXSpawn.js';
|
|
5
|
-
|
|
6
|
-
const TEMP_TANGENT = new Vector3();
|
|
7
|
-
const TEMP_BITANGENT = new Vector3();
|
|
8
|
-
const TEMP_VELOCITY = new Vector3();
|
|
9
|
-
/**
|
|
10
|
-
* Assigns a random initial velocity to each spawned particle within a cone around a direction axis
|
|
11
|
-
*/
|
|
12
|
-
class FXSpawnVelocity extends FXSpawn {
|
|
13
|
-
/**
|
|
14
|
-
* @param direction - Cone axis; normalized automatically. Defaults to `(0, 1, 0)`
|
|
15
|
-
* @param angle - Cone half-angle range in radians; `{ min: 0, max: 0 }` fires in a straight line.
|
|
16
|
-
* Defaults to `{ min: 0, max: Math.PI }`
|
|
17
|
-
* @param magnitude - Speed range in units/second. Defaults to `{ min: -1, max: 1 }`
|
|
18
|
-
*/
|
|
19
|
-
constructor(direction = new Vector3(0, 1, 0), angle = { min: 0, max: Math.PI }, magnitude = { min: -1, max: 1 }) {
|
|
20
|
-
super();
|
|
21
|
-
/** @internal */
|
|
22
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
23
|
-
this._private_directionInternal = direction.clone().normalize();
|
|
24
|
-
this._private_angleInternal = resolveFXRangeConfig(angle);
|
|
25
|
-
this._private_magnitudeInternal = resolveFXRangeConfig(magnitude);
|
|
26
|
-
assertValidNumber(this._private_angleInternal.min, "FXSpawnVelocity.constructor.angle.min");
|
|
27
|
-
assertValidNumber(this._private_angleInternal.max, "FXSpawnVelocity.constructor.angle.max");
|
|
28
|
-
assertValidNumber(this._private_magnitudeInternal.min, "FXSpawnVelocity.constructor.magnitude.min");
|
|
29
|
-
assertValidNumber(this._private_magnitudeInternal.max, "FXSpawnVelocity.constructor.magnitude.max");
|
|
30
|
-
}
|
|
31
|
-
/** Cone axis (always normalized) */
|
|
32
|
-
get direction() {
|
|
33
|
-
return this._private_directionInternal;
|
|
34
|
-
}
|
|
35
|
-
/** Cone half-angle range in radians */
|
|
36
|
-
get angle() {
|
|
37
|
-
return this._private_angleInternal;
|
|
38
|
-
}
|
|
39
|
-
/** Speed range in units/second */
|
|
40
|
-
get magnitude() {
|
|
41
|
-
return this._private_magnitudeInternal;
|
|
42
|
-
}
|
|
43
|
-
set direction(value) {
|
|
44
|
-
this._private_directionInternal.copy(value).normalize();
|
|
45
|
-
}
|
|
46
|
-
set angle(value) {
|
|
47
|
-
this._private_angleInternal = resolveFXRangeConfig(value);
|
|
48
|
-
assertValidNumber(this._private_angleInternal.min, "FXSpawnVelocity.angle.min");
|
|
49
|
-
assertValidNumber(this._private_angleInternal.max, "FXSpawnVelocity.angle.max");
|
|
50
|
-
}
|
|
51
|
-
set magnitude(value) {
|
|
52
|
-
this._private_magnitudeInternal = resolveFXRangeConfig(value);
|
|
53
|
-
assertValidNumber(this._private_magnitudeInternal.min, "FXSpawnVelocity.magnitude.min");
|
|
54
|
-
assertValidNumber(this._private_magnitudeInternal.max, "FXSpawnVelocity.magnitude.max");
|
|
55
|
-
}
|
|
56
|
-
/** @internal */
|
|
57
|
-
spawn(properties, instanceBegin, instanceEnd) {
|
|
58
|
-
const { builtin } = properties;
|
|
59
|
-
const { array, itemSize } = builtin;
|
|
60
|
-
const { min: angleMin, max: angleMax } = this._private_angleInternal;
|
|
61
|
-
const { min: magnitudeMin, max: magnitudeMax } = this._private_magnitudeInternal;
|
|
62
|
-
const dir = this._private_directionInternal;
|
|
63
|
-
if (Math.abs(dir.y) < 0.999) {
|
|
64
|
-
TEMP_TANGENT.set(0, 1, 0).cross(dir).normalize();
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
TEMP_TANGENT.set(1, 0, 0).cross(dir).normalize();
|
|
68
|
-
}
|
|
69
|
-
TEMP_BITANGENT.crossVectors(dir, TEMP_TANGENT);
|
|
70
|
-
const cosMin = Math.cos(angleMax);
|
|
71
|
-
const cosMax = Math.cos(angleMin);
|
|
72
|
-
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
73
|
-
const itemOffset = i * itemSize;
|
|
74
|
-
const cosTheta = MathUtils.lerp(cosMin, cosMax, Math.random());
|
|
75
|
-
const sinTheta = Math.sqrt(1 - cosTheta * cosTheta);
|
|
76
|
-
const phi = Math.random() * Math.PI * 2;
|
|
77
|
-
const magnitude = MathUtils.randFloat(magnitudeMin, magnitudeMax);
|
|
78
|
-
TEMP_VELOCITY.copy(dir)
|
|
79
|
-
.multiplyScalar(cosTheta)
|
|
80
|
-
.addScaledVector(TEMP_TANGENT, Math.cos(phi) * sinTheta)
|
|
81
|
-
.addScaledVector(TEMP_BITANGENT, Math.sin(phi) * sinTheta)
|
|
82
|
-
.multiplyScalar(magnitude);
|
|
83
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] = TEMP_VELOCITY.x;
|
|
84
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] = TEMP_VELOCITY.y;
|
|
85
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] = TEMP_VELOCITY.z;
|
|
86
|
-
}
|
|
87
|
-
builtin.needsUpdate = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export { FXSpawnVelocity };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { IUniform, ShaderMaterial } from "three";
|
|
2
|
-
import { Matrix3, Matrix4, Texture, Vector2, Vector3, Vector4 } from "three";
|
|
3
|
-
import { FXColor } from "../miscellaneous/color/FXColor";
|
|
4
|
-
export type FXProperty = Texture | FXColor | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4 | number;
|
|
5
|
-
export type FXPropertyName = "Texture" | "FXColor" | "Vector2" | "Vector3" | "Vector4" | "Matrix3" | "Matrix4" | "number";
|
|
6
|
-
export type FXPropertyConstructor = typeof Texture | typeof FXColor | typeof Vector2 | typeof Vector3 | typeof Vector4 | typeof Matrix3 | typeof Matrix4 | NumberConstructor;
|
|
7
|
-
export type FXPropertyCopyTo = FXColor | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4;
|
|
8
|
-
export type FXPropertyCopyFrom = FXColor & Vector2 & Vector3 & Vector4 & Matrix3 & Matrix4;
|
|
9
|
-
export interface GLTypeInfo {
|
|
10
|
-
glslTypeName: string;
|
|
11
|
-
bufferSize: number;
|
|
12
|
-
instantiable: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface GLProperty {
|
|
15
|
-
value: FXProperty;
|
|
16
|
-
glslTypeInfo: GLTypeInfo;
|
|
17
|
-
}
|
|
18
|
-
export declare function resolveGLSLTypeInfo(value: FXProperty | FXPropertyName | FXPropertyConstructor): GLTypeInfo;
|
|
19
|
-
export declare function resolvePropertyUniform(name: string, material: ShaderMaterial): IUniform<FXProperty>;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Texture, Vector2, Vector3, Vector4, Matrix3, Matrix4 } from 'three';
|
|
2
|
-
import { FXColor } from '../miscellaneous/color/FXColor.js';
|
|
3
|
-
|
|
4
|
-
const GLSL_TYPE_INFO_FLOAT = Object.freeze({
|
|
5
|
-
glslTypeName: "float",
|
|
6
|
-
bufferSize: 1,
|
|
7
|
-
instantiable: true,
|
|
8
|
-
});
|
|
9
|
-
const GLSL_TYPE_INFO_SAMPLER2D = Object.freeze({
|
|
10
|
-
glslTypeName: "sampler2D",
|
|
11
|
-
bufferSize: -1,
|
|
12
|
-
instantiable: false,
|
|
13
|
-
});
|
|
14
|
-
const GLSL_TYPE_INFO_VEC2 = Object.freeze({
|
|
15
|
-
glslTypeName: "vec2",
|
|
16
|
-
bufferSize: 2,
|
|
17
|
-
instantiable: true,
|
|
18
|
-
});
|
|
19
|
-
const GLSL_TYPE_INFO_VEC3 = Object.freeze({
|
|
20
|
-
glslTypeName: "vec3",
|
|
21
|
-
bufferSize: 3,
|
|
22
|
-
instantiable: true,
|
|
23
|
-
});
|
|
24
|
-
const GLSL_TYPE_INFO_VEC4 = Object.freeze({
|
|
25
|
-
glslTypeName: "vec4",
|
|
26
|
-
bufferSize: 4,
|
|
27
|
-
instantiable: true,
|
|
28
|
-
});
|
|
29
|
-
const GLSL_TYPE_INFO_MAT3 = Object.freeze({
|
|
30
|
-
glslTypeName: "mat3",
|
|
31
|
-
bufferSize: 9,
|
|
32
|
-
instantiable: true,
|
|
33
|
-
});
|
|
34
|
-
const GLSL_TYPE_INFO_MAT4 = Object.freeze({
|
|
35
|
-
glslTypeName: "mat4",
|
|
36
|
-
bufferSize: 16,
|
|
37
|
-
instantiable: true,
|
|
38
|
-
});
|
|
39
|
-
function resolveGLSLTypeInfo(value) {
|
|
40
|
-
if (typeof value === "string") {
|
|
41
|
-
switch (value) {
|
|
42
|
-
case "number":
|
|
43
|
-
return GLSL_TYPE_INFO_FLOAT;
|
|
44
|
-
case "Texture":
|
|
45
|
-
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
46
|
-
case "FXColor":
|
|
47
|
-
return GLSL_TYPE_INFO_VEC4;
|
|
48
|
-
case "Vector2":
|
|
49
|
-
return GLSL_TYPE_INFO_VEC2;
|
|
50
|
-
case "Vector3":
|
|
51
|
-
return GLSL_TYPE_INFO_VEC3;
|
|
52
|
-
case "Vector4":
|
|
53
|
-
return GLSL_TYPE_INFO_VEC4;
|
|
54
|
-
case "Matrix3":
|
|
55
|
-
return GLSL_TYPE_INFO_MAT3;
|
|
56
|
-
case "Matrix4":
|
|
57
|
-
return GLSL_TYPE_INFO_MAT4;
|
|
58
|
-
default:
|
|
59
|
-
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type name`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (typeof value === "function") {
|
|
63
|
-
if (value === Number) {
|
|
64
|
-
return GLSL_TYPE_INFO_FLOAT;
|
|
65
|
-
}
|
|
66
|
-
if (value === Texture) {
|
|
67
|
-
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
68
|
-
}
|
|
69
|
-
if (value === FXColor) {
|
|
70
|
-
return GLSL_TYPE_INFO_VEC4;
|
|
71
|
-
}
|
|
72
|
-
if (value === Vector2) {
|
|
73
|
-
return GLSL_TYPE_INFO_VEC2;
|
|
74
|
-
}
|
|
75
|
-
if (value === Vector3) {
|
|
76
|
-
return GLSL_TYPE_INFO_VEC3;
|
|
77
|
-
}
|
|
78
|
-
if (value === Vector4) {
|
|
79
|
-
return GLSL_TYPE_INFO_VEC4;
|
|
80
|
-
}
|
|
81
|
-
if (value === Matrix3) {
|
|
82
|
-
return GLSL_TYPE_INFO_MAT3;
|
|
83
|
-
}
|
|
84
|
-
if (value === Matrix4) {
|
|
85
|
-
return GLSL_TYPE_INFO_MAT4;
|
|
86
|
-
}
|
|
87
|
-
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type constructor`);
|
|
88
|
-
}
|
|
89
|
-
if (typeof value === "number") {
|
|
90
|
-
return GLSL_TYPE_INFO_FLOAT;
|
|
91
|
-
}
|
|
92
|
-
if (value instanceof Texture) {
|
|
93
|
-
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
94
|
-
}
|
|
95
|
-
if (value instanceof FXColor) {
|
|
96
|
-
return GLSL_TYPE_INFO_VEC4;
|
|
97
|
-
}
|
|
98
|
-
if (value instanceof Vector2) {
|
|
99
|
-
return GLSL_TYPE_INFO_VEC2;
|
|
100
|
-
}
|
|
101
|
-
if (value instanceof Vector3) {
|
|
102
|
-
return GLSL_TYPE_INFO_VEC3;
|
|
103
|
-
}
|
|
104
|
-
if (value instanceof Vector4) {
|
|
105
|
-
return GLSL_TYPE_INFO_VEC4;
|
|
106
|
-
}
|
|
107
|
-
if (value instanceof Matrix3) {
|
|
108
|
-
return GLSL_TYPE_INFO_MAT3;
|
|
109
|
-
}
|
|
110
|
-
if (value instanceof Matrix4) {
|
|
111
|
-
return GLSL_TYPE_INFO_MAT4;
|
|
112
|
-
}
|
|
113
|
-
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export { resolveGLSLTypeInfo };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Color, MeshLambertMaterial } from "three";
|
|
2
|
-
import type { GLTypeInfo } from "../../instancedParticle/shared";
|
|
3
|
-
import type { FXNodeBlending } from "../../nodes/blending/FXNodeBlending";
|
|
4
|
-
import { FXNodeColor } from "../../nodes/color/FXNodeColor";
|
|
5
|
-
import type { FXNodeNormal } from "../../nodes/normal/FXNodeNormal";
|
|
6
|
-
import { FXNodeTexture } from "../../nodes/texture/FXNodeTexture";
|
|
7
|
-
import { FXBlending } from "../FXMaterial/FXMaterial";
|
|
8
|
-
export interface FXScatterUniforms {
|
|
9
|
-
u_ScatterTint: {
|
|
10
|
-
value: Color;
|
|
11
|
-
};
|
|
12
|
-
u_ScatterPower: {
|
|
13
|
-
value: number;
|
|
14
|
-
};
|
|
15
|
-
u_ForwardScatterStrength: {
|
|
16
|
-
value: number;
|
|
17
|
-
};
|
|
18
|
-
u_BackScatterStrength: {
|
|
19
|
-
value: number;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export declare function buildFXDiffuseMaterial(varyings: Record<string, GLTypeInfo>, blending: FXBlending, useAlphaHashing: boolean, alphaTest: number, albedoNodes: readonly (FXNodeColor | FXNodeTexture | FXNodeBlending)[], normalNodes: readonly (FXNodeTexture | FXNodeNormal)[], emissionNodes: readonly (FXNodeColor | FXNodeTexture)[], scatterUniforms?: FXScatterUniforms, shadowSensitivity?: {
|
|
23
|
-
value: number;
|
|
24
|
-
}): MeshLambertMaterial;
|