@roomle/web-sdk 4.2.0 → 4.3.0-alpha.2

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 (92) hide show
  1. package/lib/ConfiguratorKernel.wasm +0 -0
  2. package/lib/{GaussianBlurNode-DEczNsyD.mjs → GaussianBlurNode-Bjszve7N.mjs} +15 -15
  3. package/lib/{GaussianBlurNode-DEczNsyD.mjs.map → GaussianBlurNode-Bjszve7N.mjs.map} +1 -1
  4. package/lib/RoomleCore.js +3 -3
  5. package/lib/RoomleCore.wasm +0 -0
  6. package/lib/RoomleToolsCore.wasm +0 -0
  7. package/lib/{api-B6sLiuiL.mjs → api-C430uhWG.mjs} +2 -2
  8. package/lib/{api-B6sLiuiL.mjs.map → api-C430uhWG.mjs.map} +1 -1
  9. package/lib/asset-loader.worker-eqHzNAwa.mjs.map +1 -1
  10. package/lib/{banana-for-scale-C-grIlTK.mjs → banana-for-scale-DGYmxeBG.mjs} +3 -3
  11. package/lib/{banana-for-scale-C-grIlTK.mjs.map → banana-for-scale-DGYmxeBG.mjs.map} +1 -1
  12. package/lib/budgeteer.sw-BUMElkO1.mjs.map +1 -1
  13. package/lib/{common-utils-6T8eGlhX.mjs → common-utils-CyQUubmw.mjs} +29 -15
  14. package/lib/{common-utils-6T8eGlhX.mjs.map → common-utils-CyQUubmw.mjs.map} +1 -1
  15. package/lib/{component-dimensioning-DJuokZnv.mjs → component-dimensioning-BXN285kw.mjs} +4 -4
  16. package/lib/{component-dimensioning-DJuokZnv.mjs.map → component-dimensioning-BXN285kw.mjs.map} +1 -1
  17. package/lib/{component-raycast-helper-SZg14d7A.mjs → component-raycast-helper-CADFRMLS.mjs} +3 -3
  18. package/lib/{component-raycast-helper-SZg14d7A.mjs.map → component-raycast-helper-CADFRMLS.mjs.map} +1 -1
  19. package/lib/configurator-9ICb3RBz.mjs +2 -0
  20. package/lib/{configurator-Cbof6AET.mjs → configurator-CUiTTJmW.mjs} +4 -4
  21. package/lib/{configurator-Cbof6AET.mjs.map → configurator-CUiTTJmW.mjs.map} +1 -1
  22. package/lib/{decorate-CX1ZGuFY.mjs → decorate-CjaqqbUP.mjs} +12 -9
  23. package/lib/decorate-CjaqqbUP.mjs.map +1 -0
  24. package/lib/dimensioning-helper-0s61LK9R.mjs +2 -0
  25. package/lib/{dimensioning-helper-BwvR76_I.mjs → dimensioning-helper-Cgao7A18.mjs} +2 -2
  26. package/lib/{dimensioning-helper-BwvR76_I.mjs.map → dimensioning-helper-Cgao7A18.mjs.map} +1 -1
  27. package/lib/{glb-viewer-DmVh1uJg.mjs → glb-viewer-DB5c3Qk5.mjs} +6 -6
  28. package/lib/{glb-viewer-DmVh1uJg.mjs.map → glb-viewer-DB5c3Qk5.mjs.map} +1 -1
  29. package/lib/glb-viewer-_gIYHXT9.mjs +2 -0
  30. package/lib/{highlight-coordinator-Qonmfsu1.mjs → highlight-coordinator-RCfVwPHC.mjs} +2 -2
  31. package/lib/{highlight-coordinator-Qonmfsu1.mjs.map → highlight-coordinator-RCfVwPHC.mjs.map} +1 -1
  32. package/lib/{homag-intelligence-CzD_RMQo.mjs → homag-intelligence-8eBT714O.mjs} +8 -5
  33. package/lib/{homag-intelligence-CzD_RMQo.mjs.map → homag-intelligence-8eBT714O.mjs.map} +1 -1
  34. package/lib/{imos-ix-poc-export-helper-Q6-OXziY.mjs → imos-ix-poc-export-helper-DRQK_p2h.mjs} +2 -2
  35. package/lib/{imos-ix-poc-export-helper-Q6-OXziY.mjs.map → imos-ix-poc-export-helper-DRQK_p2h.mjs.map} +1 -1
  36. package/lib/{material-viewer-BkSh-aG7.mjs → material-viewer-CfZwcbei.mjs} +6 -6
  37. package/lib/{material-viewer-BkSh-aG7.mjs.map → material-viewer-CfZwcbei.mjs.map} +1 -1
  38. package/lib/{packages-BGVMQMZK.mjs → packages-0GadOkxt.mjs} +5 -5
  39. package/lib/{packages-BGVMQMZK.mjs.map → packages-0GadOkxt.mjs.map} +1 -1
  40. package/lib/{planner-DFa8uJOF.mjs → planner-CyQKj8Ok.mjs} +3 -3
  41. package/lib/{planner-DFa8uJOF.mjs.map → planner-CyQKj8Ok.mjs.map} +1 -1
  42. package/lib/planner-D63FNjtX.mjs +2 -0
  43. package/lib/{plugin-system-CqXT37-v.mjs → plugin-system-vlnG8j2T.mjs} +3 -3
  44. package/lib/{plugin-system-CqXT37-v.mjs.map → plugin-system-vlnG8j2T.mjs.map} +1 -1
  45. package/lib/{roomle-headless-setup-7xnQlZl3.mjs → roomle-headless-setup-DbO_rLjK.mjs} +54 -40
  46. package/lib/roomle-headless-setup-DbO_rLjK.mjs.map +1 -0
  47. package/lib/roomle-headless.d.ts +167 -126
  48. package/lib/roomle-headless.js +289 -358
  49. package/lib/roomle-headless.js.map +1 -1
  50. package/lib/roomle-renderer-FUqNfNIf.mjs.map +1 -1
  51. package/lib/{roomle-sdk-B73VmWod.mjs → roomle-sdk-CpgzRTKP.mjs} +2855 -2713
  52. package/lib/roomle-sdk-CpgzRTKP.mjs.map +1 -0
  53. package/lib/roomle-sdk.d.ts +121 -15
  54. package/lib/roomle-sdk.js +7 -7
  55. package/lib/{roomle-webgpu-renderer-Dzuy_Y39.mjs → roomle-webgpu-renderer-Lt55gNj5.mjs} +370 -303
  56. package/lib/roomle-webgpu-renderer-Lt55gNj5.mjs.map +1 -0
  57. package/lib/{scene-renderer-DR7EFd-8.mjs → scene-renderer-CSBoi_8w.mjs} +5 -5
  58. package/lib/{scene-renderer-DR7EFd-8.mjs.map → scene-renderer-CSBoi_8w.mjs.map} +1 -1
  59. package/lib/{script-loader-BlsGBrYo.mjs → script-loader-BmScoq7Y.mjs} +3 -3
  60. package/lib/{script-loader-BlsGBrYo.mjs.map → script-loader-BmScoq7Y.mjs.map} +1 -1
  61. package/lib/{shading-settings-Bnt9v9xJ.mjs → shading-settings-CRNmMpcn.mjs} +2 -2
  62. package/lib/{shading-settings-Bnt9v9xJ.mjs.map → shading-settings-CRNmMpcn.mjs.map} +1 -1
  63. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  64. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts +34 -8
  65. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js +5 -1
  66. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +1 -1
  67. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  68. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.js +3 -3
  69. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  70. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  71. package/lib/{stats-helper-vEwFkDIt.mjs → stats-helper-P4jYV8as.mjs} +3 -3
  72. package/lib/{stats-helper-vEwFkDIt.mjs.map → stats-helper-P4jYV8as.mjs.map} +1 -1
  73. package/lib/three.tsl-BnL9nfJa.mjs +2 -0
  74. package/lib/{three.tsl-BElp7_oF.mjs → three.tsl-Dew9p5yF.mjs} +46 -48
  75. package/lib/{three.tsl-BElp7_oF.mjs.map → three.tsl-Dew9p5yF.mjs.map} +1 -1
  76. package/lib/{threejs-utils-C9zED_Tu.mjs → threejs-utils-DKJ0uer7.mjs} +92 -88
  77. package/lib/threejs-utils-DKJ0uer7.mjs.map +1 -0
  78. package/lib/{tools-core-DKYMilYC.mjs → tools-core-CAEfSB8I.mjs} +3 -3
  79. package/lib/{tools-core-DKYMilYC.mjs.map → tools-core-CAEfSB8I.mjs.map} +1 -1
  80. package/lib/{webgpu-BMwlJflc.mjs → webgpu-B0rxiqW-.mjs} +313 -313
  81. package/lib/{webgpu-BMwlJflc.mjs.map → webgpu-B0rxiqW-.mjs.map} +1 -1
  82. package/package.json +2 -2
  83. package/lib/configurator-BFd5022u.mjs +0 -2
  84. package/lib/decorate-CX1ZGuFY.mjs.map +0 -1
  85. package/lib/dimensioning-helper-yMfkA1IY.mjs +0 -2
  86. package/lib/glb-viewer-DlH5_aTU.mjs +0 -2
  87. package/lib/planner-CSKuhBke.mjs +0 -2
  88. package/lib/roomle-headless-setup-7xnQlZl3.mjs.map +0 -1
  89. package/lib/roomle-sdk-B73VmWod.mjs.map +0 -1
  90. package/lib/roomle-webgpu-renderer-Dzuy_Y39.mjs.map +0 -1
  91. package/lib/three.tsl-BtDRDR0q.mjs +0 -2
  92. package/lib/threejs-utils-C9zED_Tu.mjs.map +0 -1
@@ -1,18 +1,35 @@
1
- import { a as e, i as t, n, r, t as i } from "./packages-BGVMQMZK.mjs";
1
+ import { a as e, i as t, n, r, t as i } from "./packages-0GadOkxt.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-C9zED_Tu.mjs";
3
+ import { mt as s, vt as c } from "./threejs-utils-DKJ0uer7.mjs";
4
4
  import { Si as l, m as u, nt as d } from "./three.core-0KaTx8dm.mjs";
5
- import { A as f, F as p, G as m, J as h, K as ee, M as te, N as ne, P as re, S as ie, W as ae, a as oe, at as se, b as ce, ct as le, dt as ue, i as de, j as fe, k as pe, l as g, lt as _, m as v, mt as y, o as b, ot as x, q as S, r as C, s as w, st as T, t as E, u as D, ut as O, x as k, y as A, z as j } from "./roomle-sdk-B73VmWod.mjs";
6
- import { n as M } from "./roomle-renderer-FUqNfNIf.mjs";
7
- import { n as N } from "./script-loader-BlsGBrYo.mjs";
8
- import { t as P } from "./configurator-Cbof6AET.mjs";
9
- import { t as F } from "./planner-DFa8uJOF.mjs";
10
- import { n as I, t as L } from "./glb-viewer-DmVh1uJg.mjs";
11
- import { t as R } from "./api-B6sLiuiL.mjs";
12
- import { t as z } from "./roomle-headless-setup-7xnQlZl3.mjs";
13
- import { createRequire as B } from "module";
14
- //#region packages/headless-core/src/headless-script-loader.ts
15
- var me = B(import.meta.url), V = {}, H = [
5
+ import { i as f } from "./decorate-CjaqqbUP.mjs";
6
+ import { V as p } from "./common-utils-CyQUubmw.mjs";
7
+ import { A as m, F as h, G as ee, J as te, K as ne, M as re, N as ie, P as ae, S as oe, V as se, W as ce, a as g, at as le, b as ue, ct as de, dt as fe, i as pe, j as me, k as he, l as ge, lt as _e, m as ve, mt as ye, o as _, ot as v, q as y, r as b, s as x, st as S, t as C, u as w, ut as T, x as E, y as D, z as O } from "./roomle-sdk-CpgzRTKP.mjs";
8
+ import { n as k } from "./roomle-renderer-FUqNfNIf.mjs";
9
+ import { n as A } from "./script-loader-BmScoq7Y.mjs";
10
+ import { t as j } from "./configurator-CUiTTJmW.mjs";
11
+ import { t as M } from "./planner-CyQKj8Ok.mjs";
12
+ import { n as N, t as P } from "./glb-viewer-DB5c3Qk5.mjs";
13
+ import { t as be } from "./api-C430uhWG.mjs";
14
+ import { t as xe } from "./roomle-headless-setup-DbO_rLjK.mjs";
15
+ import { createRequire as Se } from "module";
16
+ //#region packages/headless-core/src/headless-tween-stub.ts
17
+ var Ce = {
18
+ add(e) {
19
+ try {
20
+ e.end?.();
21
+ } catch {}
22
+ },
23
+ remove() {},
24
+ removeAll() {},
25
+ getAll() {
26
+ return [];
27
+ },
28
+ update() {}
29
+ }, we = () => {
30
+ let e = window;
31
+ e.TWEEN = Ce;
32
+ }, Te = Se(import.meta.url), F = {}, I = [
16
33
  [
17
34
  "ConfiguratorKernel.wasm",
18
35
  "ConfiguratorKernel",
@@ -28,48 +45,48 @@ var me = B(import.meta.url), V = {}, H = [
28
45
  "RoomleToolsCore",
29
46
  "roomle-core-hsc/wasm_modern/RoomleToolsCore.js"
30
47
  ]
31
- ], he = class {
48
+ ], L = class {
32
49
  constructor(e) {
33
50
  this._creator_ = e;
34
51
  }
35
52
  async fetch(e, t) {
36
- if (V[t.id]) return;
53
+ if (F[t.id]) return;
37
54
  if (typeof e == "function") {
38
- this._registerFactory(e), V[t.id] = !0;
55
+ this._registerFactory(e), F[t.id] = !0;
39
56
  return;
40
57
  }
41
58
  let n = this._resolveEntry(e);
42
59
  if (n) {
43
- let [, r, i] = n, a = me(e.startsWith("/") ? e : i);
44
- globalThis[r] = a.default || a, V[t.id] = !0;
60
+ let [, r, i] = n, a = Te(e.startsWith("/") ? e : i);
61
+ globalThis[r] = a.default || a, F[t.id] = !0;
45
62
  }
46
63
  }
47
64
  _registerFactory(e) {
48
65
  let t = e.toString();
49
- for (let [n, r] of H) if (t.includes(n)) {
66
+ for (let [n, r] of I) if (t.includes(n)) {
50
67
  globalThis[r] = e;
51
68
  return;
52
69
  }
53
70
  console.warn("HeadlessScriptLoader: Could not identify Emscripten factory function");
54
71
  }
55
72
  _resolveEntry(e) {
56
- for (let t of H) {
73
+ for (let t of I) {
57
74
  let [n, r] = t, i = r;
58
75
  if (e.includes(i) || e.includes(n)) return t;
59
76
  }
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);
77
+ return e.includes("configurator") ? I[0] : e.includes("planner") ? I[1] : e.includes("tools") ? I[2] : (console.warn(`HeadlessScriptLoader: Could not resolve module for URL: ${e}`), null);
61
78
  }
62
79
  loadScripts(e) {
63
80
  let t = e.map((e) => this.fetch(e.name, { id: e.id }));
64
81
  return Promise.all(t);
65
82
  }
66
83
  resolveKernelPaths(e) {
67
- return N(e);
84
+ return A(e);
68
85
  }
69
86
  cleanUp() {
70
- V = {};
87
+ F = {};
71
88
  }
72
- }, ge = class {
89
+ }, Ee = class {
73
90
  get _lifeCycleManager() {
74
91
  return globalThis.__RML__DI__?.lookup("life-cycle-manager", this._creator_);
75
92
  }
@@ -135,7 +152,7 @@ var me = B(import.meta.url), V = {}, H = [
135
152
  pause() {}
136
153
  resume() {}
137
154
  destroy() {}
138
- }, _e = class {
155
+ }, De = class {
139
156
  constructor(e) {
140
157
  this._creator_ = e;
141
158
  }
@@ -163,11 +180,15 @@ var me = B(import.meta.url), V = {}, H = [
163
180
  }
164
181
  setAlwaysUseCache(e) {}
165
182
  preFillAssetCache(e, t) {}
166
- }, ve = class extends g {
183
+ }, Oe = class extends ge {
167
184
  _getScriptLoaderKernelId(e) {
168
- return e === f.PLANNER ? "kernel-planner" : "kernel";
185
+ return e === m.PLANNER ? "kernel-planner" : "kernel";
169
186
  }
170
- }, ye = class {
187
+ useEnvironmentGeometry(e) {
188
+ if (!this._kernelInstance) throw Error("trying to set useEnvironmentGeometry but there is no kernel instance yet!");
189
+ this._kernelInstance.useEnvironmentGeometry(e);
190
+ }
191
+ }, ke = class {
171
192
  wrap(e) {
172
193
  return new Proxy(e, { get(e, t) {
173
194
  let n = e[t];
@@ -180,33 +201,33 @@ var me = B(import.meta.url), V = {}, H = [
180
201
  } : n;
181
202
  } });
182
203
  }
183
- }, be = class extends de {
204
+ }, Ae = class extends pe {
184
205
  async addReflectiveFloor(e) {}
185
- }, U = null;
186
- function xe(e) {
187
- U = e;
206
+ }, R = null;
207
+ function je(e) {
208
+ R = e;
188
209
  }
189
- var W = null, Se = 256 * 1024 * 1024, Ce = 1, G = 500, K = 512;
190
- function q(e) {
191
- return Math.max(1, Math.floor(Se * .95 / e));
210
+ var z = null, Me = 256 * 1024 * 1024, Ne = 1, B = 500, V = 512;
211
+ function H(e) {
212
+ return Math.max(1, Math.floor(Me * .95 / e));
192
213
  }
193
- var we = (e) => {
194
- W = e;
195
- }, J = null, Y = {
196
- minIntervalMs: G,
197
- maxSize: K
198
- }, Te = (e, t) => {
199
- J = e, Y = {
200
- minIntervalMs: t?.minIntervalMs ?? G,
201
- maxSize: t?.maxSize ?? K
214
+ var Pe = (e) => {
215
+ z = e;
216
+ }, U = null, W = {
217
+ minIntervalMs: B,
218
+ maxSize: V
219
+ }, Fe = (e, t) => {
220
+ U = e, W = {
221
+ minIntervalMs: t?.minIntervalMs ?? B,
222
+ maxSize: t?.maxSize ?? V
202
223
  };
203
- }, Ee = class {
224
+ }, Ie = class {
204
225
  constructor() {
205
226
  this._pathTracer = null, this._renderer = null;
206
227
  }
207
228
  async render(e, t, n, r = 10, i = {}) {
208
229
  let a = await this._getPathTracer(e);
209
- i.bounces !== void 0 && (a.bounces = i.bounces), a.renderScale = i.renderScale ?? Ce;
230
+ i.bounces !== void 0 && (a.bounces = i.bounces), a.renderScale = i.renderScale ?? Ne;
210
231
  let o = this._applyScenePatches(t), s = {
211
232
  autoClear: e.autoClear,
212
233
  toneMapping: e.toneMapping,
@@ -216,7 +237,7 @@ var we = (e) => {
216
237
  try {
217
238
  a.setScene(t, n), a.reset();
218
239
  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));
240
+ for (; a.samples < o;) a.renderSample(), z?.(a.samples, o), U && a.samples >= 2 && performance.now() - s >= W.minIntervalMs && (await this._emitPreview(e, a.samples, o), s = performance.now()), await new Promise((e) => setTimeout(e, 0));
220
241
  a.renderSample(), i.denoise && await this._denoiseAndBlit(e, a);
221
242
  } finally {
222
243
  this._undoScenePatches(o), e.autoClear = s.autoClear, e.toneMapping = s.toneMapping, e.toneMappingExposure = s.toneMappingExposure, e.outputColorSpace = s.outputColorSpace;
@@ -275,12 +296,12 @@ var we = (e) => {
275
296
  try {
276
297
  let r = e.domElement, i = r.getContext?.("webgpu");
277
298
  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);
299
+ let a = Math.min(1, W.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
300
  if (!c) return;
280
301
  let { createCanvas: l, ImageData: u } = await import("@napi-rs/canvas"), d = l(c.width, c.height);
281
302
  d.getContext("2d").putImageData(new u(new Uint8ClampedArray(c.data.buffer, c.data.byteOffset, c.data.byteLength), c.width, c.height), 0, 0);
282
303
  let f = await d.encode("png");
283
- J?.({
304
+ U?.({
284
305
  png: new Uint8Array(f.buffer, f.byteOffset, f.byteLength),
285
306
  width: c.width,
286
307
  height: c.height,
@@ -290,7 +311,7 @@ var we = (e) => {
290
311
  } catch {}
291
312
  }
292
313
  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);
314
+ let i = n * 4, a = Math.ceil(n / 16) * 16 * 4, o = H(a * 4), s = new Float32Array(i * r);
294
315
  for (let c = 0; c < r; c += o) {
295
316
  let l = Math.min(o, r - c), u = await e.readRenderTargetPixelsAsync({ textures: [t] }, 0, c, n, l);
296
317
  if (u.length === i * l) s.set(u, c * i);
@@ -299,8 +320,8 @@ var we = (e) => {
299
320
  return s;
300
321
  }
301
322
  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);
323
+ if (!R) throw Error("WebGPUPathTracerRenderer: pathTracerSettings.denoise=true but no external denoiser is registered. Use setPathTracerExternalDenoiser() with Intel OIDN binaries");
324
+ let n = t._pathTracer.outputTarget, { width: r, height: i } = n, a = await this._readHdrTargetTiled(e, n, r, i), o = await R(a, r, i);
304
325
  this._writeDenoisedIntoTarget(e, n, o, r, i);
305
326
  let s = t._blitQuad, c = e.toneMapping, l = e.toneMappingExposure, u = e.autoClear, d = e.getRenderTarget();
306
327
  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);
@@ -308,7 +329,7 @@ var we = (e) => {
308
329
  _writeDenoisedIntoTarget(e, t, n, r, i) {
309
330
  let a = e.backend, o = a?.get?.(t)?.texture, s = a?.device?.queue;
310
331
  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);
332
+ let c = r * 16, l = r * 4, u = H(c);
312
333
  for (let e = 0; e < i; e += u) {
313
334
  let t = Math.min(u, i - e), a = n.subarray(e * l, (e + t) * l);
314
335
  s.writeTexture({
@@ -332,10 +353,10 @@ var we = (e) => {
332
353
  async _getPathTracer(e) {
333
354
  if (this._pathTracer && this._renderer === e) return this._pathTracer;
334
355
  this._pathTracer?.dispose();
335
- let { WebGPUPathTracer: t } = await import("./webgpu-BMwlJflc.mjs"), n = new t(e);
356
+ let { WebGPUPathTracer: t } = await import("./webgpu-B0rxiqW-.mjs"), n = new t(e);
336
357
  return n.useMegakernel(!0), n.dynamicLowRes = !1, n.renderDelay = 0, n.fadeDuration = 0, n.minSamples = 1, this._pathTracer = n, this._renderer = e, n;
337
358
  }
338
- }, De = class e extends v {
359
+ }, Le = class e extends ve {
339
360
  constructor(...e) {
340
361
  super(...e), this._headlessPathTracerRenderer = null;
341
362
  }
@@ -349,7 +370,7 @@ var we = (e) => {
349
370
  }
350
371
  async _createRoomleRenderer(e) {
351
372
  if (!e.isWebGPURenderer) return super._createRoomleRenderer(e);
352
- let { RoomleWebGPURenderer: t } = await import("./roomle-webgpu-renderer-Dzuy_Y39.mjs");
373
+ let { RoomleWebGPURenderer: t } = await import("./roomle-webgpu-renderer-Lt55gNj5.mjs");
353
374
  return new t(this._creator_, e, !0, void 0, !1);
354
375
  }
355
376
  static hasExplicitCameraPlacement(e) {
@@ -377,9 +398,9 @@ var we = (e) => {
377
398
  }) } : super._renderFrame(e, t, n, r);
378
399
  }
379
400
  async _renderPathTracedFrame(e, t, n, r) {
380
- let i = e instanceof M ? e.renderer : e;
401
+ let i = e instanceof k ? e.renderer : e;
381
402
  if (!i.isWebGPURenderer) throw Error("HeadlessImageRenderer: path tracing requires the WebGPU renderer (enable webGpu)");
382
- this._headlessPathTracerRenderer ||= new Ee(), await this._headlessPathTracerRenderer.render(i, t, n, r.samples, r.settings);
403
+ this._headlessPathTracerRenderer ||= new Ie(), await this._headlessPathTracerRenderer.render(i, t, n, r.samples, r.settings);
383
404
  let { imageDataUrl: a } = await this._readFrameAndClear(i);
384
405
  return a;
385
406
  }
@@ -413,22 +434,7 @@ var we = (e) => {
413
434
  let { width: r, height: i } = e.domElement;
414
435
  return t.readbackScaled(Math.max(1, Math.round(r * n)), Math.max(1, Math.round(i * n)));
415
436
  }
416
- }, Oe = {
417
- add(e) {
418
- try {
419
- e.end?.();
420
- } catch {}
421
- },
422
- remove() {},
423
- removeAll() {},
424
- getAll() {
425
- return [];
426
- },
427
- update() {}
428
- }, ke = () => {
429
- let e = window;
430
- e.TWEEN = Oe;
431
- }, X = class extends oe {
437
+ }, G = class extends g {
432
438
  constructor(...e) {
433
439
  super(...e), this._callbacks = /* @__PURE__ */ new Set(), this._dispatcherInstalled = !1;
434
440
  }
@@ -438,223 +444,191 @@ var we = (e) => {
438
444
  }), !0);
439
445
  }
440
446
  static async loadEquirectTexture(e) {
441
- let t = await (e.toLowerCase().endsWith(".exr") ? new w() : new b()).loadAsync(e);
447
+ let t = await (e.toLowerCase().endsWith(".exr") ? new x() : new _()).loadAsync(e);
442
448
  return t.mapping = 303, t;
443
449
  }
444
- }, Z = 1024, Ae = "inline-plan-xml#", je = "inline-configuration#", Q = class e {
445
- constructor() {
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._webGpu = !0, this._loaderQueue = Promise.resolve(), this._skyboxOriginal = /* @__PURE__ */ new WeakMap(), this._onReadyForRenderArmed = null;
450
+ }, Re = (e, t) => {
451
+ let n = new le();
452
+ globalThis.__RML__DI__ = n;
453
+ class r extends Ee {
454
+ constructor(n) {
455
+ super(n, e, t);
456
+ }
457
+ }
458
+ let i = [
459
+ new S("script-loader", L, v.CONTEXT, !0),
460
+ new S("dom-helper", r, v.CONTEXT, !0),
461
+ new S("data-syncer", De, v.GLOBAL, !0),
462
+ new S("planner-kernel-access", Oe, v.GLOBAL, !0),
463
+ new S("kernel-callback-guard", ke, v.GLOBAL, !0),
464
+ new S("web-gpu-ground-shadow-reflection", Ae, v.CONTEXT, !0),
465
+ new S("image-renderer", Le, v.CONTEXT, !0),
466
+ new S("hdr-environment-loader", G, v.GLOBAL, !0)
467
+ ];
468
+ return n.addDependencyInjectionAssignments(b), n.addDependencyInjectionAssignments(i), n;
469
+ }, K = 12e4, ze = async (e, t) => {
470
+ let n = await C.callbacks, r = n?.onReadyForRender, i = n ? new Promise((e) => {
471
+ n.onReadyForRender = () => {
472
+ try {
473
+ r?.();
474
+ } finally {
475
+ n.onReadyForRender = r, e();
476
+ }
477
+ };
478
+ }) : Promise.resolve(), a = e.getSceneManager().whenRenderLoopFunctionApplied();
479
+ await t(e), await Promise.all([p(i, "HeadlessRoomleSdk: onReadyForRender never fired, the scene never finished loading its assets", K), p(a, "HeadlessRoomleSdk: the plan was never added to the scene, the render loop never ran the scheduled scene-graph mutation", K)]);
480
+ }, q = (e) => {
481
+ let t = e.ssaa ?? (e.pathTracer ? 1 : 2), n = e.width ?? e.size ?? 1024, r = e.height ?? e.size ?? 1024;
482
+ return {
483
+ ssaa: t,
484
+ targetWidth: n,
485
+ targetHeight: r,
486
+ renderWidth: n * t,
487
+ renderHeight: r * t
488
+ };
489
+ }, J = async (e, t, n, r) => e.pixels ? X(e.pixels, t, n) : r > 1 ? Z(e.image, t, n) : e.image, Be = async (e, t) => {
490
+ if (e.pixels) {
491
+ 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);
492
+ return {
493
+ dataUrl: await X(e.pixels, r, i),
494
+ width: r,
495
+ height: i
496
+ };
497
+ }
498
+ if (t > 1) {
499
+ let n = Math.round(e.width / t), r = Math.round(e.height / t);
500
+ return {
501
+ dataUrl: await Z(e.image, n, r),
502
+ width: n,
503
+ height: r
504
+ };
447
505
  }
506
+ return {
507
+ dataUrl: e.image,
508
+ width: e.width,
509
+ height: e.height
510
+ };
511
+ }, Y = async (e, t) => {
512
+ if (!t) return;
513
+ let n = await import("fs"), r = e.replace(/^data:image\/\w+;base64,/, "");
514
+ n.writeFileSync(t, Buffer.from(r, "base64"));
515
+ }, X = async (e, t, n) => {
516
+ let { createCanvas: r, ImageData: i } = await import("@napi-rs/canvas"), a = r(e.width, e.height);
517
+ 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");
518
+ let o = r(t, n), s = o.getContext("2d");
519
+ return s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high", s.drawImage(a, 0, 0, t, n), o.toDataURLAsync("image/png");
520
+ }, Z = async (e, t, n) => {
521
+ 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");
522
+ return s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high", s.drawImage(a, 0, 0, t, n), o.toDataURLAsync("image/png");
523
+ }, Ve = 1024, He = 768, Ue = "inline-plan-xml#", We = "inline-configuration#", Q = (e, t) => e && !t, Ge = class e {
448
524
  static async create(t) {
449
- let n = new e();
450
- return await n._init(t), n;
525
+ let n = new e(t);
526
+ return await C.setGlobalInitData({
527
+ configuratorId: t.configuratorId,
528
+ locale: t.locale,
529
+ tenant: t.tenant,
530
+ overrideCountry: t.overrideCountry,
531
+ customApiUrl: t.customApiUrl,
532
+ overrideRapi: t.overrideRapi,
533
+ animateCamera: !1
534
+ }), n;
451
535
  }
452
- async _init(e) {
453
- this._width = e.width ?? 1024, this._height = e.height ?? 768, this._featureFlags = e.featureFlags, !e.webGpu && !e.featureFlags?.webGpu && console.warn("HeadlessRoomleSdk: WebGPU is required, forcing webGpu on."), this._webGpu = !0, this._webGpuConfig = {
536
+ constructor(e) {
537
+ this._plannerMainPromise = null, this._loaderQueue = Promise.resolve(), this._loadedScene = null, this._skyboxOriginal = /* @__PURE__ */ new WeakMap(), this._initData = e, !e.webGpu && !e.featureFlags?.webGpu && console.warn("HeadlessRoomleSdk: WebGPU is required, forcing webGpu on."), this._webGpuConfig = {
454
538
  autoDetectQualityLevel: !1,
455
539
  autoQualityMinFps: 0,
456
540
  autoQualityMaxFps: 2 ** 53 - 1,
457
541
  ...e.webGpuConfig
458
- }, ke(), this._registerHeadlessServices(this._width, this._height), await E.setGlobalInitData({
459
- configuratorId: e.configuratorId,
460
- locale: e.locale,
461
- tenant: e.tenant,
462
- overrideCountry: e.overrideCountry,
463
- customApiUrl: e.customApiUrl,
464
- overrideRapi: e.overrideRapi,
465
- animateCamera: !1
466
- }), this._initialized = !0;
542
+ }, we(), this._container = Re(e.width ?? Ve, e.height ?? He);
467
543
  }
468
- _deepMergeHeadlessInitDefaults(e) {
469
- if (!this._featureFlags && !this._webGpuConfig && !this._webGpu) return e;
470
- let t = e?.featureFlags;
471
- return {
472
- ...e,
473
- webGpu: this._webGpu,
474
- featureFlags: {
475
- ...this._featureFlags,
476
- ...t
477
- },
478
- webGpuConfig: {
479
- ...this._webGpuConfig,
480
- ...e?.webGpuConfig
481
- }
482
- };
544
+ getHeadlessConfigurator() {
545
+ return this._getConfigurator();
483
546
  }
484
- _registerHeadlessServices(e, t) {
485
- let n = new se();
486
- globalThis.__RML__DI__ = n;
487
- class r extends ge {
488
- constructor(n) {
489
- super(n, e, t);
490
- }
491
- }
492
- let i = [
493
- new T("script-loader", he, x.CONTEXT, !0),
494
- new T("dom-helper", r, x.CONTEXT, !0),
495
- new T("data-syncer", _e, x.GLOBAL, !0),
496
- new T("planner-kernel-access", ve, x.GLOBAL, !0),
497
- new T("kernel-callback-guard", ye, x.GLOBAL, !0),
498
- new T("web-gpu-ground-shadow-reflection", be, x.CONTEXT, !0),
499
- new T("image-renderer", De, x.CONTEXT, !0),
500
- new T("hdr-environment-loader", X, x.GLOBAL, !0)
501
- ];
502
- n.addDependencyInjectionAssignments(C), n.addDependencyInjectionAssignments(i);
503
- }
504
- _makeStubElement() {
505
- return {
506
- clientWidth: this._width,
507
- clientHeight: this._height,
508
- appendChild() {},
509
- removeChild() {},
510
- style: {},
511
- classList: { add() {} }
512
- };
547
+ async createHeadlessPlanner() {
548
+ await this._getPlannerMain();
513
549
  }
514
- async prewarmConfigurator(e) {
515
- this._ensureInitialized();
516
- let t = await E.getConfigurator(this._deepMergeHeadlessInitDefaults(e));
517
- await t.boot(), this._configuratorMain = t, this._configurator = t.getApi(), await this._configurator.init(this._makeStubElement()), this._configuratorReady = !0;
550
+ _getPlannerMain() {
551
+ return this._plannerMainPromise ||= this._bootPlanner(), this._plannerMainPromise;
518
552
  }
519
- async prewarmPlanner(e) {
520
- this._ensureInitialized();
521
- let t = await E.getPlanner({
553
+ async _bootPlanner() {
554
+ let { width: e, height: t, ...n } = this._initData;
555
+ if (n.moc === !1) throw Error("HeadlessRoomleSdk: planner requires moc:true");
556
+ let r = await C.getPlanner({
557
+ ...n,
522
558
  moc: !0,
523
- ...this._deepMergeHeadlessInitDefaults(e)
559
+ webGpu: !0,
560
+ featureFlags: { ...n.featureFlags },
561
+ webGpuConfig: this._webGpuConfig
524
562
  });
525
- if (e?.moc === !1) throw Error("HeadlessRoomleSdk: planner requires moc:true");
526
- await t.boot(), this._plannerMain = t, this._planner = t.getApi(), await this._planner.init(this._makeStubElement()), this._plannerReady = !0;
563
+ return await r.boot(), await r.getApi().init({}), r;
527
564
  }
528
- async prewarmGlbViewer(e) {
529
- this._ensureInitialized();
530
- let t = await E.getGlbViewer(this._deepMergeHeadlessInitDefaults(e));
531
- await t.boot(), this._glbViewerMain = t, this._glbViewer = t.getApi(), await this._glbViewer.init(this._makeStubElement()), this._glbViewerReady = !0;
565
+ async _getPlanner() {
566
+ return (await this._getPlannerMain()).getApi();
532
567
  }
533
- async loadConfiguration(e, t) {
534
- return this._loadIntoConfigurator(e, () => this._configurator.loadConfigurationById(e), t);
568
+ async _getConfigurator() {
569
+ return (await this._getPlanner()).getConfiguratorApi();
535
570
  }
536
- async loadConfigurationString(e, t) {
537
- let n = await this._inlineSceneId(je, e);
538
- return this._loadIntoConfigurator(n, () => this._configurator.loadConfiguration(e), t);
571
+ async loadConfiguration(e) {
572
+ return this._loadIntoPlanner(e, (t) => t.createPlanFromObject(e));
539
573
  }
540
- async loadConfigurableItemById(e, t) {
541
- return this._loadIntoConfigurator(e, () => this._configurator.loadConfigurableItemById(e), t);
574
+ async loadConfigurationString(e) {
575
+ let t = We + await f(e);
576
+ return this._loadIntoPlanner(t, (t) => t.createPlanFromConfigurationString(e));
542
577
  }
543
- async _loadIntoConfigurator(e, t, n) {
544
- return this._ensureInitialized(), this._withLoader(async () => {
545
- if (this._configuratorReady || await this.prewarmConfigurator(n), this._loadedConfigurationId === e) return;
546
- let { pka: r, plannerVM: i } = this._plannerReady ? this._getPlannerListenerInfo() : {};
547
- r && i && r.removeConfiguratorListener(i);
548
- try {
549
- await this._armOnReadyForRender(), await t(), this._loadedConfigurationId = e, this._loadedPlanId = null, this._loadedStaticItemId = null, await this._settleScene();
550
- } finally {
551
- r && i && r.addConfiguratorListener(i);
552
- }
553
- });
578
+ async loadConfigurableItemById(e) {
579
+ return this._loadIntoPlanner(e, (t) => t.createPlanFromObject(e));
554
580
  }
555
- async loadStaticItem(e, t) {
556
- return this._ensureInitialized(), this._withLoader(async () => {
557
- this._glbViewerReady || await this.prewarmGlbViewer(t), this._loadedStaticItemId !== e && (await this._armOnReadyForRender(), await this._glbViewer.loadStaticItem(e), this._suppressGlbSelfShadowing(), this._loadedStaticItemId = e, this._loadedConfigurationId = null, this._loadedPlanId = null, await this._settleScene());
558
- });
559
- }
560
- _suppressGlbSelfShadowing() {
561
- let e = this._glbViewer.getSceneManager().getScene();
562
- e && e.traverse((e) => {
563
- e.isMesh && (e.castShadow = !1);
564
- });
581
+ async loadStaticItem(e) {
582
+ return this._loadIntoPlanner(e, (t) => t.createPlanFromObject(e));
565
583
  }
566
- async loadObject(e, a) {
567
- if (this._ensureInitialized(), i(e)) throw Error(`HeadlessRoomleSdk: component ids ("${e}") are not supported. Use loadConfigurableItemById, loadConfiguration, or loadPlan directly.`);
568
- return n(e) ? this.loadConfigurationString(e, a) : r(e) ? this.loadPlan(e, a) : t(e) ? (await (await E.getRapiAccess()).getItem(e))?.configuration ? this.loadConfigurableItemById(e, a) : this.loadStaticItem(e, a) : this.loadConfiguration(e, a);
584
+ async loadObject(e) {
585
+ if (i(e)) throw Error(`HeadlessRoomleSdk: component ids ("${e}") are not supported. Use loadConfigurableItemById, loadConfiguration, or loadPlan directly.`);
586
+ return n(e) ? this.loadConfigurationString(e) : r(e) ? this.loadPlan(e) : this.loadConfiguration(e);
569
587
  }
570
- async loadPlan(e, t) {
571
- return this._ensureInitialized(), this._loadIntoPlanner(e, () => this._planner.loadPlan(e), t);
588
+ async loadPlan(e) {
589
+ return this._loadIntoPlanner(e, (t) => t.loadPlan(e), !0);
572
590
  }
573
- async loadPlanXml(e, t) {
574
- this._ensureInitialized();
575
- let n = await this._inlineSceneId(Ae, e);
576
- return this._loadIntoPlanner(n, () => this._planner.loadPlanXml(e), t);
591
+ async loadPlanXml(e) {
592
+ let t = Ue + await f(e);
593
+ return this._loadIntoPlanner(t, (t) => t.loadPlanXml(e), !0);
577
594
  }
578
- async _loadIntoPlanner(e, t, n) {
579
- return this._withLoader(async () => {
580
- if (this._plannerReady || await this.prewarmPlanner(n), this._loadedPlanId === e) return;
581
- let { pka: r, configuratorVM: i } = this._configuratorReady ? this._getConfiguratorListenerInfo() : {};
582
- r && i && r.removeConfiguratorListener(i);
583
- try {
584
- await this._armOnReadyForRender(), await t(), this._loadedPlanId = e, this._loadedConfigurationId = null, this._loadedStaticItemId = null, await this._settleScene();
585
- } finally {
586
- r && i && r.addConfiguratorListener(i);
587
- }
588
- });
595
+ _loadIntoPlanner(e, t, n = !1) {
596
+ return this._withLoader(() => this._load(e, t, n, this._loadedScene?.environmentGeometry ?? !1));
589
597
  }
590
- async _inlineSceneId(e, t) {
591
- let n = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
592
- return e + Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("").slice(0, 32);
598
+ async _load(e, t, n, r) {
599
+ let i = await this._getPlanner();
600
+ if (i.getConfiguratorContext().baseContext = se.PLANNER, this._loadedScene?.identity === e) return;
601
+ this._loadedScene = null;
602
+ let a = Q(r, n);
603
+ this._useEnvironmentGeometry(a), await ze(i, t), this._loadedScene = {
604
+ identity: e,
605
+ isPlan: n,
606
+ environmentGeometry: a,
607
+ planner: i,
608
+ reload: (r) => (this._loadedScene = null, this._load(e, t, n, r))
609
+ };
593
610
  }
594
611
  _withLoader(e) {
595
612
  let t = this._loaderQueue.then(e);
596
613
  return this._loaderQueue = t.then(() => {}, () => {}), t;
597
614
  }
598
- async _settleScene() {
599
- this._onReadyForRenderArmed &&= (await this._onReadyForRenderArmed, null);
600
- }
601
- async _armOnReadyForRender() {
602
- let e = await E.callbacks;
603
- if (!e) {
604
- this._onReadyForRenderArmed = null;
605
- return;
606
- }
607
- let t = e.onReadyForRender;
608
- this._onReadyForRenderArmed = new Promise((n) => {
609
- e.onReadyForRender = () => {
610
- try {
611
- t?.();
612
- } finally {
613
- e.onReadyForRender = t, n();
614
- }
615
- };
616
- });
617
- }
618
- _getPlannerListenerInfo() {
619
- try {
620
- return {
621
- pka: globalThis.__RML__DI__?.lookup?.("planner-kernel-access"),
622
- plannerVM: this._planner?.getSceneManager()?.viewModel
623
- };
624
- } catch {
625
- return {};
626
- }
627
- }
628
- _getConfiguratorListenerInfo() {
629
- try {
630
- return {
631
- pka: globalThis.__RML__DI__?.lookup?.("planner-kernel-access"),
632
- configuratorVM: this._configurator?.getSceneManager()?.viewModel
633
- };
634
- } catch {
635
- return {};
636
- }
637
- }
638
615
  async exportGLB(e) {
639
616
  return this._export(e, "glb");
640
617
  }
641
618
  async exportUSDZ(e) {
642
619
  return this._export(e, "usdz");
643
620
  }
644
- _getActiveApi() {
645
- if (this._loadedPlanId) return this._planner;
646
- if (this._loadedConfigurationId) return this._configurator;
647
- if (this._loadedStaticItemId) return this._glbViewer;
648
- throw Error("HeadlessRoomleSdk: nothing loaded — call loadPlan(), loadConfiguration(), loadConfigurableItemById(), loadStaticItem() or loadObject() first");
621
+ _requireLoadedScene() {
622
+ if (!this._loadedScene) throw Error("HeadlessRoomleSdk: nothing loaded, call loadPlan(), loadPlanXml(), loadConfiguration(), loadConfigurationString(), loadConfigurableItemById(), loadStaticItem() or loadObject() first");
623
+ return this._loadedScene;
649
624
  }
650
625
  _getActiveSceneManager() {
651
- return this._loadedStaticItemId ? this._glbViewer.getSceneManager() : this._getActiveApi().getSceneManager();
626
+ return this._requireLoadedScene().planner.getSceneManager();
652
627
  }
653
628
  async setEnvironmentMap(e, t = {}) {
654
- this._ensureInitialized(), await this._getEnvironmentSceneManager().loadEnvMap(e), this.setEnvironmentMapOptions(t);
629
+ await this._getEnvironmentSceneManager().loadEnvMap(e), this.setEnvironmentMapOptions(t);
655
630
  }
656
631
  async resetEnvironmentMap(e = {}) {
657
- this._ensureInitialized();
658
632
  let t = this._getEnvironmentSceneManager();
659
633
  await t.loadEnvMap(t.initData?.envMapUrl ?? "" + new URL("default_256.exr", import.meta.url).href), this.setEnvironmentMapOptions(e);
660
634
  }
@@ -667,138 +641,95 @@ var we = (e) => {
667
641
  return e;
668
642
  }
669
643
  async setSkybox(e) {
670
- this._ensureInitialized();
671
644
  let t = this._getActiveSceneManager().getScene();
672
645
  this._skyboxOriginal.has(t) || this._skyboxOriginal.set(t, {
673
646
  background: t.background,
674
647
  showEnvironmentBackground: t.userData.showEnvironmentBackground
675
- }), t.background = await X.loadEquirectTexture(e), t.userData.showEnvironmentBackground = !1;
648
+ }), t.background = await G.loadEquirectTexture(e), t.userData.showEnvironmentBackground = !1;
676
649
  }
677
650
  resetSkybox() {
678
- this._ensureInitialized();
679
651
  let e = this._getActiveSceneManager().getScene(), t = this._skyboxOriginal.get(e);
680
652
  t && (e.background = t.background, e.userData.showEnvironmentBackground = t.showEnvironmentBackground, this._skyboxOriginal.delete(e));
681
653
  }
682
- async _export(e, t) {
683
- this._ensureInitialized();
684
- let n = this._getActiveSceneManager(), r = t === "glb" ? await n.createExportGLB() : await n.createUSDZExport();
685
- if (!r) throw Error(`${t.toUpperCase()} export produced no data`);
686
- let i = r instanceof ArrayBuffer ? r : r.buffer;
687
- return e && (await import("fs")).writeFileSync(e, Buffer.from(i)), { buffer: i };
688
- }
689
- async exportScreenshot(e, t = {}) {
690
- this._ensureInitialized();
691
- let { ssaa: n, targetWidth: r, targetHeight: i, renderWidth: a, renderHeight: o } = this._getRenderDimensions(t), s = {
692
- rotationY: t.rotationY,
693
- cameraPosition: t.cameraPosition,
694
- cameraPitch: t.cameraPitch,
695
- cameraYaw: t.cameraYaw,
696
- fov: t.fov,
697
- showWallsAndCeiling: t.showWallsAndCeiling,
698
- width: a,
699
- height: o,
700
- preserveSceneBackground: !0,
701
- pathTracer: t.pathTracer,
702
- pathTracerSamples: t.pathTracerSamples,
703
- pathTracerSettings: t.pathTracerSettings,
704
- preferRawPixels: !0,
705
- rawPixelsScale: 1 / n
706
- }, c = await this._getActiveApi().preparePerspectiveImage(s), l = await this._resolveImageDataUrl(c, r, i, n);
707
- return await this._writeDataUrlToFile(l, e), { dataUrl: l };
708
- }
709
- async exportPerspectiveImage(e, t = {}) {
710
- this._ensureInitialized();
711
- let { ssaa: n, targetWidth: r, targetHeight: i, renderWidth: a, renderHeight: o } = this._getRenderDimensions(t), s = {
712
- ...t,
713
- width: a,
714
- height: o,
715
- preferRawPixels: !0,
716
- rawPixelsScale: 1 / n
717
- }, c = await this._getActiveApi().preparePerspectiveImage(s), l = !!c.pixels || n > 1, u = await this._resolveImageDataUrl(c, r, i, n);
718
- return await this._writeDataUrlToFile(u, e), {
719
- dataUrl: u,
720
- width: l ? r : c.width,
721
- height: l ? i : c.height
722
- };
654
+ _useEnvironmentGeometry(e) {
655
+ this._container.lookup("planner-kernel-access")?.useEnvironmentGeometry(e);
723
656
  }
724
- async exportTopImage(e, t = {}) {
725
- if (this._ensureInitialized(), this._loadedStaticItemId) throw Error("HeadlessRoomleSdk: exportTopImage is not supported for static items");
726
- let n = this._getActiveApi(), r = t.ssaa ?? 2, i = {
727
- ...t,
728
- size: (t.size ?? Z) * r,
729
- showDimensions: t.showDimensions ?? !1,
730
- preferRawPixels: !0,
731
- rawPixelsScale: 1 / r
732
- }, a = await n.prepareTopImage(i), o = await this._resolveTopImage(a, r);
733
- return await this._writeDataUrlToFile(o.dataUrl, e), o;
734
- }
735
- async _resolveTopImage(e, t) {
736
- if (e.pixels) {
737
- 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);
738
- return {
739
- dataUrl: await this._rawPixelsToPngDataUrl(e.pixels, r, i),
740
- width: r,
741
- height: i
742
- };
743
- }
744
- if (t > 1) {
745
- let n = Math.round(e.width / t), r = Math.round(e.height / t);
746
- return {
747
- dataUrl: await this._ssaaDownscale(e.image, n, r),
748
- width: n,
749
- height: r
750
- };
751
- }
752
- return {
753
- dataUrl: e.image,
754
- width: e.width,
755
- height: e.height
756
- };
757
- }
758
- _getRenderDimensions(e) {
759
- let t = e.ssaa ?? (e.pathTracer ? 1 : 2), n = e.width ?? e.size ?? Z, r = e.height ?? e.size ?? Z;
760
- return {
761
- ssaa: t,
762
- targetWidth: n,
763
- targetHeight: r,
764
- renderWidth: n * t,
765
- renderHeight: r * t
766
- };
657
+ _withLoadedScene(e, t) {
658
+ return this._withLoader(async () => {
659
+ let n = this._requireLoadedScene();
660
+ return n.environmentGeometry !== Q(e, n.isPlan) && (await n.reload(e), n = this._requireLoadedScene()), t(n);
661
+ });
767
662
  }
768
- async _resolveImageDataUrl(e, t, n, r) {
769
- return e.pixels ? this._rawPixelsToPngDataUrl(e.pixels, t, n) : r > 1 ? this._ssaaDownscale(e.image, t, n) : e.image;
663
+ _export(e, t) {
664
+ return this._withLoadedScene(!1, async (n) => {
665
+ let r = n.planner.getSceneManager(), i = t === "glb" ? await r.createExportGLB() : await r.createUSDZExport();
666
+ if (!i) throw Error(`${t.toUpperCase()} export produced no data`);
667
+ let a = i instanceof ArrayBuffer ? i : i.buffer;
668
+ return e && (await import("fs")).writeFileSync(e, Buffer.from(a)), { buffer: a };
669
+ });
770
670
  }
771
- async _writeDataUrlToFile(e, t) {
772
- if (!t) return;
773
- let n = await import("fs"), r = e.replace(/^data:image\/\w+;base64,/, "");
774
- n.writeFileSync(t, Buffer.from(r, "base64"));
671
+ exportScreenshot(e, t = {}) {
672
+ return this._withLoadedScene(!0, async (n) => {
673
+ let { ssaa: r, targetWidth: i, targetHeight: a, renderWidth: o, renderHeight: s } = q(t), c = {
674
+ rotationY: t.rotationY,
675
+ cameraPosition: t.cameraPosition,
676
+ cameraPitch: t.cameraPitch,
677
+ cameraYaw: t.cameraYaw,
678
+ fov: t.fov,
679
+ showWallsAndCeiling: t.showWallsAndCeiling,
680
+ width: o,
681
+ height: s,
682
+ preserveSceneBackground: !0,
683
+ pathTracer: t.pathTracer,
684
+ pathTracerSamples: t.pathTracerSamples,
685
+ pathTracerSettings: t.pathTracerSettings,
686
+ preferRawPixels: !0,
687
+ rawPixelsScale: 1 / r
688
+ }, l = await J(await n.planner.preparePerspectiveImage(c), i, a, r);
689
+ return await Y(l, e), { dataUrl: l };
690
+ });
775
691
  }
776
- async _rawPixelsToPngDataUrl(e, t, n) {
777
- let { createCanvas: r, ImageData: i } = await import("@napi-rs/canvas"), a = r(e.width, e.height);
778
- 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");
779
- let o = r(t, n), s = o.getContext("2d");
780
- return s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high", s.drawImage(a, 0, 0, t, n), o.toDataURLAsync("image/png");
692
+ exportPerspectiveImage(e, t = {}) {
693
+ return this._withLoadedScene(!0, async (n) => {
694
+ let { ssaa: r, targetWidth: i, targetHeight: a, renderWidth: o, renderHeight: s } = q(t), c = {
695
+ ...t,
696
+ width: o,
697
+ height: s,
698
+ preferRawPixels: !0,
699
+ rawPixelsScale: 1 / r
700
+ }, l = await n.planner.preparePerspectiveImage(c), u = !!l.pixels || r > 1, d = await J(l, i, a, r);
701
+ return await Y(d, e), {
702
+ dataUrl: d,
703
+ width: u ? i : l.width,
704
+ height: u ? a : l.height
705
+ };
706
+ });
781
707
  }
782
- async _ssaaDownscale(e, t, n) {
783
- 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");
784
- return s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high", s.drawImage(a, 0, 0, t, n), o.toDataURLAsync("image/png");
708
+ exportTopImage(e, t = {}) {
709
+ return this._withLoadedScene(!0, async (n) => {
710
+ let r = t.ssaa ?? 2, i = {
711
+ ...t,
712
+ size: (t.size ?? 1024) * r,
713
+ showDimensions: t.showDimensions ?? !1,
714
+ preferRawPixels: !0,
715
+ rawPixelsScale: 1 / r
716
+ }, a = await Be(await n.planner.prepareTopImage(i), r);
717
+ return await Y(a.dataUrl, e), a;
718
+ });
785
719
  }
786
720
  getConfiguratorApi() {
787
- return this._configurator;
721
+ return this._getConfigurator();
788
722
  }
789
723
  getPlannerApi() {
790
- return this._planner;
724
+ return this._getPlanner();
791
725
  }
792
726
  async destroy() {
793
- this._configuratorMain && this._configuratorMain.destroy(), this._plannerMain && this._plannerMain.destroy(), this._glbViewerMain && this._glbViewerMain.destroy();
794
- }
795
- _ensureInitialized() {
796
- if (!this._initialized) throw Error("HeadlessRoomleSdk not initialized. Call HeadlessRoomleSdk.create() first.");
727
+ this._plannerMainPromise && (await this._plannerMainPromise.catch(() => null))?.destroy();
797
728
  }
798
- }, $ = () => globalThis.__RML__DI__?.lookup("model-export-state"), Me = (e) => {
729
+ }, $ = () => globalThis.__RML__DI__?.lookup("model-export-state"), Ke = (e) => {
799
730
  $()?.setModelExportOngoing(e);
800
- }, Ne = () => $()?.isModelExportOngoing() ?? !1;
731
+ }, qe = () => $()?.isModelExportOngoing() ?? !1;
801
732
  //#endregion
802
- export { o as CONFIGURATION_TYPE, s as CORE_EDGE_TYPE, c as CORE_OBJECT_CATEGORY, a as CORE_PERMISSION_TO_DELETE, P as Configurator, fe as FloorPlanElementViewModel, L as GlbViewer, j as HI_CONTEXT_ACTION, Q as HeadlessRoomleSdk, ie as MeasurementLinePlanElementViewModel, A as PLAN_ELEMENT_CHANGE_TYPES, p as PlanElementViewModel, re as PlanObjectViewModel, F as Planner, le as RapiAccess, _ as RapiInvalidIdError, O as RapiOfflineError, R as RoomDesignerApi, pe as RoomleConfigurator, I as RoomleGLBViewer, y as RoomleLightSource, D as RoomlePlanner, E as RoomleSdk, ne as StaticPlanObjectViewModel, te as WallPlanElementViewModel, ae as createExtObj, h as createExtObjId, ue as getCatalogIdFromConfigurationHash, z as getHeadlessWebGpuMaxTextureDimension, m as isExtObjId, ee as isExternalObject, ce as isFirefox, i as isIdAComponent, n as isIdAConfigurationString, r as isIdAPlan, t as isIdAnItem, Ne as isModelExportOngoing, e as isPlanSnapshotId, k as isSafari, S as removeExtObjIdPrefix, Me as setModelExportOngoing, xe as setPathTracerExternalDenoiser, Te as setPathTracerPreviewHook, we as setPathTracerProgressHook };
733
+ export { o as CONFIGURATION_TYPE, s as CORE_EDGE_TYPE, c as CORE_OBJECT_CATEGORY, a as CORE_PERMISSION_TO_DELETE, j as Configurator, me as FloorPlanElementViewModel, P as GlbViewer, O as HI_CONTEXT_ACTION, Ge as HeadlessRoomleSdk, oe as MeasurementLinePlanElementViewModel, D as PLAN_ELEMENT_CHANGE_TYPES, h as PlanElementViewModel, ae as PlanObjectViewModel, M as Planner, de as RapiAccess, _e as RapiInvalidIdError, T as RapiOfflineError, be as RoomDesignerApi, he as RoomleConfigurator, N as RoomleGLBViewer, ye as RoomleLightSource, w as RoomlePlanner, C as RoomleSdk, ie as StaticPlanObjectViewModel, re as WallPlanElementViewModel, ce as createExtObj, te as createExtObjId, fe as getCatalogIdFromConfigurationHash, xe as getHeadlessWebGpuMaxTextureDimension, ee as isExtObjId, ne as isExternalObject, ue as isFirefox, i as isIdAComponent, n as isIdAConfigurationString, r as isIdAPlan, t as isIdAnItem, qe as isModelExportOngoing, e as isPlanSnapshotId, E as isSafari, y as removeExtObjIdPrefix, Ke as setModelExportOngoing, je as setPathTracerExternalDenoiser, Fe as setPathTracerPreviewHook, Pe as setPathTracerProgressHook };
803
734
 
804
735
  //# sourceMappingURL=roomle-headless.js.map