laymur 0.27.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.
- package/README.md +2 -2
- package/dist/core/miscellaneous/canvas.js +3 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +2 -1
- package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.js +2 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +1 -1
- package/dist/debug/UIAspectDebug.js +4 -7
- package/dist/debug/UIHeightDebug.js +4 -4
- package/dist/debug/UIHorizontalDistanceDebug.js +4 -7
- package/dist/debug/UIHorizontalInterpolationDebug.js +11 -10
- package/dist/debug/UIVerticalDistanceDebug.js +4 -7
- package/dist/debug/UIVerticalInterpolationDebug.js +11 -10
- package/dist/debug/UIWidthDebug.js +4 -4
- package/dist/debug/miscellaneous.d.ts +7 -0
- package/dist/debug/miscellaneous.js +11 -1
- package/package.json +24 -21
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
|
|
11
11
|
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
12
12
|
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
|
|
13
|
-
<a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.157.0--0.
|
|
13
|
+
<a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.157.0--0.187.0-green" alt="Three.js"></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
## Features
|
|
@@ -32,7 +32,7 @@ npm install laymur
|
|
|
32
32
|
|
|
33
33
|
Peer Dependencies:
|
|
34
34
|
|
|
35
|
-
- `three` (>=0.157.0 <0.
|
|
35
|
+
- `three` (>=0.157.0 <0.188.0)
|
|
36
36
|
- `@lume/kiwi` (^0.4.4)
|
|
37
37
|
- `ferrsign` (^0.0.4)
|
|
38
38
|
- `fast-simplex-noise` (^4.0.0) - only required when using `laymur/particles`
|
|
@@ -44,5 +44,8 @@ export function createCanvasTexture(canvas) {
|
|
|
44
44
|
const texture = new CanvasTexture(canvas, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearFilter, RGBAFormat, UnsignedByteType, 1);
|
|
45
45
|
texture.colorSpace = checkSRGBSupport() ? SRGBColorSpace : NoColorSpace;
|
|
46
46
|
texture.generateMipmaps = false;
|
|
47
|
+
// The typings of three 0.181 and later make CanvasTexture generic over its image, with
|
|
48
|
+
// HTMLCanvasElement as the default; earlier ones have no type parameter to name UICanvas
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- needed from three 0.181 on
|
|
47
50
|
return texture;
|
|
48
51
|
}
|
|
@@ -212,7 +212,8 @@ export function buildMaterial(source, uniformProperties, layout, transparency, m
|
|
|
212
212
|
premultipliedAlpha,
|
|
213
213
|
});
|
|
214
214
|
if (masked) {
|
|
215
|
-
// fwidth on WebGL1 (three.js before r163); WebGL2 has derivatives built in
|
|
215
|
+
// fwidth on WebGL1 (three.js before r163); WebGL2 has derivatives built in. The typings of
|
|
216
|
+
// r163 and later no longer declare the flag
|
|
216
217
|
material.extensions.derivatives = true;
|
|
217
218
|
}
|
|
218
219
|
return { material, varyingRowCount: packed.rowCount };
|
|
@@ -101,7 +101,8 @@ function install(material, uniforms, baseCacheKey) {
|
|
|
101
101
|
? previousCompile.toString()
|
|
102
102
|
: baseCacheKey.call(material)) + CACHE_KEY_SUFFIX;
|
|
103
103
|
if (material instanceof ShaderMaterial) {
|
|
104
|
-
// fwidth on WebGL1 (three.js before r163); built-in materials fall back to world units
|
|
104
|
+
// fwidth on WebGL1 (three.js before r163); built-in materials fall back to world units.
|
|
105
|
+
// The typings of r163 and later no longer declare the flag
|
|
105
106
|
material.extensions.derivatives = true;
|
|
106
107
|
material.defines = { ...material.defines };
|
|
107
108
|
material.defines["LAYMUR_MASK_DERIVATIVES"] = "";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UIResizePolicy } from "./UIResizePolicy.js";
|
|
2
|
-
/** Scales area
|
|
2
|
+
/** Scales area so the rect covers it preserving proportions (like CSS object-fit: cover) */
|
|
3
3
|
export declare class UIResizePolicyCover extends UIResizePolicy {
|
|
4
4
|
private rectWidthInternal;
|
|
5
5
|
private rectHeightInternal;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assertValidPositiveNumber } from "../asserts.js";
|
|
2
2
|
import { UIResizePolicy } from "./UIResizePolicy.js";
|
|
3
|
-
/** Scales area
|
|
3
|
+
/** Scales area so the rect covers it preserving proportions (like CSS object-fit: cover) */
|
|
4
4
|
export class UIResizePolicyCover extends UIResizePolicy {
|
|
5
5
|
/**
|
|
6
6
|
* Creates cover resize policy.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UIResizePolicy } from "./UIResizePolicy.js";
|
|
2
|
-
/** Scales area
|
|
2
|
+
/** Scales area so the rect fits inside it preserving proportions (like CSS object-fit: contain) */
|
|
3
3
|
export declare class UIResizePolicyFit extends UIResizePolicy {
|
|
4
4
|
private rectWidthInternal;
|
|
5
5
|
private rectHeightInternal;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assertValidPositiveNumber } from "../asserts.js";
|
|
2
2
|
import { UIResizePolicy } from "./UIResizePolicy.js";
|
|
3
|
-
/** Scales area
|
|
3
|
+
/** Scales area so the rect fits inside it preserving proportions (like CSS object-fit: contain) */
|
|
4
4
|
export class UIResizePolicyFit extends UIResizePolicy {
|
|
5
5
|
/**
|
|
6
6
|
* Creates fit resize policy.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
6
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
7
7
|
export class UIAspectDebug {
|
|
8
8
|
constructor(constraint) {
|
|
9
9
|
this.constraint = constraint;
|
|
@@ -32,16 +32,13 @@ export class UIAspectDebug {
|
|
|
32
32
|
this.spriteMaterial.opacity = this.tint.a;
|
|
33
33
|
this.tint.setDirtyFalse();
|
|
34
34
|
}
|
|
35
|
-
renderer
|
|
35
|
+
updateDebugResolution(renderer);
|
|
36
36
|
this.diagonalMaterial.resolution.copy(debugResolutionVector);
|
|
37
37
|
const { x, y, oppositeX, oppositeY, width, height, centerX, centerY } = this.constraint.element;
|
|
38
38
|
if (width <= 0 || height <= 0) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
this.diagonalGeometry.
|
|
42
|
-
new Vector3(x, y, 0),
|
|
43
|
-
new Vector3(oppositeX, oppositeY, 0),
|
|
44
|
-
]);
|
|
41
|
+
this.diagonalGeometry.setPositions([x, y, 0, oppositeX, oppositeY, 0]);
|
|
45
42
|
const nextText = this.constraint.aspect.toFixed(2) + " (" + width.toFixed(0) + "x" + height.toFixed(0) + ")";
|
|
46
43
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
47
44
|
this.drawText(nextText);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
6
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
7
7
|
export class UIHeightDebug {
|
|
8
8
|
constructor(constraint) {
|
|
9
9
|
this.constraint = constraint;
|
|
@@ -32,13 +32,13 @@ export class UIHeightDebug {
|
|
|
32
32
|
this.spriteMaterial.opacity = this.tint.a;
|
|
33
33
|
this.tint.setDirtyFalse();
|
|
34
34
|
}
|
|
35
|
-
renderer
|
|
35
|
+
updateDebugResolution(renderer);
|
|
36
36
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
37
37
|
const { x, y, oppositeY, height, centerX, centerY } = this.constraint.element;
|
|
38
38
|
if (height <= 0) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
this.lineGeometry.
|
|
41
|
+
this.lineGeometry.setPositions([x, y, 0, x, oppositeY, 0]);
|
|
42
42
|
const nextText = "H: " + height.toFixed(0);
|
|
43
43
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
44
44
|
this.drawText(nextText);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
@@ -6,7 +6,7 @@ import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
|
|
|
6
6
|
import { LineSegmentsGeometry } from "three/addons/lines/LineSegmentsGeometry.js";
|
|
7
7
|
import { UIColor, UILayer, UIOrientation } from "../core/index.js";
|
|
8
8
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
9
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
9
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
10
10
|
export class UIHorizontalDistanceDebug {
|
|
11
11
|
constructor(constraint) {
|
|
12
12
|
this.constraint = constraint;
|
|
@@ -45,7 +45,7 @@ export class UIHorizontalDistanceDebug {
|
|
|
45
45
|
this.spriteMaterial.opacity = this.tint.a;
|
|
46
46
|
this.tint.setDirtyFalse();
|
|
47
47
|
}
|
|
48
|
-
renderer
|
|
48
|
+
updateDebugResolution(renderer);
|
|
49
49
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
50
50
|
this.tickMaterial.resolution.copy(debugResolutionVector);
|
|
51
51
|
const elementA = this.constraint.a;
|
|
@@ -63,10 +63,7 @@ export class UIHorizontalDistanceDebug {
|
|
|
63
63
|
: elementB instanceof UILayer
|
|
64
64
|
? anchorAY
|
|
65
65
|
: (anchorAY + anchorBY) / 2;
|
|
66
|
-
this.lineGeometry.
|
|
67
|
-
new Vector3(anchorAX, midY, 0),
|
|
68
|
-
new Vector3(anchorBX, midY, 0),
|
|
69
|
-
]);
|
|
66
|
+
this.lineGeometry.setPositions([anchorAX, midY, 0, anchorBX, midY, 0]);
|
|
70
67
|
const tickSize = 10;
|
|
71
68
|
this.tickGeometry.setPositions([
|
|
72
69
|
anchorAX,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
6
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
7
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
7
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
8
8
|
export class UIHorizontalInterpolationDebug {
|
|
9
9
|
constructor(constraint) {
|
|
10
10
|
this.constraint = constraint;
|
|
@@ -43,7 +43,7 @@ export class UIHorizontalInterpolationDebug {
|
|
|
43
43
|
this.spriteMaterial.opacity = this.tint.a;
|
|
44
44
|
this.tint.setDirtyFalse();
|
|
45
45
|
}
|
|
46
|
-
renderer
|
|
46
|
+
updateDebugResolution(renderer);
|
|
47
47
|
this.baseLineMaterial.resolution.copy(debugResolutionVector);
|
|
48
48
|
this.markerMaterial.resolution.copy(debugResolutionVector);
|
|
49
49
|
const elementA = this.constraint.a;
|
|
@@ -61,14 +61,15 @@ export class UIHorizontalInterpolationDebug {
|
|
|
61
61
|
? elementC.x + elementC.width * this.constraint.anchorC
|
|
62
62
|
: elementC.x;
|
|
63
63
|
const midY = (anchorAY + anchorBY) / 2;
|
|
64
|
-
this.baseLineGeometry.
|
|
65
|
-
new Vector3(anchorAX, midY, 0),
|
|
66
|
-
new Vector3(anchorBX, midY, 0),
|
|
67
|
-
]);
|
|
64
|
+
this.baseLineGeometry.setPositions([anchorAX, midY, 0, anchorBX, midY, 0]);
|
|
68
65
|
const markerSize = 12;
|
|
69
|
-
this.markerGeometry.
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
this.markerGeometry.setPositions([
|
|
67
|
+
anchorCX,
|
|
68
|
+
midY - markerSize,
|
|
69
|
+
0,
|
|
70
|
+
anchorCX,
|
|
71
|
+
midY + markerSize,
|
|
72
|
+
0,
|
|
72
73
|
]);
|
|
73
74
|
const nextText = "hi: " + this.constraint.t.toFixed(2);
|
|
74
75
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
@@ -6,7 +6,7 @@ import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
|
|
|
6
6
|
import { LineSegmentsGeometry } from "three/addons/lines/LineSegmentsGeometry.js";
|
|
7
7
|
import { UIColor, UILayer, UIOrientation } from "../core/index.js";
|
|
8
8
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
9
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
9
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
10
10
|
export class UIVerticalDistanceDebug {
|
|
11
11
|
constructor(constraint) {
|
|
12
12
|
this.constraint = constraint;
|
|
@@ -45,7 +45,7 @@ export class UIVerticalDistanceDebug {
|
|
|
45
45
|
this.spriteMaterial.opacity = this.tint.a;
|
|
46
46
|
this.tint.setDirtyFalse();
|
|
47
47
|
}
|
|
48
|
-
renderer
|
|
48
|
+
updateDebugResolution(renderer);
|
|
49
49
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
50
50
|
this.tickMaterial.resolution.copy(debugResolutionVector);
|
|
51
51
|
const elementA = this.constraint.a;
|
|
@@ -63,10 +63,7 @@ export class UIVerticalDistanceDebug {
|
|
|
63
63
|
: elementB instanceof UILayer
|
|
64
64
|
? anchorAX
|
|
65
65
|
: (anchorAX + anchorBX) / 2;
|
|
66
|
-
this.lineGeometry.
|
|
67
|
-
new Vector3(midX, anchorAY, 0),
|
|
68
|
-
new Vector3(midX, anchorBY, 0),
|
|
69
|
-
]);
|
|
66
|
+
this.lineGeometry.setPositions([midX, anchorAY, 0, midX, anchorBY, 0]);
|
|
70
67
|
const tickSize = 10;
|
|
71
68
|
this.tickGeometry.setPositions([
|
|
72
69
|
midX - tickSize,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
6
|
import { isUIPlaneElement } from "../core/miscellaneous/shared.js";
|
|
7
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
7
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
8
8
|
export class UIVerticalInterpolationDebug {
|
|
9
9
|
constructor(constraint) {
|
|
10
10
|
this.constraint = constraint;
|
|
@@ -43,7 +43,7 @@ export class UIVerticalInterpolationDebug {
|
|
|
43
43
|
this.spriteMaterial.opacity = this.tint.a;
|
|
44
44
|
this.tint.setDirtyFalse();
|
|
45
45
|
}
|
|
46
|
-
renderer
|
|
46
|
+
updateDebugResolution(renderer);
|
|
47
47
|
this.baseLineMaterial.resolution.copy(debugResolutionVector);
|
|
48
48
|
this.markerMaterial.resolution.copy(debugResolutionVector);
|
|
49
49
|
const elementA = this.constraint.a;
|
|
@@ -61,14 +61,15 @@ export class UIVerticalInterpolationDebug {
|
|
|
61
61
|
? elementC.y + elementC.height * this.constraint.anchorC
|
|
62
62
|
: elementC.y;
|
|
63
63
|
const midX = (anchorAX + anchorBX) / 2;
|
|
64
|
-
this.baseLineGeometry.
|
|
65
|
-
new Vector3(midX, anchorAY, 0),
|
|
66
|
-
new Vector3(midX, anchorBY, 0),
|
|
67
|
-
]);
|
|
64
|
+
this.baseLineGeometry.setPositions([midX, anchorAY, 0, midX, anchorBY, 0]);
|
|
68
65
|
const markerSize = 12;
|
|
69
|
-
this.markerGeometry.
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
this.markerGeometry.setPositions([
|
|
67
|
+
midX - markerSize,
|
|
68
|
+
anchorCY,
|
|
69
|
+
0,
|
|
70
|
+
midX + markerSize,
|
|
71
|
+
anchorCY,
|
|
72
|
+
0,
|
|
72
73
|
]);
|
|
73
74
|
const nextText = "vi: " + this.constraint.t.toFixed(2);
|
|
74
75
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CanvasTexture, Object3D, Sprite, SpriteMaterial
|
|
1
|
+
import { CanvasTexture, Object3D, Sprite, SpriteMaterial } from "three";
|
|
2
2
|
import { Line2 } from "three/addons/lines/Line2.js";
|
|
3
3
|
import { LineGeometry } from "three/addons/lines/LineGeometry.js";
|
|
4
4
|
import { LineMaterial } from "three/addons/lines/LineMaterial.js";
|
|
5
5
|
import { UIColor, UIOrientation } from "../core/index.js";
|
|
6
|
-
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, } from "./miscellaneous.js";
|
|
6
|
+
import { DEBUG_BADGE_BACKGROUND_COLOR, DEBUG_BADGE_FONT_FAMILY, DEBUG_BADGE_FONT_SIZE, DEBUG_BADGE_SIZE, DEBUG_LINE_WIDTH, DEBUG_RENDER_ORDER, debugResolutionVector, updateDebugResolution, } from "./miscellaneous.js";
|
|
7
7
|
export class UIWidthDebug {
|
|
8
8
|
constructor(constraint) {
|
|
9
9
|
this.constraint = constraint;
|
|
@@ -32,13 +32,13 @@ export class UIWidthDebug {
|
|
|
32
32
|
this.spriteMaterial.opacity = this.tint.a;
|
|
33
33
|
this.tint.setDirtyFalse();
|
|
34
34
|
}
|
|
35
|
-
renderer
|
|
35
|
+
updateDebugResolution(renderer);
|
|
36
36
|
this.lineMaterial.resolution.copy(debugResolutionVector);
|
|
37
37
|
const { x, y, oppositeX, width, centerX, centerY } = this.constraint.element;
|
|
38
38
|
if (width <= 0) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
this.lineGeometry.
|
|
41
|
+
this.lineGeometry.setPositions([x, y, 0, oppositeX, y, 0]);
|
|
42
42
|
const nextText = "W: " + width.toFixed(0);
|
|
43
43
|
if (nextText !== this.lastRenderedText || tintDirty) {
|
|
44
44
|
this.drawText(nextText);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
1
2
|
import { Vector2 } from "three";
|
|
2
3
|
export declare const DEBUG_RENDER_ORDER = 8192;
|
|
3
4
|
export declare const DEBUG_LINE_WIDTH = 2;
|
|
@@ -6,3 +7,9 @@ export declare const DEBUG_BADGE_FONT_SIZE = 30;
|
|
|
6
7
|
export declare const DEBUG_BADGE_FONT_FAMILY = "monospace";
|
|
7
8
|
export declare const DEBUG_BADGE_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.8)";
|
|
8
9
|
export declare const debugResolutionVector: Vector2;
|
|
10
|
+
/**
|
|
11
|
+
* Sets `debugResolutionVector` to the size of the current viewport, the value three.js 0.165 and
|
|
12
|
+
* later write into `LineMaterial.resolution` before each draw. Earlier versions keep the value
|
|
13
|
+
* set here, so line widths are the same on every version.
|
|
14
|
+
*/
|
|
15
|
+
export declare function updateDebugResolution(renderer: WebGLRenderer): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector2 } from "three";
|
|
1
|
+
import { Vector2, Vector4 } from "three";
|
|
2
2
|
export const DEBUG_RENDER_ORDER = 8192;
|
|
3
3
|
export const DEBUG_LINE_WIDTH = 2;
|
|
4
4
|
export const DEBUG_BADGE_SIZE = 150;
|
|
@@ -6,3 +6,13 @@ export const DEBUG_BADGE_FONT_SIZE = 30;
|
|
|
6
6
|
export const DEBUG_BADGE_FONT_FAMILY = "monospace";
|
|
7
7
|
export const DEBUG_BADGE_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.8)";
|
|
8
8
|
export const debugResolutionVector = new Vector2();
|
|
9
|
+
const debugViewport = new Vector4();
|
|
10
|
+
/**
|
|
11
|
+
* Sets `debugResolutionVector` to the size of the current viewport, the value three.js 0.165 and
|
|
12
|
+
* later write into `LineMaterial.resolution` before each draw. Earlier versions keep the value
|
|
13
|
+
* set here, so line widths are the same on every version.
|
|
14
|
+
*/
|
|
15
|
+
export function updateDebugResolution(renderer) {
|
|
16
|
+
renderer.getViewport(debugViewport);
|
|
17
|
+
debugResolutionVector.set(debugViewport.z, debugViewport.w);
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "laymur",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "Constraint-based UI library for Three.js mobile advertisements",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -11,29 +11,17 @@
|
|
|
11
11
|
"layout",
|
|
12
12
|
"typescript"
|
|
13
13
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"homepage": "https://github.com/jango-git/laymur#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/jango-git/laymur/issues"
|
|
17
|
+
},
|
|
16
18
|
"repository": {
|
|
17
19
|
"type": "git",
|
|
18
20
|
"url": "git+https://github.com/jango-git/laymur.git"
|
|
19
21
|
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "jango",
|
|
20
24
|
"type": "module",
|
|
21
|
-
"sideEffects": false,
|
|
22
|
-
"scripts": {
|
|
23
|
-
"clean": "rm -rf dist",
|
|
24
|
-
"build": "npm run clean && tsc -p tsconfig.json",
|
|
25
|
-
"lint": "eslint src",
|
|
26
|
-
"format": "prettier --write . && eslint src --fix",
|
|
27
|
-
"prepublishOnly": "npm run build"
|
|
28
|
-
},
|
|
29
|
-
"main": "./dist/core/index.js",
|
|
30
|
-
"module": "./dist/core/index.js",
|
|
31
|
-
"types": "./dist/core/index.d.ts",
|
|
32
|
-
"files": [
|
|
33
|
-
"dist",
|
|
34
|
-
"README.md",
|
|
35
|
-
"LICENSE"
|
|
36
|
-
],
|
|
37
25
|
"exports": {
|
|
38
26
|
".": {
|
|
39
27
|
"types": "./dist/core/index.d.ts",
|
|
@@ -49,11 +37,26 @@
|
|
|
49
37
|
},
|
|
50
38
|
"./package.json": "./package.json"
|
|
51
39
|
},
|
|
40
|
+
"main": "./dist/core/index.js",
|
|
41
|
+
"types": "./dist/core/index.d.ts",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"sideEffects": false,
|
|
48
|
+
"scripts": {
|
|
49
|
+
"clean": "rm -rf dist",
|
|
50
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
51
|
+
"lint": "eslint src",
|
|
52
|
+
"format": "prettier --write . && eslint src --fix",
|
|
53
|
+
"prepublishOnly": "npm run build"
|
|
54
|
+
},
|
|
52
55
|
"peerDependencies": {
|
|
53
56
|
"@lume/kiwi": "^0.4.4",
|
|
54
57
|
"fast-simplex-noise": "^4.0.0",
|
|
55
|
-
"ferrsign": "^0.0.
|
|
56
|
-
"three": ">=0.157.0 <0.
|
|
58
|
+
"ferrsign": "^0.0.6",
|
|
59
|
+
"three": ">=0.157.0 <0.188.0"
|
|
57
60
|
},
|
|
58
61
|
"peerDependenciesMeta": {
|
|
59
62
|
"fast-simplex-noise": {
|