sparcoon 0.7.1 → 0.7.3
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.js +1 -0
- package/dist/instancedParticle/FXInstancedParticle.js +8 -3
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.d.ts +1 -1
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.js +12 -12
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.d.ts +1 -0
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.js +15 -0
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.js +1 -2
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.js +1 -2
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.d.ts +1 -1
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.js +6 -4
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.d.ts +1 -0
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.js +7 -0
- package/dist/miscellaneous/miscellaneous.d.ts +0 -1
- package/dist/miscellaneous/miscellaneous.js +1 -5
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.d.ts +5 -2
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.js +39 -23
- package/dist/nodes/color/FXNodeColorOverLife.d.ts +3 -1
- package/dist/nodes/color/FXNodeColorOverLife.js +23 -17
- package/dist/nodes/color/FXNodeSphericalClip.d.ts +4 -1
- package/dist/nodes/color/FXNodeSphericalClip.js +20 -14
- package/dist/nodes/normal/FXNodeFlatNormal.js +1 -2
- package/dist/nodes/normal/FXNodeSphericalNormal.js +1 -2
- package/dist/nodes/texture/FXNodeAnimatedTexture.d.ts +9 -4
- package/dist/nodes/texture/FXNodeAnimatedTexture.js +54 -42
- package/dist/nodes/texture/FXNodeStaticTexture.d.ts +4 -2
- package/dist/nodes/texture/FXNodeStaticTexture.js +23 -19
- package/package.json +1 -1
- package/dist/instancedParticle/FXInstancedParticle.Internal.js +0 -14
|
@@ -53,6 +53,7 @@ class FXEmitter extends Object3D {
|
|
|
53
53
|
};
|
|
54
54
|
collectProperties(collectedProperties, _private_spawnSequence, "FXEmitter.constructor.spawnSequence");
|
|
55
55
|
collectProperties(collectedProperties, _private_behaviorSequence, "FXEmitter.constructor.behaviorSequence");
|
|
56
|
+
material.prepare();
|
|
56
57
|
const threeMaterial = material.buildThreeMaterial(collectedProperties);
|
|
57
58
|
this._private_mesh = new FXInstancedParticle(collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP, threeMaterial);
|
|
58
59
|
if (options.castShadow ?? EMITTER_DEFAULT_CAST_SHADOW) {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { Mesh, InstancedBufferAttribute, StreamDrawUsage } from 'three';
|
|
1
|
+
import { Mesh, InstancedBufferGeometry, BufferAttribute, Float32BufferAttribute, InstancedBufferAttribute, StreamDrawUsage } from 'three';
|
|
2
2
|
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../miscellaneous/miscellaneous.js';
|
|
3
|
-
import { INSTANCED_PARTICLE_GEOMETRY } from './FXInstancedParticle.Internal.js';
|
|
4
3
|
|
|
5
4
|
class FXInstancedParticle extends Mesh {
|
|
6
5
|
constructor(varyings, expectedCapacity, _private_capacityStep, material) {
|
|
7
|
-
const instancedGeometry =
|
|
6
|
+
const instancedGeometry = new InstancedBufferGeometry();
|
|
7
|
+
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
|
|
8
|
+
instancedGeometry.setIndex(new BufferAttribute(indices, 1));
|
|
9
|
+
const positions = new Float32Array([-0.5, 0.5, 0, 0.5, 0.5, 0, -0.5, -0.5, 0, 0.5, -0.5, 0]);
|
|
10
|
+
instancedGeometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
|
|
11
|
+
const uvs = new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]);
|
|
12
|
+
instancedGeometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
|
|
8
13
|
super(instancedGeometry, material);
|
|
9
14
|
this._private_capacityStep = _private_capacityStep;
|
|
10
15
|
this.propertyBuffers = {};
|
|
@@ -4,7 +4,7 @@ import type { FXNodeBlending } from "../../nodes/blending/FXNodeBlending";
|
|
|
4
4
|
import { FXNodeColor } from "../../nodes/color/FXNodeColor";
|
|
5
5
|
import type { FXNodeNormal } from "../../nodes/normal/FXNodeNormal";
|
|
6
6
|
import { FXNodeTexture } from "../../nodes/texture/FXNodeTexture";
|
|
7
|
-
import
|
|
7
|
+
import { FXBlending } from "../FXMaterial/FXMaterial";
|
|
8
8
|
export interface FXScatterUniforms {
|
|
9
9
|
u_ScatterTint: {
|
|
10
10
|
value: Color;
|
|
@@ -4,6 +4,7 @@ import { FXNodeColor } from '../../nodes/color/FXNodeColor.js';
|
|
|
4
4
|
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../../nodes/FXNode.js';
|
|
5
5
|
import { FXNodeTexture } from '../../nodes/texture/FXNodeTexture.js';
|
|
6
6
|
import { buildAlbedoAndBlendingCode } from '../FXMaterial/FXBlending.Internal.js';
|
|
7
|
+
import { FXBlending } from '../FXMaterial/FXMaterial.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Wraps every `getShadow(...)` call in the shader source with
|
|
@@ -257,18 +258,17 @@ function buildFXDiffuseMaterial(varyings, blending, useAlphaHashing, alphaTest,
|
|
|
257
258
|
fragmentShader = fragmentShader.replace("#include <premultiplied_alpha_fragment>", albedoCode.premultChunk);
|
|
258
259
|
shader.fragmentShader = fragmentPreamble + "\n" + fragmentShader;
|
|
259
260
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
// ].join("_");
|
|
261
|
+
const scatterKey = useScatter ? `scatter(${scatterUniforms.u_ScatterPower.value})` : "no-scatter";
|
|
262
|
+
const shadowKey = useShadowSensitivity ? "shadow-sens" : "no-shadow-sens";
|
|
263
|
+
material.customProgramCacheKey = () => [
|
|
264
|
+
"fx",
|
|
265
|
+
albedoNodes.map((node) => node.cacheKey).join("-") || "none",
|
|
266
|
+
normalNodes.map((node) => node.cacheKey).join("-") || "none",
|
|
267
|
+
emissionNodes.map((node) => node.cacheKey).join("-") || "none",
|
|
268
|
+
FXBlending[blending],
|
|
269
|
+
scatterKey,
|
|
270
|
+
shadowKey,
|
|
271
|
+
].join("_");
|
|
272
272
|
return material;
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -43,6 +43,21 @@ class FXDiffuseMaterial extends FXMaterial {
|
|
|
43
43
|
buildThreeMaterial(varyings) {
|
|
44
44
|
return buildFXDiffuseMaterial(varyings, this.blending, this.useAlphaHashing, this.alphaTest, this.albedoNodes, this._private_normalNodes, this._private_emissionNodes, this._private_scatterUniforms, this._private_shadowSensitivity);
|
|
45
45
|
}
|
|
46
|
+
prepare() {
|
|
47
|
+
let i = 0;
|
|
48
|
+
for (const node of this.albedoNodes) {
|
|
49
|
+
node.prepare?.(i);
|
|
50
|
+
i += 1;
|
|
51
|
+
}
|
|
52
|
+
for (const node of this._private_normalNodes) {
|
|
53
|
+
node.prepare?.(i);
|
|
54
|
+
i += 1;
|
|
55
|
+
}
|
|
56
|
+
for (const node of this._private_emissionNodes) {
|
|
57
|
+
node.prepare?.(i);
|
|
58
|
+
i += 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
export { FXDiffuseMaterial };
|
|
@@ -137,8 +137,7 @@ function buildDepthMaterial(albedoNodes, depthAlphaTest, useDepthAlphaHash, useS
|
|
|
137
137
|
}
|
|
138
138
|
shader.fragmentShader = fragmentPreamble + "\n" + fragmentShader;
|
|
139
139
|
};
|
|
140
|
-
|
|
141
|
-
// `fx-depth-${useDepthAlphaHash ? "alphaHash" : "alphaTest"}-${useSphericalDepth ? "spherical" : "flat"}-${depthNodes.map((node) => node.cacheKey).join("-") || "none"}`;
|
|
140
|
+
material.customProgramCacheKey = () => `fx-depth-${useDepthAlphaHash ? "alphaHash" : "alphaTest"}-${useSphericalDepth ? "spherical" : "flat"}-${depthNodes.map((node) => node.cacheKey).join("-") || "none"}`;
|
|
142
141
|
return material;
|
|
143
142
|
}
|
|
144
143
|
|
|
@@ -168,8 +168,7 @@ function buildDistanceMaterial(albedoNodes, distanceAlphaTest, useDistanceAlphaH
|
|
|
168
168
|
}
|
|
169
169
|
shader.fragmentShader = fragmentPreamble + "\n" + fragmentShader;
|
|
170
170
|
};
|
|
171
|
-
|
|
172
|
-
// `fx-distance-${useDistanceAlphaHash ? "alphaHash" : "alphaTest"}-${useSphericalDepth ? "spherical" : "flat"}-${distanceNodes.map((node) => node.cacheKey).join("-") || "none"}`;
|
|
171
|
+
material.customProgramCacheKey = () => `fx-distance-${useDistanceAlphaHash ? "alphaHash" : "alphaTest"}-${useSphericalDepth ? "spherical" : "flat"}-${distanceNodes.map((node) => node.cacheKey).join("-") || "none"}`;
|
|
173
172
|
return material;
|
|
174
173
|
}
|
|
175
174
|
|
|
@@ -3,5 +3,5 @@ import type { GLTypeInfo } from "../../instancedParticle/shared";
|
|
|
3
3
|
import type { FXNodeBlending } from "../../nodes/blending/FXNodeBlending";
|
|
4
4
|
import type { FXNodeColor } from "../../nodes/color/FXNodeColor";
|
|
5
5
|
import type { FXNodeTexture } from "../../nodes/texture/FXNodeTexture";
|
|
6
|
-
import
|
|
6
|
+
import { FXBlending } from "../FXMaterial/FXMaterial";
|
|
7
7
|
export declare function buildFXUnlitMaterial(varyings: Record<string, GLTypeInfo>, blending: FXBlending, useAlphaHashing: boolean, alphaTest: number, albedoNodes: readonly (FXNodeColor | FXNodeTexture | FXNodeBlending)[]): MeshBasicMaterial;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MeshBasicMaterial, DoubleSide, NormalBlending } from 'three';
|
|
2
2
|
import { PARTICLE_DEFINES } from '../../miscellaneous/miscellaneous.js';
|
|
3
3
|
import { buildAlbedoAndBlendingCode } from '../FXMaterial/FXBlending.Internal.js';
|
|
4
|
+
import { FXBlending } from '../FXMaterial/FXMaterial.js';
|
|
4
5
|
|
|
5
6
|
function buildFXUnlitMaterial(varyings, blending, useAlphaHashing, alphaTest, albedoNodes) {
|
|
6
7
|
const attributeDeclarations = [];
|
|
@@ -91,10 +92,11 @@ function buildFXUnlitMaterial(varyings, blending, useAlphaHashing, alphaTest, al
|
|
|
91
92
|
fragmentShader = fragmentShader.replace("#include <premultiplied_alpha_fragment>", albedoCode.premultChunk);
|
|
92
93
|
shader.fragmentShader = fragmentPreamble + "\n" + fragmentShader;
|
|
93
94
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
material.customProgramCacheKey = () => [
|
|
96
|
+
"fx-unlit",
|
|
97
|
+
albedoNodes.map((node) => node.cacheKey).join("-") || "none",
|
|
98
|
+
FXBlending[blending],
|
|
99
|
+
].join("_");
|
|
98
100
|
return material;
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -9,6 +9,13 @@ class FXUnlitMaterial extends FXMaterial {
|
|
|
9
9
|
buildThreeMaterial(varyings) {
|
|
10
10
|
return buildFXUnlitMaterial(varyings, this.blending, this.useAlphaHashing, this.alphaTest, this.albedoNodes);
|
|
11
11
|
}
|
|
12
|
+
prepare() {
|
|
13
|
+
let i = 0;
|
|
14
|
+
for (const node of this.albedoNodes) {
|
|
15
|
+
node.prepare?.(i);
|
|
16
|
+
i += 1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
export { FXUnlitMaterial };
|
|
@@ -4,7 +4,6 @@ import type { Vector3Like } from "../miscellaneous/math";
|
|
|
4
4
|
import type { FXTextureConfig } from "../miscellaneous/texture/FXTextureView.Internal";
|
|
5
5
|
import type { FXColor } from "./color/FXColor";
|
|
6
6
|
import type { FXCurve1D } from "./curve/FXCurve1D";
|
|
7
|
-
export declare function getNextInstanceId(): number;
|
|
8
7
|
export interface FXRange {
|
|
9
8
|
min: number;
|
|
10
9
|
max: number;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Texture, DataTexture, RGBAFormat, UnsignedByteType, UVMapping, ClampToEdgeWrapping, LinearFilter, SRGBColorSpace } from 'three';
|
|
2
2
|
|
|
3
|
-
let nextInstanceId = 0;
|
|
4
|
-
function getNextInstanceId() {
|
|
5
|
-
return nextInstanceId++;
|
|
6
|
-
}
|
|
7
3
|
function resolveFXRangeConfig(config) {
|
|
8
4
|
if (typeof config === "number") {
|
|
9
5
|
return { min: config, max: config };
|
|
@@ -86,4 +82,4 @@ const PARTICLE_DEFINES = `
|
|
|
86
82
|
#define PARTICLE_RANDOM_C p_builtin[3][3]
|
|
87
83
|
`;
|
|
88
84
|
|
|
89
|
-
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, PARTICLE_DEFINES, buildGradientTexture,
|
|
85
|
+
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, PARTICLE_DEFINES, buildGradientTexture, resolveAspect, resolveFXRangeConfig, resolveFXVector3Config };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FXNodeBlending } from "./FXNodeBlending";
|
|
2
2
|
export declare class FXNodeLightnessBlendingMask extends FXNodeBlending {
|
|
3
|
-
private
|
|
4
|
-
private
|
|
3
|
+
private uniformNameEdge0;
|
|
4
|
+
private uniformNameEdge1;
|
|
5
|
+
private edge0Internal;
|
|
6
|
+
private edge1Internal;
|
|
7
|
+
private isPrepared;
|
|
5
8
|
/**
|
|
6
9
|
* @param edge0 - brightness threshold where mask starts (below this: NormalBlending). Defaults to `0.3`
|
|
7
10
|
* @param edge1 - brightness threshold where mask is fully active (above this: full FXBlending effect). Defaults to `0.7`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
2
2
|
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER, BLENDING_EXPRESSION_CURRENT_COLOR_PLACEHOLDER } from '../FXNode.js';
|
|
3
3
|
import { FXNodeBlending } from './FXNodeBlending.js';
|
|
4
4
|
|
|
@@ -11,38 +11,54 @@ class FXNodeLightnessBlendingMask extends FXNodeBlending {
|
|
|
11
11
|
super();
|
|
12
12
|
/** @internal */
|
|
13
13
|
this.cacheKey = "lightness-blending-mask";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
|
|
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})`;
|
|
14
|
+
this._private_isPrepared = false;
|
|
15
|
+
assertValidNonNegativeNumber(edge0, "FXNodeLightnessBlendingMask.constructor.edge0");
|
|
16
|
+
assertValidNonNegativeNumber(edge1, "FXNodeLightnessBlendingMask.constructor.edge1");
|
|
17
|
+
this._private_edge0Internal = edge0;
|
|
18
|
+
this._private_edge1Internal = edge1;
|
|
32
19
|
}
|
|
33
20
|
/** Brightness threshold where mask starts (below this: NormalBlending) */
|
|
34
21
|
get edge0() {
|
|
35
|
-
return this.
|
|
22
|
+
return this._private_edge0Internal;
|
|
36
23
|
}
|
|
37
24
|
/** Brightness threshold where mask is fully active (above this: full FXBlending effect) */
|
|
38
25
|
get edge1() {
|
|
39
|
-
return this.
|
|
26
|
+
return this._private_edge1Internal;
|
|
40
27
|
}
|
|
41
28
|
set edge0(value) {
|
|
42
|
-
|
|
29
|
+
assertValidNonNegativeNumber(value, "FXNodeLightnessBlendingMask.edge0");
|
|
30
|
+
this._private_edge0Internal = value;
|
|
31
|
+
if (this._private_isPrepared) {
|
|
32
|
+
this.uniforms[this._private_uniformNameEdge0].value = value;
|
|
33
|
+
}
|
|
43
34
|
}
|
|
44
35
|
set edge1(value) {
|
|
45
|
-
|
|
36
|
+
assertValidNonNegativeNumber(value, "FXNodeLightnessBlendingMask.edge1");
|
|
37
|
+
this._private_edge1Internal = value;
|
|
38
|
+
if (this._private_isPrepared) {
|
|
39
|
+
this.uniforms[this._private_uniformNameEdge1].value = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
prepare(index) {
|
|
44
|
+
this._private_uniformNameEdge0 = `u_LightnessBlendingMaskEdge0_${index}`;
|
|
45
|
+
this._private_uniformNameEdge1 = `u_LightnessBlendingMaskEdge1_${index}`;
|
|
46
|
+
this.uniformDeclarations = [
|
|
47
|
+
`uniform float ${this._private_uniformNameEdge0};`,
|
|
48
|
+
`uniform float ${this._private_uniformNameEdge1};`,
|
|
49
|
+
];
|
|
50
|
+
this.uniforms = {
|
|
51
|
+
[this._private_uniformNameEdge0]: { value: this._private_edge0Internal },
|
|
52
|
+
[this._private_uniformNameEdge1]: { value: this._private_edge1Internal },
|
|
53
|
+
};
|
|
54
|
+
this.helperFunctions = `
|
|
55
|
+
float fxLightnessBlendingMask(vec4 color, float edge0, float edge1) {
|
|
56
|
+
float brightness = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
57
|
+
return smoothstep(edge0, edge1, brightness);
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
this.blendingExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxLightnessBlendingMask(${BLENDING_EXPRESSION_CURRENT_COLOR_PLACEHOLDER}, ${this._private_uniformNameEdge0}, ${this._private_uniformNameEdge1})`;
|
|
61
|
+
this._private_isPrepared = true;
|
|
46
62
|
}
|
|
47
63
|
}
|
|
48
64
|
|
|
@@ -6,8 +6,10 @@ import { FXNodeColor } from "./FXNodeColor";
|
|
|
6
6
|
* Color node that animates particle color along a gradient curve over its lifetime
|
|
7
7
|
*/
|
|
8
8
|
export declare class FXNodeColorOverLife extends FXNodeColor {
|
|
9
|
-
private
|
|
9
|
+
private uniformName;
|
|
10
|
+
private gradientTexture;
|
|
10
11
|
private curveInternal;
|
|
12
|
+
private isPrepared;
|
|
11
13
|
/**
|
|
12
14
|
* @param curve - Color gradient defining the animation over the particle lifetime
|
|
13
15
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FXCurve1D } from '../../miscellaneous/curve/FXCurve1D.js';
|
|
2
|
-
import { buildGradientTexture
|
|
2
|
+
import { buildGradientTexture } from '../../miscellaneous/miscellaneous.js';
|
|
3
3
|
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
4
4
|
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
5
5
|
import { FXNodeColor } from './FXNodeColor.js';
|
|
@@ -17,10 +17,29 @@ class FXNodeColorOverLife extends FXNodeColor {
|
|
|
17
17
|
this.affectsDepth = true;
|
|
18
18
|
/** @internal */
|
|
19
19
|
this.cacheKey = "color-over-life";
|
|
20
|
-
|
|
21
|
-
this._private_uniformName = `u_ColorOverLife_${id}`;
|
|
20
|
+
this._private_isPrepared = false;
|
|
22
21
|
this._private_curveInternal = new FXCurve1D(curve);
|
|
23
22
|
this._private_gradientTexture = buildGradientTexture(this._private_curveInternal);
|
|
23
|
+
}
|
|
24
|
+
/** Current color gradient curve */
|
|
25
|
+
get curve() {
|
|
26
|
+
return this._private_curveInternal;
|
|
27
|
+
}
|
|
28
|
+
set curve(value) {
|
|
29
|
+
this._private_curveInternal = new FXCurve1D(value);
|
|
30
|
+
this._private_gradientTexture.dispose();
|
|
31
|
+
this._private_gradientTexture = buildGradientTexture(this._private_curveInternal);
|
|
32
|
+
if (this._private_isPrepared) {
|
|
33
|
+
this.uniforms[this._private_uniformName].value = this._private_gradientTexture;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Releases the backing gradient texture */
|
|
37
|
+
destroy() {
|
|
38
|
+
this._private_gradientTexture.dispose();
|
|
39
|
+
}
|
|
40
|
+
/** @internal */
|
|
41
|
+
prepare(index) {
|
|
42
|
+
this._private_uniformName = `u_ColorOverLife_${index}`;
|
|
24
43
|
this.uniformDeclarations = [`uniform sampler2D ${this._private_uniformName};`];
|
|
25
44
|
this.uniforms = {
|
|
26
45
|
[this._private_uniformName]: { value: this._private_gradientTexture },
|
|
@@ -38,20 +57,7 @@ class FXNodeColorOverLife extends FXNodeColor {
|
|
|
38
57
|
}
|
|
39
58
|
`;
|
|
40
59
|
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleColorOverLife(${this._private_uniformName})`;
|
|
41
|
-
|
|
42
|
-
/** Current color gradient curve */
|
|
43
|
-
get curve() {
|
|
44
|
-
return this._private_curveInternal;
|
|
45
|
-
}
|
|
46
|
-
set curve(value) {
|
|
47
|
-
this._private_curveInternal = new FXCurve1D(value);
|
|
48
|
-
this._private_gradientTexture.dispose();
|
|
49
|
-
this._private_gradientTexture = buildGradientTexture(this._private_curveInternal);
|
|
50
|
-
this.uniforms[this._private_uniformName].value = this._private_gradientTexture;
|
|
51
|
-
}
|
|
52
|
-
/** Releases the backing gradient texture */
|
|
53
|
-
destroy() {
|
|
54
|
-
this._private_gradientTexture.dispose();
|
|
60
|
+
this._private_isPrepared = true;
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
|
|
@@ -7,7 +7,9 @@ import { FXNodeColor } from "./FXNodeColor";
|
|
|
7
7
|
* (UV radius `0.5`). An `innerRadius` of `0.5` produces a hard circular clip with no gradient.
|
|
8
8
|
*/
|
|
9
9
|
export declare class FXNodeSphericalClip extends FXNodeColor {
|
|
10
|
-
private
|
|
10
|
+
private uniformName;
|
|
11
|
+
private innerRadiusInternal;
|
|
12
|
+
private isPrepared;
|
|
11
13
|
/**
|
|
12
14
|
* @param innerRadius - UV radius where the fade begins; must be non-negative. Defaults to `0.5`
|
|
13
15
|
*/
|
|
@@ -15,4 +17,5 @@ export declare class FXNodeSphericalClip extends FXNodeColor {
|
|
|
15
17
|
/** UV radius of the fully opaque inner area */
|
|
16
18
|
get innerRadius(): number;
|
|
17
19
|
set innerRadius(value: number);
|
|
20
|
+
prepare(index: number): void;
|
|
18
21
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
2
|
-
import { getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
3
2
|
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
4
3
|
import { FXNodeColor } from './FXNodeColor.js';
|
|
5
4
|
|
|
@@ -20,12 +19,26 @@ class FXNodeSphericalClip extends FXNodeColor {
|
|
|
20
19
|
this.affectsDepth = true;
|
|
21
20
|
/** @internal */
|
|
22
21
|
this.cacheKey = "spherical-clip";
|
|
22
|
+
this._private_isPrepared = false;
|
|
23
23
|
assertValidNonNegativeNumber(innerRadius, "FXNodeSphericalClip.constructor.innerRadius");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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};`];
|
|
27
40
|
this.uniforms = {
|
|
28
|
-
[this.
|
|
41
|
+
[this._private_uniformName]: { value: this._private_innerRadiusInternal },
|
|
29
42
|
};
|
|
30
43
|
this.helperFunctions = `
|
|
31
44
|
vec4 fxApplySphericalClip(float innerRadius) {
|
|
@@ -33,15 +46,8 @@ class FXNodeSphericalClip extends FXNodeColor {
|
|
|
33
46
|
return vec4(1.0, 1.0, 1.0, 1.0 - smoothstep(innerRadius, 0.5, distanceToCenter));
|
|
34
47
|
}
|
|
35
48
|
`;
|
|
36
|
-
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxApplySphericalClip(${this.
|
|
37
|
-
|
|
38
|
-
/** UV radius of the fully opaque inner area */
|
|
39
|
-
get innerRadius() {
|
|
40
|
-
return this.uniforms[this._private_uniformInnerRadius].value;
|
|
41
|
-
}
|
|
42
|
-
set innerRadius(value) {
|
|
43
|
-
assertValidNonNegativeNumber(value, "FXNodeSphericalClip.innerRadius");
|
|
44
|
-
this.uniforms[this._private_uniformInnerRadius].value = value;
|
|
49
|
+
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxApplySphericalClip(${this._private_uniformName})`;
|
|
50
|
+
this._private_isPrepared = true;
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
2
1
|
import { FXNodeNormal } from './FXNodeNormal.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -10,7 +9,7 @@ class FXNodeFlatNormal extends FXNodeNormal {
|
|
|
10
9
|
/** @internal */
|
|
11
10
|
this.cacheKey = "flat-normal";
|
|
12
11
|
/** @internal */
|
|
13
|
-
this.normalExpression =
|
|
12
|
+
this.normalExpression = `vec3(0.0, 0.0, 1.0)`;
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
2
1
|
import { FXNodeNormal } from './FXNodeNormal.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -17,7 +16,7 @@ class FXNodeSphericalNormal extends FXNodeNormal {
|
|
|
17
16
|
}
|
|
18
17
|
`;
|
|
19
18
|
/** @internal */
|
|
20
|
-
this.normalExpression =
|
|
19
|
+
this.normalExpression = `fxComputeSphericalNormal(p_uv)`;
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
|
|
@@ -26,11 +26,15 @@ export interface FXNodeAnimatedTextureOptions {
|
|
|
26
26
|
* is `columns * rows`. Both `columns` and `rows` must be positive integers.
|
|
27
27
|
*/
|
|
28
28
|
export declare class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
29
|
+
private uniformTexture;
|
|
30
|
+
private uniformUVTransform;
|
|
31
|
+
private uniformColumns;
|
|
32
|
+
private uniformRows;
|
|
33
33
|
private readonly textureInternal;
|
|
34
|
+
private readonly isInterpolate;
|
|
35
|
+
private columnsInternal;
|
|
36
|
+
private rowsInternal;
|
|
37
|
+
private isPrepared;
|
|
34
38
|
/**
|
|
35
39
|
* @param options - Sprite sheet configuration
|
|
36
40
|
*/
|
|
@@ -44,4 +48,5 @@ export declare class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
44
48
|
set texture(config: FXTextureConfig);
|
|
45
49
|
set columns(value: number);
|
|
46
50
|
set rows(value: number);
|
|
51
|
+
prepare(index: number): void;
|
|
47
52
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
|
|
2
|
-
import { getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
3
2
|
import { FXTextureView } from '../../miscellaneous/texture/FXTextureView.js';
|
|
4
3
|
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
5
4
|
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
@@ -20,21 +19,65 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
20
19
|
super();
|
|
21
20
|
/** @internal */
|
|
22
21
|
this.affectsDepth = true;
|
|
22
|
+
this._private_isPrepared = false;
|
|
23
23
|
assertValidPositiveNumber(columns, "FXNodeAnimatedTexture.constructor.columns");
|
|
24
24
|
assertValidPositiveNumber(rows, "FXNodeAnimatedTexture.constructor.rows");
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
this._private_uniformUVTransform = `u_AnimatedTextureUVTransform_${idx}`;
|
|
28
|
-
this._private_uniformColumns = `u_AnimatedTextureColumns_${idx}`;
|
|
29
|
-
this._private_uniformRows = `u_AnimatedTextureRows_${idx}`;
|
|
25
|
+
this._private_columnsInternal = columns;
|
|
26
|
+
this._private_rowsInternal = rows;
|
|
30
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}`;
|
|
31
74
|
const uvTransform = this._private_textureInternal.calculateUVTransform();
|
|
32
75
|
this._private_textureInternal.setTextureDirtyFalse();
|
|
33
76
|
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
34
77
|
const gammaCorrection = checkSRGBSupport()
|
|
35
78
|
? ""
|
|
36
79
|
: "color = vec4(pow(color.rgb, vec3(2.2)), color.a);";
|
|
37
|
-
this.cacheKey =
|
|
80
|
+
this.cacheKey = this._private_isInterpolate ? "animated-texture-interpolated" : "animated-texture";
|
|
38
81
|
this.uniformDeclarations = [
|
|
39
82
|
`uniform sampler2D ${this._private_uniformTexture};`,
|
|
40
83
|
`uniform mat3 ${this._private_uniformUVTransform};`,
|
|
@@ -44,11 +87,10 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
44
87
|
this.uniforms = {
|
|
45
88
|
[this._private_uniformTexture]: { value: this._private_textureInternal.texture },
|
|
46
89
|
[this._private_uniformUVTransform]: { value: uvTransform },
|
|
47
|
-
[this._private_uniformColumns]: { value:
|
|
48
|
-
[this._private_uniformRows]: { value:
|
|
90
|
+
[this._private_uniformColumns]: { value: this._private_columnsInternal },
|
|
91
|
+
[this._private_uniformRows]: { value: this._private_rowsInternal },
|
|
49
92
|
};
|
|
50
|
-
this.helperFunctions =
|
|
51
|
-
? `
|
|
93
|
+
this.helperFunctions = this._private_isInterpolate ? `
|
|
52
94
|
vec2 fxFrameToUV(vec2 uv, float frame, float columns, float rows) {
|
|
53
95
|
float column = mod(frame, columns);
|
|
54
96
|
float row = floor(frame / columns);
|
|
@@ -102,37 +144,7 @@ class FXNodeAnimatedTexture extends FXNodeTexture {
|
|
|
102
144
|
}
|
|
103
145
|
`;
|
|
104
146
|
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleAnimatedTexture(${this._private_uniformTexture}, ${this._private_uniformUVTransform}, p_uv, ${this._private_uniformColumns}, ${this._private_uniformRows})`;
|
|
105
|
-
|
|
106
|
-
/** View describing the texture and its atlas region */
|
|
107
|
-
get texture() {
|
|
108
|
-
return this._private_textureInternal;
|
|
109
|
-
}
|
|
110
|
-
/** Number of frame columns in the sprite sheet */
|
|
111
|
-
get columns() {
|
|
112
|
-
return this.uniforms[this._private_uniformColumns].value;
|
|
113
|
-
}
|
|
114
|
-
/** Number of frame rows in the sprite sheet */
|
|
115
|
-
get rows() {
|
|
116
|
-
return this.uniforms[this._private_uniformRows].value;
|
|
117
|
-
}
|
|
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();
|
|
123
|
-
}
|
|
124
|
-
if (this._private_textureInternal.uvTransformDirty) {
|
|
125
|
-
this._private_textureInternal.calculateUVTransform(this.uniforms[this._private_uniformUVTransform].value);
|
|
126
|
-
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
set columns(value) {
|
|
130
|
-
assertValidPositiveNumber(value, "FXNodeAnimatedTexture.columns");
|
|
131
|
-
this.uniforms[this._private_uniformColumns].value = value;
|
|
132
|
-
}
|
|
133
|
-
set rows(value) {
|
|
134
|
-
assertValidPositiveNumber(value, "FXNodeAnimatedTexture.rows");
|
|
135
|
-
this.uniforms[this._private_uniformRows].value = value;
|
|
147
|
+
this._private_isPrepared = true;
|
|
136
148
|
}
|
|
137
149
|
}
|
|
138
150
|
|
|
@@ -5,9 +5,10 @@ import { FXNodeTexture } from "./FXNodeTexture";
|
|
|
5
5
|
* Texture node that applies a single static texture to every particle
|
|
6
6
|
*/
|
|
7
7
|
export declare class FXNodeStaticTexture extends FXNodeTexture {
|
|
8
|
-
private
|
|
9
|
-
private
|
|
8
|
+
private uniformTexture;
|
|
9
|
+
private uniformUVTransform;
|
|
10
10
|
private readonly textureInternal;
|
|
11
|
+
private isPrepared;
|
|
11
12
|
/**
|
|
12
13
|
* @param config - Texture or atlas configuration applied to every particle
|
|
13
14
|
*/
|
|
@@ -15,4 +16,5 @@ export declare class FXNodeStaticTexture extends FXNodeTexture {
|
|
|
15
16
|
/** View describing the texture and its atlas region */
|
|
16
17
|
get texture(): FXTextureView;
|
|
17
18
|
set texture(config: FXTextureConfig);
|
|
19
|
+
prepare(index: number): void;
|
|
18
20
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getNextInstanceId } from '../../miscellaneous/miscellaneous.js';
|
|
2
1
|
import { FXTextureView } from '../../miscellaneous/texture/FXTextureView.js';
|
|
3
2
|
import { checkSRGBSupport } from '../../miscellaneous/webglCapabilities.js';
|
|
4
3
|
import { CURRENT_EXPRESSION_VALUE_PLACEHOLDER } from '../FXNode.js';
|
|
@@ -17,10 +16,29 @@ class FXNodeStaticTexture extends FXNodeTexture {
|
|
|
17
16
|
this.affectsDepth = true;
|
|
18
17
|
/** @internal */
|
|
19
18
|
this.cacheKey = "static-texture";
|
|
20
|
-
|
|
21
|
-
this._private_uniformTexture = `u_StaticTexture_${id}`;
|
|
22
|
-
this._private_uniformUVTransform = `u_StaticTextureUVTransform_${id}`;
|
|
19
|
+
this._private_isPrepared = false;
|
|
23
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}`;
|
|
24
42
|
const uvTransform = this._private_textureInternal.calculateUVTransform();
|
|
25
43
|
this._private_textureInternal.setTextureDirtyFalse();
|
|
26
44
|
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
@@ -42,21 +60,7 @@ class FXNodeStaticTexture extends FXNodeTexture {
|
|
|
42
60
|
}
|
|
43
61
|
`;
|
|
44
62
|
this.colorExpression = `${CURRENT_EXPRESSION_VALUE_PLACEHOLDER} * fxSampleStaticTexture(${this._private_uniformTexture}, ${this._private_uniformUVTransform}, p_uv)`;
|
|
45
|
-
|
|
46
|
-
/** View describing the texture and its atlas region */
|
|
47
|
-
get texture() {
|
|
48
|
-
return this._private_textureInternal;
|
|
49
|
-
}
|
|
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();
|
|
55
|
-
}
|
|
56
|
-
if (this._private_textureInternal.uvTransformDirty) {
|
|
57
|
-
this._private_textureInternal.calculateUVTransform(this.uniforms[this._private_uniformUVTransform].value);
|
|
58
|
-
this._private_textureInternal.setUVTransformDirtyFalse();
|
|
59
|
-
}
|
|
63
|
+
this._private_isPrepared = true;
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { InstancedBufferGeometry, BufferAttribute, Float32BufferAttribute } from 'three';
|
|
2
|
-
|
|
3
|
-
const INSTANCED_PARTICLE_GEOMETRY = (() => {
|
|
4
|
-
const geometry = new InstancedBufferGeometry();
|
|
5
|
-
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
|
|
6
|
-
geometry.setIndex(new BufferAttribute(indices, 1));
|
|
7
|
-
const positions = new Float32Array([-0.5, 0.5, 0, 0.5, 0.5, 0, -0.5, -0.5, 0, 0.5, -0.5, 0]);
|
|
8
|
-
geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
|
|
9
|
-
const uvs = new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]);
|
|
10
|
-
geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
|
|
11
|
-
return geometry;
|
|
12
|
-
})();
|
|
13
|
-
|
|
14
|
-
export { INSTANCED_PARTICLE_GEOMETRY };
|