laymur 0.27.1 → 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.
Files changed (82) hide show
  1. package/README.md +46 -1
  2. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +2 -1
  3. package/dist/core/constraints/UICustomConstraint.js +1 -1
  4. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +2 -1
  5. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +2 -1
  6. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +2 -1
  7. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +2 -1
  8. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +2 -1
  9. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +2 -1
  10. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +2 -1
  11. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +2 -1
  12. package/dist/core/constraints/constraintAsserts.d.ts +41 -0
  13. package/dist/core/constraints/constraintAsserts.js +171 -0
  14. package/dist/core/elements/UIDummy/UIDummy.d.ts +8 -5
  15. package/dist/core/elements/UIDummy/UIDummy.js +21 -10
  16. package/dist/core/elements/UIElement/UIElement.Internal.d.ts +6 -5
  17. package/dist/core/elements/UIElement/UIElement.Internal.js +0 -4
  18. package/dist/core/elements/UIElement/UIElement.d.ts +12 -6
  19. package/dist/core/elements/UIElement/UIElement.js +14 -7
  20. package/dist/core/elements/UIText/UIText.d.ts +6 -1
  21. package/dist/core/elements/UIText/UIText.js +22 -12
  22. package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +1 -1
  23. package/dist/core/miscellaneous/UIBlendMode.d.ts +5 -0
  24. package/dist/core/miscellaneous/UIBlendMode.js +7 -0
  25. package/dist/core/miscellaneous/asserts.d.ts +0 -41
  26. package/dist/core/miscellaneous/asserts.js +0 -170
  27. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +10 -7
  28. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +11 -8
  29. package/dist/core/miscellaneous/text-style/UITextStyle.Internal.d.ts +4 -1
  30. package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +4 -1
  31. package/dist/core/miscellaneous/text-style/UITextStyle.js +4 -1
  32. package/dist/core/shaders/UIProgressMaskFunctionCircular.js +1 -2
  33. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +6 -2
  34. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +1 -0
  35. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +18 -9
  36. package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.d.ts +44 -0
  37. package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.js +75 -0
  38. package/dist/particles/behaviorModules/UIBehaviorBounce.d.ts +51 -0
  39. package/dist/particles/behaviorModules/UIBehaviorBounce.js +107 -0
  40. package/dist/particles/behaviorModules/UIBehaviorOrbit.d.ts +39 -0
  41. package/dist/particles/behaviorModules/UIBehaviorOrbit.js +73 -0
  42. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -2
  43. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +9 -5
  44. package/dist/particles/behaviorModules/UIBehaviorSeek.d.ts +38 -0
  45. package/dist/particles/behaviorModules/UIBehaviorSeek.js +75 -0
  46. package/dist/particles/elements/UIEmitter.Internal.d.ts +45 -1
  47. package/dist/particles/elements/UIEmitter.Internal.js +25 -1
  48. package/dist/particles/elements/UIEmitter.Schedule.d.ts +31 -0
  49. package/dist/particles/elements/UIEmitter.Schedule.js +81 -0
  50. package/dist/particles/elements/UIEmitter.d.ts +79 -9
  51. package/dist/particles/elements/UIEmitter.js +239 -82
  52. package/dist/particles/index.d.ts +13 -1
  53. package/dist/particles/index.js +11 -1
  54. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +6 -0
  55. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +27 -0
  56. package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +7 -1
  57. package/dist/particles/instancedParticle/UIInstancedParticle.js +12 -1
  58. package/dist/particles/miscellaneous/miscellaneous.d.ts +22 -0
  59. package/dist/particles/miscellaneous/miscellaneous.js +38 -0
  60. package/dist/particles/renderingModules/UIRenderingFlipbook.d.ts +41 -0
  61. package/dist/particles/renderingModules/UIRenderingFlipbook.js +70 -0
  62. package/dist/particles/renderingModules/UIRenderingModule.d.ts +2 -1
  63. package/dist/particles/renderingModules/UIRenderingModule.js +2 -1
  64. package/dist/particles/renderingModules/UIRenderingRandomColor.d.ts +19 -0
  65. package/dist/particles/renderingModules/UIRenderingRandomColor.js +28 -0
  66. package/dist/particles/renderingModules/UIRenderingShape.d.ts +31 -0
  67. package/dist/particles/renderingModules/UIRenderingShape.js +54 -0
  68. package/dist/particles/renderingModules/UIRenderingTexture.d.ts +1 -1
  69. package/dist/particles/renderingModules/UIRenderingTexture.js +4 -28
  70. package/dist/particles/shaders/UIRenderingFlipbook.d.ts +5 -0
  71. package/dist/particles/shaders/UIRenderingFlipbook.js +19 -0
  72. package/dist/particles/shaders/UIRenderingRandomColor.d.ts +2 -0
  73. package/dist/particles/shaders/UIRenderingRandomColor.js +10 -0
  74. package/dist/particles/shaders/UIRenderingShape.d.ts +6 -0
  75. package/dist/particles/shaders/UIRenderingShape.js +15 -0
  76. package/dist/particles/shaders/UIRenderingTexture.d.ts +4 -2
  77. package/dist/particles/shaders/UIRenderingTexture.js +27 -2
  78. package/dist/particles/spawnModules/UISpawnCircle.d.ts +44 -0
  79. package/dist/particles/spawnModules/UISpawnCircle.js +81 -0
  80. package/dist/particles/spawnModules/UISpawnRadialVelocity.d.ts +37 -0
  81. package/dist/particles/spawnModules/UISpawnRadialVelocity.js +75 -0
  82. package/package.json +1 -1
@@ -0,0 +1,37 @@
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 { UISpawnModule } from "./UISpawnModule.js";
5
+ /**
6
+ * Assigns velocity along the direction from a center to the spawn position: outward for a positive
7
+ * speed, inward for a negative one.
8
+ *
9
+ * Reads the position, so it goes after the shape module in the spawn sequence. A particle at the
10
+ * center moves in a random direction.
11
+ */
12
+ export declare class UISpawnRadialVelocity extends UISpawnModule<{
13
+ builtin: "Matrix4";
14
+ }> {
15
+ readonly requiredProperties: {
16
+ readonly builtin: "Matrix4";
17
+ };
18
+ private magnitudeInternal;
19
+ private centerInternal;
20
+ /**
21
+ * @param magnitude - Speed range in units/second. Accepts number, tuple, or range object
22
+ * @param center - Center relative to the emitter
23
+ */
24
+ constructor(magnitude?: UIRangeConfig, center?: UIVector2Config);
25
+ /** Speed range in units/second */
26
+ get magnitude(): UIRange;
27
+ /** Center relative to the emitter */
28
+ get center(): Vector2Like;
29
+ /** Speed range in units/second */
30
+ set magnitude(value: UIRangeConfig);
31
+ /** Center relative to the emitter */
32
+ set center(value: UIVector2Config);
33
+ spawn(properties: {
34
+ builtin: InstancedBufferAttribute;
35
+ }, instanceBegin: number, instanceEnd: number, randomSalt: number): void;
36
+ private assertValid;
37
+ }
@@ -0,0 +1,75 @@
1
+ import { MathUtils } from "three";
2
+ import { assertValidNumber } 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
+ import { UISpawnModule } from "./UISpawnModule.js";
5
+ /**
6
+ * Assigns velocity along the direction from a center to the spawn position: outward for a positive
7
+ * speed, inward for a negative one.
8
+ *
9
+ * Reads the position, so it goes after the shape module in the spawn sequence. A particle at the
10
+ * center moves in a random direction.
11
+ */
12
+ export class UISpawnRadialVelocity extends UISpawnModule {
13
+ /**
14
+ * @param magnitude - Speed range in units/second. Accepts number, tuple, or range object
15
+ * @param center - Center relative to the emitter
16
+ */
17
+ constructor(magnitude = { min: 50, max: 100 }, center = 0) {
18
+ super();
19
+ this.requiredProperties = { builtin: "Matrix4" };
20
+ this.magnitudeInternal = resolveUIRangeConfig(magnitude);
21
+ this.centerInternal = resolveUIVector2Config(center);
22
+ this.assertValid("UISpawnRadialVelocity.constructor");
23
+ }
24
+ /** Speed range in units/second */
25
+ get magnitude() {
26
+ return this.magnitudeInternal;
27
+ }
28
+ /** Center relative to the emitter */
29
+ get center() {
30
+ return this.centerInternal;
31
+ }
32
+ /** Speed range in units/second */
33
+ set magnitude(value) {
34
+ this.magnitudeInternal = resolveUIRangeConfig(value);
35
+ this.assertValid("UISpawnRadialVelocity");
36
+ }
37
+ /** Center relative to the emitter */
38
+ set center(value) {
39
+ this.centerInternal = resolveUIVector2Config(value);
40
+ this.assertValid("UISpawnRadialVelocity");
41
+ }
42
+ spawn(properties, instanceBegin, instanceEnd, randomSalt) {
43
+ const { builtin } = properties;
44
+ const { array, itemSize } = builtin;
45
+ const { min: magnitudeMin, max: magnitudeMax } = this.magnitudeInternal;
46
+ const { x: centerX, y: centerY } = this.centerInternal;
47
+ const magnitudeStream = particleRandomStream(randomSalt, 0);
48
+ const angleStream = particleRandomStream(randomSalt, 1);
49
+ for (let i = instanceBegin; i < instanceEnd; i++) {
50
+ const itemOffset = i * itemSize;
51
+ const magnitude = MathUtils.lerp(magnitudeMin, magnitudeMax, particleRandom(array, itemOffset, magnitudeStream));
52
+ let directionX = array[itemOffset + BUILTIN_OFFSET_POSITION_X] - centerX;
53
+ let directionY = array[itemOffset + BUILTIN_OFFSET_POSITION_Y] - centerY;
54
+ const length = Math.hypot(directionX, directionY);
55
+ if (length > 0) {
56
+ directionX /= length;
57
+ directionY /= length;
58
+ }
59
+ else {
60
+ const angle = particleRandom(array, itemOffset, angleStream) * Math.PI * 2;
61
+ directionX = Math.cos(angle);
62
+ directionY = Math.sin(angle);
63
+ }
64
+ array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] = directionX * magnitude;
65
+ array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] = directionY * magnitude;
66
+ }
67
+ builtin.needsUpdate = true;
68
+ }
69
+ assertValid(subject) {
70
+ assertValidNumber(this.magnitudeInternal.min, `${subject}.magnitude.min`);
71
+ assertValidNumber(this.magnitudeInternal.max, `${subject}.magnitude.max`);
72
+ assertValidNumber(this.centerInternal.x, `${subject}.center.x`);
73
+ assertValidNumber(this.centerInternal.y, `${subject}.center.y`);
74
+ }
75
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "keywords": [
6
6
  "ui",