laymur 0.27.0 → 0.28.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 +48 -3
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +2 -1
- package/dist/core/constraints/UICustomConstraint.js +1 -1
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +2 -1
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +2 -1
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +2 -1
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +2 -1
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +2 -1
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +2 -1
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +2 -1
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +2 -1
- package/dist/core/constraints/constraintAsserts.d.ts +41 -0
- package/dist/core/constraints/constraintAsserts.js +171 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +8 -5
- package/dist/core/elements/UIDummy/UIDummy.js +21 -10
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +6 -5
- package/dist/core/elements/UIElement/UIElement.Internal.js +0 -4
- package/dist/core/elements/UIElement/UIElement.d.ts +12 -6
- package/dist/core/elements/UIElement/UIElement.js +14 -7
- package/dist/core/elements/UIText/UIText.d.ts +6 -1
- package/dist/core/elements/UIText/UIText.js +22 -12
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +1 -1
- package/dist/core/miscellaneous/UIBlendMode.d.ts +5 -0
- package/dist/core/miscellaneous/UIBlendMode.js +7 -0
- package/dist/core/miscellaneous/asserts.d.ts +0 -41
- package/dist/core/miscellaneous/asserts.js +0 -170
- package/dist/core/miscellaneous/canvas.js +3 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +2 -1
- package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.js +2 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +10 -7
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +11 -8
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +1 -1
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.d.ts +4 -1
- package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +4 -1
- package/dist/core/miscellaneous/text-style/UITextStyle.js +4 -1
- package/dist/core/shaders/UIProgressMaskFunctionCircular.js +1 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +6 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +1 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +18 -9
- package/dist/debug/UIAspectDebug.js +4 -7
- package/dist/debug/UIHeightDebug.js +4 -4
- package/dist/debug/UIHorizontalDistanceDebug.js +4 -7
- package/dist/debug/UIHorizontalInterpolationDebug.js +11 -10
- package/dist/debug/UIVerticalDistanceDebug.js +4 -7
- package/dist/debug/UIVerticalInterpolationDebug.js +11 -10
- package/dist/debug/UIWidthDebug.js +4 -4
- package/dist/debug/miscellaneous.d.ts +7 -0
- package/dist/debug/miscellaneous.js +11 -1
- package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.d.ts +44 -0
- package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.js +75 -0
- package/dist/particles/behaviorModules/UIBehaviorBounce.d.ts +51 -0
- package/dist/particles/behaviorModules/UIBehaviorBounce.js +107 -0
- package/dist/particles/behaviorModules/UIBehaviorOrbit.d.ts +39 -0
- package/dist/particles/behaviorModules/UIBehaviorOrbit.js +73 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -2
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +9 -5
- package/dist/particles/behaviorModules/UIBehaviorSeek.d.ts +38 -0
- package/dist/particles/behaviorModules/UIBehaviorSeek.js +75 -0
- package/dist/particles/elements/UIEmitter.Internal.d.ts +45 -1
- package/dist/particles/elements/UIEmitter.Internal.js +25 -1
- package/dist/particles/elements/UIEmitter.Schedule.d.ts +31 -0
- package/dist/particles/elements/UIEmitter.Schedule.js +81 -0
- package/dist/particles/elements/UIEmitter.d.ts +79 -9
- package/dist/particles/elements/UIEmitter.js +239 -82
- package/dist/particles/index.d.ts +13 -1
- package/dist/particles/index.js +11 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +6 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +27 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +7 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.js +12 -1
- package/dist/particles/miscellaneous/miscellaneous.d.ts +22 -0
- package/dist/particles/miscellaneous/miscellaneous.js +38 -0
- package/dist/particles/renderingModules/UIRenderingFlipbook.d.ts +41 -0
- package/dist/particles/renderingModules/UIRenderingFlipbook.js +70 -0
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +2 -1
- package/dist/particles/renderingModules/UIRenderingModule.js +2 -1
- package/dist/particles/renderingModules/UIRenderingRandomColor.d.ts +19 -0
- package/dist/particles/renderingModules/UIRenderingRandomColor.js +28 -0
- package/dist/particles/renderingModules/UIRenderingShape.d.ts +31 -0
- package/dist/particles/renderingModules/UIRenderingShape.js +54 -0
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +1 -1
- package/dist/particles/renderingModules/UIRenderingTexture.js +4 -28
- package/dist/particles/shaders/UIRenderingFlipbook.d.ts +5 -0
- package/dist/particles/shaders/UIRenderingFlipbook.js +19 -0
- package/dist/particles/shaders/UIRenderingRandomColor.d.ts +2 -0
- package/dist/particles/shaders/UIRenderingRandomColor.js +10 -0
- package/dist/particles/shaders/UIRenderingShape.d.ts +6 -0
- package/dist/particles/shaders/UIRenderingShape.js +15 -0
- package/dist/particles/shaders/UIRenderingTexture.d.ts +4 -2
- package/dist/particles/shaders/UIRenderingTexture.js +27 -2
- package/dist/particles/spawnModules/UISpawnCircle.d.ts +44 -0
- package/dist/particles/spawnModules/UISpawnCircle.js +81 -0
- package/dist/particles/spawnModules/UISpawnRadialVelocity.d.ts +37 -0
- package/dist/particles/spawnModules/UISpawnRadialVelocity.js +75 -0
- package/package.json +24 -21
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
6
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
7
7
|
export class UIAspectDebug {
|
|
8
8
|
constructor(constraint) {
|
|
9
9
|
this.constraint = constraint;
|
|
@@ -32,16 +32,13 @@ export class UIAspectDebug {
|
|
|
32
32
|
this.spriteMaterial.opacity = this.tint.a;
|
|
33
33
|
this.tint.setDirtyFalse();
|
|
34
34
|
}
|
|
35
|
-
renderer
|
|
35
|
+
updateDebugResolution(renderer);
|
|
36
36
|
this.diagonalMaterial.resolution.copy(debugResolutionVector);
|
|
37
37
|
const { x, y, oppositeX, oppositeY, width, height, centerX, centerY } = this.constraint.element;
|
|
38
38
|
if (width <= 0 || height <= 0) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
this.diagonalGeometry.
|
|
42
|
-
new Vector3(x, y, 0),
|
|
43
|
-
new Vector3(oppositeX, oppositeY, 0),
|
|
44
|
-
]);
|
|
41
|
+
this.diagonalGeometry.setPositions([x, y, 0, oppositeX, oppositeY, 0]);
|
|
45
42
|
const nextText = this.constraint.aspect.toFixed(2) + " (" + width.toFixed(0) + "x" + height.toFixed(0) + ")";
|
|
46
43
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
47
44
|
this.drawText(nextText);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
6
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
7
7
|
export class UIHeightDebug {
|
|
8
8
|
constructor(constraint) {
|
|
9
9
|
this.constraint = constraint;
|
|
@@ -32,13 +32,13 @@ export class UIHeightDebug {
|
|
|
32
32
|
this.spriteMaterial.opacity = this.tint.a;
|
|
33
33
|
this.tint.setDirtyFalse();
|
|
34
34
|
}
|
|
35
|
-
renderer
|
|
35
|
+
updateDebugResolution(renderer);
|
|
36
36
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
37
37
|
const { x, y, oppositeY, height, centerX, centerY } = this.constraint.element;
|
|
38
38
|
if (height <= 0) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
this.lineGeometry.
|
|
41
|
+
this.lineGeometry.setPositions([x, y, 0, x, oppositeY, 0]);
|
|
42
42
|
const nextText = "H: " + height.toFixed(0);
|
|
43
43
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
44
44
|
this.drawText(nextText);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
@@ -6,7 +6,7 @@ import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
|
|
|
6
6
|
import { LineSegmentsGeometry } from "three/addons/lines/LineSegmentsGeometry.js";
|
|
7
7
|
import { UIColor, UILayer, UIOrientation } from "../core/index.js";
|
|
8
8
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
9
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
9
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
10
10
|
export class UIHorizontalDistanceDebug {
|
|
11
11
|
constructor(constraint) {
|
|
12
12
|
this.constraint = constraint;
|
|
@@ -45,7 +45,7 @@ export class UIHorizontalDistanceDebug {
|
|
|
45
45
|
this.spriteMaterial.opacity = this.tint.a;
|
|
46
46
|
this.tint.setDirtyFalse();
|
|
47
47
|
}
|
|
48
|
-
renderer
|
|
48
|
+
updateDebugResolution(renderer);
|
|
49
49
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
50
50
|
this.tickMaterial.resolution.copy(debugResolutionVector);
|
|
51
51
|
const elementA = this.constraint.a;
|
|
@@ -63,10 +63,7 @@ export class UIHorizontalDistanceDebug {
|
|
|
63
63
|
: elementB instanceof UILayer
|
|
64
64
|
? anchorAY
|
|
65
65
|
: (anchorAY + anchorBY) / 2;
|
|
66
|
-
this.lineGeometry.
|
|
67
|
-
new Vector3(anchorAX, midY, 0),
|
|
68
|
-
new Vector3(anchorBX, midY, 0),
|
|
69
|
-
]);
|
|
66
|
+
this.lineGeometry.setPositions([anchorAX, midY, 0, anchorBX, midY, 0]);
|
|
70
67
|
const tickSize = 10;
|
|
71
68
|
this.tickGeometry.setPositions([
|
|
72
69
|
anchorAX,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
6
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
7
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
7
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
8
8
|
export class UIHorizontalInterpolationDebug {
|
|
9
9
|
constructor(constraint) {
|
|
10
10
|
this.constraint = constraint;
|
|
@@ -43,7 +43,7 @@ export class UIHorizontalInterpolationDebug {
|
|
|
43
43
|
this.spriteMaterial.opacity = this.tint.a;
|
|
44
44
|
this.tint.setDirtyFalse();
|
|
45
45
|
}
|
|
46
|
-
renderer
|
|
46
|
+
updateDebugResolution(renderer);
|
|
47
47
|
this.baseLineMaterial.resolution.copy(debugResolutionVector);
|
|
48
48
|
this.markerMaterial.resolution.copy(debugResolutionVector);
|
|
49
49
|
const elementA = this.constraint.a;
|
|
@@ -61,14 +61,15 @@ export class UIHorizontalInterpolationDebug {
|
|
|
61
61
|
? elementC.x + elementC.width * this.constraint.anchorC
|
|
62
62
|
: elementC.x;
|
|
63
63
|
const midY = (anchorAY + anchorBY) / 2;
|
|
64
|
-
this.baseLineGeometry.
|
|
65
|
-
new Vector3(anchorAX, midY, 0),
|
|
66
|
-
new Vector3(anchorBX, midY, 0),
|
|
67
|
-
]);
|
|
64
|
+
this.baseLineGeometry.setPositions([anchorAX, midY, 0, anchorBX, midY, 0]);
|
|
68
65
|
const markerSize = 12;
|
|
69
|
-
this.markerGeometry.
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
this.markerGeometry.setPositions([
|
|
67
|
+
anchorCX,
|
|
68
|
+
midY - markerSize,
|
|
69
|
+
0,
|
|
70
|
+
anchorCX,
|
|
71
|
+
midY + markerSize,
|
|
72
|
+
0,
|
|
72
73
|
]);
|
|
73
74
|
const nextText = "hi: " + this.constraint.t.toFixed(2);
|
|
74
75
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
@@ -6,7 +6,7 @@ import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
|
|
|
6
6
|
import { LineSegmentsGeometry } from "three/addons/lines/LineSegmentsGeometry.js";
|
|
7
7
|
import { UIColor, UILayer, UIOrientation } from "../core/index.js";
|
|
8
8
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
9
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
9
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
10
10
|
export class UIVerticalDistanceDebug {
|
|
11
11
|
constructor(constraint) {
|
|
12
12
|
this.constraint = constraint;
|
|
@@ -45,7 +45,7 @@ export class UIVerticalDistanceDebug {
|
|
|
45
45
|
this.spriteMaterial.opacity = this.tint.a;
|
|
46
46
|
this.tint.setDirtyFalse();
|
|
47
47
|
}
|
|
48
|
-
renderer
|
|
48
|
+
updateDebugResolution(renderer);
|
|
49
49
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
50
50
|
this.tickMaterial.resolution.copy(debugResolutionVector);
|
|
51
51
|
const elementA = this.constraint.a;
|
|
@@ -63,10 +63,7 @@ export class UIVerticalDistanceDebug {
|
|
|
63
63
|
: elementB instanceof UILayer
|
|
64
64
|
? anchorAX
|
|
65
65
|
: (anchorAX + anchorBX) / 2;
|
|
66
|
-
this.lineGeometry.
|
|
67
|
-
new Vector3(midX, anchorAY, 0),
|
|
68
|
-
new Vector3(midX, anchorBY, 0),
|
|
69
|
-
]);
|
|
66
|
+
this.lineGeometry.setPositions([midX, anchorAY, 0, midX, anchorBY, 0]);
|
|
70
67
|
const tickSize = 10;
|
|
71
68
|
this.tickGeometry.setPositions([
|
|
72
69
|
midX - tickSize,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
6
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
7
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
7
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
8
8
|
export class UIVerticalInterpolationDebug {
|
|
9
9
|
constructor(constraint) {
|
|
10
10
|
this.constraint = constraint;
|
|
@@ -43,7 +43,7 @@ export class UIVerticalInterpolationDebug {
|
|
|
43
43
|
this.spriteMaterial.opacity = this.tint.a;
|
|
44
44
|
this.tint.setDirtyFalse();
|
|
45
45
|
}
|
|
46
|
-
renderer
|
|
46
|
+
updateDebugResolution(renderer);
|
|
47
47
|
this.baseLineMaterial.resolution.copy(debugResolutionVector);
|
|
48
48
|
this.markerMaterial.resolution.copy(debugResolutionVector);
|
|
49
49
|
const elementA = this.constraint.a;
|
|
@@ -61,14 +61,15 @@ export class UIVerticalInterpolationDebug {
|
|
|
61
61
|
? elementC.y + elementC.height * this.constraint.anchorC
|
|
62
62
|
: elementC.y;
|
|
63
63
|
const midX = (anchorAX + anchorBX) / 2;
|
|
64
|
-
this.baseLineGeometry.
|
|
65
|
-
new Vector3(midX, anchorAY, 0),
|
|
66
|
-
new Vector3(midX, anchorBY, 0),
|
|
67
|
-
]);
|
|
64
|
+
this.baseLineGeometry.setPositions([midX, anchorAY, 0, midX, anchorBY, 0]);
|
|
68
65
|
const markerSize = 12;
|
|
69
|
-
this.markerGeometry.
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
this.markerGeometry.setPositions([
|
|
67
|
+
midX - markerSize,
|
|
68
|
+
anchorCY,
|
|
69
|
+
0,
|
|
70
|
+
midX + markerSize,
|
|
71
|
+
anchorCY,
|
|
72
|
+
0,
|
|
72
73
|
]);
|
|
73
74
|
const nextText = "vi: " + this.constraint.t.toFixed(2);
|
|
74
75
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
6
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
7
7
|
export class UIWidthDebug {
|
|
8
8
|
constructor(constraint) {
|
|
9
9
|
this.constraint = constraint;
|
|
@@ -32,13 +32,13 @@ export class UIWidthDebug {
|
|
|
32
32
|
this.spriteMaterial.opacity = this.tint.a;
|
|
33
33
|
this.tint.setDirtyFalse();
|
|
34
34
|
}
|
|
35
|
-
renderer
|
|
35
|
+
updateDebugResolution(renderer);
|
|
36
36
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
37
37
|
const { x, y, oppositeX, width, centerX, centerY } = this.constraint.element;
|
|
38
38
|
if (width <= 0) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
this.lineGeometry.
|
|
41
|
+
this.lineGeometry.setPositions([x, y, 0, oppositeX, y, 0]);
|
|
42
42
|
const nextText = "W: " + width.toFixed(0);
|
|
43
43
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
44
44
|
this.drawText(nextText);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
1
2
|
import { Vector2 } from "three";
|
|
2
3
|
export declare const DEBUG_RENDER_ORDER = 8192;
|
|
3
4
|
export declare const DEBUG_LINE_WIDTH = 2;
|
|
@@ -6,3 +7,9 @@ export declare const DEBUG_BADGE_FONT_SIZE = 30;
|
|
|
6
7
|
export declare const DEBUG_BADGE_FONT_FAMILY = "monospace";
|
|
7
8
|
export declare const DEBUG_BADGE_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.8)";
|
|
8
9
|
export declare const debugResolutionVector: Vector2;
|
|
10
|
+
/**
|
|
11
|
+
* Sets `debugResolutionVector` to the size of the current viewport, the value three.js 0.165 and
|
|
12
|
+
* later write into `LineMaterial.resolution` before each draw. Earlier versions keep the value
|
|
13
|
+
* set here, so line widths are the same on every version.
|
|
14
|
+
*/
|
|
15
|
+
export declare function updateDebugResolution(renderer: WebGLRenderer): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector2 } from "three";
|
|
1
|
+
import { Vector2, Vector4 } from "three";
|
|
2
2
|
export const DEBUG_RENDER_ORDER = 8192;
|
|
3
3
|
export const DEBUG_LINE_WIDTH = 2;
|
|
4
4
|
export const DEBUG_BADGE_SIZE = 150;
|
|
@@ -6,3 +6,13 @@ export const DEBUG_BADGE_FONT_SIZE = 30;
|
|
|
6
6
|
export const DEBUG_BADGE_FONT_FAMILY = "monospace";
|
|
7
7
|
export const DEBUG_BADGE_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.8)";
|
|
8
8
|
export const debugResolutionVector = new Vector2();
|
|
9
|
+
const debugViewport = new Vector4();
|
|
10
|
+
/**
|
|
11
|
+
* Sets `debugResolutionVector` to the size of the current viewport, the value three.js 0.165 and
|
|
12
|
+
* later write into `LineMaterial.resolution` before each draw. Earlier versions keep the value
|
|
13
|
+
* set here, so line widths are the same on every version.
|
|
14
|
+
*/
|
|
15
|
+
export function updateDebugResolution(renderer) {
|
|
16
|
+
renderer.getViewport(debugViewport);
|
|
17
|
+
debugResolutionVector.set(debugViewport.z, debugViewport.w);
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
2
|
+
import type { UIAspectConfig } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
4
|
+
/**
|
|
5
|
+
* Turns the X axis of particles along their velocity and stretches them along it with speed, as
|
|
6
|
+
* motion blur of sparks and streaks.
|
|
7
|
+
*
|
|
8
|
+
* Sets the rotation every frame, so torque has no effect. The length is derived from the Y scale,
|
|
9
|
+
* so the module composes with any scale source: put it after `UISpawnRandomScale` or
|
|
10
|
+
* `UIBehaviorScaleOverLife` in the sequence. A particle at rest keeps its rotation.
|
|
11
|
+
*/
|
|
12
|
+
export declare class UIBehaviorAlignToVelocity extends UIBehaviorModule<{
|
|
13
|
+
builtin: "Matrix4";
|
|
14
|
+
}> {
|
|
15
|
+
readonly requiredProperties: {
|
|
16
|
+
readonly builtin: "Matrix4";
|
|
17
|
+
};
|
|
18
|
+
private stretchInternal;
|
|
19
|
+
private rotationOffsetInternal;
|
|
20
|
+
private aspectInternal;
|
|
21
|
+
/**
|
|
22
|
+
* @param stretch - Seconds of motion added to the length: the length grows by speed * stretch
|
|
23
|
+
* @param aspect - Width/height ratio at rest, the same as given to the scale module. Accepts
|
|
24
|
+
* number or texture
|
|
25
|
+
* @param rotationOffset - Angle in radians added to the direction, for sprites drawn along
|
|
26
|
+
* another axis
|
|
27
|
+
*/
|
|
28
|
+
constructor(stretch?: number, aspect?: UIAspectConfig, rotationOffset?: number);
|
|
29
|
+
/** Seconds of motion added to the length */
|
|
30
|
+
get stretch(): number;
|
|
31
|
+
/** Width/height aspect ratio at rest */
|
|
32
|
+
get aspect(): number;
|
|
33
|
+
/** Angle in radians added to the direction */
|
|
34
|
+
get rotationOffset(): number;
|
|
35
|
+
/** Seconds of motion added to the length */
|
|
36
|
+
set stretch(value: number);
|
|
37
|
+
/** Width/height aspect ratio at rest */
|
|
38
|
+
set aspect(value: UIAspectConfig);
|
|
39
|
+
/** Angle in radians added to the direction */
|
|
40
|
+
set rotationOffset(value: number);
|
|
41
|
+
update(properties: {
|
|
42
|
+
builtin: InstancedBufferAttribute;
|
|
43
|
+
}, instanceCount: number): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assertValidNonNegativeNumber, assertValidNumber, assertValidPositiveNumber, } from "../../core/miscellaneous/asserts.js";
|
|
2
|
+
import { BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, resolveAspect, } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
4
|
+
/**
|
|
5
|
+
* Turns the X axis of particles along their velocity and stretches them along it with speed, as
|
|
6
|
+
* motion blur of sparks and streaks.
|
|
7
|
+
*
|
|
8
|
+
* Sets the rotation every frame, so torque has no effect. The length is derived from the Y scale,
|
|
9
|
+
* so the module composes with any scale source: put it after `UISpawnRandomScale` or
|
|
10
|
+
* `UIBehaviorScaleOverLife` in the sequence. A particle at rest keeps its rotation.
|
|
11
|
+
*/
|
|
12
|
+
export class UIBehaviorAlignToVelocity extends UIBehaviorModule {
|
|
13
|
+
/**
|
|
14
|
+
* @param stretch - Seconds of motion added to the length: the length grows by speed * stretch
|
|
15
|
+
* @param aspect - Width/height ratio at rest, the same as given to the scale module. Accepts
|
|
16
|
+
* number or texture
|
|
17
|
+
* @param rotationOffset - Angle in radians added to the direction, for sprites drawn along
|
|
18
|
+
* another axis
|
|
19
|
+
*/
|
|
20
|
+
constructor(stretch = 0, aspect = 1, rotationOffset = 0) {
|
|
21
|
+
super();
|
|
22
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
23
|
+
this.stretchInternal = stretch;
|
|
24
|
+
this.aspectInternal = resolveAspect(aspect);
|
|
25
|
+
this.rotationOffsetInternal = rotationOffset;
|
|
26
|
+
assertValidNonNegativeNumber(stretch, "UIBehaviorAlignToVelocity.constructor.stretch");
|
|
27
|
+
assertValidPositiveNumber(this.aspectInternal, "UIBehaviorAlignToVelocity.constructor.aspect");
|
|
28
|
+
assertValidNumber(rotationOffset, "UIBehaviorAlignToVelocity.constructor.rotationOffset");
|
|
29
|
+
}
|
|
30
|
+
/** Seconds of motion added to the length */
|
|
31
|
+
get stretch() {
|
|
32
|
+
return this.stretchInternal;
|
|
33
|
+
}
|
|
34
|
+
/** Width/height aspect ratio at rest */
|
|
35
|
+
get aspect() {
|
|
36
|
+
return this.aspectInternal;
|
|
37
|
+
}
|
|
38
|
+
/** Angle in radians added to the direction */
|
|
39
|
+
get rotationOffset() {
|
|
40
|
+
return this.rotationOffsetInternal;
|
|
41
|
+
}
|
|
42
|
+
/** Seconds of motion added to the length */
|
|
43
|
+
set stretch(value) {
|
|
44
|
+
assertValidNonNegativeNumber(value, "UIBehaviorAlignToVelocity.stretch");
|
|
45
|
+
this.stretchInternal = value;
|
|
46
|
+
}
|
|
47
|
+
/** Width/height aspect ratio at rest */
|
|
48
|
+
set aspect(value) {
|
|
49
|
+
this.aspectInternal = resolveAspect(value);
|
|
50
|
+
assertValidPositiveNumber(this.aspectInternal, "UIBehaviorAlignToVelocity.aspect");
|
|
51
|
+
}
|
|
52
|
+
/** Angle in radians added to the direction */
|
|
53
|
+
set rotationOffset(value) {
|
|
54
|
+
assertValidNumber(value, "UIBehaviorAlignToVelocity.rotationOffset");
|
|
55
|
+
this.rotationOffsetInternal = value;
|
|
56
|
+
}
|
|
57
|
+
update(properties, instanceCount) {
|
|
58
|
+
const { builtin } = properties;
|
|
59
|
+
const { array, itemSize } = builtin;
|
|
60
|
+
for (let i = 0; i < instanceCount; i++) {
|
|
61
|
+
const itemOffset = i * itemSize;
|
|
62
|
+
const velocityX = array[itemOffset + BUILTIN_OFFSET_VELOCITY_X];
|
|
63
|
+
const velocityY = array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y];
|
|
64
|
+
const speed = Math.hypot(velocityX, velocityY);
|
|
65
|
+
if (speed > 0) {
|
|
66
|
+
array[itemOffset + BUILTIN_OFFSET_ROTATION] =
|
|
67
|
+
Math.atan2(velocityY, velocityX) + this.rotationOffsetInternal;
|
|
68
|
+
}
|
|
69
|
+
array[itemOffset + BUILTIN_OFFSET_SCALE_X] =
|
|
70
|
+
array[itemOffset + BUILTIN_OFFSET_SCALE_Y] * this.aspectInternal +
|
|
71
|
+
speed * this.stretchInternal;
|
|
72
|
+
}
|
|
73
|
+
builtin.needsUpdate = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
2
|
+
import type { Vector2Like } from "../../core/miscellaneous/math.js";
|
|
3
|
+
import type { UIVector2Config } from "../miscellaneous/miscellaneous.js";
|
|
4
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
|
+
/**
|
|
6
|
+
* Keeps particles on one side of a line and bounces them off it, as a floor or a wall.
|
|
7
|
+
*
|
|
8
|
+
* The line passes through a point, and its normal points to the free side. A particle behind it
|
|
9
|
+
* is put back on the line, the velocity into it is reflected and scaled by the restitution, and
|
|
10
|
+
* the velocity along it decays by the friction while in contact, as `UIBehaviorVelocityDamping`
|
|
11
|
+
* does. The point and the normal are in the particle space of the emitter.
|
|
12
|
+
*/
|
|
13
|
+
export declare class UIBehaviorBounce extends UIBehaviorModule<{
|
|
14
|
+
builtin: "Matrix4";
|
|
15
|
+
}> {
|
|
16
|
+
readonly requiredProperties: {
|
|
17
|
+
readonly builtin: "Matrix4";
|
|
18
|
+
};
|
|
19
|
+
private pointInternal;
|
|
20
|
+
private normalX;
|
|
21
|
+
private normalY;
|
|
22
|
+
private restitutionInternal;
|
|
23
|
+
private frictionInternal;
|
|
24
|
+
/**
|
|
25
|
+
* @param point - A point of the line
|
|
26
|
+
* @param normal - Direction to the free side, normalized by the module
|
|
27
|
+
* @param restitution - Share of the speed into the line kept after a bounce, from 0 to 1
|
|
28
|
+
* @param friction - Share of the speed along the line lost per second of contact, from 0 to 1
|
|
29
|
+
*/
|
|
30
|
+
constructor(point: UIVector2Config, normal?: UIVector2Config, restitution?: number, friction?: number);
|
|
31
|
+
/** A point of the line */
|
|
32
|
+
get point(): Vector2Like;
|
|
33
|
+
/** Unit direction to the free side */
|
|
34
|
+
get normal(): Vector2Like;
|
|
35
|
+
/** Share of the speed into the line kept after a bounce */
|
|
36
|
+
get restitution(): number;
|
|
37
|
+
/** Share of the speed along the line lost per second of contact */
|
|
38
|
+
get friction(): number;
|
|
39
|
+
/** A point of the line */
|
|
40
|
+
set point(value: UIVector2Config);
|
|
41
|
+
/** Direction to the free side, normalized by the module */
|
|
42
|
+
set normal(value: UIVector2Config);
|
|
43
|
+
/** Share of the speed into the line kept after a bounce */
|
|
44
|
+
set restitution(value: number);
|
|
45
|
+
/** Share of the speed along the line lost per second of contact */
|
|
46
|
+
set friction(value: number);
|
|
47
|
+
update(properties: {
|
|
48
|
+
builtin: InstancedBufferAttribute;
|
|
49
|
+
}, instanceCount: number, deltaTime: number): void;
|
|
50
|
+
private setNormal;
|
|
51
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { assertValidNumber, assertValidUnitNumber } from "../../core/miscellaneous/asserts.js";
|
|
2
|
+
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, resolveUIVector2Config, } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
4
|
+
/**
|
|
5
|
+
* Keeps particles on one side of a line and bounces them off it, as a floor or a wall.
|
|
6
|
+
*
|
|
7
|
+
* The line passes through a point, and its normal points to the free side. A particle behind it
|
|
8
|
+
* is put back on the line, the velocity into it is reflected and scaled by the restitution, and
|
|
9
|
+
* the velocity along it decays by the friction while in contact, as `UIBehaviorVelocityDamping`
|
|
10
|
+
* does. The point and the normal are in the particle space of the emitter.
|
|
11
|
+
*/
|
|
12
|
+
export class UIBehaviorBounce extends UIBehaviorModule {
|
|
13
|
+
/**
|
|
14
|
+
* @param point - A point of the line
|
|
15
|
+
* @param normal - Direction to the free side, normalized by the module
|
|
16
|
+
* @param restitution - Share of the speed into the line kept after a bounce, from 0 to 1
|
|
17
|
+
* @param friction - Share of the speed along the line lost per second of contact, from 0 to 1
|
|
18
|
+
*/
|
|
19
|
+
constructor(point, normal = { x: 0, y: 1 }, restitution = 0.5, friction = 0.9) {
|
|
20
|
+
super();
|
|
21
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
22
|
+
this.normalX = 0;
|
|
23
|
+
this.normalY = 1;
|
|
24
|
+
this.pointInternal = resolveUIVector2Config(point);
|
|
25
|
+
assertValidNumber(this.pointInternal.x, "UIBehaviorBounce.constructor.point.x");
|
|
26
|
+
assertValidNumber(this.pointInternal.y, "UIBehaviorBounce.constructor.point.y");
|
|
27
|
+
this.setNormal(normal, "UIBehaviorBounce.constructor.normal");
|
|
28
|
+
assertValidUnitNumber(restitution, "UIBehaviorBounce.constructor.restitution");
|
|
29
|
+
assertValidUnitNumber(friction, "UIBehaviorBounce.constructor.friction");
|
|
30
|
+
this.restitutionInternal = restitution;
|
|
31
|
+
this.frictionInternal = friction;
|
|
32
|
+
}
|
|
33
|
+
/** A point of the line */
|
|
34
|
+
get point() {
|
|
35
|
+
return this.pointInternal;
|
|
36
|
+
}
|
|
37
|
+
/** Unit direction to the free side */
|
|
38
|
+
get normal() {
|
|
39
|
+
return { x: this.normalX, y: this.normalY };
|
|
40
|
+
}
|
|
41
|
+
/** Share of the speed into the line kept after a bounce */
|
|
42
|
+
get restitution() {
|
|
43
|
+
return this.restitutionInternal;
|
|
44
|
+
}
|
|
45
|
+
/** Share of the speed along the line lost per second of contact */
|
|
46
|
+
get friction() {
|
|
47
|
+
return this.frictionInternal;
|
|
48
|
+
}
|
|
49
|
+
/** A point of the line */
|
|
50
|
+
set point(value) {
|
|
51
|
+
this.pointInternal = resolveUIVector2Config(value);
|
|
52
|
+
assertValidNumber(this.pointInternal.x, "UIBehaviorBounce.point.x");
|
|
53
|
+
assertValidNumber(this.pointInternal.y, "UIBehaviorBounce.point.y");
|
|
54
|
+
}
|
|
55
|
+
/** Direction to the free side, normalized by the module */
|
|
56
|
+
set normal(value) {
|
|
57
|
+
this.setNormal(value, "UIBehaviorBounce.normal");
|
|
58
|
+
}
|
|
59
|
+
/** Share of the speed into the line kept after a bounce */
|
|
60
|
+
set restitution(value) {
|
|
61
|
+
assertValidUnitNumber(value, "UIBehaviorBounce.restitution");
|
|
62
|
+
this.restitutionInternal = value;
|
|
63
|
+
}
|
|
64
|
+
/** Share of the speed along the line lost per second of contact */
|
|
65
|
+
set friction(value) {
|
|
66
|
+
assertValidUnitNumber(value, "UIBehaviorBounce.friction");
|
|
67
|
+
this.frictionInternal = value;
|
|
68
|
+
}
|
|
69
|
+
update(properties, instanceCount, deltaTime) {
|
|
70
|
+
const { builtin } = properties;
|
|
71
|
+
const { array, itemSize } = builtin;
|
|
72
|
+
const { x: pointX, y: pointY } = this.pointInternal;
|
|
73
|
+
const { normalX, normalY } = this;
|
|
74
|
+
const keptAlong = Math.pow(1 - this.frictionInternal, deltaTime);
|
|
75
|
+
for (let i = 0; i < instanceCount; i++) {
|
|
76
|
+
const itemOffset = i * itemSize;
|
|
77
|
+
const depth = (array[itemOffset + BUILTIN_OFFSET_POSITION_X] - pointX) * normalX +
|
|
78
|
+
(array[itemOffset + BUILTIN_OFFSET_POSITION_Y] - pointY) * normalY;
|
|
79
|
+
if (depth >= 0) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_X] -= normalX * depth;
|
|
83
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] -= normalY * depth;
|
|
84
|
+
const velocityX = array[itemOffset + BUILTIN_OFFSET_VELOCITY_X];
|
|
85
|
+
const velocityY = array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y];
|
|
86
|
+
// Split into the parts across the line (normal * across) and along it
|
|
87
|
+
const across = velocityX * normalX + velocityY * normalY;
|
|
88
|
+
const alongX = velocityX - normalX * across;
|
|
89
|
+
const alongY = velocityY - normalY * across;
|
|
90
|
+
const acrossAfter = across < 0 ? -across * this.restitutionInternal : across;
|
|
91
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] = alongX * keptAlong + normalX * acrossAfter;
|
|
92
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] = alongY * keptAlong + normalY * acrossAfter;
|
|
93
|
+
}
|
|
94
|
+
builtin.needsUpdate = true;
|
|
95
|
+
}
|
|
96
|
+
setNormal(value, subject) {
|
|
97
|
+
const { x, y } = resolveUIVector2Config(value);
|
|
98
|
+
assertValidNumber(x, `${subject}.x`);
|
|
99
|
+
assertValidNumber(y, `${subject}.y`);
|
|
100
|
+
const length = Math.hypot(x, y);
|
|
101
|
+
if (length === 0) {
|
|
102
|
+
throw new Error(`${subject}: normal must not be zero`);
|
|
103
|
+
}
|
|
104
|
+
this.normalX = x / length;
|
|
105
|
+
this.normalY = y / length;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
2
|
+
import type { Vector2Like } from "../../core/miscellaneous/math.js";
|
|
3
|
+
import type { UIRange, UIRangeConfig, UIVector2Config } from "../miscellaneous/miscellaneous.js";
|
|
4
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
|
+
/**
|
|
6
|
+
* Turns the motion of particles around a center: position and velocity rotate together at an
|
|
7
|
+
* angular speed, so a particle at rest circles the center at its distance and one moving outward
|
|
8
|
+
* spirals.
|
|
9
|
+
*
|
|
10
|
+
* The rotation is kinematic, not a force: the distance to the center stays unless the velocity
|
|
11
|
+
* changes it. The center is in the particle space of the emitter.
|
|
12
|
+
*/
|
|
13
|
+
export declare class UIBehaviorOrbit extends UIBehaviorModule<{
|
|
14
|
+
builtin: "Matrix4";
|
|
15
|
+
}> {
|
|
16
|
+
readonly requiredProperties: {
|
|
17
|
+
readonly builtin: "Matrix4";
|
|
18
|
+
};
|
|
19
|
+
private centerInternal;
|
|
20
|
+
private angularSpeedInternal;
|
|
21
|
+
/**
|
|
22
|
+
* @param angularSpeed - Radians per second, counter-clockwise for positive values. Accepts
|
|
23
|
+
* number, tuple, or range object
|
|
24
|
+
* @param center - Center of the rotation
|
|
25
|
+
*/
|
|
26
|
+
constructor(angularSpeed: UIRangeConfig, center?: UIVector2Config);
|
|
27
|
+
/** Radians per second, counter-clockwise for positive values */
|
|
28
|
+
get angularSpeed(): UIRange;
|
|
29
|
+
/** Center of the rotation */
|
|
30
|
+
get center(): Vector2Like;
|
|
31
|
+
/** Radians per second, counter-clockwise for positive values */
|
|
32
|
+
set angularSpeed(value: UIRangeConfig);
|
|
33
|
+
/** Center of the rotation */
|
|
34
|
+
set center(value: UIVector2Config);
|
|
35
|
+
update(properties: {
|
|
36
|
+
builtin: InstancedBufferAttribute;
|
|
37
|
+
}, instanceCount: number, deltaTime: number, randomSalt: number): void;
|
|
38
|
+
private assertValid;
|
|
39
|
+
}
|