sparcoon 0.7.2 → 0.9.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/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/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 +46 -48
- package/dist/emitter/FXEmitter.js +355 -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 +10 -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 +1 -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/FXMeshMaterial.d.ts +40 -0
- package/dist/render/FXMeshMaterial.js +77 -0
- package/dist/world/FXWorld.d.ts +42 -0
- package/dist/world/FXWorld.js +103 -0
- package/package.json +45 -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 -17
- 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 -24
- 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,21 +0,0 @@
|
|
|
1
|
-
import { FXNodeColor } from "./FXNodeColor";
|
|
2
|
-
/**
|
|
3
|
-
* Color node that clips a particle to a circle with a configurable soft edge
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Fades alpha from fully opaque at `innerRadius` to fully transparent at the billboard edge
|
|
7
|
-
* (UV radius `0.5`). An `innerRadius` of `0.5` produces a hard circular clip with no gradient.
|
|
8
|
-
*/
|
|
9
|
-
export declare class FXNodeSphericalClip extends FXNodeColor {
|
|
10
|
-
private uniformName;
|
|
11
|
-
private innerRadiusInternal;
|
|
12
|
-
private isPrepared;
|
|
13
|
-
/**
|
|
14
|
-
* @param innerRadius - UV radius where the fade begins; must be non-negative. Defaults to `0.5`
|
|
15
|
-
*/
|
|
16
|
-
constructor(innerRadius?: number);
|
|
17
|
-
/** UV radius of the fully opaque inner area */
|
|
18
|
-
get innerRadius(): number;
|
|
19
|
-
set innerRadius(value: number);
|
|
20
|
-
prepare(index: number): void;
|
|
21
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
2
|
-
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
3
|
-
import { FXNodeColor } from './FXNodeColor.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Color node that clips a particle to a circle with a configurable soft edge
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Fades alpha from fully opaque at `innerRadius` to fully transparent at the billboard edge
|
|
10
|
-
* (UV radius `0.5`). An `innerRadius` of `0.5` produces a hard circular clip with no gradient.
|
|
11
|
-
*/
|
|
12
|
-
class FXNodeSphericalClip extends FXNodeColor {
|
|
13
|
-
/**
|
|
14
|
-
* @param innerRadius - UV radius where the fade begins; must be non-negative. Defaults to `0.5`
|
|
15
|
-
*/
|
|
16
|
-
constructor(innerRadius = 0.5) {
|
|
17
|
-
super();
|
|
18
|
-
/** @internal */
|
|
19
|
-
this.affectsDepth = true;
|
|
20
|
-
/** @internal */
|
|
21
|
-
this.cacheKey = "spherical-clip";
|
|
22
|
-
this._private_isPrepared = false;
|
|
23
|
-
assertValidNonNegativeNumber(innerRadius, "FXNodeSphericalClip.constructor.innerRadius");
|
|
24
|
-
this._private_innerRadiusInternal = innerRadius;
|
|
25
|
-
}
|
|
26
|
-
/** UV radius of the fully opaque inner area */
|
|
27
|
-
get innerRadius() {
|
|
28
|
-
return this._private_innerRadiusInternal;
|
|
29
|
-
}
|
|
30
|
-
set innerRadius(value) {
|
|
31
|
-
assertValidNonNegativeNumber(value, "FXNodeSphericalClip.innerRadius");
|
|
32
|
-
this._private_innerRadiusInternal = value;
|
|
33
|
-
if (this._private_isPrepared) {
|
|
34
|
-
this.uniforms[this._private_uniformName].value = value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
prepare(index) {
|
|
38
|
-
this._private_uniformName = `u_SphericalClipInnerRadius_${index}`;
|
|
39
|
-
this.uniformDeclarations = [`uniform float ${this._private_uniformName};`];
|
|
40
|
-
this.uniforms = {
|
|
41
|
-
[this._private_uniformName]: { value: this._private_innerRadiusInternal },
|
|
42
|
-
};
|
|
43
|
-
this.helperFunctions = `
|
|
44
|
-
vec4 fxApplySphericalClip(float innerRadius) {
|
|
45
|
-
float distanceToCenter = distance(p_uv, vec2(0.5, 0.5));
|
|
46
|
-
return vec4(1.0, 1.0, 1.0, 1.0 - smoothstep(innerRadius, 0.5, distanceToCenter));
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxApplySphericalClip(${this._private_uniformName})`;
|
|
50
|
-
this._private_isPrepared = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { FXNodeSphericalClip };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
2
|
-
import { FXNodeNormal } from './FXNodeNormal.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Normal node that outputs a constant face-aligned normal pointing toward the camera
|
|
6
|
-
*/
|
|
7
|
-
class FXNodeFlatNormal extends FXNodeNormal {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
/** @internal */
|
|
11
|
-
this.cacheKey = "flat-normal";
|
|
12
|
-
/** @internal */
|
|
13
|
-
this.normalExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * vec3(0.0, 0.0, 1.0)`;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { FXNodeFlatNormal };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
2
|
-
import { FXNodeNormal } from './FXNodeNormal.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Normal node that makes flat billboard particles appear as spheres under directional lighting
|
|
6
|
-
*/
|
|
7
|
-
class FXNodeSphericalNormal extends FXNodeNormal {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
/** @internal */
|
|
11
|
-
this.cacheKey = "spherical-normal";
|
|
12
|
-
/** @internal */
|
|
13
|
-
this.helperFunctions = `
|
|
14
|
-
vec3 fxComputeSphericalNormal(vec2 uv) {
|
|
15
|
-
vec2 centeredUV = uv * 2.0 - 1.0;
|
|
16
|
-
return normalize(vec3(centeredUV, sqrt(max(0.0, 1.0 - dot(centeredUV, centeredUV)))));
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
/** @internal */
|
|
20
|
-
this.normalExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxComputeSphericalNormal(p_uv)`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { FXNodeSphericalNormal };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { FXTextureView } from "../../miscellaneous/texture/FXTextureView";
|
|
2
|
-
import type { FXTextureConfig } from "../../miscellaneous/texture/FXTextureView.Internal";
|
|
3
|
-
import { FXNodeTexture } from "./FXNodeTexture";
|
|
4
|
-
/**
|
|
5
|
-
* Options for {@link FXNodeAnimatedTexture}
|
|
6
|
-
*/
|
|
7
|
-
export interface FXNodeAnimatedTextureOptions {
|
|
8
|
-
/** Texture or atlas configuration containing all animation frames */
|
|
9
|
-
texture: FXTextureConfig;
|
|
10
|
-
/** Number of frame columns in the sprite sheet */
|
|
11
|
-
columns: number;
|
|
12
|
-
/** Number of frame rows in the sprite sheet */
|
|
13
|
-
rows: number;
|
|
14
|
-
/**
|
|
15
|
-
* If true, blends between adjacent frames for smoother animation
|
|
16
|
-
*
|
|
17
|
-
* @defaultValue `false`
|
|
18
|
-
*/
|
|
19
|
-
interpolate?: boolean;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Texture node that animates through sprite sheet frames over a particle's lifetime
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* Frames advance from the first to the last as the particle ages. The total frame count
|
|
26
|
-
* is `columns * rows`. Both `columns` and `rows` must be positive integers.
|
|
27
|
-
*/
|
|
28
|
-
export declare class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
29
|
-
private uniformTexture;
|
|
30
|
-
private uniformUVTransform;
|
|
31
|
-
private uniformColumns;
|
|
32
|
-
private uniformRows;
|
|
33
|
-
private readonly textureInternal;
|
|
34
|
-
private readonly isInterpolate;
|
|
35
|
-
private columnsInternal;
|
|
36
|
-
private rowsInternal;
|
|
37
|
-
private isPrepared;
|
|
38
|
-
/**
|
|
39
|
-
* @param options - Sprite sheet configuration
|
|
40
|
-
*/
|
|
41
|
-
constructor({ texture, columns, rows, interpolate }: FXNodeAnimatedTextureOptions);
|
|
42
|
-
/** View describing the texture and its atlas region */
|
|
43
|
-
get texture(): FXTextureView;
|
|
44
|
-
/** Number of frame columns in the sprite sheet */
|
|
45
|
-
get columns(): number;
|
|
46
|
-
/** Number of frame rows in the sprite sheet */
|
|
47
|
-
get rows(): number;
|
|
48
|
-
set texture(config: FXTextureConfig);
|
|
49
|
-
set columns(value: number);
|
|
50
|
-
set rows(value: number);
|
|
51
|
-
prepare(index: number): void;
|
|
52
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
|
|
2
|
-
import { FXTextureView } from '../../miscellaneous/texture/FXTextureView.js';
|
|
3
|
-
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
4
|
-
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
5
|
-
import { FXNodeTexture } from './FXNodeTexture.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Texture node that animates through sprite sheet frames over a particle's lifetime
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Frames advance from the first to the last as the particle ages. The total frame count
|
|
12
|
-
* is `columns * rows`. Both `columns` and `rows` must be positive integers.
|
|
13
|
-
*/
|
|
14
|
-
class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
15
|
-
/**
|
|
16
|
-
* @param options - Sprite sheet configuration
|
|
17
|
-
*/
|
|
18
|
-
constructor({ texture, columns, rows, interpolate = false }) {
|
|
19
|
-
super();
|
|
20
|
-
/** @internal */
|
|
21
|
-
this.affectsDepth = true;
|
|
22
|
-
this._private_isPrepared = false;
|
|
23
|
-
assertValidPositiveNumber(columns, "FXNodeAnimatedTexture.constructor.columns");
|
|
24
|
-
assertValidPositiveNumber(rows, "FXNodeAnimatedTexture.constructor.rows");
|
|
25
|
-
this._private_columnsInternal = columns;
|
|
26
|
-
this._private_rowsInternal = rows;
|
|
27
|
-
this._private_textureInternal = new FXTextureView(texture);
|
|
28
|
-
this._private_isInterpolate = interpolate;
|
|
29
|
-
}
|
|
30
|
-
/** View describing the texture and its atlas region */
|
|
31
|
-
get texture() {
|
|
32
|
-
return this._private_textureInternal;
|
|
33
|
-
}
|
|
34
|
-
/** Number of frame columns in the sprite sheet */
|
|
35
|
-
get columns() {
|
|
36
|
-
return this._private_columnsInternal;
|
|
37
|
-
}
|
|
38
|
-
/** Number of frame rows in the sprite sheet */
|
|
39
|
-
get rows() {
|
|
40
|
-
return this._private_rowsInternal;
|
|
41
|
-
}
|
|
42
|
-
set texture(config) {
|
|
43
|
-
this._private_textureInternal.set(config);
|
|
44
|
-
if (this._private_isPrepared) {
|
|
45
|
-
if (this._private_textureInternal.textureDirty) {
|
|
46
|
-
this.uniforms[this._private_uniformTexture].value = this._private_textureInternal.texture;
|
|
47
|
-
this._private_textureInternal.setTextureDirtyFalse();
|
|
48
|
-
}
|
|
49
|
-
if (this._private_textureInternal.uvTransformDirty) {
|
|
50
|
-
this._private_textureInternal.calculateUVTransform(this.uniforms[this._private_uniformUVTransform].value);
|
|
51
|
-
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
set columns(value) {
|
|
56
|
-
assertValidPositiveNumber(value, "FXNodeAnimatedTexture.columns");
|
|
57
|
-
this._private_columnsInternal = value;
|
|
58
|
-
if (this._private_isPrepared) {
|
|
59
|
-
this.uniforms[this._private_uniformColumns].value = value;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
set rows(value) {
|
|
63
|
-
assertValidPositiveNumber(value, "FXNodeAnimatedTexture.rows");
|
|
64
|
-
this._private_rowsInternal = value;
|
|
65
|
-
if (this._private_isPrepared) {
|
|
66
|
-
this.uniforms[this._private_uniformRows].value = value;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
prepare(index) {
|
|
70
|
-
this._private_uniformTexture = `u_AnimatedTexture_${index}`;
|
|
71
|
-
this._private_uniformUVTransform = `u_AnimatedTextureUVTransform_${index}`;
|
|
72
|
-
this._private_uniformColumns = `u_AnimatedTextureColumns_${index}`;
|
|
73
|
-
this._private_uniformRows = `u_AnimatedTextureRows_${index}`;
|
|
74
|
-
const uvTransform = this._private_textureInternal.calculateUVTransform();
|
|
75
|
-
this._private_textureInternal.setTextureDirtyFalse();
|
|
76
|
-
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
77
|
-
const gammaCorrection = checkSRGBSupport()
|
|
78
|
-
? ""
|
|
79
|
-
: "color = vec4(pow(color.rgb, vec3(2.2)), color.a);";
|
|
80
|
-
this.cacheKey = this._private_isInterpolate ? "animated-texture-interpolated" : "animated-texture";
|
|
81
|
-
this.uniformDeclarations = [
|
|
82
|
-
`uniform sampler2D ${this._private_uniformTexture};`,
|
|
83
|
-
`uniform mat3 ${this._private_uniformUVTransform};`,
|
|
84
|
-
`uniform float ${this._private_uniformColumns};`,
|
|
85
|
-
`uniform float ${this._private_uniformRows};`,
|
|
86
|
-
];
|
|
87
|
-
this.uniforms = {
|
|
88
|
-
[this._private_uniformTexture]: { value: this._private_textureInternal.texture },
|
|
89
|
-
[this._private_uniformUVTransform]: { value: uvTransform },
|
|
90
|
-
[this._private_uniformColumns]: { value: this._private_columnsInternal },
|
|
91
|
-
[this._private_uniformRows]: { value: this._private_rowsInternal },
|
|
92
|
-
};
|
|
93
|
-
this.helperFunctions = this._private_isInterpolate ? `
|
|
94
|
-
vec2 fxFrameToUV(vec2 uv, float frame, float columns, float rows) {
|
|
95
|
-
float column = mod(frame, columns);
|
|
96
|
-
float row = floor(frame / columns);
|
|
97
|
-
return vec2((column + uv.x) / columns, 1.0 - (row + 1.0 - uv.y) / rows);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
vec4 fxSampleAnimatedTexture(sampler2D spriteSheet, mat3 uvTransform, vec2 uv, float columns, float rows) {
|
|
101
|
-
float totalFrames = columns * rows;
|
|
102
|
-
|
|
103
|
-
// Fractional frame position drives both frame selection and blend weight
|
|
104
|
-
float exactFrame = PARTICLE_AGE / PARTICLE_LIFETIME * totalFrames;
|
|
105
|
-
float currentFrame = clamp(floor(exactFrame), 0.0, totalFrames - 1.0);
|
|
106
|
-
float nextFrame = clamp(currentFrame + 1.0, 0.0, totalFrames - 1.0);
|
|
107
|
-
float blendWeight = fract(exactFrame);
|
|
108
|
-
|
|
109
|
-
vec2 currentUV = (uvTransform * vec3(fxFrameToUV(uv, currentFrame, columns, rows), 1.0)).xy;
|
|
110
|
-
vec2 nextUV = (uvTransform * vec3(fxFrameToUV(uv, nextFrame, columns, rows), 1.0)).xy;
|
|
111
|
-
|
|
112
|
-
vec4 color = mix(
|
|
113
|
-
texture2D(spriteSheet, currentUV),
|
|
114
|
-
texture2D(spriteSheet, nextUV),
|
|
115
|
-
blendWeight
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
// Apply gamma correction when sRGB textures are not natively supported
|
|
119
|
-
${gammaCorrection}
|
|
120
|
-
|
|
121
|
-
return color;
|
|
122
|
-
}
|
|
123
|
-
`
|
|
124
|
-
: `
|
|
125
|
-
vec4 fxSampleAnimatedTexture(sampler2D spriteSheet, mat3 uvTransform, vec2 uv, float columns, float rows) {
|
|
126
|
-
// Determine which frame to display based on normalized particle age
|
|
127
|
-
float totalFrames = columns * rows;
|
|
128
|
-
float frame = floor(PARTICLE_AGE / PARTICLE_LIFETIME * totalFrames);
|
|
129
|
-
frame = clamp(frame, 0.0, totalFrames - 1.0);
|
|
130
|
-
|
|
131
|
-
// Locate the frame's column and row in the sprite sheet grid
|
|
132
|
-
float column = mod(frame, columns);
|
|
133
|
-
float row = floor(frame / columns);
|
|
134
|
-
|
|
135
|
-
// Remap UV to the frame's tile region, then apply atlas transform
|
|
136
|
-
vec2 frameUV = vec2((column + uv.x) / columns, 1.0 - (row + 1.0 - uv.y) / rows);
|
|
137
|
-
vec2 atlasUV = (uvTransform * vec3(frameUV, 1.0)).xy;
|
|
138
|
-
vec4 color = texture2D(spriteSheet, atlasUV);
|
|
139
|
-
|
|
140
|
-
// Apply gamma correction when sRGB textures are not natively supported
|
|
141
|
-
${gammaCorrection}
|
|
142
|
-
|
|
143
|
-
return color;
|
|
144
|
-
}
|
|
145
|
-
`;
|
|
146
|
-
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleAnimatedTexture(${this._private_uniformTexture}, ${this._private_uniformUVTransform}, p_uv, ${this._private_uniformColumns}, ${this._private_uniformRows})`;
|
|
147
|
-
this._private_isPrepared = true;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export { FXNodeAnimatedTexture };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FXTextureView } from "../../miscellaneous/texture/FXTextureView";
|
|
2
|
-
import type { FXTextureConfig } from "../../miscellaneous/texture/FXTextureView.Internal";
|
|
3
|
-
import { FXNodeTexture } from "./FXNodeTexture";
|
|
4
|
-
/**
|
|
5
|
-
* Texture node that applies a single static texture to every particle
|
|
6
|
-
*/
|
|
7
|
-
export declare class FXNodeStaticTexture extends FXNodeTexture {
|
|
8
|
-
private uniformTexture;
|
|
9
|
-
private uniformUVTransform;
|
|
10
|
-
private readonly textureInternal;
|
|
11
|
-
private isPrepared;
|
|
12
|
-
/**
|
|
13
|
-
* @param config - Texture or atlas configuration applied to every particle
|
|
14
|
-
*/
|
|
15
|
-
constructor(config: FXTextureConfig);
|
|
16
|
-
/** View describing the texture and its atlas region */
|
|
17
|
-
get texture(): FXTextureView;
|
|
18
|
-
set texture(config: FXTextureConfig);
|
|
19
|
-
prepare(index: number): void;
|
|
20
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { FXTextureView } from '../../miscellaneous/texture/FXTextureView.js';
|
|
2
|
-
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
3
|
-
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
4
|
-
import { FXNodeTexture } from './FXNodeTexture.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Texture node that applies a single static texture to every particle
|
|
8
|
-
*/
|
|
9
|
-
class FXNodeStaticTexture extends FXNodeTexture {
|
|
10
|
-
/**
|
|
11
|
-
* @param config - Texture or atlas configuration applied to every particle
|
|
12
|
-
*/
|
|
13
|
-
constructor(config) {
|
|
14
|
-
super();
|
|
15
|
-
/** @internal */
|
|
16
|
-
this.affectsDepth = true;
|
|
17
|
-
/** @internal */
|
|
18
|
-
this.cacheKey = "static-texture";
|
|
19
|
-
this._private_isPrepared = false;
|
|
20
|
-
this._private_textureInternal = new FXTextureView(config);
|
|
21
|
-
}
|
|
22
|
-
/** View describing the texture and its atlas region */
|
|
23
|
-
get texture() {
|
|
24
|
-
return this._private_textureInternal;
|
|
25
|
-
}
|
|
26
|
-
set texture(config) {
|
|
27
|
-
this._private_textureInternal.set(config);
|
|
28
|
-
if (this._private_isPrepared) {
|
|
29
|
-
if (this._private_textureInternal.textureDirty) {
|
|
30
|
-
this.uniforms[this._private_uniformTexture].value = this._private_textureInternal.texture;
|
|
31
|
-
this._private_textureInternal.setTextureDirtyFalse();
|
|
32
|
-
}
|
|
33
|
-
if (this._private_textureInternal.uvTransformDirty) {
|
|
34
|
-
this._private_textureInternal.calculateUVTransform(this.uniforms[this._private_uniformUVTransform].value);
|
|
35
|
-
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
prepare(index) {
|
|
40
|
-
this._private_uniformTexture = `u_StaticTexture_${index}`;
|
|
41
|
-
this._private_uniformUVTransform = `u_StaticTextureUVTransform_${index}`;
|
|
42
|
-
const uvTransform = this._private_textureInternal.calculateUVTransform();
|
|
43
|
-
this._private_textureInternal.setTextureDirtyFalse();
|
|
44
|
-
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
45
|
-
this.uniformDeclarations = [
|
|
46
|
-
`uniform sampler2D ${this._private_uniformTexture};`,
|
|
47
|
-
`uniform mat3 ${this._private_uniformUVTransform};`,
|
|
48
|
-
];
|
|
49
|
-
this.uniforms = {
|
|
50
|
-
[this._private_uniformTexture]: { value: this._private_textureInternal.texture },
|
|
51
|
-
[this._private_uniformUVTransform]: { value: uvTransform },
|
|
52
|
-
};
|
|
53
|
-
this.helperFunctions = `
|
|
54
|
-
vec4 fxSampleStaticTexture(sampler2D colorTexture, mat3 uvTransform, vec2 uv) {
|
|
55
|
-
vec2 transformedUV = (uvTransform * vec3(uv, 1.0)).xy;
|
|
56
|
-
vec4 color = texture2D(colorTexture, transformedUV);
|
|
57
|
-
// Apply gamma correction when sRGB textures are not natively supported
|
|
58
|
-
${checkSRGBSupport() ? "" : "color = vec4(pow(color.rgb, vec3(2.2)), color.a);"}
|
|
59
|
-
return color;
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
62
|
-
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleStaticTexture(${this._private_uniformTexture}, ${this._private_uniformUVTransform}, p_uv)`;
|
|
63
|
-
this._private_isPrepared = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { FXNodeStaticTexture };
|