sparcoon 0.0.6 → 0.0.8
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/_virtual/2d.js +3 -0
- package/dist/_virtual/3d.js +3 -0
- package/dist/_virtual/4d.js +3 -0
- package/dist/_virtual/mod.js +5 -0
- package/dist/_virtual/mod2.js +3 -0
- package/dist/behaviorModules/FXBehaviorDirectionalGravity.js +7 -3
- package/dist/behaviorModules/FXBehaviorPointGravity.js +10 -4
- package/dist/behaviorModules/FXBehaviorTorqueNoise.d.ts +1 -1
- package/dist/behaviorModules/FXBehaviorTorqueNoise.js +3 -1
- package/dist/behaviorModules/FXBehaviorVelocityDamping.js +2 -1
- package/dist/behaviorModules/FXBehaviorVelocityNoise.d.ts +1 -1
- package/dist/behaviorModules/FXBehaviorVelocityNoise.js +8 -4
- package/dist/elements/FXEmitter.js +7 -5
- package/dist/instancedParticle/shared.d.ts +1 -7
- package/dist/instancedParticle/shared.js +1 -1
- package/dist/miscellaneous/miscellaneous.d.ts +1 -2
- package/dist/miscellaneous/miscellaneous.js +2 -6
- package/dist/node_modules/fast-simplex-noise/lib/2d.js +93 -0
- package/dist/node_modules/fast-simplex-noise/lib/3d.js +142 -0
- package/dist/node_modules/fast-simplex-noise/lib/4d.js +196 -0
- package/dist/node_modules/fast-simplex-noise/lib/mod.js +24 -0
- package/dist/renderingModules/FXRenderingColorOverLife.js +1 -1
- package/dist/renderingModules/FXRenderingColorOverVelocity.js +2 -2
- package/dist/shaders/FXRenderingColorOverVelocity.glsl.js +1 -1
- package/dist/spawnModules/FXSpawnBox.d.ts +7 -7
- package/dist/spawnModules/FXSpawnBox.js +24 -24
- package/dist/spawnModules/FXSpawnOffset.js +3 -3
- package/package.json +12 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertValidNumber } from '../miscellaneous/asserts.js';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveFXVector3Config, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
|
|
3
3
|
import { FXBehaviorModule } from './FXBehaviorModule.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -15,9 +15,10 @@ class FXBehaviorDirectionalGravity extends FXBehaviorModule {
|
|
|
15
15
|
super();
|
|
16
16
|
/** @internal */
|
|
17
17
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
|
-
this._private_directionInternal =
|
|
18
|
+
this._private_directionInternal = resolveFXVector3Config(direction);
|
|
19
19
|
assertValidNumber(this._private_directionInternal.x, "FXBehaviorDirectionalGravity.constructor.direction.x");
|
|
20
20
|
assertValidNumber(this._private_directionInternal.y, "FXBehaviorDirectionalGravity.constructor.direction.y");
|
|
21
|
+
assertValidNumber(this._private_directionInternal.z, "FXBehaviorDirectionalGravity.constructor.direction.z");
|
|
21
22
|
}
|
|
22
23
|
/** Acceleration vector in units/second² */
|
|
23
24
|
get direction() {
|
|
@@ -25,9 +26,10 @@ class FXBehaviorDirectionalGravity extends FXBehaviorModule {
|
|
|
25
26
|
}
|
|
26
27
|
/** Acceleration vector in units/second² */
|
|
27
28
|
set direction(value) {
|
|
28
|
-
this._private_directionInternal =
|
|
29
|
+
this._private_directionInternal = resolveFXVector3Config(value);
|
|
29
30
|
assertValidNumber(this._private_directionInternal.x, "FXBehaviorDirectionalGravity.direction.x");
|
|
30
31
|
assertValidNumber(this._private_directionInternal.y, "FXBehaviorDirectionalGravity.direction.y");
|
|
32
|
+
assertValidNumber(this._private_directionInternal.z, "FXBehaviorDirectionalGravity.direction.z");
|
|
31
33
|
}
|
|
32
34
|
/** @internal */
|
|
33
35
|
update(properties, instanceCount, deltaTime) {
|
|
@@ -35,10 +37,12 @@ class FXBehaviorDirectionalGravity extends FXBehaviorModule {
|
|
|
35
37
|
const { array, itemSize } = builtin;
|
|
36
38
|
const offsetX = this._private_directionInternal.x * deltaTime;
|
|
37
39
|
const offsetY = this._private_directionInternal.y * deltaTime;
|
|
40
|
+
const offsetZ = this._private_directionInternal.z * deltaTime;
|
|
38
41
|
for (let i = 0; i < instanceCount; i++) {
|
|
39
42
|
const itemOffset = i * itemSize;
|
|
40
43
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += offsetX;
|
|
41
44
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += offsetY;
|
|
45
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] += offsetZ;
|
|
42
46
|
}
|
|
43
47
|
builtin.needsUpdate = true;
|
|
44
48
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MathUtils } from 'three';
|
|
2
2
|
import { assertValidNumber } from '../miscellaneous/asserts.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveFXVector3Config, resolveFXRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
|
|
4
4
|
import { FXBehaviorModule } from './FXBehaviorModule.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -19,9 +19,10 @@ class FXBehaviorPointGravity extends FXBehaviorModule {
|
|
|
19
19
|
super();
|
|
20
20
|
/** @internal */
|
|
21
21
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
22
|
-
this._private_centerInternal =
|
|
22
|
+
this._private_centerInternal = resolveFXVector3Config(center);
|
|
23
23
|
assertValidNumber(this._private_centerInternal.x, "FXBehaviorPointGravity.constructor.center.x");
|
|
24
24
|
assertValidNumber(this._private_centerInternal.y, "FXBehaviorPointGravity.constructor.center.y");
|
|
25
|
+
assertValidNumber(this._private_centerInternal.z, "FXBehaviorPointGravity.constructor.center.z");
|
|
25
26
|
this._private_strengthInternal = resolveFXRangeConfig(strength);
|
|
26
27
|
assertValidNumber(this._private_strengthInternal.min, "FXBehaviorPointGravity.constructor.strength.min");
|
|
27
28
|
assertValidNumber(this._private_strengthInternal.max, "FXBehaviorPointGravity.constructor.strength.max");
|
|
@@ -50,9 +51,10 @@ class FXBehaviorPointGravity extends FXBehaviorModule {
|
|
|
50
51
|
}
|
|
51
52
|
/** Gravity center position */
|
|
52
53
|
set center(value) {
|
|
53
|
-
this._private_centerInternal =
|
|
54
|
+
this._private_centerInternal = resolveFXVector3Config(value);
|
|
54
55
|
assertValidNumber(this._private_centerInternal.x, "FXBehaviorPointGravity.center.x");
|
|
55
56
|
assertValidNumber(this._private_centerInternal.y, "FXBehaviorPointGravity.center.y");
|
|
57
|
+
assertValidNumber(this._private_centerInternal.z, "FXBehaviorPointGravity.center.z");
|
|
56
58
|
}
|
|
57
59
|
/** Force multiplier range */
|
|
58
60
|
set strength(value) {
|
|
@@ -80,11 +82,12 @@ class FXBehaviorPointGravity extends FXBehaviorModule {
|
|
|
80
82
|
const itemOffset = i * itemSize;
|
|
81
83
|
const dx = this._private_centerInternal.x - array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
82
84
|
const dy = this._private_centerInternal.y - array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
85
|
+
const dz = this._private_centerInternal.z - array[itemOffset + BUILTIN_OFFSET_POSITION_Z];
|
|
83
86
|
// Constant over the life of a particle but different for each particle
|
|
84
87
|
const thresholdT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
|
|
85
88
|
const threshold = MathUtils.lerp(this.threshold.min, this.threshold.max, thresholdT);
|
|
86
89
|
const thresholdSquared = threshold * threshold;
|
|
87
|
-
const distanceSquared = dx * dx + dy * dy;
|
|
90
|
+
const distanceSquared = dx * dx + dy * dy + dz * dz;
|
|
88
91
|
if (distanceSquared < thresholdSquared) {
|
|
89
92
|
continue;
|
|
90
93
|
}
|
|
@@ -98,10 +101,13 @@ class FXBehaviorPointGravity extends FXBehaviorModule {
|
|
|
98
101
|
const forceMagnitude = strength / Math.pow(distance, exponent);
|
|
99
102
|
const directionX = dx / distance;
|
|
100
103
|
const directionY = dy / distance;
|
|
104
|
+
const directionZ = dz / distance;
|
|
101
105
|
const accelerationX = directionX * forceMagnitude;
|
|
102
106
|
const accelerationY = directionY * forceMagnitude;
|
|
107
|
+
const accelerationZ = directionZ * forceMagnitude;
|
|
103
108
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += accelerationX * deltaTime;
|
|
104
109
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += accelerationY * deltaTime;
|
|
110
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] += accelerationZ * deltaTime;
|
|
105
111
|
}
|
|
106
112
|
builtin.needsUpdate = true;
|
|
107
113
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FXRange, FXRangeConfig } from "../miscellaneous/miscellaneous";
|
|
2
2
|
import { FXBehaviorModule } from "./FXBehaviorModule";
|
|
3
3
|
/**
|
|
4
4
|
* Applies noise-based angular acceleration to particles.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { m as modExports } from '../_virtual/mod.js';
|
|
1
2
|
import { MathUtils } from 'three';
|
|
2
3
|
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_C,
|
|
4
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_TORQUE } from '../miscellaneous/miscellaneous.js';
|
|
4
5
|
import { FXBehaviorModule } from './FXBehaviorModule.js';
|
|
5
6
|
|
|
7
|
+
const generateNoise3D = modExports.makeNoise3D();
|
|
6
8
|
/**
|
|
7
9
|
* Applies noise-based angular acceleration to particles.
|
|
8
10
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MathUtils } from 'three';
|
|
2
2
|
import { assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y } from '../miscellaneous/miscellaneous.js';
|
|
3
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
|
|
4
4
|
import { FXBehaviorModule } from './FXBehaviorModule.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -41,6 +41,7 @@ class FXBehaviorVelocityDamping extends FXBehaviorModule {
|
|
|
41
41
|
const dampingFactor = Math.pow(1 - MathUtils.lerp(this._private_dampingInternal.min, this._private_dampingInternal.max, dampingT), deltaTime);
|
|
42
42
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] *= dampingFactor;
|
|
43
43
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] *= dampingFactor;
|
|
44
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] *= dampingFactor;
|
|
44
45
|
}
|
|
45
46
|
builtin.needsUpdate = true;
|
|
46
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FXRange, FXRangeConfig } from "../miscellaneous/miscellaneous";
|
|
2
2
|
import { FXBehaviorModule } from "./FXBehaviorModule";
|
|
3
3
|
/**
|
|
4
4
|
* Applies noise-based acceleration to particles.
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { m as modExports } from '../_virtual/mod.js';
|
|
1
2
|
import { MathUtils } from 'three';
|
|
2
3
|
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z
|
|
4
|
+
import { resolveFXRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
|
|
4
5
|
import { FXBehaviorModule } from './FXBehaviorModule.js';
|
|
5
6
|
|
|
7
|
+
const generateNoise3D0 = modExports.makeNoise3D();
|
|
8
|
+
const generateNoise3D1 = modExports.makeNoise3D();
|
|
9
|
+
const generateNoise3D2 = modExports.makeNoise3D();
|
|
6
10
|
/**
|
|
7
11
|
* Applies noise-based acceleration to particles.
|
|
8
12
|
*
|
|
@@ -56,9 +60,9 @@ class FXBehaviorVelocityNoise extends FXBehaviorModule {
|
|
|
56
60
|
// Constant over the life of a particle but different for each particle
|
|
57
61
|
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_C];
|
|
58
62
|
const scale = MathUtils.lerp(this._private_scaleInternal.min, this._private_scaleInternal.max, scaleT);
|
|
59
|
-
const noiseX =
|
|
60
|
-
const noiseY =
|
|
61
|
-
const noiseZ =
|
|
63
|
+
const noiseX = generateNoise3D0(x * scale, y * scale, z * scale);
|
|
64
|
+
const noiseY = generateNoise3D1(x * scale, y * scale, z * scale);
|
|
65
|
+
const noiseZ = generateNoise3D2(x * scale, y * scale, z * scale);
|
|
62
66
|
// Constant over the life of a particle but different for each particle
|
|
63
67
|
const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
|
|
64
68
|
const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
|
|
@@ -2,7 +2,7 @@ import { Object3D, NormalBlending } from 'three';
|
|
|
2
2
|
import { FXInstancedParticle } from '../instancedParticle/FXInstancedParticle.js';
|
|
3
3
|
import { collectProperties, collectUniforms } from '../instancedParticle/FXInstancedParticle.Internal.js';
|
|
4
4
|
import { resolveGLSLTypeInfo } from '../instancedParticle/shared.js';
|
|
5
|
-
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C } from '../miscellaneous/miscellaneous.js';
|
|
5
|
+
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_VELOCITY_Z, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C } from '../miscellaneous/miscellaneous.js';
|
|
6
6
|
import { EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES } from './FXEmitter.Internal.js';
|
|
7
7
|
|
|
8
8
|
const INSTANCES = new Array();
|
|
@@ -58,6 +58,8 @@ class FXEmitter extends Object3D {
|
|
|
58
58
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] * deltaTime;
|
|
59
59
|
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] +=
|
|
60
60
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] * deltaTime;
|
|
61
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Z] +=
|
|
62
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] * deltaTime;
|
|
61
63
|
}
|
|
62
64
|
builtin.needsUpdate = true;
|
|
63
65
|
}
|
|
@@ -73,11 +75,11 @@ class FXEmitter extends Object3D {
|
|
|
73
75
|
const collectedProperties = {
|
|
74
76
|
builtin: resolveGLSLTypeInfo("Matrix4"),
|
|
75
77
|
};
|
|
76
|
-
collectProperties(collectedProperties, _private_spawnSequence, "
|
|
77
|
-
collectProperties(collectedProperties, _private_behaviorSequence, "
|
|
78
|
-
collectProperties(collectedProperties, _private_renderingSequence, "
|
|
78
|
+
collectProperties(collectedProperties, _private_spawnSequence, "FXEmitter.constructor.spawnSequence:");
|
|
79
|
+
collectProperties(collectedProperties, _private_behaviorSequence, "FXEmitter.constructor.behaviorSequence");
|
|
80
|
+
collectProperties(collectedProperties, _private_renderingSequence, "FXEmitter.constructor.renderingSequence");
|
|
79
81
|
const collectedUniforms = {};
|
|
80
|
-
collectUniforms(collectedUniforms, _private_renderingSequence, "
|
|
82
|
+
collectUniforms(collectedUniforms, _private_renderingSequence, "FXEmitter.constructor.renderingSequence");
|
|
81
83
|
this._private_mesh = new FXInstancedParticle(this._private_renderingSequence.map((module) => module.source), collectedUniforms, collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP, options.blending ?? NormalBlending, options.useAlphaHashing ?? false);
|
|
82
84
|
this.automaticallyDestroyModules =
|
|
83
85
|
options.automaticallyDestroyModules ?? EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES;
|
|
@@ -2,7 +2,7 @@ import type { IUniform, ShaderMaterial } from "three";
|
|
|
2
2
|
import { Matrix3, Matrix4, Texture, Vector2, Vector3, Vector4 } from "three";
|
|
3
3
|
import { FXColor } from "../color/FXColor";
|
|
4
4
|
export type FXProperty = Texture | FXColor | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4 | number;
|
|
5
|
-
export type FXPropertyName = "Texture" | "
|
|
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;
|
|
7
7
|
export type FXPropertyCopyTo = FXColor | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4;
|
|
8
8
|
export type FXPropertyCopyFrom = FXColor & Vector2 & Vector3 & Vector4 & Matrix3 & Matrix4;
|
|
@@ -15,11 +15,5 @@ export interface GLProperty {
|
|
|
15
15
|
value: FXProperty;
|
|
16
16
|
glslTypeInfo: GLTypeInfo;
|
|
17
17
|
}
|
|
18
|
-
export interface PlaneData {
|
|
19
|
-
source: string;
|
|
20
|
-
properties: Record<string, GLProperty>;
|
|
21
|
-
transform: Matrix4;
|
|
22
|
-
visibility: boolean;
|
|
23
|
-
}
|
|
24
18
|
export declare function resolveGLSLTypeInfo(value: FXProperty | FXPropertyName | FXPropertyConstructor): GLTypeInfo;
|
|
25
19
|
export declare function resolvePropertyUniform(name: string, material: ShaderMaterial): IUniform<FXProperty>;
|
|
@@ -11,9 +11,8 @@ export type FXRangeConfig = FXRange | [number, number, number] | number;
|
|
|
11
11
|
export type FXVector3Config = Vector3Like | Vector3Tuple | number;
|
|
12
12
|
export type FXAspectConfig = number | FXTextureConfig;
|
|
13
13
|
export declare function resolveFXRangeConfig(config: FXRangeConfig): FXRange;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function resolveFXVector3Config(config: FXVector3Config): Vector3Like;
|
|
15
15
|
export declare function resolveAspect(config: number | FXTextureConfig): number;
|
|
16
|
-
export declare function generateNoise3D(x: number, y: number, z: number): number;
|
|
17
16
|
export declare function buildGradientTexture(colors: FXColor[]): DataTexture;
|
|
18
17
|
export declare const BUILTIN_OFFSET_POSITION_X = 0;
|
|
19
18
|
export declare const BUILTIN_OFFSET_POSITION_Y = 1;
|
|
@@ -9,7 +9,7 @@ function resolveFXRangeConfig(config) {
|
|
|
9
9
|
}
|
|
10
10
|
return config;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function resolveFXVector3Config(config) {
|
|
13
13
|
if (typeof config === "number") {
|
|
14
14
|
return { x: config, y: config, z: config };
|
|
15
15
|
}
|
|
@@ -27,10 +27,6 @@ function resolveAspect(config) {
|
|
|
27
27
|
}
|
|
28
28
|
return config.sourceSize.w / config.sourceSize.h;
|
|
29
29
|
}
|
|
30
|
-
function generateNoise3D(x, y, z) {
|
|
31
|
-
const noise = Math.sin(x * 12.9898 + y * 78.233 + z * 37.719) * 43758.5453123;
|
|
32
|
-
return (noise - Math.floor(noise)) * 2 - 1;
|
|
33
|
-
}
|
|
34
30
|
function buildGradientTexture(colors) {
|
|
35
31
|
const width = colors.length;
|
|
36
32
|
const height = 1;
|
|
@@ -63,4 +59,4 @@ const BUILTIN_OFFSET_RANDOM_A = 13;
|
|
|
63
59
|
const BUILTIN_OFFSET_RANDOM_B = 14;
|
|
64
60
|
const BUILTIN_OFFSET_RANDOM_C = 15;
|
|
65
61
|
|
|
66
|
-
export { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z, buildGradientTexture,
|
|
62
|
+
export { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z, buildGradientTexture, resolveAspect, resolveFXRangeConfig, resolveFXVector3Config };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { __exports as _2d } from '../../../_virtual/2d.js';
|
|
2
|
+
|
|
3
|
+
var hasRequired_2d;
|
|
4
|
+
|
|
5
|
+
function require_2d () {
|
|
6
|
+
if (hasRequired_2d) return _2d;
|
|
7
|
+
hasRequired_2d = 1;
|
|
8
|
+
/*
|
|
9
|
+
* Based on example code by Stefan Gustavson (stegu@itn.liu.se).
|
|
10
|
+
* Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
|
|
11
|
+
* Better rank ordering method by Stefan Gustavson in 2012.
|
|
12
|
+
*
|
|
13
|
+
* This code was placed in the public domain by its original author,
|
|
14
|
+
* Stefan Gustavson. You may use it as you see fit, but
|
|
15
|
+
* attribution is appreciated.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(_2d, "__esModule", { value: true });
|
|
18
|
+
_2d.makeNoise2D = void 0;
|
|
19
|
+
var G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
|
|
20
|
+
var Grad = [
|
|
21
|
+
[1, 1],
|
|
22
|
+
[-1, 1],
|
|
23
|
+
[1, -1],
|
|
24
|
+
[-1, -1],
|
|
25
|
+
[1, 0],
|
|
26
|
+
[-1, 0],
|
|
27
|
+
[1, 0],
|
|
28
|
+
[-1, 0],
|
|
29
|
+
[0, 1],
|
|
30
|
+
[0, -1],
|
|
31
|
+
[0, 1],
|
|
32
|
+
[0, -1],
|
|
33
|
+
];
|
|
34
|
+
function makeNoise2D(random) {
|
|
35
|
+
if (random === void 0) { random = Math.random; }
|
|
36
|
+
var p = new Uint8Array(256);
|
|
37
|
+
for (var i = 0; i < 256; i++)
|
|
38
|
+
p[i] = i;
|
|
39
|
+
var n;
|
|
40
|
+
var q;
|
|
41
|
+
for (var i = 255; i > 0; i--) {
|
|
42
|
+
n = Math.floor((i + 1) * random());
|
|
43
|
+
q = p[i];
|
|
44
|
+
p[i] = p[n];
|
|
45
|
+
p[n] = q;
|
|
46
|
+
}
|
|
47
|
+
var perm = new Uint8Array(512);
|
|
48
|
+
var permMod12 = new Uint8Array(512);
|
|
49
|
+
for (var i = 0; i < 512; i++) {
|
|
50
|
+
perm[i] = p[i & 255];
|
|
51
|
+
permMod12[i] = perm[i] % 12;
|
|
52
|
+
}
|
|
53
|
+
return function (x, y) {
|
|
54
|
+
// Skew the input space to determine which simplex cell we're in
|
|
55
|
+
var s = (x + y) * 0.5 * (Math.sqrt(3.0) - 1.0); // Hairy factor for 2D
|
|
56
|
+
var i = Math.floor(x + s);
|
|
57
|
+
var j = Math.floor(y + s);
|
|
58
|
+
var t = (i + j) * G2;
|
|
59
|
+
var X0 = i - t; // Unskew the cell origin back to (x,y) space
|
|
60
|
+
var Y0 = j - t;
|
|
61
|
+
var x0 = x - X0; // The x,y distances from the cell origin
|
|
62
|
+
var y0 = y - Y0;
|
|
63
|
+
// Determine which simplex we are in.
|
|
64
|
+
var i1 = x0 > y0 ? 1 : 0;
|
|
65
|
+
var j1 = x0 > y0 ? 0 : 1;
|
|
66
|
+
// Offsets for corners
|
|
67
|
+
var x1 = x0 - i1 + G2;
|
|
68
|
+
var y1 = y0 - j1 + G2;
|
|
69
|
+
var x2 = x0 - 1.0 + 2.0 * G2;
|
|
70
|
+
var y2 = y0 - 1.0 + 2.0 * G2;
|
|
71
|
+
// Work out the hashed gradient indices of the three simplex corners
|
|
72
|
+
var ii = i & 255;
|
|
73
|
+
var jj = j & 255;
|
|
74
|
+
var g0 = Grad[permMod12[ii + perm[jj]]];
|
|
75
|
+
var g1 = Grad[permMod12[ii + i1 + perm[jj + j1]]];
|
|
76
|
+
var g2 = Grad[permMod12[ii + 1 + perm[jj + 1]]];
|
|
77
|
+
// Calculate the contribution from the three corners
|
|
78
|
+
var t0 = 0.5 - x0 * x0 - y0 * y0;
|
|
79
|
+
var n0 = t0 < 0 ? 0.0 : Math.pow(t0, 4) * (g0[0] * x0 + g0[1] * y0);
|
|
80
|
+
var t1 = 0.5 - x1 * x1 - y1 * y1;
|
|
81
|
+
var n1 = t1 < 0 ? 0.0 : Math.pow(t1, 4) * (g1[0] * x1 + g1[1] * y1);
|
|
82
|
+
var t2 = 0.5 - x2 * x2 - y2 * y2;
|
|
83
|
+
var n2 = t2 < 0 ? 0.0 : Math.pow(t2, 4) * (g2[0] * x2 + g2[1] * y2);
|
|
84
|
+
// Add contributions from each corner to get the final noise value.
|
|
85
|
+
// The result is scaled to return values in the interval [-1, 1]
|
|
86
|
+
return 70.14805770653952 * (n0 + n1 + n2);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
_2d.makeNoise2D = makeNoise2D;
|
|
90
|
+
return _2d;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { require_2d as __require };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { __exports as _3d } from '../../../_virtual/3d.js';
|
|
2
|
+
|
|
3
|
+
var hasRequired_3d;
|
|
4
|
+
|
|
5
|
+
function require_3d () {
|
|
6
|
+
if (hasRequired_3d) return _3d;
|
|
7
|
+
hasRequired_3d = 1;
|
|
8
|
+
/*
|
|
9
|
+
* Based on example code by Stefan Gustavson (stegu@itn.liu.se).
|
|
10
|
+
* Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
|
|
11
|
+
* Better rank ordering method by Stefan Gustavson in 2012.
|
|
12
|
+
*
|
|
13
|
+
* This code was placed in the public domain by its original author,
|
|
14
|
+
* Stefan Gustavson. You may use it as you see fit, but
|
|
15
|
+
* attribution is appreciated.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(_3d, "__esModule", { value: true });
|
|
18
|
+
_3d.makeNoise3D = void 0;
|
|
19
|
+
var G3 = 1.0 / 6.0;
|
|
20
|
+
var Grad = [
|
|
21
|
+
[1, 1, 0],
|
|
22
|
+
[-1, 1, 0],
|
|
23
|
+
[1, -1, 0],
|
|
24
|
+
[-1, -1, 0],
|
|
25
|
+
[1, 0, 1],
|
|
26
|
+
[-1, 0, 1],
|
|
27
|
+
[1, 0, -1],
|
|
28
|
+
[-1, 0, -1],
|
|
29
|
+
[0, 1, 1],
|
|
30
|
+
[0, -1, -1],
|
|
31
|
+
[0, 1, -1],
|
|
32
|
+
[0, -1, -1],
|
|
33
|
+
];
|
|
34
|
+
function makeNoise3D(random) {
|
|
35
|
+
if (random === void 0) { random = Math.random; }
|
|
36
|
+
var p = new Uint8Array(256);
|
|
37
|
+
for (var i = 0; i < 256; i++)
|
|
38
|
+
p[i] = i;
|
|
39
|
+
var n;
|
|
40
|
+
var q;
|
|
41
|
+
for (var i = 255; i > 0; i--) {
|
|
42
|
+
n = Math.floor((i + 1) * random());
|
|
43
|
+
q = p[i];
|
|
44
|
+
p[i] = p[n];
|
|
45
|
+
p[n] = q;
|
|
46
|
+
}
|
|
47
|
+
var perm = new Uint8Array(512);
|
|
48
|
+
var permMod12 = new Uint8Array(512);
|
|
49
|
+
for (var i = 0; i < 512; i++) {
|
|
50
|
+
perm[i] = p[i & 255];
|
|
51
|
+
permMod12[i] = perm[i] % 12;
|
|
52
|
+
}
|
|
53
|
+
return function (x, y, z) {
|
|
54
|
+
// Skew the input space to determine which simplex cell we're in
|
|
55
|
+
var s = (x + y + z) / 3.0; // Very nice and simple skew factor for 3D
|
|
56
|
+
var i = Math.floor(x + s);
|
|
57
|
+
var j = Math.floor(y + s);
|
|
58
|
+
var k = Math.floor(z + s);
|
|
59
|
+
var t = (i + j + k) * G3;
|
|
60
|
+
var X0 = i - t; // Unskew the cell origin back to (x,y,z) space
|
|
61
|
+
var Y0 = j - t;
|
|
62
|
+
var Z0 = k - t;
|
|
63
|
+
var x0 = x - X0; // The x,y,z distances from the cell origin
|
|
64
|
+
var y0 = y - Y0;
|
|
65
|
+
var z0 = z - Z0;
|
|
66
|
+
// Deterine which simplex we are in
|
|
67
|
+
var i1, j1, k1 // Offsets for second corner of simplex in (i,j,k) coords
|
|
68
|
+
;
|
|
69
|
+
var i2, j2, k2 // Offsets for third corner of simplex in (i,j,k) coords
|
|
70
|
+
;
|
|
71
|
+
if (x0 >= y0) {
|
|
72
|
+
if (y0 >= z0) {
|
|
73
|
+
i1 = i2 = j2 = 1;
|
|
74
|
+
j1 = k1 = k2 = 0;
|
|
75
|
+
}
|
|
76
|
+
else if (x0 >= z0) {
|
|
77
|
+
i1 = i2 = k2 = 1;
|
|
78
|
+
j1 = k1 = j2 = 0;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
k1 = i2 = k2 = 1;
|
|
82
|
+
i1 = j1 = j2 = 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
if (y0 < z0) {
|
|
87
|
+
k1 = j2 = k2 = 1;
|
|
88
|
+
i1 = j1 = i2 = 0;
|
|
89
|
+
}
|
|
90
|
+
else if (x0 < z0) {
|
|
91
|
+
j1 = j2 = k2 = 1;
|
|
92
|
+
i1 = k1 = i2 = 0;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
j1 = i2 = j2 = 1;
|
|
96
|
+
i1 = k1 = k2 = 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
|
|
100
|
+
var y1 = y0 - j1 + G3;
|
|
101
|
+
var z1 = z0 - k1 + G3;
|
|
102
|
+
var x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
|
|
103
|
+
var y2 = y0 - j2 + 2.0 * G3;
|
|
104
|
+
var z2 = z0 - k2 + 2.0 * G3;
|
|
105
|
+
var x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
|
|
106
|
+
var y3 = y0 - 1.0 + 3.0 * G3;
|
|
107
|
+
var z3 = z0 - 1.0 + 3.0 * G3;
|
|
108
|
+
// Work out the hashed gradient indices of the four simplex corners
|
|
109
|
+
var ii = i & 255;
|
|
110
|
+
var jj = j & 255;
|
|
111
|
+
var kk = k & 255;
|
|
112
|
+
var g0 = Grad[permMod12[ii + perm[jj + perm[kk]]]];
|
|
113
|
+
var g1 = Grad[permMod12[ii + i1 + perm[jj + j1 + perm[kk + k1]]]];
|
|
114
|
+
var g2 = Grad[permMod12[ii + i2 + perm[jj + j2 + perm[kk + k2]]]];
|
|
115
|
+
var g3 = Grad[permMod12[ii + 1 + perm[jj + 1 + perm[kk + 1]]]];
|
|
116
|
+
// Calculate the contribution from the four corners
|
|
117
|
+
var t0 = 0.5 - x0 * x0 - y0 * y0 - z0 * z0;
|
|
118
|
+
var n0 = t0 < 0
|
|
119
|
+
? 0.0
|
|
120
|
+
: Math.pow(t0, 4) * (g0[0] * x0 + g0[1] * y0 + g0[2] * z0);
|
|
121
|
+
var t1 = 0.5 - x1 * x1 - y1 * y1 - z1 * z1;
|
|
122
|
+
var n1 = t1 < 0
|
|
123
|
+
? 0.0
|
|
124
|
+
: Math.pow(t1, 4) * (g1[0] * x1 + g1[1] * y1 + g1[2] * z1);
|
|
125
|
+
var t2 = 0.5 - x2 * x2 - y2 * y2 - z2 * z2;
|
|
126
|
+
var n2 = t2 < 0
|
|
127
|
+
? 0.0
|
|
128
|
+
: Math.pow(t2, 4) * (g2[0] * x2 + g2[1] * y2 + g2[2] * z2);
|
|
129
|
+
var t3 = 0.5 - x3 * x3 - y3 * y3 - z3 * z3;
|
|
130
|
+
var n3 = t3 < 0
|
|
131
|
+
? 0.0
|
|
132
|
+
: Math.pow(t3, 4) * (g3[0] * x3 + g3[1] * y3 + g3[2] * z3);
|
|
133
|
+
// Add contributions from each corner to get the final noise value.
|
|
134
|
+
// The result is scaled to stay just inside [-1,1]
|
|
135
|
+
return 94.68493150681972 * (n0 + n1 + n2 + n3);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
_3d.makeNoise3D = makeNoise3D;
|
|
139
|
+
return _3d;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { require_3d as __require };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { __exports as _4d } from '../../../_virtual/4d.js';
|
|
2
|
+
|
|
3
|
+
var hasRequired_4d;
|
|
4
|
+
|
|
5
|
+
function require_4d () {
|
|
6
|
+
if (hasRequired_4d) return _4d;
|
|
7
|
+
hasRequired_4d = 1;
|
|
8
|
+
/*
|
|
9
|
+
* Based on example code by Stefan Gustavson (stegu@itn.liu.se).
|
|
10
|
+
* Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
|
|
11
|
+
* Better rank ordering method by Stefan Gustavson in 2012.
|
|
12
|
+
*
|
|
13
|
+
* This code was placed in the public domain by its original author,
|
|
14
|
+
* Stefan Gustavson. You may use it as you see fit, but
|
|
15
|
+
* attribution is appreciated.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(_4d, "__esModule", { value: true });
|
|
18
|
+
_4d.makeNoise4D = void 0;
|
|
19
|
+
var G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
|
|
20
|
+
var Grad = [
|
|
21
|
+
[0, 1, 1, 1],
|
|
22
|
+
[0, 1, 1, -1],
|
|
23
|
+
[0, 1, -1, 1],
|
|
24
|
+
[0, 1, -1, -1],
|
|
25
|
+
[0, -1, 1, 1],
|
|
26
|
+
[0, -1, 1, -1],
|
|
27
|
+
[0, -1, -1, 1],
|
|
28
|
+
[0, -1, -1, -1],
|
|
29
|
+
[1, 0, 1, 1],
|
|
30
|
+
[1, 0, 1, -1],
|
|
31
|
+
[1, 0, -1, 1],
|
|
32
|
+
[1, 0, -1, -1],
|
|
33
|
+
[-1, 0, 1, 1],
|
|
34
|
+
[-1, 0, 1, -1],
|
|
35
|
+
[-1, 0, -1, 1],
|
|
36
|
+
[-1, 0, -1, -1],
|
|
37
|
+
[1, 1, 0, 1],
|
|
38
|
+
[1, 1, 0, -1],
|
|
39
|
+
[1, -1, 0, 1],
|
|
40
|
+
[1, -1, 0, -1],
|
|
41
|
+
[-1, 1, 0, 1],
|
|
42
|
+
[-1, 1, 0, -1],
|
|
43
|
+
[-1, -1, 0, 1],
|
|
44
|
+
[-1, -1, 0, -1],
|
|
45
|
+
[1, 1, 1, 0],
|
|
46
|
+
[1, 1, -1, 0],
|
|
47
|
+
[1, -1, 1, 0],
|
|
48
|
+
[1, -1, -1, 0],
|
|
49
|
+
[-1, 1, 1, 0],
|
|
50
|
+
[-1, 1, -1, 0],
|
|
51
|
+
[-1, -1, 1, 0],
|
|
52
|
+
[-1, -1, -1, 0],
|
|
53
|
+
];
|
|
54
|
+
function makeNoise4D(random) {
|
|
55
|
+
if (random === void 0) { random = Math.random; }
|
|
56
|
+
var p = new Uint8Array(256);
|
|
57
|
+
for (var i = 0; i < 256; i++)
|
|
58
|
+
p[i] = i;
|
|
59
|
+
var n;
|
|
60
|
+
var q;
|
|
61
|
+
for (var i = 255; i > 0; i--) {
|
|
62
|
+
n = Math.floor((i + 1) * random());
|
|
63
|
+
q = p[i];
|
|
64
|
+
p[i] = p[n];
|
|
65
|
+
p[n] = q;
|
|
66
|
+
}
|
|
67
|
+
var perm = new Uint8Array(512);
|
|
68
|
+
var permMod12 = new Uint8Array(512);
|
|
69
|
+
for (var i = 0; i < 512; i++) {
|
|
70
|
+
perm[i] = p[i & 255];
|
|
71
|
+
permMod12[i] = perm[i] % 12;
|
|
72
|
+
}
|
|
73
|
+
return function (x, y, z, w) {
|
|
74
|
+
// Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
|
|
75
|
+
var s = (x + y + z + w) * (Math.sqrt(5.0) - 1.0) / 4.0; // Factor for 4D skewing
|
|
76
|
+
var i = Math.floor(x + s);
|
|
77
|
+
var j = Math.floor(y + s);
|
|
78
|
+
var k = Math.floor(z + s);
|
|
79
|
+
var l = Math.floor(w + s);
|
|
80
|
+
var t = (i + j + k + l) * G4; // Factor for 4D unskewing
|
|
81
|
+
var X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
|
|
82
|
+
var Y0 = j - t;
|
|
83
|
+
var Z0 = k - t;
|
|
84
|
+
var W0 = l - t;
|
|
85
|
+
var x0 = x - X0; // The x,y,z,w distances from the cell origin
|
|
86
|
+
var y0 = y - Y0;
|
|
87
|
+
var z0 = z - Z0;
|
|
88
|
+
var w0 = w - W0;
|
|
89
|
+
// To find out which of the 24 possible simplices we're in, we need to determine the
|
|
90
|
+
// magnitude ordering of x0, y0, z0 and w0. Six pair-wise comparisons are performed between
|
|
91
|
+
// each possible pair of the four coordinates, and the results are used to rank the numbers.
|
|
92
|
+
var rankx = 0;
|
|
93
|
+
var ranky = 0;
|
|
94
|
+
var rankz = 0;
|
|
95
|
+
var rankw = 0;
|
|
96
|
+
if (x0 > y0)
|
|
97
|
+
rankx++;
|
|
98
|
+
else
|
|
99
|
+
ranky++;
|
|
100
|
+
if (x0 > z0)
|
|
101
|
+
rankx++;
|
|
102
|
+
else
|
|
103
|
+
rankz++;
|
|
104
|
+
if (x0 > w0)
|
|
105
|
+
rankx++;
|
|
106
|
+
else
|
|
107
|
+
rankw++;
|
|
108
|
+
if (y0 > z0)
|
|
109
|
+
ranky++;
|
|
110
|
+
else
|
|
111
|
+
rankz++;
|
|
112
|
+
if (y0 > w0)
|
|
113
|
+
ranky++;
|
|
114
|
+
else
|
|
115
|
+
rankw++;
|
|
116
|
+
if (z0 > w0)
|
|
117
|
+
rankz++;
|
|
118
|
+
else
|
|
119
|
+
rankw++;
|
|
120
|
+
// simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
|
|
121
|
+
// Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w
|
|
122
|
+
// impossible. Only the 24 indices which have non-zero entries make any sense.
|
|
123
|
+
// We use a thresholding to set the coordinates in turn from the largest magnitude.
|
|
124
|
+
// Rank 3 denotes the largest coordinate.
|
|
125
|
+
var i1 = rankx >= 3 ? 1 : 0;
|
|
126
|
+
var j1 = ranky >= 3 ? 1 : 0;
|
|
127
|
+
var k1 = rankz >= 3 ? 1 : 0;
|
|
128
|
+
var l1 = rankw >= 3 ? 1 : 0;
|
|
129
|
+
// Rank 2 denotes the second largest coordinate.
|
|
130
|
+
var i2 = rankx >= 2 ? 1 : 0;
|
|
131
|
+
var j2 = ranky >= 2 ? 1 : 0;
|
|
132
|
+
var k2 = rankz >= 2 ? 1 : 0;
|
|
133
|
+
var l2 = rankw >= 2 ? 1 : 0;
|
|
134
|
+
// Rank 1 denotes the second smallest coordinate.
|
|
135
|
+
var i3 = rankx >= 1 ? 1 : 0;
|
|
136
|
+
var j3 = ranky >= 1 ? 1 : 0;
|
|
137
|
+
var k3 = rankz >= 1 ? 1 : 0;
|
|
138
|
+
var l3 = rankw >= 1 ? 1 : 0;
|
|
139
|
+
// The fifth corner has all coordinate offsets = 1, so no need to compute that.
|
|
140
|
+
var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
|
|
141
|
+
var y1 = y0 - j1 + G4;
|
|
142
|
+
var z1 = z0 - k1 + G4;
|
|
143
|
+
var w1 = w0 - l1 + G4;
|
|
144
|
+
var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
|
|
145
|
+
var y2 = y0 - j2 + 2.0 * G4;
|
|
146
|
+
var z2 = z0 - k2 + 2.0 * G4;
|
|
147
|
+
var w2 = w0 - l2 + 2.0 * G4;
|
|
148
|
+
var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
|
|
149
|
+
var y3 = y0 - j3 + 3.0 * G4;
|
|
150
|
+
var z3 = z0 - k3 + 3.0 * G4;
|
|
151
|
+
var w3 = w0 - l3 + 3.0 * G4;
|
|
152
|
+
var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
|
|
153
|
+
var y4 = y0 - 1.0 + 4.0 * G4;
|
|
154
|
+
var z4 = z0 - 1.0 + 4.0 * G4;
|
|
155
|
+
var w4 = w0 - 1.0 + 4.0 * G4;
|
|
156
|
+
// Work out the hashed gradient indices of the five simplex corners
|
|
157
|
+
var ii = i & 255;
|
|
158
|
+
var jj = j & 255;
|
|
159
|
+
var kk = k & 255;
|
|
160
|
+
var ll = l & 255;
|
|
161
|
+
var g0 = Grad[perm[ii + perm[jj + perm[kk + perm[ll]]]] %
|
|
162
|
+
32];
|
|
163
|
+
var g1 = Grad[perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32];
|
|
164
|
+
var g2 = Grad[perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32];
|
|
165
|
+
var g3 = Grad[perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32];
|
|
166
|
+
var g4 = Grad[perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32];
|
|
167
|
+
// Calculate the contribution from the five corners
|
|
168
|
+
var t0 = 0.5 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
|
|
169
|
+
var n0 = t0 < 0
|
|
170
|
+
? 0.0
|
|
171
|
+
: Math.pow(t0, 4) * (g0[0] * x0 + g0[1] * y0 + g0[2] * z0 + g0[3] * w0);
|
|
172
|
+
var t1 = 0.5 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
|
|
173
|
+
var n1 = t1 < 0
|
|
174
|
+
? 0.0
|
|
175
|
+
: Math.pow(t1, 4) * (g1[0] * x1 + g1[1] * y1 + g1[2] * z1 + g1[3] * w1);
|
|
176
|
+
var t2 = 0.5 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
|
|
177
|
+
var n2 = t2 < 0
|
|
178
|
+
? 0.0
|
|
179
|
+
: Math.pow(t2, 4) * (g2[0] * x2 + g2[1] * y2 + g2[2] * z2 + g2[3] * w2);
|
|
180
|
+
var t3 = 0.5 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
|
|
181
|
+
var n3 = t3 < 0
|
|
182
|
+
? 0.0
|
|
183
|
+
: Math.pow(t3, 4) * (g3[0] * x3 + g3[1] * y3 + g3[2] * z3 + g3[3] * w3);
|
|
184
|
+
var t4 = 0.5 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
|
|
185
|
+
var n4 = t4 < 0
|
|
186
|
+
? 0.0
|
|
187
|
+
: Math.pow(t4, 4) * (g4[0] * x4 + g4[1] * y4 + g4[2] * z4 + g4[3] * w4);
|
|
188
|
+
// Sum up and scale the result to cover the range [-1,1]
|
|
189
|
+
return 72.37855765153665 * (n0 + n1 + n2 + n3 + n4);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
_4d.makeNoise4D = makeNoise4D;
|
|
193
|
+
return _4d;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { require_4d as __require };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __exports as mod } from '../../../_virtual/mod2.js';
|
|
2
|
+
import { __require as require_2d } from './2d.js';
|
|
3
|
+
import { __require as require_3d } from './3d.js';
|
|
4
|
+
import { __require as require_4d } from './4d.js';
|
|
5
|
+
|
|
6
|
+
var hasRequiredMod;
|
|
7
|
+
|
|
8
|
+
function requireMod () {
|
|
9
|
+
if (hasRequiredMod) return mod;
|
|
10
|
+
hasRequiredMod = 1;
|
|
11
|
+
(function (exports$1) {
|
|
12
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
13
|
+
exports$1.makeNoise4D = exports$1.makeNoise3D = exports$1.makeNoise2D = void 0;
|
|
14
|
+
var _2d_1 = require_2d();
|
|
15
|
+
Object.defineProperty(exports$1, "makeNoise2D", { enumerable: true, get: function () { return _2d_1.makeNoise2D; } });
|
|
16
|
+
var _3d_1 = require_3d();
|
|
17
|
+
Object.defineProperty(exports$1, "makeNoise3D", { enumerable: true, get: function () { return _3d_1.makeNoise3D; } });
|
|
18
|
+
var _4d_1 = require_4d();
|
|
19
|
+
Object.defineProperty(exports$1, "makeNoise4D", { enumerable: true, get: function () { return _4d_1.makeNoise4D; } });
|
|
20
|
+
} (mod));
|
|
21
|
+
return mod;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { requireMod as __require };
|
|
@@ -20,7 +20,7 @@ class FXRenderingColorOverLife extends FXRenderingModule {
|
|
|
20
20
|
/** @internal */
|
|
21
21
|
this.source = source;
|
|
22
22
|
if (colors.length === 0) {
|
|
23
|
-
throw new Error("
|
|
23
|
+
throw new Error("FXRenderingColorOverLife: colors array cannot be empty");
|
|
24
24
|
}
|
|
25
25
|
this.requiredUniforms = { colorOverLifeTexture: buildGradientTexture(colors) };
|
|
26
26
|
}
|
|
@@ -21,10 +21,10 @@ class FXRenderingColorOverVelocity extends FXRenderingModule {
|
|
|
21
21
|
/** @internal */
|
|
22
22
|
this.source = source;
|
|
23
23
|
if (colors.length === 0) {
|
|
24
|
-
throw new Error("
|
|
24
|
+
throw new Error("FXRenderingColorOverVelocity: colors array cannot be empty");
|
|
25
25
|
}
|
|
26
26
|
if (maxVelocity <= 0) {
|
|
27
|
-
throw new Error("
|
|
27
|
+
throw new Error("FXRenderingColorOverVelocity: maxVelocity must be greater than 0");
|
|
28
28
|
}
|
|
29
29
|
this.source = source.replace("COLOR_OVER_VELOCITY_MAX", `COLOR_OVER_VELOCITY_MAX ${maxVelocity.toFixed(2)}`);
|
|
30
30
|
this.requiredUniforms = { colorOverVelocityTexture: buildGradientTexture(colors) };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var source = "#define COLOR_OVER_VELOCITY_MAX vec4 draw(){float t=clamp(length(
|
|
1
|
+
var source = "#define COLOR_OVER_VELOCITY_MAX vec4 draw(){float t=clamp(length(vec3(PARTICLE_VELOCITY_X,PARTICLE_VELOCITY_Y,PARTICLE_VELOCITY_Z))/COLOR_OVER_VELOCITY_MAX,0.0,1.0);return srgbTexture2D(p_colorOverVelocityTexture,vec2(t,0.5));}";
|
|
2
2
|
|
|
3
3
|
export { source as default };
|
|
@@ -2,7 +2,7 @@ import type { Vector3Like } from "../miscellaneous/math";
|
|
|
2
2
|
import { type FXVector3Config } from "../miscellaneous/miscellaneous";
|
|
3
3
|
import { FXSpawnModule } from "./FXSpawnModule";
|
|
4
4
|
/**
|
|
5
|
-
* Spawns particles at random positions within
|
|
5
|
+
* Spawns particles at random positions within an axis-aligned bounding box.
|
|
6
6
|
*
|
|
7
7
|
* Position is chosen uniformly within the bounds defined by min and max.
|
|
8
8
|
*/
|
|
@@ -12,16 +12,16 @@ export declare class FXSpawnBox extends FXSpawnModule<{
|
|
|
12
12
|
private minInternal;
|
|
13
13
|
private maxInternal;
|
|
14
14
|
/**
|
|
15
|
-
* @param min -
|
|
16
|
-
* @param max -
|
|
15
|
+
* @param min - Minimum corner of the spawn box
|
|
16
|
+
* @param max - Maximum corner of the spawn box
|
|
17
17
|
*/
|
|
18
18
|
constructor(min?: FXVector3Config, max?: FXVector3Config);
|
|
19
|
-
/**
|
|
19
|
+
/** Minimum corner of the spawn box */
|
|
20
20
|
get min(): Vector3Like;
|
|
21
|
-
/**
|
|
21
|
+
/** Maximum corner of the spawn box */
|
|
22
22
|
get max(): Vector3Like;
|
|
23
|
-
/**
|
|
23
|
+
/** Minimum corner of the spawn box */
|
|
24
24
|
set min(value: FXVector3Config);
|
|
25
|
-
/**
|
|
25
|
+
/** Maximum corner of the spawn box */
|
|
26
26
|
set max(value: FXVector3Config);
|
|
27
27
|
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import { MathUtils } from 'three';
|
|
2
2
|
import { assertValidNumber } from '../miscellaneous/asserts.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../miscellaneous/miscellaneous.js';
|
|
4
4
|
import { FXSpawnModule } from './FXSpawnModule.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Spawns particles at random positions within
|
|
7
|
+
* Spawns particles at random positions within an axis-aligned bounding box.
|
|
8
8
|
*
|
|
9
9
|
* Position is chosen uniformly within the bounds defined by min and max.
|
|
10
10
|
*/
|
|
11
11
|
class FXSpawnBox extends FXSpawnModule {
|
|
12
12
|
/**
|
|
13
|
-
* @param min -
|
|
14
|
-
* @param max -
|
|
13
|
+
* @param min - Minimum corner of the spawn box
|
|
14
|
+
* @param max - Maximum corner of the spawn box
|
|
15
15
|
*/
|
|
16
16
|
constructor(min = { x: -1, y: -1, z: -1 }, max = { x: 1, y: 1, z: 1 }) {
|
|
17
17
|
super();
|
|
18
18
|
/** @internal */
|
|
19
19
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
20
|
-
this._private_minInternal =
|
|
21
|
-
this._private_maxInternal =
|
|
22
|
-
assertValidNumber(this._private_minInternal.x, "
|
|
23
|
-
assertValidNumber(this._private_minInternal.y, "
|
|
24
|
-
assertValidNumber(this._private_minInternal.z, "
|
|
25
|
-
assertValidNumber(this._private_maxInternal.x, "
|
|
26
|
-
assertValidNumber(this._private_maxInternal.y, "
|
|
27
|
-
assertValidNumber(this._private_maxInternal.z, "
|
|
20
|
+
this._private_minInternal = resolveFXVector3Config(min);
|
|
21
|
+
this._private_maxInternal = resolveFXVector3Config(max);
|
|
22
|
+
assertValidNumber(this._private_minInternal.x, "FXSpawnBox.constructor.min.x");
|
|
23
|
+
assertValidNumber(this._private_minInternal.y, "FXSpawnBox.constructor.min.y");
|
|
24
|
+
assertValidNumber(this._private_minInternal.z, "FXSpawnBox.constructor.min.z");
|
|
25
|
+
assertValidNumber(this._private_maxInternal.x, "FXSpawnBox.constructor.max.x");
|
|
26
|
+
assertValidNumber(this._private_maxInternal.y, "FXSpawnBox.constructor.max.y");
|
|
27
|
+
assertValidNumber(this._private_maxInternal.z, "FXSpawnBox.constructor.max.z");
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/** Minimum corner of the spawn box */
|
|
30
30
|
get min() {
|
|
31
31
|
return this._private_minInternal;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
33
|
+
/** Maximum corner of the spawn box */
|
|
34
34
|
get max() {
|
|
35
35
|
return this._private_maxInternal;
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
37
|
+
/** Minimum corner of the spawn box */
|
|
38
38
|
set min(value) {
|
|
39
|
-
this._private_minInternal =
|
|
40
|
-
assertValidNumber(this._private_minInternal.x, "
|
|
41
|
-
assertValidNumber(this._private_minInternal.y, "
|
|
42
|
-
assertValidNumber(this._private_minInternal.z, "
|
|
39
|
+
this._private_minInternal = resolveFXVector3Config(value);
|
|
40
|
+
assertValidNumber(this._private_minInternal.x, "FXSpawnBox.min.x");
|
|
41
|
+
assertValidNumber(this._private_minInternal.y, "FXSpawnBox.min.y");
|
|
42
|
+
assertValidNumber(this._private_minInternal.z, "FXSpawnBox.min.z");
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
44
|
+
/** Maximum corner of the spawn box */
|
|
45
45
|
set max(value) {
|
|
46
|
-
this._private_maxInternal =
|
|
47
|
-
assertValidNumber(this._private_maxInternal.x, "
|
|
48
|
-
assertValidNumber(this._private_maxInternal.y, "
|
|
49
|
-
assertValidNumber(this._private_maxInternal.z, "
|
|
46
|
+
this._private_maxInternal = resolveFXVector3Config(value);
|
|
47
|
+
assertValidNumber(this._private_maxInternal.x, "FXSpawnBox.max.x");
|
|
48
|
+
assertValidNumber(this._private_maxInternal.y, "FXSpawnBox.max.y");
|
|
49
|
+
assertValidNumber(this._private_maxInternal.z, "FXSpawnBox.max.z");
|
|
50
50
|
}
|
|
51
51
|
/** @internal */
|
|
52
52
|
spawn(properties, instanceBegin, instanceEnd) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertValidNumber } from '../miscellaneous/asserts.js';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../miscellaneous/miscellaneous.js';
|
|
3
3
|
import { FXSpawnModule } from './FXSpawnModule.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@ class FXSpawnOffset extends FXSpawnModule {
|
|
|
15
15
|
super();
|
|
16
16
|
/** @internal */
|
|
17
17
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
|
-
this._private_offsetInternal =
|
|
18
|
+
this._private_offsetInternal = resolveFXVector3Config(offset);
|
|
19
19
|
assertValidNumber(this._private_offsetInternal.x, "FXSpawnOffset.constructor.offset.x");
|
|
20
20
|
assertValidNumber(this._private_offsetInternal.y, "FXSpawnOffset.constructor.offset.y");
|
|
21
21
|
assertValidNumber(this._private_offsetInternal.z, "FXSpawnOffset.constructor.offset.z");
|
|
@@ -26,7 +26,7 @@ class FXSpawnOffset extends FXSpawnModule {
|
|
|
26
26
|
}
|
|
27
27
|
/** Particle position offset */
|
|
28
28
|
set offset(value) {
|
|
29
|
-
this._private_offsetInternal =
|
|
29
|
+
this._private_offsetInternal = resolveFXVector3Config(value);
|
|
30
30
|
assertValidNumber(this._private_offsetInternal.x, "FXSpawnOffset.offset.x");
|
|
31
31
|
assertValidNumber(this._private_offsetInternal.y, "FXSpawnOffset.offset.y");
|
|
32
32
|
assertValidNumber(this._private_offsetInternal.z, "FXSpawnOffset.offset.z");
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sparcoon",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"particles",
|
|
7
|
+
"particle-system",
|
|
7
8
|
"three.js",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
9
|
+
"3d",
|
|
10
|
+
"webgl",
|
|
11
|
+
"instanced",
|
|
12
|
+
"billboard",
|
|
10
13
|
"typescript"
|
|
11
14
|
],
|
|
12
15
|
"author": "jango",
|
|
@@ -36,8 +39,9 @@
|
|
|
36
39
|
}
|
|
37
40
|
},
|
|
38
41
|
"peerDependencies": {
|
|
39
|
-
"
|
|
40
|
-
"ferrsign": "^0.0.4"
|
|
42
|
+
"fast-simplex-noise": "^4.0.0",
|
|
43
|
+
"ferrsign": "^0.0.4",
|
|
44
|
+
"three": ">=0.157.0 <0.180.0"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
47
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -51,5 +55,8 @@
|
|
|
51
55
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
52
56
|
"ts-transformer-minify-privates": "^1.0.0",
|
|
53
57
|
"typescript": "^5.8.3"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@rollup/plugin-commonjs": "^29.0.2"
|
|
54
61
|
}
|
|
55
62
|
}
|