sparcoon 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/emitter/FXEmitter.d.ts +4 -0
- package/dist/emitter/FXEmitter.js +8 -0
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.d.ts +0 -2
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.js +0 -2
- package/dist/emitter/behavior/FXBehaviorPointForce.d.ts +0 -4
- package/dist/emitter/behavior/FXBehaviorPointForce.js +0 -4
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.d.ts +4 -3
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.js +9 -3
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.d.ts +0 -1
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.js +0 -1
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.d.ts +0 -2
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.js +0 -2
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.d.ts +4 -2
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.js +9 -2
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.d.ts +0 -1
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.js +0 -1
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.d.ts +0 -2
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.js +0 -2
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.d.ts +4 -2
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.js +9 -2
- package/dist/emitter/spawn/FXSpawnBox.d.ts +0 -1
- package/dist/emitter/spawn/FXSpawnBox.js +0 -1
- package/dist/emitter/spawn/FXSpawnLifetime.d.ts +0 -1
- package/dist/emitter/spawn/FXSpawnLifetime.js +0 -1
- package/dist/emitter/spawn/FXSpawnOffset.d.ts +0 -1
- package/dist/emitter/spawn/FXSpawnOffset.js +0 -1
- package/dist/emitter/spawn/FXSpawnPoint.d.ts +0 -1
- package/dist/emitter/spawn/FXSpawnPoint.js +0 -1
- package/dist/emitter/spawn/FXSpawnRotation.d.ts +0 -1
- package/dist/emitter/spawn/FXSpawnRotation.js +0 -1
- package/dist/emitter/spawn/FXSpawnScale.d.ts +0 -2
- package/dist/emitter/spawn/FXSpawnScale.js +0 -2
- package/dist/emitter/spawn/FXSpawnSphere.d.ts +3 -10
- package/dist/emitter/spawn/FXSpawnSphere.js +8 -15
- package/dist/emitter/spawn/FXSpawnTorque.d.ts +0 -1
- package/dist/emitter/spawn/FXSpawnTorque.js +0 -1
- package/dist/emitter/spawn/FXSpawnVelocity.d.ts +3 -6
- package/dist/emitter/spawn/FXSpawnVelocity.js +6 -9
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/instancedParticle/FXInstancedParticle.d.ts +1 -0
- package/dist/instancedParticle/FXInstancedParticle.js +4 -1
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.d.ts +4 -3
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.js +49 -63
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.js +1 -1
- package/dist/materials/FXMaterial/FXBlending.Internal.d.ts +24 -0
- package/dist/materials/FXMaterial/FXBlending.Internal.js +64 -0
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.js +10 -4
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.js +9 -4
- package/dist/materials/FXMaterial/FXMaterial.d.ts +18 -15
- package/dist/materials/FXMaterial/FXMaterial.js +22 -7
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.d.ts +3 -2
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.js +18 -14
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.js +1 -1
- package/dist/nodes/FXNode.d.ts +5 -0
- package/dist/nodes/FXNode.js +10 -0
- package/dist/nodes/blending/FXNodeBlending.d.ts +6 -0
- package/dist/nodes/blending/FXNodeBlending.js +9 -0
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.d.ts +16 -0
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.js +49 -0
- package/dist/nodes/color/FXNodeColor.d.ts +2 -3
- package/dist/nodes/color/FXNodeColor.js +3 -5
- package/dist/nodes/color/FXNodeColorOverLife.d.ts +0 -5
- package/dist/nodes/color/FXNodeColorOverLife.js +6 -8
- package/dist/nodes/color/FXNodeSphericalClip.js +6 -3
- package/dist/nodes/normal/FXNodeFlatNormal.d.ts +0 -1
- package/dist/nodes/normal/FXNodeFlatNormal.js +5 -5
- package/dist/nodes/normal/FXNodeNormal.d.ts +2 -3
- package/dist/nodes/normal/FXNodeNormal.js +3 -1
- package/dist/nodes/normal/FXNodeSphericalNormal.d.ts +0 -1
- package/dist/nodes/normal/FXNodeSphericalNormal.js +11 -9
- package/dist/nodes/texture/FXNodeAnimatedTexture.d.ts +3 -3
- package/dist/nodes/texture/FXNodeAnimatedTexture.js +19 -17
- package/dist/nodes/texture/FXNodeStaticTexture.d.ts +3 -3
- package/dist/nodes/texture/FXNodeStaticTexture.js +21 -18
- package/dist/nodes/texture/FXNodeTexture.d.ts +2 -3
- package/dist/nodes/texture/FXNodeTexture.js +3 -5
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FXNodeBlending } from "./FXNodeBlending";
|
|
2
|
+
export declare class FXNodeLightnessBlendingMask extends FXNodeBlending {
|
|
3
|
+
private readonly uniformEdge0;
|
|
4
|
+
private readonly uniformEdge1;
|
|
5
|
+
/**
|
|
6
|
+
* @param edge0 - brightness threshold where mask starts (below this: NormalBlending). Defaults to `0.3`
|
|
7
|
+
* @param edge1 - brightness threshold where mask is fully active (above this: full FXBlending effect). Defaults to `0.7`
|
|
8
|
+
*/
|
|
9
|
+
constructor(edge0?: number, edge1?: number);
|
|
10
|
+
/** Brightness threshold where mask starts (below this: NormalBlending) */
|
|
11
|
+
get edge0(): number;
|
|
12
|
+
/** Brightness threshold where mask is fully active (above this: full FXBlending effect) */
|
|
13
|
+
get edge1(): number;
|
|
14
|
+
set edge0(value: number);
|
|
15
|
+
set edge1(value: number);
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
2
|
+
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER, BLENDING_EXPRESSION_CURRENT_COLOR_PLACEHOLDER } from '../FXNode.js';
|
|
3
|
+
import { FXNodeBlending } from './FXNodeBlending.js';
|
|
4
|
+
|
|
5
|
+
class FXNodeLightnessBlendingMask extends FXNodeBlending {
|
|
6
|
+
/**
|
|
7
|
+
* @param edge0 - brightness threshold where mask starts (below this: NormalBlending). Defaults to `0.3`
|
|
8
|
+
* @param edge1 - brightness threshold where mask is fully active (above this: full FXBlending effect). Defaults to `0.7`
|
|
9
|
+
*/
|
|
10
|
+
constructor(edge0 = 0.3, edge1 = 0.7) {
|
|
11
|
+
super();
|
|
12
|
+
/** @internal */
|
|
13
|
+
this.cacheKey = "lightness-blending-mask";
|
|
14
|
+
const id = getNextInstanceId();
|
|
15
|
+
this._private_uniformEdge0 = `u_LightnessBlendingMaskEdge0_${id}`;
|
|
16
|
+
this._private_uniformEdge1 = `u_LightnessBlendingMaskEdge1_${id}`;
|
|
17
|
+
this.uniformDeclarations = [
|
|
18
|
+
`uniform float ${this._private_uniformEdge0};`,
|
|
19
|
+
`uniform float ${this._private_uniformEdge1};`,
|
|
20
|
+
];
|
|
21
|
+
this.uniforms = {
|
|
22
|
+
[this._private_uniformEdge0]: { value: edge0 },
|
|
23
|
+
[this._private_uniformEdge1]: { value: edge1 },
|
|
24
|
+
};
|
|
25
|
+
this.helperFunctions = `
|
|
26
|
+
float fxLightnessBlendingMask(vec4 color, float edge0, float edge1) {
|
|
27
|
+
float brightness = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
28
|
+
return smoothstep(edge0, edge1, brightness);
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
this.blendingExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxLightnessBlendingMask(${BLENDING_EXPRESSION_CURRENT_COLOR_PLACEHOLDER}, ${this._private_uniformEdge0}, ${this._private_uniformEdge1})`;
|
|
32
|
+
}
|
|
33
|
+
/** Brightness threshold where mask starts (below this: NormalBlending) */
|
|
34
|
+
get edge0() {
|
|
35
|
+
return this.uniforms[this._private_uniformEdge0].value;
|
|
36
|
+
}
|
|
37
|
+
/** Brightness threshold where mask is fully active (above this: full FXBlending effect) */
|
|
38
|
+
get edge1() {
|
|
39
|
+
return this.uniforms[this._private_uniformEdge1].value;
|
|
40
|
+
}
|
|
41
|
+
set edge0(value) {
|
|
42
|
+
this.uniforms[this._private_uniformEdge0].value = value;
|
|
43
|
+
}
|
|
44
|
+
set edge1(value) {
|
|
45
|
+
this.uniforms[this._private_uniformEdge1].value = value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { FXNodeLightnessBlendingMask };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { FXNode } from "../FXNode";
|
|
1
2
|
/**
|
|
2
3
|
* Abstract base class for particle color nodes
|
|
3
4
|
*/
|
|
4
|
-
export declare abstract class FXNodeColor {
|
|
5
|
-
/** Releases any GPU resources held by this node */
|
|
6
|
-
destroy?(): void;
|
|
5
|
+
export declare abstract class FXNodeColor extends FXNode {
|
|
7
6
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { FXNode } from '../FXNode.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Abstract base class for particle color nodes
|
|
3
5
|
*/
|
|
4
|
-
class FXNodeColor {
|
|
5
|
-
constructor() {
|
|
6
|
-
/** @internal */
|
|
7
|
-
this.affectsDepth = false;
|
|
8
|
-
}
|
|
6
|
+
class FXNodeColor extends FXNode {
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
export { FXNodeColor };
|
|
@@ -14,11 +14,6 @@ export declare class FXNodeColorOverLife extends FXNodeColor {
|
|
|
14
14
|
constructor(curve: FXCurve1DConfig<FXColor>);
|
|
15
15
|
/** Current color gradient curve */
|
|
16
16
|
get curve(): FXCurve1D<FXColor>;
|
|
17
|
-
/**
|
|
18
|
-
* Replaces the color gradient curve and rebuilds the backing texture
|
|
19
|
-
*
|
|
20
|
-
* @param value - New color gradient configuration
|
|
21
|
-
*/
|
|
22
17
|
set curve(value: FXCurve1DConfig<FXColor>);
|
|
23
18
|
/** Releases the backing gradient texture */
|
|
24
19
|
destroy(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FXCurve1D } from '../../miscellaneous/curve/FXCurve1D.js';
|
|
2
2
|
import { buildGradientTexture, getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
3
3
|
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
4
|
+
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
4
5
|
import { FXNodeColor } from './FXNodeColor.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -12,12 +13,14 @@ class FXNodeColorOverLife extends FXNodeColor {
|
|
|
12
13
|
*/
|
|
13
14
|
constructor(curve) {
|
|
14
15
|
super();
|
|
16
|
+
/** @internal */
|
|
17
|
+
this.affectsDepth = true;
|
|
18
|
+
/** @internal */
|
|
19
|
+
this.cacheKey = "color-over-life";
|
|
15
20
|
const id = getNextInstanceId();
|
|
16
21
|
this._private_uniformName = `u_ColorOverLife_${id}`;
|
|
17
22
|
this._private_curveInternal = new FXCurve1D(curve);
|
|
18
23
|
this._private_gradientTexture = buildGradientTexture(this._private_curveInternal);
|
|
19
|
-
this.affectsDepth = true;
|
|
20
|
-
this.cacheKey = "color-over-life";
|
|
21
24
|
this.uniformDeclarations = [`uniform sampler2D ${this._private_uniformName};`];
|
|
22
25
|
this.uniforms = {
|
|
23
26
|
[this._private_uniformName]: { value: this._private_gradientTexture },
|
|
@@ -34,17 +37,12 @@ class FXNodeColorOverLife extends FXNodeColor {
|
|
|
34
37
|
return color;
|
|
35
38
|
}
|
|
36
39
|
`;
|
|
37
|
-
this.colorExpression =
|
|
40
|
+
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleColorOverLife(${this._private_uniformName})`;
|
|
38
41
|
}
|
|
39
42
|
/** Current color gradient curve */
|
|
40
43
|
get curve() {
|
|
41
44
|
return this._private_curveInternal;
|
|
42
45
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Replaces the color gradient curve and rebuilds the backing texture
|
|
45
|
-
*
|
|
46
|
-
* @param value - New color gradient configuration
|
|
47
|
-
*/
|
|
48
46
|
set curve(value) {
|
|
49
47
|
this._private_curveInternal = new FXCurve1D(value);
|
|
50
48
|
this._private_gradientTexture.dispose();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
2
2
|
import { getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
3
|
+
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
3
4
|
import { FXNodeColor } from './FXNodeColor.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -15,11 +16,13 @@ class FXNodeSphericalClip extends FXNodeColor {
|
|
|
15
16
|
*/
|
|
16
17
|
constructor(innerRadius = 0.5) {
|
|
17
18
|
super();
|
|
19
|
+
/** @internal */
|
|
20
|
+
this.affectsDepth = true;
|
|
21
|
+
/** @internal */
|
|
22
|
+
this.cacheKey = "spherical-clip";
|
|
18
23
|
assertValidNonNegativeNumber(innerRadius, "FXNodeSphericalClip.constructor.innerRadius");
|
|
19
24
|
const id = getNextInstanceId();
|
|
20
25
|
this._private_uniformInnerRadius = `u_SphericalClipInnerRadius_${id}`;
|
|
21
|
-
this.affectsDepth = true;
|
|
22
|
-
this.cacheKey = "spherical-clip";
|
|
23
26
|
this.uniformDeclarations = [`uniform float ${this._private_uniformInnerRadius};`];
|
|
24
27
|
this.uniforms = {
|
|
25
28
|
[this._private_uniformInnerRadius]: { value: innerRadius },
|
|
@@ -30,7 +33,7 @@ class FXNodeSphericalClip extends FXNodeColor {
|
|
|
30
33
|
return vec4(1.0, 1.0, 1.0, 1.0 - smoothstep(innerRadius, 0.5, distanceToCenter));
|
|
31
34
|
}
|
|
32
35
|
`;
|
|
33
|
-
this.colorExpression =
|
|
36
|
+
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxApplySphericalClip(${this._private_uniformInnerRadius})`;
|
|
34
37
|
}
|
|
35
38
|
/** UV radius of the fully opaque inner area */
|
|
36
39
|
get innerRadius() {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
1
2
|
import { FXNodeNormal } from './FXNodeNormal.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -5,12 +6,11 @@ import { FXNodeNormal } from './FXNodeNormal.js';
|
|
|
5
6
|
*/
|
|
6
7
|
class FXNodeFlatNormal extends FXNodeNormal {
|
|
7
8
|
constructor() {
|
|
8
|
-
super();
|
|
9
|
+
super(...arguments);
|
|
10
|
+
/** @internal */
|
|
9
11
|
this.cacheKey = "flat-normal";
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
this.helperFunctions = "";
|
|
13
|
-
this.normalExpression = "vec3(0.0, 0.0, 1.0)";
|
|
12
|
+
/** @internal */
|
|
13
|
+
this.normalExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * vec3(0.0, 0.0, 1.0)`;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { FXNode } from "../FXNode";
|
|
1
2
|
/**
|
|
2
3
|
* Abstract base class for particle normal nodes
|
|
3
4
|
*/
|
|
4
|
-
export declare abstract class FXNodeNormal {
|
|
5
|
-
/** Releases any GPU resources held by this node */
|
|
6
|
-
destroy?(): void;
|
|
5
|
+
export declare abstract class FXNodeNormal extends FXNode {
|
|
7
6
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
1
2
|
import { FXNodeNormal } from './FXNodeNormal.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -5,17 +6,18 @@ import { FXNodeNormal } from './FXNodeNormal.js';
|
|
|
5
6
|
*/
|
|
6
7
|
class FXNodeSphericalNormal extends FXNodeNormal {
|
|
7
8
|
constructor() {
|
|
8
|
-
super();
|
|
9
|
+
super(...arguments);
|
|
10
|
+
/** @internal */
|
|
9
11
|
this.cacheKey = "spherical-normal";
|
|
10
|
-
|
|
11
|
-
this.uniforms = {};
|
|
12
|
+
/** @internal */
|
|
12
13
|
this.helperFunctions = `
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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)`;
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -30,18 +30,18 @@ export declare class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
30
30
|
private readonly uniformUVTransform;
|
|
31
31
|
private readonly uniformColumns;
|
|
32
32
|
private readonly uniformRows;
|
|
33
|
-
private readonly
|
|
33
|
+
private readonly textureInternal;
|
|
34
34
|
/**
|
|
35
35
|
* @param options - Sprite sheet configuration
|
|
36
36
|
*/
|
|
37
37
|
constructor({ texture, columns, rows, interpolate }: FXNodeAnimatedTextureOptions);
|
|
38
38
|
/** View describing the texture and its atlas region */
|
|
39
|
-
get
|
|
39
|
+
get texture(): FXTextureView;
|
|
40
40
|
/** Number of frame columns in the sprite sheet */
|
|
41
41
|
get columns(): number;
|
|
42
42
|
/** Number of frame rows in the sprite sheet */
|
|
43
43
|
get rows(): number;
|
|
44
|
-
set
|
|
44
|
+
set texture(config: FXTextureConfig);
|
|
45
45
|
set columns(value: number);
|
|
46
46
|
set rows(value: number);
|
|
47
47
|
}
|
|
@@ -2,6 +2,7 @@ import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
|
|
|
2
2
|
import { getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
3
3
|
import { FXTextureView } from '../../miscellaneous/texture/FXTextureView.js';
|
|
4
4
|
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
5
|
+
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
5
6
|
import { FXNodeTexture } from './FXNodeTexture.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -17,6 +18,8 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
17
18
|
*/
|
|
18
19
|
constructor({ texture, columns, rows, interpolate = false }) {
|
|
19
20
|
super();
|
|
21
|
+
/** @internal */
|
|
22
|
+
this.affectsDepth = true;
|
|
20
23
|
assertValidPositiveNumber(columns, "FXNodeAnimatedTexture.constructor.columns");
|
|
21
24
|
assertValidPositiveNumber(rows, "FXNodeAnimatedTexture.constructor.rows");
|
|
22
25
|
const idx = getNextInstanceId();
|
|
@@ -24,14 +27,13 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
24
27
|
this._private_uniformUVTransform = `u_AnimatedTextureUVTransform_${idx}`;
|
|
25
28
|
this._private_uniformColumns = `u_AnimatedTextureColumns_${idx}`;
|
|
26
29
|
this._private_uniformRows = `u_AnimatedTextureRows_${idx}`;
|
|
27
|
-
this.
|
|
28
|
-
const uvTransform = this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
30
|
+
this._private_textureInternal = new FXTextureView(texture);
|
|
31
|
+
const uvTransform = this._private_textureInternal.calculateUVTransform();
|
|
32
|
+
this._private_textureInternal.setTextureDirtyFalse();
|
|
33
|
+
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
31
34
|
const gammaCorrection = checkSRGBSupport()
|
|
32
35
|
? ""
|
|
33
36
|
: "color = vec4(pow(color.rgb, vec3(2.2)), color.a);";
|
|
34
|
-
this.affectsDepth = true;
|
|
35
37
|
this.cacheKey = interpolate ? "animated-texture-interpolated" : "animated-texture";
|
|
36
38
|
this.uniformDeclarations = [
|
|
37
39
|
`uniform sampler2D ${this._private_uniformTexture};`,
|
|
@@ -40,7 +42,7 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
40
42
|
`uniform float ${this._private_uniformRows};`,
|
|
41
43
|
];
|
|
42
44
|
this.uniforms = {
|
|
43
|
-
[this._private_uniformTexture]: { value: this.
|
|
45
|
+
[this._private_uniformTexture]: { value: this._private_textureInternal.texture },
|
|
44
46
|
[this._private_uniformUVTransform]: { value: uvTransform },
|
|
45
47
|
[this._private_uniformColumns]: { value: columns },
|
|
46
48
|
[this._private_uniformRows]: { value: rows },
|
|
@@ -99,11 +101,11 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
99
101
|
return color;
|
|
100
102
|
}
|
|
101
103
|
`;
|
|
102
|
-
this.colorExpression =
|
|
104
|
+
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleAnimatedTexture(${this._private_uniformTexture}, ${this._private_uniformUVTransform}, p_uv, ${this._private_uniformColumns}, ${this._private_uniformRows})`;
|
|
103
105
|
}
|
|
104
106
|
/** View describing the texture and its atlas region */
|
|
105
|
-
get
|
|
106
|
-
return this.
|
|
107
|
+
get texture() {
|
|
108
|
+
return this._private_textureInternal;
|
|
107
109
|
}
|
|
108
110
|
/** Number of frame columns in the sprite sheet */
|
|
109
111
|
get columns() {
|
|
@@ -113,15 +115,15 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
113
115
|
get rows() {
|
|
114
116
|
return this.uniforms[this._private_uniformRows].value;
|
|
115
117
|
}
|
|
116
|
-
set
|
|
117
|
-
this.
|
|
118
|
-
if (this.
|
|
119
|
-
this.uniforms[this._private_uniformTexture].value = this.
|
|
120
|
-
this.
|
|
118
|
+
set texture(config) {
|
|
119
|
+
this._private_textureInternal.set(config);
|
|
120
|
+
if (this._private_textureInternal.textureDirty) {
|
|
121
|
+
this.uniforms[this._private_uniformTexture].value = this._private_textureInternal.texture;
|
|
122
|
+
this._private_textureInternal.setTextureDirtyFalse();
|
|
121
123
|
}
|
|
122
|
-
if (this.
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
124
|
+
if (this._private_textureInternal.uvTransformDirty) {
|
|
125
|
+
this._private_textureInternal.calculateUVTransform(this.uniforms[this._private_uniformUVTransform].value);
|
|
126
|
+
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
set columns(value) {
|
|
@@ -7,12 +7,12 @@ import { FXNodeTexture } from "./FXNodeTexture";
|
|
|
7
7
|
export declare class FXNodeStaticTexture extends FXNodeTexture {
|
|
8
8
|
private readonly uniformTexture;
|
|
9
9
|
private readonly uniformUVTransform;
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly textureInternal;
|
|
11
11
|
/**
|
|
12
12
|
* @param config - Texture or atlas configuration applied to every particle
|
|
13
13
|
*/
|
|
14
14
|
constructor(config: FXTextureConfig);
|
|
15
15
|
/** View describing the texture and its atlas region */
|
|
16
|
-
get
|
|
17
|
-
set
|
|
16
|
+
get texture(): FXTextureView;
|
|
17
|
+
set texture(config: FXTextureConfig);
|
|
18
18
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
2
2
|
import { FXTextureView } from '../../miscellaneous/texture/FXTextureView.js';
|
|
3
3
|
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
4
|
+
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
4
5
|
import { FXNodeTexture } from './FXNodeTexture.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -12,21 +13,23 @@ class FXNodeStaticTexture extends FXNodeTexture {
|
|
|
12
13
|
*/
|
|
13
14
|
constructor(config) {
|
|
14
15
|
super();
|
|
16
|
+
/** @internal */
|
|
17
|
+
this.affectsDepth = true;
|
|
18
|
+
/** @internal */
|
|
19
|
+
this.cacheKey = "static-texture";
|
|
15
20
|
const id = getNextInstanceId();
|
|
16
21
|
this._private_uniformTexture = `u_StaticTexture_${id}`;
|
|
17
22
|
this._private_uniformUVTransform = `u_StaticTextureUVTransform_${id}`;
|
|
18
|
-
this.
|
|
19
|
-
const uvTransform = this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.affectsDepth = true;
|
|
23
|
-
this.cacheKey = "static-texture";
|
|
23
|
+
this._private_textureInternal = new FXTextureView(config);
|
|
24
|
+
const uvTransform = this._private_textureInternal.calculateUVTransform();
|
|
25
|
+
this._private_textureInternal.setTextureDirtyFalse();
|
|
26
|
+
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
24
27
|
this.uniformDeclarations = [
|
|
25
28
|
`uniform sampler2D ${this._private_uniformTexture};`,
|
|
26
29
|
`uniform mat3 ${this._private_uniformUVTransform};`,
|
|
27
30
|
];
|
|
28
31
|
this.uniforms = {
|
|
29
|
-
[this._private_uniformTexture]: { value: this.
|
|
32
|
+
[this._private_uniformTexture]: { value: this._private_textureInternal.texture },
|
|
30
33
|
[this._private_uniformUVTransform]: { value: uvTransform },
|
|
31
34
|
};
|
|
32
35
|
this.helperFunctions = `
|
|
@@ -38,21 +41,21 @@ class FXNodeStaticTexture extends FXNodeTexture {
|
|
|
38
41
|
return color;
|
|
39
42
|
}
|
|
40
43
|
`;
|
|
41
|
-
this.colorExpression =
|
|
44
|
+
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleStaticTexture(${this._private_uniformTexture}, ${this._private_uniformUVTransform}, p_uv)`;
|
|
42
45
|
}
|
|
43
46
|
/** View describing the texture and its atlas region */
|
|
44
|
-
get
|
|
45
|
-
return this.
|
|
47
|
+
get texture() {
|
|
48
|
+
return this._private_textureInternal;
|
|
46
49
|
}
|
|
47
|
-
set
|
|
48
|
-
this.
|
|
49
|
-
if (this.
|
|
50
|
-
this.uniforms[this._private_uniformTexture].value = this.
|
|
51
|
-
this.
|
|
50
|
+
set texture(config) {
|
|
51
|
+
this._private_textureInternal.set(config);
|
|
52
|
+
if (this._private_textureInternal.textureDirty) {
|
|
53
|
+
this.uniforms[this._private_uniformTexture].value = this._private_textureInternal.texture;
|
|
54
|
+
this._private_textureInternal.setTextureDirtyFalse();
|
|
52
55
|
}
|
|
53
|
-
if (this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
+
if (this._private_textureInternal.uvTransformDirty) {
|
|
57
|
+
this._private_textureInternal.calculateUVTransform(this.uniforms[this._private_uniformUVTransform].value);
|
|
58
|
+
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { FXNode } from "../FXNode";
|
|
1
2
|
/**
|
|
2
3
|
* Abstract base class for particle texture nodes
|
|
3
4
|
*/
|
|
4
|
-
export declare abstract class FXNodeTexture {
|
|
5
|
-
/** Releases any GPU resources held by this node */
|
|
6
|
-
destroy?(): void;
|
|
5
|
+
export declare abstract class FXNodeTexture extends FXNode {
|
|
7
6
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { FXNode } from '../FXNode.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Abstract base class for particle texture nodes
|
|
3
5
|
*/
|
|
4
|
-
class FXNodeTexture {
|
|
5
|
-
constructor() {
|
|
6
|
-
/** @internal */
|
|
7
|
-
this.affectsDepth = false;
|
|
8
|
-
}
|
|
6
|
+
class FXNodeTexture extends FXNode {
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
export { FXNodeTexture };
|