laymur 0.2.1 → 0.2.3
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.
|
@@ -55,7 +55,7 @@ export declare class UIHorizontalProportionConstraint extends UISingleParameterC
|
|
|
55
55
|
*/
|
|
56
56
|
set proportion(value: number);
|
|
57
57
|
/**
|
|
58
|
-
* Builds the
|
|
58
|
+
* Builds the right-hand side expression for the constraint equation.
|
|
59
59
|
*
|
|
60
60
|
* Creates the expression: (elementA.width * proportion) - elementB.width = 0
|
|
61
61
|
* This enforces the relationship: elementA.width * proportion = elementB.width
|
|
@@ -63,5 +63,5 @@ export declare class UIHorizontalProportionConstraint extends UISingleParameterC
|
|
|
63
63
|
* @returns The UIExpression representing the proportional width relationship
|
|
64
64
|
* @private
|
|
65
65
|
*/
|
|
66
|
-
private
|
|
66
|
+
private buildRHS;
|
|
67
67
|
}
|
|
@@ -55,7 +55,7 @@ export declare class UIVerticalProportionConstraint extends UISingleParameterCon
|
|
|
55
55
|
*/
|
|
56
56
|
set proportion(value: number);
|
|
57
57
|
/**
|
|
58
|
-
* Builds the
|
|
58
|
+
* Builds the right-hand side expression for the constraint equation.
|
|
59
59
|
*
|
|
60
60
|
* Creates the expression: (elementA.height * proportion) - elementB.height = 0
|
|
61
61
|
* This enforces the relationship: elementA.height * proportion = elementB.height
|
|
@@ -63,5 +63,5 @@ export declare class UIVerticalProportionConstraint extends UISingleParameterCon
|
|
|
63
63
|
* @returns The UIExpression representing the proportional height relationship
|
|
64
64
|
* @private
|
|
65
65
|
*/
|
|
66
|
-
private
|
|
66
|
+
private buildRHS;
|
|
67
67
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Scene, OrthographicCamera, MathUtils, ShaderMaterial,
|
|
1
|
+
import { Color, Scene, OrthographicCamera, MathUtils, ShaderMaterial, PlaneGeometry, Mesh, UniformsUtils, WebGLRenderTarget, UnsignedByteType, LinearFilter, RGBAFormat, PerspectiveCamera, CanvasTexture } from 'three';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Mathematical expression builder for constraint equations in the UI layout system.
|
|
@@ -1815,6 +1815,7 @@ function resolvePriority(priority) {
|
|
|
1815
1815
|
return priority ?? UIPriority.P0;
|
|
1816
1816
|
}
|
|
1817
1817
|
|
|
1818
|
+
const tempColor = new Color();
|
|
1818
1819
|
class UISceneWrapper {
|
|
1819
1820
|
constructor(w, h) {
|
|
1820
1821
|
this._private_scene = new Scene();
|
|
@@ -1882,6 +1883,18 @@ class UISceneWrapper {
|
|
|
1882
1883
|
return Array.from(this._private_elements.keys()).sort((a, b) => this.getZIndex(a) - this.getZIndex(b));
|
|
1883
1884
|
}
|
|
1884
1885
|
render(renderer, deltaTime) {
|
|
1886
|
+
const originalRenderTarget = renderer.getRenderTarget();
|
|
1887
|
+
const originalClearColor = renderer.getClearColor(tempColor);
|
|
1888
|
+
const originalClearAlpha = renderer.getClearAlpha();
|
|
1889
|
+
const originalAutoClear = renderer.autoClear;
|
|
1890
|
+
const originalAutoClearColor = renderer.autoClearColor;
|
|
1891
|
+
const originalAutoClearDepth = renderer.autoClearDepth;
|
|
1892
|
+
const originalAutoClearStencil = renderer.autoClearStencil;
|
|
1893
|
+
renderer.autoClear = false;
|
|
1894
|
+
renderer.autoClearColor = false;
|
|
1895
|
+
renderer.autoClearDepth = false;
|
|
1896
|
+
renderer.autoClearStencil = false;
|
|
1897
|
+
renderer.setClearColor(0x000000, 1);
|
|
1885
1898
|
for (const [element, object] of this._private_elements) {
|
|
1886
1899
|
const micro = element.micro;
|
|
1887
1900
|
const cos = Math.cos(micro.rotation);
|
|
@@ -1899,7 +1912,15 @@ class UISceneWrapper {
|
|
|
1899
1912
|
object.rotation.z = micro.rotation;
|
|
1900
1913
|
element["onBeforeRenderInternal"](renderer, deltaTime);
|
|
1901
1914
|
}
|
|
1915
|
+
renderer.clear(false, true, true);
|
|
1902
1916
|
renderer.render(this._private_scene, this._private_camera);
|
|
1917
|
+
renderer.setRenderTarget(originalRenderTarget);
|
|
1918
|
+
renderer.setClearColor(originalClearColor);
|
|
1919
|
+
renderer.setClearAlpha(originalClearAlpha);
|
|
1920
|
+
renderer.autoClear = originalAutoClear;
|
|
1921
|
+
renderer.autoClearColor = originalAutoClearColor;
|
|
1922
|
+
renderer.autoClearDepth = originalAutoClearDepth;
|
|
1923
|
+
renderer.autoClearStencil = originalAutoClearStencil;
|
|
1903
1924
|
}
|
|
1904
1925
|
}
|
|
1905
1926
|
|
|
@@ -2056,8 +2077,10 @@ class UISolverWrapper {
|
|
|
2056
2077
|
relation,
|
|
2057
2078
|
enabled,
|
|
2058
2079
|
});
|
|
2059
|
-
|
|
2060
|
-
|
|
2080
|
+
if (enabled) {
|
|
2081
|
+
this._private_solver.addConstraint(constraint);
|
|
2082
|
+
this._private_recalculationRequired = true;
|
|
2083
|
+
}
|
|
2061
2084
|
return index;
|
|
2062
2085
|
}
|
|
2063
2086
|
removeConstraint(index) {
|
|
@@ -2882,7 +2905,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
2882
2905
|
this._private_a = _private_a;
|
|
2883
2906
|
this._private_b = _private_b;
|
|
2884
2907
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
2885
|
-
this.constraint = this.solverWrapper.createConstraint(
|
|
2908
|
+
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relationInternal, this.priorityInternal, this.isConstraintEnabled());
|
|
2886
2909
|
}
|
|
2887
2910
|
/**
|
|
2888
2911
|
* Gets the current proportion value being enforced.
|
|
@@ -2898,11 +2921,11 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
2898
2921
|
set proportion(value) {
|
|
2899
2922
|
if (this._private_proportionInternal !== value) {
|
|
2900
2923
|
this._private_proportionInternal = value;
|
|
2901
|
-
this.solverWrapper.
|
|
2924
|
+
this.solverWrapper.setConstraintRHS(this.constraint, this._private_buildRHS());
|
|
2902
2925
|
}
|
|
2903
2926
|
}
|
|
2904
2927
|
/**
|
|
2905
|
-
* Builds the
|
|
2928
|
+
* Builds the right-hand side expression for the constraint equation.
|
|
2906
2929
|
*
|
|
2907
2930
|
* Creates the expression: (elementA.width * proportion) - elementB.width = 0
|
|
2908
2931
|
* This enforces the relationship: elementA.width * proportion = elementB.width
|
|
@@ -2910,7 +2933,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
2910
2933
|
* @returns The UIExpression representing the proportional width relationship
|
|
2911
2934
|
* @private
|
|
2912
2935
|
*/
|
|
2913
|
-
|
|
2936
|
+
_private_buildRHS() {
|
|
2914
2937
|
return UIExpression.minus(new UIExpression(0, [[this._private_a.wVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.wVariable, 1]]));
|
|
2915
2938
|
}
|
|
2916
2939
|
}
|
|
@@ -3079,7 +3102,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
3079
3102
|
this._private_a = _private_a;
|
|
3080
3103
|
this._private_b = _private_b;
|
|
3081
3104
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
3082
|
-
this.constraint = this.solverWrapper.createConstraint(
|
|
3105
|
+
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relationInternal, this.priorityInternal, this.isConstraintEnabled());
|
|
3083
3106
|
}
|
|
3084
3107
|
/**
|
|
3085
3108
|
* Gets the current proportion value being enforced.
|
|
@@ -3095,11 +3118,11 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
3095
3118
|
set proportion(value) {
|
|
3096
3119
|
if (this._private_proportionInternal !== value) {
|
|
3097
3120
|
this._private_proportionInternal = value;
|
|
3098
|
-
this.solverWrapper.
|
|
3121
|
+
this.solverWrapper.setConstraintRHS(this.constraint, this._private_buildRHS());
|
|
3099
3122
|
}
|
|
3100
3123
|
}
|
|
3101
3124
|
/**
|
|
3102
|
-
* Builds the
|
|
3125
|
+
* Builds the right-hand side expression for the constraint equation.
|
|
3103
3126
|
*
|
|
3104
3127
|
* Creates the expression: (elementA.height * proportion) - elementB.height = 0
|
|
3105
3128
|
* This enforces the relationship: elementA.height * proportion = elementB.height
|
|
@@ -3107,7 +3130,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
3107
3130
|
* @returns The UIExpression representing the proportional height relationship
|
|
3108
3131
|
* @private
|
|
3109
3132
|
*/
|
|
3110
|
-
|
|
3133
|
+
_private_buildRHS() {
|
|
3111
3134
|
return UIExpression.minus(new UIExpression(0, [[this._private_a.hVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.hVariable, 1]]));
|
|
3112
3135
|
}
|
|
3113
3136
|
}
|
|
@@ -5330,7 +5353,6 @@ class UIFullscreenLayer extends UILayer {
|
|
|
5330
5353
|
*/
|
|
5331
5354
|
render(renderer, deltaTime) {
|
|
5332
5355
|
assertValidNumber(deltaTime, "UIFullscreenLayer.deltaTime");
|
|
5333
|
-
renderer.clear(false, true, true);
|
|
5334
5356
|
super.renderInternal(renderer, deltaTime);
|
|
5335
5357
|
}
|
|
5336
5358
|
/**
|