laymur 0.19.3 → 0.21.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/README.md +20 -3
- package/dist/_virtual/2d.js +3 -0
- package/dist/_virtual/3d.js +3 -0
- package/dist/_virtual/4d.js +3 -0
- package/dist/_virtual/mod.js +5 -0
- package/dist/_virtual/mod2.js +3 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +0 -1
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +0 -1
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +22 -0
- package/dist/core/elements/UIElement/UIElement.Internal.js +21 -1
- package/dist/core/elements/UIElement/UIElement.d.ts +24 -0
- package/dist/core/elements/UIElement/UIElement.js +61 -2
- package/dist/core/elements/UIProgress/UIProgress.js +2 -1
- package/dist/core/elements/UIText/UIText.js +1 -8
- package/dist/core/index.d.ts +1 -0
- package/dist/core/miscellaneous/UIBlendMode.d.ts +7 -0
- package/dist/core/miscellaneous/UIBlendMode.js +10 -0
- package/dist/core/miscellaneous/UIRelation.d.ts +2 -2
- package/dist/core/miscellaneous/UIRelation.js +2 -2
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +50 -6
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +3 -1
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +80 -60
- package/dist/core/miscellaneous/generic-plane/shared.d.ts +9 -0
- package/dist/core/miscellaneous/generic-plane/shared.js +66 -2
- package/dist/core/miscellaneous/webglCapabilities.js +0 -1
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +2 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +4 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +4 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +8 -2
- package/dist/debug/UIAspectDebug.js +1 -1
- package/dist/index.js +1 -0
- package/dist/node_modules/fast-simplex-noise/lib/2d.js +93 -0
- package/dist/node_modules/fast-simplex-noise/lib/3d.js +142 -0
- package/dist/node_modules/fast-simplex-noise/lib/4d.js +196 -0
- package/dist/node_modules/fast-simplex-noise/lib/mod.js +24 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +3 -3
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +3 -3
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +0 -3
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +0 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +0 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +1 -3
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +0 -1
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +1 -3
- package/dist/particles/index.d.ts +1 -1
- package/dist/particles/index.js +1 -1
- package/dist/particles/miscellaneous/miscellaneous.d.ts +1 -1
- package/dist/particles/miscellaneous/miscellaneous.js +2 -4
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +6 -5
- package/dist/particles/renderingModules/UIRenderingTexture.js +55 -11
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* **Cassowary solver** - constraint-based layouts via `@lume/kiwi`
|
|
19
19
|
* **Orientation-aware** - define portrait and landscape rules in one layout, solver toggles automatically
|
|
20
20
|
* **Micro-transforms** - visual-only transforms (scale, rotation, offset) that bypass the solver
|
|
21
|
+
* **Color adjustment** - per-element hue/saturation/lightness and additive blend mode
|
|
21
22
|
* **Resize policies** - Cover, Fit, FixedHeight, FixedWidth, Cross strategies
|
|
22
23
|
* **Modular particles** - separate `laymur/particles` entry point, import only if needed
|
|
23
24
|
* **Debug overlay** - separate `laymur/debug` entry point, constraint visualization
|
|
@@ -33,6 +34,7 @@ Peer Dependencies:
|
|
|
33
34
|
* `three` (>=0.157.0 <0.180.0)
|
|
34
35
|
* `@lume/kiwi` (^0.4.4)
|
|
35
36
|
* `ferrsign` (^0.0.4)
|
|
37
|
+
* `fast-simplex-noise` (^4.0.0) - only required when using `laymur/particles`
|
|
36
38
|
|
|
37
39
|
## Visual Editor & Live Examples
|
|
38
40
|
|
|
@@ -105,9 +107,24 @@ element.micro.scaleX = Math.sin(Date.now() * 0.001) + 1;
|
|
|
105
107
|
element.micro.rotation += 0.01;
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
### 4.
|
|
110
|
+
### 4. Color Adjustment
|
|
109
111
|
|
|
110
|
-
|
|
112
|
+
Every element supports per-element color tweaks that run in the shader, independent of the layout solver.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { UIBlendMode } from 'laymur';
|
|
116
|
+
|
|
117
|
+
element.hue = 180; // hue shift in degrees
|
|
118
|
+
element.saturation = 0.5; // multiplier (1 = unchanged, 0 = grayscale)
|
|
119
|
+
element.lightness = 0.1; // offset (0 = unchanged)
|
|
120
|
+
|
|
121
|
+
// Additive blending (light accumulation), only affects BLEND transparency
|
|
122
|
+
element.blendMode = UIBlendMode.ADDITIVE;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 5. Particle System
|
|
126
|
+
|
|
127
|
+
Modular pipeline: Spawn -> Behavior -> Rendering.
|
|
111
128
|
|
|
112
129
|
```typescript
|
|
113
130
|
import { UIEmitter, UISpawnRectangle, UIBehaviorDirectionalGravity, UIRenderingTexture } from 'laymur/particles';
|
|
@@ -123,7 +140,7 @@ const emitter = new UIEmitter(
|
|
|
123
140
|
emitter.play(60); // particles/sec
|
|
124
141
|
```
|
|
125
142
|
|
|
126
|
-
###
|
|
143
|
+
### 6. Debug Overlay
|
|
127
144
|
|
|
128
145
|
`laymur/debug` renders visual overlays for constraints - useful during development to inspect layout relationships.
|
|
129
146
|
|
|
@@ -126,7 +126,6 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
126
126
|
else {
|
|
127
127
|
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");
|
|
128
128
|
}
|
|
129
|
-
// C - A*(1-t) - B*t = 0
|
|
130
129
|
const aScaled = aExpression.clone().multiply(1 - this._private_tInternal);
|
|
131
130
|
const bScaled = bExpression.clone().multiply(this._private_tInternal);
|
|
132
131
|
return UIExpression.minus(UIExpression.minus(cExpression, aScaled), bScaled);
|
package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js
CHANGED
|
@@ -126,7 +126,6 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
126
126
|
else {
|
|
127
127
|
throw new Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");
|
|
128
128
|
}
|
|
129
|
-
// C - A*(1-t) - B*t = 0
|
|
130
129
|
const aScaled = aExpression.clone().multiply(1 - this._private_tInternal);
|
|
131
130
|
const bScaled = bExpression.clone().multiply(this._private_tInternal);
|
|
132
131
|
return UIExpression.minus(UIExpression.minus(cExpression, aScaled), bScaled);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HSLAdjustment } from "../../miscellaneous/generic-plane/shared";
|
|
2
|
+
import { UIBlendMode } from "../../miscellaneous/UIBlendMode";
|
|
1
3
|
import type { UIMicroConfig } from "../../miscellaneous/micro/UIMicro.Internal";
|
|
2
4
|
import { UITransparencyMode } from "../../miscellaneous/UITransparencyMode";
|
|
3
5
|
import type { UIDummyOptions } from "../UIDummy/UIDummy.Internal";
|
|
@@ -7,5 +9,25 @@ export interface UIElementOptions extends UIDummyOptions {
|
|
|
7
9
|
micro: Partial<UIMicroConfig>;
|
|
8
10
|
/** Alpha blending mode */
|
|
9
11
|
transparencyMode: UITransparencyMode;
|
|
12
|
+
/** Color blending mode (only affects BLEND transparency) */
|
|
13
|
+
blendMode: UIBlendMode;
|
|
14
|
+
/** Hue shift in degrees */
|
|
15
|
+
hue: number;
|
|
16
|
+
/** Saturation multiplier (1 = unchanged, 0 = grayscale) */
|
|
17
|
+
saturation: number;
|
|
18
|
+
/** Lightness offset (0 = unchanged) */
|
|
19
|
+
lightness: number;
|
|
10
20
|
}
|
|
11
21
|
export declare const ELEMENT_DEFAULT_TRANSPARENCY_MODE = UITransparencyMode.BLEND;
|
|
22
|
+
export declare const ELEMENT_DEFAULT_BLEND_MODE = UIBlendMode.NORMAL;
|
|
23
|
+
export declare const ELEMENT_DEFAULT_HUE = 0;
|
|
24
|
+
export declare const ELEMENT_DEFAULT_SATURATION = 1;
|
|
25
|
+
export declare const ELEMENT_DEFAULT_LIGHTNESS = 0;
|
|
26
|
+
/** Maps a blend mode to the output-alpha multiplier used by the premultiplied shader. */
|
|
27
|
+
export declare function blendModeToFactor(mode: UIBlendMode): number;
|
|
28
|
+
/**
|
|
29
|
+
* Packs HSL adjustment into the shader attribute layout (hue in turns, saturation
|
|
30
|
+
* multiplier, lightness offset). Hue degrees become turns so the shader can wrap
|
|
31
|
+
* them with a cheap fract().
|
|
32
|
+
*/
|
|
33
|
+
export declare function packHSL(target: HSLAdjustment, hue: number, saturation: number, lightness: number): HSLAdjustment;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
import { UIBlendMode } from '../../miscellaneous/UIBlendMode.js';
|
|
1
2
|
import { UITransparencyMode } from '../../miscellaneous/UITransparencyMode.js';
|
|
2
3
|
|
|
3
4
|
const ELEMENT_DEFAULT_TRANSPARENCY_MODE = UITransparencyMode.BLEND;
|
|
5
|
+
const ELEMENT_DEFAULT_BLEND_MODE = UIBlendMode.NORMAL;
|
|
6
|
+
const ELEMENT_DEFAULT_HUE = 0;
|
|
7
|
+
const ELEMENT_DEFAULT_SATURATION = 1;
|
|
8
|
+
const ELEMENT_DEFAULT_LIGHTNESS = 0;
|
|
9
|
+
/** Maps a blend mode to the output-alpha multiplier used by the premultiplied shader. */
|
|
10
|
+
function blendModeToFactor(mode) {
|
|
11
|
+
return mode === UIBlendMode.ADDITIVE ? 0 : 1;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Packs HSL adjustment into the shader attribute layout (hue in turns, saturation
|
|
15
|
+
* multiplier, lightness offset). Hue degrees become turns so the shader can wrap
|
|
16
|
+
* them with a cheap fract().
|
|
17
|
+
*/
|
|
18
|
+
function packHSL(target, hue, saturation, lightness) {
|
|
19
|
+
target.h = hue / 360;
|
|
20
|
+
target.s = saturation;
|
|
21
|
+
target.l = lightness;
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
4
24
|
|
|
5
|
-
export { ELEMENT_DEFAULT_TRANSPARENCY_MODE };
|
|
25
|
+
export { ELEMENT_DEFAULT_BLEND_MODE, ELEMENT_DEFAULT_HUE, ELEMENT_DEFAULT_LIGHTNESS, ELEMENT_DEFAULT_SATURATION, ELEMENT_DEFAULT_TRANSPARENCY_MODE, blendModeToFactor, packHSL };
|
|
@@ -2,6 +2,7 @@ import type { WebGLRenderer } from "three";
|
|
|
2
2
|
import type { UILayer } from "../../layers/UILayer/UILayer";
|
|
3
3
|
import type { UIProperty } from "../../miscellaneous/generic-plane/shared";
|
|
4
4
|
import { UIMicro } from "../../miscellaneous/micro/UIMicro";
|
|
5
|
+
import type { UIBlendMode } from "../../miscellaneous/UIBlendMode";
|
|
5
6
|
import type { UIMode } from "../../miscellaneous/UIMode";
|
|
6
7
|
import type { UITransparencyMode } from "../../miscellaneous/UITransparencyMode";
|
|
7
8
|
import type { UISceneWrapperView } from "../../wrappers/UISceneWrapper/UISceneWrapper.Internal";
|
|
@@ -15,6 +16,13 @@ export declare abstract class UIElement extends UIDummy {
|
|
|
15
16
|
protected planeHandler: number;
|
|
16
17
|
private transparencyModeInternal;
|
|
17
18
|
private transparencyModeDirty;
|
|
19
|
+
private blendModeInternal;
|
|
20
|
+
private blendModeDirty;
|
|
21
|
+
private hueInternal;
|
|
22
|
+
private saturationInternal;
|
|
23
|
+
private lightnessInternal;
|
|
24
|
+
private hslDirty;
|
|
25
|
+
private readonly hslValue;
|
|
18
26
|
private visibilityDirty;
|
|
19
27
|
/**
|
|
20
28
|
* Creates a new UIElement instance.
|
|
@@ -27,8 +35,24 @@ export declare abstract class UIElement extends UIDummy {
|
|
|
27
35
|
constructor(layer: UILayer, source: string, properties: Record<string, UIProperty>, options?: Partial<UIElementOptions>);
|
|
28
36
|
/** Alpha blending mode */
|
|
29
37
|
get transparencyMode(): UITransparencyMode;
|
|
38
|
+
/** Color blending mode (only affects BLEND transparency) */
|
|
39
|
+
get blendMode(): UIBlendMode;
|
|
30
40
|
/** Alpha blending mode */
|
|
31
41
|
set transparencyMode(value: UITransparencyMode);
|
|
42
|
+
/** Color blending mode (only affects BLEND transparency) */
|
|
43
|
+
set blendMode(value: UIBlendMode);
|
|
44
|
+
/** Hue shift in degrees */
|
|
45
|
+
get hue(): number;
|
|
46
|
+
/** Hue shift in degrees */
|
|
47
|
+
set hue(value: number);
|
|
48
|
+
/** Saturation multiplier (1 = unchanged, 0 = grayscale) */
|
|
49
|
+
get saturation(): number;
|
|
50
|
+
/** Saturation multiplier (1 = unchanged, 0 = grayscale) */
|
|
51
|
+
set saturation(value: number);
|
|
52
|
+
/** Lightness offset (0 = unchanged) */
|
|
53
|
+
get lightness(): number;
|
|
54
|
+
/** Lightness offset (0 = unchanged) */
|
|
55
|
+
set lightness(value: number);
|
|
32
56
|
set mode(value: UIMode);
|
|
33
57
|
/** Removes element and frees resources */
|
|
34
58
|
destroy(): void;
|
|
@@ -3,7 +3,7 @@ import { computeTransformMatrix } from '../../miscellaneous/computeTransform.js'
|
|
|
3
3
|
import { UIMicro } from '../../miscellaneous/micro/UIMicro.js';
|
|
4
4
|
import { isUIModeVisible } from '../../miscellaneous/UIMode.js';
|
|
5
5
|
import { UIDummy } from '../UIDummy/UIDummy.js';
|
|
6
|
-
import { ELEMENT_DEFAULT_TRANSPARENCY_MODE } from './UIElement.Internal.js';
|
|
6
|
+
import { ELEMENT_DEFAULT_TRANSPARENCY_MODE, ELEMENT_DEFAULT_BLEND_MODE, ELEMENT_DEFAULT_HUE, ELEMENT_DEFAULT_SATURATION, ELEMENT_DEFAULT_LIGHTNESS, blendModeToFactor, packHSL } from './UIElement.Internal.js';
|
|
7
7
|
|
|
8
8
|
/** Base class for renderable UI elements */
|
|
9
9
|
class UIElement extends UIDummy {
|
|
@@ -18,20 +18,31 @@ class UIElement extends UIDummy {
|
|
|
18
18
|
constructor(layer, source, properties, options) {
|
|
19
19
|
super(layer, options);
|
|
20
20
|
this._private_transparencyModeDirty = false;
|
|
21
|
+
this._private_blendModeDirty = false;
|
|
22
|
+
this._private_hslDirty = false;
|
|
23
|
+
this._private_hslValue = { h: 0, s: 0, l: 0 };
|
|
21
24
|
this._private_visibilityDirty = false;
|
|
22
25
|
this._private_handleWillRender = (renderer, deltaTime) => {
|
|
23
26
|
this.onWillRender(renderer, deltaTime);
|
|
24
27
|
};
|
|
25
28
|
this.micro = new UIMicro(options?.micro);
|
|
26
29
|
this._private_transparencyModeInternal = options?.transparencyMode ?? ELEMENT_DEFAULT_TRANSPARENCY_MODE;
|
|
30
|
+
this._private_blendModeInternal = options?.blendMode ?? ELEMENT_DEFAULT_BLEND_MODE;
|
|
31
|
+
this._private_hueInternal = options?.hue ?? ELEMENT_DEFAULT_HUE;
|
|
32
|
+
this._private_saturationInternal = options?.saturation ?? ELEMENT_DEFAULT_SATURATION;
|
|
33
|
+
this._private_lightnessInternal = options?.lightness ?? ELEMENT_DEFAULT_LIGHTNESS;
|
|
27
34
|
this.sceneWrapper = this.layer.sceneWrapper;
|
|
28
|
-
this.planeHandler = this.sceneWrapper.createPlane(source, properties, new Matrix4().identity(), isUIModeVisible(options?.mode ?? this.mode), this._private_transparencyModeInternal);
|
|
35
|
+
this.planeHandler = this.sceneWrapper.createPlane(source, properties, new Matrix4().identity(), isUIModeVisible(options?.mode ?? this.mode), this._private_transparencyModeInternal, blendModeToFactor(this._private_blendModeInternal), packHSL(this._private_hslValue, this._private_hueInternal, this._private_saturationInternal, this._private_lightnessInternal));
|
|
29
36
|
this.layer.signalRendering.on(this._private_handleWillRender);
|
|
30
37
|
}
|
|
31
38
|
/** Alpha blending mode */
|
|
32
39
|
get transparencyMode() {
|
|
33
40
|
return this._private_transparencyModeInternal;
|
|
34
41
|
}
|
|
42
|
+
/** Color blending mode (only affects BLEND transparency) */
|
|
43
|
+
get blendMode() {
|
|
44
|
+
return this._private_blendModeInternal;
|
|
45
|
+
}
|
|
35
46
|
/** Alpha blending mode */
|
|
36
47
|
set transparencyMode(value) {
|
|
37
48
|
if (this._private_transparencyModeInternal !== value) {
|
|
@@ -39,6 +50,46 @@ class UIElement extends UIDummy {
|
|
|
39
50
|
this._private_transparencyModeDirty = true;
|
|
40
51
|
}
|
|
41
52
|
}
|
|
53
|
+
/** Color blending mode (only affects BLEND transparency) */
|
|
54
|
+
set blendMode(value) {
|
|
55
|
+
if (this._private_blendModeInternal !== value) {
|
|
56
|
+
this._private_blendModeInternal = value;
|
|
57
|
+
this._private_blendModeDirty = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Hue shift in degrees */
|
|
61
|
+
get hue() {
|
|
62
|
+
return this._private_hueInternal;
|
|
63
|
+
}
|
|
64
|
+
/** Hue shift in degrees */
|
|
65
|
+
set hue(value) {
|
|
66
|
+
if (this._private_hueInternal !== value) {
|
|
67
|
+
this._private_hueInternal = value;
|
|
68
|
+
this._private_hslDirty = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Saturation multiplier (1 = unchanged, 0 = grayscale) */
|
|
72
|
+
get saturation() {
|
|
73
|
+
return this._private_saturationInternal;
|
|
74
|
+
}
|
|
75
|
+
/** Saturation multiplier (1 = unchanged, 0 = grayscale) */
|
|
76
|
+
set saturation(value) {
|
|
77
|
+
if (this._private_saturationInternal !== value) {
|
|
78
|
+
this._private_saturationInternal = value;
|
|
79
|
+
this._private_hslDirty = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Lightness offset (0 = unchanged) */
|
|
83
|
+
get lightness() {
|
|
84
|
+
return this._private_lightnessInternal;
|
|
85
|
+
}
|
|
86
|
+
/** Lightness offset (0 = unchanged) */
|
|
87
|
+
set lightness(value) {
|
|
88
|
+
if (this._private_lightnessInternal !== value) {
|
|
89
|
+
this._private_lightnessInternal = value;
|
|
90
|
+
this._private_hslDirty = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
42
93
|
set mode(value) {
|
|
43
94
|
if (this.modeInternal !== value) {
|
|
44
95
|
this._private_visibilityDirty = isUIModeVisible(this.modeInternal) !== isUIModeVisible(value);
|
|
@@ -63,6 +114,14 @@ class UIElement extends UIDummy {
|
|
|
63
114
|
this.sceneWrapper.setTransparency(this.planeHandler, this._private_transparencyModeInternal);
|
|
64
115
|
this._private_transparencyModeDirty = false;
|
|
65
116
|
}
|
|
117
|
+
if (this._private_blendModeDirty) {
|
|
118
|
+
this.sceneWrapper.setBlend(this.planeHandler, blendModeToFactor(this._private_blendModeInternal));
|
|
119
|
+
this._private_blendModeDirty = false;
|
|
120
|
+
}
|
|
121
|
+
if (this._private_hslDirty) {
|
|
122
|
+
this.sceneWrapper.setHSL(this.planeHandler, packHSL(this._private_hslValue, this._private_hueInternal, this._private_saturationInternal, this._private_lightnessInternal));
|
|
123
|
+
this._private_hslDirty = false;
|
|
124
|
+
}
|
|
66
125
|
if (this._private_visibilityDirty) {
|
|
67
126
|
this.sceneWrapper.setVisibility(this.planeHandler, isUIModeVisible(this.modeInternal));
|
|
68
127
|
this._private_visibilityDirty = false;
|
|
@@ -7,6 +7,7 @@ import { UITextureView } from '../../miscellaneous/texture/UITextureView.js';
|
|
|
7
7
|
import { isUIModeVisible } from '../../miscellaneous/UIMode.js';
|
|
8
8
|
import source from '../../shaders/UIProgress.glsl.js';
|
|
9
9
|
import { UIElement } from '../UIElement/UIElement.js';
|
|
10
|
+
import { blendModeToFactor, packHSL } from '../UIElement/UIElement.Internal.js';
|
|
10
11
|
import { PROGRESS_DEFAULT_VALUE } from './UIProgress.Internal.js';
|
|
11
12
|
|
|
12
13
|
/** Progress bar with customizable fill direction */
|
|
@@ -150,7 +151,7 @@ class UIProgress extends UIElement {
|
|
|
150
151
|
color: this._private_colorInternal,
|
|
151
152
|
progress: this._private_progressInternal,
|
|
152
153
|
...this._private_maskFunctionInternal.enumerateProperties(),
|
|
153
|
-
}, computeTrimmedTransformMatrix(this.x, this.y, this.width, this.height, this.zIndex, micro.x, micro.y, micro.anchorX, micro.anchorY, micro.scaleX, micro.scaleY, micro.rotation, micro.anchorMode, textureTrim.left, textureTrim.right, textureTrim.top, textureTrim.bottom), isUIModeVisible(this.mode), this.transparencyMode);
|
|
154
|
+
}, computeTrimmedTransformMatrix(this.x, this.y, this.width, this.height, this.zIndex, micro.x, micro.y, micro.anchorX, micro.anchorY, micro.scaleX, micro.scaleY, micro.rotation, micro.anchorMode, textureTrim.left, textureTrim.right, textureTrim.top, textureTrim.bottom), isUIModeVisible(this.mode), this.transparencyMode, blendModeToFactor(this.blendMode), packHSL({ h: 0, s: 0, l: 0 }, this.hue, this.saturation, this.lightness));
|
|
154
155
|
this._private_colorInternal.setDirtyFalse();
|
|
155
156
|
this.texture.setTextureDirtyFalse();
|
|
156
157
|
this.texture.setUVTransformDirtyFalse();
|
|
@@ -162,10 +162,6 @@ class UIText extends UIElement {
|
|
|
162
162
|
const paddingH = this._private_paddingInternal.left + this._private_paddingInternal.right;
|
|
163
163
|
const desiredHeight = size.height + paddingV;
|
|
164
164
|
const desiredWidth = size.width + paddingH;
|
|
165
|
-
// Two calculation passes are required to cover both cases -
|
|
166
|
-
// when the width is specified by a constraint and cannot be changed,
|
|
167
|
-
// or when the height is specified by a constraint and cannot be changed,
|
|
168
|
-
// but the width still has priority, because it is specified first and last.
|
|
169
165
|
this.width = desiredWidth;
|
|
170
166
|
this.height = (desiredHeight / desiredWidth) * Math.round(this.width);
|
|
171
167
|
this.width = (desiredWidth / desiredHeight) * Math.round(this.height);
|
|
@@ -192,14 +188,11 @@ class UIText extends UIElement {
|
|
|
192
188
|
return;
|
|
193
189
|
}
|
|
194
190
|
const textChunks = this._private_buildTextChunks();
|
|
195
|
-
// Two passes of text size calculation are needed to first
|
|
196
|
-
// suggest the desired sizes to the solver, and then
|
|
197
|
-
// adjust our expectations based on the result obtained.
|
|
198
191
|
const { size: desiredTextSize } = calculateTextContentParameters(textChunks, this._private_maxLineWidthInternal);
|
|
199
192
|
const paddingV = this._private_paddingInternal.top + this._private_paddingInternal.bottom;
|
|
200
193
|
const paddingH = this._private_paddingInternal.left + this._private_paddingInternal.right;
|
|
201
194
|
this.height = desiredTextSize.height + paddingV;
|
|
202
|
-
this.width = desiredTextSize.width + paddingH;
|
|
195
|
+
this.width = desiredTextSize.width + paddingH;
|
|
203
196
|
const { lines: realTextLines, size: realTextSize } = calculateTextContentParameters(textChunks, Math.round(this.width) - paddingH);
|
|
204
197
|
this.height = realTextSize.height + paddingV;
|
|
205
198
|
this.width = realTextSize.width + paddingH;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -51,3 +51,4 @@ export { UIOrientation } from "./miscellaneous/UIOrientation";
|
|
|
51
51
|
export { UIPriority } from "./miscellaneous/UIPriority";
|
|
52
52
|
export { UIRelation } from "./miscellaneous/UIRelation";
|
|
53
53
|
export { UITransparencyMode } from "./miscellaneous/UITransparencyMode";
|
|
54
|
+
export { UIBlendMode } from "./miscellaneous/UIBlendMode";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Color blending modes */
|
|
2
|
+
var UIBlendMode;
|
|
3
|
+
(function (UIBlendMode) {
|
|
4
|
+
/** Standard alpha-over compositing. */
|
|
5
|
+
UIBlendMode[UIBlendMode["NORMAL"] = 0] = "NORMAL";
|
|
6
|
+
/** Additive blending (light accumulation). Only affects BLEND transparency. */
|
|
7
|
+
UIBlendMode[UIBlendMode["ADDITIVE"] = 1] = "ADDITIVE";
|
|
8
|
+
})(UIBlendMode || (UIBlendMode = {}));
|
|
9
|
+
|
|
10
|
+
export { UIBlendMode };
|
|
@@ -3,9 +3,9 @@ import { Operator } from "@lume/kiwi";
|
|
|
3
3
|
export declare enum UIRelation {
|
|
4
4
|
/** Equality: LHS = RHS */
|
|
5
5
|
EQUAL = 0,
|
|
6
|
-
/** Less than or equal: LHS
|
|
6
|
+
/** Less than or equal: LHS <= RHS */
|
|
7
7
|
LESS_THAN = 1,
|
|
8
|
-
/** Greater than or equal: LHS
|
|
8
|
+
/** Greater than or equal: LHS >= RHS */
|
|
9
9
|
GREATER_THAN = 2
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -5,9 +5,9 @@ var UIRelation;
|
|
|
5
5
|
(function (UIRelation) {
|
|
6
6
|
/** Equality: LHS = RHS */
|
|
7
7
|
UIRelation[UIRelation["EQUAL"] = 0] = "EQUAL";
|
|
8
|
-
/** Less than or equal: LHS
|
|
8
|
+
/** Less than or equal: LHS <= RHS */
|
|
9
9
|
UIRelation[UIRelation["LESS_THAN"] = 1] = "LESS_THAN";
|
|
10
|
-
/** Greater than or equal: LHS
|
|
10
|
+
/** Greater than or equal: LHS >= RHS */
|
|
11
11
|
UIRelation[UIRelation["GREATER_THAN"] = 2] = "GREATER_THAN";
|
|
12
12
|
})(UIRelation || (UIRelation = {}));
|
|
13
13
|
/**
|
package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Mesh, Matrix4, InstancedBufferAttribute } from 'three';
|
|
1
|
+
import { Mesh, Vector3, Matrix4, InstancedBufferAttribute } from 'three';
|
|
2
2
|
import { resolveGLSLTypeInfo, resolvePropertyUniform, cloneProperty, extractZIndexFromBuffer, cloneGLProperties, arePropertiesPartiallyCompatible } from '../shared.js';
|
|
3
3
|
import { INITIAL_CAPACITY, INSTANCED_PLANE_GEOMETRY, buildMaterial, CAPACITY_STEP, buildEmptyInstancedBufferAttribute, writePropertyToArray, reconstructValue, copyBetweenBuffers, shiftBufferRegion } from './UIGenericInstancedPlane.Internal.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Instanced shader plane mesh for batched rendering.
|
|
7
7
|
*
|
|
8
|
-
* Operates on indices, not handlers. Registry manages handler
|
|
8
|
+
* Operates on indices, not handlers. Registry manages handler->index mapping.
|
|
9
9
|
* Elements are ordered by zIndex (ascending) within the buffer.
|
|
10
10
|
*
|
|
11
11
|
* @internal
|
|
@@ -22,6 +22,14 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
22
22
|
value: new Matrix4().identity(),
|
|
23
23
|
glslTypeInfo: resolveGLSLTypeInfo("Matrix4"),
|
|
24
24
|
},
|
|
25
|
+
instanceBlend: {
|
|
26
|
+
value: 1,
|
|
27
|
+
glslTypeInfo: resolveGLSLTypeInfo("number"),
|
|
28
|
+
},
|
|
29
|
+
instanceHSL: {
|
|
30
|
+
value: new Vector3(0, 1, 0),
|
|
31
|
+
glslTypeInfo: resolveGLSLTypeInfo("Vector3"),
|
|
32
|
+
},
|
|
25
33
|
};
|
|
26
34
|
for (const name in properties) {
|
|
27
35
|
const descriptor = properties[name];
|
|
@@ -68,7 +76,7 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
68
76
|
/**
|
|
69
77
|
* Insert instance at given index. Elements at [index..end) are shifted right.
|
|
70
78
|
*/
|
|
71
|
-
insertAt(index, properties, transform, visibility) {
|
|
79
|
+
insertAt(index, properties, transform, visibility, blend, hsl) {
|
|
72
80
|
if (index < 0 || index > this._private_instancesCountInternal) {
|
|
73
81
|
throw new Error(`UIGenericInstancedPlane.insertAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
|
|
74
82
|
}
|
|
@@ -76,7 +84,7 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
76
84
|
if (index < this._private_instancesCountInternal) {
|
|
77
85
|
this._private_shiftBuffersRight(index, 1);
|
|
78
86
|
}
|
|
79
|
-
this._private_writeToBuffers(index, properties, transform, visibility);
|
|
87
|
+
this._private_writeToBuffers(index, properties, transform, visibility, blend, hsl);
|
|
80
88
|
this._private_instancesCountInternal++;
|
|
81
89
|
this._private_instancedGeometry.instanceCount = this._private_instancesCountInternal;
|
|
82
90
|
}
|
|
@@ -137,6 +145,29 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
137
145
|
array[index] = visible ? 1 : 0;
|
|
138
146
|
attribute.needsUpdate = true;
|
|
139
147
|
}
|
|
148
|
+
/** Update blend factor at given index (1 = normal over, 0 = additive) */
|
|
149
|
+
setBlendAt(index, blend) {
|
|
150
|
+
if (index < 0 || index >= this._private_instancesCountInternal) {
|
|
151
|
+
throw new Error(`UIGenericInstancedPlane.setBlendAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
|
|
152
|
+
}
|
|
153
|
+
const attribute = this._private_resolveAttribute("instanceBlend");
|
|
154
|
+
const array = attribute.array;
|
|
155
|
+
array[index] = blend;
|
|
156
|
+
attribute.needsUpdate = true;
|
|
157
|
+
}
|
|
158
|
+
/** Update HSL adjustment at given index (hue in turns, saturation multiplier, lightness offset) */
|
|
159
|
+
setHSLAt(index, hsl) {
|
|
160
|
+
if (index < 0 || index >= this._private_instancesCountInternal) {
|
|
161
|
+
throw new Error(`UIGenericInstancedPlane.setHSLAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
|
|
162
|
+
}
|
|
163
|
+
const attribute = this._private_resolveAttribute("instanceHSL");
|
|
164
|
+
const array = attribute.array;
|
|
165
|
+
const offset = index * 3;
|
|
166
|
+
array[offset] = hsl.h;
|
|
167
|
+
array[offset + 1] = hsl.s;
|
|
168
|
+
array[offset + 2] = hsl.l;
|
|
169
|
+
attribute.needsUpdate = true;
|
|
170
|
+
}
|
|
140
171
|
/**
|
|
141
172
|
* Extract complete instance data at given index.
|
|
142
173
|
* Returns cloned data safe for external use.
|
|
@@ -154,7 +185,10 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
154
185
|
};
|
|
155
186
|
}
|
|
156
187
|
for (const name in this._private_varyingProperties) {
|
|
157
|
-
if (name === "instanceVisibility" ||
|
|
188
|
+
if (name === "instanceVisibility" ||
|
|
189
|
+
name === "instanceTransform" ||
|
|
190
|
+
name === "instanceBlend" ||
|
|
191
|
+
name === "instanceHSL") {
|
|
158
192
|
continue;
|
|
159
193
|
}
|
|
160
194
|
const { value, glslTypeInfo } = this._private_varyingProperties[name];
|
|
@@ -308,10 +342,20 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
308
342
|
attribute.needsUpdate = true;
|
|
309
343
|
}
|
|
310
344
|
}
|
|
311
|
-
_private_writeToBuffers(index, properties, transform, visibility) {
|
|
345
|
+
_private_writeToBuffers(index, properties, transform, visibility, blend, hsl) {
|
|
312
346
|
const visibilityAttribute = this._private_resolveAttribute("instanceVisibility");
|
|
313
347
|
visibilityAttribute.array[index] = visibility ? 1 : 0;
|
|
314
348
|
visibilityAttribute.needsUpdate = true;
|
|
349
|
+
const blendAttribute = this._private_resolveAttribute("instanceBlend");
|
|
350
|
+
blendAttribute.array[index] = blend;
|
|
351
|
+
blendAttribute.needsUpdate = true;
|
|
352
|
+
const hslAttribute = this._private_resolveAttribute("instanceHSL");
|
|
353
|
+
const hslArray = hslAttribute.array;
|
|
354
|
+
const hslOffset = index * 3;
|
|
355
|
+
hslArray[hslOffset] = hsl.h;
|
|
356
|
+
hslArray[hslOffset + 1] = hsl.s;
|
|
357
|
+
hslArray[hslOffset + 2] = hsl.l;
|
|
358
|
+
hslAttribute.needsUpdate = true;
|
|
315
359
|
const transformAttribute = this._private_resolveAttribute("instanceTransform");
|
|
316
360
|
const transformArray = transformAttribute.array;
|
|
317
361
|
const transformOffset = index * 16;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Matrix4 } from "three";
|
|
2
2
|
import type { UITransparencyMode } from "../../UITransparencyMode";
|
|
3
|
-
import type { GLProperty } from "../shared";
|
|
3
|
+
import type { GLProperty, HSLAdjustment } from "../shared";
|
|
4
4
|
import type { UIGenericInstancedPlane } from "../UIGenericInstancedPlane/UIGenericInstancedPlane";
|
|
5
5
|
export interface PlaneDescriptor {
|
|
6
6
|
mesh: UIGenericInstancedPlane;
|
|
@@ -12,5 +12,7 @@ export interface PlaneState {
|
|
|
12
12
|
transform: Matrix4;
|
|
13
13
|
visibility: boolean;
|
|
14
14
|
transparency: UITransparencyMode;
|
|
15
|
+
blend: number;
|
|
16
|
+
hsl: HSLAdjustment;
|
|
15
17
|
zIndex: number;
|
|
16
18
|
}
|