sparcoon 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/FXEmitter.d.ts +1 -0
- package/dist/elements/FXEmitter.js +3 -5
- package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +1 -1
- package/dist/instancedParticle/FXInstancedParticle.Internal.js +2 -1
- package/dist/instancedParticle/FXInstancedParticle.d.ts +2 -3
- package/dist/instancedParticle/FXInstancedParticle.js +2 -9
- package/dist/instancedParticle/shared.js +1 -8
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Object3D,
|
|
1
|
+
import { Object3D, NormalBlending } from 'three';
|
|
2
2
|
import { FXInstancedParticle } from '../instancedParticle/FXInstancedParticle.js';
|
|
3
3
|
import { collectProperties, collectUniforms } from '../instancedParticle/FXInstancedParticle.Internal.js';
|
|
4
4
|
import { resolveGLSLTypeInfo } from '../instancedParticle/shared.js';
|
|
@@ -76,11 +76,9 @@ class FXEmitter extends Object3D {
|
|
|
76
76
|
collectProperties(collectedProperties, _private_spawnSequence, "UIEmitter.constructor.spawnSequence:");
|
|
77
77
|
collectProperties(collectedProperties, _private_behaviorSequence, "UIEmitter.constructor.behaviorSequence");
|
|
78
78
|
collectProperties(collectedProperties, _private_renderingSequence, "UIEmitter.constructor.renderingSequence");
|
|
79
|
-
const collectedUniforms = {
|
|
80
|
-
origin: { value: new Vector2(), glslTypeInfo: resolveGLSLTypeInfo("Vector2") },
|
|
81
|
-
};
|
|
79
|
+
const collectedUniforms = {};
|
|
82
80
|
collectUniforms(collectedUniforms, _private_renderingSequence, "UIEmitter.constructor.renderingSequence");
|
|
83
|
-
this._private_mesh = new FXInstancedParticle(this._private_renderingSequence.map((module) => module.source), collectedUniforms, collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP, options.blending ?? NormalBlending);
|
|
81
|
+
this._private_mesh = new FXInstancedParticle(this._private_renderingSequence.map((module) => module.source), collectedUniforms, collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP, options.blending ?? NormalBlending, options.useAlphaHashing ?? false);
|
|
84
82
|
this.automaticallyDestroyModules =
|
|
85
83
|
options.automaticallyDestroyModules ?? EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES;
|
|
86
84
|
this.add(this._private_mesh);
|
|
@@ -10,4 +10,4 @@ export declare function collectUniforms(keeper: Record<string, GLProperty>, modu
|
|
|
10
10
|
}[], debugContext: string): void;
|
|
11
11
|
export declare function buildParticleVertexShader(uniformDeclarations: string[], attributeDeclarations: string[], varyingDeclarations: string[], vertexAssignments: string[]): string;
|
|
12
12
|
export declare function buildParticleFragmentShader(uniformDeclarations: string[], varyingDeclarations: string[], sources: string[]): string;
|
|
13
|
-
export declare function buildParticleMaterial(sources: string[], uniformProperties: Record<string, GLProperty>, varyingProperties: Record<string, GLTypeInfo>, blending: Blending): ShaderMaterial;
|
|
13
|
+
export declare function buildParticleMaterial(sources: string[], uniformProperties: Record<string, GLProperty>, varyingProperties: Record<string, GLTypeInfo>, blending: Blending, useAlphaHashing: boolean): ShaderMaterial;
|
|
@@ -185,7 +185,7 @@ function buildParticleFragmentShader(uniformDeclarations, varyingDeclarations, s
|
|
|
185
185
|
}
|
|
186
186
|
`;
|
|
187
187
|
}
|
|
188
|
-
function buildParticleMaterial(sources, uniformProperties, varyingProperties, blending) {
|
|
188
|
+
function buildParticleMaterial(sources, uniformProperties, varyingProperties, blending, useAlphaHashing) {
|
|
189
189
|
const uniforms = {};
|
|
190
190
|
const uniformDeclarations = [];
|
|
191
191
|
const attributeDeclarations = [];
|
|
@@ -209,6 +209,7 @@ function buildParticleMaterial(sources, uniformProperties, varyingProperties, bl
|
|
|
209
209
|
transparent: true,
|
|
210
210
|
depthWrite: false,
|
|
211
211
|
depthTest: true,
|
|
212
|
+
alphaHash: useAlphaHashing,
|
|
212
213
|
blending,
|
|
213
214
|
});
|
|
214
215
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { Blending } from "three";
|
|
2
2
|
import { InstancedBufferAttribute, Mesh } from "three";
|
|
3
|
-
import {
|
|
3
|
+
import type { GLProperty, GLTypeInfo } from "./shared";
|
|
4
4
|
export declare class FXInstancedParticle extends Mesh {
|
|
5
5
|
private readonly capacityStep;
|
|
6
6
|
readonly propertyBuffers: Record<string, InstancedBufferAttribute>;
|
|
7
7
|
private readonly instancedGeometry;
|
|
8
8
|
private readonly shaderMaterial;
|
|
9
9
|
private capacity;
|
|
10
|
-
constructor(sources: string[], uniforms: Record<string, GLProperty>, varyings: Record<string, GLTypeInfo>, expectedCapacity: number, capacityStep: number, blending: Blending);
|
|
10
|
+
constructor(sources: string[], uniforms: Record<string, GLProperty>, varyings: Record<string, GLTypeInfo>, expectedCapacity: number, capacityStep: number, blending: Blending, useAlphaHashing: boolean);
|
|
11
11
|
get instanceCount(): number;
|
|
12
12
|
createInstances(count: number): void;
|
|
13
|
-
setOrigin(x: number, y: number): void;
|
|
14
13
|
removeDeadParticles(): void;
|
|
15
14
|
drop(): void;
|
|
16
15
|
destroy(): void;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { Mesh, InstancedBufferAttribute, StreamDrawUsage } from 'three';
|
|
2
2
|
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME } from '../miscellaneous/miscellaneous.js';
|
|
3
3
|
import { INSTANCED_PARTICLE_GEOMETRY, buildParticleMaterial } from './FXInstancedParticle.Internal.js';
|
|
4
|
-
import { resolvePropertyUniform } from './shared.js';
|
|
5
4
|
|
|
6
5
|
class FXInstancedParticle extends Mesh {
|
|
7
|
-
constructor(sources, uniforms, varyings, expectedCapacity, _private_capacityStep, blending) {
|
|
6
|
+
constructor(sources, uniforms, varyings, expectedCapacity, _private_capacityStep, blending, useAlphaHashing) {
|
|
8
7
|
const instancedGeometry = INSTANCED_PARTICLE_GEOMETRY.clone();
|
|
9
|
-
const shaderMaterial = buildParticleMaterial(sources, uniforms, varyings, blending);
|
|
8
|
+
const shaderMaterial = buildParticleMaterial(sources, uniforms, varyings, blending, useAlphaHashing);
|
|
10
9
|
super(instancedGeometry, shaderMaterial);
|
|
11
10
|
this._private_capacityStep = _private_capacityStep;
|
|
12
11
|
this.propertyBuffers = {};
|
|
13
12
|
this.frustumCulled = false;
|
|
14
|
-
this.matrixAutoUpdate = false;
|
|
15
|
-
this.matrixWorldAutoUpdate = false;
|
|
16
13
|
this._private_instancedGeometry = instancedGeometry;
|
|
17
14
|
this._private_instancedGeometry.instanceCount = 0;
|
|
18
15
|
this._private_shaderMaterial = shaderMaterial;
|
|
@@ -33,10 +30,6 @@ class FXInstancedParticle extends Mesh {
|
|
|
33
30
|
this._private_ensureCapacity(currentInstanceCount + count);
|
|
34
31
|
this._private_instancedGeometry.instanceCount += count;
|
|
35
32
|
}
|
|
36
|
-
setOrigin(x, y) {
|
|
37
|
-
const uniform = resolvePropertyUniform("origin", this._private_shaderMaterial);
|
|
38
|
-
uniform.value.set(x, y);
|
|
39
|
-
}
|
|
40
33
|
removeDeadParticles() {
|
|
41
34
|
const builtinBuffer = this.propertyBuffers.builtin;
|
|
42
35
|
if (builtinBuffer === undefined) {
|
|
@@ -112,12 +112,5 @@ function resolveGLSLTypeInfo(value) {
|
|
|
112
112
|
}
|
|
113
113
|
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type`);
|
|
114
114
|
}
|
|
115
|
-
function resolvePropertyUniform(name, material) {
|
|
116
|
-
const uniform = material.uniforms[`p_${name}`];
|
|
117
|
-
if (uniform === undefined) {
|
|
118
|
-
throw new Error(`resolvePropertyUniform.name: unknown uniform`);
|
|
119
|
-
}
|
|
120
|
-
return uniform;
|
|
121
|
-
}
|
|
122
115
|
|
|
123
|
-
export { resolveGLSLTypeInfo
|
|
116
|
+
export { resolveGLSLTypeInfo };
|