laymur 0.26.0 → 0.27.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 +79 -35
- package/dist/core/constraints/UICustomConstraint.d.ts +1 -1
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +1 -1
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +1 -1
- package/dist/core/constraints/builders/UIConstraint2DBuilder.d.ts +2 -3
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.d.ts +2 -2
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +24 -12
- package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +10 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +42 -5
- package/dist/core/elements/UIDummy/UIDummy.js +119 -25
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +1 -1
- package/dist/core/elements/UIElement/UIElement.d.ts +14 -0
- package/dist/core/elements/UIElement/UIElement.js +34 -3
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +1 -1
- package/dist/core/elements/UIGraphics/UIGraphics.d.ts +1 -1
- package/dist/core/elements/UIGraphics/UIGraphics.js +2 -2
- package/dist/core/elements/UIImage/UIImage.d.ts +2 -2
- package/dist/core/elements/UIImage/UIImage.js +10 -8
- package/dist/core/elements/UINineSlice/UINineSlice.d.ts +4 -4
- package/dist/core/elements/UINineSlice/UINineSlice.js +11 -9
- package/dist/core/elements/UIProgress/UIProgress.d.ts +2 -2
- package/dist/core/elements/UIProgress/UIProgress.js +15 -10
- package/dist/core/elements/UIScene/UIScene.Internal.d.ts +1 -1
- package/dist/core/elements/UIScene/UIScene.d.ts +3 -2
- package/dist/core/elements/UIScene/UIScene.js +18 -12
- package/dist/core/elements/UIText/UIText.Measuring.d.ts +1 -1
- package/dist/core/elements/UIText/UIText.d.ts +3 -3
- package/dist/core/elements/UIText/UIText.js +6 -6
- package/dist/core/index.d.ts +44 -41
- package/dist/core/index.js +12 -9
- package/dist/core/layers/UILayer/UILayer.d.ts +40 -4
- package/dist/core/layers/UILayer/UILayer.js +70 -9
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.Internal.d.ts +27 -0
- package/dist/core/layers/{UIFullscreenLayer/UIFullscreenLayer.Internal.js → UIViewportLayer/UIViewportLayer.Internal.js} +1 -1
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.d.ts +98 -0
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +251 -0
- package/dist/core/miscellaneous/asserts.d.ts +14 -0
- package/dist/core/miscellaneous/asserts.js +28 -0
- package/dist/core/miscellaneous/canvas.js +7 -2
- package/dist/core/miscellaneous/color/UIColor.js +4 -2
- package/dist/core/miscellaneous/computeTransform.d.ts +12 -0
- package/dist/core/miscellaneous/computeTransform.js +20 -0
- package/dist/core/miscellaneous/context-monitor/UIContextMonitor.d.ts +1 -0
- package/dist/core/miscellaneous/context-monitor/UIContextMonitor.js +60 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.d.ts +7 -4
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +13 -6
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +2 -2
- package/dist/core/miscellaneous/text-style/UITextStyle.js +2 -2
- package/dist/core/miscellaneous/texture/UITextureView.d.ts +4 -1
- package/dist/core/miscellaneous/texture/UITextureView.js +10 -7
- package/dist/core/miscellaneous/viewport/UIElementViewport.d.ts +31 -0
- package/dist/core/miscellaneous/viewport/UIElementViewport.js +54 -0
- package/dist/core/miscellaneous/viewport/UIViewport.d.ts +37 -0
- package/dist/core/miscellaneous/viewport/UIViewport.js +31 -0
- package/dist/core/miscellaneous/viewport/UIWindowViewport.d.ts +13 -0
- package/dist/core/miscellaneous/viewport/UIWindowViewport.js +25 -0
- package/dist/core/miscellaneous/webglCapabilities.js +61 -55
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +36 -5
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +23 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +153 -15
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +2 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +3 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +36 -16
- package/dist/debug/UIAspectDebug.js +4 -0
- package/dist/debug/UIHeightDebug.js +4 -0
- package/dist/debug/UIHorizontalDistanceDebug.js +5 -0
- package/dist/debug/UIHorizontalInterpolationDebug.js +5 -0
- package/dist/debug/UILayerDebug.d.ts +7 -0
- package/dist/debug/UILayerDebug.js +21 -0
- package/dist/debug/UIVerticalDistanceDebug.js +5 -0
- package/dist/debug/UIVerticalInterpolationDebug.js +5 -0
- package/dist/debug/UIWidthDebug.js +4 -0
- package/dist/debug/index.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +5 -1
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +2 -2
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +13 -10
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +6 -4
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +4 -3
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +2 -2
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +8 -8
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +4 -3
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +8 -5
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +8 -8
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +7 -5
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +12 -8
- package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -2
- package/dist/particles/elements/UIEmitter.Internal.js +6 -0
- package/dist/particles/elements/UIEmitter.d.ts +19 -3
- package/dist/particles/elements/UIEmitter.js +100 -54
- package/dist/particles/index.d.ts +3 -2
- package/dist/particles/index.js +1 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +8 -2
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +16 -11
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +7 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +37 -2
- package/dist/particles/miscellaneous/miscellaneous.d.ts +34 -0
- package/dist/particles/miscellaneous/miscellaneous.js +72 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +2 -2
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +2 -3
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +3 -2
- package/dist/particles/renderingModules/UIRenderingModule.js +2 -1
- package/dist/particles/renderingModules/UIRenderingTexture.js +2 -1
- package/dist/particles/shaders/UIRenderingColorOverLife.d.ts +1 -2
- package/dist/particles/shaders/UIRenderingColorOverLife.js +5 -3
- package/dist/particles/shaders/UIRenderingColorOverVelocity.d.ts +1 -9
- package/dist/particles/shaders/UIRenderingColorOverVelocity.js +6 -13
- package/dist/particles/spawnModules/UISpawnModule.d.ts +5 -2
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +2 -2
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +5 -5
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +5 -3
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomScale.js +4 -3
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +5 -3
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +6 -4
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnRectangle.js +6 -4
- package/package.json +13 -4
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -21
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +0 -144
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
|
-
import { assertValidNumber } from "../../core/miscellaneous/asserts.js";
|
|
3
|
-
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y,
|
|
2
|
+
import { assertValidNumber, assertValidPositiveNumber } from "../../core/miscellaneous/asserts.js";
|
|
3
|
+
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, particleRandom, particleRandomStream, resolveUIRangeConfig, resolveUIVector2Config, } from "../miscellaneous/miscellaneous.js";
|
|
4
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
5
|
/**
|
|
6
6
|
* Applies gravity attraction toward a point.
|
|
@@ -27,8 +27,8 @@ export class UIBehaviorPointGravity extends UIBehaviorModule {
|
|
|
27
27
|
assertValidNumber(this.exponentInternal.min, "UIBehaviorPointGravity.constructor.exponent.min");
|
|
28
28
|
assertValidNumber(this.exponentInternal.max, "UIBehaviorPointGravity.constructor.exponent.max");
|
|
29
29
|
this.thresholdInternal = resolveUIRangeConfig(threshold);
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
assertValidPositiveNumber(this.thresholdInternal.min, "UIBehaviorPointGravity.constructor.threshold.min");
|
|
31
|
+
assertValidPositiveNumber(this.thresholdInternal.max, "UIBehaviorPointGravity.constructor.threshold.max");
|
|
32
32
|
}
|
|
33
33
|
/** Gravity center position */
|
|
34
34
|
get center() {
|
|
@@ -67,26 +67,29 @@ export class UIBehaviorPointGravity extends UIBehaviorModule {
|
|
|
67
67
|
/** Minimum distance range */
|
|
68
68
|
set threshold(value) {
|
|
69
69
|
this.thresholdInternal = resolveUIRangeConfig(value);
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
assertValidPositiveNumber(this.thresholdInternal.min, "UIBehaviorPointGravity.threshold.min");
|
|
71
|
+
assertValidPositiveNumber(this.thresholdInternal.max, "UIBehaviorPointGravity.threshold.max");
|
|
72
72
|
}
|
|
73
|
-
update(properties, instanceCount, deltaTime) {
|
|
73
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
74
74
|
const { builtin } = properties;
|
|
75
75
|
const { array, itemSize } = builtin;
|
|
76
|
+
const thresholdStream = particleRandomStream(randomSalt, 0);
|
|
77
|
+
const strengthStream = particleRandomStream(randomSalt, 1);
|
|
78
|
+
const exponentStream = particleRandomStream(randomSalt, 2);
|
|
76
79
|
for (let i = 0; i < instanceCount; i++) {
|
|
77
80
|
const itemOffset = i * itemSize;
|
|
78
81
|
const dx = this.centerInternal.x - array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
79
82
|
const dy = this.centerInternal.y - array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
80
|
-
const thresholdT = array
|
|
83
|
+
const thresholdT = particleRandom(array, itemOffset, thresholdStream);
|
|
81
84
|
const threshold = MathUtils.lerp(this.threshold.min, this.threshold.max, thresholdT);
|
|
82
85
|
const thresholdSquared = threshold * threshold;
|
|
83
86
|
const distanceSquared = dx * dx + dy * dy;
|
|
84
87
|
if (distanceSquared < thresholdSquared) {
|
|
85
88
|
continue;
|
|
86
89
|
}
|
|
87
|
-
const strengthT = array
|
|
90
|
+
const strengthT = particleRandom(array, itemOffset, strengthStream);
|
|
88
91
|
const strength = MathUtils.lerp(this.strengthInternal.min, this.strengthInternal.max, strengthT);
|
|
89
|
-
const exponentT = array
|
|
92
|
+
const exponentT = particleRandom(array, itemOffset, exponentStream);
|
|
90
93
|
const exponent = MathUtils.lerp(this.exponentInternal.min, this.exponentInternal.max, exponentT);
|
|
91
94
|
const distance = Math.sqrt(distanceSquared);
|
|
92
95
|
const forceMagnitude = strength / Math.pow(distance, exponent);
|
|
@@ -44,5 +44,5 @@ export declare class UIBehaviorScaleOscillation extends UIBehaviorModule<{
|
|
|
44
44
|
set aspect(value: UIAspectConfig);
|
|
45
45
|
update(properties: {
|
|
46
46
|
builtin: InstancedBufferAttribute;
|
|
47
|
-
}, instanceCount: number): void;
|
|
47
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
48
48
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
2
|
import { assertValidNonNegativeNumber, assertValidPositiveNumber, } from "../../core/miscellaneous/asserts.js";
|
|
3
|
-
import { BUILTIN_OFFSET_AGE,
|
|
3
|
+
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, particleRandom, particleRandomStream, resolveAspect, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
4
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
5
|
/**
|
|
6
6
|
* Oscillates particle scale along one axis, like a paper piece turning its edge to the viewer.
|
|
@@ -61,14 +61,16 @@ export class UIBehaviorScaleOscillation extends UIBehaviorModule {
|
|
|
61
61
|
this.aspectInternal = resolveAspect(value);
|
|
62
62
|
assertValidPositiveNumber(this.aspectInternal, "UIBehaviorScaleOscillation.aspect");
|
|
63
63
|
}
|
|
64
|
-
update(properties, instanceCount) {
|
|
64
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
65
65
|
const { builtin } = properties;
|
|
66
66
|
const { array, itemSize } = builtin;
|
|
67
|
+
const frequencyStream = particleRandomStream(randomSalt, 0);
|
|
68
|
+
const phaseStream = particleRandomStream(randomSalt, 1);
|
|
67
69
|
for (let i = 0; i < instanceCount; i++) {
|
|
68
70
|
const itemOffset = i * itemSize;
|
|
69
|
-
const frequencyT = array
|
|
71
|
+
const frequencyT = particleRandom(array, itemOffset, frequencyStream);
|
|
70
72
|
const frequency = MathUtils.lerp(this.frequencyInternal.min, this.frequencyInternal.max, frequencyT);
|
|
71
|
-
const phase = array
|
|
73
|
+
const phase = particleRandom(array, itemOffset, phaseStream) * Math.PI * 2;
|
|
72
74
|
const angle = array[itemOffset + BUILTIN_OFFSET_AGE] * frequency * Math.PI * 2 + phase;
|
|
73
75
|
const factor = 1 - this.depthInternal * (1 - Math.cos(angle));
|
|
74
76
|
if (this.axisInternal === "x") {
|
|
@@ -25,5 +25,5 @@ export declare class UIBehaviorScaleOverLife extends UIBehaviorModule<{
|
|
|
25
25
|
set aspect(value: UIAspectConfig);
|
|
26
26
|
update(properties: {
|
|
27
27
|
builtin: InstancedBufferAttribute;
|
|
28
|
-
}, instanceCount: number): void;
|
|
28
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
29
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
2
|
import { assertValidNonNegativeNumber, assertValidPositiveNumber, } from "../../core/miscellaneous/asserts.js";
|
|
3
|
-
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME,
|
|
3
|
+
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, particleRandom, particleRandomStream, resolveAspect, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
4
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
5
|
/**
|
|
6
6
|
* Animates particle scale over lifetime.
|
|
@@ -37,15 +37,16 @@ export class UIBehaviorScaleOverLife extends UIBehaviorModule {
|
|
|
37
37
|
this.aspectInternal = resolveAspect(value);
|
|
38
38
|
assertValidPositiveNumber(this.aspectInternal, "UIBehaviorScaleOverLife.aspect");
|
|
39
39
|
}
|
|
40
|
-
update(properties, instanceCount) {
|
|
40
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
41
41
|
const { builtin } = properties;
|
|
42
42
|
const { array, itemSize } = builtin;
|
|
43
|
+
const scaleStream = particleRandomStream(randomSalt, 0);
|
|
43
44
|
for (let i = 0; i < instanceCount; i++) {
|
|
44
45
|
const itemOffset = i * itemSize;
|
|
45
46
|
const lifeT = Math.min(array[itemOffset + BUILTIN_OFFSET_AGE] / array[itemOffset + BUILTIN_OFFSET_LIFETIME], 1);
|
|
46
47
|
const segment = (this.scales.length - 1) * lifeT;
|
|
47
48
|
const index = Math.floor(segment);
|
|
48
|
-
const scaleT = array
|
|
49
|
+
const scaleT = particleRandom(array, itemOffset, scaleStream);
|
|
49
50
|
const localT = segment - index;
|
|
50
51
|
const scaleRange0 = this.scales[index];
|
|
51
52
|
const scaleRange1 = this.scales[index + 1];
|
|
@@ -16,12 +16,12 @@ export declare class UIBehaviorTorqueDamping extends UIBehaviorModule<{
|
|
|
16
16
|
/**
|
|
17
17
|
* @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
|
|
18
18
|
*/
|
|
19
|
-
constructor(damping:
|
|
19
|
+
constructor(damping: UIRangeConfig);
|
|
20
20
|
/** Damping coefficient range (0-1) */
|
|
21
21
|
get damping(): UIRange;
|
|
22
22
|
/** Damping coefficient range (0-1) */
|
|
23
23
|
set damping(value: UIRangeConfig);
|
|
24
24
|
update(properties: {
|
|
25
25
|
builtin: InstancedBufferAttribute;
|
|
26
|
-
}, instanceCount: number, deltaTime: number): void;
|
|
26
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
27
27
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
|
-
import {
|
|
3
|
-
import { BUILTIN_OFFSET_RANDOM_E, BUILTIN_OFFSET_TORQUE, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
2
|
+
import { assertValidUnitNumber, BUILTIN_OFFSET_TORQUE, particleRandom, particleRandomStream, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
4
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
4
|
/**
|
|
6
5
|
* Reduces particle angular velocity over time.
|
|
@@ -15,8 +14,8 @@ export class UIBehaviorTorqueDamping extends UIBehaviorModule {
|
|
|
15
14
|
super();
|
|
16
15
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
17
16
|
this.dampingInternal = resolveUIRangeConfig(damping);
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorTorqueDamping.constructor.damping.min`);
|
|
18
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorTorqueDamping.constructor.damping.max`);
|
|
20
19
|
}
|
|
21
20
|
/** Damping coefficient range (0-1) */
|
|
22
21
|
get damping() {
|
|
@@ -25,15 +24,16 @@ export class UIBehaviorTorqueDamping extends UIBehaviorModule {
|
|
|
25
24
|
/** Damping coefficient range (0-1) */
|
|
26
25
|
set damping(value) {
|
|
27
26
|
this.dampingInternal = resolveUIRangeConfig(value);
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorTorqueDamping.damping.min`);
|
|
28
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorTorqueDamping.damping.max`);
|
|
30
29
|
}
|
|
31
|
-
update(properties, instanceCount, deltaTime) {
|
|
30
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
32
31
|
const { builtin } = properties;
|
|
33
32
|
const { array, itemSize } = builtin;
|
|
33
|
+
const dampingStream = particleRandomStream(randomSalt, 0);
|
|
34
34
|
for (let i = 0; i < instanceCount; i++) {
|
|
35
35
|
const itemOffset = i * itemSize;
|
|
36
|
-
const dampingT = array
|
|
36
|
+
const dampingT = particleRandom(array, itemOffset, dampingStream);
|
|
37
37
|
const dampingFactor = Math.pow(1 - MathUtils.lerp(this.dampingInternal.min, this.dampingInternal.max, dampingT), deltaTime);
|
|
38
38
|
array[itemOffset + BUILTIN_OFFSET_TORQUE] *= dampingFactor;
|
|
39
39
|
}
|
|
@@ -4,7 +4,8 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Applies noise-based angular acceleration to particles.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* The noise is sampled at the particle position times scale, so 1 / scale is the size of a noise
|
|
8
|
+
* detail in layer units; around 0.005 gives a smooth change over a few hundred units.
|
|
8
9
|
*/
|
|
9
10
|
export declare class UIBehaviorTorqueNoise extends UIBehaviorModule<{
|
|
10
11
|
builtin: "Matrix4";
|
|
@@ -18,7 +19,7 @@ export declare class UIBehaviorTorqueNoise extends UIBehaviorModule<{
|
|
|
18
19
|
* @param scale - Noise frequency range. Accepts number, tuple, or range object
|
|
19
20
|
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
20
21
|
*/
|
|
21
|
-
constructor(scale:
|
|
22
|
+
constructor(scale: UIRangeConfig, strength: UIRangeConfig);
|
|
22
23
|
/** Noise frequency range */
|
|
23
24
|
get scale(): UIRange;
|
|
24
25
|
/** Force multiplier range */
|
|
@@ -29,5 +30,5 @@ export declare class UIBehaviorTorqueNoise extends UIBehaviorModule<{
|
|
|
29
30
|
set strength(value: UIRangeConfig);
|
|
30
31
|
update(properties: {
|
|
31
32
|
builtin: InstancedBufferAttribute;
|
|
32
|
-
}, instanceCount: number, deltaTime: number): void;
|
|
33
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
33
34
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
2
|
import { assertValidNonNegativeNumber, assertValidPositiveNumber, } from "../../core/miscellaneous/asserts.js";
|
|
3
|
-
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y,
|
|
3
|
+
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_TORQUE, generateNoise2D, particleRandom, particleRandomStream, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
4
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
5
|
/**
|
|
6
6
|
* Applies noise-based angular acceleration to particles.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The noise is sampled at the particle position times scale, so 1 / scale is the size of a noise
|
|
9
|
+
* detail in layer units; around 0.005 gives a smooth change over a few hundred units.
|
|
9
10
|
*/
|
|
10
11
|
export class UIBehaviorTorqueNoise extends UIBehaviorModule {
|
|
11
12
|
/**
|
|
@@ -42,15 +43,17 @@ export class UIBehaviorTorqueNoise extends UIBehaviorModule {
|
|
|
42
43
|
assertValidNonNegativeNumber(this.strengthInternal.min, `UIBehaviorTorqueNoise.strength.min`);
|
|
43
44
|
assertValidNonNegativeNumber(this.strengthInternal.max, `UIBehaviorTorqueNoise.strength.max`);
|
|
44
45
|
}
|
|
45
|
-
update(properties, instanceCount, deltaTime) {
|
|
46
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
46
47
|
const { builtin } = properties;
|
|
47
48
|
const { array, itemSize } = builtin;
|
|
49
|
+
const scaleStream = particleRandomStream(randomSalt, 0);
|
|
50
|
+
const strengthStream = particleRandomStream(randomSalt, 1);
|
|
48
51
|
for (let i = 0; i < instanceCount; i++) {
|
|
49
52
|
const itemOffset = i * itemSize;
|
|
50
|
-
const scaleT = array
|
|
53
|
+
const scaleT = particleRandom(array, itemOffset, scaleStream);
|
|
51
54
|
const scale = MathUtils.lerp(this.scaleInternal.min, this.scaleInternal.max, scaleT);
|
|
52
55
|
const noise = generateNoise2D(array[itemOffset + BUILTIN_OFFSET_POSITION_X] * scale, array[itemOffset + BUILTIN_OFFSET_POSITION_Y] * scale);
|
|
53
|
-
const strengthT = array
|
|
56
|
+
const strengthT = particleRandom(array, itemOffset, strengthStream);
|
|
54
57
|
const strength = MathUtils.lerp(this.strengthInternal.min, this.strengthInternal.max, strengthT);
|
|
55
58
|
array[itemOffset + BUILTIN_OFFSET_TORQUE] += noise * strength * deltaTime;
|
|
56
59
|
}
|
|
@@ -23,5 +23,5 @@ export declare class UIBehaviorVelocityDamping extends UIBehaviorModule<{
|
|
|
23
23
|
set damping(value: UIRangeConfig);
|
|
24
24
|
update(properties: {
|
|
25
25
|
builtin: InstancedBufferAttribute;
|
|
26
|
-
}, instanceCount: number, deltaTime: number): void;
|
|
26
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
27
27
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
|
-
import {
|
|
3
|
-
import { BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
2
|
+
import { assertValidUnitNumber, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, particleRandom, particleRandomStream, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
4
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
4
|
/**
|
|
6
5
|
* Reduces particle velocity over time.
|
|
@@ -15,8 +14,8 @@ export class UIBehaviorVelocityDamping extends UIBehaviorModule {
|
|
|
15
14
|
super();
|
|
16
15
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
17
16
|
this.dampingInternal = resolveUIRangeConfig(damping);
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorVelocityDamping.constructor.damping.min`);
|
|
18
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorVelocityDamping.constructor.damping.max`);
|
|
20
19
|
}
|
|
21
20
|
/** Damping coefficient range (0-1) */
|
|
22
21
|
get damping() {
|
|
@@ -25,15 +24,16 @@ export class UIBehaviorVelocityDamping extends UIBehaviorModule {
|
|
|
25
24
|
/** Damping coefficient range (0-1) */
|
|
26
25
|
set damping(value) {
|
|
27
26
|
this.dampingInternal = resolveUIRangeConfig(value);
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorVelocityDamping.damping.min`);
|
|
28
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorVelocityDamping.damping.max`);
|
|
30
29
|
}
|
|
31
|
-
update(properties, instanceCount, deltaTime) {
|
|
30
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
32
31
|
const { builtin } = properties;
|
|
33
32
|
const { array, itemSize } = builtin;
|
|
33
|
+
const dampingStream = particleRandomStream(randomSalt, 0);
|
|
34
34
|
for (let i = 0; i < instanceCount; i++) {
|
|
35
35
|
const itemOffset = i * itemSize;
|
|
36
|
-
const dampingT = array
|
|
36
|
+
const dampingT = particleRandom(array, itemOffset, dampingStream);
|
|
37
37
|
const dampingFactor = Math.pow(1 - MathUtils.lerp(this.dampingInternal.min, this.dampingInternal.max, dampingT), deltaTime);
|
|
38
38
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] *= dampingFactor;
|
|
39
39
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] *= dampingFactor;
|
|
@@ -2,9 +2,11 @@ import type { InstancedBufferAttribute } from "three";
|
|
|
2
2
|
import { type UIRange, type UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
3
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
4
4
|
/**
|
|
5
|
-
* Applies noise-based acceleration to particles.
|
|
5
|
+
* Applies noise-based acceleration to particles: a still flow field that particles drift through.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* The noise is sampled at the particle position times scale, so 1 / scale is the size of a noise
|
|
8
|
+
* detail in layer units. A detail much smaller than the distance a particle moves in a frame
|
|
9
|
+
* turns the drift into jitter.
|
|
8
10
|
*/
|
|
9
11
|
export declare class UIBehaviorVelocityNoise extends UIBehaviorModule<{
|
|
10
12
|
builtin: "Matrix4";
|
|
@@ -15,10 +17,10 @@ export declare class UIBehaviorVelocityNoise extends UIBehaviorModule<{
|
|
|
15
17
|
private scaleInternal;
|
|
16
18
|
private strengthInternal;
|
|
17
19
|
/**
|
|
18
|
-
* @param scale - Noise frequency range. Accepts number, tuple, or range object
|
|
20
|
+
* @param scale - Noise frequency range in 1 / layer units. Accepts number, tuple, or range object
|
|
19
21
|
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
20
22
|
*/
|
|
21
|
-
constructor(scale?:
|
|
23
|
+
constructor(scale?: UIRangeConfig, strength?: UIRangeConfig);
|
|
22
24
|
/** Noise frequency range */
|
|
23
25
|
get scale(): UIRange;
|
|
24
26
|
/** Force multiplier range */
|
|
@@ -29,5 +31,5 @@ export declare class UIBehaviorVelocityNoise extends UIBehaviorModule<{
|
|
|
29
31
|
set strength(value: UIRangeConfig);
|
|
30
32
|
update(properties: {
|
|
31
33
|
builtin: InstancedBufferAttribute;
|
|
32
|
-
}, instanceCount: number, deltaTime: number): void;
|
|
34
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
33
35
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
2
|
import { assertValidNonNegativeNumber, assertValidPositiveNumber, } from "../../core/miscellaneous/asserts.js";
|
|
3
|
-
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y,
|
|
3
|
+
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, generateNoise2D, particleRandom, particleRandomStream, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
4
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
5
|
/**
|
|
6
|
-
* Applies noise-based acceleration to particles.
|
|
6
|
+
* Applies noise-based acceleration to particles: a still flow field that particles drift through.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The noise is sampled at the particle position times scale, so 1 / scale is the size of a noise
|
|
9
|
+
* detail in layer units. A detail much smaller than the distance a particle moves in a frame
|
|
10
|
+
* turns the drift into jitter.
|
|
9
11
|
*/
|
|
10
12
|
export class UIBehaviorVelocityNoise extends UIBehaviorModule {
|
|
11
13
|
/**
|
|
12
|
-
* @param scale - Noise frequency range. Accepts number, tuple, or range object
|
|
14
|
+
* @param scale - Noise frequency range in 1 / layer units. Accepts number, tuple, or range object
|
|
13
15
|
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
14
16
|
*/
|
|
15
|
-
constructor(scale =
|
|
17
|
+
constructor(scale = 0.005, strength = 500) {
|
|
16
18
|
super();
|
|
17
19
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
20
|
this.scaleInternal = resolveUIRangeConfig(scale);
|
|
@@ -42,18 +44,20 @@ export class UIBehaviorVelocityNoise extends UIBehaviorModule {
|
|
|
42
44
|
assertValidNonNegativeNumber(this.strengthInternal.min, `UIBehaviorVelocityNoise.strength.min`);
|
|
43
45
|
assertValidNonNegativeNumber(this.strengthInternal.max, `UIBehaviorVelocityNoise.strength.max`);
|
|
44
46
|
}
|
|
45
|
-
update(properties, instanceCount, deltaTime) {
|
|
47
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
46
48
|
const { builtin } = properties;
|
|
47
49
|
const { array, itemSize } = builtin;
|
|
50
|
+
const scaleStream = particleRandomStream(randomSalt, 0);
|
|
51
|
+
const strengthStream = particleRandomStream(randomSalt, 1);
|
|
48
52
|
for (let i = 0; i < instanceCount; i++) {
|
|
49
53
|
const itemOffset = i * itemSize;
|
|
50
54
|
const x = array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
51
55
|
const y = array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
52
|
-
const scaleT = array
|
|
56
|
+
const scaleT = particleRandom(array, itemOffset, scaleStream);
|
|
53
57
|
const scale = MathUtils.lerp(this.scaleInternal.min, this.scaleInternal.max, scaleT);
|
|
54
58
|
const noiseX = generateNoise2D(x * scale, y * scale);
|
|
55
59
|
const noiseY = generateNoise2D((x + 100) * scale, (y + 100) * scale);
|
|
56
|
-
const strengthT = array
|
|
60
|
+
const strengthT = particleRandom(array, itemOffset, strengthStream);
|
|
57
61
|
const strength = MathUtils.lerp(this.strengthInternal.min, this.strengthInternal.max, strengthT);
|
|
58
62
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += noiseX * strength * deltaTime;
|
|
59
63
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += noiseY * strength * deltaTime;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { UIMode } from "../../core/index.js";
|
|
2
1
|
import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal.js";
|
|
2
|
+
import { UIMode } from "../../core/index.js";
|
|
3
3
|
/** Configuration options for UIEmitter */
|
|
4
4
|
export interface UIEmitterOptions extends UIAnchorOptions {
|
|
5
5
|
/** Whether the particles are drawn */
|
|
6
6
|
mode: UIEmitterMode;
|
|
7
7
|
/** Number of particles to allocate for up front; a hint, not a limit */
|
|
8
8
|
expectedCapacity: number;
|
|
9
|
-
/**
|
|
9
|
+
/** Capacity is kept a multiple of this; the buffers double when they grow */
|
|
10
10
|
capacityStep: number;
|
|
11
|
+
/** Longest frame step in seconds; longer frames, such as after a hidden tab, are clamped */
|
|
12
|
+
maxDeltaTime: number;
|
|
13
|
+
/**
|
|
14
|
+
* Seed of the random values, a non-negative integer. Emitters with one seed and one sequence
|
|
15
|
+
* of spawns produce the same particles. Random by default.
|
|
16
|
+
*/
|
|
17
|
+
seed: number;
|
|
11
18
|
/** Whether to call destroy() on all modules when the emitter is destroyed */
|
|
12
19
|
automaticallyDestroyModules: boolean;
|
|
13
20
|
}
|
|
@@ -19,4 +26,10 @@ export type UIEmitterMode = UIMode.HIDDEN | UIMode.VISIBLE;
|
|
|
19
26
|
export declare const EMITTER_DEFAULT_MODE: UIEmitterMode;
|
|
20
27
|
export declare const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
21
28
|
export declare const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
29
|
+
export declare const EMITTER_DEFAULT_MAX_DELTA_TIME = 0.1;
|
|
30
|
+
export declare const EMITTER_DEFAULT_LIFETIME = 1;
|
|
22
31
|
export declare const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
32
|
+
/** Salts the emitter hands out: one for the builtin values the shaders read, one per module */
|
|
33
|
+
export declare const EMITTER_SHADER_SALT = 0;
|
|
34
|
+
export declare const EMITTER_SPAWN_SALT_BASE = 256;
|
|
35
|
+
export declare const EMITTER_BEHAVIOR_SALT_BASE = 512;
|
|
@@ -5,4 +5,10 @@ export function ignoreInput() {
|
|
|
5
5
|
export const EMITTER_DEFAULT_MODE = UIMode.VISIBLE;
|
|
6
6
|
export const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
7
7
|
export const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
8
|
+
export const EMITTER_DEFAULT_MAX_DELTA_TIME = 0.1;
|
|
9
|
+
export const EMITTER_DEFAULT_LIFETIME = 1;
|
|
8
10
|
export const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
11
|
+
/** Salts the emitter hands out: one for the builtin values the shaders read, one per module */
|
|
12
|
+
export const EMITTER_SHADER_SALT = 0;
|
|
13
|
+
export const EMITTER_SPAWN_SALT_BASE = 0x100;
|
|
14
|
+
export const EMITTER_BEHAVIOR_SALT_BASE = 0x200;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UILayer } from "../../core/index.js";
|
|
2
1
|
import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor.js";
|
|
2
|
+
import type { UILayer } from "../../core/index.js";
|
|
3
3
|
import type { UIBehaviorModule } from "../behaviorModules/UIBehaviorModule.js";
|
|
4
4
|
import type { UIRenderingModule } from "../renderingModules/UIRenderingModule.js";
|
|
5
5
|
import type { UISpawnModule } from "../spawnModules/UISpawnModule.js";
|
|
@@ -22,6 +22,10 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
22
22
|
private emissionDuration;
|
|
23
23
|
private emissionElapsed;
|
|
24
24
|
private modeInternal;
|
|
25
|
+
private maxDeltaTimeInternal;
|
|
26
|
+
private seedInternal;
|
|
27
|
+
/** Particles spawned since the seed was set; picks the seed of the next particle */
|
|
28
|
+
private spawnedCount;
|
|
25
29
|
/**
|
|
26
30
|
* @param layer - Layer containing this emitter
|
|
27
31
|
* @param spawnSequence - Modules that initialize new particles
|
|
@@ -30,6 +34,10 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
30
34
|
* @param options - Configuration options
|
|
31
35
|
*/
|
|
32
36
|
constructor(layer: UILayer, spawnSequence: UISpawnModule[], behaviorSequence: readonly UIBehaviorModule[], renderingSequence: readonly UIRenderingModule[], options?: Partial<UIEmitterOptions>);
|
|
37
|
+
/** Seed of the random values */
|
|
38
|
+
get seed(): number;
|
|
39
|
+
/** Longest frame step in seconds; longer frames are clamped */
|
|
40
|
+
get maxDeltaTime(): number;
|
|
33
41
|
/** Visibility mode */
|
|
34
42
|
get mode(): UIEmitterMode;
|
|
35
43
|
/**
|
|
@@ -39,15 +47,23 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
39
47
|
get zIndex(): number;
|
|
40
48
|
/** Visibility mode */
|
|
41
49
|
set mode(value: UIEmitterMode);
|
|
50
|
+
/** Longest frame step in seconds; longer frames are clamped */
|
|
51
|
+
set maxDeltaTime(value: number);
|
|
52
|
+
/**
|
|
53
|
+
* Sets the seed and restarts its sequence: the next particles repeat those spawned after the
|
|
54
|
+
* same seed was set before
|
|
55
|
+
*/
|
|
56
|
+
set seed(value: number);
|
|
42
57
|
/**
|
|
43
58
|
* Rendering order among the elements of the layer. Higher values on top; elements with equal
|
|
44
59
|
* values keep the order of creation, a later one on top.
|
|
45
60
|
*/
|
|
46
61
|
set zIndex(value: number);
|
|
47
62
|
/**
|
|
48
|
-
* Spawns a specific number of particles immediately.
|
|
63
|
+
* Spawns a specific number of particles immediately. Before the spawn modules run, every
|
|
64
|
+
* property of a new particle is 0, except scale 1 and lifetime 1 second.
|
|
49
65
|
*
|
|
50
|
-
* @param count - Number of particles to create
|
|
66
|
+
* @param count - Number of particles to create, a non-negative integer
|
|
51
67
|
*/
|
|
52
68
|
burst(count: number): void;
|
|
53
69
|
/** Removes all active particles */
|