@spatial-elements/core 1.0.0-beta.13 → 1.0.0-beta.14
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/catalog/CarouselSectionSurfaces.d.ts.map +1 -1
- package/dist/catalog/CarouselSectionSurfaces.js +8 -2
- package/dist/catalog/CarouselSectionSurfaces.js.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.js +12 -4
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
- package/dist/catalog/SourceDomMotion.d.ts.map +1 -1
- package/dist/catalog/SourceDomMotion.js +2 -3
- package/dist/catalog/SourceDomMotion.js.map +1 -1
- package/dist/catalog/carouselRenderClip.d.ts +4 -0
- package/dist/catalog/carouselRenderClip.d.ts.map +1 -0
- package/dist/catalog/carouselRenderClip.js +15 -0
- package/dist/catalog/carouselRenderClip.js.map +1 -0
- package/dist/spatial-element/SpatialElementPaneController.d.ts +4 -4
- package/dist/spatial-element/SpatialElementPaneController.d.ts.map +1 -1
- package/dist/spatial-element/SpatialElementPaneController.js +46 -20
- package/dist/spatial-element/SpatialElementPaneController.js.map +1 -1
- package/dist/spatial-element/responsiveLayout.d.ts.map +1 -1
- package/dist/spatial-element/responsiveLayout.js +4 -2
- package/dist/spatial-element/responsiveLayout.js.map +1 -1
- package/dist/stage/DetailWheelGesture.d.ts +3 -1
- package/dist/stage/DetailWheelGesture.d.ts.map +1 -1
- package/dist/stage/DetailWheelGesture.js +9 -6
- package/dist/stage/DetailWheelGesture.js.map +1 -1
- package/dist/stage/HeldSceneCapture.d.ts +15 -0
- package/dist/stage/HeldSceneCapture.d.ts.map +1 -0
- package/dist/stage/HeldSceneCapture.js +48 -0
- package/dist/stage/HeldSceneCapture.js.map +1 -0
- package/dist/stage/PanelPresentationController.d.ts +5 -0
- package/dist/stage/PanelPresentationController.d.ts.map +1 -1
- package/dist/stage/PanelPresentationController.js +74 -30
- package/dist/stage/PanelPresentationController.js.map +1 -1
- package/dist/stage/SpaceMouseAdapter.js +8 -6
- package/dist/stage/SpaceMouseAdapter.js.map +1 -1
- package/dist/stage/SpatialElementInteractionController.d.ts +24 -2
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
- package/dist/stage/SpatialElementInteractionController.js +226 -56
- package/dist/stage/SpatialElementInteractionController.js.map +1 -1
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +5 -2
- package/dist/stage/StageExperience.js.map +1 -1
- package/dist/stage/StageRenderPipeline.d.ts +1 -0
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
- package/dist/stage/StageRenderPipeline.js +15 -8
- package/dist/stage/StageRenderPipeline.js.map +1 -1
- package/dist/stage/cssProjection.d.ts +3 -1
- package/dist/stage/cssProjection.d.ts.map +1 -1
- package/dist/stage/cssProjection.js +8 -3
- package/dist/stage/cssProjection.js.map +1 -1
- package/dist/stage/rendererState.d.ts.map +1 -1
- package/dist/stage/rendererState.js +24 -9
- package/dist/stage/rendererState.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,10 +9,12 @@ export type CssProjectionQuad = readonly [
|
|
|
9
9
|
CssProjectionPoint
|
|
10
10
|
];
|
|
11
11
|
/**
|
|
12
|
-
* Returns
|
|
12
|
+
* Returns matrix elements mapping a local rectangle onto a projected screen quad.
|
|
13
13
|
*
|
|
14
14
|
* Corners are ordered clockwise from the top-left. The resulting homography keeps
|
|
15
15
|
* a flat DOM surface in the exact same perspective projection as its WebGPU plane.
|
|
16
16
|
*/
|
|
17
|
+
export declare function getProjectiveCssMatrixElements(corners: CssProjectionQuad, width: number, height: number): number[] | null;
|
|
18
|
+
/** CSS serialization is only needed when writing the final DOM transform. */
|
|
17
19
|
export declare function getProjectiveCssMatrix3d(corners: CssProjectionQuad, width: number, height: number): string | null;
|
|
18
20
|
//# sourceMappingURL=cssProjection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssProjection.d.ts","sourceRoot":"","sources":["../../src/stage/cssProjection.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS;IACxC,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;CAClB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"cssProjection.d.ts","sourceRoot":"","sources":["../../src/stage/cssProjection.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS;IACxC,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;CAClB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,mBA+Cd;AAED,6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAGjG"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns
|
|
2
|
+
* Returns matrix elements mapping a local rectangle onto a projected screen quad.
|
|
3
3
|
*
|
|
4
4
|
* Corners are ordered clockwise from the top-left. The resulting homography keeps
|
|
5
5
|
* a flat DOM surface in the exact same perspective projection as its WebGPU plane.
|
|
6
6
|
*/
|
|
7
|
-
export function
|
|
7
|
+
export function getProjectiveCssMatrixElements(corners, width, height) {
|
|
8
8
|
const safeWidth = Math.max(width, 0.000001);
|
|
9
9
|
const safeHeight = Math.max(height, 0.000001);
|
|
10
10
|
const [topLeft, topRight, bottomRight, bottomLeft] = corners;
|
|
@@ -47,6 +47,11 @@ export function getProjectiveCssMatrix3d(corners, width, height) {
|
|
|
47
47
|
];
|
|
48
48
|
if (matrix.some((value) => !Number.isFinite(value)))
|
|
49
49
|
return null;
|
|
50
|
-
return
|
|
50
|
+
return matrix.map((value) => (Math.abs(value) < 1e-10 ? 0 : value));
|
|
51
|
+
}
|
|
52
|
+
/** CSS serialization is only needed when writing the final DOM transform. */
|
|
53
|
+
export function getProjectiveCssMatrix3d(corners, width, height) {
|
|
54
|
+
const matrix = getProjectiveCssMatrixElements(corners, width, height);
|
|
55
|
+
return matrix ? `matrix3d(${matrix.join(',')})` : null;
|
|
51
56
|
}
|
|
52
57
|
//# sourceMappingURL=cssProjection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssProjection.js","sourceRoot":"","sources":["../../src/stage/cssProjection.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"cssProjection.js","sourceRoot":"","sources":["../../src/stage/cssProjection.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC7C,OAA0B,EAC1B,KAAa,EACb,MAAc;IAEd,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9C,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC;IAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,WA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,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG;QACd,MAAM,GAAG,SAAS;QAClB,MAAM,GAAG,SAAS;QAClB,CAAC;QACD,WAAW,GAAG,SAAS;QACvB,MAAM,GAAG,UAAU;QACnB,MAAM,GAAG,UAAU;QACnB,CAAC;QACD,WAAW,GAAG,UAAU;QACxB,CAAC;QACD,CAAC;QACD,CAAC;QACD,CAAC;QACD,OAAO,CAAC,CAAC;QACT,OAAO,CAAC,CAAC;QACT,CAAC;QACD,CAAC;KACD,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAEjE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,wBAAwB,CAAC,OAA0B,EAAE,KAAa,EAAE,MAAc;IACjG,MAAM,MAAM,GAAG,8BAA8B,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC","sourcesContent":["export interface CssProjectionPoint {\n\tx: number;\n\ty: number;\n}\n\nexport type CssProjectionQuad = readonly [\n\tCssProjectionPoint,\n\tCssProjectionPoint,\n\tCssProjectionPoint,\n\tCssProjectionPoint\n];\n\n/**\n * Returns matrix elements mapping a local rectangle onto a projected screen quad.\n *\n * Corners are ordered clockwise from the top-left. The resulting homography keeps\n * a flat DOM surface in the exact same perspective projection as its WebGPU plane.\n */\nexport function getProjectiveCssMatrixElements(\n\tcorners: CssProjectionQuad,\n\twidth: number,\n\theight: number\n) {\n\tconst safeWidth = Math.max(width, 0.000001);\n\tconst safeHeight = Math.max(height, 0.000001);\n\tconst [topLeft, topRight, bottomRight, bottomLeft] = corners;\n\tconst deltaX1 = topRight.x - bottomRight.x;\n\tconst deltaX2 = bottomLeft.x - bottomRight.x;\n\tconst deltaX3 = topLeft.x - topRight.x + bottomRight.x - bottomLeft.x;\n\tconst deltaY1 = topRight.y - bottomRight.y;\n\tconst deltaY2 = bottomLeft.y - bottomRight.y;\n\tconst deltaY3 = topLeft.y - topRight.y + bottomRight.y - bottomLeft.y;\n\tlet projectiveX = 0;\n\tlet projectiveY = 0;\n\n\tif (Math.abs(deltaX3) > 0.000001 || Math.abs(deltaY3) > 0.000001) {\n\t\tconst determinant = deltaX1 * deltaY2 - deltaX2 * deltaY1;\n\t\tif (Math.abs(determinant) < 0.000001) return null;\n\n\t\tprojectiveX = (deltaX3 * deltaY2 - deltaX2 * deltaY3) / determinant;\n\t\tprojectiveY = (deltaX1 * deltaY3 - deltaX3 * deltaY1) / determinant;\n\t}\n\n\tconst scaleX = topRight.x - topLeft.x + projectiveX * topRight.x;\n\tconst shearX = bottomLeft.x - topLeft.x + projectiveY * bottomLeft.x;\n\tconst scaleY = topRight.y - topLeft.y + projectiveX * topRight.y;\n\tconst shearY = bottomLeft.y - topLeft.y + projectiveY * bottomLeft.y;\n\tconst matrix = [\n\t\tscaleX / safeWidth,\n\t\tscaleY / safeWidth,\n\t\t0,\n\t\tprojectiveX / safeWidth,\n\t\tshearX / safeHeight,\n\t\tshearY / safeHeight,\n\t\t0,\n\t\tprojectiveY / safeHeight,\n\t\t0,\n\t\t0,\n\t\t1,\n\t\t0,\n\t\ttopLeft.x,\n\t\ttopLeft.y,\n\t\t0,\n\t\t1\n\t];\n\tif (matrix.some((value) => !Number.isFinite(value))) return null;\n\n\treturn matrix.map((value) => (Math.abs(value) < 1e-10 ? 0 : value));\n}\n\n/** CSS serialization is only needed when writing the final DOM transform. */\nexport function getProjectiveCssMatrix3d(corners: CssProjectionQuad, width: number, height: number) {\n\tconst matrix = getProjectiveCssMatrixElements(corners, width, height);\n\treturn matrix ? `matrix3d(${matrix.join(',')})` : null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rendererState.d.ts","sourceRoot":"","sources":["../../src/stage/rendererState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,KAAK,iBAAiB,GAAG,IAAI,CAC5B,cAAc,EACZ,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,eAAe,GACf,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,CAClB,GAAG;IAAE,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"rendererState.d.ts","sourceRoot":"","sources":["../../src/stage/rendererState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,KAAK,iBAAiB,GAAG,IAAI,CAC5B,cAAc,EACZ,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,eAAe,GACf,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,CAClB,GAAG;IAAE,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC;AAS5E,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,OAAO,CAAC,QAK5G;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CA2BlF;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAS1F"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Color, Vector4 } from 'three/webgpu';
|
|
2
|
+
// Nested passes need distinct snapshots, but each renderer can reuse that small
|
|
3
|
+
// stack after a pass returns instead of allocating three math objects per pass.
|
|
4
|
+
const statePools = new WeakMap();
|
|
2
5
|
/** A cached uniform attachment must be complete on WebGPU and its WebGL fallback. */
|
|
3
6
|
export function clearFullTarget(renderer) {
|
|
4
7
|
const scissorTest = renderer.getScissorTest();
|
|
@@ -14,23 +17,35 @@ export function clearFullTarget(renderer) {
|
|
|
14
17
|
}
|
|
15
18
|
/** A pass borrows renderer state; failures must not poison the next output band. */
|
|
16
19
|
export function withRendererState(renderer, draw) {
|
|
20
|
+
let pool = statePools.get(renderer);
|
|
21
|
+
if (!pool) {
|
|
22
|
+
pool = { depth: 0, frames: [] };
|
|
23
|
+
statePools.set(renderer, pool);
|
|
24
|
+
}
|
|
25
|
+
const snapshot = pool.frames[pool.depth] ??= { color: new Color(), viewport: new Vector4(), scissor: new Vector4() };
|
|
17
26
|
const canvas = renderer.getCanvasTarget();
|
|
18
27
|
const target = renderer.getRenderTarget();
|
|
19
|
-
const color = renderer.getClearColor(
|
|
28
|
+
const color = renderer.getClearColor(snapshot.color);
|
|
20
29
|
const alpha = renderer.getClearAlpha();
|
|
21
|
-
const viewport = renderer.getViewport(
|
|
22
|
-
const scissor = renderer.getScissor(
|
|
30
|
+
const viewport = renderer.getViewport(snapshot.viewport);
|
|
31
|
+
const scissor = renderer.getScissor(snapshot.scissor);
|
|
23
32
|
const scissorTest = renderer.getScissorTest();
|
|
33
|
+
pool.depth++;
|
|
24
34
|
try {
|
|
25
35
|
return draw();
|
|
26
36
|
}
|
|
27
37
|
finally {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
try {
|
|
39
|
+
renderer.setCanvasTarget(canvas);
|
|
40
|
+
renderer.setRenderTarget(target);
|
|
41
|
+
renderer.setClearColor(color, alpha);
|
|
42
|
+
renderer.setViewport(viewport);
|
|
43
|
+
renderer.setScissor(scissor);
|
|
44
|
+
renderer.setScissorTest(scissorTest);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
pool.depth--;
|
|
48
|
+
}
|
|
34
49
|
}
|
|
35
50
|
}
|
|
36
51
|
/** Restore borrowed scene visibility even if a WebGPU pass throws. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rendererState.js","sourceRoot":"","sources":["../../src/stage/rendererState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAkB9C,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAAC,QAA6E;IAC5G,MAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;IAC9C,IAAI,WAAW;QAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAAC,CAAC;YACjB,CAAC;QAAC,IAAI,WAAW;YAAE,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAAC,CAAC;AAC5D,CAAC;AAED,oFAAoF;AACpF,MAAM,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C;IAClD,IAAI,CAAC;QACJ,OAAO,IAAI,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACV,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","sourcesContent":["import { Color, Vector4 } from 'three/webgpu';\nimport type { WebGPURenderer } from 'three/webgpu';\n\ntype RendererStatePort = Pick<\n\tWebGPURenderer,\n\t| 'getCanvasTarget'\n\t| 'setCanvasTarget'\n\t| 'getRenderTarget'\n\t| 'setRenderTarget'\n\t| 'getClearColor'\n\t| 'getClearAlpha'\n\t| 'setClearColor'\n\t| 'getViewport'\n\t| 'getScissor'\n\t| 'getScissorTest'\n\t| 'setScissorTest'\n> & { setViewport(value: Vector4): void; setScissor(value: Vector4): void };\n\n// Nested passes need distinct snapshots, but each renderer can reuse that small\n// stack after a pass returns instead of allocating three math objects per pass.\nconst statePools = new WeakMap<RendererStatePort, {\n\tdepth: number;\n\tframes: { color: Color; viewport: Vector4; scissor: Vector4 }[];\n}>();\n\n/** A cached uniform attachment must be complete on WebGPU and its WebGL fallback. */\nexport function clearFullTarget(renderer: Pick<WebGPURenderer, 'getScissorTest' | 'setScissorTest' | 'clear'>) {\n\tconst scissorTest = renderer.getScissorTest();\n\tif (scissorTest) renderer.setScissorTest(false);\n\ttry { renderer.clear(); }\n\tfinally { if (scissorTest) renderer.setScissorTest(true); }\n}\n\n/** A pass borrows renderer state; failures must not poison the next output band. */\nexport function withRendererState<T>(renderer: RendererStatePort, draw: () => T): T {\n\tlet pool = statePools.get(renderer);\n\tif (!pool) {\n\t\tpool = { depth: 0, frames: [] };\n\t\tstatePools.set(renderer, pool);\n\t}\n\tconst snapshot = pool.frames[pool.depth] ??= { color: new Color(), viewport: new Vector4(), scissor: new Vector4() };\n\tconst canvas = renderer.getCanvasTarget();\n\tconst target = renderer.getRenderTarget();\n\tconst color = renderer.getClearColor(snapshot.color);\n\tconst alpha = renderer.getClearAlpha();\n\tconst viewport = renderer.getViewport(snapshot.viewport);\n\tconst scissor = renderer.getScissor(snapshot.scissor);\n\tconst scissorTest = renderer.getScissorTest();\n\tpool.depth++;\n\ttry {\n\t\treturn draw();\n\t} finally {\n\t\ttry {\n\t\t\trenderer.setCanvasTarget(canvas);\n\t\t\trenderer.setRenderTarget(target);\n\t\t\trenderer.setClearColor(color, alpha);\n\t\t\trenderer.setViewport(viewport);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t} finally { pool.depth--; }\n\t}\n}\n\n/** Restore borrowed scene visibility even if a WebGPU pass throws. */\nexport function withVisibility<T>(nodes: readonly { visible: boolean }[], draw: () => T): T {\n\tconst visible = nodes.map((node) => node.visible);\n\ttry {\n\t\treturn draw();\n\t} finally {\n\t\tnodes.forEach((node, index) => {\n\t\t\tnode.visible = visible[index];\n\t\t});\n\t}\n}\n"]}
|