@flighthq/render 0.3.0-next.1714.3bd86f1 → 0.3.0-next.1729.f927a3b
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,3 +1,3 @@
|
|
|
1
1
|
import type { RenderProxy, RenderState } from '@flighthq/types/contract';
|
|
2
|
-
export declare function updateRenderProxyColorScaleBias(state: RenderState, data: RenderProxy,
|
|
2
|
+
export declare function updateRenderProxyColorScaleBias(state: RenderState, data: RenderProxy, parentData?: RenderProxy): void;
|
|
3
3
|
//# sourceMappingURL=renderColorScaleBias.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderColorScaleBias.d.ts","sourceRoot":"","sources":["../src/renderColorScaleBias.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderColorScaleBias.d.ts","sourceRoot":"","sources":["../src/renderColorScaleBias.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAKV,WAAW,EACX,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAelC,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,CA2BrH"}
|
|
@@ -1,21 +1,99 @@
|
|
|
1
|
+
import { multiplyColorMatrix } from '@flighthq/adjustments/contract';
|
|
2
|
+
import { concatColorScaleBias, createColorScaleBias } from '@flighthq/materials/contract';
|
|
1
3
|
import { getNodeRuntime } from '@flighthq/node/contract';
|
|
2
4
|
import { getRenderStateRuntime } from './renderState';
|
|
3
5
|
// Hands the node's resolved color adjustment to the render node. A node's color-adjustment stack
|
|
4
6
|
// (NodeRuntime.colorAdjustments) is fused once into the affine `resolvedColorScaleBias` cache by the
|
|
5
|
-
// set-accessors on change — never per frame
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
7
|
+
// set-accessors on change — never per frame. The render walk then applies the local value first and its
|
|
8
|
+
// parent's inherited value second, matching the appearance and alpha axes: a transform on a container
|
|
9
|
+
// must reach every renderer-bearing descendant. Null and single-adjustment paths remain reference-only;
|
|
10
|
+
// only a node with both local and inherited adjustments performs composition. The result is the
|
|
11
|
+
// Adjustment-tier fold input; it is not a material and does not key the batch.
|
|
9
12
|
//
|
|
10
13
|
// Matrix-tier channel mixing travels through `resolvedColorMatrix`. A non-matrix operation that cannot
|
|
11
14
|
// be represented by either path leaves `colorAdjustmentsUnsupported` set, invoking the shakeable guard
|
|
12
15
|
// so unsupported adjustment data is reported rather than silently discarded.
|
|
13
|
-
export function updateRenderProxyColorScaleBias(state, data,
|
|
16
|
+
export function updateRenderProxyColorScaleBias(state, data, parentData) {
|
|
14
17
|
const runtime = getNodeRuntime(data.source);
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const localColorScaleBias = runtime.resolvedColorScaleBias ?? null;
|
|
19
|
+
const localColorMatrix = runtime.resolvedColorMatrix ?? null;
|
|
20
|
+
const parentColorScaleBias = parentData?.colorScaleBias ?? null;
|
|
21
|
+
const parentColorMatrix = parentData?.colorMatrix ?? null;
|
|
22
|
+
if (localColorMatrix !== null || parentColorMatrix !== null) {
|
|
23
|
+
data.colorMatrix = resolveInheritedColorMatrix(data.colorMatrix, parentColorMatrix, parentColorScaleBias, localColorMatrix, localColorScaleBias);
|
|
24
|
+
data.colorScaleBias = null;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
data.colorMatrix = null;
|
|
28
|
+
data.colorScaleBias = resolveInheritedColorScaleBias(data.colorScaleBias, parentColorScaleBias, localColorScaleBias);
|
|
29
|
+
}
|
|
17
30
|
if (runtime.colorAdjustmentsUnsupported) {
|
|
18
31
|
getRenderStateRuntime(state).colorAdjustmentUnsupportedGuard?.(state, data.source);
|
|
19
32
|
}
|
|
20
33
|
}
|
|
34
|
+
function resolveInheritedColorScaleBias(previous, parent, local) {
|
|
35
|
+
if (parent === null)
|
|
36
|
+
return local;
|
|
37
|
+
if (local === null)
|
|
38
|
+
return parent;
|
|
39
|
+
const out = previous !== parent && previous !== local && previous !== null && inheritedColorScaleBiases.has(previous)
|
|
40
|
+
? previous
|
|
41
|
+
: createInheritedColorScaleBias();
|
|
42
|
+
// SWF and scene-graph semantics apply the local adjustment first, then the parent's adjustment.
|
|
43
|
+
concatColorScaleBias(out, parent, local);
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
function resolveInheritedColorMatrix(previous, parentMatrix, parentColorScaleBias, localMatrix, localColorScaleBias) {
|
|
47
|
+
if (parentMatrix === null && parentColorScaleBias === null)
|
|
48
|
+
return localMatrix;
|
|
49
|
+
if (localMatrix === null && localColorScaleBias === null)
|
|
50
|
+
return parentMatrix;
|
|
51
|
+
const parent = parentMatrix ?? writeColorScaleBiasMatrix(parentColorMatrixScratch, parentColorScaleBias);
|
|
52
|
+
const local = localMatrix ?? writeColorScaleBiasMatrix(localColorMatrixScratch, localColorScaleBias);
|
|
53
|
+
const out = previous !== parentMatrix &&
|
|
54
|
+
previous !== localMatrix &&
|
|
55
|
+
previous !== null &&
|
|
56
|
+
previous !== undefined &&
|
|
57
|
+
inheritedColorMatrices.has(previous)
|
|
58
|
+
? previous
|
|
59
|
+
: createInheritedColorMatrix();
|
|
60
|
+
return multiplyColorMatrix(parent, local, out);
|
|
61
|
+
}
|
|
62
|
+
function writeColorScaleBiasMatrix(out, value) {
|
|
63
|
+
out[0] = value.redScale;
|
|
64
|
+
out[1] = 0;
|
|
65
|
+
out[2] = 0;
|
|
66
|
+
out[3] = 0;
|
|
67
|
+
out[4] = value.redBias;
|
|
68
|
+
out[5] = 0;
|
|
69
|
+
out[6] = value.greenScale;
|
|
70
|
+
out[7] = 0;
|
|
71
|
+
out[8] = 0;
|
|
72
|
+
out[9] = value.greenBias;
|
|
73
|
+
out[10] = 0;
|
|
74
|
+
out[11] = 0;
|
|
75
|
+
out[12] = value.blueScale;
|
|
76
|
+
out[13] = 0;
|
|
77
|
+
out[14] = value.blueBias;
|
|
78
|
+
out[15] = 0;
|
|
79
|
+
out[16] = 0;
|
|
80
|
+
out[17] = 0;
|
|
81
|
+
out[18] = value.alphaScale;
|
|
82
|
+
out[19] = value.alphaBias;
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
function createInheritedColorScaleBias() {
|
|
86
|
+
const value = createColorScaleBias();
|
|
87
|
+
inheritedColorScaleBiases.add(value);
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
function createInheritedColorMatrix() {
|
|
91
|
+
const value = new Array(20);
|
|
92
|
+
inheritedColorMatrices.add(value);
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
const inheritedColorScaleBiases = new WeakSet();
|
|
96
|
+
const inheritedColorMatrices = new WeakSet();
|
|
97
|
+
const parentColorMatrixScratch = new Array(20);
|
|
98
|
+
const localColorMatrixScratch = new Array(20);
|
|
21
99
|
//# sourceMappingURL=renderColorScaleBias.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderColorScaleBias.js","sourceRoot":"","sources":["../src/renderColorScaleBias.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderColorScaleBias.js","sourceRoot":"","sources":["../src/renderColorScaleBias.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAUzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,iGAAiG;AACjG,qGAAqG;AACrG,wGAAwG;AACxG,sGAAsG;AACtG,wGAAwG;AACxG,gGAAgG;AAChG,+EAA+E;AAC/E,EAAE;AACF,uGAAuG;AACvG,uGAAuG;AACvG,6EAA6E;AAC7E,MAAM,UAAU,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MAAM,sBAAsB,GAAG,IAAI,OAAO,EAAqB,CAAC;AAChE,MAAM,wBAAwB,GAAG,IAAI,KAAK,CAAS,EAAE,CAAC,CAAC;AACvD,MAAM,uBAAuB,GAAG,IAAI,KAAK,CAAS,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/render",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.1729.f927a3b",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flighthq/
|
|
40
|
-
"@flighthq/
|
|
41
|
-
"@flighthq/
|
|
42
|
-
"@flighthq/
|
|
43
|
-
"@flighthq/
|
|
44
|
-
"@flighthq/
|
|
45
|
-
"@flighthq/
|
|
46
|
-
"@flighthq/
|
|
47
|
-
"@flighthq/
|
|
39
|
+
"@flighthq/adjustments": "0.3.0-next.1729.f927a3b",
|
|
40
|
+
"@flighthq/color": "0.3.0-next.1729.f927a3b",
|
|
41
|
+
"@flighthq/entity": "0.3.0-next.1729.f927a3b",
|
|
42
|
+
"@flighthq/geometry": "0.3.0-next.1729.f927a3b",
|
|
43
|
+
"@flighthq/log": "0.3.0-next.1729.f927a3b",
|
|
44
|
+
"@flighthq/materials": "0.3.0-next.1729.f927a3b",
|
|
45
|
+
"@flighthq/mesh": "0.3.0-next.1729.f927a3b",
|
|
46
|
+
"@flighthq/node": "0.3.0-next.1729.f927a3b",
|
|
47
|
+
"@flighthq/signals": "0.3.0-next.1729.f927a3b",
|
|
48
|
+
"@flighthq/types": "0.3.0-next.1729.f927a3b"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@flighthq/adjustments": "*",
|
|
51
51
|
"@flighthq/camera": "*",
|
|
52
52
|
"@flighthq/scene2d": "*",
|
|
53
53
|
"@flighthq/lighting": "*",
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
applyColorMatrixToColor,
|
|
3
|
+
createColorMatrixAdjustment,
|
|
4
|
+
createColorScaleBiasAdjustment,
|
|
5
|
+
createTintAdjustment,
|
|
6
|
+
} from '@flighthq/adjustments/contract';
|
|
7
|
+
import { addNodeChild, setNodeColorAdjustments } from '@flighthq/node/contract';
|
|
3
8
|
import { createDisplayObject, getNode2DRuntime } from '@flighthq/scene2d/contract';
|
|
4
9
|
import type { Renderable } from '@flighthq/types/contract';
|
|
5
10
|
|
|
6
11
|
import { updateRenderProxyColorScaleBias } from './renderColorScaleBias';
|
|
7
|
-
import { createRenderProxy } from './renderProxy';
|
|
12
|
+
import { createRenderProxy, getRenderProxy2D, prepareScene2DRender } from './renderProxy';
|
|
8
13
|
import { createRenderState } from './renderState';
|
|
9
14
|
|
|
10
15
|
describe('updateRenderProxyColorScaleBias', () => {
|
|
@@ -27,6 +32,7 @@ describe('updateRenderProxyColorScaleBias', () => {
|
|
|
27
32
|
const data = createRenderProxy(state, node as unknown as Renderable);
|
|
28
33
|
updateRenderProxyColorScaleBias(state, data);
|
|
29
34
|
expect(data.colorMatrix).toEqual(matrix);
|
|
35
|
+
expect(data.colorScaleBias).toBeNull();
|
|
30
36
|
});
|
|
31
37
|
|
|
32
38
|
it('resolves to null when the node carries no adjustments', () => {
|
|
@@ -35,6 +41,151 @@ describe('updateRenderProxyColorScaleBias', () => {
|
|
|
35
41
|
const data = createRenderProxy(state, node as unknown as Renderable);
|
|
36
42
|
updateRenderProxyColorScaleBias(state, data);
|
|
37
43
|
expect(data.colorScaleBias).toBeNull();
|
|
44
|
+
expect(data.colorMatrix).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('inherits a parent adjustment when the renderer-bearing child has none of its own', () => {
|
|
48
|
+
const state = createRenderState();
|
|
49
|
+
const parent = createDisplayObject();
|
|
50
|
+
const child = createDisplayObject();
|
|
51
|
+
setNodeColorAdjustments(parent, [createTintAdjustment(0x80ff33ff)]);
|
|
52
|
+
const parentData = createRenderProxy(state, parent as unknown as Renderable);
|
|
53
|
+
const childData = createRenderProxy(state, child as unknown as Renderable);
|
|
54
|
+
updateRenderProxyColorScaleBias(state, parentData);
|
|
55
|
+
updateRenderProxyColorScaleBias(state, childData, parentData);
|
|
56
|
+
expect(childData.colorScaleBias).toBe(parentData.colorScaleBias);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('carries a container adjustment to its child through the real render walk', () => {
|
|
60
|
+
const state = createRenderState();
|
|
61
|
+
const parent = createDisplayObject();
|
|
62
|
+
const child = createDisplayObject();
|
|
63
|
+
addNodeChild(parent, child);
|
|
64
|
+
setNodeColorAdjustments(parent, [createTintAdjustment(0x80ff33ff)]);
|
|
65
|
+
prepareScene2DRender(state, parent);
|
|
66
|
+
expect(getRenderProxy2D(state, child)?.colorScaleBias).toBe(getRenderProxy2D(state, parent)?.colorScaleBias);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('refreshes inherited adjustments through descendants when an ancestor changes', () => {
|
|
70
|
+
const state = createRenderState();
|
|
71
|
+
const root = createDisplayObject();
|
|
72
|
+
const parent = createDisplayObject();
|
|
73
|
+
const child = createDisplayObject();
|
|
74
|
+
addNodeChild(root, parent);
|
|
75
|
+
addNodeChild(parent, child);
|
|
76
|
+
setNodeColorAdjustments(root, [createTintAdjustment(0x80ffffff)]);
|
|
77
|
+
setNodeColorAdjustments(parent, [createTintAdjustment(0xff8033ff)]);
|
|
78
|
+
|
|
79
|
+
prepareScene2DRender(state, root);
|
|
80
|
+
const first = getRenderProxy2D(state, child)?.colorScaleBias;
|
|
81
|
+
expect(first?.redScale).toBeCloseTo(0.5 * 1);
|
|
82
|
+
expect(first?.greenScale).toBeCloseTo(1 * 0.5);
|
|
83
|
+
|
|
84
|
+
setNodeColorAdjustments(root, [createTintAdjustment(0x40ffffff)]);
|
|
85
|
+
prepareScene2DRender(state, root);
|
|
86
|
+
const second = getRenderProxy2D(state, child)?.colorScaleBias;
|
|
87
|
+
expect(second?.redScale).toBeCloseTo(0.25 * 1);
|
|
88
|
+
expect(second?.greenScale).toBeCloseTo(1 * 0.5);
|
|
89
|
+
|
|
90
|
+
setNodeColorAdjustments(parent, null);
|
|
91
|
+
prepareScene2DRender(state, root);
|
|
92
|
+
expect(getRenderProxy2D(state, child)?.colorScaleBias).toBe(getRenderProxy2D(state, root)?.colorScaleBias);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('concatenates a parent affine adjustment after the child adjustment', () => {
|
|
96
|
+
const state = createRenderState();
|
|
97
|
+
const parent = createDisplayObject();
|
|
98
|
+
const child = createDisplayObject();
|
|
99
|
+
setNodeColorAdjustments(parent, [
|
|
100
|
+
createColorScaleBiasAdjustment({
|
|
101
|
+
redScale: 0.5,
|
|
102
|
+
redBias: 0.1,
|
|
103
|
+
greenScale: 1,
|
|
104
|
+
greenBias: 0,
|
|
105
|
+
blueScale: 1,
|
|
106
|
+
blueBias: 0,
|
|
107
|
+
alphaScale: 1,
|
|
108
|
+
alphaBias: 0,
|
|
109
|
+
}),
|
|
110
|
+
]);
|
|
111
|
+
setNodeColorAdjustments(child, [
|
|
112
|
+
createColorScaleBiasAdjustment({
|
|
113
|
+
redScale: 0.25,
|
|
114
|
+
redBias: 0.2,
|
|
115
|
+
greenScale: 1,
|
|
116
|
+
greenBias: 0,
|
|
117
|
+
blueScale: 1,
|
|
118
|
+
blueBias: 0,
|
|
119
|
+
alphaScale: 1,
|
|
120
|
+
alphaBias: 0,
|
|
121
|
+
}),
|
|
122
|
+
]);
|
|
123
|
+
const parentData = createRenderProxy(state, parent as unknown as Renderable);
|
|
124
|
+
const childData = createRenderProxy(state, child as unknown as Renderable);
|
|
125
|
+
updateRenderProxyColorScaleBias(state, parentData);
|
|
126
|
+
updateRenderProxyColorScaleBias(state, childData, parentData);
|
|
127
|
+
expect(childData.colorScaleBias?.redScale).toBeCloseTo(0.125);
|
|
128
|
+
expect(childData.colorScaleBias?.redBias).toBeCloseTo(0.2);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('promotes a parent affine and child matrix to one parent-after-child matrix', () => {
|
|
132
|
+
const state = createRenderState();
|
|
133
|
+
const parent = createDisplayObject();
|
|
134
|
+
const child = createDisplayObject();
|
|
135
|
+
const parentAdjustment = createColorScaleBiasAdjustment({
|
|
136
|
+
redScale: 0.5,
|
|
137
|
+
redBias: 0.1,
|
|
138
|
+
greenScale: 1,
|
|
139
|
+
greenBias: 0,
|
|
140
|
+
blueScale: 1,
|
|
141
|
+
blueBias: 0,
|
|
142
|
+
alphaScale: 1,
|
|
143
|
+
alphaBias: 0,
|
|
144
|
+
});
|
|
145
|
+
const childMatrix = [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
146
|
+
setNodeColorAdjustments(parent, [parentAdjustment]);
|
|
147
|
+
setNodeColorAdjustments(child, [createColorMatrixAdjustment(childMatrix)]);
|
|
148
|
+
const parentData = createRenderProxy(state, parent as unknown as Renderable);
|
|
149
|
+
const childData = createRenderProxy(state, child as unknown as Renderable);
|
|
150
|
+
updateRenderProxyColorScaleBias(state, parentData);
|
|
151
|
+
updateRenderProxyColorScaleBias(state, childData, parentData);
|
|
152
|
+
const source = 0x204060ff;
|
|
153
|
+
const expected = applyColorMatrixToColor(
|
|
154
|
+
parentAdjustment.colorMatrix,
|
|
155
|
+
applyColorMatrixToColor(childMatrix, source),
|
|
156
|
+
);
|
|
157
|
+
expect(applyColorMatrixToColor(childData.colorMatrix!, source)).toBe(expected);
|
|
158
|
+
expect(childData.colorScaleBias).toBeNull();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('promotes a parent matrix and child affine to one parent-after-child matrix', () => {
|
|
162
|
+
const state = createRenderState();
|
|
163
|
+
const parent = createDisplayObject();
|
|
164
|
+
const child = createDisplayObject();
|
|
165
|
+
const parentMatrix = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0];
|
|
166
|
+
const childAdjustment = createColorScaleBiasAdjustment({
|
|
167
|
+
redScale: 0.5,
|
|
168
|
+
redBias: 0.1,
|
|
169
|
+
greenScale: 1,
|
|
170
|
+
greenBias: 0,
|
|
171
|
+
blueScale: 1,
|
|
172
|
+
blueBias: 0,
|
|
173
|
+
alphaScale: 1,
|
|
174
|
+
alphaBias: 0,
|
|
175
|
+
});
|
|
176
|
+
setNodeColorAdjustments(parent, [createColorMatrixAdjustment(parentMatrix)]);
|
|
177
|
+
setNodeColorAdjustments(child, [childAdjustment]);
|
|
178
|
+
const parentData = createRenderProxy(state, parent as unknown as Renderable);
|
|
179
|
+
const childData = createRenderProxy(state, child as unknown as Renderable);
|
|
180
|
+
updateRenderProxyColorScaleBias(state, parentData);
|
|
181
|
+
updateRenderProxyColorScaleBias(state, childData, parentData);
|
|
182
|
+
const source = 0x204060ff;
|
|
183
|
+
const expected = applyColorMatrixToColor(
|
|
184
|
+
parentMatrix,
|
|
185
|
+
applyColorMatrixToColor(childAdjustment.colorMatrix, source),
|
|
186
|
+
);
|
|
187
|
+
expect(applyColorMatrixToColor(childData.colorMatrix!, source)).toBe(expected);
|
|
188
|
+
expect(childData.colorScaleBias).toBeNull();
|
|
38
189
|
});
|
|
39
190
|
|
|
40
191
|
it('reads the cache the accessor fused once (the walk never re-fuses)', () => {
|