@roomle/web-sdk 4.0.0 → 4.1.0-alpha.1

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 (127) hide show
  1. package/lib/{BufferGeometry-CnbfgBmz.mjs → BufferGeometry-DcRNeLZD.mjs} +2 -2
  2. package/lib/{BufferGeometry-CnbfgBmz.mjs.map → BufferGeometry-DcRNeLZD.mjs.map} +1 -1
  3. package/lib/{GLTFExporter-BxcjPMva.mjs → GLTFExporter-DdzTpCjW.mjs} +46 -46
  4. package/lib/{GLTFExporter-BxcjPMva.mjs.map → GLTFExporter-DdzTpCjW.mjs.map} +1 -1
  5. package/lib/{GaussianBlurNode-8gO-I1qG.mjs → GaussianBlurNode-CLuzhfDu.mjs} +19 -19
  6. package/lib/{GaussianBlurNode-8gO-I1qG.mjs.map → GaussianBlurNode-CLuzhfDu.mjs.map} +1 -1
  7. package/lib/{Object3D-DMaDdv-D.mjs → Object3D-CEXK2mMb.mjs} +1 -1
  8. package/lib/{Object3D-DMaDdv-D.mjs.map → Object3D-CEXK2mMb.mjs.map} +1 -1
  9. package/lib/Pass-C7MZilDW.mjs +53 -0
  10. package/lib/Pass-C7MZilDW.mjs.map +1 -0
  11. package/lib/{PointLightHelper-CahXSxiA.mjs → PointLightHelper-dDeo1kUI.mjs} +4 -4
  12. package/lib/{PointLightHelper-CahXSxiA.mjs.map → PointLightHelper-dDeo1kUI.mjs.map} +1 -1
  13. package/lib/{SpotLightHelper-BEqeYq1p.mjs → SpotLightHelper-BsMEPgVo.mjs} +3 -3
  14. package/lib/{SpotLightHelper-BEqeYq1p.mjs.map → SpotLightHelper-BsMEPgVo.mjs.map} +1 -1
  15. package/lib/{USDZExporter-ZZoG1mne.mjs → USDZExporter-BIDQSKG4.mjs} +3 -3
  16. package/lib/{USDZExporter-ZZoG1mne.mjs.map → USDZExporter-BIDQSKG4.mjs.map} +1 -1
  17. package/lib/{Vector4-BkA_VGid.mjs → Vector4-D-4p8rfn.mjs} +2 -2
  18. package/lib/{Vector4-BkA_VGid.mjs.map → Vector4-D-4p8rfn.mjs.map} +1 -1
  19. package/lib/{api-CUyBdNba.mjs → api-BEszDVqh.mjs} +10 -10
  20. package/lib/{api-CUyBdNba.mjs.map → api-BEszDVqh.mjs.map} +1 -1
  21. package/lib/{asset-loader.worker-C_5RQYHp.mjs → asset-loader.worker-eqHzNAwa.mjs} +1 -1
  22. package/lib/asset-loader.worker-eqHzNAwa.mjs.map +1 -0
  23. package/lib/{banana-for-scale-B77S3z9R.mjs → banana-for-scale-CiCouumi.mjs} +4 -4
  24. package/lib/{banana-for-scale-B77S3z9R.mjs.map → banana-for-scale-CiCouumi.mjs.map} +1 -1
  25. package/lib/{budgeteer.sw-DxeAvd0v.mjs → budgeteer.sw-BUMElkO1.mjs} +1 -1
  26. package/lib/budgeteer.sw-BUMElkO1.mjs.map +1 -0
  27. package/lib/{common-utils-BiOW17Ao.mjs → common-utils-CCzT4Gnn.mjs} +2 -2
  28. package/lib/{common-utils-BiOW17Ao.mjs.map → common-utils-CCzT4Gnn.mjs.map} +1 -1
  29. package/lib/{component-dimensioning-DPyPzSsa.mjs → component-dimensioning-DWEZ4jZg.mjs} +7 -7
  30. package/lib/{component-dimensioning-DPyPzSsa.mjs.map → component-dimensioning-DWEZ4jZg.mjs.map} +1 -1
  31. package/lib/{component-raycast-helper-RiQIybsX.mjs → component-raycast-helper-D2hyLpdX.mjs} +17 -17
  32. package/lib/{component-raycast-helper-RiQIybsX.mjs.map → component-raycast-helper-D2hyLpdX.mjs.map} +1 -1
  33. package/lib/configurator-BENT3shs.mjs +2 -0
  34. package/lib/{configurator-C_rsqn9l.mjs → configurator-BjLLdSf8.mjs} +16 -16
  35. package/lib/{configurator-C_rsqn9l.mjs.map → configurator-BjLLdSf8.mjs.map} +1 -1
  36. package/lib/{continuous-drawing-helper-C_Yc0uuv.mjs → continuous-drawing-helper-CCuU99Vh.mjs} +3 -3
  37. package/lib/{continuous-drawing-helper-C_Yc0uuv.mjs.map → continuous-drawing-helper-CCuU99Vh.mjs.map} +1 -1
  38. package/lib/{dat.gui.module-BLjoST8r.mjs → dat.gui.module-B2PXSbre.mjs} +1 -1
  39. package/lib/{dat.gui.module-BLjoST8r.mjs.map → dat.gui.module-B2PXSbre.mjs.map} +1 -1
  40. package/lib/{decorate-BAtqSPNS.mjs → decorate-CX1ZGuFY.mjs} +1 -1
  41. package/lib/{decorate-BAtqSPNS.mjs.map → decorate-CX1ZGuFY.mjs.map} +1 -1
  42. package/lib/{dimensioning-helper-D9oxGkry.mjs → dimensioning-helper-CjuQqjBn.mjs} +14 -14
  43. package/lib/{dimensioning-helper-D9oxGkry.mjs.map → dimensioning-helper-CjuQqjBn.mjs.map} +1 -1
  44. package/lib/dimensioning-helper-ImsWfczi.mjs +2 -0
  45. package/lib/{dist-DGov-RNo.mjs → dist-Blgk0vU0.mjs} +1 -1
  46. package/lib/{dist-DGov-RNo.mjs.map → dist-Blgk0vU0.mjs.map} +1 -1
  47. package/lib/{fflate.module-CTnSdWOb.mjs → fflate.module-DTkA0kF8.mjs} +1 -1
  48. package/lib/{fflate.module-CTnSdWOb.mjs.map → fflate.module-DTkA0kF8.mjs.map} +1 -1
  49. package/lib/{glb-viewer-A5vSLFZ5.mjs → glb-viewer-9Ata6ZNJ.mjs} +59 -45
  50. package/lib/glb-viewer-9Ata6ZNJ.mjs.map +1 -0
  51. package/lib/glb-viewer-CGqSGT38.mjs +2 -0
  52. package/lib/{highlight-coordinator-CZEJGeXA.mjs → highlight-coordinator-PyWNABN9.mjs} +3 -3
  53. package/lib/{highlight-coordinator-CZEJGeXA.mjs.map → highlight-coordinator-PyWNABN9.mjs.map} +1 -1
  54. package/lib/{homag-intelligence-BdCDX7LF.mjs → homag-intelligence-BNqPqVgE.mjs} +3 -3
  55. package/lib/{homag-intelligence-BdCDX7LF.mjs.map → homag-intelligence-BNqPqVgE.mjs.map} +1 -1
  56. package/lib/{imos-ix-poc-export-helper-CaXXDNvP.mjs → imos-ix-poc-export-helper-C1LfrtjM.mjs} +3 -3
  57. package/lib/{imos-ix-poc-export-helper-CaXXDNvP.mjs.map → imos-ix-poc-export-helper-C1LfrtjM.mjs.map} +1 -1
  58. package/lib/{kernel-utils-BYEsHVYJ.mjs → kernel-utils-Cn4evFqF.mjs} +2 -2
  59. package/lib/{kernel-utils-BYEsHVYJ.mjs.map → kernel-utils-Cn4evFqF.mjs.map} +1 -1
  60. package/lib/{layer-CIWL5ZW3.mjs → layer-DvZF9ur3.mjs} +1 -1
  61. package/lib/{layer-CIWL5ZW3.mjs.map → layer-DvZF9ur3.mjs.map} +1 -1
  62. package/lib/{main-BUl8iCi1.mjs → main-n3n3jdja.mjs} +1097 -1017
  63. package/lib/{main-BUl8iCi1.mjs.map → main-n3n3jdja.mjs.map} +1 -1
  64. package/lib/{material-viewer-C4SqVaGG.mjs → material-viewer-Cv5Awgwm.mjs} +24 -24
  65. package/lib/{material-viewer-C4SqVaGG.mjs.map → material-viewer-Cv5Awgwm.mjs.map} +1 -1
  66. package/lib/{packages-C9gO5mKk.mjs → packages-B3bi3adH.mjs} +5 -5
  67. package/lib/{packages-C9gO5mKk.mjs.map → packages-B3bi3adH.mjs.map} +1 -1
  68. package/lib/planner-DIT2VvMG.mjs +44 -0
  69. package/lib/{planner-t4QH26WW.mjs.map → planner-DIT2VvMG.mjs.map} +1 -1
  70. package/lib/planner-DaI8ZwEe.mjs +2 -0
  71. package/lib/{plugin-system-COZJdJH_.mjs → plugin-system-FuZpDWqv.mjs} +3 -3
  72. package/lib/{plugin-system-COZJdJH_.mjs.map → plugin-system-FuZpDWqv.mjs.map} +1 -1
  73. package/lib/roomle-headless-setup-CMHahWyC.mjs +612 -0
  74. package/lib/roomle-headless-setup-CMHahWyC.mjs.map +1 -0
  75. package/lib/roomle-headless.d.ts +113 -34
  76. package/lib/roomle-headless.js +433 -84
  77. package/lib/roomle-headless.js.map +1 -1
  78. package/lib/{roomle-renderer-DhLUaHJZ.mjs → roomle-renderer-BR0UKz2y.mjs} +2 -2
  79. package/lib/{roomle-renderer-DhLUaHJZ.mjs.map → roomle-renderer-BR0UKz2y.mjs.map} +1 -1
  80. package/lib/roomle-sdk.d.ts +37 -9
  81. package/lib/roomle-sdk.js +8 -8
  82. package/lib/{roomle-webgpu-renderer-CRGcdahn.mjs → roomle-webgpu-renderer-fOYJoKJU.mjs} +175 -173
  83. package/lib/roomle-webgpu-renderer-fOYJoKJU.mjs.map +1 -0
  84. package/lib/{scene-renderer-D5CfxCag.mjs → scene-renderer-CAzAJ4pS.mjs} +212 -211
  85. package/lib/{scene-renderer-D5CfxCag.mjs.map → scene-renderer-CAzAJ4pS.mjs.map} +1 -1
  86. package/lib/{script-loader-D6IuUFjw.mjs → script-loader-BAWHLt9q.mjs} +3 -3
  87. package/lib/{script-loader-D6IuUFjw.mjs.map → script-loader-BAWHLt9q.mjs.map} +1 -1
  88. package/lib/{shading-settings-BEMqEGzB.mjs → shading-settings-BPpgt0Fq.mjs} +101 -146
  89. package/lib/shading-settings-BPpgt0Fq.mjs.map +1 -0
  90. package/lib/{stats-helper-DAfbSToL.mjs → stats-helper-CqiTcJuc.mjs} +3 -3
  91. package/lib/{stats-helper-DAfbSToL.mjs.map → stats-helper-CqiTcJuc.mjs.map} +1 -1
  92. package/lib/{svgo.browser-DYieWzyw.mjs → svgo.browser-EB1zkPfG.mjs} +1 -1
  93. package/lib/{svgo.browser-DYieWzyw.mjs.map → svgo.browser-EB1zkPfG.mjs.map} +1 -1
  94. package/lib/{three.core-DjCexDCp.mjs → three.core-CmmDf_BZ.mjs} +73 -38
  95. package/lib/{three.core-DjCexDCp.mjs.map → three.core-CmmDf_BZ.mjs.map} +1 -1
  96. package/lib/{three.module-CuRNgijg.mjs → three.module-BkkLbA6n.mjs} +857 -857
  97. package/lib/{three.module-CuRNgijg.mjs.map → three.module-BkkLbA6n.mjs.map} +1 -1
  98. package/lib/three.tsl-8HwZJGJ8.mjs +2 -0
  99. package/lib/{three.tsl-BIBER8nk.mjs → three.tsl-Cw9IeeKW.mjs} +64 -52
  100. package/lib/{three.tsl-BIBER8nk.mjs.map → three.tsl-Cw9IeeKW.mjs.map} +1 -1
  101. package/lib/three.webgpu-Bw4_U6Q1.mjs +3 -0
  102. package/lib/{three.webgpu-Bz4Xtk0X.mjs → three.webgpu-DL5l_0xI.mjs} +1742 -1728
  103. package/lib/{three.webgpu-Bz4Xtk0X.mjs.map → three.webgpu-DL5l_0xI.mjs.map} +1 -1
  104. package/lib/{threejs-utils-Dpvg3Czz.mjs → threejs-utils-PRhv_eX3.mjs} +63 -63
  105. package/lib/{threejs-utils-Dpvg3Czz.mjs.map → threejs-utils-PRhv_eX3.mjs.map} +1 -1
  106. package/lib/{tools-core-BDOFf9le.mjs → tools-core-CmrXkw3J.mjs} +3 -3
  107. package/lib/{tools-core-BDOFf9le.mjs.map → tools-core-CmrXkw3J.mjs.map} +1 -1
  108. package/lib/webgpu-wkXAkJ6p.mjs +5084 -0
  109. package/lib/webgpu-wkXAkJ6p.mjs.map +1 -0
  110. package/lib/workers-YGDNEfpU.mjs +6 -0
  111. package/lib/{workers-DcgrO-z7.mjs.map → workers-YGDNEfpU.mjs.map} +1 -1
  112. package/package.json +5 -4
  113. package/lib/asset-loader.worker-C_5RQYHp.mjs.map +0 -1
  114. package/lib/budgeteer.sw-DxeAvd0v.mjs.map +0 -1
  115. package/lib/configurator-BBlZVIId.mjs +0 -2
  116. package/lib/dimensioning-helper-Bzf1sbpy.mjs +0 -2
  117. package/lib/glb-viewer-A5vSLFZ5.mjs.map +0 -1
  118. package/lib/glb-viewer-B4ILlvw0.mjs +0 -2
  119. package/lib/planner-49YwTdiA.mjs +0 -2
  120. package/lib/planner-t4QH26WW.mjs +0 -44
  121. package/lib/roomle-headless-setup-Cc8EAnVe.mjs +0 -1204
  122. package/lib/roomle-headless-setup-Cc8EAnVe.mjs.map +0 -1
  123. package/lib/roomle-webgpu-renderer-CRGcdahn.mjs.map +0 -1
  124. package/lib/shading-settings-BEMqEGzB.mjs.map +0 -1
  125. package/lib/three.tsl-Q-21y0pO.mjs +0 -2
  126. package/lib/three.webgpu-dtN0kDKB.mjs +0 -3
  127. package/lib/workers-DcgrO-z7.mjs +0 -6
@@ -1,17 +1,18 @@
1
- import { a as e, i as t, n, r, t as i } from "./packages-C9gO5mKk.mjs";
1
+ import { a as e, i as t, n, r, t as i } from "./packages-B3bi3adH.mjs";
2
2
  import { i as a, t as o } from "./kernel-BWfRHWkW.mjs";
3
- import { mt as s, vt as c } from "./threejs-utils-Dpvg3Czz.mjs";
4
- import { xi as l } from "./three.core-DjCexDCp.mjs";
5
- import { A as u, B as d, F as f, G as p, H as ee, I as m, J as h, K as g, M as _, N as v, P as y, S as b, U as x, W as S, a as C, b as w, c as T, ct as E, dt as D, i as O, it as k, k as A, l as j, n as M, nt as N, ot as P, pt as F, rt as I, s as L, st as te, ut as R, v as z, x as B, y as V } from "./main-BUl8iCi1.mjs";
6
- import { n as H } from "./script-loader-D6IuUFjw.mjs";
7
- import { t as U } from "./configurator-C_rsqn9l.mjs";
8
- import { t as W } from "./planner-t4QH26WW.mjs";
9
- import { n as G, t as K } from "./glb-viewer-A5vSLFZ5.mjs";
10
- import { t as q } from "./api-CUyBdNba.mjs";
11
- import "./roomle-headless-setup-Cc8EAnVe.mjs";
12
- import { createRequire as J } from "module";
3
+ import { mt as s, vt as c } from "./threejs-utils-PRhv_eX3.mjs";
4
+ import { Si as l, m as u, nt as d } from "./three.core-CmmDf_BZ.mjs";
5
+ import { B as f, C as p, E as m, I as h, J as ee, K as te, L as ne, N as re, P as ie, Q as ae, R as oe, S as se, T as ce, W as le, X as ue, Y as de, _ as fe, a as pe, c as g, ct as _, d as v, dt as y, f as b, ft as x, gt as S, ht as C, i as w, l as T, lt as E, n as D, o as O, p as k, pt as A, q as j, s as M, st as N, vt as P, w as F, z as I } from "./main-n3n3jdja.mjs";
6
+ import { n as L } from "./roomle-renderer-BR0UKz2y.mjs";
7
+ import { n as R } from "./script-loader-BAWHLt9q.mjs";
8
+ import { t as z } from "./configurator-BjLLdSf8.mjs";
9
+ import { t as B } from "./planner-DIT2VvMG.mjs";
10
+ import { n as me, t as he } from "./glb-viewer-9Ata6ZNJ.mjs";
11
+ import { t as ge } from "./api-BEszDVqh.mjs";
12
+ import { t as _e } from "./roomle-headless-setup-CMHahWyC.mjs";
13
+ import { createRequire as ve } from "module";
13
14
  //#region packages/headless-core/src/headless-script-loader.ts
14
- var Y = J(import.meta.url), X = {}, Z = [
15
+ var ye = ve(import.meta.url), V = {}, H = [
15
16
  [
16
17
  "ConfiguratorKernel.wasm",
17
18
  "ConfiguratorKernel",
@@ -27,48 +28,48 @@ var Y = J(import.meta.url), X = {}, Z = [
27
28
  "RoomleToolsCore",
28
29
  "roomle-core-hsc/wasm_modern/RoomleToolsCore.js"
29
30
  ]
30
- ], Q = class {
31
+ ], be = class {
31
32
  constructor(e) {
32
33
  this._creator_ = e;
33
34
  }
34
35
  async fetch(e, t) {
35
- if (X[t.id]) return;
36
+ if (V[t.id]) return;
36
37
  if (typeof e == "function") {
37
- this._registerFactory(e), X[t.id] = !0;
38
+ this._registerFactory(e), V[t.id] = !0;
38
39
  return;
39
40
  }
40
41
  let n = this._resolveEntry(e);
41
42
  if (n) {
42
- let [, r, i] = n, a = Y(e.startsWith("/") ? e : i);
43
- globalThis[r] = a.default || a, X[t.id] = !0;
43
+ let [, r, i] = n, a = ye(e.startsWith("/") ? e : i);
44
+ globalThis[r] = a.default || a, V[t.id] = !0;
44
45
  }
45
46
  }
46
47
  _registerFactory(e) {
47
48
  let t = e.toString();
48
- for (let [n, r] of Z) if (t.includes(n)) {
49
+ for (let [n, r] of H) if (t.includes(n)) {
49
50
  globalThis[r] = e;
50
51
  return;
51
52
  }
52
53
  console.warn("HeadlessScriptLoader: Could not identify Emscripten factory function");
53
54
  }
54
55
  _resolveEntry(e) {
55
- for (let t of Z) {
56
+ for (let t of H) {
56
57
  let [n, r] = t, i = r;
57
58
  if (e.includes(i) || e.includes(n)) return t;
58
59
  }
59
- return e.includes("configurator") ? Z[0] : e.includes("planner") ? Z[1] : e.includes("tools") ? Z[2] : (console.warn(`HeadlessScriptLoader: Could not resolve module for URL: ${e}`), null);
60
+ return e.includes("configurator") ? H[0] : e.includes("planner") ? H[1] : e.includes("tools") ? H[2] : (console.warn(`HeadlessScriptLoader: Could not resolve module for URL: ${e}`), null);
60
61
  }
61
62
  loadScripts(e) {
62
63
  let t = e.map((e) => this.fetch(e.name, { id: e.id }));
63
64
  return Promise.all(t);
64
65
  }
65
66
  resolveKernelPaths(e) {
66
- return H(e);
67
+ return R(e);
67
68
  }
68
69
  cleanUp() {
69
- X = {};
70
+ V = {};
70
71
  }
71
- }, ne = class {
72
+ }, xe = class {
72
73
  get _lifeCycleManager() {
73
74
  return globalThis.__RML__DI__?.lookup("life-cycle-manager", this._creator_);
74
75
  }
@@ -134,7 +135,7 @@ var Y = J(import.meta.url), X = {}, Z = [
134
135
  pause() {}
135
136
  resume() {}
136
137
  destroy() {}
137
- }, re = class {
138
+ }, Se = class {
138
139
  constructor(e) {
139
140
  this._creator_ = e;
140
141
  }
@@ -162,11 +163,11 @@ var Y = J(import.meta.url), X = {}, Z = [
162
163
  }
163
164
  setAlwaysUseCache(e) {}
164
165
  preFillAssetCache(e, t) {}
165
- }, ie = class extends L {
166
+ }, Ce = class extends v {
166
167
  _getScriptLoaderKernelId(e) {
167
- return e === u.PLANNER ? "kernel-planner" : "kernel";
168
+ return e === ie.PLANNER ? "kernel-planner" : "kernel";
168
169
  }
169
- }, ae = class {
170
+ }, we = class {
170
171
  wrap(e) {
171
172
  return new Proxy(e, { get(e, t) {
172
173
  let n = e[t];
@@ -179,7 +180,240 @@ var Y = J(import.meta.url), X = {}, Z = [
179
180
  } : n;
180
181
  } });
181
182
  }
182
- }, oe = {
183
+ }, Te = class extends pe {
184
+ async addReflectiveFloor(e) {}
185
+ }, U = null;
186
+ function Ee(e) {
187
+ U = e;
188
+ }
189
+ var W = null, De = 256 * 1024 * 1024, Oe = 1, G = 500, K = 512;
190
+ function q(e) {
191
+ return Math.max(1, Math.floor(De * .95 / e));
192
+ }
193
+ var ke = (e) => {
194
+ W = e;
195
+ }, J = null, Y = {
196
+ minIntervalMs: G,
197
+ maxSize: K
198
+ }, Ae = (e, t) => {
199
+ J = e, Y = {
200
+ minIntervalMs: t?.minIntervalMs ?? G,
201
+ maxSize: t?.maxSize ?? K
202
+ };
203
+ }, X = class {
204
+ constructor() {
205
+ this._pathTracer = null, this._renderer = null;
206
+ }
207
+ async render(e, t, n, r = 10, i = {}) {
208
+ let a = await this._getPathTracer(e);
209
+ i.bounces !== void 0 && (a.bounces = i.bounces), a.renderScale = i.renderScale ?? Oe;
210
+ let o = this._applyScenePatches(t), s = {
211
+ autoClear: e.autoClear,
212
+ toneMapping: e.toneMapping,
213
+ toneMappingExposure: e.toneMappingExposure,
214
+ outputColorSpace: e.outputColorSpace
215
+ };
216
+ try {
217
+ a.setScene(t, n), a.reset();
218
+ let o = Math.max(1, Math.floor(r)), s = 0;
219
+ for (; a.samples < o;) a.renderSample(), W?.(a.samples, o), J && a.samples >= 2 && performance.now() - s >= Y.minIntervalMs && (await this._emitPreview(e, a.samples, o), s = performance.now()), await new Promise((e) => setTimeout(e, 0));
220
+ a.renderSample(), i.denoise && await this._denoiseAndBlit(e, a);
221
+ } finally {
222
+ this._undoScenePatches(o), e.autoClear = s.autoClear, e.toneMapping = s.toneMapping, e.toneMappingExposure = s.toneMappingExposure, e.outputColorSpace = s.outputColorSpace;
223
+ }
224
+ }
225
+ _applyScenePatches(e) {
226
+ let t = {
227
+ materialSides: /* @__PURE__ */ new Map(),
228
+ hiddenMeshes: [],
229
+ geometryAttributes: /* @__PURE__ */ new Map(),
230
+ detachedMeshes: []
231
+ };
232
+ e.traverse((e) => this._prepareObjectForPathTracing(e, t));
233
+ for (let e = t.detachedMeshes.length - 1; e >= 0; e--) {
234
+ let { object: n, parent: r, index: i } = t.detachedMeshes[e];
235
+ r.children.splice(i, 1), n.parent = null;
236
+ }
237
+ return t;
238
+ }
239
+ _prepareObjectForPathTracing(e, t) {
240
+ let n = e.geometry, r = e;
241
+ if (n?.isBufferGeometry && (!n.attributes.position && e.parent && t.detachedMeshes.push({
242
+ object: r,
243
+ parent: e.parent,
244
+ index: e.parent.children.indexOf(e)
245
+ }), t.geometryAttributes.has(n) || (t.geometryAttributes.set(n, new Set(Object.keys(n.attributes))), this._patchInvalidTangents(n, !r.isMesh))), r.isMesh) {
246
+ if (r.visible && (r.userData?.isBoundingGeometry || r.name?.match("bounding box"))) {
247
+ r.visible = !1, t.hiddenMeshes.push(r);
248
+ return;
249
+ }
250
+ this._forceDoubleSidedMaterials(r, t.materialSides);
251
+ }
252
+ }
253
+ _forceDoubleSidedMaterials(e, t) {
254
+ let n = Array.isArray(e.material) ? e.material : [e.material];
255
+ for (let e of n) e?.side === 0 && !t.has(e) && (t.set(e, e.side), e.side = 2);
256
+ }
257
+ _undoScenePatches(e) {
258
+ for (let { object: t, parent: n, index: r } of e.detachedMeshes) n.children.splice(r, 0, t), t.parent = n;
259
+ for (let [t, n] of e.materialSides) t.side = n;
260
+ for (let t of e.hiddenMeshes) t.visible = !0;
261
+ for (let [t, n] of e.geometryAttributes) Object.keys(t.attributes).filter((e) => !n.has(e)).forEach((e) => t.deleteAttribute(e));
262
+ }
263
+ _patchInvalidTangents(e, t) {
264
+ let n = e.attributes.position;
265
+ !n || e.attributes.tangent || this._hasInvalidTriangleLayout(e, t) && e.setAttribute("tangent", new u(new Float32Array(n.count * 4), 4));
266
+ }
267
+ _hasInvalidTriangleLayout(e, t) {
268
+ let n = e.attributes.position.count, r = e.index?.array, i = r ? r.length : n;
269
+ return t || i % 3 != 0 ? !0 : r ? e.groups.some((e) => e.start + e.count > r.length) || r.some((e) => e >= n) : !1;
270
+ }
271
+ dispose() {
272
+ this._pathTracer?.dispose(), this._pathTracer = null, this._renderer = null;
273
+ }
274
+ async _emitPreview(e, t, n) {
275
+ try {
276
+ let r = e.domElement, i = r.getContext?.("webgpu");
277
+ if (!i?.readbackScaled) return;
278
+ let a = Math.min(1, Y.maxSize / Math.max(1, Math.max(r.width, r.height))), o = Math.max(1, Math.round(r.width * a)), s = Math.max(1, Math.round(r.height * a)), c = await i.readbackScaled(o, s);
279
+ if (!c) return;
280
+ let { createCanvas: l, ImageData: u } = await import("@napi-rs/canvas"), d = l(c.width, c.height);
281
+ d.getContext("2d").putImageData(new u(new Uint8ClampedArray(c.data.buffer, c.data.byteOffset, c.data.byteLength), c.width, c.height), 0, 0);
282
+ let f = await d.encode("png");
283
+ J?.({
284
+ png: new Uint8Array(f.buffer, f.byteOffset, f.byteLength),
285
+ width: c.width,
286
+ height: c.height,
287
+ samples: t,
288
+ totalSamples: n
289
+ });
290
+ } catch {}
291
+ }
292
+ async _readHdrTargetTiled(e, t, n, r) {
293
+ let i = n * 4, a = Math.ceil(n / 16) * 16 * 4, o = q(a * 4), s = new Float32Array(i * r);
294
+ for (let c = 0; c < r; c += o) {
295
+ let l = Math.min(o, r - c), u = await e.readRenderTargetPixelsAsync({ textures: [t] }, 0, c, n, l);
296
+ if (u.length === i * l) s.set(u, c * i);
297
+ else for (let e = 0; e < l; e++) s.set(u.subarray(e * a, e * a + i), (c + e) * i);
298
+ }
299
+ return s;
300
+ }
301
+ async _denoiseAndBlit(e, t) {
302
+ if (!U) throw Error("WebGPUPathTracerRenderer: pathTracerSettings.denoise=true but no external denoiser is registered. Use setPathTracerExternalDenoiser() with Intel OIDN binaries");
303
+ let n = t._pathTracer.outputTarget, { width: r, height: i } = n, a = await this._readHdrTargetTiled(e, n, r, i), o = await U(a, r, i);
304
+ this._writeDenoisedIntoTarget(e, n, o, r, i);
305
+ let s = t._blitQuad, c = e.toneMapping, l = e.toneMappingExposure, u = e.autoClear, d = e.getRenderTarget();
306
+ e.toneMapping = 0, e.toneMappingExposure = 1, e.autoClear = !0, e.setRenderTarget(null), s.material.transition = 1, s.material.opacity = 1, s.material.texture = n, s.material.toneMapping = c, s.material.toneMappingExposure = l, s.render(e), e.autoClear = u, e.toneMapping = c, e.toneMappingExposure = l, e.setRenderTarget(d);
307
+ }
308
+ _writeDenoisedIntoTarget(e, t, n, r, i) {
309
+ let a = e.backend, o = a?.get?.(t)?.texture, s = a?.device?.queue;
310
+ if (!o || !s) throw Error("WebGPUPathTracerRenderer: could not access the backend GPU texture for the denoise write-back.");
311
+ let c = r * 16, l = r * 4, u = q(c);
312
+ for (let e = 0; e < i; e += u) {
313
+ let t = Math.min(u, i - e), a = n.subarray(e * l, (e + t) * l);
314
+ s.writeTexture({
315
+ texture: o,
316
+ origin: {
317
+ x: 0,
318
+ y: e,
319
+ z: 0
320
+ }
321
+ }, a, {
322
+ offset: 0,
323
+ bytesPerRow: c,
324
+ rowsPerImage: t
325
+ }, {
326
+ width: r,
327
+ height: t,
328
+ depthOrArrayLayers: 1
329
+ });
330
+ }
331
+ }
332
+ async _getPathTracer(e) {
333
+ if (this._pathTracer && this._renderer === e) return this._pathTracer;
334
+ this._pathTracer?.dispose();
335
+ let { WebGPUPathTracer: t } = await import("./webgpu-wkXAkJ6p.mjs"), n = new t(e);
336
+ return n.useMegakernel(!0), n.dynamicLowRes = !1, n.renderDelay = 0, n.fadeDuration = 0, n.minSamples = 1, this._pathTracer = n, this._renderer = e, n;
337
+ }
338
+ }, je = class e extends fe {
339
+ constructor(...e) {
340
+ super(...e), this._headlessPathTracerRenderer = null;
341
+ }
342
+ async _createThreejsImageRenderer() {
343
+ if (!this._initData.featureFlags.webGpu) return super._createThreejsImageRenderer();
344
+ let { WebGPURenderer: e } = await import("./three.webgpu-Bw4_U6Q1.mjs"), t = new e({
345
+ antialias: !1,
346
+ alpha: !0
347
+ });
348
+ return await t.init(), t;
349
+ }
350
+ async _createRoomleRenderer(e) {
351
+ if (!e.isWebGPURenderer) return super._createRoomleRenderer(e);
352
+ let { RoomleWebGPURenderer: t } = await import("./roomle-webgpu-renderer-fOYJoKJU.mjs");
353
+ return new t(this._creator_, e, !0, void 0, !1);
354
+ }
355
+ static hasExplicitCameraPlacement(e) {
356
+ return e.cameraPosition !== void 0 || e.cameraPitch !== void 0 || e.cameraYaw !== void 0;
357
+ }
358
+ static placeCameraExplicitly(e, t) {
359
+ e.near = .01, e.far = 1e3, t.cameraPosition && e.position.set(t.cameraPosition.x, t.cameraPosition.y, t.cameraPosition.z), (t.cameraPitch !== void 0 || t.cameraYaw !== void 0) && e.quaternion.setFromEuler(new d(-(t.cameraPitch ?? 0), t.cameraYaw ?? 0, 0, "ZYX")), e.updateProjectionMatrix();
360
+ }
361
+ _getRenderSize(e) {
362
+ let { width: t, height: n } = super._getRenderSize(e);
363
+ return {
364
+ width: e.width ?? t,
365
+ height: e.height ?? n
366
+ };
367
+ }
368
+ _placeCamera(t, n, r, i) {
369
+ e.hasExplicitCameraPlacement(i) ? e.placeCameraExplicitly(t, i) : (super._placeCamera(t, n, r, i), n && (t.near = Math.max(.01, n.diagonal * .5))), i.fov !== void 0 && (t.fov = i.fov);
370
+ let { width: a, height: o } = this._getRenderSize(i);
371
+ t.aspect = a / o, t.updateProjectionMatrix();
372
+ }
373
+ async _renderFrame(e, t, n, r) {
374
+ return r.pathTracer ? { imageDataUrl: await this._renderPathTracedFrame(e, t, n, {
375
+ samples: r.pathTracerSamples,
376
+ settings: r.pathTracerSettings
377
+ }) } : super._renderFrame(e, t, n, r);
378
+ }
379
+ async _renderPathTracedFrame(e, t, n, r) {
380
+ let i = e instanceof L ? e.renderer : e;
381
+ if (!i.isWebGPURenderer) throw Error("HeadlessImageRenderer: path tracing requires the WebGPU renderer (enable featureFlags.webGpu)");
382
+ this._headlessPathTracerRenderer ||= new X(), await this._headlessPathTracerRenderer.render(i, t, n, r.samples, r.settings);
383
+ let { imageDataUrl: a } = await this._readFrameAndClear(i);
384
+ return a;
385
+ }
386
+ async _readFrameAndClear(e, t) {
387
+ let n = this._getWebGpuMockContext(e);
388
+ if (!n) return super._readFrameAndClear(e, t);
389
+ let r = !!t?.preferRawPixels && !t?.showDimensions, i = r ? await this._readScaledRawPixels(e, n, t?.rawPixelsScale) : null;
390
+ if (i) return e.clear(), {
391
+ imageDataUrl: "",
392
+ pixels: i
393
+ };
394
+ let a = await n.flushReadback();
395
+ if (r && a) {
396
+ let { width: t, height: n } = e.domElement;
397
+ return e.clear(), {
398
+ imageDataUrl: "",
399
+ pixels: {
400
+ data: a,
401
+ width: t,
402
+ height: n
403
+ }
404
+ };
405
+ }
406
+ return super._readFrameAndClear(e, t);
407
+ }
408
+ _getWebGpuMockContext(e) {
409
+ return e.isWebGPURenderer ? e.domElement?.getContext?.("webgpu") ?? null : null;
410
+ }
411
+ async _readScaledRawPixels(e, t, n) {
412
+ if (!n || n <= 0 || n >= 1) return null;
413
+ let { width: r, height: i } = e.domElement;
414
+ return t.readbackScaled(Math.max(1, Math.round(r * n)), Math.max(1, Math.round(i * n)));
415
+ }
416
+ }, Me = {
183
417
  add(e) {
184
418
  try {
185
419
  e.end?.();
@@ -191,42 +425,83 @@ var Y = J(import.meta.url), X = {}, Z = [
191
425
  return [];
192
426
  },
193
427
  update() {}
194
- }, $ = () => {
428
+ }, Ne = () => {
195
429
  let e = window;
196
- e.TWEEN = oe;
197
- }, se = "inline-plan-xml#", ce = "inline-configuration#", le = class e {
430
+ e.TWEEN = Me;
431
+ }, Z = class extends O {
432
+ constructor(...e) {
433
+ super(...e), this._callbacks = /* @__PURE__ */ new Set(), this._dispatcherInstalled = !1;
434
+ }
435
+ registerEnvironmentChangedCallback(e) {
436
+ this._callbacks.add(e), this._dispatcherInstalled ||= (super.registerEnvironmentChangedCallback((e) => {
437
+ this._callbacks.forEach((t) => t(e));
438
+ }), !0);
439
+ }
440
+ static async loadEquirectTexture(e) {
441
+ let t = await (e.toLowerCase().endsWith(".exr") ? new g() : new M()).loadAsync(e);
442
+ return t.mapping = 303, t;
443
+ }
444
+ }, Q = 1024, Pe = "inline-plan-xml#", Fe = "inline-configuration#", Ie = class e {
198
445
  constructor() {
199
- this._initialized = !1, this._configuratorReady = !1, this._plannerReady = !1, this._glbViewerReady = !1, this._loadedConfigurationId = null, this._loadedPlanId = null, this._loadedStaticItemId = null, this._width = 1024, this._height = 768, this._loaderQueue = Promise.resolve(), this._onReadyForRenderArmed = null;
446
+ this._initialized = !1, this._configuratorReady = !1, this._plannerReady = !1, this._glbViewerReady = !1, this._loadedConfigurationId = null, this._loadedPlanId = null, this._loadedStaticItemId = null, this._width = 1024, this._height = 768, this._loaderQueue = Promise.resolve(), this._skyboxOriginal = /* @__PURE__ */ new WeakMap(), this._onReadyForRenderArmed = null;
200
447
  }
201
448
  static async create(t) {
202
449
  let n = new e();
203
450
  return await n._init(t), n;
204
451
  }
205
452
  async _init(e) {
206
- this._width = e.width ?? 1024, this._height = e.height ?? 768, $(), this._registerHeadlessServices(this._width, this._height), await j.setGlobalInitData({
453
+ this._width = e.width ?? 1024, this._height = e.height ?? 768, this._featureFlags = e.featureFlags, e.featureFlags?.webGpu || (console.warn("HeadlessRoomleSdk: WebGPU is required, forcing featureFlags.webGpu on."), this._featureFlags = {
454
+ ...e.featureFlags,
455
+ webGpu: !0
456
+ }), this._webGpuConfig = {
457
+ autoDetectQualityLevel: !1,
458
+ autoQualityMinFps: 0,
459
+ autoQualityMaxFps: 2 ** 53 - 1,
460
+ ...e.webGpuConfig
461
+ }, Ne(), this._registerHeadlessServices(this._width, this._height), await k.setGlobalInitData({
207
462
  configuratorId: e.configuratorId,
208
463
  locale: e.locale,
209
464
  tenant: e.tenant,
210
465
  overrideCountry: e.overrideCountry,
466
+ customApiUrl: e.customApiUrl,
467
+ overrideRapi: e.overrideRapi,
211
468
  animateCamera: !1
212
469
  }), this._initialized = !0;
213
470
  }
471
+ _deepMergeHeadlessInitDefaults(e) {
472
+ if (!this._featureFlags && !this._webGpuConfig) return e;
473
+ let t = e?.featureFlags;
474
+ return {
475
+ ...e,
476
+ featureFlags: {
477
+ ...this._featureFlags,
478
+ ...t
479
+ },
480
+ webGpuConfig: {
481
+ ...this._webGpuConfig,
482
+ ...e?.webGpuConfig
483
+ }
484
+ };
485
+ }
214
486
  _registerHeadlessServices(e, t) {
215
487
  let n = new N();
216
488
  globalThis.__RML__DI__ = n;
217
- class r extends ne {
489
+ class r extends xe {
218
490
  constructor(n) {
219
491
  super(n, e, t);
220
492
  }
221
493
  }
222
494
  let i = [
223
- new k("script-loader", Q, I.CONTEXT, !0),
224
- new k("dom-helper", r, I.CONTEXT, !0),
225
- new k("data-syncer", re, I.GLOBAL, !0),
226
- new k("planner-kernel-access", ie, I.GLOBAL, !0),
227
- new k("kernel-callback-guard", ae, I.GLOBAL, !0)
495
+ new E("script-loader", be, _.CONTEXT, !0),
496
+ new E("dom-helper", r, _.CONTEXT, !0),
497
+ new E("data-syncer", Se, _.GLOBAL, !0),
498
+ new E("planner-kernel-access", Ce, _.GLOBAL, !0),
499
+ new E("kernel-callback-guard", we, _.GLOBAL, !0),
500
+ new E("web-gpu-ground-shadow-reflection", Te, _.CONTEXT, !0),
501
+ new E("image-renderer", je, _.CONTEXT, !0),
502
+ new E("hdr-environment-loader", Z, _.GLOBAL, !0)
228
503
  ];
229
- n.addDependencyInjectionAssignments(O), n.addDependencyInjectionAssignments(i);
504
+ n.addDependencyInjectionAssignments(w), n.addDependencyInjectionAssignments(i);
230
505
  }
231
506
  _makeStubElement() {
232
507
  return {
@@ -240,28 +515,28 @@ var Y = J(import.meta.url), X = {}, Z = [
240
515
  }
241
516
  async prewarmConfigurator(e) {
242
517
  this._ensureInitialized();
243
- let t = await j.getConfigurator(e);
518
+ let t = await k.getConfigurator(this._deepMergeHeadlessInitDefaults(e));
244
519
  await t.boot(), this._configuratorMain = t, this._configurator = t.getApi(), await this._configurator.init(this._makeStubElement()), this._configuratorReady = !0;
245
520
  }
246
521
  async prewarmPlanner(e) {
247
522
  this._ensureInitialized();
248
- let t = await j.getPlanner({
523
+ let t = await k.getPlanner({
249
524
  moc: !0,
250
- ...e
525
+ ...this._deepMergeHeadlessInitDefaults(e)
251
526
  });
252
527
  if (e?.moc === !1) throw Error("HeadlessRoomleSdk: planner requires moc:true");
253
528
  await t.boot(), this._plannerMain = t, this._planner = t.getApi(), await this._planner.init(this._makeStubElement()), this._plannerReady = !0;
254
529
  }
255
530
  async prewarmGlbViewer(e) {
256
531
  this._ensureInitialized();
257
- let t = await j.getGlbViewer(e);
532
+ let t = await k.getGlbViewer(this._deepMergeHeadlessInitDefaults(e));
258
533
  await t.boot(), this._glbViewerMain = t, this._glbViewer = t.getApi(), await this._glbViewer.init(this._makeStubElement()), this._glbViewerReady = !0;
259
534
  }
260
535
  async loadConfiguration(e, t) {
261
536
  return this._loadIntoConfigurator(e, () => this._configurator.loadConfigurationById(e), t);
262
537
  }
263
538
  async loadConfigurationString(e, t) {
264
- let n = await this._inlineSceneId(ce, e);
539
+ let n = await this._inlineSceneId(Fe, e);
265
540
  return this._loadIntoConfigurator(n, () => this._configurator.loadConfiguration(e), t);
266
541
  }
267
542
  async loadConfigurableItemById(e, t) {
@@ -292,14 +567,14 @@ var Y = J(import.meta.url), X = {}, Z = [
292
567
  }
293
568
  async loadObject(e, a) {
294
569
  if (this._ensureInitialized(), i(e)) throw Error(`HeadlessRoomleSdk: component ids ("${e}") are not supported. Use loadConfigurableItemById, loadConfiguration, or loadPlan directly.`);
295
- return n(e) ? this.loadConfigurationString(e, a) : r(e) ? this.loadPlan(e, a) : t(e) ? (await (await j.getRapiAccess()).getItem(e))?.configuration ? this.loadConfigurableItemById(e, a) : this.loadStaticItem(e, a) : this.loadConfiguration(e, a);
570
+ return n(e) ? this.loadConfigurationString(e, a) : r(e) ? this.loadPlan(e, a) : t(e) ? (await (await k.getRapiAccess()).getItem(e))?.configuration ? this.loadConfigurableItemById(e, a) : this.loadStaticItem(e, a) : this.loadConfiguration(e, a);
296
571
  }
297
572
  async loadPlan(e, t) {
298
573
  return this._ensureInitialized(), this._loadIntoPlanner(e, () => this._planner.loadPlan(e), t);
299
574
  }
300
575
  async loadPlanXml(e, t) {
301
576
  this._ensureInitialized();
302
- let n = await this._inlineSceneId(se, e);
577
+ let n = await this._inlineSceneId(Pe, e);
303
578
  return this._loadIntoPlanner(n, () => this._planner.loadPlanXml(e), t);
304
579
  }
305
580
  async _loadIntoPlanner(e, t, n) {
@@ -326,7 +601,7 @@ var Y = J(import.meta.url), X = {}, Z = [
326
601
  this._onReadyForRenderArmed &&= (await this._onReadyForRenderArmed, null);
327
602
  }
328
603
  async _armOnReadyForRender() {
329
- let e = await j.callbacks;
604
+ let e = await k.callbacks;
330
605
  if (!e) {
331
606
  this._onReadyForRenderArmed = null;
332
607
  return;
@@ -377,6 +652,35 @@ var Y = J(import.meta.url), X = {}, Z = [
377
652
  _getActiveSceneManager() {
378
653
  return this._loadedStaticItemId ? this._glbViewer.getSceneManager() : this._getActiveApi().getSceneManager();
379
654
  }
655
+ async setEnvironmentMap(e, t = {}) {
656
+ this._ensureInitialized(), await this._getEnvironmentSceneManager().loadEnvMap(e), this.setEnvironmentMapOptions(t);
657
+ }
658
+ async resetEnvironmentMap(e = {}) {
659
+ this._ensureInitialized();
660
+ let t = this._getEnvironmentSceneManager();
661
+ await t.loadEnvMap(t.initData?.envMapUrl ?? "" + new URL("default_256.exr", import.meta.url).href), this.setEnvironmentMapOptions(e);
662
+ }
663
+ setEnvironmentMapOptions(e) {
664
+ e.intensity === void 0 && e.rotation === void 0 || this._getEnvironmentSceneManager().setEnvironmentMap?.(void 0, e.intensity, e.rotation);
665
+ }
666
+ _getEnvironmentSceneManager() {
667
+ let e = this._getActiveSceneManager();
668
+ if (typeof e.loadEnvMap != "function") throw Error("HeadlessRoomleSdk: setEnvironmentMap is not supported for the active module");
669
+ return e;
670
+ }
671
+ async setSkybox(e) {
672
+ this._ensureInitialized();
673
+ let t = this._getActiveSceneManager().getScene();
674
+ this._skyboxOriginal.has(t) || this._skyboxOriginal.set(t, {
675
+ background: t.background,
676
+ showEnvironmentBackground: t.userData.showEnvironmentBackground
677
+ }), t.background = await Z.loadEquirectTexture(e), t.userData.showEnvironmentBackground = !1;
678
+ }
679
+ resetSkybox() {
680
+ this._ensureInitialized();
681
+ let e = this._getActiveSceneManager().getScene(), t = this._skyboxOriginal.get(e);
682
+ t && (e.background = t.background, e.userData.showEnvironmentBackground = t.showEnvironmentBackground, this._skyboxOriginal.delete(e));
683
+ }
380
684
  async _export(e, t) {
381
685
  this._ensureInitialized();
382
686
  let n = this._getActiveSceneManager(), r = t === "glb" ? await n.createExportGLB() : await n.createUSDZExport();
@@ -386,57 +690,100 @@ var Y = J(import.meta.url), X = {}, Z = [
386
690
  }
387
691
  async exportScreenshot(e, t = {}) {
388
692
  this._ensureInitialized();
389
- let n = t.ssaa ?? 2, r = t.size ?? 1024, i = r * n, a = (await this._getActiveApi().preparePerspectiveImage({
693
+ let { ssaa: n, targetWidth: r, targetHeight: i, renderWidth: a, renderHeight: o } = this._getRenderDimensions(t), s = {
390
694
  rotationY: t.rotationY,
391
- size: i,
392
- preserveSceneBackground: !0
393
- })).image;
394
- if (n > 1 && (a = await this._ssaaDownscale(a, r, r)), e) {
395
- let t = await import("fs"), n = a.replace(/^data:image\/\w+;base64,/, "");
396
- t.writeFileSync(e, Buffer.from(n, "base64"));
397
- }
398
- return { dataUrl: a };
695
+ cameraPosition: t.cameraPosition,
696
+ cameraPitch: t.cameraPitch,
697
+ cameraYaw: t.cameraYaw,
698
+ fov: t.fov,
699
+ showWallsAndCeiling: t.showWallsAndCeiling,
700
+ width: a,
701
+ height: o,
702
+ preserveSceneBackground: !0,
703
+ pathTracer: t.pathTracer,
704
+ pathTracerSamples: t.pathTracerSamples,
705
+ pathTracerSettings: t.pathTracerSettings,
706
+ preferRawPixels: !0,
707
+ rawPixelsScale: 1 / n
708
+ }, c = await this._getActiveApi().preparePerspectiveImage(s), l = await this._resolveImageDataUrl(c, r, i, n);
709
+ return await this._writeDataUrlToFile(l, e), { dataUrl: l };
399
710
  }
400
711
  async exportPerspectiveImage(e, t = {}) {
401
712
  this._ensureInitialized();
402
- let n = t.ssaa ?? 2, r = t.size ?? 1024, i = r * n, a = await this._getActiveApi().preparePerspectiveImage({
713
+ let { ssaa: n, targetWidth: r, targetHeight: i, renderWidth: a, renderHeight: o } = this._getRenderDimensions(t), s = {
403
714
  ...t,
404
- size: i
405
- }), o = a.image, s = a.width, c = a.height;
406
- if (n > 1 && (o = await this._ssaaDownscale(o, r, r), s = r, c = r), e) {
407
- let t = await import("fs"), n = o.replace(/^data:image\/\w+;base64,/, "");
408
- t.writeFileSync(e, Buffer.from(n, "base64"));
409
- }
410
- return {
411
- dataUrl: o,
412
- width: s,
413
- height: c
715
+ width: a,
716
+ height: o,
717
+ preferRawPixels: !0,
718
+ rawPixelsScale: 1 / n
719
+ }, c = await this._getActiveApi().preparePerspectiveImage(s), l = !!c.pixels || n > 1, u = await this._resolveImageDataUrl(c, r, i, n);
720
+ return await this._writeDataUrlToFile(u, e), {
721
+ dataUrl: u,
722
+ width: l ? r : c.width,
723
+ height: l ? i : c.height
414
724
  };
415
725
  }
416
726
  async exportTopImage(e, t = {}) {
417
727
  if (this._ensureInitialized(), this._loadedStaticItemId) throw Error("HeadlessRoomleSdk: exportTopImage is not supported for static items");
418
- let n = this._getActiveApi(), r = t.ssaa ?? 2, i = await n.prepareTopImage({
728
+ let n = this._getActiveApi(), r = t.ssaa ?? 2, i = {
419
729
  ...t,
420
- size: (t.size ?? 1024) * r,
421
- showDimensions: t.showDimensions ?? !1
422
- }), a = i.image, o = i.width, s = i.height;
423
- if (r > 1) {
424
- let e = Math.round(o / r), t = Math.round(s / r);
425
- a = await this._ssaaDownscale(a, e, t), o = e, s = t;
730
+ size: (t.size ?? Q) * r,
731
+ showDimensions: t.showDimensions ?? !1,
732
+ preferRawPixels: !0,
733
+ rawPixelsScale: 1 / r
734
+ }, a = await n.prepareTopImage(i), o = await this._resolveTopImage(a, r);
735
+ return await this._writeDataUrlToFile(o.dataUrl, e), o;
736
+ }
737
+ async _resolveTopImage(e, t) {
738
+ if (e.pixels) {
739
+ let n = e.pixels.width < e.width, r = n ? e.pixels.width : Math.round(e.pixels.width / t), i = n ? e.pixels.height : Math.round(e.pixels.height / t);
740
+ return {
741
+ dataUrl: await this._rawPixelsToPngDataUrl(e.pixels, r, i),
742
+ width: r,
743
+ height: i
744
+ };
426
745
  }
427
- if (e) {
428
- let t = await import("fs"), n = a.replace(/^data:image\/\w+;base64,/, "");
429
- t.writeFileSync(e, Buffer.from(n, "base64"));
746
+ if (t > 1) {
747
+ let n = Math.round(e.width / t), r = Math.round(e.height / t);
748
+ return {
749
+ dataUrl: await this._ssaaDownscale(e.image, n, r),
750
+ width: n,
751
+ height: r
752
+ };
430
753
  }
431
754
  return {
432
- dataUrl: a,
433
- width: o,
434
- height: s
755
+ dataUrl: e.image,
756
+ width: e.width,
757
+ height: e.height
758
+ };
759
+ }
760
+ _getRenderDimensions(e) {
761
+ let t = e.ssaa ?? (e.pathTracer ? 1 : 2), n = e.width ?? e.size ?? Q, r = e.height ?? e.size ?? Q;
762
+ return {
763
+ ssaa: t,
764
+ targetWidth: n,
765
+ targetHeight: r,
766
+ renderWidth: n * t,
767
+ renderHeight: r * t
435
768
  };
436
769
  }
770
+ async _resolveImageDataUrl(e, t, n, r) {
771
+ return e.pixels ? this._rawPixelsToPngDataUrl(e.pixels, t, n) : r > 1 ? this._ssaaDownscale(e.image, t, n) : e.image;
772
+ }
773
+ async _writeDataUrlToFile(e, t) {
774
+ if (!t) return;
775
+ let n = await import("fs"), r = e.replace(/^data:image\/\w+;base64,/, "");
776
+ n.writeFileSync(t, Buffer.from(r, "base64"));
777
+ }
778
+ async _rawPixelsToPngDataUrl(e, t, n) {
779
+ let { createCanvas: r, ImageData: i } = await import("@napi-rs/canvas"), a = r(e.width, e.height);
780
+ if (a.getContext("2d").putImageData(new i(new Uint8ClampedArray(e.data.buffer, e.data.byteOffset, e.data.byteLength), e.width, e.height), 0, 0), t === e.width && n === e.height) return a.toDataURLAsync("image/png");
781
+ let o = r(t, n), s = o.getContext("2d");
782
+ return s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high", s.drawImage(a, 0, 0, t, n), o.toDataURLAsync("image/png");
783
+ }
437
784
  async _ssaaDownscale(e, t, n) {
438
785
  let { createCanvas: r, loadImage: i } = await import("@napi-rs/canvas"), a = await i(Buffer.from(e.replace(/^data:image\/\w+;base64,/, ""), "base64")), o = r(t, n), s = o.getContext("2d");
439
- return s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high", s.drawImage(a, 0, 0, t, n), o.toDataURL("image/png");
786
+ return s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high", s.drawImage(a, 0, 0, t, n), o.toDataURLAsync("image/png");
440
787
  }
441
788
  getConfiguratorApi() {
442
789
  return this._configurator;
@@ -450,8 +797,10 @@ var Y = J(import.meta.url), X = {}, Z = [
450
797
  _ensureInitialized() {
451
798
  if (!this._initialized) throw Error("HeadlessRoomleSdk not initialized. Call HeadlessRoomleSdk.create() first.");
452
799
  }
453
- };
800
+ }, $ = () => globalThis.__RML__DI__?.lookup("model-export-state"), Le = (e) => {
801
+ $()?.setModelExportOngoing(e);
802
+ }, Re = () => $()?.isModelExportOngoing() ?? !1;
454
803
  //#endregion
455
- export { o as CONFIGURATION_TYPE, s as CORE_EDGE_TYPE, c as CORE_OBJECT_CATEGORY, a as CORE_PERMISSION_TO_DELETE, U as Configurator, C as ConfiguratorUiCallbacks, _ as FloorPlanElementViewModel, K as GlbViewer, h as GlobalCallback, d as HI_CONTEXT_ACTION, le as HeadlessRoomleSdk, R as IdbManager, M as Main, b as MeasurementLinePlanElementViewModel, z as PLAN_ELEMENT_CHANGE_TYPES, m as PlanElementViewModel, f as PlanObjectViewModel, W as Planner, P as RapiAccess, te as RapiInvalidIdError, E as RapiOfflineError, q as RoomDesignerApi, A as RoomleConfigurator, G as RoomleGLBViewer, F as RoomleLightSource, T as RoomlePlanner, V as RoomlePlannerUiCallback, j as RoomleSdk, y as StaticPlanObjectViewModel, v as WallPlanElementViewModel, ee as createExtObj, g as createExtObjId, D as getCatalogIdFromConfigurationHash, x as isExtObjId, S as isExternalObject, w as isFirefox, i as isIdAComponent, n as isIdAConfigurationString, r as isIdAPlan, t as isIdAnItem, e as isPlanSnapshotId, B as isSafari, p as removeExtObjIdPrefix };
804
+ export { o as CONFIGURATION_TYPE, s as CORE_EDGE_TYPE, c as CORE_OBJECT_CATEGORY, a as CORE_PERMISSION_TO_DELETE, z as Configurator, T as ConfiguratorUiCallbacks, h as FloorPlanElementViewModel, he as GlbViewer, ae as GlobalCallback, le as HI_CONTEXT_ACTION, Ie as HeadlessRoomleSdk, C as IdbManager, D as Main, m as MeasurementLinePlanElementViewModel, se as PLAN_ELEMENT_CHANGE_TYPES, f as PlanElementViewModel, I as PlanObjectViewModel, B as Planner, y as RapiAccess, x as RapiInvalidIdError, A as RapiOfflineError, ge as RoomDesignerApi, re as RoomleConfigurator, me as RoomleGLBViewer, P as RoomleLightSource, b as RoomlePlanner, p as RoomlePlannerUiCallback, k as RoomleSdk, oe as StaticPlanObjectViewModel, ne as WallPlanElementViewModel, te as createExtObj, ue as createExtObjId, S as getCatalogIdFromConfigurationHash, _e as getHeadlessWebGpuMaxTextureDimension, j as isExtObjId, ee as isExternalObject, F as isFirefox, i as isIdAComponent, n as isIdAConfigurationString, r as isIdAPlan, t as isIdAnItem, Re as isModelExportOngoing, e as isPlanSnapshotId, ce as isSafari, de as removeExtObjIdPrefix, Le as setModelExportOngoing, Ee as setPathTracerExternalDenoiser, Ae as setPathTracerPreviewHook, ke as setPathTracerProgressHook };
456
805
 
457
806
  //# sourceMappingURL=roomle-headless.js.map