@spatial-elements/core 1.0.0-beta.13 → 1.0.0-beta.15

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.
Files changed (69) hide show
  1. package/dist/catalog/CarouselSectionSurfaces.d.ts.map +1 -1
  2. package/dist/catalog/CarouselSectionSurfaces.js +8 -2
  3. package/dist/catalog/CarouselSectionSurfaces.js.map +1 -1
  4. package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
  5. package/dist/catalog/CatalogSpatialElementLayer.js +12 -4
  6. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  7. package/dist/catalog/SourceDomMotion.d.ts.map +1 -1
  8. package/dist/catalog/SourceDomMotion.js +2 -3
  9. package/dist/catalog/SourceDomMotion.js.map +1 -1
  10. package/dist/catalog/carouselRenderClip.d.ts +4 -0
  11. package/dist/catalog/carouselRenderClip.d.ts.map +1 -0
  12. package/dist/catalog/carouselRenderClip.js +15 -0
  13. package/dist/catalog/carouselRenderClip.js.map +1 -0
  14. package/dist/spatial-element/SpatialElementDockController.d.ts +5 -3
  15. package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
  16. package/dist/spatial-element/SpatialElementDockController.js +41 -30
  17. package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
  18. package/dist/spatial-element/SpatialElementPaneController.d.ts +4 -4
  19. package/dist/spatial-element/SpatialElementPaneController.d.ts.map +1 -1
  20. package/dist/spatial-element/SpatialElementPaneController.js +46 -20
  21. package/dist/spatial-element/SpatialElementPaneController.js.map +1 -1
  22. package/dist/spatial-element/responsiveLayout.d.ts.map +1 -1
  23. package/dist/spatial-element/responsiveLayout.js +4 -2
  24. package/dist/spatial-element/responsiveLayout.js.map +1 -1
  25. package/dist/spatial-element/spatialElementDock.d.ts +1 -1
  26. package/dist/spatial-element/spatialElementDock.d.ts.map +1 -1
  27. package/dist/spatial-element/spatialElementDock.js +2 -2
  28. package/dist/spatial-element/spatialElementDock.js.map +1 -1
  29. package/dist/stage/DetailWheelGesture.d.ts +17 -2
  30. package/dist/stage/DetailWheelGesture.d.ts.map +1 -1
  31. package/dist/stage/DetailWheelGesture.js +45 -7
  32. package/dist/stage/DetailWheelGesture.js.map +1 -1
  33. package/dist/stage/HeldSceneCapture.d.ts +15 -0
  34. package/dist/stage/HeldSceneCapture.d.ts.map +1 -0
  35. package/dist/stage/HeldSceneCapture.js +48 -0
  36. package/dist/stage/HeldSceneCapture.js.map +1 -0
  37. package/dist/stage/MinimapController.d.ts +2 -0
  38. package/dist/stage/MinimapController.d.ts.map +1 -1
  39. package/dist/stage/MinimapController.js +23 -3
  40. package/dist/stage/MinimapController.js.map +1 -1
  41. package/dist/stage/PanelPresentationController.d.ts +5 -0
  42. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  43. package/dist/stage/PanelPresentationController.js +74 -30
  44. package/dist/stage/PanelPresentationController.js.map +1 -1
  45. package/dist/stage/SpaceMouseAdapter.js +8 -6
  46. package/dist/stage/SpaceMouseAdapter.js.map +1 -1
  47. package/dist/stage/SpatialElementInteractionController.d.ts +27 -2
  48. package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
  49. package/dist/stage/SpatialElementInteractionController.js +272 -56
  50. package/dist/stage/SpatialElementInteractionController.js.map +1 -1
  51. package/dist/stage/StageExperience.d.ts.map +1 -1
  52. package/dist/stage/StageExperience.js +17 -17
  53. package/dist/stage/StageExperience.js.map +1 -1
  54. package/dist/stage/StageRenderPipeline.d.ts +1 -0
  55. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  56. package/dist/stage/StageRenderPipeline.js +15 -8
  57. package/dist/stage/StageRenderPipeline.js.map +1 -1
  58. package/dist/stage/TrackpadGesture.d.ts +17 -0
  59. package/dist/stage/TrackpadGesture.d.ts.map +1 -0
  60. package/dist/stage/TrackpadGesture.js +39 -0
  61. package/dist/stage/TrackpadGesture.js.map +1 -0
  62. package/dist/stage/cssProjection.d.ts +3 -1
  63. package/dist/stage/cssProjection.d.ts.map +1 -1
  64. package/dist/stage/cssProjection.js +8 -3
  65. package/dist/stage/cssProjection.js.map +1 -1
  66. package/dist/stage/rendererState.d.ts.map +1 -1
  67. package/dist/stage/rendererState.js +24 -9
  68. package/dist/stage/rendererState.js.map +1 -1
  69. package/package.json +1 -1
@@ -0,0 +1,17 @@
1
+ type Sample = Pick<WheelEvent, 'deltaX' | 'deltaY' | 'deltaMode' | 'ctrlKey' | 'shiftKey'> & {
2
+ momentum?: boolean;
3
+ };
4
+ export type TrackpadAction = 'wheel' | 'pinch' | 'pan';
5
+ /** Choose a command from the gesture's initial direction, never a device type.
6
+ * A clearly horizontal start opts into two-axis pan in an eligible stage. Every
7
+ * other start retains ordinary wheel navigation until this gesture ends. */
8
+ export declare class TrackpadGesture {
9
+ private lastTime;
10
+ private ctrl;
11
+ private nativeTail;
12
+ private action;
13
+ reset(): void;
14
+ resolve(now: number, sample: Sample, canStartPan: boolean): TrackpadAction;
15
+ }
16
+ export {};
17
+ //# sourceMappingURL=TrackpadGesture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrackpadGesture.d.ts","sourceRoot":"","sources":["../../src/stage/TrackpadGesture.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AACpH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvD;;4EAE4E;AAC5E,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAA2B;IACzC,KAAK;IAML,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,cAAc;CAqB1E"}
@@ -0,0 +1,39 @@
1
+ import { DETAIL_WHEEL_IDLE_MS } from './DetailWheelGesture.js';
2
+ /** Choose a command from the gesture's initial direction, never a device type.
3
+ * A clearly horizontal start opts into two-axis pan in an eligible stage. Every
4
+ * other start retains ordinary wheel navigation until this gesture ends. */
5
+ export class TrackpadGesture {
6
+ lastTime = -Infinity;
7
+ ctrl = false;
8
+ nativeTail = false;
9
+ action = 'wheel';
10
+ reset() {
11
+ this.lastTime = -Infinity;
12
+ this.action = 'wheel';
13
+ this.ctrl = false;
14
+ this.nativeTail = false;
15
+ }
16
+ resolve(now, sample, canStartPan) {
17
+ const x = sample.deltaX || 0, y = sample.deltaY || 0;
18
+ if (x === 0 && y === 0)
19
+ return this.action;
20
+ const gap = now - this.lastTime;
21
+ const ctrl = Boolean(sample.ctrlKey);
22
+ const changedModifier = ctrl !== this.ctrl;
23
+ const fresh = changedModifier || (this.nativeTail && sample.momentum === false) ||
24
+ (gap >= DETAIL_WHEEL_IDLE_MS && sample.momentum !== true);
25
+ if (fresh) {
26
+ // Ignore minor sideways drift and ambiguous diagonal starts. Line/page
27
+ // wheels and Shift-wheel keep their existing behavior. No later sample
28
+ // can promote a running scroll/zoom gesture to pan, even as panels clear.
29
+ const horizontal = sample.deltaMode === 0 && !sample.shiftKey &&
30
+ Math.abs(x) > Math.abs(y) * 2;
31
+ this.action = ctrl ? 'pinch' : canStartPan && horizontal ? 'pan' : 'wheel';
32
+ }
33
+ this.ctrl = ctrl;
34
+ this.nativeTail = sample.momentum === true;
35
+ this.lastTime = now;
36
+ return this.action;
37
+ }
38
+ }
39
+ //# sourceMappingURL=TrackpadGesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrackpadGesture.js","sourceRoot":"","sources":["../../src/stage/TrackpadGesture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAK/D;;4EAE4E;AAC5E,MAAM,O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C/B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;QAC5E,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD","sourcesContent":["import { DETAIL_WHEEL_IDLE_MS } from './DetailWheelGesture.js';\n\ntype Sample = Pick<WheelEvent, 'deltaX' | 'deltaY' | 'deltaMode' | 'ctrlKey' | 'shiftKey'> & { momentum?: boolean };\nexport type TrackpadAction = 'wheel' | 'pinch' | 'pan';\n\n/** Choose a command from the gesture's initial direction, never a device type.\n * A clearly horizontal start opts into two-axis pan in an eligible stage. Every\n * other start retains ordinary wheel navigation until this gesture ends. */\nexport class TrackpadGesture {\n\tprivate lastTime = -Infinity;\n\tprivate ctrl = false;\n\tprivate nativeTail = false;\n\tprivate action: TrackpadAction = 'wheel';\n\treset() {\n\t\tthis.lastTime = -Infinity;\n\t\tthis.action = 'wheel';\n\t\tthis.ctrl = false;\n\t\tthis.nativeTail = false;\n\t}\n\tresolve(now: number, sample: Sample, canStartPan: boolean): TrackpadAction {\n\t\tconst x = sample.deltaX || 0, y = sample.deltaY || 0;\n\t\tif (x === 0 && y === 0) return this.action;\n\t\tconst gap = now - this.lastTime;\n\t\tconst ctrl = Boolean(sample.ctrlKey);\n\t\tconst changedModifier = ctrl !== this.ctrl;\n\t\tconst fresh = changedModifier || (this.nativeTail && sample.momentum === false) ||\n\t\t\t(gap >= DETAIL_WHEEL_IDLE_MS && sample.momentum !== true);\n\t\tif (fresh) {\n\t\t\t// Ignore minor sideways drift and ambiguous diagonal starts. Line/page\n\t\t\t// wheels and Shift-wheel keep their existing behavior. No later sample\n\t\t\t// can promote a running scroll/zoom gesture to pan, even as panels clear.\n\t\t\tconst horizontal = sample.deltaMode === 0 && !sample.shiftKey &&\n\t\t\t\tMath.abs(x) > Math.abs(y) * 2;\n\t\t\tthis.action = ctrl ? 'pinch' : canStartPan && horizontal ? 'pan' : 'wheel';\n\t\t}\n\t\tthis.ctrl = ctrl;\n\t\tthis.nativeTail = sample.momentum === true;\n\t\tthis.lastTime = now;\n\t\treturn this.action;\n\t}\n}\n"]}
@@ -9,10 +9,12 @@ export type CssProjectionQuad = readonly [
9
9
  CssProjectionPoint
10
10
  ];
11
11
  /**
12
- * Returns a CSS matrix that maps a local rectangle onto a projected screen quad.
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,wBAAwB,CACvC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,iBA+Cd"}
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 a CSS matrix that maps a local rectangle onto a projected screen quad.
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 getProjectiveCssMatrix3d(corners, width, height) {
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 `matrix3d(${matrix.map((value) => (Math.abs(value) < 1e-10 ? 0 : value)).join(',')})`;
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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AAG,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,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAC9F,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 a CSS matrix that maps 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 getProjectiveCssMatrix3d(\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 `matrix3d(${matrix.map((value) => (Math.abs(value) < 1e-10 ? 0 : value)).join(',')})`;\n}\n"]}
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,WAAW,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,W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;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;AAE5E,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,CAkBlF;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
+ {"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(new Color());
28
+ const color = renderer.getClearColor(snapshot.color);
20
29
  const alpha = renderer.getClearAlpha();
21
- const viewport = renderer.getViewport(new Vector4());
22
- const scissor = renderer.getScissor(new Vector4());
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
- renderer.setCanvasTarget(canvas);
29
- renderer.setRenderTarget(target);
30
- renderer.setClearColor(color, alpha);
31
- renderer.setViewport(viewport);
32
- renderer.setScissor(scissor);
33
- renderer.setScissorTest(scissorTest);
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,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AAI,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/** 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\tconst canvas = renderer.getCanvasTarget();\n\tconst target = renderer.getRenderTarget();\n\tconst color = renderer.getClearColor(new Color());\n\tconst alpha = renderer.getClearAlpha();\n\tconst viewport = renderer.getViewport(new Vector4());\n\tconst scissor = renderer.getScissor(new Vector4());\n\tconst scissorTest = renderer.getScissorTest();\n\ttry {\n\t\treturn draw();\n\t} finally {\n\t\trenderer.setCanvasTarget(canvas);\n\t\trenderer.setRenderTarget(target);\n\t\trenderer.setClearColor(color, alpha);\n\t\trenderer.setViewport(viewport);\n\t\trenderer.setScissor(scissor);\n\t\trenderer.setScissorTest(scissorTest);\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"]}
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,gFAAgF;AAChF,gFAAgF;AAChF,MAAM,UAAU,GAAG,IAAI,OAAO,EAG1B,CAAC;AAEL,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,UAAU,iBAAiB,CAAI,QAA2B,EAAE,IAAa;IAC9E,IAAI,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAChC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE,CAAC;IACrH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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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spatial-elements/core",
3
- "version": "1.0.0-beta.13",
3
+ "version": "1.0.0-beta.15",
4
4
  "description": "Framework-independent rendering and catalog runtime for Spatial Elements.",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",