laymur 0.25.1 → 0.26.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 +41 -5
- package/dist/core/elements/UIAnchor/UIAnchor.d.ts +2 -2
- package/dist/core/elements/UIAnchor/UIAnchor.js +3 -2
- package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +3 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +32 -0
- package/dist/core/elements/UIDummy/UIDummy.js +101 -2
- package/dist/core/elements/UIElement/UIElement.d.ts +23 -1
- package/dist/core/elements/UIElement/UIElement.js +50 -3
- package/dist/core/elements/UIGraphics/UIGraphics.js +2 -2
- package/dist/core/elements/UIProgress/UIProgress.js +2 -5
- package/dist/core/elements/UIScene/UIScene.js +3 -2
- package/dist/core/elements/UIText/UIText.js +2 -2
- package/dist/core/index.d.ts +53 -4
- package/dist/core/index.js +15 -2
- package/dist/core/layers/UILayer/UILayer.d.ts +11 -1
- package/dist/core/layers/UILayer/UILayer.js +37 -2
- package/dist/core/miscellaneous/UIAffineMatrix3.d.ts +13 -0
- package/dist/core/miscellaneous/UIAffineMatrix3.js +13 -0
- package/dist/core/miscellaneous/area/UIArea.d.ts +10 -1
- package/dist/core/miscellaneous/area/UIArea.js +4 -1
- package/dist/core/miscellaneous/area/UIAreaCircle.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.js +0 -1
- package/dist/core/miscellaneous/area/UIAreaPolygon.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +0 -1
- package/dist/core/miscellaneous/area/UIAreaRectangle.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +0 -1
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +0 -1
- package/dist/core/miscellaneous/asserts.d.ts +9 -0
- package/dist/core/miscellaneous/asserts.js +16 -0
- package/dist/core/miscellaneous/color/UIColor.js +1 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +17 -3
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +88 -26
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.d.ts +9 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.js +29 -6
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +51 -11
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +2 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +47 -6
- package/dist/core/miscellaneous/generic-plane/shared.d.ts +15 -3
- package/dist/core/miscellaneous/generic-plane/shared.js +38 -7
- package/dist/core/miscellaneous/generic-plane/varyingPacking.d.ts +46 -0
- package/dist/core/miscellaneous/generic-plane/varyingPacking.js +170 -0
- package/dist/core/miscellaneous/mask/UIMask.Internal.d.ts +61 -0
- package/dist/core/miscellaneous/mask/UIMask.Internal.js +56 -0
- package/dist/core/miscellaneous/mask/UIMask.d.ts +84 -0
- package/dist/core/miscellaneous/mask/UIMask.js +265 -0
- package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.d.ts +50 -0
- package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.js +233 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +10 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +7 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +2 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +0 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +2 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +0 -1
- package/dist/core/miscellaneous/micro/UIMicro.Internal.d.ts +3 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +1 -0
- package/dist/core/miscellaneous/micro/UIMicro.d.ts +18 -1
- package/dist/core/miscellaneous/micro/UIMicro.js +23 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.d.ts +16 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +8 -2
- package/dist/core/miscellaneous/texture/UITextureView.d.ts +2 -1
- package/dist/core/miscellaneous/texture/UITextureView.js +3 -2
- package/dist/core/shaders/UIMask.d.ts +15 -0
- package/dist/core/shaders/UIMask.js +45 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +0 -1
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +2 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +1 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +3 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +0 -1
- package/dist/debug/index.d.ts +2 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +7 -1
- package/dist/particles/behaviorModules/UIBehaviorModule.js +2 -1
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +0 -2
- package/dist/particles/elements/UIEmitter.Internal.d.ts +7 -0
- package/dist/particles/elements/UIEmitter.d.ts +1 -8
- package/dist/particles/index.d.ts +5 -0
- package/dist/particles/index.js +3 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +11 -2
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +101 -72
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +1 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +4 -2
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +4 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +0 -2
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +4 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +0 -2
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +10 -1
- package/dist/particles/renderingModules/UIRenderingModule.js +3 -1
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +4 -0
- package/dist/particles/spawnModules/UISpawnModule.d.ts +13 -1
- package/dist/particles/spawnModules/UISpawnModule.js +3 -1
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnOffset.js +0 -2
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +0 -2
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +0 -2
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.js +0 -2
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +0 -2
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +0 -2
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRectangle.js +0 -2
- package/package.json +1 -1
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import type { UILayer } from "../../core/index.js";
|
|
2
2
|
import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor.js";
|
|
3
|
-
import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal.js";
|
|
4
3
|
import type { UIBehaviorModule } from "../behaviorModules/UIBehaviorModule.js";
|
|
5
4
|
import type { UIRenderingModule } from "../renderingModules/UIRenderingModule.js";
|
|
6
5
|
import type { UISpawnModule } from "../spawnModules/UISpawnModule.js";
|
|
7
|
-
import type { UIEmitterMode, UIEmitterPlayOptions } from "./UIEmitter.Internal.js";
|
|
8
|
-
export interface UIEmitterOptions extends UIAnchorOptions {
|
|
9
|
-
mode: UIEmitterMode;
|
|
10
|
-
expectedCapacity: number;
|
|
11
|
-
capacityStep: number;
|
|
12
|
-
automaticallyDestroyModules: boolean;
|
|
13
|
-
}
|
|
6
|
+
import type { UIEmitterMode, UIEmitterOptions, UIEmitterPlayOptions } from "./UIEmitter.Internal.js";
|
|
14
7
|
/**
|
|
15
8
|
* Particle emitter element.
|
|
16
9
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { UIBehaviorDirectionalGravity } from "./behaviorModules/UIBehaviorDirectionalGravity.js";
|
|
2
|
+
export { UIBehaviorModule } from "./behaviorModules/UIBehaviorModule.js";
|
|
2
3
|
export { UIBehaviorPointGravity } from "./behaviorModules/UIBehaviorPointGravity.js";
|
|
3
4
|
export { UIBehaviorScaleOscillation } from "./behaviorModules/UIBehaviorScaleOscillation.js";
|
|
4
5
|
export type { UIScaleOscillationAxis } from "./behaviorModules/UIBehaviorScaleOscillation.js";
|
|
@@ -8,9 +9,13 @@ export { UIBehaviorTorqueNoise } from "./behaviorModules/UIBehaviorTorqueNoise.j
|
|
|
8
9
|
export { UIBehaviorVelocityDamping } from "./behaviorModules/UIBehaviorVelocityDamping.js";
|
|
9
10
|
export { UIBehaviorVelocityNoise } from "./behaviorModules/UIBehaviorVelocityNoise.js";
|
|
10
11
|
export { UIEmitter } from "./elements/UIEmitter.js";
|
|
12
|
+
export type { UIEmitterMode, UIEmitterOptions, UIEmitterPlayOptions, } from "./elements/UIEmitter.Internal.js";
|
|
13
|
+
export type { UIAspectConfig, UIRange, UIRangeConfig, UIVector2Config, } from "./miscellaneous/miscellaneous.js";
|
|
11
14
|
export { UIRenderingColorOverLife } from "./renderingModules/UIRenderingColorOverLife.js";
|
|
12
15
|
export { UIRenderingColorOverVelocity } from "./renderingModules/UIRenderingColorOverVelocity.js";
|
|
16
|
+
export { UIRenderingModule } from "./renderingModules/UIRenderingModule.js";
|
|
13
17
|
export { UIRenderingTexture } from "./renderingModules/UIRenderingTexture.js";
|
|
18
|
+
export { UISpawnModule } from "./spawnModules/UISpawnModule.js";
|
|
14
19
|
export { UISpawnOffset } from "./spawnModules/UISpawnOffset.js";
|
|
15
20
|
export { UISpawnRandomLifetime } from "./spawnModules/UISpawnRandomLifetime.js";
|
|
16
21
|
export { UISpawnRandomRotation } from "./spawnModules/UISpawnRandomRotation.js";
|
package/dist/particles/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { UIBehaviorDirectionalGravity } from "./behaviorModules/UIBehaviorDirectionalGravity.js";
|
|
2
|
+
export { UIBehaviorModule } from "./behaviorModules/UIBehaviorModule.js";
|
|
2
3
|
export { UIBehaviorPointGravity } from "./behaviorModules/UIBehaviorPointGravity.js";
|
|
3
4
|
export { UIBehaviorScaleOscillation } from "./behaviorModules/UIBehaviorScaleOscillation.js";
|
|
4
5
|
export { UIBehaviorScaleOverLife } from "./behaviorModules/UIBehaviorScaleOverLife.js";
|
|
@@ -9,7 +10,9 @@ export { UIBehaviorVelocityNoise } from "./behaviorModules/UIBehaviorVelocityNoi
|
|
|
9
10
|
export { UIEmitter } from "./elements/UIEmitter.js";
|
|
10
11
|
export { UIRenderingColorOverLife } from "./renderingModules/UIRenderingColorOverLife.js";
|
|
11
12
|
export { UIRenderingColorOverVelocity } from "./renderingModules/UIRenderingColorOverVelocity.js";
|
|
13
|
+
export { UIRenderingModule } from "./renderingModules/UIRenderingModule.js";
|
|
12
14
|
export { UIRenderingTexture } from "./renderingModules/UIRenderingTexture.js";
|
|
15
|
+
export { UISpawnModule } from "./spawnModules/UISpawnModule.js";
|
|
13
16
|
export { UISpawnOffset } from "./spawnModules/UISpawnOffset.js";
|
|
14
17
|
export { UISpawnRandomLifetime } from "./spawnModules/UISpawnRandomLifetime.js";
|
|
15
18
|
export { UISpawnRandomRotation } from "./spawnModules/UISpawnRandomRotation.js";
|
|
@@ -8,5 +8,14 @@ export declare function collectUniforms(keeper: Record<string, GLProperty>, modu
|
|
|
8
8
|
requiredUniforms: Record<string, UIProperty>;
|
|
9
9
|
}[], debugContext: string): void;
|
|
10
10
|
export declare function buildParticleVertexShader(uniformDeclarations: string[], attributeDeclarations: string[], varyingDeclarations: string[], vertexAssignments: string[]): string;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Builds the fragment shader of a particle mesh. Sources read particle values through the
|
|
13
|
+
* PARTICLE_* macros and properties as p_* globals, all filled from packed varyings.
|
|
14
|
+
* @param fieldDeclarations Packed varyings, p_* globals and PARTICLE_* macros
|
|
15
|
+
* @param fieldAssignments Statements filling the p_* globals at the start of main
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildParticleFragmentShader(uniformDeclarations: string[], fieldDeclarations: string[], fieldAssignments: string[], sources: string[]): string;
|
|
18
|
+
export declare function buildParticleMaterial(sources: string[], uniformProperties: Record<string, GLProperty>, varyingProperties: Record<string, GLTypeInfo>): {
|
|
19
|
+
material: ShaderMaterial;
|
|
20
|
+
varyingRowCount: number;
|
|
21
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BufferAttribute, DoubleSide, Float32BufferAttribute, InstancedBufferGeometry, ShaderMaterial, } from "three";
|
|
2
2
|
import { UIColor } from "../../core/index.js";
|
|
3
3
|
import { resolveGLSLTypeInfo } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
4
|
+
import { isIdentifierReferenced, packVaryings, } from "../../core/miscellaneous/generic-plane/varyingPacking.js";
|
|
4
5
|
import { checkSRGBSupport } from "../../core/miscellaneous/webglCapabilities.js";
|
|
6
|
+
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_D, BUILTIN_OFFSET_RANDOM_E, BUILTIN_OFFSET_RANDOM_F, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, } from "../miscellaneous/miscellaneous.js";
|
|
5
7
|
export const INSTANCED_PARTICLE_GEOMETRY = (() => {
|
|
6
8
|
const geometry = new InstancedBufferGeometry();
|
|
7
9
|
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
|
|
@@ -12,6 +14,26 @@ export const INSTANCED_PARTICLE_GEOMETRY = (() => {
|
|
|
12
14
|
geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
|
|
13
15
|
return geometry;
|
|
14
16
|
})();
|
|
17
|
+
const BUILTIN_PROPERTY = "builtin";
|
|
18
|
+
/** Macros of the builtin particle values and their offsets in the builtin mat4 */
|
|
19
|
+
const PARTICLE_BUILTIN_MACROS = [
|
|
20
|
+
["PARTICLE_POSITION_X", BUILTIN_OFFSET_POSITION_X],
|
|
21
|
+
["PARTICLE_POSITION_Y", BUILTIN_OFFSET_POSITION_Y],
|
|
22
|
+
["PARTICLE_VELOCITY_X", BUILTIN_OFFSET_VELOCITY_X],
|
|
23
|
+
["PARTICLE_VELOCITY_Y", BUILTIN_OFFSET_VELOCITY_Y],
|
|
24
|
+
["PARTICLE_SCALE_X", BUILTIN_OFFSET_SCALE_X],
|
|
25
|
+
["PARTICLE_SCALE_Y", BUILTIN_OFFSET_SCALE_Y],
|
|
26
|
+
["PARTICLE_ROTATION", BUILTIN_OFFSET_ROTATION],
|
|
27
|
+
["PARTICLE_TORQUE", BUILTIN_OFFSET_TORQUE],
|
|
28
|
+
["PARTICLE_LIFETIME", BUILTIN_OFFSET_LIFETIME],
|
|
29
|
+
["PARTICLE_AGE", BUILTIN_OFFSET_AGE],
|
|
30
|
+
["PARTICLE_RANDOM_A", BUILTIN_OFFSET_RANDOM_A],
|
|
31
|
+
["PARTICLE_RANDOM_B", BUILTIN_OFFSET_RANDOM_B],
|
|
32
|
+
["PARTICLE_RANDOM_C", BUILTIN_OFFSET_RANDOM_C],
|
|
33
|
+
["PARTICLE_RANDOM_D", BUILTIN_OFFSET_RANDOM_D],
|
|
34
|
+
["PARTICLE_RANDOM_E", BUILTIN_OFFSET_RANDOM_E],
|
|
35
|
+
["PARTICLE_RANDOM_F", BUILTIN_OFFSET_RANDOM_F],
|
|
36
|
+
];
|
|
15
37
|
export function collectProperties(keeper, modules, debugContext) {
|
|
16
38
|
for (const module of modules) {
|
|
17
39
|
if (module.requiredProperties === undefined) {
|
|
@@ -20,6 +42,9 @@ export function collectProperties(keeper, modules, debugContext) {
|
|
|
20
42
|
for (const key in module.requiredProperties) {
|
|
21
43
|
const existingTypeInfo = keeper[key];
|
|
22
44
|
const newTypeInfo = resolveGLSLTypeInfo(module.requiredProperties[key]);
|
|
45
|
+
if (newTypeInfo.affine === true) {
|
|
46
|
+
throw new Error(`${debugContext}: "${key}" cannot be UIAffineMatrix3 per particle, use Matrix3`);
|
|
47
|
+
}
|
|
23
48
|
if (existingTypeInfo === undefined) {
|
|
24
49
|
keeper[key] = newTypeInfo;
|
|
25
50
|
}
|
|
@@ -44,30 +69,15 @@ export function collectUniforms(keeper, modules, debugContext) {
|
|
|
44
69
|
}
|
|
45
70
|
}
|
|
46
71
|
}
|
|
72
|
+
function builtinComponent(base, index) {
|
|
73
|
+
return `${base}[${Math.floor(index / 4)}].${"xyzw"[index % 4]}`;
|
|
74
|
+
}
|
|
75
|
+
function buildBuiltinMacros(base) {
|
|
76
|
+
return PARTICLE_BUILTIN_MACROS.map(([name, index]) => `#define ${name} ${builtinComponent(base, index)}`).join("\n");
|
|
77
|
+
}
|
|
47
78
|
export function buildParticleVertexShader(uniformDeclarations, attributeDeclarations, varyingDeclarations, vertexAssignments) {
|
|
48
79
|
return `
|
|
49
|
-
|
|
50
|
-
#define PARTICLE_POSITION_X a_builtin[0][0]
|
|
51
|
-
#define PARTICLE_POSITION_Y a_builtin[0][1]
|
|
52
|
-
|
|
53
|
-
#define PARTICLE_VELOCITY_X a_builtin[0][2]
|
|
54
|
-
#define PARTICLE_VELOCITY_Y a_builtin[0][3]
|
|
55
|
-
|
|
56
|
-
#define PARTICLE_SCALE_X a_builtin[1][0]
|
|
57
|
-
#define PARTICLE_SCALE_Y a_builtin[1][1]
|
|
58
|
-
|
|
59
|
-
#define PARTICLE_ROTATION a_builtin[1][2]
|
|
60
|
-
#define PARTICLE_TORQUE a_builtin[1][3]
|
|
61
|
-
|
|
62
|
-
#define PARTICLE_LIFETIME a_builtin[2][0]
|
|
63
|
-
#define PARTICLE_AGE a_builtin[2][1]
|
|
64
|
-
|
|
65
|
-
#define PARTICLE_RANDOM_A a_builtin[2][2]
|
|
66
|
-
#define PARTICLE_RANDOM_B a_builtin[2][3]
|
|
67
|
-
#define PARTICLE_RANDOM_C a_builtin[3][0]
|
|
68
|
-
#define PARTICLE_RANDOM_D a_builtin[3][1]
|
|
69
|
-
#define PARTICLE_RANDOM_E a_builtin[3][2]
|
|
70
|
-
#define PARTICLE_RANDOM_F a_builtin[3][3]
|
|
80
|
+
${buildBuiltinMacros("a_builtin")}
|
|
71
81
|
|
|
72
82
|
// User attributes
|
|
73
83
|
${attributeDeclarations.join("\n")}
|
|
@@ -75,17 +85,12 @@ export function buildParticleVertexShader(uniformDeclarations, attributeDeclarat
|
|
|
75
85
|
// Uniforms
|
|
76
86
|
${uniformDeclarations.join("\n")}
|
|
77
87
|
|
|
78
|
-
//
|
|
79
|
-
varying vec2 p_uv;
|
|
80
|
-
|
|
81
|
-
// User varyings
|
|
88
|
+
// Packed varyings
|
|
82
89
|
${varyingDeclarations.join("\n")}
|
|
83
90
|
|
|
84
91
|
void main() {
|
|
85
92
|
${vertexAssignments.join("\n")}
|
|
86
93
|
|
|
87
|
-
p_uv = uv;
|
|
88
|
-
|
|
89
94
|
vec2 transformedPosition = position.xy;
|
|
90
95
|
transformedPosition.x *= PARTICLE_SCALE_X;
|
|
91
96
|
transformedPosition.y *= PARTICLE_SCALE_Y;
|
|
@@ -106,7 +111,13 @@ export function buildParticleVertexShader(uniformDeclarations, attributeDeclarat
|
|
|
106
111
|
}
|
|
107
112
|
`;
|
|
108
113
|
}
|
|
109
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Builds the fragment shader of a particle mesh. Sources read particle values through the
|
|
116
|
+
* PARTICLE_* macros and properties as p_* globals, all filled from packed varyings.
|
|
117
|
+
* @param fieldDeclarations Packed varyings, p_* globals and PARTICLE_* macros
|
|
118
|
+
* @param fieldAssignments Statements filling the p_* globals at the start of main
|
|
119
|
+
*/
|
|
120
|
+
export function buildParticleFragmentShader(uniformDeclarations, fieldDeclarations, fieldAssignments, sources) {
|
|
110
121
|
const renamedSources = sources.map((source, index) => {
|
|
111
122
|
return source.replace(/vec4\s+draw\s*\(\s*\)/g, `vec4 draw${index}()`);
|
|
112
123
|
});
|
|
@@ -120,38 +131,11 @@ export function buildParticleFragmentShader(uniformDeclarations, varyingDeclarat
|
|
|
120
131
|
#define PI 3.14159265359
|
|
121
132
|
#define SRGB_SUPPORTED ${checkSRGBSupport() ? "1" : "0"}
|
|
122
133
|
|
|
123
|
-
#define PARTICLE_POSITION_X p_builtin[0][0]
|
|
124
|
-
#define PARTICLE_POSITION_Y p_builtin[0][1]
|
|
125
|
-
|
|
126
|
-
#define PARTICLE_VELOCITY_X p_builtin[0][2]
|
|
127
|
-
#define PARTICLE_VELOCITY_Y p_builtin[0][3]
|
|
128
|
-
|
|
129
|
-
#define PARTICLE_SCALE_X p_builtin[1][0]
|
|
130
|
-
#define PARTICLE_SCALE_Y p_builtin[1][1]
|
|
131
|
-
|
|
132
|
-
#define PARTICLE_ROTATION p_builtin[1][2]
|
|
133
|
-
#define PARTICLE_TORQUE p_builtin[1][3]
|
|
134
|
-
|
|
135
|
-
#define PARTICLE_LIFETIME p_builtin[2][0]
|
|
136
|
-
#define PARTICLE_AGE p_builtin[2][1]
|
|
137
|
-
|
|
138
|
-
#define PARTICLE_RANDOM_A p_builtin[2][2]
|
|
139
|
-
#define PARTICLE_RANDOM_B p_builtin[2][3]
|
|
140
|
-
#define PARTICLE_RANDOM_C p_builtin[3][0]
|
|
141
|
-
#define PARTICLE_RANDOM_D p_builtin[3][1]
|
|
142
|
-
#define PARTICLE_RANDOM_E p_builtin[3][2]
|
|
143
|
-
#define PARTICLE_RANDOM_F p_builtin[3][3]
|
|
144
|
-
|
|
145
134
|
// Uniforms
|
|
146
135
|
${uniformDeclarations.join("\n")}
|
|
147
136
|
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// User varyings
|
|
152
|
-
${varyingDeclarations.join("\n")}
|
|
153
|
-
|
|
154
|
-
#include <alphahash_pars_fragment>
|
|
137
|
+
// Packed varyings and the fields read from them
|
|
138
|
+
${fieldDeclarations.join("\n")}
|
|
155
139
|
|
|
156
140
|
// sRGB decode helper
|
|
157
141
|
vec4 srgbTexture2D(sampler2D textureSampler, vec2 uv) {
|
|
@@ -167,15 +151,12 @@ export function buildParticleFragmentShader(uniformDeclarations, varyingDeclarat
|
|
|
167
151
|
${renamedSources.join("\n")}
|
|
168
152
|
|
|
169
153
|
void main() {
|
|
154
|
+
${fieldAssignments.join("\n")}
|
|
155
|
+
|
|
170
156
|
vec4 diffuseColor = ${drawCalls};
|
|
171
157
|
if (diffuseColor.a < 0.0035) {
|
|
172
158
|
discard;
|
|
173
159
|
}
|
|
174
|
-
#ifdef USE_ALPHAHASH
|
|
175
|
-
if (diffuseColor.a < getAlphaHashThreshold(p_position)) {
|
|
176
|
-
discard;
|
|
177
|
-
}
|
|
178
|
-
#endif
|
|
179
160
|
gl_FragColor = linearToOutputTexel(diffuseColor);
|
|
180
161
|
}
|
|
181
162
|
`;
|
|
@@ -184,27 +165,75 @@ export function buildParticleMaterial(sources, uniformProperties, varyingPropert
|
|
|
184
165
|
const uniforms = {};
|
|
185
166
|
const uniformDeclarations = [];
|
|
186
167
|
const attributeDeclarations = [];
|
|
187
|
-
const varyingDeclarations = [];
|
|
188
|
-
const vertexAssignments = [];
|
|
189
168
|
for (const name in uniformProperties) {
|
|
190
169
|
const { value, glslTypeInfo } = uniformProperties[name];
|
|
191
170
|
uniforms[`p_${name}`] = { value: value instanceof UIColor ? value.toGLSLColor() : value };
|
|
192
171
|
uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);
|
|
193
172
|
}
|
|
194
173
|
for (const name in varyingProperties) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
174
|
+
attributeDeclarations.push(`attribute ${varyingProperties[name].glslTypeName} a_${name};`);
|
|
175
|
+
}
|
|
176
|
+
// Only what the fragment shader reads takes varyings. Most sources read a couple of builtin
|
|
177
|
+
// values through the PARTICLE_* macros, so those are passed one by one rather than as the
|
|
178
|
+
// whole builtin mat4; a source naming p_builtin itself gets the whole matrix.
|
|
179
|
+
const unpackedFragment = buildParticleFragmentShader(uniformDeclarations, [], [], sources);
|
|
180
|
+
const fields = [];
|
|
181
|
+
const macroFields = [];
|
|
182
|
+
const wholeBuiltin = isIdentifierReferenced(unpackedFragment, `p_${BUILTIN_PROPERTY}`);
|
|
183
|
+
if (isIdentifierReferenced(unpackedFragment, "p_uv")) {
|
|
184
|
+
fields.push({ name: "p_uv", glslTypeName: "vec2", components: ["uv.x", "uv.y"] });
|
|
185
|
+
}
|
|
186
|
+
for (const name in varyingProperties) {
|
|
187
|
+
const { glslTypeName, bufferSize, columnCount } = varyingProperties[name];
|
|
188
|
+
if (name === BUILTIN_PROPERTY && !wholeBuiltin) {
|
|
189
|
+
for (const [macro, index] of PARTICLE_BUILTIN_MACROS) {
|
|
190
|
+
if (isIdentifierReferenced(unpackedFragment, macro)) {
|
|
191
|
+
fields.push({
|
|
192
|
+
name: macro,
|
|
193
|
+
glslTypeName: "float",
|
|
194
|
+
components: [builtinComponent(`a_${name}`, index)],
|
|
195
|
+
});
|
|
196
|
+
macroFields.push(macro);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (!isIdentifierReferenced(unpackedFragment, `p_${name}`)) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const columnSize = bufferSize / columnCount;
|
|
205
|
+
const components = [];
|
|
206
|
+
for (let i = 0; i < bufferSize; i++) {
|
|
207
|
+
const column = columnCount > 1 ? `a_${name}[${Math.floor(i / columnSize)}]` : `a_${name}`;
|
|
208
|
+
components.push(bufferSize > 1 ? `${column}.${"xyzw"[i % columnSize]}` : column);
|
|
209
|
+
}
|
|
210
|
+
fields.push({ name: `p_${name}`, glslTypeName, components });
|
|
211
|
+
}
|
|
212
|
+
const packed = packVaryings(fields);
|
|
213
|
+
const fieldDeclarations = [...packed.declarations];
|
|
214
|
+
const fieldAssignments = [];
|
|
215
|
+
for (const { name, glslTypeName } of fields) {
|
|
216
|
+
const expression = packed.fragmentExpressions.get(name) ?? "";
|
|
217
|
+
if (macroFields.includes(name)) {
|
|
218
|
+
fieldDeclarations.push(`#define ${name} ${expression}`);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
fieldDeclarations.push(`${glslTypeName} ${name};`);
|
|
222
|
+
fieldAssignments.push(`${name} = ${expression};`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (wholeBuiltin) {
|
|
226
|
+
fieldDeclarations.push(buildBuiltinMacros(`p_${BUILTIN_PROPERTY}`));
|
|
199
227
|
}
|
|
200
|
-
|
|
228
|
+
const material = new ShaderMaterial({
|
|
201
229
|
uniforms,
|
|
202
|
-
vertexShader: buildParticleVertexShader(uniformDeclarations, attributeDeclarations,
|
|
203
|
-
fragmentShader: buildParticleFragmentShader(uniformDeclarations,
|
|
230
|
+
vertexShader: buildParticleVertexShader(uniformDeclarations, attributeDeclarations, packed.declarations, packed.vertexAssignments),
|
|
231
|
+
fragmentShader: buildParticleFragmentShader(uniformDeclarations, fieldDeclarations, fieldAssignments, sources),
|
|
204
232
|
transparent: true,
|
|
205
233
|
side: DoubleSide,
|
|
206
234
|
forceSinglePass: true,
|
|
207
235
|
depthWrite: false,
|
|
208
236
|
depthTest: true,
|
|
209
237
|
});
|
|
238
|
+
return { material, varyingRowCount: packed.rowCount };
|
|
210
239
|
}
|
|
@@ -7,6 +7,7 @@ export declare class UIInstancedParticle extends Mesh {
|
|
|
7
7
|
private readonly shaderMaterial;
|
|
8
8
|
private readonly vertexAttributeCount;
|
|
9
9
|
private readonly vertexAttributeSubject;
|
|
10
|
+
private readonly varyingRowCount;
|
|
10
11
|
private capacity;
|
|
11
12
|
constructor(sources: string[], uniforms: Record<string, GLProperty>, varyings: Record<string, GLTypeInfo>, expectedCapacity: number, capacityStep: number);
|
|
12
13
|
get instanceCount(): number;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { InstancedBufferAttribute, Mesh, StreamDrawUsage } from "three";
|
|
2
|
-
import { assertVertexAttributeBudget } from "../../core/miscellaneous/asserts.js";
|
|
2
|
+
import { assertVaryingBudget, assertVertexAttributeBudget, } from "../../core/miscellaneous/asserts.js";
|
|
3
3
|
import { resolvePropertyUniform } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
4
4
|
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME } from "../miscellaneous/miscellaneous.js";
|
|
5
5
|
import { buildParticleMaterial, INSTANCED_PARTICLE_GEOMETRY } from "./UIInstancedParticle.Internal.js";
|
|
6
6
|
export class UIInstancedParticle extends Mesh {
|
|
7
7
|
constructor(sources, uniforms, varyings, expectedCapacity, capacityStep) {
|
|
8
8
|
const instancedGeometry = INSTANCED_PARTICLE_GEOMETRY.clone();
|
|
9
|
-
const shaderMaterial = buildParticleMaterial(sources, uniforms, varyings);
|
|
9
|
+
const { material: shaderMaterial, varyingRowCount } = buildParticleMaterial(sources, uniforms, varyings);
|
|
10
10
|
super(instancedGeometry, shaderMaterial);
|
|
11
11
|
this.capacityStep = capacityStep;
|
|
12
12
|
this.propertyBuffers = {};
|
|
13
13
|
this.onBeforeRenderInternal = (renderer) => {
|
|
14
14
|
assertVertexAttributeBudget(renderer, this.vertexAttributeCount, this.vertexAttributeSubject);
|
|
15
|
+
assertVaryingBudget(renderer, this.varyingRowCount, this.vertexAttributeSubject);
|
|
15
16
|
};
|
|
16
17
|
this.frustumCulled = false;
|
|
17
18
|
this.matrixAutoUpdate = false;
|
|
@@ -26,6 +27,7 @@ export class UIInstancedParticle extends Mesh {
|
|
|
26
27
|
}
|
|
27
28
|
this.vertexAttributeCount = vertexAttributeCount;
|
|
28
29
|
this.vertexAttributeSubject = `UIInstancedParticle.onBeforeRender.properties (${Object.keys(varyings).join(", ")})`;
|
|
30
|
+
this.varyingRowCount = varyingRowCount;
|
|
29
31
|
this.onBeforeRender = this.onBeforeRenderInternal;
|
|
30
32
|
for (const name in varyings) {
|
|
31
33
|
const { bufferSize } = varyings[name];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UIColor } from "../../core/index.js";
|
|
2
|
+
import type { UIProperty, UIPropertyName } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
2
3
|
import { UIRenderingModule } from "./UIRenderingModule.js";
|
|
3
4
|
/**
|
|
4
5
|
* Colors particles based on lifetime progression.
|
|
@@ -6,6 +7,9 @@ import { UIRenderingModule } from "./UIRenderingModule.js";
|
|
|
6
7
|
* Interpolates through color gradient as particles age from birth to death.
|
|
7
8
|
*/
|
|
8
9
|
export declare class UIRenderingColorOverLife extends UIRenderingModule {
|
|
10
|
+
readonly requiredProperties: Record<string, UIPropertyName>;
|
|
11
|
+
readonly requiredUniforms: Record<string, UIProperty>;
|
|
12
|
+
readonly source: string;
|
|
9
13
|
/**
|
|
10
14
|
* @param colors - Color gradient stops from birth to death
|
|
11
15
|
*/
|
|
@@ -12,11 +12,9 @@ export class UIRenderingColorOverLife extends UIRenderingModule {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(colors) {
|
|
14
14
|
super();
|
|
15
|
-
/** @internal */
|
|
16
15
|
this.requiredProperties = {
|
|
17
16
|
builtin: "Matrix4",
|
|
18
17
|
};
|
|
19
|
-
/** @internal */
|
|
20
18
|
this.source = source;
|
|
21
19
|
if (colors.length === 0) {
|
|
22
20
|
throw new Error("UIRenderingColorOverLife.constructor.colors: colors array cannot be empty");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UIColor } from "../../core/index.js";
|
|
2
|
+
import type { UIProperty, UIPropertyName } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
2
3
|
import { UIRenderingModule } from "./UIRenderingModule.js";
|
|
3
4
|
/**
|
|
4
5
|
* Colors particles based on velocity magnitude.
|
|
@@ -6,6 +7,9 @@ import { UIRenderingModule } from "./UIRenderingModule.js";
|
|
|
6
7
|
* Maps velocity from 0 to maxVelocity across the color gradient.
|
|
7
8
|
*/
|
|
8
9
|
export declare class UIRenderingColorOverVelocity extends UIRenderingModule {
|
|
10
|
+
readonly requiredProperties: Record<string, UIPropertyName>;
|
|
11
|
+
readonly requiredUniforms: Record<string, UIProperty>;
|
|
12
|
+
readonly source: string;
|
|
9
13
|
/**
|
|
10
14
|
* @param colors - Color gradient from slow to fast
|
|
11
15
|
* @param maxVelocity - Velocity mapped to final color
|
|
@@ -13,11 +13,9 @@ export class UIRenderingColorOverVelocity extends UIRenderingModule {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(colors, maxVelocity) {
|
|
15
15
|
super();
|
|
16
|
-
/** @internal */
|
|
17
16
|
this.requiredProperties = {
|
|
18
17
|
builtin: "Matrix4",
|
|
19
18
|
};
|
|
20
|
-
/** @internal */
|
|
21
19
|
this.source = source;
|
|
22
20
|
if (colors.length === 0) {
|
|
23
21
|
throw new Error("UIRenderingColorOverVelocity.constructor.colors: colors array cannot be empty");
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import type { UIProperty, UIPropertyName } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
1
2
|
/**
|
|
2
3
|
* Base class for particle rendering modules.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
+
* The source defines `vec4 draw()`; the colors of all rendering modules are multiplied. It reads
|
|
6
|
+
* `p_uv`, uniforms and properties as `p_<name>`, and builtin values through the `PARTICLE_*`
|
|
7
|
+
* macros, which are cheaper than reading `p_builtin` as a whole.
|
|
5
8
|
*/
|
|
6
9
|
export declare abstract class UIRenderingModule {
|
|
10
|
+
/** Per-particle properties the source reads, by name and type */
|
|
11
|
+
readonly requiredProperties?: Record<string, UIPropertyName>;
|
|
12
|
+
/** Uniforms the source reads, as `p_<name>` */
|
|
13
|
+
abstract readonly requiredUniforms: Record<string, UIProperty>;
|
|
14
|
+
/** GLSL source defining `vec4 draw()` */
|
|
15
|
+
abstract readonly source: string;
|
|
7
16
|
destroy?(): void;
|
|
8
17
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base class for particle rendering modules.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The source defines `vec4 draw()`; the colors of all rendering modules are multiplied. It reads
|
|
5
|
+
* `p_uv`, uniforms and properties as `p_<name>`, and builtin values through the `PARTICLE_*`
|
|
6
|
+
* macros, which are cheaper than reading `p_builtin` as a whole.
|
|
5
7
|
*/
|
|
6
8
|
export class UIRenderingModule {
|
|
7
9
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UIProperty, UIPropertyName } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
1
2
|
import type { UITextureConfig } from "../../core/miscellaneous/texture/UITextureView.Internal.js";
|
|
2
3
|
import { UIRenderingModule } from "./UIRenderingModule.js";
|
|
3
4
|
/**
|
|
@@ -8,6 +9,9 @@ import { UIRenderingModule } from "./UIRenderingModule.js";
|
|
|
8
9
|
* All configs in the array must share the same underlying Three.js Texture object.
|
|
9
10
|
*/
|
|
10
11
|
export declare class UIRenderingTexture extends UIRenderingModule {
|
|
12
|
+
readonly requiredProperties?: Record<string, UIPropertyName>;
|
|
13
|
+
readonly requiredUniforms: Record<string, UIProperty>;
|
|
14
|
+
readonly source: string;
|
|
11
15
|
/**
|
|
12
16
|
* @param config - Single texture config or array of configs (same atlas required for arrays)
|
|
13
17
|
*/
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIPropertyName } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
2
3
|
/**
|
|
3
4
|
* Base class for particle spawn modules.
|
|
4
5
|
*
|
|
5
|
-
* Spawn modules initialize particle properties when particles are created.
|
|
6
|
+
* Spawn modules initialize particle properties when particles are created. Declare the
|
|
7
|
+
* per-particle properties the module writes in `requiredProperties`, usually
|
|
8
|
+
* `{ builtin: "Matrix4" }` (laid out by the BUILTIN_OFFSET_* constants), and fill them in `spawn`.
|
|
6
9
|
*/
|
|
7
10
|
export declare abstract class UISpawnModule<T extends Record<string, UIPropertyName> = Record<string, UIPropertyName>> {
|
|
11
|
+
/** Per-particle properties the module writes, by name and type */
|
|
12
|
+
abstract readonly requiredProperties: T;
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the particles in [instanceBegin, instanceEnd).
|
|
15
|
+
* @param properties Per-particle buffers of the required properties
|
|
16
|
+
*/
|
|
17
|
+
abstract spawn(properties: {
|
|
18
|
+
[K in keyof T]: InstancedBufferAttribute;
|
|
19
|
+
}, instanceBegin: number, instanceEnd: number): void;
|
|
8
20
|
destroy?(): void;
|
|
9
21
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base class for particle spawn modules.
|
|
3
3
|
*
|
|
4
|
-
* Spawn modules initialize particle properties when particles are created.
|
|
4
|
+
* Spawn modules initialize particle properties when particles are created. Declare the
|
|
5
|
+
* per-particle properties the module writes in `requiredProperties`, usually
|
|
6
|
+
* `{ builtin: "Matrix4" }` (laid out by the BUILTIN_OFFSET_* constants), and fill them in `spawn`.
|
|
5
7
|
*/
|
|
6
8
|
export class UISpawnModule {
|
|
7
9
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { Vector2Like } from "../../core/miscellaneous/math.js";
|
|
2
3
|
import type { UIVector2Config } from "../miscellaneous/miscellaneous.js";
|
|
3
4
|
import { UISpawnModule } from "./UISpawnModule.js";
|
|
@@ -9,6 +10,9 @@ import { UISpawnModule } from "./UISpawnModule.js";
|
|
|
9
10
|
export declare class UISpawnOffset extends UISpawnModule<{
|
|
10
11
|
builtin: "Matrix4";
|
|
11
12
|
}> {
|
|
13
|
+
readonly requiredProperties: {
|
|
14
|
+
readonly builtin: "Matrix4";
|
|
15
|
+
};
|
|
12
16
|
private offsetInternal;
|
|
13
17
|
/**
|
|
14
18
|
* @param offset - Initial particle position offset
|
|
@@ -18,4 +22,7 @@ export declare class UISpawnOffset extends UISpawnModule<{
|
|
|
18
22
|
get offset(): Vector2Like;
|
|
19
23
|
/** Particle position offset */
|
|
20
24
|
set offset(value: UIVector2Config);
|
|
25
|
+
spawn(properties: {
|
|
26
|
+
builtin: InstancedBufferAttribute;
|
|
27
|
+
}, instanceBegin: number, instanceEnd: number): void;
|
|
21
28
|
}
|
|
@@ -12,7 +12,6 @@ export class UISpawnOffset extends UISpawnModule {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(offset = { x: 0, y: 0 }) {
|
|
14
14
|
super();
|
|
15
|
-
/** @internal */
|
|
16
15
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
17
16
|
this.offsetInternal = resolveUIVector2Config(offset);
|
|
18
17
|
assertValidNumber(this.offsetInternal.x, "UISpawnOffset.constructor.offset.x");
|
|
@@ -28,7 +27,6 @@ export class UISpawnOffset extends UISpawnModule {
|
|
|
28
27
|
assertValidNumber(this.offsetInternal.x, "UISpawnOffset.offset.x");
|
|
29
28
|
assertValidNumber(this.offsetInternal.y, "UISpawnOffset.offset.y");
|
|
30
29
|
}
|
|
31
|
-
/** @internal */
|
|
32
30
|
spawn(properties, instanceBegin, instanceEnd) {
|
|
33
31
|
const { builtin } = properties;
|
|
34
32
|
const { array, itemSize } = builtin;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UISpawnModule } from "./UISpawnModule.js";
|
|
3
4
|
/**
|
|
@@ -8,6 +9,9 @@ import { UISpawnModule } from "./UISpawnModule.js";
|
|
|
8
9
|
export declare class UISpawnRandomLifetime extends UISpawnModule<{
|
|
9
10
|
builtin: "Matrix4";
|
|
10
11
|
}> {
|
|
12
|
+
readonly requiredProperties: {
|
|
13
|
+
readonly builtin: "Matrix4";
|
|
14
|
+
};
|
|
11
15
|
private lifetimeInternal;
|
|
12
16
|
/**
|
|
13
17
|
* @param lifetime - Lifetime range in seconds. Accepts number, tuple, or range object
|
|
@@ -17,4 +21,7 @@ export declare class UISpawnRandomLifetime extends UISpawnModule<{
|
|
|
17
21
|
get lifetime(): UIRange;
|
|
18
22
|
/** Lifetime range in seconds */
|
|
19
23
|
set lifetime(value: UIRangeConfig);
|
|
24
|
+
spawn(properties: {
|
|
25
|
+
builtin: InstancedBufferAttribute;
|
|
26
|
+
}, instanceBegin: number, instanceEnd: number): void;
|
|
20
27
|
}
|
|
@@ -13,7 +13,6 @@ export class UISpawnRandomLifetime extends UISpawnModule {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(lifetime = { min: 4, max: 8 }) {
|
|
15
15
|
super();
|
|
16
|
-
/** @internal */
|
|
17
16
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
17
|
this.lifetimeInternal = resolveUIRangeConfig(lifetime);
|
|
19
18
|
assertValidPositiveNumber(this.lifetimeInternal.min, "UISpawnRandomLifetime.constructor.lifetime.min");
|
|
@@ -29,7 +28,6 @@ export class UISpawnRandomLifetime extends UISpawnModule {
|
|
|
29
28
|
assertValidPositiveNumber(this.lifetimeInternal.min, "UISpawnRandomLifetime.lifetime.min");
|
|
30
29
|
assertValidPositiveNumber(this.lifetimeInternal.max, "UISpawnRandomLifetime.lifetime.max");
|
|
31
30
|
}
|
|
32
|
-
/** @internal */
|
|
33
31
|
spawn(properties, instanceBegin, instanceEnd) {
|
|
34
32
|
const { builtin } = properties;
|
|
35
33
|
const { array, itemSize } = builtin;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UISpawnModule } from "./UISpawnModule.js";
|
|
3
4
|
/**
|
|
@@ -8,6 +9,9 @@ import { UISpawnModule } from "./UISpawnModule.js";
|
|
|
8
9
|
export declare class UISpawnRandomRotation extends UISpawnModule<{
|
|
9
10
|
builtin: "Matrix4";
|
|
10
11
|
}> {
|
|
12
|
+
requiredProperties: {
|
|
13
|
+
readonly builtin: "Matrix4";
|
|
14
|
+
};
|
|
11
15
|
private rotationInternal;
|
|
12
16
|
/**
|
|
13
17
|
* @param rotation - Rotation range in radians. Accepts number, tuple, or range object
|
|
@@ -17,4 +21,7 @@ export declare class UISpawnRandomRotation extends UISpawnModule<{
|
|
|
17
21
|
get rotation(): UIRange;
|
|
18
22
|
/** Rotation range in radians */
|
|
19
23
|
set rotation(value: UIRangeConfig);
|
|
24
|
+
spawn(properties: {
|
|
25
|
+
builtin: InstancedBufferAttribute;
|
|
26
|
+
}, instanceBegin: number, instanceEnd: number): void;
|
|
20
27
|
}
|
|
@@ -13,7 +13,6 @@ export class UISpawnRandomRotation extends UISpawnModule {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(rotation = { min: -Math.PI, max: Math.PI }) {
|
|
15
15
|
super();
|
|
16
|
-
/** @internal */
|
|
17
16
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
17
|
this.rotationInternal = resolveUIRangeConfig(rotation);
|
|
19
18
|
assertValidNumber(this.rotationInternal.min, "UISpawnRandomRotation.constructor.rotation.min");
|
|
@@ -29,7 +28,6 @@ export class UISpawnRandomRotation extends UISpawnModule {
|
|
|
29
28
|
assertValidNumber(this.rotationInternal.min, "UISpawnRandomRotation.rotation.min");
|
|
30
29
|
assertValidNumber(this.rotationInternal.max, "UISpawnRandomRotation.rotation.max");
|
|
31
30
|
}
|
|
32
|
-
/** @internal */
|
|
33
31
|
spawn(properties, instanceBegin, instanceEnd) {
|
|
34
32
|
const { builtin } = properties;
|
|
35
33
|
const { array, itemSize } = builtin;
|