laymur 0.8.0 → 0.9.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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PlaneGeometry, Color, Scene, OrthographicCamera, ShaderMaterial, Vector4, Mesh, Texture, Vector2, Vector3, Matrix2, Matrix3, Matrix4, MathUtils, Quaternion, CanvasTexture, LinearFilter, WebGLRenderTarget, UnsignedByteType, RGBAFormat, PerspectiveCamera, InstancedBufferGeometry, InstancedBufferAttribute } from 'three';
1
+ import { Color, PlaneGeometry, Scene, OrthographicCamera, ShaderMaterial, Vector4, Mesh, Texture, Vector2, Vector3, Matrix2, Matrix3, Matrix4, MathUtils, Quaternion, CanvasTexture, LinearFilter, WebGLRenderTarget, UnsignedByteType, RGBAFormat, PerspectiveCamera, InstancedBufferGeometry, InstancedBufferAttribute } from 'three';
2
2
 
3
3
  /**
4
4
  * Mathematical expression builder for constraint equations in the UI layout system.
@@ -2169,6 +2169,7 @@ var fragmentShader = "in vec2 io_UV;\n\nuniform float alphaTest;\n\n#include <co
2169
2169
  var vertexShader = "out vec2 io_UV;\n#include <common>\n\nvoid main() {\n #include <begin_vertex>\n io_UV = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
2170
2170
 
2171
2171
  const DEFAULT_ALPHA_TEST = 0.25;
2172
+ const COLOR = new Color();
2172
2173
  const UNIFROM_TYPE_MAP = new Map([
2173
2174
  [UIColor, "vec4"],
2174
2175
  [Color, "vec3"],
@@ -2258,7 +2259,9 @@ class UISceneWrapper {
2258
2259
  throw new Error(`Uniform ${uniform} not found in material`);
2259
2260
  }
2260
2261
  if (value instanceof UIColor) {
2261
- descriptor.material.uniforms[uniform].value.set(value.r, value.g, value.b, value.a);
2262
+ const linear = COLOR.set(value.r, value.g, value.b);
2263
+ linear.convertSRGBToLinear();
2264
+ descriptor.material.uniforms[uniform].value.set(linear.r, linear.g, linear.b, value.a);
2262
2265
  }
2263
2266
  else {
2264
2267
  descriptor.material.uniforms[uniform].value = value;
@@ -6691,7 +6694,6 @@ class UIResizePolicyNone extends UIResizePolicy {
6691
6694
  }
6692
6695
  }
6693
6696
 
6694
- const TEMP_POSITION = new Vector3();
6695
6697
  /**
6696
6698
  * UI layer that covers the full browser window.
6697
6699
  *
@@ -6777,24 +6779,21 @@ class UIFullscreenLayer extends UILayer {
6777
6779
  * @returns 2D position in layer space
6778
6780
  */
6779
6781
  projectWorldPosition(position, camera) {
6780
- const projectedPosition = TEMP_POSITION.copy(position).project(camera);
6782
+ const projectedPosition = position.clone().project(camera);
6781
6783
  projectedPosition.x = MathUtils.mapLinear(projectedPosition.x, -1, 1, this.x, this.width);
6782
6784
  projectedPosition.y = MathUtils.mapLinear(projectedPosition.y, -1, 1, this.y, this.height);
6783
- return new Vector2(projectedPosition.x, projectedPosition.y);
6785
+ return projectedPosition;
6784
6786
  }
6785
6787
  /**
6786
6788
  * Projects 2D layer position to 3D world coordinates.
6787
6789
  *
6788
6790
  * @param position - 2D position in layer space
6789
6791
  * @param camera - Camera for unprojection
6790
- * @param z - Z depth in camera space (defaults to 1)
6792
+ * @param z - z in NDC space (defaults to -1)
6791
6793
  * @returns 3D position in world space
6792
6794
  */
6793
6795
  projectLayerPosition(position, camera, z = -1) {
6794
- TEMP_POSITION.x = MathUtils.mapLinear(position.x, this.x, this.width, -1, 1);
6795
- TEMP_POSITION.y = MathUtils.mapLinear(position.y, this.y, this.height, -1, 1);
6796
- TEMP_POSITION.z = z;
6797
- return TEMP_POSITION.unproject(camera);
6796
+ return new Vector3(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), z).unproject(camera);
6798
6797
  }
6799
6798
  _private_handleWindowInput(event, pointerFunctionName, inputEvent) {
6800
6799
  const rect = event.target instanceof HTMLElement