laymur 0.17.7 → 0.18.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.
@@ -27,6 +27,7 @@ export { UISceneUpdateMode } from "./elements/UIScene/UIScene.Internal";
27
27
  export { UIText } from "./elements/UIText/UIText";
28
28
  export { UITextResizeMode } from "./elements/UIText/UIText.Internal";
29
29
  export { UIFullscreenLayer } from "./layers/UIFullscreenLayer/UIFullscreenLayer";
30
+ export type { UIFullscreenLayerInputEventData } from "./layers/UIFullscreenLayer/UIFullscreenLayer.Internal";
30
31
  export { UILayer } from "./layers/UILayer/UILayer";
31
32
  export { UIAreaCircle } from "./miscellaneous/area/UIAreaCircle";
32
33
  export { UIAreaPolygon } from "./miscellaneous/area/UIAreaPolygon";
@@ -1,9 +1,7 @@
1
1
  /** Transparency rendering modes */
2
2
  export declare enum UITransparencyMode {
3
- /** Binary transparency. Best performance. */
4
- CLIP = 0,
5
3
  /** Dithered transparency. Good performance. */
6
- HASH = 1,
7
- /** Alpha blending. Best quality, requires depth sorting. */
8
- BLEND = 2
4
+ HASH = 0,
5
+ /** Alpha blending. Best quality. */
6
+ BLEND = 1
9
7
  }
@@ -1,12 +1,10 @@
1
1
  /** Transparency rendering modes */
2
2
  var UITransparencyMode;
3
3
  (function (UITransparencyMode) {
4
- /** Binary transparency. Best performance. */
5
- UITransparencyMode[UITransparencyMode["CLIP"] = 0] = "CLIP";
6
4
  /** Dithered transparency. Good performance. */
7
- UITransparencyMode[UITransparencyMode["HASH"] = 1] = "HASH";
8
- /** Alpha blending. Best quality, requires depth sorting. */
9
- UITransparencyMode[UITransparencyMode["BLEND"] = 2] = "BLEND";
5
+ UITransparencyMode[UITransparencyMode["HASH"] = 0] = "HASH";
6
+ /** Alpha blending. Best quality. */
7
+ UITransparencyMode[UITransparencyMode["BLEND"] = 1] = "BLEND";
10
8
  })(UITransparencyMode || (UITransparencyMode = {}));
11
9
 
12
10
  export { UITransparencyMode };
@@ -1,7 +1,7 @@
1
1
  import { InstancedBufferGeometry, Uint16BufferAttribute, Float32BufferAttribute, Vector4, ShaderMaterial, DoubleSide, InstancedBufferAttribute, Vector2, Vector3, Matrix3, Matrix4 } from 'three';
2
2
  import { UIColor } from '../../color/UIColor.js';
3
3
  import { UITransparencyMode } from '../../UITransparencyMode.js';
4
- import { buildGenericPlaneFragmentShader, DEFAULT_ALPHA_TEST, resolveGLSLTypeInfo } from '../shared.js';
4
+ import { buildGenericPlaneFragmentShader, resolveGLSLTypeInfo } from '../shared.js';
5
5
 
6
6
  const INSTANCED_PLANE_GEOMETRY = (() => {
7
7
  const geometry = new InstancedBufferGeometry();
@@ -103,16 +103,17 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
103
103
  gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);
104
104
  }
105
105
  `;
106
- const fragmentShader = buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source);
106
+ const alphaTestValue = 1 / 255;
107
+ const fragmentShader = buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source, alphaTestValue);
107
108
  return new ShaderMaterial({
108
109
  uniforms,
109
110
  vertexShader,
110
111
  fragmentShader,
111
112
  transparent: transparency === UITransparencyMode.BLEND,
112
- alphaTest: transparency === UITransparencyMode.CLIP ? DEFAULT_ALPHA_TEST : 0.0,
113
+ alphaTest: alphaTestValue,
113
114
  alphaHash: transparency === UITransparencyMode.HASH,
114
- depthWrite: transparency !== UITransparencyMode.BLEND,
115
- depthTest: true,
115
+ depthWrite: false,
116
+ depthTest: false,
116
117
  side: DoubleSide,
117
118
  forceSinglePass: true,
118
119
  });
@@ -23,7 +23,6 @@ export interface PlaneData {
23
23
  visibility: boolean;
24
24
  transparency: UITransparencyMode;
25
25
  }
26
- export declare const DEFAULT_ALPHA_TEST = 0.5;
27
26
  export declare function resolveGLSLTypeInfo(value: UIProperty | UIPropertyName | UIPropertyConstructor): GLTypeInfo;
28
27
  export declare function resolvePropertyUniform(name: string, material: ShaderMaterial): IUniform<UIProperty>;
29
28
  export declare function arePropertiesPartiallyCompatible(full: Readonly<Record<string, Readonly<GLProperty>>>, partial: Readonly<Record<string, Readonly<GLProperty>>>): boolean;
@@ -35,4 +34,4 @@ export declare function cloneGLProperties(properties: Record<string, GLProperty>
35
34
  export declare function extractZIndex(transform: Matrix4): number;
36
35
  /** Extracts zIndex from transform buffer at given instance index */
37
36
  export declare function extractZIndexFromBuffer(buffer: Float32Array, instanceIndex: number): number;
38
- export declare function buildGenericPlaneFragmentShader(uniformDeclarations: string[], varyingDeclarations: string[], source: string): string;
37
+ export declare function buildGenericPlaneFragmentShader(uniformDeclarations: string[], varyingDeclarations: string[], source: string, alphaTestValue: number): string;
@@ -2,7 +2,6 @@ import { Texture, Vector2, Vector3, Vector4, Matrix3, Matrix4 } from 'three';
2
2
  import { UIColor } from '../color/UIColor.js';
3
3
  import { checkSRGBSupport } from '../webglCapabilities.js';
4
4
 
5
- const DEFAULT_ALPHA_TEST = 0.5;
6
5
  const GLSL_TYPE_INFO_FLOAT = Object.freeze({
7
6
  glslTypeName: "float",
8
7
  bufferSize: 1,
@@ -178,7 +177,7 @@ function extractZIndex(transform) {
178
177
  function extractZIndexFromBuffer(buffer, instanceIndex) {
179
178
  return buffer[instanceIndex * 16 + 14];
180
179
  }
181
- function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source) {
180
+ function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source, alphaTestValue) {
182
181
  return `
183
182
  // Defines
184
183
  #define PI 3.14159265359
@@ -210,11 +209,9 @@ function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclaration
210
209
  ${source}
211
210
  void main() {
212
211
  vec4 diffuseColor = draw();
213
- #ifdef USE_ALPHATEST
214
- if (diffuseColor.a < ${DEFAULT_ALPHA_TEST.toFixed(2)}) {
215
- discard;
216
- }
217
- #endif
212
+ if (diffuseColor.a <= ${alphaTestValue.toFixed(8)}) {
213
+ discard;
214
+ }
218
215
  #ifdef USE_ALPHAHASH
219
216
  if (diffuseColor.a < getAlphaHashThreshold(p_position)) {
220
217
  discard;
@@ -225,4 +222,4 @@ function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclaration
225
222
  `;
226
223
  }
227
224
 
228
- export { DEFAULT_ALPHA_TEST, arePropertiesPartiallyCompatible, buildGenericPlaneFragmentShader, cloneGLProperties, cloneProperties, cloneProperty, convertUIPropertiesToGLProperties, extractZIndex, extractZIndexFromBuffer, resolveGLSLTypeInfo, resolvePropertyUniform };
225
+ export { arePropertiesPartiallyCompatible, buildGenericPlaneFragmentShader, cloneGLProperties, cloneProperties, cloneProperty, convertUIPropertiesToGLProperties, extractZIndex, extractZIndexFromBuffer, resolveGLSLTypeInfo, resolvePropertyUniform };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.17.7",
3
+ "version": "0.18.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "keywords": [
6
6
  "ui",