laymur 0.26.0 → 0.27.1

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 (140) hide show
  1. package/README.md +80 -36
  2. package/dist/core/constraints/UICustomConstraint.d.ts +1 -1
  3. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +1 -1
  4. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +1 -1
  5. package/dist/core/constraints/builders/UIConstraint2DBuilder.d.ts +2 -3
  6. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.d.ts +2 -2
  7. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +24 -12
  8. package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +10 -0
  9. package/dist/core/elements/UIDummy/UIDummy.d.ts +42 -5
  10. package/dist/core/elements/UIDummy/UIDummy.js +119 -25
  11. package/dist/core/elements/UIElement/UIElement.Internal.d.ts +1 -1
  12. package/dist/core/elements/UIElement/UIElement.d.ts +14 -0
  13. package/dist/core/elements/UIElement/UIElement.js +34 -3
  14. package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +1 -1
  15. package/dist/core/elements/UIGraphics/UIGraphics.d.ts +1 -1
  16. package/dist/core/elements/UIGraphics/UIGraphics.js +2 -2
  17. package/dist/core/elements/UIImage/UIImage.d.ts +2 -2
  18. package/dist/core/elements/UIImage/UIImage.js +10 -8
  19. package/dist/core/elements/UINineSlice/UINineSlice.d.ts +4 -4
  20. package/dist/core/elements/UINineSlice/UINineSlice.js +11 -9
  21. package/dist/core/elements/UIProgress/UIProgress.d.ts +2 -2
  22. package/dist/core/elements/UIProgress/UIProgress.js +15 -10
  23. package/dist/core/elements/UIScene/UIScene.Internal.d.ts +1 -1
  24. package/dist/core/elements/UIScene/UIScene.d.ts +3 -2
  25. package/dist/core/elements/UIScene/UIScene.js +18 -12
  26. package/dist/core/elements/UIText/UIText.Measuring.d.ts +1 -1
  27. package/dist/core/elements/UIText/UIText.d.ts +3 -3
  28. package/dist/core/elements/UIText/UIText.js +6 -6
  29. package/dist/core/index.d.ts +44 -41
  30. package/dist/core/index.js +12 -9
  31. package/dist/core/layers/UILayer/UILayer.d.ts +40 -4
  32. package/dist/core/layers/UILayer/UILayer.js +70 -9
  33. package/dist/core/layers/UIViewportLayer/UIViewportLayer.Internal.d.ts +27 -0
  34. package/dist/core/layers/{UIFullscreenLayer/UIFullscreenLayer.Internal.js → UIViewportLayer/UIViewportLayer.Internal.js} +1 -1
  35. package/dist/core/layers/UIViewportLayer/UIViewportLayer.d.ts +98 -0
  36. package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +251 -0
  37. package/dist/core/miscellaneous/asserts.d.ts +14 -0
  38. package/dist/core/miscellaneous/asserts.js +28 -0
  39. package/dist/core/miscellaneous/canvas.js +10 -2
  40. package/dist/core/miscellaneous/color/UIColor.js +4 -2
  41. package/dist/core/miscellaneous/computeTransform.d.ts +12 -0
  42. package/dist/core/miscellaneous/computeTransform.js +20 -0
  43. package/dist/core/miscellaneous/context-monitor/UIContextMonitor.d.ts +1 -0
  44. package/dist/core/miscellaneous/context-monitor/UIContextMonitor.js +60 -0
  45. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +2 -1
  46. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +1 -1
  47. package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.js +2 -1
  48. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.d.ts +7 -4
  49. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +13 -6
  50. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +1 -1
  51. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +3 -3
  52. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +2 -2
  53. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +2 -2
  54. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +1 -1
  55. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +3 -3
  56. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +2 -2
  57. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +2 -2
  58. package/dist/core/miscellaneous/text-style/UITextStyle.js +2 -2
  59. package/dist/core/miscellaneous/texture/UITextureView.d.ts +4 -1
  60. package/dist/core/miscellaneous/texture/UITextureView.js +10 -7
  61. package/dist/core/miscellaneous/viewport/UIElementViewport.d.ts +31 -0
  62. package/dist/core/miscellaneous/viewport/UIElementViewport.js +54 -0
  63. package/dist/core/miscellaneous/viewport/UIViewport.d.ts +37 -0
  64. package/dist/core/miscellaneous/viewport/UIViewport.js +31 -0
  65. package/dist/core/miscellaneous/viewport/UIWindowViewport.d.ts +13 -0
  66. package/dist/core/miscellaneous/viewport/UIWindowViewport.js +25 -0
  67. package/dist/core/miscellaneous/webglCapabilities.js +61 -55
  68. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +36 -5
  69. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +23 -2
  70. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +153 -15
  71. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
  72. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +2 -0
  73. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +3 -0
  74. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +36 -16
  75. package/dist/debug/UIAspectDebug.js +8 -7
  76. package/dist/debug/UIHeightDebug.js +8 -4
  77. package/dist/debug/UIHorizontalDistanceDebug.js +9 -7
  78. package/dist/debug/UIHorizontalInterpolationDebug.js +16 -10
  79. package/dist/debug/UILayerDebug.d.ts +7 -0
  80. package/dist/debug/UILayerDebug.js +21 -0
  81. package/dist/debug/UIVerticalDistanceDebug.js +9 -7
  82. package/dist/debug/UIVerticalInterpolationDebug.js +16 -10
  83. package/dist/debug/UIWidthDebug.js +8 -4
  84. package/dist/debug/index.d.ts +1 -1
  85. package/dist/debug/miscellaneous.d.ts +7 -0
  86. package/dist/debug/miscellaneous.js +11 -1
  87. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +1 -1
  88. package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +5 -1
  89. package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +2 -2
  90. package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +13 -10
  91. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +1 -1
  92. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +6 -4
  93. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +1 -1
  94. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +4 -3
  95. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +2 -2
  96. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +8 -8
  97. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +4 -3
  98. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +8 -5
  99. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +1 -1
  100. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +8 -8
  101. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +7 -5
  102. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +12 -8
  103. package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -2
  104. package/dist/particles/elements/UIEmitter.Internal.js +6 -0
  105. package/dist/particles/elements/UIEmitter.d.ts +19 -3
  106. package/dist/particles/elements/UIEmitter.js +100 -54
  107. package/dist/particles/index.d.ts +3 -2
  108. package/dist/particles/index.js +1 -0
  109. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +8 -2
  110. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +16 -11
  111. package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +7 -0
  112. package/dist/particles/instancedParticle/UIInstancedParticle.js +37 -2
  113. package/dist/particles/miscellaneous/miscellaneous.d.ts +34 -0
  114. package/dist/particles/miscellaneous/miscellaneous.js +72 -0
  115. package/dist/particles/renderingModules/UIRenderingColorOverLife.js +2 -2
  116. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +2 -3
  117. package/dist/particles/renderingModules/UIRenderingModule.d.ts +3 -2
  118. package/dist/particles/renderingModules/UIRenderingModule.js +2 -1
  119. package/dist/particles/renderingModules/UIRenderingTexture.js +2 -1
  120. package/dist/particles/shaders/UIRenderingColorOverLife.d.ts +1 -2
  121. package/dist/particles/shaders/UIRenderingColorOverLife.js +5 -3
  122. package/dist/particles/shaders/UIRenderingColorOverVelocity.d.ts +1 -9
  123. package/dist/particles/shaders/UIRenderingColorOverVelocity.js +6 -13
  124. package/dist/particles/spawnModules/UISpawnModule.d.ts +5 -2
  125. package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +2 -2
  126. package/dist/particles/spawnModules/UISpawnRandomLifetime.js +5 -5
  127. package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +1 -1
  128. package/dist/particles/spawnModules/UISpawnRandomRotation.js +5 -3
  129. package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +1 -1
  130. package/dist/particles/spawnModules/UISpawnRandomScale.js +4 -3
  131. package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +1 -1
  132. package/dist/particles/spawnModules/UISpawnRandomTorque.js +5 -3
  133. package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +1 -1
  134. package/dist/particles/spawnModules/UISpawnRandomVelocity.js +6 -4
  135. package/dist/particles/spawnModules/UISpawnRectangle.d.ts +1 -1
  136. package/dist/particles/spawnModules/UISpawnRectangle.js +6 -4
  137. package/package.json +34 -22
  138. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -21
  139. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
  140. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +0 -144
@@ -1,144 +0,0 @@
1
- import { Ferrsign1 } from "ferrsign";
2
- import { MathUtils, Ray, Vector3 } from "three";
3
- import { assertValidNumber } from "../../miscellaneous/asserts.js";
4
- import { isUIModeInteractive } from "../../miscellaneous/UIMode.js";
5
- import { UILayer } from "../UILayer/UILayer.js";
6
- import { FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY } from "./UIFullscreenLayer.Internal.js";
7
- /** Layer that automatically handles browser window resizing and input events */
8
- export class UIFullscreenLayer extends UILayer {
9
- constructor(options) {
10
- const resizePolicy = options?.resizePolicy ?? FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY;
11
- const scale = resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
12
- super({
13
- width: window.innerWidth * scale,
14
- height: window.innerHeight * scale,
15
- ...options,
16
- });
17
- this.resizePolicyDirty = false;
18
- this.signalPointerPressedInternal = new Ferrsign1();
19
- this.signalPointerMovedInternal = new Ferrsign1();
20
- this.signalPointerReleasedInternal = new Ferrsign1();
21
- this.onResize = () => {
22
- const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
23
- this.resizePolicy.dirty = false;
24
- this.resizePolicyDirty = false;
25
- this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
26
- };
27
- this.onPointerDown = (event) => {
28
- this.handleWindowInput(event, "onPointerDown", this.signalPointerPressedInternal);
29
- };
30
- this.onPointerMove = (event) => {
31
- this.handleWindowInput(event, "onPointerMove", this.signalPointerMovedInternal);
32
- };
33
- this.onPointerUp = (event) => {
34
- this.handleWindowInput(event, "onPointerUp", this.signalPointerReleasedInternal);
35
- };
36
- this.resizePolicyInternal = resizePolicy;
37
- window.addEventListener("resize", this.onResize);
38
- window.addEventListener("pointerdown", this.onPointerDown);
39
- window.addEventListener("pointermove", this.onPointerMove);
40
- window.addEventListener("pointerup", this.onPointerUp);
41
- }
42
- /** Current resize policy */
43
- get resizePolicy() {
44
- return this.resizePolicyInternal;
45
- }
46
- /** Signal fired when pointer is pressed */
47
- get signalPointerPressed() {
48
- return this.signalPointerPressedInternal;
49
- }
50
- /** Signal fired when pointer is moved */
51
- get signalPointerMoved() {
52
- return this.signalPointerMovedInternal;
53
- }
54
- /** Signal fired when pointer is released */
55
- get signalPointerReleased() {
56
- return this.signalPointerReleasedInternal;
57
- }
58
- /** Updates resize policy */
59
- set resizePolicy(value) {
60
- if (this.resizePolicyInternal !== value) {
61
- this.resizePolicyInternal = value;
62
- this.resizePolicyDirty = true;
63
- }
64
- }
65
- /** Removes event listeners and destroys the layer with its elements and constraints */
66
- destroy() {
67
- window.removeEventListener("resize", this.onResize);
68
- window.removeEventListener("pointerdown", this.onPointerDown);
69
- window.removeEventListener("pointermove", this.onPointerMove);
70
- window.removeEventListener("pointerup", this.onPointerUp);
71
- super.destroy();
72
- }
73
- /**
74
- * Renders layer and all visible elements
75
- * @param renderer Three.js WebGL renderer
76
- * @param deltaTime Time since last frame in seconds
77
- */
78
- render(renderer, deltaTime) {
79
- assertValidNumber(deltaTime, "UIFullscreenLayer.render.deltaTime");
80
- if (this.destroyed) {
81
- return;
82
- }
83
- if (this.resizePolicy.dirty || this.resizePolicyDirty) {
84
- this.onResize();
85
- }
86
- super.renderInternal(renderer, deltaTime);
87
- }
88
- /**
89
- * Projects 3D world position to 2D layer coordinates
90
- * @param position World position
91
- * @param camera Three.js camera
92
- * @param result Reusable vector instance
93
- * @returns Layer coordinates
94
- */
95
- projectWorldPosition(position, camera, result = new Vector3()) {
96
- result.copy(position).project(camera);
97
- result.x = MathUtils.mapLinear(result.x, -1, 1, this.x, this.width);
98
- result.y = MathUtils.mapLinear(result.y, -1, 1, this.y, this.height);
99
- return result;
100
- }
101
- /**
102
- * Projects 2D layer coordinates to 3D world position
103
- * @param position Layer coordinates
104
- * @param camera Three.js camera
105
- * @param z Depth coordinate
106
- * @param result Reusable vector instance
107
- * @returns World position
108
- */
109
- projectLayerPosition(position, camera, z = -1, result = new Vector3()) {
110
- return result
111
- .set(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), z)
112
- .unproject(camera);
113
- }
114
- /**
115
- * Builds ray from layer position through camera
116
- * @param position Layer coordinates
117
- * @param camera Three.js camera
118
- * @param result Reusable ray instance
119
- * @returns Ray from near to far plane
120
- */
121
- buildRay(position, camera, result = new Ray()) {
122
- const near = new Vector3(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), -1).unproject(camera);
123
- const far = new Vector3(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), 1).unproject(camera);
124
- const direction = far.sub(near).normalize();
125
- return result.set(near, direction);
126
- }
127
- handleWindowInput(event, pointerFunctionName, signal) {
128
- const rect = event.target instanceof HTMLElement ? event.target.getBoundingClientRect() : null;
129
- const x = rect ? event.clientX - rect.left : event.clientX;
130
- const y = rect ? rect.bottom - event.clientY : window.innerHeight - event.clientY;
131
- const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
132
- const scaledX = x * scale;
133
- const scaledY = y * scale;
134
- if (isUIModeInteractive(this.mode)) {
135
- signal.emit({
136
- x: scaledX,
137
- y: scaledY,
138
- identifier: event.pointerId,
139
- layer: this,
140
- });
141
- this.inputWrapperInternal[pointerFunctionName](scaledX, scaledY, event.pointerId);
142
- }
143
- }
144
- }