laymur 0.3.0 → 0.3.4

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.
@@ -1,5 +1,6 @@
1
1
  import { Eventail } from "eventail";
2
2
  import type { WebGLRenderer } from "three";
3
+ import type { UIPlaneElement } from "../miscellaneous/asserts";
3
4
  import { UIMode } from "../miscellaneous/UIMode";
4
5
  import { UIOrientation } from "../miscellaneous/UIOrientation";
5
6
  import type { UISceneWrapperClientAPI } from "../miscellaneous/UISceneWrapperClientAPI";
@@ -44,7 +45,7 @@ export declare enum UILayerEvent {
44
45
  * @see {@link UISceneWrapper} - 3D scene management
45
46
  * @see {@link UIOrientation} - Layer orientation states
46
47
  */
47
- export declare abstract class UILayer extends Eventail {
48
+ export declare abstract class UILayer extends Eventail implements UIPlaneElement {
48
49
  /** Optional name identifier for the layer. */
49
50
  name: string;
50
51
  /**
@@ -94,6 +95,16 @@ export declare abstract class UILayer extends Eventail {
94
95
  * @param h - Initial height of the layer
95
96
  */
96
97
  constructor(w: number, h: number);
98
+ /**
99
+ * Gets the current x position value from the constraint solver.
100
+ * @returns The current x position in pixels
101
+ */
102
+ get x(): number;
103
+ /**
104
+ * Gets the current y position value from the constraint solver.
105
+ * @returns The current y position in pixels
106
+ */
107
+ get y(): number;
97
108
  /**
98
109
  * Gets the current width value from the constraint solver.
99
110
  * @returns The current layer width in pixels
@@ -0,0 +1,32 @@
1
+ import { InstancedBufferAttribute, Matrix2, Matrix3, Matrix4, Mesh, Texture, Vector2, Vector3, Vector4 } from "three";
2
+ import { UIColor } from "../miscellaneous/UIColor";
3
+ import { UITransparencyMode } from "./UITransparencyMode";
4
+ export type UIPropertyType = Texture | UIColor | Vector2 | Vector3 | Vector4 | Matrix2 | Matrix3 | Matrix4 | number;
5
+ export type UIPropertyTypeName = "Texture" | "UIColor" | "Vector2" | "Vector3" | "Vector4" | "Matrix2" | "Matrix3" | "Matrix4" | "number";
6
+ interface Descriptor {
7
+ firstIndex: number;
8
+ count: number;
9
+ }
10
+ export declare class UIGenericInstancedPlane extends Mesh {
11
+ protected handlerToDescriptor: Map<number, Descriptor>;
12
+ protected lastHandler: number;
13
+ protected capacity: number;
14
+ protected propertyBuffers: Map<string, InstancedBufferAttribute>;
15
+ private readonly instancedGeometry;
16
+ private readonly shaderMaterial;
17
+ constructor(source: string, layout: Record<string, UIPropertyTypeName>, transparency?: UITransparencyMode, capacity?: number);
18
+ createInstances(count: number): number;
19
+ destroyInstances(handler: number): void;
20
+ updateProperties(handler: number, offset: number, instancesProperties: Record<string, UIPropertyType>[]): void;
21
+ updateTransforms(handler: number, offset: number, instancesTransforms: Matrix4[]): void;
22
+ updateUVTransforms(handler: number, offset: number, uvTransforms: Matrix3[]): void;
23
+ updateVisibility(handler: number, offset: number, instancesVisibility: boolean[]): void;
24
+ destroy(): void;
25
+ private resolveDescriptor;
26
+ private resolveBufferAttribute;
27
+ private resolveUniform;
28
+ private resizeGeometry;
29
+ private copyRangeData;
30
+ private shiftRangesDown;
31
+ }
32
+ export {};
@@ -1,4 +1,4 @@
1
- import type { Matrix4 } from "three";
1
+ import type { Matrix4, Object3D } from "three";
2
2
  import type { UITransparencyMode } from "./UITransparencyMode";
3
3
  export interface UISceneWrapperClientAPI {
4
4
  createPlane(source: string, uniforms: Record<string, unknown>): number;
@@ -7,4 +7,6 @@ export interface UISceneWrapperClientAPI {
7
7
  setUniform(handler: number, uniform: string, value: unknown): this;
8
8
  setTransparency(handler: number, mode: UITransparencyMode): this;
9
9
  setVisibility(handler: number, visible: boolean): this;
10
+ insertCustomObject(object: Object3D): this;
11
+ removeCustomObject(object: Object3D): this;
10
12
  }
@@ -9,7 +9,7 @@ export declare const EPSILON = 0.000001;
9
9
  */
10
10
  export interface UILayerElement {
11
11
  /** The UI layer that contains this element. */
12
- layer: UILayer;
12
+ readonly layer: UILayer;
13
13
  }
14
14
  /**
15
15
  * Interface for UI elements that have a position in 2D space.
@@ -19,13 +19,13 @@ export interface UILayerElement {
19
19
  */
20
20
  export interface UIPointElement {
21
21
  /** Solver variable descriptor for the x-coordinate. */
22
- xVariable: number;
22
+ readonly xVariable: number;
23
23
  /** Solver variable descriptor for the y-coordinate. */
24
- yVariable: number;
24
+ readonly yVariable: number;
25
25
  /** The x-coordinate of the element. */
26
- x: number;
26
+ readonly x: number;
27
27
  /** The y-coordinate of the element. */
28
- y: number;
28
+ readonly y: number;
29
29
  }
30
30
  /**
31
31
  * Interface for UI elements that have both position and dimensions in 2D space.
@@ -35,13 +35,13 @@ export interface UIPointElement {
35
35
  */
36
36
  export interface UIPlaneElement extends UIPointElement {
37
37
  /** Solver variable descriptor for the width dimension. */
38
- wVariable: number;
38
+ readonly wVariable: number;
39
39
  /** Solver variable descriptor for the height dimension. */
40
- hVariable: number;
40
+ readonly hVariable: number;
41
41
  /** The width of the element. */
42
- width: number;
42
+ readonly width: number;
43
43
  /** The height of the element. */
44
- height: number;
44
+ readonly height: number;
45
45
  }
46
46
  /**
47
47
  * Type guard to check if an object implements the UILayerElement interface.
@@ -1,7 +1,9 @@
1
- import type { WebGLRenderer } from "three";
2
- import { Matrix4, PlaneGeometry } from "three";
1
+ import type { Object3D, WebGLRenderer } from "three";
2
+ import { Color, Matrix2, Matrix3, Matrix4, PlaneGeometry, Texture, Vector2, Vector3, Vector4 } from "three";
3
+ import { UIColor } from "../miscellaneous/UIColor";
3
4
  import type { UISceneWrapperClientAPI } from "../miscellaneous/UISceneWrapperClientAPI";
4
5
  import { UITransparencyMode } from "../miscellaneous/UITransparencyMode";
6
+ type UIPropertyType = UIColor | Color | Texture | Vector2 | Vector3 | Vector4 | Matrix2 | Matrix3 | Matrix4;
5
7
  export declare const geometry: PlaneGeometry;
6
8
  export declare class UISceneWrapper implements UISceneWrapperClientAPI {
7
9
  private readonly scene;
@@ -9,13 +11,16 @@ export declare class UISceneWrapper implements UISceneWrapperClientAPI {
9
11
  private readonly descriptors;
10
12
  private lastPlaneIndex;
11
13
  constructor(w: number, h: number);
12
- createPlane(source: string, uniforms: Record<string, unknown>): number;
14
+ createPlane(source: string, uniforms: Record<string, UIPropertyType>): number;
13
15
  destroyPlane(handler: number): this;
14
16
  setTransform(handler: number, value: Matrix4): this;
15
- setUniform(handler: number, uniform: string, value: unknown): this;
17
+ setUniform(handler: number, uniform: string, value: UIPropertyType): this;
16
18
  setTransparency(handler: number, mode: UITransparencyMode): this;
17
19
  setVisibility(handler: number, visible: boolean): this;
20
+ insertCustomObject(object: Object3D): this;
21
+ removeCustomObject(object: Object3D): this;
18
22
  resize(width: number, height: number): this;
19
23
  render(renderer: WebGLRenderer): this;
20
24
  private resolveDescriptor;
21
25
  }
26
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.3.0",
4
- "description": "Lightweight Three.js UI toolkit mainly for mobile ads",
3
+ "version": "0.3.4",
4
+ "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
7
7
  "build": "npm run clean && rollup -c",
@@ -30,8 +30,11 @@
30
30
  "keywords": [
31
31
  "ui",
32
32
  "three.js",
33
- "typescript",
34
- "3d"
33
+ "mobile",
34
+ "ads",
35
+ "constraints",
36
+ "layout",
37
+ "typescript"
35
38
  ],
36
39
  "author": "jango",
37
40
  "license": "MIT",
File without changes
File without changes