sparcoon 0.1.0 → 0.3.0
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/dist/{elements → emitter}/FXEmitter.Internal.d.ts +4 -4
- package/dist/emitter/FXEmitter.Internal.js +26 -0
- package/dist/emitter/FXEmitter.d.ts +31 -0
- package/dist/{elements → emitter}/FXEmitter.js +14 -22
- package/dist/{behaviorModules/FXBehaviorModule.d.ts → emitter/behavior/FXBehavior.d.ts} +2 -2
- package/dist/{behaviorModules/FXBehaviorModule.js → emitter/behavior/FXBehavior.js} +2 -2
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorDirectionalGravity.d.ts +4 -4
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorDirectionalGravity.js +4 -4
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorPointGravity.d.ts +4 -4
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorPointGravity.js +4 -4
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorScaleOverLife.d.ts +3 -3
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorScaleOverLife.js +4 -4
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueDamping.d.ts +3 -3
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueDamping.js +4 -4
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueNoise.d.ts +3 -3
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueNoise.js +5 -5
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityDamping.d.ts +3 -3
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityDamping.js +4 -4
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityNoise.d.ts +3 -3
- package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityNoise.js +5 -5
- package/dist/emitter/spawn/FXSpawn.d.ts +9 -0
- package/dist/{spawnModules/FXSpawnModule.js → emitter/spawn/FXSpawn.js} +2 -2
- package/dist/{spawnModules → emitter/spawn}/FXSpawnBox.d.ts +4 -4
- package/dist/{spawnModules → emitter/spawn}/FXSpawnBox.js +4 -4
- package/dist/{spawnModules/FXSpawnOffset.d.ts → emitter/spawn/FXSpawnPoint.d.ts} +4 -4
- package/dist/{spawnModules/FXSpawnOffset.js → emitter/spawn/FXSpawnPoint.js} +5 -5
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomLifetime.d.ts +3 -3
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomLifetime.js +4 -4
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomRotation.d.ts +3 -3
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomRotation.js +4 -4
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomScale.d.ts +3 -3
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomScale.js +4 -4
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomTorque.d.ts +3 -3
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomTorque.js +4 -4
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomVelocity.d.ts +3 -3
- package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomVelocity.js +4 -4
- package/dist/emitter/spawn/FXSpawnSphere.d.ts +38 -0
- package/dist/emitter/spawn/FXSpawnSphere.js +89 -0
- package/dist/index.d.ts +28 -20
- package/dist/index.js +28 -22
- package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +1 -12
- package/dist/instancedParticle/FXInstancedParticle.Internal.js +2 -206
- package/dist/instancedParticle/FXInstancedParticle.d.ts +3 -5
- package/dist/instancedParticle/FXInstancedParticle.js +4 -10
- package/dist/instancedParticle/shared.d.ts +1 -1
- package/dist/instancedParticle/shared.js +1 -1
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.d.ts +7 -0
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.js +141 -0
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.d.ts +15 -0
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.js +26 -0
- package/dist/materials/FXMaterial/FXMaterial.Internal.d.ts +5 -0
- package/dist/materials/FXMaterial/FXMaterial.Internal.js +106 -0
- package/dist/materials/FXMaterial/FXMaterial.d.ts +19 -0
- package/dist/materials/FXMaterial/FXMaterial.js +25 -0
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.d.ts +6 -0
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.js +84 -0
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.d.ts +6 -0
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.js +14 -0
- package/dist/{color → miscellaneous/color}/FXColor.js +2 -2
- package/dist/miscellaneous/miscellaneous.d.ts +2 -1
- package/dist/miscellaneous/miscellaneous.js +24 -1
- package/dist/nodes/color/FXColorNode.d.ts +3 -0
- package/dist/nodes/color/FXColorNode.js +8 -0
- package/dist/nodes/color/FXColorOverLifeNode.d.ts +6 -0
- package/dist/nodes/color/FXColorOverLifeNode.js +38 -0
- package/dist/nodes/normal/FXFlatNormalNode.d.ts +4 -0
- package/dist/nodes/normal/FXFlatNormalNode.js +14 -0
- package/dist/nodes/normal/FXNormalNode.d.ts +3 -0
- package/dist/nodes/normal/FXNormalNode.js +4 -0
- package/dist/nodes/normal/FXSphericalNormalNode.d.ts +4 -0
- package/dist/nodes/normal/FXSphericalNormalNode.js +19 -0
- package/dist/nodes/texture/FXAnimatedTextureNode.d.ts +11 -0
- package/dist/nodes/texture/FXAnimatedTextureNode.js +80 -0
- package/dist/nodes/texture/FXStaticTextureNode.d.ts +5 -0
- package/dist/nodes/texture/FXStaticTextureNode.js +26 -0
- package/dist/nodes/texture/FXTextureNode.d.ts +3 -0
- package/dist/nodes/texture/FXTextureNode.js +8 -0
- package/package.json +1 -1
- package/dist/elements/FXEmitter.Internal.js +0 -12
- package/dist/elements/FXEmitter.d.ts +0 -38
- package/dist/instancedParticle/FXParticleDepthMaterial.d.ts +0 -2
- package/dist/instancedParticle/FXParticleDepthMaterial.js +0 -52
- package/dist/instancedParticle/FXParticleLambertMaterial.d.ts +0 -4
- package/dist/instancedParticle/FXParticleLambertMaterial.js +0 -152
- package/dist/instancedParticle/FXParticleNormalsMode.d.ts +0 -5
- package/dist/instancedParticle/FXParticleNormalsMode.js +0 -8
- package/dist/instancedParticle/FXParticleRenderingMode.d.ts +0 -4
- package/dist/instancedParticle/FXParticleRenderingMode.js +0 -7
- package/dist/miscellaneous/texture/FXTextureView.Internal.js +0 -6
- package/dist/miscellaneous/texture/FXTextureView.js +0 -234
- package/dist/renderingModules/FXRenderingAnimatedTexture.d.ts +0 -5
- package/dist/renderingModules/FXRenderingAnimatedTexture.js +0 -14
- package/dist/renderingModules/FXRenderingColorOverLife.d.ts +0 -14
- package/dist/renderingModules/FXRenderingColorOverLife.js +0 -32
- package/dist/renderingModules/FXRenderingColorOverVelocity.d.ts +0 -15
- package/dist/renderingModules/FXRenderingColorOverVelocity.js +0 -37
- package/dist/renderingModules/FXRenderingModule.d.ts +0 -8
- package/dist/renderingModules/FXRenderingModule.js +0 -9
- package/dist/renderingModules/FXRenderingShadow.d.ts +0 -12
- package/dist/renderingModules/FXRenderingTexture.d.ts +0 -14
- package/dist/renderingModules/FXRenderingTexture.js +0 -26
- package/dist/shaders/FXRenderingAnimatedTexture.glsl.js +0 -3
- package/dist/shaders/FXRenderingColorOverLife.glsl.js +0 -3
- package/dist/shaders/FXRenderingColorOverVelocity.glsl.js +0 -3
- package/dist/shaders/FXRenderingTexture.glsl.js +0 -3
- package/dist/spawnModules/FXSpawnModule.d.ts +0 -9
- /package/dist/{color → miscellaneous/color}/FXColor.Internal.d.ts +0 -0
- /package/dist/{color → miscellaneous/color}/FXColor.Internal.js +0 -0
- /package/dist/{color → miscellaneous/color}/FXColor.d.ts +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { FXAspectConfig, FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
2
|
+
import { FXSpawn } from "./FXSpawn";
|
|
3
3
|
/**
|
|
4
4
|
* Assigns random scale to particles.
|
|
5
5
|
*
|
|
6
6
|
* Base scale is chosen uniformly from the range. Aspect ratio is applied to X scale.
|
|
7
7
|
*/
|
|
8
|
-
export declare class FXSpawnRandomScale extends
|
|
8
|
+
export declare class FXSpawnRandomScale extends FXSpawn<{
|
|
9
9
|
builtin: "Matrix4";
|
|
10
10
|
}> {
|
|
11
11
|
private scaleInternal;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { MathUtils } from 'three';
|
|
2
|
-
import { assertValidPositiveNumber } from '
|
|
3
|
-
import { resolveFXRangeConfig, resolveAspect, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '
|
|
4
|
-
import {
|
|
2
|
+
import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
+
import { resolveFXRangeConfig, resolveAspect, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { FXSpawn } from './FXSpawn.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Assigns random scale to particles.
|
|
8
8
|
*
|
|
9
9
|
* Base scale is chosen uniformly from the range. Aspect ratio is applied to X scale.
|
|
10
10
|
*/
|
|
11
|
-
class FXSpawnRandomScale extends
|
|
11
|
+
class FXSpawnRandomScale extends FXSpawn {
|
|
12
12
|
/**
|
|
13
13
|
* @param scale - Base scale range. Accepts number, tuple, or range object
|
|
14
14
|
* @param aspect - Width/height ratio. Accepts number or texture
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
2
|
+
import { FXSpawn } from "./FXSpawn";
|
|
3
3
|
/**
|
|
4
4
|
* Assigns random angular velocity to particles.
|
|
5
5
|
*
|
|
6
6
|
* Torque (rotation speed) is chosen uniformly from the specified range.
|
|
7
7
|
*/
|
|
8
|
-
export declare class FXSpawnRandomTorque extends
|
|
8
|
+
export declare class FXSpawnRandomTorque extends FXSpawn<{
|
|
9
9
|
builtin: "Matrix4";
|
|
10
10
|
}> {
|
|
11
11
|
private torqueInternal;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { MathUtils } from 'three';
|
|
2
|
-
import { assertValidNumber } from '
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_TORQUE } from '
|
|
4
|
-
import {
|
|
2
|
+
import { assertValidNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { FXSpawn } from './FXSpawn.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Assigns random angular velocity to particles.
|
|
8
8
|
*
|
|
9
9
|
* Torque (rotation speed) is chosen uniformly from the specified range.
|
|
10
10
|
*/
|
|
11
|
-
class FXSpawnRandomTorque extends
|
|
11
|
+
class FXSpawnRandomTorque extends FXSpawn {
|
|
12
12
|
/**
|
|
13
13
|
* @param torque - Angular velocity range in radians/second. Accepts number, tuple, or range object
|
|
14
14
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class FXSpawnRandomVelocity extends
|
|
2
|
+
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
3
|
+
import { FXSpawn } from "./FXSpawn";
|
|
4
|
+
export declare class FXSpawnRandomVelocity extends FXSpawn<{
|
|
5
5
|
builtin: "Matrix4";
|
|
6
6
|
}> {
|
|
7
7
|
private angleInternal;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Vector3, MathUtils } from 'three';
|
|
2
|
-
import { assertValidNumber } from '
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '
|
|
4
|
-
import {
|
|
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
5
|
|
|
6
6
|
const TEMP_TANGENT = new Vector3();
|
|
7
7
|
const TEMP_BITANGENT = new Vector3();
|
|
8
8
|
const TEMP_VELOCITY = new Vector3();
|
|
9
|
-
class FXSpawnRandomVelocity extends
|
|
9
|
+
class FXSpawnRandomVelocity extends FXSpawn {
|
|
10
10
|
constructor(direction = new Vector3(0, 1, 0), angle = { min: 0, max: Math.PI }, magnitude = { min: -50, max: 50 }) {
|
|
11
11
|
super();
|
|
12
12
|
/** @internal */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FXSpawn } from "./FXSpawn";
|
|
2
|
+
/**
|
|
3
|
+
* Spawns particles at random positions within a spherical shell.
|
|
4
|
+
*
|
|
5
|
+
* The `angle` parameter controls the polar spread from the equatorial plane:
|
|
6
|
+
* - `0` - flat disk (XZ plane only)
|
|
7
|
+
* - `Math.PI / 2` - full sphere
|
|
8
|
+
* - Values in between produce a spherical band/zone
|
|
9
|
+
*/
|
|
10
|
+
export declare class FXSpawnSphere extends FXSpawn<{
|
|
11
|
+
builtin: "Matrix4";
|
|
12
|
+
}> {
|
|
13
|
+
private innerRadiusInternal;
|
|
14
|
+
private outerRadiusInternal;
|
|
15
|
+
private angleInternal;
|
|
16
|
+
/**
|
|
17
|
+
* @param innerRadius - Minimum spawn radius (0 = spawn from center)
|
|
18
|
+
* @param outerRadius - Maximum spawn radius
|
|
19
|
+
* @param angle - Polar half-angle from equatorial plane: 0 = disk, Math.PI/2 = full sphere
|
|
20
|
+
*/
|
|
21
|
+
constructor(innerRadius?: number, outerRadius?: number, angle?: number);
|
|
22
|
+
/**
|
|
23
|
+
* Polar half-angle from the equatorial plane.
|
|
24
|
+
* - `0` — flat disk
|
|
25
|
+
* - `Math.PI / 2` — full sphere
|
|
26
|
+
*/
|
|
27
|
+
get angle(): number;
|
|
28
|
+
/** Minimum spawn radius */
|
|
29
|
+
get innerRadius(): number;
|
|
30
|
+
/** Maximum spawn radius */
|
|
31
|
+
get outerRadius(): number;
|
|
32
|
+
/** Minimum spawn radius */
|
|
33
|
+
set innerRadius(value: number);
|
|
34
|
+
/** Maximum spawn radius */
|
|
35
|
+
set outerRadius(value: number);
|
|
36
|
+
/** @see {@link angle} */
|
|
37
|
+
set angle(value: number);
|
|
38
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
* The `angle` parameter controls the polar spread from the equatorial plane:
|
|
10
|
+
* - `0` - flat disk (XZ plane only)
|
|
11
|
+
* - `Math.PI / 2` - full sphere
|
|
12
|
+
* - Values in between produce a spherical band/zone
|
|
13
|
+
*/
|
|
14
|
+
class FXSpawnSphere extends FXSpawn {
|
|
15
|
+
/**
|
|
16
|
+
* @param innerRadius - Minimum spawn radius (0 = spawn from center)
|
|
17
|
+
* @param outerRadius - Maximum spawn radius
|
|
18
|
+
* @param angle - Polar half-angle from equatorial plane: 0 = disk, Math.PI/2 = full sphere
|
|
19
|
+
*/
|
|
20
|
+
constructor(innerRadius = 0, outerRadius = 1, angle = Math.PI / 2) {
|
|
21
|
+
super();
|
|
22
|
+
/** @internal */
|
|
23
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
24
|
+
this._private_innerRadiusInternal = innerRadius;
|
|
25
|
+
this._private_outerRadiusInternal = outerRadius;
|
|
26
|
+
this._private_angleInternal = angle;
|
|
27
|
+
assertValidNonNegativeNumber(innerRadius, "FXSpawnSphere.constructor.innerRadius");
|
|
28
|
+
assertValidNonNegativeNumber(outerRadius, "FXSpawnSphere.constructor.outerRadius");
|
|
29
|
+
assertValidNumber(angle, "FXSpawnSphere.constructor.angle");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Polar half-angle from the equatorial plane.
|
|
33
|
+
* - `0` — flat disk
|
|
34
|
+
* - `Math.PI / 2` — full sphere
|
|
35
|
+
*/
|
|
36
|
+
get angle() {
|
|
37
|
+
return this._private_angleInternal;
|
|
38
|
+
}
|
|
39
|
+
/** Minimum spawn radius */
|
|
40
|
+
get innerRadius() {
|
|
41
|
+
return this._private_innerRadiusInternal;
|
|
42
|
+
}
|
|
43
|
+
/** Maximum spawn radius */
|
|
44
|
+
get outerRadius() {
|
|
45
|
+
return this._private_outerRadiusInternal;
|
|
46
|
+
}
|
|
47
|
+
/** Minimum spawn radius */
|
|
48
|
+
set innerRadius(value) {
|
|
49
|
+
assertValidNonNegativeNumber(value, "FXSpawnSphere.innerRadius");
|
|
50
|
+
this._private_innerRadiusInternal = value;
|
|
51
|
+
}
|
|
52
|
+
/** Maximum spawn radius */
|
|
53
|
+
set outerRadius(value) {
|
|
54
|
+
assertValidNonNegativeNumber(value, "FXSpawnSphere.outerRadius");
|
|
55
|
+
this._private_outerRadiusInternal = value;
|
|
56
|
+
}
|
|
57
|
+
/** @see {@link angle} */
|
|
58
|
+
set angle(value) {
|
|
59
|
+
assertValidNumber(value, "FXSpawnSphere.angle");
|
|
60
|
+
this._private_angleInternal = value;
|
|
61
|
+
}
|
|
62
|
+
/** @internal */
|
|
63
|
+
spawn(properties, instanceBegin, instanceEnd) {
|
|
64
|
+
const { builtin } = properties;
|
|
65
|
+
const { array, itemSize } = builtin;
|
|
66
|
+
const inner = this._private_innerRadiusInternal;
|
|
67
|
+
const outer = this._private_outerRadiusInternal;
|
|
68
|
+
const sinAngle = Math.sin(this._private_angleInternal);
|
|
69
|
+
// Volume-uniform radius sampling within the shell
|
|
70
|
+
const inner3 = inner * inner * inner;
|
|
71
|
+
const outer3 = outer * outer * outer;
|
|
72
|
+
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
73
|
+
// Uniform volume-weighted radius
|
|
74
|
+
const r = Math.cbrt(MathUtils.randFloat(inner3, outer3));
|
|
75
|
+
// Uniform sampling on spherical zone:
|
|
76
|
+
// cosTheta in [-sinAngle, sinAngle] gives latitude range [-angle, +angle]
|
|
77
|
+
const cosTheta = MathUtils.randFloat(-sinAngle, sinAngle);
|
|
78
|
+
const sinTheta = Math.sqrt(1 - cosTheta * cosTheta);
|
|
79
|
+
const phi = MathUtils.randFloat(0, Math.PI * 2);
|
|
80
|
+
const itemOffset = i * itemSize;
|
|
81
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_X] = r * sinTheta * Math.cos(phi);
|
|
82
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] = r * cosTheta;
|
|
83
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Z] = r * sinTheta * Math.sin(phi);
|
|
84
|
+
}
|
|
85
|
+
builtin.needsUpdate = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { FXSpawnSphere };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
export { FXBehaviorDirectionalGravity } from "./
|
|
2
|
-
export { FXBehaviorPointGravity } from "./
|
|
3
|
-
export { FXBehaviorScaleOverLife } from "./
|
|
4
|
-
export { FXBehaviorTorqueDamping } from "./
|
|
5
|
-
export { FXBehaviorTorqueNoise } from "./
|
|
6
|
-
export { FXBehaviorVelocityDamping } from "./
|
|
7
|
-
export { FXBehaviorVelocityNoise } from "./
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
1
|
+
export { FXBehaviorDirectionalGravity } from "./emitter/behavior/FXBehaviorDirectionalGravity";
|
|
2
|
+
export { FXBehaviorPointGravity } from "./emitter/behavior/FXBehaviorPointGravity";
|
|
3
|
+
export { FXBehaviorScaleOverLife } from "./emitter/behavior/FXBehaviorScaleOverLife";
|
|
4
|
+
export { FXBehaviorTorqueDamping } from "./emitter/behavior/FXBehaviorTorqueDamping";
|
|
5
|
+
export { FXBehaviorTorqueNoise } from "./emitter/behavior/FXBehaviorTorqueNoise";
|
|
6
|
+
export { FXBehaviorVelocityDamping } from "./emitter/behavior/FXBehaviorVelocityDamping";
|
|
7
|
+
export { FXBehaviorVelocityNoise } from "./emitter/behavior/FXBehaviorVelocityNoise";
|
|
8
|
+
export { FXEmitter } from "./emitter/FXEmitter";
|
|
9
|
+
export { FXSpawnBox } from "./emitter/spawn/FXSpawnBox";
|
|
10
|
+
export { FXSpawnPoint as FXSpawnOffset } from "./emitter/spawn/FXSpawnPoint";
|
|
11
|
+
export { FXSpawnRandomLifetime } from "./emitter/spawn/FXSpawnRandomLifetime";
|
|
12
|
+
export { FXSpawnRandomRotation } from "./emitter/spawn/FXSpawnRandomRotation";
|
|
13
|
+
export { FXSpawnRandomScale } from "./emitter/spawn/FXSpawnRandomScale";
|
|
14
|
+
export { FXSpawnRandomTorque } from "./emitter/spawn/FXSpawnRandomTorque";
|
|
15
|
+
export { FXSpawnRandomVelocity } from "./emitter/spawn/FXSpawnRandomVelocity";
|
|
16
|
+
export { FXSpawnSphere } from "./emitter/spawn/FXSpawnSphere";
|
|
17
|
+
export { FXDiffuseMaterial } from "./materials/FXDiffuseMaterial/FXDiffuseMaterial";
|
|
18
|
+
export { FXMaterial } from "./materials/FXMaterial/FXMaterial";
|
|
19
|
+
export { FXUnlitMaterial } from "./materials/FXUnlitMaterial/FXUnlitMaterial";
|
|
20
|
+
export { FXColor } from "./miscellaneous/color/FXColor";
|
|
21
|
+
export { FXColorNode } from "./nodes/color/FXColorNode";
|
|
22
|
+
export { FXColorOverLifeNode } from "./nodes/color/FXColorOverLifeNode";
|
|
23
|
+
export { FXFlatNormalNode } from "./nodes/normal/FXFlatNormalNode";
|
|
24
|
+
export { FXNormalNode } from "./nodes/normal/FXNormalNode";
|
|
25
|
+
export { FXSphericalNormalNode } from "./nodes/normal/FXSphericalNormalNode";
|
|
26
|
+
export { FXAnimatedTextureNode } from "./nodes/texture/FXAnimatedTextureNode";
|
|
27
|
+
export { FXStaticTextureNode } from "./nodes/texture/FXStaticTextureNode";
|
|
28
|
+
export { FXTextureNode } from "./nodes/texture/FXTextureNode";
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
export { FXBehaviorDirectionalGravity } from './
|
|
2
|
-
export { FXBehaviorPointGravity } from './
|
|
3
|
-
export { FXBehaviorScaleOverLife } from './
|
|
4
|
-
export { FXBehaviorTorqueDamping } from './
|
|
5
|
-
export { FXBehaviorTorqueNoise } from './
|
|
6
|
-
export { FXBehaviorVelocityDamping } from './
|
|
7
|
-
export { FXBehaviorVelocityNoise } from './
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
1
|
+
export { FXBehaviorDirectionalGravity } from './emitter/behavior/FXBehaviorDirectionalGravity.js';
|
|
2
|
+
export { FXBehaviorPointGravity } from './emitter/behavior/FXBehaviorPointGravity.js';
|
|
3
|
+
export { FXBehaviorScaleOverLife } from './emitter/behavior/FXBehaviorScaleOverLife.js';
|
|
4
|
+
export { FXBehaviorTorqueDamping } from './emitter/behavior/FXBehaviorTorqueDamping.js';
|
|
5
|
+
export { FXBehaviorTorqueNoise } from './emitter/behavior/FXBehaviorTorqueNoise.js';
|
|
6
|
+
export { FXBehaviorVelocityDamping } from './emitter/behavior/FXBehaviorVelocityDamping.js';
|
|
7
|
+
export { FXBehaviorVelocityNoise } from './emitter/behavior/FXBehaviorVelocityNoise.js';
|
|
8
|
+
export { FXEmitter } from './emitter/FXEmitter.js';
|
|
9
|
+
export { FXSpawnBox } from './emitter/spawn/FXSpawnBox.js';
|
|
10
|
+
export { FXSpawnPoint as FXSpawnOffset } from './emitter/spawn/FXSpawnPoint.js';
|
|
11
|
+
export { FXSpawnRandomLifetime } from './emitter/spawn/FXSpawnRandomLifetime.js';
|
|
12
|
+
export { FXSpawnRandomRotation } from './emitter/spawn/FXSpawnRandomRotation.js';
|
|
13
|
+
export { FXSpawnRandomScale } from './emitter/spawn/FXSpawnRandomScale.js';
|
|
14
|
+
export { FXSpawnRandomTorque } from './emitter/spawn/FXSpawnRandomTorque.js';
|
|
15
|
+
export { FXSpawnRandomVelocity } from './emitter/spawn/FXSpawnRandomVelocity.js';
|
|
16
|
+
export { FXSpawnSphere } from './emitter/spawn/FXSpawnSphere.js';
|
|
17
|
+
export { FXDiffuseMaterial } from './materials/FXDiffuseMaterial/FXDiffuseMaterial.js';
|
|
18
|
+
export { FXMaterial } from './materials/FXMaterial/FXMaterial.js';
|
|
19
|
+
export { FXUnlitMaterial } from './materials/FXUnlitMaterial/FXUnlitMaterial.js';
|
|
20
|
+
export { FXColor } from './miscellaneous/color/FXColor.js';
|
|
21
|
+
export { FXColorNode } from './nodes/color/FXColorNode.js';
|
|
22
|
+
export { FXColorOverLifeNode } from './nodes/color/FXColorOverLifeNode.js';
|
|
23
|
+
export { FXFlatNormalNode } from './nodes/normal/FXFlatNormalNode.js';
|
|
24
|
+
export { FXNormalNode } from './nodes/normal/FXNormalNode.js';
|
|
25
|
+
export { FXSphericalNormalNode } from './nodes/normal/FXSphericalNormalNode.js';
|
|
26
|
+
export { FXAnimatedTextureNode } from './nodes/texture/FXAnimatedTextureNode.js';
|
|
27
|
+
export { FXStaticTextureNode } from './nodes/texture/FXStaticTextureNode.js';
|
|
28
|
+
export { FXTextureNode } from './nodes/texture/FXTextureNode.js';
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import { InstancedBufferGeometry
|
|
2
|
-
import type { GLProperty, GLTypeInfo } from "./shared";
|
|
3
|
-
import { type FXProperty, type FXPropertyName } from "./shared";
|
|
1
|
+
import { InstancedBufferGeometry } from "three";
|
|
4
2
|
export declare const INSTANCED_PARTICLE_GEOMETRY: InstancedBufferGeometry;
|
|
5
|
-
export declare function collectProperties(keeper: Record<string, GLTypeInfo>, modules: readonly {
|
|
6
|
-
requiredProperties?: Record<string, FXPropertyName>;
|
|
7
|
-
}[], debugContext: string): void;
|
|
8
|
-
export declare function collectUniforms(keeper: Record<string, GLProperty>, modules: readonly {
|
|
9
|
-
requiredUniforms: Record<string, FXProperty>;
|
|
10
|
-
}[], debugContext: string): void;
|
|
11
|
-
export declare function buildParticleVertexShader(uniformDeclarations: string[], attributeDeclarations: string[], varyingDeclarations: string[], vertexAssignments: string[]): string;
|
|
12
|
-
export declare function buildParticleFragmentShader(uniformDeclarations: string[], varyingDeclarations: string[], sources: string[]): string;
|
|
13
|
-
export declare function buildParticleMaterial(sources: string[], uniformProperties: Record<string, GLProperty>, varyingProperties: Record<string, GLTypeInfo>, blending: Blending, useAlphaHashing: boolean): ShaderMaterial;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { InstancedBufferGeometry, BufferAttribute, Float32BufferAttribute
|
|
2
|
-
import { FXColor } from '../color/FXColor.js';
|
|
3
|
-
import { checkSRGBSupport } from '../miscellaneous/webglCapabilities.js';
|
|
4
|
-
import { resolveGLSLTypeInfo } from './shared.js';
|
|
1
|
+
import { InstancedBufferGeometry, BufferAttribute, Float32BufferAttribute } from 'three';
|
|
5
2
|
|
|
6
3
|
const INSTANCED_PARTICLE_GEOMETRY = (() => {
|
|
7
4
|
const geometry = new InstancedBufferGeometry();
|
|
@@ -13,206 +10,5 @@ const INSTANCED_PARTICLE_GEOMETRY = (() => {
|
|
|
13
10
|
geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
|
|
14
11
|
return geometry;
|
|
15
12
|
})();
|
|
16
|
-
function collectProperties(keeper, modules, debugContext) {
|
|
17
|
-
for (const module of modules) {
|
|
18
|
-
if (module.requiredProperties === undefined) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
for (const key in module.requiredProperties) {
|
|
22
|
-
const existingTypeInfo = keeper[key];
|
|
23
|
-
const newTypeInfo = resolveGLSLTypeInfo(module.requiredProperties[key]);
|
|
24
|
-
if (existingTypeInfo === undefined) {
|
|
25
|
-
keeper[key] = newTypeInfo;
|
|
26
|
-
}
|
|
27
|
-
else if (existingTypeInfo.glslTypeName !== newTypeInfo.glslTypeName) {
|
|
28
|
-
throw new Error(`${debugContext}: property conflict for "${key}"`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function collectUniforms(keeper, modules, debugContext) {
|
|
34
|
-
for (const module of modules) {
|
|
35
|
-
for (const key in module.requiredUniforms) {
|
|
36
|
-
const value = module.requiredUniforms[key];
|
|
37
|
-
const existingGLProperty = keeper[key];
|
|
38
|
-
const newPropertyTypeInfo = resolveGLSLTypeInfo(value);
|
|
39
|
-
if (existingGLProperty === undefined) {
|
|
40
|
-
keeper[key] = { value, glslTypeInfo: newPropertyTypeInfo };
|
|
41
|
-
}
|
|
42
|
-
else if (existingGLProperty.glslTypeInfo.glslTypeName !== newPropertyTypeInfo.glslTypeName) {
|
|
43
|
-
throw new Error(`${debugContext}: property conflict for "${key}"`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function buildParticleVertexShader(uniformDeclarations, attributeDeclarations, varyingDeclarations, vertexAssignments) {
|
|
49
|
-
return `
|
|
50
|
-
#define PARTICLE_POSITION_X p_builtin[0][0]
|
|
51
|
-
#define PARTICLE_POSITION_Y p_builtin[0][1]
|
|
52
|
-
#define PARTICLE_POSITION_Z p_builtin[0][2]
|
|
53
13
|
|
|
54
|
-
|
|
55
|
-
#define PARTICLE_VELOCITY_Y p_builtin[1][0]
|
|
56
|
-
#define PARTICLE_VELOCITY_Z p_builtin[1][1]
|
|
57
|
-
|
|
58
|
-
#define PARTICLE_SCALE_X p_builtin[1][2]
|
|
59
|
-
#define PARTICLE_SCALE_Y p_builtin[1][3]
|
|
60
|
-
#define PARTICLE_SCALE_Z p_builtin[2][0]
|
|
61
|
-
|
|
62
|
-
#define PARTICLE_ROTATION p_builtin[2][1]
|
|
63
|
-
#define PARTICLE_TORQUE p_builtin[2][2]
|
|
64
|
-
|
|
65
|
-
#define PARTICLE_LIFETIME p_builtin[2][3]
|
|
66
|
-
#define PARTICLE_AGE p_builtin[3][0]
|
|
67
|
-
|
|
68
|
-
#define PARTICLE_RANDOM_A p_builtin[3][1]
|
|
69
|
-
#define PARTICLE_RANDOM_B p_builtin[3][2]
|
|
70
|
-
#define PARTICLE_RANDOM_C p_builtin[3][3]
|
|
71
|
-
|
|
72
|
-
// User attributes
|
|
73
|
-
${attributeDeclarations.join("\n")}
|
|
74
|
-
|
|
75
|
-
// Uniforms
|
|
76
|
-
${uniformDeclarations.join("\n")}
|
|
77
|
-
|
|
78
|
-
// Builtin varyings
|
|
79
|
-
varying vec2 p_uv;
|
|
80
|
-
|
|
81
|
-
// User varyings
|
|
82
|
-
${varyingDeclarations.join("\n")}
|
|
83
|
-
|
|
84
|
-
void main() {
|
|
85
|
-
${vertexAssignments.join("\n")}
|
|
86
|
-
|
|
87
|
-
p_uv = uv;
|
|
88
|
-
|
|
89
|
-
vec2 transformedPosition = position.xy;
|
|
90
|
-
|
|
91
|
-
transformedPosition.x *= PARTICLE_SCALE_X;
|
|
92
|
-
transformedPosition.y *= PARTICLE_SCALE_Y;
|
|
93
|
-
|
|
94
|
-
float cosR = cos(PARTICLE_ROTATION);
|
|
95
|
-
float sinR = sin(PARTICLE_ROTATION);
|
|
96
|
-
|
|
97
|
-
transformedPosition = vec2(
|
|
98
|
-
transformedPosition.x * cosR - transformedPosition.y * sinR,
|
|
99
|
-
transformedPosition.x * sinR + transformedPosition.y * cosR
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
vec3 center = vec3(
|
|
103
|
-
PARTICLE_POSITION_X,
|
|
104
|
-
PARTICLE_POSITION_Y,
|
|
105
|
-
PARTICLE_POSITION_Z
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
vec4 modelViewCenter = modelViewMatrix * vec4(center, 1.0);
|
|
109
|
-
modelViewCenter.xy += transformedPosition;
|
|
110
|
-
gl_Position = projectionMatrix * modelViewCenter;
|
|
111
|
-
}
|
|
112
|
-
`;
|
|
113
|
-
}
|
|
114
|
-
function buildParticleFragmentShader(uniformDeclarations, varyingDeclarations, sources) {
|
|
115
|
-
const renamedSources = sources.map((source, index) => {
|
|
116
|
-
return source.replace(/vec4\s+draw\s*\(\s*\)/g, `vec4 draw${index}()`);
|
|
117
|
-
});
|
|
118
|
-
let drawCalls = "";
|
|
119
|
-
for (let i = 0; i < sources.length; i++) {
|
|
120
|
-
drawCalls += i !== 0 ? " * " : "";
|
|
121
|
-
drawCalls += `draw${i}()`;
|
|
122
|
-
}
|
|
123
|
-
return `
|
|
124
|
-
#include <common>
|
|
125
|
-
|
|
126
|
-
// Defines
|
|
127
|
-
#define SRGB_SUPPORTED ${checkSRGBSupport() ? "1" : "0"}
|
|
128
|
-
|
|
129
|
-
#define PARTICLE_POSITION_X p_builtin[0][0]
|
|
130
|
-
#define PARTICLE_POSITION_Y p_builtin[0][1]
|
|
131
|
-
#define PARTICLE_POSITION_Z p_builtin[0][2]
|
|
132
|
-
|
|
133
|
-
#define PARTICLE_VELOCITY_X p_builtin[0][3]
|
|
134
|
-
#define PARTICLE_VELOCITY_Y p_builtin[1][0]
|
|
135
|
-
#define PARTICLE_VELOCITY_Z p_builtin[1][1]
|
|
136
|
-
|
|
137
|
-
#define PARTICLE_SCALE_X p_builtin[1][2]
|
|
138
|
-
#define PARTICLE_SCALE_Y p_builtin[1][3]
|
|
139
|
-
#define PARTICLE_SCALE_Z p_builtin[2][0]
|
|
140
|
-
|
|
141
|
-
#define PARTICLE_ROTATION p_builtin[2][1]
|
|
142
|
-
#define PARTICLE_TORQUE p_builtin[2][2]
|
|
143
|
-
|
|
144
|
-
#define PARTICLE_LIFETIME p_builtin[2][3]
|
|
145
|
-
#define PARTICLE_AGE p_builtin[3][0]
|
|
146
|
-
|
|
147
|
-
#define PARTICLE_RANDOM_A p_builtin[3][1]
|
|
148
|
-
#define PARTICLE_RANDOM_B p_builtin[3][2]
|
|
149
|
-
#define PARTICLE_RANDOM_C p_builtin[3][3]
|
|
150
|
-
|
|
151
|
-
// Uniforms
|
|
152
|
-
${uniformDeclarations.join("\n")}
|
|
153
|
-
|
|
154
|
-
// Builtin varyings
|
|
155
|
-
varying vec2 p_uv;
|
|
156
|
-
|
|
157
|
-
// User varyings
|
|
158
|
-
${varyingDeclarations.join("\n")}
|
|
159
|
-
|
|
160
|
-
#include <alphahash_pars_fragment>
|
|
161
|
-
|
|
162
|
-
// sRGB decode helper
|
|
163
|
-
vec4 srgbTexture2D(sampler2D textureSampler, vec2 uv) {
|
|
164
|
-
#if SRGB_SUPPORTED
|
|
165
|
-
return texture2D(textureSampler, uv);
|
|
166
|
-
#else
|
|
167
|
-
vec4 textureValue = texture2D(textureSampler, uv);
|
|
168
|
-
return vec4(pow(textureValue.rgb, vec3(2.2)), textureValue.a);
|
|
169
|
-
#endif
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Source must define vec4 draw() function
|
|
173
|
-
${renamedSources.join("\n")}
|
|
174
|
-
|
|
175
|
-
void main() {
|
|
176
|
-
vec4 diffuseColor = ${drawCalls};
|
|
177
|
-
if (diffuseColor.a < 0.0035) {
|
|
178
|
-
discard;
|
|
179
|
-
}
|
|
180
|
-
#ifdef USE_ALPHAHASH
|
|
181
|
-
if (diffuseColor.a < getAlphaHashThreshold(vec3(p_builtin[0][0], p_builtin[0][1], p_builtin[0][2]))) {
|
|
182
|
-
discard;
|
|
183
|
-
}
|
|
184
|
-
#endif
|
|
185
|
-
gl_FragColor = linearToOutputTexel(diffuseColor);
|
|
186
|
-
}
|
|
187
|
-
`;
|
|
188
|
-
}
|
|
189
|
-
function buildParticleMaterial(sources, uniformProperties, varyingProperties, blending, useAlphaHashing) {
|
|
190
|
-
const uniforms = {};
|
|
191
|
-
const uniformDeclarations = [];
|
|
192
|
-
const attributeDeclarations = [];
|
|
193
|
-
const varyingDeclarations = [];
|
|
194
|
-
const vertexAssignments = [];
|
|
195
|
-
for (const name in uniformProperties) {
|
|
196
|
-
const { value, glslTypeInfo } = uniformProperties[name];
|
|
197
|
-
uniforms[`p_${name}`] = { value: value instanceof FXColor ? value.toGLSLColor() : value };
|
|
198
|
-
uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);
|
|
199
|
-
}
|
|
200
|
-
for (const name in varyingProperties) {
|
|
201
|
-
const { glslTypeName } = varyingProperties[name];
|
|
202
|
-
attributeDeclarations.push(`attribute ${glslTypeName} a_${name};`);
|
|
203
|
-
varyingDeclarations.push(`varying ${glslTypeName} p_${name};`);
|
|
204
|
-
vertexAssignments.push(`p_${name} = a_${name};`);
|
|
205
|
-
}
|
|
206
|
-
return new ShaderMaterial({
|
|
207
|
-
uniforms,
|
|
208
|
-
vertexShader: buildParticleVertexShader(uniformDeclarations, attributeDeclarations, varyingDeclarations, vertexAssignments),
|
|
209
|
-
fragmentShader: buildParticleFragmentShader(uniformDeclarations, varyingDeclarations, sources),
|
|
210
|
-
transparent: true,
|
|
211
|
-
depthWrite: false,
|
|
212
|
-
depthTest: true,
|
|
213
|
-
alphaHash: useAlphaHashing,
|
|
214
|
-
blending,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export { INSTANCED_PARTICLE_GEOMETRY, buildParticleFragmentShader, buildParticleMaterial, buildParticleVertexShader, collectProperties, collectUniforms };
|
|
14
|
+
export { INSTANCED_PARTICLE_GEOMETRY };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Material } from "three";
|
|
2
2
|
import { InstancedBufferAttribute, Mesh } from "three";
|
|
3
|
-
import {
|
|
4
|
-
import { FXParticleRenderingMode } from "./FXParticleRenderingMode";
|
|
5
|
-
import type { GLProperty, GLTypeInfo } from "./shared";
|
|
3
|
+
import type { GLTypeInfo } from "./shared";
|
|
6
4
|
export declare class FXInstancedParticle extends Mesh {
|
|
7
5
|
private readonly capacityStep;
|
|
8
6
|
readonly propertyBuffers: Record<string, InstancedBufferAttribute>;
|
|
9
7
|
private readonly instancedGeometry;
|
|
10
8
|
private readonly particleMaterial;
|
|
11
9
|
private capacity;
|
|
12
|
-
constructor(
|
|
10
|
+
constructor(varyings: Record<string, GLTypeInfo>, expectedCapacity: number, capacityStep: number, material: Material);
|
|
13
11
|
get instanceCount(): number;
|
|
14
12
|
createInstances(count: number): void;
|
|
15
13
|
removeDeadParticles(): void;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { Mesh, InstancedBufferAttribute, StreamDrawUsage } from 'three';
|
|
2
2
|
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME } from '../miscellaneous/miscellaneous.js';
|
|
3
|
-
import { INSTANCED_PARTICLE_GEOMETRY
|
|
4
|
-
import { buildParticleLambertMaterial } from './FXParticleLambertMaterial.js';
|
|
5
|
-
import './FXParticleNormalsMode.js';
|
|
6
|
-
import { FXParticleRenderingMode } from './FXParticleRenderingMode.js';
|
|
3
|
+
import { INSTANCED_PARTICLE_GEOMETRY } from './FXInstancedParticle.Internal.js';
|
|
7
4
|
|
|
8
5
|
class FXInstancedParticle extends Mesh {
|
|
9
|
-
constructor(
|
|
6
|
+
constructor(varyings, expectedCapacity, _private_capacityStep, material) {
|
|
10
7
|
const instancedGeometry = INSTANCED_PARTICLE_GEOMETRY.clone();
|
|
11
|
-
|
|
12
|
-
? buildParticleLambertMaterial(sources, uniforms, varyings, blending, useAlphaHashing, normalsMode)
|
|
13
|
-
: buildParticleMaterial(sources, uniforms, varyings, blending, useAlphaHashing);
|
|
14
|
-
super(instancedGeometry, particleMaterial);
|
|
8
|
+
super(instancedGeometry, material);
|
|
15
9
|
this._private_capacityStep = _private_capacityStep;
|
|
16
10
|
this.propertyBuffers = {};
|
|
17
11
|
this.frustumCulled = false;
|
|
18
12
|
this._private_instancedGeometry = instancedGeometry;
|
|
19
13
|
this._private_instancedGeometry.instanceCount = 0;
|
|
20
|
-
this._private_particleMaterial =
|
|
14
|
+
this._private_particleMaterial = material;
|
|
21
15
|
this._private_capacity = Math.max(Math.ceil(expectedCapacity / this._private_capacityStep) * this._private_capacityStep, this._private_capacityStep);
|
|
22
16
|
for (const name in varyings) {
|
|
23
17
|
const { bufferSize } = varyings[name];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IUniform, ShaderMaterial } from "three";
|
|
2
2
|
import { Matrix3, Matrix4, Texture, Vector2, Vector3, Vector4 } from "three";
|
|
3
|
-
import { FXColor } from "../color/FXColor";
|
|
3
|
+
import { FXColor } from "../miscellaneous/color/FXColor";
|
|
4
4
|
export type FXProperty = Texture | FXColor | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4 | number;
|
|
5
5
|
export type FXPropertyName = "Texture" | "FXColor" | "Vector2" | "Vector3" | "Vector4" | "Matrix3" | "Matrix4" | "number";
|
|
6
6
|
export type FXPropertyConstructor = typeof Texture | typeof FXColor | typeof Vector2 | typeof Vector3 | typeof Vector4 | typeof Matrix3 | typeof Matrix4 | NumberConstructor;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Blending } from "three";
|
|
2
|
+
import { MeshLambertMaterial } from "three";
|
|
3
|
+
import type { GLTypeInfo } from "../../instancedParticle/shared";
|
|
4
|
+
import type { FXColorNode } from "../../nodes/color/FXColorNode";
|
|
5
|
+
import type { FXNormalNode } from "../../nodes/normal/FXNormalNode";
|
|
6
|
+
import { FXTextureNode } from "../../nodes/texture/FXTextureNode";
|
|
7
|
+
export declare function buildFXDiffuseMaterial(varyings: Record<string, GLTypeInfo>, blending: Blending, useAlphaHashing: boolean, alphaTest: number, albedoNodes: readonly (FXColorNode | FXTextureNode)[], normalNodes: readonly (FXTextureNode | FXNormalNode)[], emissionNodes: readonly (FXColorNode | FXTextureNode)[]): MeshLambertMaterial;
|