laymur 0.25.2 → 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 +114 -34
- 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/UIAnchor/UIAnchor.d.ts +2 -2
- package/dist/core/elements/UIAnchor/UIAnchor.js +3 -2
- 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 +13 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +74 -5
- package/dist/core/elements/UIDummy/UIDummy.js +222 -29
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +1 -1
- package/dist/core/elements/UIElement/UIElement.d.ts +37 -1
- package/dist/core/elements/UIElement/UIElement.js +84 -6
- 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 +4 -4
- 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 +17 -15
- 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 +21 -14
- 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 +8 -8
- package/dist/core/index.d.ts +60 -11
- package/dist/core/index.js +22 -7
- package/dist/core/layers/UILayer/UILayer.d.ts +45 -5
- package/dist/core/layers/UILayer/UILayer.js +103 -10
- 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/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 +23 -0
- package/dist/core/miscellaneous/asserts.js +44 -0
- package/dist/core/miscellaneous/canvas.js +7 -2
- package/dist/core/miscellaneous/color/UIColor.js +5 -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.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 +19 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +16 -3
- 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 +6 -2
- package/dist/core/miscellaneous/texture/UITextureView.js +13 -9
- 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/shaders/UIMask.d.ts +15 -0
- package/dist/core/shaders/UIMask.js +45 -0
- 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 +3 -1
- 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 +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 +2 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +8 -1
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +12 -2
- package/dist/particles/behaviorModules/UIBehaviorModule.js +2 -1
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +8 -1
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +13 -12
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +6 -6
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +4 -5
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +8 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +8 -10
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +10 -2
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +8 -7
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +8 -10
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +13 -4
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +12 -10
- package/dist/particles/elements/UIEmitter.Internal.d.ts +21 -1
- package/dist/particles/elements/UIEmitter.Internal.js +6 -0
- package/dist/particles/elements/UIEmitter.d.ts +20 -11
- package/dist/particles/elements/UIEmitter.js +100 -54
- package/dist/particles/index.d.ts +7 -1
- package/dist/particles/index.js +4 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +19 -4
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +117 -83
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +8 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +41 -4
- package/dist/particles/miscellaneous/miscellaneous.d.ts +34 -0
- package/dist/particles/miscellaneous/miscellaneous.js +72 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +4 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +2 -4
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +4 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +2 -5
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +11 -1
- package/dist/particles/renderingModules/UIRenderingModule.js +4 -1
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +4 -0
- 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 +16 -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 +8 -1
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +5 -7
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +5 -5
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.js +4 -5
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +5 -5
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +6 -6
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRectangle.js +6 -6
- 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,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 { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
@@ -9,13 +10,19 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
|
9
10
|
export declare class UIBehaviorDirectionalGravity extends UIBehaviorModule<{
|
|
10
11
|
builtin: "Matrix4";
|
|
11
12
|
}> {
|
|
13
|
+
readonly requiredProperties: {
|
|
14
|
+
readonly builtin: "Matrix4";
|
|
15
|
+
};
|
|
12
16
|
private directionInternal;
|
|
13
17
|
/**
|
|
14
18
|
* @param direction - Acceleration vector in units/second^2
|
|
15
19
|
*/
|
|
16
|
-
constructor(direction:
|
|
20
|
+
constructor(direction: UIVector2Config);
|
|
17
21
|
/** Acceleration vector in units/second^2 */
|
|
18
22
|
get direction(): Vector2Like;
|
|
19
23
|
/** Acceleration vector in units/second^2 */
|
|
20
24
|
set direction(value: UIVector2Config);
|
|
25
|
+
update(properties: {
|
|
26
|
+
builtin: InstancedBufferAttribute;
|
|
27
|
+
}, instanceCount: number, deltaTime: number): void;
|
|
21
28
|
}
|
|
@@ -12,7 +12,6 @@ export class UIBehaviorDirectionalGravity extends UIBehaviorModule {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(direction) {
|
|
14
14
|
super();
|
|
15
|
-
/** @internal */
|
|
16
15
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
17
16
|
this.directionInternal = resolveUIVector2Config(direction);
|
|
18
17
|
assertValidNumber(this.directionInternal.x, "UIBehaviorDirectionalGravity.constructor.direction.x");
|
|
@@ -28,7 +27,6 @@ export class UIBehaviorDirectionalGravity extends UIBehaviorModule {
|
|
|
28
27
|
assertValidNumber(this.directionInternal.x, "UIBehaviorDirectionalGravity.direction.x");
|
|
29
28
|
assertValidNumber(this.directionInternal.y, "UIBehaviorDirectionalGravity.direction.y");
|
|
30
29
|
}
|
|
31
|
-
/** @internal */
|
|
32
30
|
update(properties, instanceCount, deltaTime) {
|
|
33
31
|
const { builtin } = properties;
|
|
34
32
|
const { array, itemSize } = builtin;
|
|
@@ -3,12 +3,22 @@ import type { UIPropertyName } from "../../core/miscellaneous/generic-plane/shar
|
|
|
3
3
|
/**
|
|
4
4
|
* Base class for particle behavior modules.
|
|
5
5
|
*
|
|
6
|
-
* Behavior modules update particle properties each frame.
|
|
6
|
+
* Behavior modules update particle properties each frame. Declare the per-particle properties
|
|
7
|
+
* the module touches in `requiredProperties` and change them in `update`.
|
|
7
8
|
*/
|
|
8
9
|
export declare abstract class UIBehaviorModule<T extends Record<string, UIPropertyName> = Record<string, UIPropertyName>> {
|
|
10
|
+
/** Per-particle properties the module reads and writes, by name and type */
|
|
9
11
|
abstract readonly requiredProperties: T;
|
|
12
|
+
/**
|
|
13
|
+
* Advances the particles in [0, instanceCount) by deltaTime seconds.
|
|
14
|
+
* @param properties Per-particle buffers of the required properties
|
|
15
|
+
* @param instanceCount Number of live particles
|
|
16
|
+
* @param deltaTime Frame step in seconds
|
|
17
|
+
* @param randomSalt Salt for `particleRandomStream`: random values of the module are
|
|
18
|
+
* independent of those of other modules, also of another instance of the same module
|
|
19
|
+
*/
|
|
10
20
|
abstract update(properties: {
|
|
11
21
|
[K in keyof T]: InstancedBufferAttribute;
|
|
12
|
-
}, instanceCount: number, deltaTime: number): void;
|
|
22
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
13
23
|
destroy?(): void;
|
|
14
24
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base class for particle behavior modules.
|
|
3
3
|
*
|
|
4
|
-
* Behavior modules update particle properties each frame.
|
|
4
|
+
* Behavior modules update particle properties each frame. Declare the per-particle properties
|
|
5
|
+
* the module touches in `requiredProperties` and change them in `update`.
|
|
5
6
|
*/
|
|
6
7
|
export class UIBehaviorModule {
|
|
7
8
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { Vector2Like } from "../../core/miscellaneous/math.js";
|
|
2
3
|
import { type UIRange, type UIRangeConfig, type UIVector2Config } from "../miscellaneous/miscellaneous.js";
|
|
3
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
@@ -9,6 +10,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
|
9
10
|
export declare class UIBehaviorPointGravity extends UIBehaviorModule<{
|
|
10
11
|
builtin: "Matrix4";
|
|
11
12
|
}> {
|
|
13
|
+
readonly requiredProperties: {
|
|
14
|
+
readonly builtin: "Matrix4";
|
|
15
|
+
};
|
|
12
16
|
private centerInternal;
|
|
13
17
|
private strengthInternal;
|
|
14
18
|
private exponentInternal;
|
|
@@ -19,7 +23,7 @@ export declare class UIBehaviorPointGravity extends UIBehaviorModule<{
|
|
|
19
23
|
* @param exponent - Distance power exponent range. Accepts number, tuple, or range object
|
|
20
24
|
* @param threshold - Minimum distance range. Accepts number, tuple, or range object
|
|
21
25
|
*/
|
|
22
|
-
constructor(center:
|
|
26
|
+
constructor(center: UIVector2Config, strength: UIRangeConfig, exponent?: UIRangeConfig, threshold?: UIRangeConfig);
|
|
23
27
|
/** Gravity center position */
|
|
24
28
|
get center(): Vector2Like;
|
|
25
29
|
/** Force multiplier range */
|
|
@@ -36,4 +40,7 @@ export declare class UIBehaviorPointGravity extends UIBehaviorModule<{
|
|
|
36
40
|
set exponent(value: UIRangeConfig);
|
|
37
41
|
/** Minimum distance range */
|
|
38
42
|
set threshold(value: UIRangeConfig);
|
|
43
|
+
update(properties: {
|
|
44
|
+
builtin: InstancedBufferAttribute;
|
|
45
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
39
46
|
}
|
|
@@ -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.
|
|
@@ -16,7 +16,6 @@ export class UIBehaviorPointGravity extends UIBehaviorModule {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(center, strength, exponent = 2, threshold = 1) {
|
|
18
18
|
super();
|
|
19
|
-
/** @internal */
|
|
20
19
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
21
20
|
this.centerInternal = resolveUIVector2Config(center);
|
|
22
21
|
assertValidNumber(this.centerInternal.x, "UIBehaviorPointGravity.constructor.center.x");
|
|
@@ -28,8 +27,8 @@ export class UIBehaviorPointGravity extends UIBehaviorModule {
|
|
|
28
27
|
assertValidNumber(this.exponentInternal.min, "UIBehaviorPointGravity.constructor.exponent.min");
|
|
29
28
|
assertValidNumber(this.exponentInternal.max, "UIBehaviorPointGravity.constructor.exponent.max");
|
|
30
29
|
this.thresholdInternal = resolveUIRangeConfig(threshold);
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
assertValidPositiveNumber(this.thresholdInternal.min, "UIBehaviorPointGravity.constructor.threshold.min");
|
|
31
|
+
assertValidPositiveNumber(this.thresholdInternal.max, "UIBehaviorPointGravity.constructor.threshold.max");
|
|
33
32
|
}
|
|
34
33
|
/** Gravity center position */
|
|
35
34
|
get center() {
|
|
@@ -68,27 +67,29 @@ export class UIBehaviorPointGravity extends UIBehaviorModule {
|
|
|
68
67
|
/** Minimum distance range */
|
|
69
68
|
set threshold(value) {
|
|
70
69
|
this.thresholdInternal = resolveUIRangeConfig(value);
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
assertValidPositiveNumber(this.thresholdInternal.min, "UIBehaviorPointGravity.threshold.min");
|
|
71
|
+
assertValidPositiveNumber(this.thresholdInternal.max, "UIBehaviorPointGravity.threshold.max");
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
update(properties, instanceCount, deltaTime) {
|
|
73
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
76
74
|
const { builtin } = properties;
|
|
77
75
|
const { array, itemSize } = builtin;
|
|
76
|
+
const thresholdStream = particleRandomStream(randomSalt, 0);
|
|
77
|
+
const strengthStream = particleRandomStream(randomSalt, 1);
|
|
78
|
+
const exponentStream = particleRandomStream(randomSalt, 2);
|
|
78
79
|
for (let i = 0; i < instanceCount; i++) {
|
|
79
80
|
const itemOffset = i * itemSize;
|
|
80
81
|
const dx = this.centerInternal.x - array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
81
82
|
const dy = this.centerInternal.y - array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
82
|
-
const thresholdT = array
|
|
83
|
+
const thresholdT = particleRandom(array, itemOffset, thresholdStream);
|
|
83
84
|
const threshold = MathUtils.lerp(this.threshold.min, this.threshold.max, thresholdT);
|
|
84
85
|
const thresholdSquared = threshold * threshold;
|
|
85
86
|
const distanceSquared = dx * dx + dy * dy;
|
|
86
87
|
if (distanceSquared < thresholdSquared) {
|
|
87
88
|
continue;
|
|
88
89
|
}
|
|
89
|
-
const strengthT = array
|
|
90
|
+
const strengthT = particleRandom(array, itemOffset, strengthStream);
|
|
90
91
|
const strength = MathUtils.lerp(this.strengthInternal.min, this.strengthInternal.max, strengthT);
|
|
91
|
-
const exponentT = array
|
|
92
|
+
const exponentT = particleRandom(array, itemOffset, exponentStream);
|
|
92
93
|
const exponent = MathUtils.lerp(this.exponentInternal.min, this.exponentInternal.max, exponentT);
|
|
93
94
|
const distance = Math.sqrt(distanceSquared);
|
|
94
95
|
const forceMagnitude = strength / Math.pow(distance, exponent);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIAspectConfig, UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
3
4
|
/** Axis whose scale oscillates */
|
|
@@ -13,6 +14,9 @@ export type UIScaleOscillationAxis = "x" | "y";
|
|
|
13
14
|
export declare class UIBehaviorScaleOscillation extends UIBehaviorModule<{
|
|
14
15
|
builtin: "Matrix4";
|
|
15
16
|
}> {
|
|
17
|
+
readonly requiredProperties: {
|
|
18
|
+
readonly builtin: "Matrix4";
|
|
19
|
+
};
|
|
16
20
|
private readonly axisInternal;
|
|
17
21
|
private frequencyInternal;
|
|
18
22
|
private depthInternal;
|
|
@@ -38,4 +42,7 @@ export declare class UIBehaviorScaleOscillation extends UIBehaviorModule<{
|
|
|
38
42
|
set depth(value: number);
|
|
39
43
|
/** Width/height aspect ratio */
|
|
40
44
|
set aspect(value: UIAspectConfig);
|
|
45
|
+
update(properties: {
|
|
46
|
+
builtin: InstancedBufferAttribute;
|
|
47
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
41
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.
|
|
@@ -19,7 +19,6 @@ export class UIBehaviorScaleOscillation extends UIBehaviorModule {
|
|
|
19
19
|
*/
|
|
20
20
|
constructor(axis, frequency, depth = 1, aspect = 1) {
|
|
21
21
|
super();
|
|
22
|
-
/** @internal */
|
|
23
22
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
24
23
|
this.axisInternal = axis;
|
|
25
24
|
this.frequencyInternal = resolveUIRangeConfig(frequency);
|
|
@@ -62,15 +61,16 @@ export class UIBehaviorScaleOscillation extends UIBehaviorModule {
|
|
|
62
61
|
this.aspectInternal = resolveAspect(value);
|
|
63
62
|
assertValidPositiveNumber(this.aspectInternal, "UIBehaviorScaleOscillation.aspect");
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
update(properties, instanceCount) {
|
|
64
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
67
65
|
const { builtin } = properties;
|
|
68
66
|
const { array, itemSize } = builtin;
|
|
67
|
+
const frequencyStream = particleRandomStream(randomSalt, 0);
|
|
68
|
+
const phaseStream = particleRandomStream(randomSalt, 1);
|
|
69
69
|
for (let i = 0; i < instanceCount; i++) {
|
|
70
70
|
const itemOffset = i * itemSize;
|
|
71
|
-
const frequencyT = array
|
|
71
|
+
const frequencyT = particleRandom(array, itemOffset, frequencyStream);
|
|
72
72
|
const frequency = MathUtils.lerp(this.frequencyInternal.min, this.frequencyInternal.max, frequencyT);
|
|
73
|
-
const phase = array
|
|
73
|
+
const phase = particleRandom(array, itemOffset, phaseStream) * Math.PI * 2;
|
|
74
74
|
const angle = array[itemOffset + BUILTIN_OFFSET_AGE] * frequency * Math.PI * 2 + phase;
|
|
75
75
|
const factor = 1 - this.depthInternal * (1 - Math.cos(angle));
|
|
76
76
|
if (this.axisInternal === "x") {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIAspectConfig, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
3
4
|
/**
|
|
@@ -8,6 +9,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
|
8
9
|
export declare class UIBehaviorScaleOverLife extends UIBehaviorModule<{
|
|
9
10
|
builtin: "Matrix4";
|
|
10
11
|
}> {
|
|
12
|
+
readonly requiredProperties: {
|
|
13
|
+
readonly builtin: "Matrix4";
|
|
14
|
+
};
|
|
11
15
|
private readonly scales;
|
|
12
16
|
private aspectInternal;
|
|
13
17
|
/**
|
|
@@ -19,4 +23,7 @@ export declare class UIBehaviorScaleOverLife extends UIBehaviorModule<{
|
|
|
19
23
|
get aspect(): number;
|
|
20
24
|
/** Width/height aspect ratio */
|
|
21
25
|
set aspect(value: UIAspectConfig);
|
|
26
|
+
update(properties: {
|
|
27
|
+
builtin: InstancedBufferAttribute;
|
|
28
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
22
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.
|
|
@@ -14,7 +14,6 @@ export class UIBehaviorScaleOverLife extends UIBehaviorModule {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(scales, aspect = 1) {
|
|
16
16
|
super();
|
|
17
|
-
/** @internal */
|
|
18
17
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
19
18
|
this.scales = [];
|
|
20
19
|
if (scales.length < 2) {
|
|
@@ -38,16 +37,16 @@ export class UIBehaviorScaleOverLife extends UIBehaviorModule {
|
|
|
38
37
|
this.aspectInternal = resolveAspect(value);
|
|
39
38
|
assertValidPositiveNumber(this.aspectInternal, "UIBehaviorScaleOverLife.aspect");
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
update(properties, instanceCount) {
|
|
40
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
43
41
|
const { builtin } = properties;
|
|
44
42
|
const { array, itemSize } = builtin;
|
|
43
|
+
const scaleStream = particleRandomStream(randomSalt, 0);
|
|
45
44
|
for (let i = 0; i < instanceCount; i++) {
|
|
46
45
|
const itemOffset = i * itemSize;
|
|
47
46
|
const lifeT = Math.min(array[itemOffset + BUILTIN_OFFSET_AGE] / array[itemOffset + BUILTIN_OFFSET_LIFETIME], 1);
|
|
48
47
|
const segment = (this.scales.length - 1) * lifeT;
|
|
49
48
|
const index = Math.floor(segment);
|
|
50
|
-
const scaleT = array
|
|
49
|
+
const scaleT = particleRandom(array, itemOffset, scaleStream);
|
|
51
50
|
const localT = segment - index;
|
|
52
51
|
const scaleRange0 = this.scales[index];
|
|
53
52
|
const scaleRange1 = this.scales[index + 1];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
3
4
|
/**
|
|
@@ -8,13 +9,19 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
|
8
9
|
export declare class UIBehaviorTorqueDamping extends UIBehaviorModule<{
|
|
9
10
|
builtin: "Matrix4";
|
|
10
11
|
}> {
|
|
12
|
+
readonly requiredProperties: {
|
|
13
|
+
readonly builtin: "Matrix4";
|
|
14
|
+
};
|
|
11
15
|
private dampingInternal;
|
|
12
16
|
/**
|
|
13
17
|
* @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
|
|
14
18
|
*/
|
|
15
|
-
constructor(damping:
|
|
19
|
+
constructor(damping: UIRangeConfig);
|
|
16
20
|
/** Damping coefficient range (0-1) */
|
|
17
21
|
get damping(): UIRange;
|
|
18
22
|
/** Damping coefficient range (0-1) */
|
|
19
23
|
set damping(value: UIRangeConfig);
|
|
24
|
+
update(properties: {
|
|
25
|
+
builtin: InstancedBufferAttribute;
|
|
26
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
20
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.
|
|
@@ -13,11 +12,10 @@ export class UIBehaviorTorqueDamping extends UIBehaviorModule {
|
|
|
13
12
|
*/
|
|
14
13
|
constructor(damping) {
|
|
15
14
|
super();
|
|
16
|
-
/** @internal */
|
|
17
15
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
16
|
this.dampingInternal = resolveUIRangeConfig(damping);
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorTorqueDamping.constructor.damping.min`);
|
|
18
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorTorqueDamping.constructor.damping.max`);
|
|
21
19
|
}
|
|
22
20
|
/** Damping coefficient range (0-1) */
|
|
23
21
|
get damping() {
|
|
@@ -26,16 +24,16 @@ export class UIBehaviorTorqueDamping extends UIBehaviorModule {
|
|
|
26
24
|
/** Damping coefficient range (0-1) */
|
|
27
25
|
set damping(value) {
|
|
28
26
|
this.dampingInternal = resolveUIRangeConfig(value);
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorTorqueDamping.damping.min`);
|
|
28
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorTorqueDamping.damping.max`);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
update(properties, instanceCount, deltaTime) {
|
|
30
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
34
31
|
const { builtin } = properties;
|
|
35
32
|
const { array, itemSize } = builtin;
|
|
33
|
+
const dampingStream = particleRandomStream(randomSalt, 0);
|
|
36
34
|
for (let i = 0; i < instanceCount; i++) {
|
|
37
35
|
const itemOffset = i * itemSize;
|
|
38
|
-
const dampingT = array
|
|
36
|
+
const dampingT = particleRandom(array, itemOffset, dampingStream);
|
|
39
37
|
const dampingFactor = Math.pow(1 - MathUtils.lerp(this.dampingInternal.min, this.dampingInternal.max, dampingT), deltaTime);
|
|
40
38
|
array[itemOffset + BUILTIN_OFFSET_TORQUE] *= dampingFactor;
|
|
41
39
|
}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
3
4
|
/**
|
|
4
5
|
* Applies noise-based angular acceleration to particles.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
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.
|
|
7
9
|
*/
|
|
8
10
|
export declare class UIBehaviorTorqueNoise extends UIBehaviorModule<{
|
|
9
11
|
builtin: "Matrix4";
|
|
10
12
|
}> {
|
|
13
|
+
readonly requiredProperties: {
|
|
14
|
+
readonly builtin: "Matrix4";
|
|
15
|
+
};
|
|
11
16
|
private scaleInternal;
|
|
12
17
|
private strengthInternal;
|
|
13
18
|
/**
|
|
14
19
|
* @param scale - Noise frequency range. Accepts number, tuple, or range object
|
|
15
20
|
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
16
21
|
*/
|
|
17
|
-
constructor(scale:
|
|
22
|
+
constructor(scale: UIRangeConfig, strength: UIRangeConfig);
|
|
18
23
|
/** Noise frequency range */
|
|
19
24
|
get scale(): UIRange;
|
|
20
25
|
/** Force multiplier range */
|
|
@@ -23,4 +28,7 @@ export declare class UIBehaviorTorqueNoise extends UIBehaviorModule<{
|
|
|
23
28
|
set scale(value: UIRangeConfig);
|
|
24
29
|
/** Force multiplier range */
|
|
25
30
|
set strength(value: UIRangeConfig);
|
|
31
|
+
update(properties: {
|
|
32
|
+
builtin: InstancedBufferAttribute;
|
|
33
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
26
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
|
/**
|
|
@@ -14,7 +15,6 @@ export class UIBehaviorTorqueNoise extends UIBehaviorModule {
|
|
|
14
15
|
*/
|
|
15
16
|
constructor(scale, strength) {
|
|
16
17
|
super();
|
|
17
|
-
/** @internal */
|
|
18
18
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
19
19
|
this.scaleInternal = resolveUIRangeConfig(scale);
|
|
20
20
|
assertValidPositiveNumber(this.scaleInternal.min, `UIBehaviorTorqueNoise.constructor.scale.min`);
|
|
@@ -43,16 +43,17 @@ export class UIBehaviorTorqueNoise extends UIBehaviorModule {
|
|
|
43
43
|
assertValidNonNegativeNumber(this.strengthInternal.min, `UIBehaviorTorqueNoise.strength.min`);
|
|
44
44
|
assertValidNonNegativeNumber(this.strengthInternal.max, `UIBehaviorTorqueNoise.strength.max`);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
update(properties, instanceCount, deltaTime) {
|
|
46
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
48
47
|
const { builtin } = properties;
|
|
49
48
|
const { array, itemSize } = builtin;
|
|
49
|
+
const scaleStream = particleRandomStream(randomSalt, 0);
|
|
50
|
+
const strengthStream = particleRandomStream(randomSalt, 1);
|
|
50
51
|
for (let i = 0; i < instanceCount; i++) {
|
|
51
52
|
const itemOffset = i * itemSize;
|
|
52
|
-
const scaleT = array
|
|
53
|
+
const scaleT = particleRandom(array, itemOffset, scaleStream);
|
|
53
54
|
const scale = MathUtils.lerp(this.scaleInternal.min, this.scaleInternal.max, scaleT);
|
|
54
55
|
const noise = generateNoise2D(array[itemOffset + BUILTIN_OFFSET_POSITION_X] * scale, array[itemOffset + BUILTIN_OFFSET_POSITION_Y] * scale);
|
|
55
|
-
const strengthT = array
|
|
56
|
+
const strengthT = particleRandom(array, itemOffset, strengthStream);
|
|
56
57
|
const strength = MathUtils.lerp(this.strengthInternal.min, this.strengthInternal.max, strengthT);
|
|
57
58
|
array[itemOffset + BUILTIN_OFFSET_TORQUE] += noise * strength * deltaTime;
|
|
58
59
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
3
4
|
/**
|
|
@@ -8,6 +9,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
|
8
9
|
export declare class UIBehaviorVelocityDamping extends UIBehaviorModule<{
|
|
9
10
|
builtin: "Matrix4";
|
|
10
11
|
}> {
|
|
12
|
+
readonly requiredProperties: {
|
|
13
|
+
readonly builtin: "Matrix4";
|
|
14
|
+
};
|
|
11
15
|
private dampingInternal;
|
|
12
16
|
/**
|
|
13
17
|
* @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
|
|
@@ -17,4 +21,7 @@ export declare class UIBehaviorVelocityDamping extends UIBehaviorModule<{
|
|
|
17
21
|
get damping(): UIRange;
|
|
18
22
|
/** Damping coefficient range (0-1) */
|
|
19
23
|
set damping(value: UIRangeConfig);
|
|
24
|
+
update(properties: {
|
|
25
|
+
builtin: InstancedBufferAttribute;
|
|
26
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
20
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.
|
|
@@ -13,11 +12,10 @@ export class UIBehaviorVelocityDamping extends UIBehaviorModule {
|
|
|
13
12
|
*/
|
|
14
13
|
constructor(damping) {
|
|
15
14
|
super();
|
|
16
|
-
/** @internal */
|
|
17
15
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
16
|
this.dampingInternal = resolveUIRangeConfig(damping);
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorVelocityDamping.constructor.damping.min`);
|
|
18
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorVelocityDamping.constructor.damping.max`);
|
|
21
19
|
}
|
|
22
20
|
/** Damping coefficient range (0-1) */
|
|
23
21
|
get damping() {
|
|
@@ -26,16 +24,16 @@ export class UIBehaviorVelocityDamping extends UIBehaviorModule {
|
|
|
26
24
|
/** Damping coefficient range (0-1) */
|
|
27
25
|
set damping(value) {
|
|
28
26
|
this.dampingInternal = resolveUIRangeConfig(value);
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
assertValidUnitNumber(this.dampingInternal.min, `UIBehaviorVelocityDamping.damping.min`);
|
|
28
|
+
assertValidUnitNumber(this.dampingInternal.max, `UIBehaviorVelocityDamping.damping.max`);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
update(properties, instanceCount, deltaTime) {
|
|
30
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
34
31
|
const { builtin } = properties;
|
|
35
32
|
const { array, itemSize } = builtin;
|
|
33
|
+
const dampingStream = particleRandomStream(randomSalt, 0);
|
|
36
34
|
for (let i = 0; i < instanceCount; i++) {
|
|
37
35
|
const itemOffset = i * itemSize;
|
|
38
|
-
const dampingT = array
|
|
36
|
+
const dampingT = particleRandom(array, itemOffset, dampingStream);
|
|
39
37
|
const dampingFactor = Math.pow(1 - MathUtils.lerp(this.dampingInternal.min, this.dampingInternal.max, dampingT), deltaTime);
|
|
40
38
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] *= dampingFactor;
|
|
41
39
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] *= dampingFactor;
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
1
2
|
import { type UIRange, type UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
2
3
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
3
4
|
/**
|
|
4
|
-
* Applies noise-based acceleration to particles.
|
|
5
|
+
* Applies noise-based acceleration to particles: a still flow field that particles drift through.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
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.
|
|
7
10
|
*/
|
|
8
11
|
export declare class UIBehaviorVelocityNoise extends UIBehaviorModule<{
|
|
9
12
|
builtin: "Matrix4";
|
|
10
13
|
}> {
|
|
14
|
+
readonly requiredProperties: {
|
|
15
|
+
readonly builtin: "Matrix4";
|
|
16
|
+
};
|
|
11
17
|
private scaleInternal;
|
|
12
18
|
private strengthInternal;
|
|
13
19
|
/**
|
|
14
|
-
* @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
|
|
15
21
|
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
16
22
|
*/
|
|
17
|
-
constructor(scale?:
|
|
23
|
+
constructor(scale?: UIRangeConfig, strength?: UIRangeConfig);
|
|
18
24
|
/** Noise frequency range */
|
|
19
25
|
get scale(): UIRange;
|
|
20
26
|
/** Force multiplier range */
|
|
@@ -23,4 +29,7 @@ export declare class UIBehaviorVelocityNoise extends UIBehaviorModule<{
|
|
|
23
29
|
set scale(value: UIRangeConfig);
|
|
24
30
|
/** Force multiplier range */
|
|
25
31
|
set strength(value: UIRangeConfig);
|
|
32
|
+
update(properties: {
|
|
33
|
+
builtin: InstancedBufferAttribute;
|
|
34
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
26
35
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
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
|
-
/** @internal */
|
|
18
19
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
19
20
|
this.scaleInternal = resolveUIRangeConfig(scale);
|
|
20
21
|
assertValidPositiveNumber(this.scaleInternal.min, `UIBehaviorVelocityNoise.constructor.scale.min`);
|
|
@@ -43,19 +44,20 @@ export class UIBehaviorVelocityNoise extends UIBehaviorModule {
|
|
|
43
44
|
assertValidNonNegativeNumber(this.strengthInternal.min, `UIBehaviorVelocityNoise.strength.min`);
|
|
44
45
|
assertValidNonNegativeNumber(this.strengthInternal.max, `UIBehaviorVelocityNoise.strength.max`);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
update(properties, instanceCount, deltaTime) {
|
|
47
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
48
48
|
const { builtin } = properties;
|
|
49
49
|
const { array, itemSize } = builtin;
|
|
50
|
+
const scaleStream = particleRandomStream(randomSalt, 0);
|
|
51
|
+
const strengthStream = particleRandomStream(randomSalt, 1);
|
|
50
52
|
for (let i = 0; i < instanceCount; i++) {
|
|
51
53
|
const itemOffset = i * itemSize;
|
|
52
54
|
const x = array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
53
55
|
const y = array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
54
|
-
const scaleT = array
|
|
56
|
+
const scaleT = particleRandom(array, itemOffset, scaleStream);
|
|
55
57
|
const scale = MathUtils.lerp(this.scaleInternal.min, this.scaleInternal.max, scaleT);
|
|
56
58
|
const noiseX = generateNoise2D(x * scale, y * scale);
|
|
57
59
|
const noiseY = generateNoise2D((x + 100) * scale, (y + 100) * scale);
|
|
58
|
-
const strengthT = array
|
|
60
|
+
const strengthT = particleRandom(array, itemOffset, strengthStream);
|
|
59
61
|
const strength = MathUtils.lerp(this.strengthInternal.min, this.strengthInternal.max, strengthT);
|
|
60
62
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += noiseX * strength * deltaTime;
|
|
61
63
|
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += noiseY * strength * deltaTime;
|