@flighthq/render 0.3.0-next.1032.e2b99fc → 0.3.0-next.1162.e90e518
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/dist/renderTarget.d.ts +3 -1
- package/dist/renderTarget.d.ts.map +1 -1
- package/dist/renderTarget.js +48 -0
- package/dist/renderTarget.js.map +1 -1
- package/package.json +10 -10
- package/src/renderTarget.test.ts +88 -1
package/dist/renderTarget.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MatrixLike, Node2D, RectangleLike, RenderTargetAxes, RenderTargetAxisDifference, RenderTargetDescriptor, ResolvedRenderTargetDescriptor } from '@flighthq/types/contract';
|
|
2
2
|
/**
|
|
3
3
|
* Writes into outCacheTransform the transform to pass to the cache resolver so the
|
|
4
4
|
* cached image is placed back at the original scene position.
|
|
@@ -14,4 +14,6 @@ export declare function computeRenderTargetSize(bounds: Readonly<RectangleLike>,
|
|
|
14
14
|
* that the bounds origin lands at (contentX, contentY).
|
|
15
15
|
*/
|
|
16
16
|
export declare function computeScene2DRenderTargetTransform(outRenderTransform: MatrixLike, source: Node2D, bounds: Readonly<RectangleLike>, contentX?: number, contentY?: number): void;
|
|
17
|
+
export declare function explainRenderTargetAxes(requested: Readonly<RenderTargetAxes>, effective: Readonly<RenderTargetAxes>): RenderTargetAxisDifference[];
|
|
18
|
+
export declare function resolveRenderTargetDescriptor(descriptor: Readonly<RenderTargetDescriptor>): ResolvedRenderTargetDescriptor;
|
|
17
19
|
//# sourceMappingURL=renderTarget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTarget.d.ts","sourceRoot":"","sources":["../src/renderTarget.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"renderTarget.d.ts","sourceRoot":"","sources":["../src/renderTarget.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACtB,8BAA8B,EAC/B,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,UAAU,EAC7B,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC/B,QAAQ,GAAE,MAAU,EACpB,QAAQ,GAAE,MAAU,GACnB,IAAI,CAON;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC/B,OAAO,GAAE,MAAU,EACnB,QAAQ,GAAE,MAAU,EACpB,SAAS,GAAE,MAAU,GACpB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAKnC;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,kBAAkB,EAAE,UAAU,EAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC/B,QAAQ,GAAE,MAAU,EACpB,QAAQ,GAAE,MAAU,GACnB,IAAI,CAUN;AAID,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EACrC,SAAS,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GACpC,0BAA0B,EAAE,CAa9B;AAKD,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GAC3C,8BAA8B,CAsBhC"}
|
package/dist/renderTarget.js
CHANGED
|
@@ -34,6 +34,54 @@ export function computeScene2DRenderTargetTransform(outRenderTransform, source,
|
|
|
34
34
|
_tempTranslation.ty = contentY - bounds.y;
|
|
35
35
|
multiplyMatrix(outRenderTransform, _tempTranslation, _tempInvLocal);
|
|
36
36
|
}
|
|
37
|
+
// Returns plain-data axis differences in a stable order. Backends retain the requested and effective
|
|
38
|
+
// shapes, then use this common comparison so every explain* surface reports substitutions uniformly.
|
|
39
|
+
export function explainRenderTargetAxes(requested, effective) {
|
|
40
|
+
const differences = [];
|
|
41
|
+
for (const axis of _renderTargetAxisOrder) {
|
|
42
|
+
const requestedValue = requested[axis];
|
|
43
|
+
const effectiveValue = effective[axis];
|
|
44
|
+
const equal = Array.isArray(requestedValue) && Array.isArray(effectiveValue)
|
|
45
|
+
? requestedValue.length === effectiveValue.length &&
|
|
46
|
+
requestedValue.every((value, index) => value === effectiveValue[index])
|
|
47
|
+
: requestedValue === effectiveValue;
|
|
48
|
+
if (!equal)
|
|
49
|
+
differences.push({ axis, effective: effectiveValue, requested: requestedValue });
|
|
50
|
+
}
|
|
51
|
+
return differences;
|
|
52
|
+
}
|
|
53
|
+
// Resolves every substrate-independent default and normalization once. Backend realizations start
|
|
54
|
+
// here and apply only device capability substitutions (for example GL MAX_SAMPLES or float-render
|
|
55
|
+
// support), so Canvas/GL/WGPU cannot independently reinterpret the descriptor's optional axes.
|
|
56
|
+
export function resolveRenderTargetDescriptor(descriptor) {
|
|
57
|
+
const width = Math.max(1, Math.ceil(descriptor.width));
|
|
58
|
+
const height = Math.max(1, Math.ceil(descriptor.height));
|
|
59
|
+
const colorAttachments = Math.max(1, Math.ceil(descriptor.colorAttachments ?? 1));
|
|
60
|
+
const defaultFormat = descriptor.format ?? 'rgba8';
|
|
61
|
+
const colorFormats = Array.from({ length: colorAttachments }, (_, index) => descriptor.colorFormats?.[index] ?? defaultFormat);
|
|
62
|
+
return {
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
format: colorFormats[0],
|
|
66
|
+
colorAttachments,
|
|
67
|
+
colorFormats,
|
|
68
|
+
sampleCount: Math.max(1, Math.ceil(descriptor.sampleCount ?? 1)),
|
|
69
|
+
depth: descriptor.depth ?? 'none',
|
|
70
|
+
colorSpace: descriptor.colorSpace ?? 'srgb',
|
|
71
|
+
clearColors: descriptor.clearColors ? [...descriptor.clearColors] : [],
|
|
72
|
+
clearDepth: descriptor.clearDepth ?? 1,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
37
75
|
const _tempInvLocal = createMatrix();
|
|
38
76
|
const _tempTranslation = createMatrix();
|
|
77
|
+
const _renderTargetAxisOrder = [
|
|
78
|
+
'width',
|
|
79
|
+
'height',
|
|
80
|
+
'format',
|
|
81
|
+
'colorAttachments',
|
|
82
|
+
'colorFormats',
|
|
83
|
+
'sampleCount',
|
|
84
|
+
'depth',
|
|
85
|
+
'colorSpace',
|
|
86
|
+
];
|
|
39
87
|
//# sourceMappingURL=renderTarget.js.map
|
package/dist/renderTarget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTarget.js","sourceRoot":"","sources":["../src/renderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderTarget.js","sourceRoot":"","sources":["../src/renderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAW7D;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,iBAA6B,EAC7B,MAA+B,EAC/B,WAAmB,CAAC,EACpB,WAAmB,CAAC;IAEpB,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC;IACxB,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC;IACxB,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC;IACxB,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC;IACxB,iBAAiB,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC;IAC3C,iBAAiB,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC;AAC7C,CAAC;AAED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,YAAY,EAAE,CAAC,KAAK,CAAC,IAAI,aAAa,CAChE,CAAC;IAEF,OAAO;QACL,KAAK;QACL,MAAM;QACN,MAAM,EAAE,YAAY,CAAC,CAAC,CAAE;QACxB,gBAAgB;QAChB,YAAY;QACZ,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;QAChE,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,MAAM;QACjC,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,MAAM;QAC3C,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE;QACtE,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,CAAC;KACvC,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC;AACrC,MAAM,gBAAgB,GAAG,YAAY,EAAE,CAAC;AACxC,MAAM,sBAAsB,GAA0C;IACpE,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,kBAAkB;IAClB,cAAc;IACd,aAAa;IACb,OAAO;IACP,YAAY;CACb,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.1162.e90e518",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flighthq/color": "0.3.0-next.
|
|
40
|
-
"@flighthq/entity": "0.3.0-next.
|
|
41
|
-
"@flighthq/geometry": "0.3.0-next.
|
|
42
|
-
"@flighthq/log": "0.3.0-next.
|
|
43
|
-
"@flighthq/materials": "0.3.0-next.
|
|
44
|
-
"@flighthq/mesh": "0.3.0-next.
|
|
45
|
-
"@flighthq/node": "0.3.0-next.
|
|
46
|
-
"@flighthq/signals": "0.3.0-next.
|
|
47
|
-
"@flighthq/types": "0.3.0-next.
|
|
39
|
+
"@flighthq/color": "0.3.0-next.1162.e90e518",
|
|
40
|
+
"@flighthq/entity": "0.3.0-next.1162.e90e518",
|
|
41
|
+
"@flighthq/geometry": "0.3.0-next.1162.e90e518",
|
|
42
|
+
"@flighthq/log": "0.3.0-next.1162.e90e518",
|
|
43
|
+
"@flighthq/materials": "0.3.0-next.1162.e90e518",
|
|
44
|
+
"@flighthq/mesh": "0.3.0-next.1162.e90e518",
|
|
45
|
+
"@flighthq/node": "0.3.0-next.1162.e90e518",
|
|
46
|
+
"@flighthq/signals": "0.3.0-next.1162.e90e518",
|
|
47
|
+
"@flighthq/types": "0.3.0-next.1162.e90e518"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@flighthq/adjustments": "*",
|
package/src/renderTarget.test.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { createMatrix, createRectangle } from '@flighthq/geometry/contract';
|
|
|
2
2
|
import { createDisplayObject } from '@flighthq/scene2d/contract';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
computeScene2DRenderTargetTransform,
|
|
6
5
|
computeRenderCacheTransform,
|
|
7
6
|
computeRenderTargetSize,
|
|
7
|
+
computeScene2DRenderTargetTransform,
|
|
8
|
+
explainRenderTargetAxes,
|
|
9
|
+
resolveRenderTargetDescriptor,
|
|
8
10
|
} from './renderTarget';
|
|
9
11
|
|
|
10
12
|
describe('computeRenderCacheTransform', () => {
|
|
@@ -82,3 +84,88 @@ describe('computeScene2DRenderTargetTransform', () => {
|
|
|
82
84
|
expect(() => computeScene2DRenderTargetTransform(out, obj, bounds)).not.toThrow();
|
|
83
85
|
});
|
|
84
86
|
});
|
|
87
|
+
|
|
88
|
+
describe('resolveRenderTargetDescriptor', () => {
|
|
89
|
+
it('resolves every optional target axis and clear policy', () => {
|
|
90
|
+
expect(resolveRenderTargetDescriptor({ width: 64, height: 48 })).toEqual({
|
|
91
|
+
width: 64,
|
|
92
|
+
height: 48,
|
|
93
|
+
format: 'rgba8',
|
|
94
|
+
colorAttachments: 1,
|
|
95
|
+
colorFormats: ['rgba8'],
|
|
96
|
+
sampleCount: 1,
|
|
97
|
+
depth: 'none',
|
|
98
|
+
colorSpace: 'srgb',
|
|
99
|
+
clearColors: [],
|
|
100
|
+
clearDepth: 1,
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('explainRenderTargetAxes', () => {
|
|
105
|
+
it('reports every changed axis in stable descriptor order', () => {
|
|
106
|
+
const requested = resolveRenderTargetDescriptor({
|
|
107
|
+
width: 64,
|
|
108
|
+
height: 48,
|
|
109
|
+
format: 'rgba16f',
|
|
110
|
+
colorAttachments: 2,
|
|
111
|
+
sampleCount: 8,
|
|
112
|
+
depth: 'depth-stencil-sampled',
|
|
113
|
+
});
|
|
114
|
+
const effective = {
|
|
115
|
+
...requested,
|
|
116
|
+
format: 'rgba8' as const,
|
|
117
|
+
colorFormats: ['rgba8', 'rgba8'] as const,
|
|
118
|
+
sampleCount: 4,
|
|
119
|
+
depth: 'depth-stencil' as const,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
expect(explainRenderTargetAxes(requested, effective)).toEqual([
|
|
123
|
+
{ axis: 'format', effective: 'rgba8', requested: 'rgba16f' },
|
|
124
|
+
{ axis: 'colorFormats', effective: ['rgba8', 'rgba8'], requested: ['rgba16f', 'rgba16f'] },
|
|
125
|
+
{ axis: 'sampleCount', effective: 4, requested: 8 },
|
|
126
|
+
{ axis: 'depth', effective: 'depth-stencil', requested: 'depth-stencil-sampled' },
|
|
127
|
+
]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('returns no differences for identical canonical axes', () => {
|
|
131
|
+
const axes = resolveRenderTargetDescriptor({ width: 64, height: 48 });
|
|
132
|
+
expect(explainRenderTargetAxes(axes, { ...axes, colorFormats: [...axes.colorFormats] })).toEqual([]);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('normalizes dimensions, attachment count, and sample count once', () => {
|
|
137
|
+
expect(
|
|
138
|
+
resolveRenderTargetDescriptor({
|
|
139
|
+
width: 10.2,
|
|
140
|
+
height: 0,
|
|
141
|
+
colorAttachments: 1.2,
|
|
142
|
+
sampleCount: 3.1,
|
|
143
|
+
}),
|
|
144
|
+
).toMatchObject({
|
|
145
|
+
width: 11,
|
|
146
|
+
height: 1,
|
|
147
|
+
colorAttachments: 2,
|
|
148
|
+
sampleCount: 4,
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('expands heterogeneous color formats across every requested attachment', () => {
|
|
153
|
+
const resolved = resolveRenderTargetDescriptor({
|
|
154
|
+
width: 64,
|
|
155
|
+
height: 48,
|
|
156
|
+
format: 'rgba16f',
|
|
157
|
+
colorAttachments: 3,
|
|
158
|
+
colorFormats: ['rgba8', 'rgba32f'],
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(resolved.format).toBe('rgba8');
|
|
162
|
+
expect(resolved.colorFormats).toEqual(['rgba8', 'rgba32f', 'rgba16f']);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('copies caller-owned clear arrays', () => {
|
|
166
|
+
const clearColors = [0xff0000ff];
|
|
167
|
+
const resolved = resolveRenderTargetDescriptor({ width: 64, height: 48, clearColors });
|
|
168
|
+
clearColors[0] = 0;
|
|
169
|
+
expect(resolved.clearColors).toEqual([0xff0000ff]);
|
|
170
|
+
});
|
|
171
|
+
});
|