@roomle/web-sdk 3.9.0-alpha.4 → 3.9.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{BufferGeometry-ltw0XkYt.mjs → BufferGeometry-Dxcf7n9V.mjs} +1 -1
- package/lib/{BufferGeometry-ltw0XkYt.mjs.map → BufferGeometry-Dxcf7n9V.mjs.map} +1 -1
- package/lib/ConfiguratorKernel.wasm +0 -0
- package/lib/{GLTFExporter-yfYOtLdk.mjs → GLTFExporter-kpv1e-Ks.mjs} +84 -84
- package/lib/{GLTFExporter-yfYOtLdk.mjs.map → GLTFExporter-kpv1e-Ks.mjs.map} +1 -1
- package/lib/GaussianBlurNode-CMVlBe39.mjs +59 -0
- package/lib/GaussianBlurNode-CMVlBe39.mjs.map +1 -0
- package/lib/{PointLightHelper-AxCe6I00.mjs → PointLightHelper-fzRB58rC.mjs} +2 -2
- package/lib/{PointLightHelper-AxCe6I00.mjs.map → PointLightHelper-fzRB58rC.mjs.map} +1 -1
- package/lib/RoomleCore.wasm +0 -0
- package/lib/RoomleToolsCore.wasm +0 -0
- package/lib/{SpotLightHelper-DpMerFPv.mjs → SpotLightHelper-D5UFwRPb.mjs} +2 -2
- package/lib/{SpotLightHelper-DpMerFPv.mjs.map → SpotLightHelper-D5UFwRPb.mjs.map} +1 -1
- package/lib/{USDZExporter-DFJQYX8l.mjs → USDZExporter-Y0SSGr5_.mjs} +2 -2
- package/lib/{USDZExporter-DFJQYX8l.mjs.map → USDZExporter-Y0SSGr5_.mjs.map} +1 -1
- package/lib/{api-x84SYo8e.mjs → api-52cOotqw.mjs} +2 -2
- package/lib/{api-x84SYo8e.mjs.map → api-52cOotqw.mjs.map} +1 -1
- package/lib/{asset-loader.worker-A7nEeQB4.mjs → asset-loader.worker-C911tbNL.mjs} +1 -1
- package/lib/asset-loader.worker-C911tbNL.mjs.map +1 -0
- package/lib/{banana-for-scale-CFY_5rk1.mjs → banana-for-scale-B_LIHI9q.mjs} +3 -3
- package/lib/{banana-for-scale-CFY_5rk1.mjs.map → banana-for-scale-B_LIHI9q.mjs.map} +1 -1
- package/lib/{budgeteer.sw-CQWYbQSc.mjs → budgeteer.sw-D3VxiASa.mjs} +1 -1
- package/lib/budgeteer.sw-D3VxiASa.mjs.map +1 -0
- package/lib/{common-utils-L3DF6Ey5.mjs → common-utils-B9PC_rvS.mjs} +2 -2
- package/lib/{common-utils-L3DF6Ey5.mjs.map → common-utils-B9PC_rvS.mjs.map} +1 -1
- package/lib/{component-dimensioning-FjlPqIvQ.mjs → component-dimensioning-12aJsCzQ.mjs} +31 -31
- package/lib/{component-dimensioning-FjlPqIvQ.mjs.map → component-dimensioning-12aJsCzQ.mjs.map} +1 -1
- package/lib/{component-raycast-helper-1n4uXeSD.mjs → component-raycast-helper-CcrmOq29.mjs} +14 -14
- package/lib/{component-raycast-helper-1n4uXeSD.mjs.map → component-raycast-helper-CcrmOq29.mjs.map} +1 -1
- package/lib/configurator-CarZpfPv.mjs +2 -0
- package/lib/{configurator-Dw5JbPMY.mjs → configurator-D3ZKy6bf.mjs} +10 -10
- package/lib/{configurator-Dw5JbPMY.mjs.map → configurator-D3ZKy6bf.mjs.map} +1 -1
- package/lib/{continuous-drawing-helper-DEmx54k_.mjs → continuous-drawing-helper-D25YPUle.mjs} +4 -4
- package/lib/{continuous-drawing-helper-DEmx54k_.mjs.map → continuous-drawing-helper-D25YPUle.mjs.map} +1 -1
- package/lib/{dimensioning-helper-BXD6AEqL.mjs → dimensioning-helper-d6JA4UMr.mjs} +49 -49
- package/lib/{dimensioning-helper-BXD6AEqL.mjs.map → dimensioning-helper-d6JA4UMr.mjs.map} +1 -1
- package/lib/dimensioning-helper-pPTkh8pl.mjs +2 -0
- package/lib/{glb-viewer-CWkc6wx7.mjs → glb-viewer-BJJ9OIlH.mjs} +35 -35
- package/lib/{glb-viewer-CWkc6wx7.mjs.map → glb-viewer-BJJ9OIlH.mjs.map} +1 -1
- package/lib/glb-viewer-CJ7BPqI-.mjs +2 -0
- package/lib/{highlight-coordinator-BJJw_RgR.mjs → highlight-coordinator-BuFleG2q.mjs} +8 -8
- package/lib/{highlight-coordinator-BJJw_RgR.mjs.map → highlight-coordinator-BuFleG2q.mjs.map} +1 -1
- package/lib/{homag-intelligence-Dk4WxD0p.mjs → homag-intelligence-BxpMWKLs.mjs} +5 -5
- package/lib/{homag-intelligence-Dk4WxD0p.mjs.map → homag-intelligence-BxpMWKLs.mjs.map} +1 -1
- package/lib/{imos-ix-poc-export-helper-C9wPB6fl.mjs → imos-ix-poc-export-helper-DU0ag-Lw.mjs} +3 -3
- package/lib/{imos-ix-poc-export-helper-C9wPB6fl.mjs.map → imos-ix-poc-export-helper-DU0ag-Lw.mjs.map} +1 -1
- package/lib/{kernel-utils-B5QlsCwn.mjs → kernel-utils-Cj5B4fDD.mjs} +16 -16
- package/lib/{kernel-utils-B5QlsCwn.mjs.map → kernel-utils-Cj5B4fDD.mjs.map} +1 -1
- package/lib/{main-CqSFaC9L.mjs → main-QTvbXAvy.mjs} +27277 -3406
- package/lib/main-QTvbXAvy.mjs.map +1 -0
- package/lib/{material-viewer-BSgvHUAe.mjs → material-viewer-BPcCfvCC.mjs} +18 -18
- package/lib/{material-viewer-BSgvHUAe.mjs.map → material-viewer-BPcCfvCC.mjs.map} +1 -1
- package/lib/packages-JQ2uWInj.mjs +4 -0
- package/lib/{planner-BgAj8Jp1.mjs → planner-C1-sOmHY.mjs} +5 -5
- package/lib/{planner-BgAj8Jp1.mjs.map → planner-C1-sOmHY.mjs.map} +1 -1
- package/lib/planner-CnRaQM_h.mjs +2 -0
- package/lib/{plugin-system-BBgoIai2.mjs → plugin-system-DlME_5b_.mjs} +2 -2
- package/lib/{plugin-system-BBgoIai2.mjs.map → plugin-system-DlME_5b_.mjs.map} +1 -1
- package/lib/rolldown-runtime-BwvMKf85.mjs +23 -0
- package/lib/roomle-headless.d.ts +32 -4
- package/lib/roomle-headless.js +40 -40
- package/lib/roomle-headless.js.map +1 -1
- package/lib/{roomle-renderer-CkSFbpmg.mjs → roomle-renderer-DYQvV88j.mjs} +2 -2
- package/lib/{roomle-renderer-CkSFbpmg.mjs.map → roomle-renderer-DYQvV88j.mjs.map} +1 -1
- package/lib/roomle-sdk.d.ts +32 -4
- package/lib/roomle-sdk.js +8 -8
- package/lib/{roomle-webgpu-renderer-DUr1RZL6.mjs → roomle-webgpu-renderer-BrZZeAGw.mjs} +296 -419
- package/lib/roomle-webgpu-renderer-BrZZeAGw.mjs.map +1 -0
- package/lib/{scene-renderer-BuMnigf2.mjs → scene-renderer-3nhM4cEu.mjs} +394 -394
- package/lib/{scene-renderer-BuMnigf2.mjs.map → scene-renderer-3nhM4cEu.mjs.map} +1 -1
- package/lib/{script-loader-DzyUQT3-.mjs → script-loader-3LiaLeLT.mjs} +2 -2
- package/lib/{script-loader-DzyUQT3-.mjs.map → script-loader-3LiaLeLT.mjs.map} +1 -1
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
- package/lib/{stats-helper-BZnX3BX3.mjs → stats-helper-COC7Moh0.mjs} +3 -3
- package/lib/{stats-helper-BZnX3BX3.mjs.map → stats-helper-COC7Moh0.mjs.map} +1 -1
- package/lib/{three.core-DNErG1F6.mjs → three.core-tV_4n8Wg.mjs} +374 -301
- package/lib/{three.core-DNErG1F6.mjs.map → three.core-tV_4n8Wg.mjs.map} +1 -1
- package/lib/{three.module-BZkESKo3.mjs → three.module-DC5fF9Zl.mjs} +1568 -1568
- package/lib/{three.module-BZkESKo3.mjs.map → three.module-DC5fF9Zl.mjs.map} +1 -1
- package/lib/three.tsl-CAEdYyg3.mjs +136 -0
- package/lib/three.tsl-CAEdYyg3.mjs.map +1 -0
- package/lib/three.tsl-S0OKwamA.mjs +2 -0
- package/lib/{three.webgpu-C8myBXe1.mjs → three.webgpu-CkP2nkXM.mjs} +747 -747
- package/lib/{three.webgpu-C8myBXe1.mjs.map → three.webgpu-CkP2nkXM.mjs.map} +1 -1
- package/lib/three.webgpu-qrxDA_v0.mjs +3 -0
- package/lib/{threejs-utils-D7sinreM.mjs → threejs-utils-CElderZe.mjs} +68 -68
- package/lib/threejs-utils-CElderZe.mjs.map +1 -0
- package/lib/{tools-core-BxOoo-C1.mjs → tools-core-mkA4m80O.mjs} +3 -3
- package/lib/{tools-core-BxOoo-C1.mjs.map → tools-core-mkA4m80O.mjs.map} +1 -1
- package/lib/workers-HXGCmmZS.mjs +6 -0
- package/lib/{workers-BJYv3y38.mjs.map → workers-HXGCmmZS.mjs.map} +1 -1
- package/package.json +1 -1
- package/lib/asset-loader.worker-A7nEeQB4.mjs.map +0 -1
- package/lib/budgeteer.sw-CQWYbQSc.mjs.map +0 -1
- package/lib/configurator-DeUTcLI3.mjs +0 -2
- package/lib/dimensioning-helper-Do9jwg8T.mjs +0 -2
- package/lib/glb-viewer-Ci-IZcIt.mjs +0 -2
- package/lib/main-CqSFaC9L.mjs.map +0 -1
- package/lib/packages-0mEYlGTx.mjs +0 -4
- package/lib/planner-CIvdB7af.mjs +0 -2
- package/lib/rolldown-runtime-DgwB9i60.mjs +0 -13
- package/lib/roomle-webgpu-renderer-DUr1RZL6.mjs.map +0 -1
- package/lib/three.webgpu-WIkDzwXU.mjs +0 -3
- package/lib/threejs-utils-D7sinreM.mjs.map +0 -1
- package/lib/workers-BJYv3y38.mjs +0 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Bt as e,
|
|
1
|
+
import { Bt as e, Si as t, Tn as n, Vt as r, f as i, h as a, m as o, mt as s, sn as c, xi as l, zt as u } from "./three.core-tV_4n8Wg.mjs";
|
|
2
2
|
import { n as d, r as f, t as p } from "./decorate-C9r0zXzz.mjs";
|
|
3
|
-
import { a as m } from "./kernel-utils-
|
|
3
|
+
import { a as m } from "./kernel-utils-Cj5B4fDD.mjs";
|
|
4
4
|
import { t as h } from "./layer-C_JtkhdO.mjs";
|
|
5
5
|
//#region packages/common-core/src/async-guard.ts
|
|
6
6
|
var g = class {
|
|
@@ -24,9 +24,9 @@ var g = class {
|
|
|
24
24
|
reset() {
|
|
25
25
|
this._init();
|
|
26
26
|
}
|
|
27
|
-
}, _ = class extends
|
|
27
|
+
}, _ = class extends n {
|
|
28
28
|
constructor(e = document.createElement("div")) {
|
|
29
|
-
super(), this.isCSS2DObject = !0, this.element = e, this.element.style.position = "absolute", this.element.style.userSelect = "none", this.element.setAttribute("draggable", !1), this.center = new
|
|
29
|
+
super(), this.isCSS2DObject = !0, this.element = e, this.element.style.position = "absolute", this.element.style.userSelect = "none", this.element.setAttribute("draggable", !1), this.center = new l(.5, .5), this.addEventListener("removed", function() {
|
|
30
30
|
this.traverse(function(e) {
|
|
31
31
|
e.element && e.element instanceof e.element.ownerDocument.defaultView.Element && e.element.parentNode !== null && e.element.remove();
|
|
32
32
|
});
|
|
@@ -35,7 +35,7 @@ var g = class {
|
|
|
35
35
|
copy(e, t) {
|
|
36
36
|
return super.copy(e, t), this.element = e.element.cloneNode(!0), this.center = e.center, this;
|
|
37
37
|
}
|
|
38
|
-
}, v = new
|
|
38
|
+
}, v = new t(), y = new c(), b = new c(), x = new t(), S = new t(), C = class {
|
|
39
39
|
constructor(e = {}) {
|
|
40
40
|
let t = this, n, r, i, a, o = { objects: /* @__PURE__ */ new WeakMap() }, s = e.element === void 0 ? document.createElement("div") : e.element;
|
|
41
41
|
s.style.overflow = "hidden", this.domElement = s, this.sortObjects = !0, this.getSize = function() {
|
|
@@ -87,11 +87,11 @@ function A(e) {
|
|
|
87
87
|
return new j(e);
|
|
88
88
|
}
|
|
89
89
|
var j = class {
|
|
90
|
-
constructor(
|
|
91
|
-
this._cameraPosition = new
|
|
90
|
+
constructor(e) {
|
|
91
|
+
this._cameraPosition = new t(), this._initialized = new g(), this._enabled = !1, this._dimensionsVisible = !1, this._dimensionLineGroup = new s(), this._creator_ = e, this._lineMaterial = new r({
|
|
92
92
|
color: k,
|
|
93
93
|
linewidth: 2
|
|
94
|
-
}), this._mainLineMaterial = new
|
|
94
|
+
}), this._mainLineMaterial = new r({
|
|
95
95
|
color: k,
|
|
96
96
|
linewidth: .001,
|
|
97
97
|
transparent: !0,
|
|
@@ -102,8 +102,8 @@ var j = class {
|
|
|
102
102
|
let t = new s();
|
|
103
103
|
return t.name = w, t.userData.ignoreComponentRaycast = !0, t;
|
|
104
104
|
}
|
|
105
|
-
_createLineFromConfig(e,
|
|
106
|
-
let
|
|
105
|
+
_createLineFromConfig(e, t) {
|
|
106
|
+
let n = new a(), r = [
|
|
107
107
|
e.start.x,
|
|
108
108
|
e.start.y,
|
|
109
109
|
e.start.z,
|
|
@@ -111,9 +111,9 @@ var j = class {
|
|
|
111
111
|
e.end.y,
|
|
112
112
|
e.end.z
|
|
113
113
|
];
|
|
114
|
-
|
|
115
|
-
let
|
|
116
|
-
return
|
|
114
|
+
n.setAttribute("position", new o(new Float32Array(r), 3));
|
|
115
|
+
let i = new u(n, t);
|
|
116
|
+
return i.name = w, i.userData.ignoreComponentRaycast = !0, i.layers.set(h.DIMENSIONS), i;
|
|
117
117
|
}
|
|
118
118
|
addLinesToLineGroup(e, t, n, r) {
|
|
119
119
|
t.extensionLines.forEach((t) => {
|
|
@@ -122,8 +122,8 @@ var j = class {
|
|
|
122
122
|
}
|
|
123
123
|
clearLineGroup(e) {
|
|
124
124
|
for (; e.children.length > 0;) {
|
|
125
|
-
let
|
|
126
|
-
|
|
125
|
+
let t = e.children[0];
|
|
126
|
+
t instanceof u && t.geometry.dispose(), e.remove(t);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
addLabelToLineGroup(e, t, n) {
|
|
@@ -135,28 +135,28 @@ var j = class {
|
|
|
135
135
|
return a.position.copy(o), e.add(a), a;
|
|
136
136
|
}
|
|
137
137
|
_getWidthLineConfig() {
|
|
138
|
-
let
|
|
138
|
+
let n = T, r = D, i = this._dimensions.y + n, a = this._getLocalCameraPosition().z < this._dimensions.z / 2 ? 0 : this._dimensions.z;
|
|
139
139
|
return {
|
|
140
|
-
mainLine: new
|
|
141
|
-
extensionLines: [new
|
|
140
|
+
mainLine: new e(new t(0, i, a), new t(this._dimensions.x, i, a)),
|
|
141
|
+
extensionLines: [new e(new t(0, i - r, a), new t(0, i + r, a)), new e(new t(this._dimensions.x, i - r, a), new t(this._dimensions.x, i + r, a))]
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
_getDepthLineConfig() {
|
|
145
|
-
let
|
|
145
|
+
let n = T, r = D, i = this._getLocalCameraPosition().x < this._dimensions.x / 2 ? -n : this._dimensions.x + n;
|
|
146
146
|
return {
|
|
147
|
-
mainLine: new
|
|
148
|
-
extensionLines: [new
|
|
147
|
+
mainLine: new e(new t(i, 0, this._dimensions.z), new t(i, 0, 0)),
|
|
148
|
+
extensionLines: [new e(new t(i - r, 0, 0), new t(i + r, 0, 0)), new e(new t(i - r, 0, this._dimensions.z), new t(i + r, 0, this._dimensions.z))]
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
_getHeightLineConfig() {
|
|
152
|
-
let
|
|
152
|
+
let n = T, r = D, i = this._getLocalCameraPosition(), a = i.x < this._dimensions.x / 2 ? -n : this._dimensions.x + n, o = i.z < this._dimensions.z / 2 ? 0 : this._dimensions.z;
|
|
153
153
|
return {
|
|
154
|
-
mainLine: new
|
|
155
|
-
extensionLines: [new
|
|
154
|
+
mainLine: new e(new t(a, 0, o), new t(a, this._dimensions.y, o)),
|
|
155
|
+
extensionLines: [new e(new t(a - r, 0, o), new t(a + r, 0, o)), new e(new t(a - r, this._dimensions.y, o), new t(a + r, this._dimensions.y, o))]
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
_getLocalCameraPosition() {
|
|
159
|
-
return !this._cameraPosition || !this._dimensionLineGroup || !this._dimensions ? new
|
|
159
|
+
return !this._cameraPosition || !this._dimensionLineGroup || !this._dimensions ? new t(0, 0, 0) : this._dimensionLineGroup.worldToLocal(this._cameraPosition.clone());
|
|
160
160
|
}
|
|
161
161
|
_getCameraDistanceInfo() {
|
|
162
162
|
if (!this._object || !this._cameraPosition || !this._dimensions) return {
|
|
@@ -164,38 +164,38 @@ var j = class {
|
|
|
164
164
|
opacity: 1,
|
|
165
165
|
distance: Infinity
|
|
166
166
|
};
|
|
167
|
-
let e = this._object.getWorldPosition(new
|
|
168
|
-
if (
|
|
167
|
+
let e = this._object.getWorldPosition(new t()), n = this._cameraPosition.distanceTo(e), r = Math.max(this._dimensions.x, this._dimensions.y, this._dimensions.z) / 2, i = r * E, a = r * 2;
|
|
168
|
+
if (n < i) return {
|
|
169
169
|
tooClose: !0,
|
|
170
170
|
opacity: 0,
|
|
171
|
-
distance:
|
|
171
|
+
distance: n
|
|
172
172
|
};
|
|
173
|
-
if (
|
|
174
|
-
let e = (
|
|
173
|
+
if (n < a) {
|
|
174
|
+
let e = (n - i) / (a - i);
|
|
175
175
|
return {
|
|
176
176
|
tooClose: !1,
|
|
177
177
|
opacity: Math.max(0, Math.min(1, e)),
|
|
178
|
-
distance:
|
|
178
|
+
distance: n
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
return {
|
|
182
182
|
tooClose: !1,
|
|
183
183
|
opacity: 1,
|
|
184
|
-
distance:
|
|
184
|
+
distance: n
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
_visibilityChangedCallback() {
|
|
188
188
|
this._onVisibilityChange && this._onVisibilityChange(this._dimensionsVisible);
|
|
189
189
|
}
|
|
190
190
|
updateDimensionLabelVisibility(e) {
|
|
191
|
-
let
|
|
192
|
-
e.getWorldPosition(
|
|
193
|
-
let
|
|
191
|
+
let n = new t();
|
|
192
|
+
e.getWorldPosition(n), this._cameraPosition = n, this.update();
|
|
193
|
+
let r = (e, r) => {
|
|
194
194
|
if (!e) return;
|
|
195
|
-
let
|
|
196
|
-
e.visible = !O(
|
|
195
|
+
let i = e.getWorldPosition(new t());
|
|
196
|
+
e.visible = !O(r, n.distanceTo(i));
|
|
197
197
|
};
|
|
198
|
-
|
|
198
|
+
r(this._widthLabel, this._dimensions.x), r(this._heightLabel, this._dimensions.y), r(this._depthLabel, this._dimensions.z);
|
|
199
199
|
}
|
|
200
200
|
update(e = !1) {
|
|
201
201
|
this._enabled && !this._dimensionsVisible && (this._dimensionsVisible = !0, this._visibilityChangedCallback()), this._performUpdate(e);
|
|
@@ -237,7 +237,7 @@ var j = class {
|
|
|
237
237
|
this._heightLineGroup.visible = !0, this.disableDimensions();
|
|
238
238
|
}
|
|
239
239
|
getBoundingBox() {
|
|
240
|
-
let e = new
|
|
240
|
+
let e = new i();
|
|
241
241
|
return e.expandByObject(this._dimensionLineGroup), e;
|
|
242
242
|
}
|
|
243
243
|
setCameraPosition(e) {
|
|
@@ -245,18 +245,18 @@ var j = class {
|
|
|
245
245
|
}
|
|
246
246
|
_performUpdate(e) {
|
|
247
247
|
if (!this._enabled && !e || !this._dimensions) return;
|
|
248
|
-
let
|
|
249
|
-
if (this._object && this._cameraPosition && !this._cameraPosition.equals(new
|
|
248
|
+
let n = 1;
|
|
249
|
+
if (this._object && this._cameraPosition && !this._cameraPosition.equals(new t(0, 0, 0))) {
|
|
250
250
|
let e = this._getCameraDistanceInfo();
|
|
251
|
-
e.tooClose ? this._dimensionLineGroup.visible = !1 : (this._dimensionLineGroup.visible = !0,
|
|
251
|
+
e.tooClose ? this._dimensionLineGroup.visible = !1 : (this._dimensionLineGroup.visible = !0, n = e.opacity, this._mainLineMaterial.opacity = n);
|
|
252
252
|
}
|
|
253
253
|
this._dimensionLineGroup.updateMatrixWorld(!0);
|
|
254
|
-
let
|
|
255
|
-
this.clearLineGroup(this._widthLineGroup), this.addLinesToLineGroup(this._widthLineGroup,
|
|
256
|
-
let
|
|
257
|
-
this.clearLineGroup(this._heightLineGroup), this.addLinesToLineGroup(this._heightLineGroup,
|
|
258
|
-
let
|
|
259
|
-
this.clearLineGroup(this._depthLineGroup), this.addLinesToLineGroup(this._depthLineGroup,
|
|
254
|
+
let r = this._getWidthLineConfig(), i = this._unitFormatter.formatMMValueToUnitString(this._dimensions.x * 1e3), a = this._dimensionLineGroup.localToWorld(r.mainLine.getCenter(new t()));
|
|
255
|
+
this.clearLineGroup(this._widthLineGroup), this.addLinesToLineGroup(this._widthLineGroup, r, this._mainLineMaterial, this._mainLineMaterial), i !== null && (this._widthLabel = this.addLabelToLineGroup(this._widthLineGroup, i, a));
|
|
256
|
+
let o = this._getHeightLineConfig(), s = this._unitFormatter.formatMMValueToUnitString(this._dimensions.y * 1e3), c = this._dimensionLineGroup.localToWorld(o.mainLine.getCenter(new t()));
|
|
257
|
+
this.clearLineGroup(this._heightLineGroup), this.addLinesToLineGroup(this._heightLineGroup, o, this._mainLineMaterial, this._mainLineMaterial), s !== null && (this._heightLabel = this.addLabelToLineGroup(this._heightLineGroup, s, c));
|
|
258
|
+
let l = this._getDepthLineConfig(), u = this._unitFormatter.formatMMValueToUnitString(this._dimensions.z * -1e3), d = this._dimensionLineGroup.localToWorld(l.mainLine.getCenter(new t()));
|
|
259
|
+
this.clearLineGroup(this._depthLineGroup), this.addLinesToLineGroup(this._depthLineGroup, l, this._mainLineMaterial, this._mainLineMaterial), u !== null && (this._depthLabel = this.addLabelToLineGroup(this._depthLineGroup, u, d));
|
|
260
260
|
}
|
|
261
261
|
_clear() {
|
|
262
262
|
this._lineMaterial.dispose(), this._mainLineMaterial.dispose(), [
|
|
@@ -272,4 +272,4 @@ p([f, d("design:type", Object)], j.prototype, "_unitFormatter", void 0);
|
|
|
272
272
|
//#endregion
|
|
273
273
|
export { E as a, _ as c, D as i, C as l, T as n, A as o, j as r, O as s, w as t, g as u };
|
|
274
274
|
|
|
275
|
-
//# sourceMappingURL=dimensioning-helper-
|
|
275
|
+
//# sourceMappingURL=dimensioning-helper-d6JA4UMr.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimensioning-helper-BXD6AEqL.mjs","names":[],"sources":["../../packages/common-core/src/async-guard.ts","../../../../node_modules/three/examples/jsm/renderers/CSS2DRenderer.js","../../packages/configurator-core/src/utils/dimensioning-helper.ts"],"sourcesContent":["export default class AsyncGuard<T> {\n public info: any;\n private _promise: Promise<T>;\n private _resolve: (value?: T | PromiseLike<T>) => void;\n private _reject: (error: Error) => void;\n\n constructor(info?: any) {\n this.info = info;\n this._init();\n }\n\n private _init() {\n this._promise = new Promise<T>((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n }\n\n public resolve(value?: any): void {\n if (value) {\n this._resolve(value);\n }\n this._resolve();\n }\n\n public reject(e: Error): void {\n this._reject(e);\n }\n\n public wait(): Promise<T> {\n return this._promise;\n }\n\n public reset() {\n this._init();\n }\n}\n","import {\n\tMatrix4,\n\tObject3D,\n\tVector2,\n\tVector3\n} from 'three';\n\n/**\n * The only type of 3D object that is supported by {@link CSS2DRenderer}.\n *\n * @augments Object3D\n * @three_import import { CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';\n */\nclass CSS2DObject extends Object3D {\n\n\t/**\n\t * Constructs a new CSS2D object.\n\t *\n\t * @param {HTMLElement} [element] - The DOM element.\n\t */\n\tconstructor( element = document.createElement( 'div' ) ) {\n\n\t\tsuper();\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isCSS2DObject = true;\n\n\t\t/**\n\t\t * The DOM element which defines the appearance of this 3D object.\n\t\t *\n\t\t * @type {HTMLElement}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.element = element;\n\n\t\tthis.element.style.position = 'absolute';\n\t\tthis.element.style.userSelect = 'none';\n\n\t\tthis.element.setAttribute( 'draggable', false );\n\n\t\t/**\n\t\t * The 3D objects center point.\n\t\t * `( 0, 0 )` is the lower left, `( 1, 1 )` is the top right.\n\t\t *\n\t\t * @type {Vector2}\n\t\t * @default (0.5,0.5)\n\t\t */\n\t\tthis.center = new Vector2( 0.5, 0.5 );\n\n\t\tthis.addEventListener( 'removed', function () {\n\n\t\t\tthis.traverse( function ( object ) {\n\n\t\t\t\tif (\n\t\t\t\t\tobject.element &&\n\t\t\t\t\tobject.element instanceof object.element.ownerDocument.defaultView.Element &&\n\t\t\t\t\tobject.element.parentNode !== null\n\t\t\t\t) {\n\n\t\t\t\t\tobject.element.remove();\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t} );\n\n\t}\n\n\tcopy( source, recursive ) {\n\n\t\tsuper.copy( source, recursive );\n\n\t\tthis.element = source.element.cloneNode( true );\n\n\t\tthis.center = source.center;\n\n\t\treturn this;\n\n\t}\n\n}\n\n//\n\nconst _vector = new Vector3();\nconst _viewMatrix = new Matrix4();\nconst _viewProjectionMatrix = new Matrix4();\nconst _a = new Vector3();\nconst _b = new Vector3();\n\n/**\n * This renderer is a simplified version of {@link CSS3DRenderer}. The only transformation that is\n * supported is translation.\n *\n * The renderer is very useful if you want to combine HTML based labels with 3D objects. Here too,\n * the respective DOM elements are wrapped into an instance of {@link CSS2DObject} and added to the\n * scene graph. All other types of renderable 3D objects (like meshes or point clouds) are ignored.\n *\n * `CSS2DRenderer` only supports 100% browser and display zoom.\n *\n * @three_import import { CSS2DRenderer } from 'three/addons/renderers/CSS2DRenderer.js';\n */\nclass CSS2DRenderer {\n\n\t/**\n\t * Constructs a new CSS2D renderer.\n\t *\n\t * @param {CSS2DRenderer~Parameters} [parameters] - The parameters.\n\t */\n\tconstructor( parameters = {} ) {\n\n\t\tconst _this = this;\n\n\t\tlet _width, _height;\n\t\tlet _widthHalf, _heightHalf;\n\n\t\tconst cache = {\n\t\t\tobjects: new WeakMap()\n\t\t};\n\n\t\tconst domElement = parameters.element !== undefined ? parameters.element : document.createElement( 'div' );\n\n\t\tdomElement.style.overflow = 'hidden';\n\n\t\t/**\n\t\t * The DOM where the renderer appends its child-elements.\n\t\t *\n\t\t * @type {HTMLElement}\n\t\t */\n\t\tthis.domElement = domElement;\n\n\t\t/**\n\t\t * Controls whether the renderer assigns `z-index` values to CSS2DObject DOM elements.\n\t\t * If set to `true`, z-index values are assigned first based on the `renderOrder`\n\t\t * and secondly - the distance to the camera. If set to `false`, no z-index values are assigned.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.sortObjects = true;\n\n\t\t/**\n\t\t * Returns an object containing the width and height of the renderer.\n\t\t *\n\t\t * @return {{width:number,height:number}} The size of the renderer.\n\t\t */\n\t\tthis.getSize = function () {\n\n\t\t\treturn {\n\t\t\t\twidth: _width,\n\t\t\t\theight: _height\n\t\t\t};\n\n\t\t};\n\n\t\t/**\n\t\t * Renders the given scene using the given camera.\n\t\t *\n\t\t * @param {Object3D} scene - A scene or any other type of 3D object.\n\t\t * @param {Camera} camera - The camera.\n\t\t */\n\t\tthis.render = function ( scene, camera ) {\n\n\t\t\tif ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();\n\t\t\tif ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();\n\n\t\t\t_viewMatrix.copy( camera.matrixWorldInverse );\n\t\t\t_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );\n\n\t\t\trenderObject( scene, scene, camera );\n\t\t\tif ( this.sortObjects ) zOrder( scene );\n\n\t\t};\n\n\t\t/**\n\t\t * Resizes the renderer to the given width and height.\n\t\t *\n\t\t * @param {number} width - The width of the renderer.\n\t\t * @param {number} height - The height of the renderer.\n\t\t */\n\t\tthis.setSize = function ( width, height ) {\n\n\t\t\t_width = width;\n\t\t\t_height = height;\n\n\t\t\t_widthHalf = _width / 2;\n\t\t\t_heightHalf = _height / 2;\n\n\t\t\tdomElement.style.width = width + 'px';\n\t\t\tdomElement.style.height = height + 'px';\n\n\t\t};\n\n\t\tfunction hideObject( object ) {\n\n\t\t\tif ( object.isCSS2DObject ) object.element.style.display = 'none';\n\n\t\t\tfor ( let i = 0, l = object.children.length; i < l; i ++ ) {\n\n\t\t\t\thideObject( object.children[ i ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction renderObject( object, scene, camera ) {\n\n\t\t\tif ( object.visible === false ) {\n\n\t\t\t\thideObject( object );\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( object.isCSS2DObject ) {\n\n\t\t\t\t_vector.setFromMatrixPosition( object.matrixWorld );\n\t\t\t\t_vector.applyMatrix4( _viewProjectionMatrix );\n\n\t\t\t\tconst visible = ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );\n\n\t\t\t\tconst element = object.element;\n\t\t\t\telement.style.display = visible === true ? '' : 'none';\n\n\t\t\t\tif ( visible === true ) {\n\n\t\t\t\t\tobject.onBeforeRender( _this, scene, camera );\n\n\t\t\t\t\telement.style.transform = 'translate(' + ( - 100 * object.center.x ) + '%,' + ( - 100 * object.center.y ) + '%)' + 'translate(' + ( _vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - _vector.y * _heightHalf + _heightHalf ) + 'px)';\n\n\t\t\t\t\tif ( element.parentNode !== domElement ) {\n\n\t\t\t\t\t\tdomElement.appendChild( element );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tobject.onAfterRender( _this, scene, camera );\n\n\t\t\t\t}\n\n\t\t\t\tconst objectData = {\n\t\t\t\t\tdistanceToCameraSquared: getDistanceToSquared( camera, object )\n\t\t\t\t};\n\n\t\t\t\tcache.objects.set( object, objectData );\n\n\t\t\t}\n\n\t\t\tfor ( let i = 0, l = object.children.length; i < l; i ++ ) {\n\n\t\t\t\trenderObject( object.children[ i ], scene, camera );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction getDistanceToSquared( object1, object2 ) {\n\n\t\t\t_a.setFromMatrixPosition( object1.matrixWorld );\n\t\t\t_b.setFromMatrixPosition( object2.matrixWorld );\n\n\t\t\treturn _a.distanceToSquared( _b );\n\n\t\t}\n\n\t\tfunction filterAndFlatten( scene ) {\n\n\t\t\tconst result = [];\n\n\t\t\tscene.traverseVisible( function ( object ) {\n\n\t\t\t\tif ( object.isCSS2DObject ) result.push( object );\n\n\t\t\t} );\n\n\t\t\treturn result;\n\n\t\t}\n\n\t\tfunction zOrder( scene ) {\n\n\t\t\tconst sorted = filterAndFlatten( scene ).sort( function ( a, b ) {\n\n\t\t\t\tif ( a.renderOrder !== b.renderOrder ) {\n\n\t\t\t\t\treturn b.renderOrder - a.renderOrder;\n\n\t\t\t\t}\n\n\t\t\t\tconst distanceA = cache.objects.get( a ).distanceToCameraSquared;\n\t\t\t\tconst distanceB = cache.objects.get( b ).distanceToCameraSquared;\n\n\t\t\t\treturn distanceA - distanceB;\n\n\t\t\t} );\n\n\t\t\tconst zMax = sorted.length;\n\n\t\t\tfor ( let i = 0, l = sorted.length; i < l; i ++ ) {\n\n\t\t\t\tsorted[ i ].element.style.zIndex = zMax - i;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\n/**\n * Constructor parameters of `CSS2DRenderer`.\n *\n * @typedef {Object} CSS2DRenderer~Parameters\n * @property {HTMLElement} [element] - A DOM element where the renderer appends its child-elements.\n * If not passed in here, a new div element will be created.\n **/\n\nexport { CSS2DObject, CSS2DRenderer };\n","import inject from '../../../common-core/src/di/inject';\nimport AsyncGuard from '../../../common-core/src/async-guard';\nimport type { Object3D, Camera } from 'three';\nimport { Group, type Scene } from 'three';\nimport { Box3 } from 'three';\nimport {\n BufferAttribute,\n BufferGeometry,\n Line,\n Line3,\n LineBasicMaterial,\n Vector3,\n} from 'three';\nimport { type KernelCube } from '../../../typings/kernel';\nimport { convertToTHREE } from '../../../common-core/src/utils/kernel-utils';\nimport type UnitFormatter from '../services/unit-formatter';\nimport { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';\nimport { LAYER } from '../../../common-core/src/webgl/layer';\n\nexport const DIMENSIONING_GEOMETRY = 'dimensioning';\nexport const DIMENSION_LINE_OFFSET = 0.08;\nexport const MIN_CAMERA_DISTANCE_RATIO = 1.2;\nexport const FADE_DISTANCE_RATIO = 2.0;\nexport const EXTENSION_LINE_LENGTH_RATIO = 0.03;\n\nexport const shouldHideDimensionLabel = (\n labelValueInMeters: number,\n distance: number,\n): boolean => {\n labelValueInMeters = Math.abs(labelValueInMeters);\n return labelValueInMeters < distance * 0.05 && distance > 3;\n};\n\nexport interface DimensionLineConfig {\n mainLine: Line3;\n extensionLines: Line3[];\n}\n\nconst LINE_COLOR = 0x373737;\n\nexport function createDimensioningHelper(creator: string): DimensioningHelper {\n return new DimensioningHelper(creator);\n}\n\nexport default class DimensioningHelper {\n public _creator_: string;\n\n @inject\n private _unitFormatter: UnitFormatter;\n\n private _object: Object3D;\n private _cameraPosition: Vector3 = new Vector3();\n private _onVisibilityChange: (visible: boolean) => void;\n private _initialized: AsyncGuard<void> = new AsyncGuard();\n\n private _origin: Vector3;\n private _dimensions: Vector3;\n\n private _lineMaterial: LineBasicMaterial;\n private readonly _mainLineMaterial: LineBasicMaterial;\n\n private readonly _widthLineGroup: Group;\n private readonly _heightLineGroup: Group;\n private readonly _depthLineGroup: Group;\n\n private _widthLabel: CSS2DObject;\n private _heightLabel: CSS2DObject;\n private _depthLabel: CSS2DObject;\n\n private _enabled: boolean = false;\n private _dimensionsVisible = false;\n\n private _dimensionLineGroup = new Group();\n\n constructor(creator: string) {\n this._creator_ = creator;\n\n this._lineMaterial = new LineBasicMaterial({\n color: LINE_COLOR,\n linewidth: 2,\n });\n\n this._mainLineMaterial = new LineBasicMaterial({\n color: LINE_COLOR,\n linewidth: 0.001,\n transparent: true,\n opacity: 1.0,\n });\n\n this._dimensionLineGroup.name = DIMENSIONING_GEOMETRY;\n\n this._widthLineGroup = this._createLineGroup('width');\n this._heightLineGroup = this._createLineGroup('height');\n this._depthLineGroup = this._createLineGroup('depth');\n\n this._dimensionLineGroup.add(this._widthLineGroup);\n this._dimensionLineGroup.add(this._heightLineGroup);\n this._dimensionLineGroup.add(this._depthLineGroup);\n\n this.update(false);\n this._initialized.resolve();\n }\n\n private _createLineGroup(_name: string): Group {\n const group = new Group();\n group.name = DIMENSIONING_GEOMETRY;\n group.userData.ignoreComponentRaycast = true;\n return group;\n }\n\n private _createLineFromConfig(\n config: Line3,\n material: LineBasicMaterial,\n ): Line {\n const geometry = new BufferGeometry();\n const vertices = [\n config.start.x,\n config.start.y,\n config.start.z,\n config.end.x,\n config.end.y,\n config.end.z,\n ];\n geometry.setAttribute(\n 'position',\n new BufferAttribute(new Float32Array(vertices), 3),\n );\n const line = new Line(geometry, material);\n line.name = DIMENSIONING_GEOMETRY;\n line.userData.ignoreComponentRaycast = true;\n line.layers.set(LAYER.DIMENSIONS);\n return line;\n }\n\n private addLinesToLineGroup(\n group: Group,\n config: DimensionLineConfig,\n mainMaterial: LineBasicMaterial,\n extMaterial: LineBasicMaterial,\n ) {\n config.extensionLines.forEach((extLine) => {\n group.add(this._createLineFromConfig(extLine, extMaterial));\n });\n\n group.add(this._createLineFromConfig(config.mainLine, mainMaterial));\n }\n\n private clearLineGroup(group: Group) {\n while (group.children.length > 0) {\n const child = group.children[0];\n if (child instanceof Line) {\n child.geometry.dispose();\n }\n group.remove(child);\n }\n }\n\n private addLabelToLineGroup(\n group: Group,\n labelText: string,\n labelWorldPosition: Vector3,\n ): CSS2DObject {\n const labelHtmlDiv = document.createElement('div');\n labelHtmlDiv.classList.add(\n 'dimension-label',\n 'dimension-label--primary',\n 'dimension-label--disabled',\n );\n const labelHtmlSpan = document.createElement('span');\n labelHtmlSpan.classList.add('dimension-label__value');\n labelHtmlSpan.innerHTML = labelText;\n labelHtmlDiv.appendChild(labelHtmlSpan);\n\n const label = new CSS2DObject(labelHtmlDiv);\n const labelLocalPosition =\n this._dimensionLineGroup.worldToLocal(labelWorldPosition);\n label.position.copy(labelLocalPosition);\n\n group.add(label);\n return label;\n }\n\n private _getWidthLineConfig(): DimensionLineConfig {\n const offset = DIMENSION_LINE_OFFSET;\n const extLength = EXTENSION_LINE_LENGTH_RATIO;\n const y = this._dimensions.y + offset;\n const localCam = this._getLocalCameraPosition();\n const z = localCam.z < this._dimensions.z / 2 ? 0 : this._dimensions.z;\n\n return {\n mainLine: new Line3(\n new Vector3(0, y, z),\n new Vector3(this._dimensions.x, y, z),\n ),\n extensionLines: [\n new Line3(\n new Vector3(0, y - extLength, z),\n new Vector3(0, y + extLength, z),\n ),\n new Line3(\n new Vector3(this._dimensions.x, y - extLength, z),\n new Vector3(this._dimensions.x, y + extLength, z),\n ),\n ],\n };\n }\n\n private _getDepthLineConfig(): DimensionLineConfig {\n const offset = DIMENSION_LINE_OFFSET;\n const extLength = EXTENSION_LINE_LENGTH_RATIO;\n const y = 0;\n const localCam = this._getLocalCameraPosition();\n const x =\n localCam.x < this._dimensions.x / 2\n ? -offset\n : this._dimensions.x + offset;\n\n return {\n mainLine: new Line3(\n new Vector3(x, y, this._dimensions.z),\n new Vector3(x, y, 0),\n ),\n extensionLines: [\n new Line3(\n new Vector3(x - extLength, y, 0),\n new Vector3(x + extLength, y, 0),\n ),\n new Line3(\n new Vector3(x - extLength, y, this._dimensions.z),\n new Vector3(x + extLength, y, this._dimensions.z),\n ),\n ],\n };\n }\n\n private _getHeightLineConfig(): DimensionLineConfig {\n const offset = DIMENSION_LINE_OFFSET;\n const extLength = EXTENSION_LINE_LENGTH_RATIO;\n const localCam = this._getLocalCameraPosition();\n const x =\n localCam.x < this._dimensions.x / 2\n ? -offset\n : this._dimensions.x + offset;\n const z = localCam.z < this._dimensions.z / 2 ? 0 : this._dimensions.z;\n\n return {\n mainLine: new Line3(\n new Vector3(x, 0, z),\n new Vector3(x, this._dimensions.y, z),\n ),\n extensionLines: [\n new Line3(\n new Vector3(x - extLength, 0, z),\n new Vector3(x + extLength, 0, z),\n ),\n new Line3(\n new Vector3(x - extLength, this._dimensions.y, z),\n new Vector3(x + extLength, this._dimensions.y, z),\n ),\n ],\n };\n }\n\n private _getLocalCameraPosition(): Vector3 {\n if (\n !this._cameraPosition ||\n !this._dimensionLineGroup ||\n !this._dimensions\n ) {\n return new Vector3(0, 0, 0);\n }\n return this._dimensionLineGroup.worldToLocal(this._cameraPosition.clone());\n }\n\n private _getCameraDistanceInfo(): {\n tooClose: boolean;\n opacity: number;\n distance: number;\n } {\n if (!this._object || !this._cameraPosition || !this._dimensions) {\n return { tooClose: false, opacity: 1.0, distance: Infinity };\n }\n const objPos = this._object.getWorldPosition(new Vector3());\n const distance = this._cameraPosition.distanceTo(objPos);\n const objectRadius =\n Math.max(this._dimensions.x, this._dimensions.y, this._dimensions.z) / 2;\n const minThreshold = objectRadius * MIN_CAMERA_DISTANCE_RATIO;\n const fadeThreshold = objectRadius * FADE_DISTANCE_RATIO;\n\n if (distance < minThreshold) {\n return { tooClose: true, opacity: 0, distance };\n }\n if (distance < fadeThreshold) {\n const opacity =\n (distance - minThreshold) / (fadeThreshold - minThreshold);\n return {\n tooClose: false,\n opacity: Math.max(0, Math.min(1, opacity)),\n distance,\n };\n }\n return { tooClose: false, opacity: 1.0, distance };\n }\n\n private _visibilityChangedCallback() {\n if (this._onVisibilityChange) {\n this._onVisibilityChange(this._dimensionsVisible);\n }\n }\n\n public updateDimensionLabelVisibility(camera: Camera) {\n const cameraPosition = new Vector3();\n camera.getWorldPosition(cameraPosition);\n\n this._cameraPosition = cameraPosition;\n this.update();\n\n const checkVisibility = (\n label: CSS2DObject,\n labelValueInMeters: number,\n ) => {\n if (!label) {\n return;\n }\n const labelPosition = label.getWorldPosition(new Vector3());\n const cameraDistanceToLabel = cameraPosition.distanceTo(labelPosition);\n label.visible = !shouldHideDimensionLabel(\n labelValueInMeters,\n cameraDistanceToLabel,\n );\n };\n\n checkVisibility(this._widthLabel, this._dimensions.x);\n checkVisibility(this._heightLabel, this._dimensions.y);\n checkVisibility(this._depthLabel, this._dimensions.z);\n }\n\n public update(force: boolean = false) {\n if (this._enabled && !this._dimensionsVisible) {\n this._dimensionsVisible = true;\n this._visibilityChangedCallback();\n }\n this._performUpdate(force);\n }\n\n public updateSize(boxForMeasurement: KernelCube) {\n this._origin = convertToTHREE(boxForMeasurement.origin);\n this._dimensionLineGroup.position.x =\n this._origin.x - this._object.position.x;\n this._dimensionLineGroup.position.y =\n this._origin.y - this._object.position.y;\n this._dimensionLineGroup.position.z =\n this._origin.z - this._object.position.z;\n this._dimensions = convertToTHREE(boxForMeasurement.size);\n this.update();\n }\n\n public removeFromObject(object: Object3D) {\n if (object) {\n object.remove(this._dimensionLineGroup);\n }\n }\n\n public onDimensionsVisibilityChanged(handler: (visible: boolean) => void) {\n this._onVisibilityChange = handler;\n }\n\n public setObject(object: Object3D): void {\n this._object = object;\n }\n\n public isInitialized(): Promise<void> {\n return this._initialized.wait();\n }\n\n public areDimensionsEnabled(): boolean {\n return this._enabled;\n }\n\n public clearScene(_scene: Scene): void {\n this._clear();\n }\n\n public addToObject(object: Object3D): void {\n if (!object || !this._dimensionLineGroup) {\n return;\n }\n object.add(this._dimensionLineGroup);\n }\n\n public enableDimensions(): void {\n this._enabled = true;\n this.addToObject(this._object);\n this.update(true);\n }\n\n public disableDimensions(): void {\n this._enabled = false;\n if (this._dimensionsVisible) {\n this._dimensionsVisible = false;\n this._visibilityChangedCallback();\n }\n this._clear();\n this.removeFromObject(this._object);\n }\n\n public enableTopDimensions(): void {\n this.enableDimensions();\n this._heightLineGroup.visible = false;\n this.update(true);\n }\n\n public disableTopDimensions(): void {\n this._heightLineGroup.visible = true;\n this.disableDimensions();\n }\n\n public getBoundingBox(): Box3 {\n const bbox = new Box3();\n bbox.expandByObject(this._dimensionLineGroup);\n return bbox;\n }\n\n public setCameraPosition(position: Vector3): void {\n this._cameraPosition = position;\n this.update();\n }\n\n private _performUpdate(force: boolean): void {\n if (!this._enabled && !force) {\n return;\n }\n if (!this._dimensions) {\n return;\n }\n\n let opacity = 1.0;\n\n if (\n this._object &&\n this._cameraPosition &&\n !this._cameraPosition.equals(new Vector3(0, 0, 0))\n ) {\n const distanceCheck = this._getCameraDistanceInfo();\n if (distanceCheck.tooClose) {\n this._dimensionLineGroup.visible = false;\n } else {\n this._dimensionLineGroup.visible = true;\n opacity = distanceCheck.opacity;\n this._mainLineMaterial.opacity = opacity;\n }\n }\n\n this._dimensionLineGroup.updateMatrixWorld(true);\n\n const widthConfig = this._getWidthLineConfig();\n const widthLabelText = this._unitFormatter.formatMMValueToUnitString(\n this._dimensions.x * 1000,\n );\n const widthPos = this._dimensionLineGroup.localToWorld(\n widthConfig.mainLine.getCenter(new Vector3()),\n );\n this.clearLineGroup(this._widthLineGroup);\n this.addLinesToLineGroup(\n this._widthLineGroup,\n widthConfig,\n this._mainLineMaterial,\n this._mainLineMaterial,\n );\n if (widthLabelText !== null) {\n this._widthLabel = this.addLabelToLineGroup(\n this._widthLineGroup,\n widthLabelText,\n widthPos,\n );\n }\n\n const heightConfig = this._getHeightLineConfig();\n const heightLabelText = this._unitFormatter.formatMMValueToUnitString(\n this._dimensions.y * 1000,\n );\n const heightPos = this._dimensionLineGroup.localToWorld(\n heightConfig.mainLine.getCenter(new Vector3()),\n );\n this.clearLineGroup(this._heightLineGroup);\n this.addLinesToLineGroup(\n this._heightLineGroup,\n heightConfig,\n this._mainLineMaterial,\n this._mainLineMaterial,\n );\n if (heightLabelText !== null) {\n this._heightLabel = this.addLabelToLineGroup(\n this._heightLineGroup,\n heightLabelText,\n heightPos,\n );\n }\n\n const depthConfig = this._getDepthLineConfig();\n const depthLabelText = this._unitFormatter.formatMMValueToUnitString(\n this._dimensions.z * -1000,\n );\n const depthPos = this._dimensionLineGroup.localToWorld(\n depthConfig.mainLine.getCenter(new Vector3()),\n );\n this.clearLineGroup(this._depthLineGroup);\n this.addLinesToLineGroup(\n this._depthLineGroup,\n depthConfig,\n this._mainLineMaterial,\n this._mainLineMaterial,\n );\n if (depthLabelText !== null) {\n this._depthLabel = this.addLabelToLineGroup(\n this._depthLineGroup,\n depthLabelText,\n depthPos,\n );\n }\n }\n\n private _clear(): void {\n this._lineMaterial.dispose();\n this._mainLineMaterial.dispose();\n [this._widthLineGroup, this._heightLineGroup, this._depthLineGroup].forEach(\n (group) => {\n this.clearLineGroup(group);\n },\n );\n }\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;AAAA,IAAqB,IAArB,MAAmC;CAMjC,YAAY,GAAY;AAEtB,EADA,KAAK,OAAO,GACZ,KAAK,OAAO;;CAGd,QAAgB;AACd,OAAK,WAAW,IAAI,SAAY,GAAS,MAAW;AAElD,GADA,KAAK,WAAW,GAChB,KAAK,UAAU;IACf;;CAGJ,QAAe,GAAmB;AAIhC,EAHI,KACF,KAAK,SAAS,EAAM,EAEtB,KAAK,UAAU;;CAGjB,OAAc,GAAgB;AAC5B,OAAK,QAAQ,EAAE;;CAGjB,OAA0B;AACxB,SAAO,KAAK;;CAGd,QAAe;AACb,OAAK,OAAO;;GCrBV,IAAN,cAA0B,EAAS;CAOlC,YAAa,IAAU,SAAS,cAAe,MAAO,EAAG;AAoCxD,EAlCA,OAAO,EASP,KAAK,gBAAgB,IASrB,KAAK,UAAU,GAEf,KAAK,QAAQ,MAAM,WAAW,YAC9B,KAAK,QAAQ,MAAM,aAAa,QAEhC,KAAK,QAAQ,aAAc,aAAa,GAAO,EAS/C,KAAK,SAAS,IAAI,EAAS,IAAK,GAAK,EAErC,KAAK,iBAAkB,WAAW,WAAY;AAE7C,QAAK,SAAU,SAAW,GAAS;AAElC,IACC,EAAO,WACP,EAAO,mBAAmB,EAAO,QAAQ,cAAc,YAAY,WACnE,EAAO,QAAQ,eAAe,QAG9B,EAAO,QAAQ,QAAQ;KAItB;IAED;;CAIJ,KAAM,GAAQ,GAAY;AAQzB,SANA,MAAM,KAAM,GAAQ,EAAW,EAE/B,KAAK,UAAU,EAAO,QAAQ,UAAW,GAAM,EAE/C,KAAK,SAAS,EAAO,QAEd;;GAQH,IAAU,IAAI,GAAS,EACvB,IAAc,IAAI,GAAS,EAC3B,IA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AAiB,EAC1C,KAAK,oBACH,KAAK,kBACL,GACA,KAAK,mBACL,KAAK,kBACN,EACG,MAAoB,SACtB,KAAK,eAAe,KAAK,oBACvB,KAAK,kBACL,GACA,EACD;EAGH,IAAM,IAAc,KAAK,qBAAqB,EACxC,IAAiB,KAAK,eAAe,0BACzC,KAAK,YAAY,IAAI,KACtB,EACK,IAAW,KAAK,oBAAoB,aACxC,EAAY,SAAS,UAAU,IAAI,GAAS,CAAC,CAC9C;AAQD,EAPA,KAAK,eAAe,KAAK,gBAAgB,EACzC,KAAK,oBACH,KAAK,iBACL,GACA,KAAK,mBACL,KAAK,kBACN,EACG,MAAmB,SACrB,KAAK,cAAc,KAAK,oBACtB,KAAK,iBACL,GACA,EACD;;CAIL,SAAuB;AAGrB,EAFA,KAAK,cAAc,SAAS,EAC5B,KAAK,kBAAkB,SAAS,EAChC;GAAC,KAAK;GAAiB,KAAK;GAAkB,KAAK;GAAgB,CAAC,SACjE,MAAU;AACT,QAAK,eAAe,EAAM;IAE7B;;;GAleF,GAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,kBAAA,KAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"dimensioning-helper-d6JA4UMr.mjs","names":[],"sources":["../../packages/common-core/src/async-guard.ts","../../../../node_modules/three/examples/jsm/renderers/CSS2DRenderer.js","../../packages/configurator-core/src/utils/dimensioning-helper.ts"],"sourcesContent":["export default class AsyncGuard<T> {\n public info: any;\n private _promise: Promise<T>;\n private _resolve: (value?: T | PromiseLike<T>) => void;\n private _reject: (error: Error) => void;\n\n constructor(info?: any) {\n this.info = info;\n this._init();\n }\n\n private _init() {\n this._promise = new Promise<T>((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n }\n\n public resolve(value?: any): void {\n if (value) {\n this._resolve(value);\n }\n this._resolve();\n }\n\n public reject(e: Error): void {\n this._reject(e);\n }\n\n public wait(): Promise<T> {\n return this._promise;\n }\n\n public reset() {\n this._init();\n }\n}\n","import {\n\tMatrix4,\n\tObject3D,\n\tVector2,\n\tVector3\n} from 'three';\n\n/**\n * The only type of 3D object that is supported by {@link CSS2DRenderer}.\n *\n * @augments Object3D\n * @three_import import { CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';\n */\nclass CSS2DObject extends Object3D {\n\n\t/**\n\t * Constructs a new CSS2D object.\n\t *\n\t * @param {HTMLElement} [element] - The DOM element.\n\t */\n\tconstructor( element = document.createElement( 'div' ) ) {\n\n\t\tsuper();\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isCSS2DObject = true;\n\n\t\t/**\n\t\t * The DOM element which defines the appearance of this 3D object.\n\t\t *\n\t\t * @type {HTMLElement}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.element = element;\n\n\t\tthis.element.style.position = 'absolute';\n\t\tthis.element.style.userSelect = 'none';\n\n\t\tthis.element.setAttribute( 'draggable', false );\n\n\t\t/**\n\t\t * The 3D objects center point.\n\t\t * `( 0, 0 )` is the lower left, `( 1, 1 )` is the top right.\n\t\t *\n\t\t * @type {Vector2}\n\t\t * @default (0.5,0.5)\n\t\t */\n\t\tthis.center = new Vector2( 0.5, 0.5 );\n\n\t\tthis.addEventListener( 'removed', function () {\n\n\t\t\tthis.traverse( function ( object ) {\n\n\t\t\t\tif (\n\t\t\t\t\tobject.element &&\n\t\t\t\t\tobject.element instanceof object.element.ownerDocument.defaultView.Element &&\n\t\t\t\t\tobject.element.parentNode !== null\n\t\t\t\t) {\n\n\t\t\t\t\tobject.element.remove();\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t} );\n\n\t}\n\n\tcopy( source, recursive ) {\n\n\t\tsuper.copy( source, recursive );\n\n\t\tthis.element = source.element.cloneNode( true );\n\n\t\tthis.center = source.center;\n\n\t\treturn this;\n\n\t}\n\n}\n\n//\n\nconst _vector = new Vector3();\nconst _viewMatrix = new Matrix4();\nconst _viewProjectionMatrix = new Matrix4();\nconst _a = new Vector3();\nconst _b = new Vector3();\n\n/**\n * This renderer is a simplified version of {@link CSS3DRenderer}. The only transformation that is\n * supported is translation.\n *\n * The renderer is very useful if you want to combine HTML based labels with 3D objects. Here too,\n * the respective DOM elements are wrapped into an instance of {@link CSS2DObject} and added to the\n * scene graph. All other types of renderable 3D objects (like meshes or point clouds) are ignored.\n *\n * `CSS2DRenderer` only supports 100% browser and display zoom.\n *\n * @three_import import { CSS2DRenderer } from 'three/addons/renderers/CSS2DRenderer.js';\n */\nclass CSS2DRenderer {\n\n\t/**\n\t * Constructs a new CSS2D renderer.\n\t *\n\t * @param {CSS2DRenderer~Parameters} [parameters] - The parameters.\n\t */\n\tconstructor( parameters = {} ) {\n\n\t\tconst _this = this;\n\n\t\tlet _width, _height;\n\t\tlet _widthHalf, _heightHalf;\n\n\t\tconst cache = {\n\t\t\tobjects: new WeakMap()\n\t\t};\n\n\t\tconst domElement = parameters.element !== undefined ? parameters.element : document.createElement( 'div' );\n\n\t\tdomElement.style.overflow = 'hidden';\n\n\t\t/**\n\t\t * The DOM where the renderer appends its child-elements.\n\t\t *\n\t\t * @type {HTMLElement}\n\t\t */\n\t\tthis.domElement = domElement;\n\n\t\t/**\n\t\t * Controls whether the renderer assigns `z-index` values to CSS2DObject DOM elements.\n\t\t * If set to `true`, z-index values are assigned first based on the `renderOrder`\n\t\t * and secondly - the distance to the camera. If set to `false`, no z-index values are assigned.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.sortObjects = true;\n\n\t\t/**\n\t\t * Returns an object containing the width and height of the renderer.\n\t\t *\n\t\t * @return {{width:number,height:number}} The size of the renderer.\n\t\t */\n\t\tthis.getSize = function () {\n\n\t\t\treturn {\n\t\t\t\twidth: _width,\n\t\t\t\theight: _height\n\t\t\t};\n\n\t\t};\n\n\t\t/**\n\t\t * Renders the given scene using the given camera.\n\t\t *\n\t\t * @param {Object3D} scene - A scene or any other type of 3D object.\n\t\t * @param {Camera} camera - The camera.\n\t\t */\n\t\tthis.render = function ( scene, camera ) {\n\n\t\t\tif ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();\n\t\t\tif ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();\n\n\t\t\t_viewMatrix.copy( camera.matrixWorldInverse );\n\t\t\t_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );\n\n\t\t\trenderObject( scene, scene, camera );\n\t\t\tif ( this.sortObjects ) zOrder( scene );\n\n\t\t};\n\n\t\t/**\n\t\t * Resizes the renderer to the given width and height.\n\t\t *\n\t\t * @param {number} width - The width of the renderer.\n\t\t * @param {number} height - The height of the renderer.\n\t\t */\n\t\tthis.setSize = function ( width, height ) {\n\n\t\t\t_width = width;\n\t\t\t_height = height;\n\n\t\t\t_widthHalf = _width / 2;\n\t\t\t_heightHalf = _height / 2;\n\n\t\t\tdomElement.style.width = width + 'px';\n\t\t\tdomElement.style.height = height + 'px';\n\n\t\t};\n\n\t\tfunction hideObject( object ) {\n\n\t\t\tif ( object.isCSS2DObject ) object.element.style.display = 'none';\n\n\t\t\tfor ( let i = 0, l = object.children.length; i < l; i ++ ) {\n\n\t\t\t\thideObject( object.children[ i ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction renderObject( object, scene, camera ) {\n\n\t\t\tif ( object.visible === false ) {\n\n\t\t\t\thideObject( object );\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( object.isCSS2DObject ) {\n\n\t\t\t\t_vector.setFromMatrixPosition( object.matrixWorld );\n\t\t\t\t_vector.applyMatrix4( _viewProjectionMatrix );\n\n\t\t\t\tconst visible = ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );\n\n\t\t\t\tconst element = object.element;\n\t\t\t\telement.style.display = visible === true ? '' : 'none';\n\n\t\t\t\tif ( visible === true ) {\n\n\t\t\t\t\tobject.onBeforeRender( _this, scene, camera );\n\n\t\t\t\t\telement.style.transform = 'translate(' + ( - 100 * object.center.x ) + '%,' + ( - 100 * object.center.y ) + '%)' + 'translate(' + ( _vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - _vector.y * _heightHalf + _heightHalf ) + 'px)';\n\n\t\t\t\t\tif ( element.parentNode !== domElement ) {\n\n\t\t\t\t\t\tdomElement.appendChild( element );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tobject.onAfterRender( _this, scene, camera );\n\n\t\t\t\t}\n\n\t\t\t\tconst objectData = {\n\t\t\t\t\tdistanceToCameraSquared: getDistanceToSquared( camera, object )\n\t\t\t\t};\n\n\t\t\t\tcache.objects.set( object, objectData );\n\n\t\t\t}\n\n\t\t\tfor ( let i = 0, l = object.children.length; i < l; i ++ ) {\n\n\t\t\t\trenderObject( object.children[ i ], scene, camera );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction getDistanceToSquared( object1, object2 ) {\n\n\t\t\t_a.setFromMatrixPosition( object1.matrixWorld );\n\t\t\t_b.setFromMatrixPosition( object2.matrixWorld );\n\n\t\t\treturn _a.distanceToSquared( _b );\n\n\t\t}\n\n\t\tfunction filterAndFlatten( scene ) {\n\n\t\t\tconst result = [];\n\n\t\t\tscene.traverseVisible( function ( object ) {\n\n\t\t\t\tif ( object.isCSS2DObject ) result.push( object );\n\n\t\t\t} );\n\n\t\t\treturn result;\n\n\t\t}\n\n\t\tfunction zOrder( scene ) {\n\n\t\t\tconst sorted = filterAndFlatten( scene ).sort( function ( a, b ) {\n\n\t\t\t\tif ( a.renderOrder !== b.renderOrder ) {\n\n\t\t\t\t\treturn b.renderOrder - a.renderOrder;\n\n\t\t\t\t}\n\n\t\t\t\tconst distanceA = cache.objects.get( a ).distanceToCameraSquared;\n\t\t\t\tconst distanceB = cache.objects.get( b ).distanceToCameraSquared;\n\n\t\t\t\treturn distanceA - distanceB;\n\n\t\t\t} );\n\n\t\t\tconst zMax = sorted.length;\n\n\t\t\tfor ( let i = 0, l = sorted.length; i < l; i ++ ) {\n\n\t\t\t\tsorted[ i ].element.style.zIndex = zMax - i;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\n/**\n * Constructor parameters of `CSS2DRenderer`.\n *\n * @typedef {Object} CSS2DRenderer~Parameters\n * @property {HTMLElement} [element] - A DOM element where the renderer appends its child-elements.\n * If not passed in here, a new div element will be created.\n **/\n\nexport { CSS2DObject, CSS2DRenderer };\n","import inject from '../../../common-core/src/di/inject';\nimport AsyncGuard from '../../../common-core/src/async-guard';\nimport type { Object3D, Camera } from 'three';\nimport { Group, type Scene } from 'three';\nimport { Box3 } from 'three';\nimport {\n BufferAttribute,\n BufferGeometry,\n Line,\n Line3,\n LineBasicMaterial,\n Vector3,\n} from 'three';\nimport { type KernelCube } from '../../../typings/kernel';\nimport { convertToTHREE } from '../../../common-core/src/utils/kernel-utils';\nimport type UnitFormatter from '../services/unit-formatter';\nimport { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';\nimport { LAYER } from '../../../common-core/src/webgl/layer';\n\nexport const DIMENSIONING_GEOMETRY = 'dimensioning';\nexport const DIMENSION_LINE_OFFSET = 0.08;\nexport const MIN_CAMERA_DISTANCE_RATIO = 1.2;\nexport const FADE_DISTANCE_RATIO = 2.0;\nexport const EXTENSION_LINE_LENGTH_RATIO = 0.03;\n\nexport const shouldHideDimensionLabel = (\n labelValueInMeters: number,\n distance: number,\n): boolean => {\n labelValueInMeters = Math.abs(labelValueInMeters);\n return labelValueInMeters < distance * 0.05 && distance > 3;\n};\n\nexport interface DimensionLineConfig {\n mainLine: Line3;\n extensionLines: Line3[];\n}\n\nconst LINE_COLOR = 0x373737;\n\nexport function createDimensioningHelper(creator: string): DimensioningHelper {\n return new DimensioningHelper(creator);\n}\n\nexport default class DimensioningHelper {\n public _creator_: string;\n\n @inject\n private _unitFormatter: UnitFormatter;\n\n private _object: Object3D;\n private _cameraPosition: Vector3 = new Vector3();\n private _onVisibilityChange: (visible: boolean) => void;\n private _initialized: AsyncGuard<void> = new AsyncGuard();\n\n private _origin: Vector3;\n private _dimensions: Vector3;\n\n private _lineMaterial: LineBasicMaterial;\n private readonly _mainLineMaterial: LineBasicMaterial;\n\n private readonly _widthLineGroup: Group;\n private readonly _heightLineGroup: Group;\n private readonly _depthLineGroup: Group;\n\n private _widthLabel: CSS2DObject;\n private _heightLabel: CSS2DObject;\n private _depthLabel: CSS2DObject;\n\n private _enabled: boolean = false;\n private _dimensionsVisible = false;\n\n private _dimensionLineGroup = new Group();\n\n constructor(creator: string) {\n this._creator_ = creator;\n\n this._lineMaterial = new LineBasicMaterial({\n color: LINE_COLOR,\n linewidth: 2,\n });\n\n this._mainLineMaterial = new LineBasicMaterial({\n color: LINE_COLOR,\n linewidth: 0.001,\n transparent: true,\n opacity: 1.0,\n });\n\n this._dimensionLineGroup.name = DIMENSIONING_GEOMETRY;\n\n this._widthLineGroup = this._createLineGroup('width');\n this._heightLineGroup = this._createLineGroup('height');\n this._depthLineGroup = this._createLineGroup('depth');\n\n this._dimensionLineGroup.add(this._widthLineGroup);\n this._dimensionLineGroup.add(this._heightLineGroup);\n this._dimensionLineGroup.add(this._depthLineGroup);\n\n this.update(false);\n this._initialized.resolve();\n }\n\n private _createLineGroup(_name: string): Group {\n const group = new Group();\n group.name = DIMENSIONING_GEOMETRY;\n group.userData.ignoreComponentRaycast = true;\n return group;\n }\n\n private _createLineFromConfig(\n config: Line3,\n material: LineBasicMaterial,\n ): Line {\n const geometry = new BufferGeometry();\n const vertices = [\n config.start.x,\n config.start.y,\n config.start.z,\n config.end.x,\n config.end.y,\n config.end.z,\n ];\n geometry.setAttribute(\n 'position',\n new BufferAttribute(new Float32Array(vertices), 3),\n );\n const line = new Line(geometry, material);\n line.name = DIMENSIONING_GEOMETRY;\n line.userData.ignoreComponentRaycast = true;\n line.layers.set(LAYER.DIMENSIONS);\n return line;\n }\n\n private addLinesToLineGroup(\n group: Group,\n config: DimensionLineConfig,\n mainMaterial: LineBasicMaterial,\n extMaterial: LineBasicMaterial,\n ) {\n config.extensionLines.forEach((extLine) => {\n group.add(this._createLineFromConfig(extLine, extMaterial));\n });\n\n group.add(this._createLineFromConfig(config.mainLine, mainMaterial));\n }\n\n private clearLineGroup(group: Group) {\n while (group.children.length > 0) {\n const child = group.children[0];\n if (child instanceof Line) {\n child.geometry.dispose();\n }\n group.remove(child);\n }\n }\n\n private addLabelToLineGroup(\n group: Group,\n labelText: string,\n labelWorldPosition: Vector3,\n ): CSS2DObject {\n const labelHtmlDiv = document.createElement('div');\n labelHtmlDiv.classList.add(\n 'dimension-label',\n 'dimension-label--primary',\n 'dimension-label--disabled',\n );\n const labelHtmlSpan = document.createElement('span');\n labelHtmlSpan.classList.add('dimension-label__value');\n labelHtmlSpan.innerHTML = labelText;\n labelHtmlDiv.appendChild(labelHtmlSpan);\n\n const label = new CSS2DObject(labelHtmlDiv);\n const labelLocalPosition =\n this._dimensionLineGroup.worldToLocal(labelWorldPosition);\n label.position.copy(labelLocalPosition);\n\n group.add(label);\n return label;\n }\n\n private _getWidthLineConfig(): DimensionLineConfig {\n const offset = DIMENSION_LINE_OFFSET;\n const extLength = EXTENSION_LINE_LENGTH_RATIO;\n const y = this._dimensions.y + offset;\n const localCam = this._getLocalCameraPosition();\n const z = localCam.z < this._dimensions.z / 2 ? 0 : this._dimensions.z;\n\n return {\n mainLine: new Line3(\n new Vector3(0, y, z),\n new Vector3(this._dimensions.x, y, z),\n ),\n extensionLines: [\n new Line3(\n new Vector3(0, y - extLength, z),\n new Vector3(0, y + extLength, z),\n ),\n new Line3(\n new Vector3(this._dimensions.x, y - extLength, z),\n new Vector3(this._dimensions.x, y + extLength, z),\n ),\n ],\n };\n }\n\n private _getDepthLineConfig(): DimensionLineConfig {\n const offset = DIMENSION_LINE_OFFSET;\n const extLength = EXTENSION_LINE_LENGTH_RATIO;\n const y = 0;\n const localCam = this._getLocalCameraPosition();\n const x =\n localCam.x < this._dimensions.x / 2\n ? -offset\n : this._dimensions.x + offset;\n\n return {\n mainLine: new Line3(\n new Vector3(x, y, this._dimensions.z),\n new Vector3(x, y, 0),\n ),\n extensionLines: [\n new Line3(\n new Vector3(x - extLength, y, 0),\n new Vector3(x + extLength, y, 0),\n ),\n new Line3(\n new Vector3(x - extLength, y, this._dimensions.z),\n new Vector3(x + extLength, y, this._dimensions.z),\n ),\n ],\n };\n }\n\n private _getHeightLineConfig(): DimensionLineConfig {\n const offset = DIMENSION_LINE_OFFSET;\n const extLength = EXTENSION_LINE_LENGTH_RATIO;\n const localCam = this._getLocalCameraPosition();\n const x =\n localCam.x < this._dimensions.x / 2\n ? -offset\n : this._dimensions.x + offset;\n const z = localCam.z < this._dimensions.z / 2 ? 0 : this._dimensions.z;\n\n return {\n mainLine: new Line3(\n new Vector3(x, 0, z),\n new Vector3(x, this._dimensions.y, z),\n ),\n extensionLines: [\n new Line3(\n new Vector3(x - extLength, 0, z),\n new Vector3(x + extLength, 0, z),\n ),\n new Line3(\n new Vector3(x - extLength, this._dimensions.y, z),\n new Vector3(x + extLength, this._dimensions.y, z),\n ),\n ],\n };\n }\n\n private _getLocalCameraPosition(): Vector3 {\n if (\n !this._cameraPosition ||\n !this._dimensionLineGroup ||\n !this._dimensions\n ) {\n return new Vector3(0, 0, 0);\n }\n return this._dimensionLineGroup.worldToLocal(this._cameraPosition.clone());\n }\n\n private _getCameraDistanceInfo(): {\n tooClose: boolean;\n opacity: number;\n distance: number;\n } {\n if (!this._object || !this._cameraPosition || !this._dimensions) {\n return { tooClose: false, opacity: 1.0, distance: Infinity };\n }\n const objPos = this._object.getWorldPosition(new Vector3());\n const distance = this._cameraPosition.distanceTo(objPos);\n const objectRadius =\n Math.max(this._dimensions.x, this._dimensions.y, this._dimensions.z) / 2;\n const minThreshold = objectRadius * MIN_CAMERA_DISTANCE_RATIO;\n const fadeThreshold = objectRadius * FADE_DISTANCE_RATIO;\n\n if (distance < minThreshold) {\n return { tooClose: true, opacity: 0, distance };\n }\n if (distance < fadeThreshold) {\n const opacity =\n (distance - minThreshold) / (fadeThreshold - minThreshold);\n return {\n tooClose: false,\n opacity: Math.max(0, Math.min(1, opacity)),\n distance,\n };\n }\n return { tooClose: false, opacity: 1.0, distance };\n }\n\n private _visibilityChangedCallback() {\n if (this._onVisibilityChange) {\n this._onVisibilityChange(this._dimensionsVisible);\n }\n }\n\n public updateDimensionLabelVisibility(camera: Camera) {\n const cameraPosition = new Vector3();\n camera.getWorldPosition(cameraPosition);\n\n this._cameraPosition = cameraPosition;\n this.update();\n\n const checkVisibility = (\n label: CSS2DObject,\n labelValueInMeters: number,\n ) => {\n if (!label) {\n return;\n }\n const labelPosition = label.getWorldPosition(new Vector3());\n const cameraDistanceToLabel = cameraPosition.distanceTo(labelPosition);\n label.visible = !shouldHideDimensionLabel(\n labelValueInMeters,\n cameraDistanceToLabel,\n );\n };\n\n checkVisibility(this._widthLabel, this._dimensions.x);\n checkVisibility(this._heightLabel, this._dimensions.y);\n checkVisibility(this._depthLabel, this._dimensions.z);\n }\n\n public update(force: boolean = false) {\n if (this._enabled && !this._dimensionsVisible) {\n this._dimensionsVisible = true;\n this._visibilityChangedCallback();\n }\n this._performUpdate(force);\n }\n\n public updateSize(boxForMeasurement: KernelCube) {\n this._origin = convertToTHREE(boxForMeasurement.origin);\n this._dimensionLineGroup.position.x =\n this._origin.x - this._object.position.x;\n this._dimensionLineGroup.position.y =\n this._origin.y - this._object.position.y;\n this._dimensionLineGroup.position.z =\n this._origin.z - this._object.position.z;\n this._dimensions = convertToTHREE(boxForMeasurement.size);\n this.update();\n }\n\n public removeFromObject(object: Object3D) {\n if (object) {\n object.remove(this._dimensionLineGroup);\n }\n }\n\n public onDimensionsVisibilityChanged(handler: (visible: boolean) => void) {\n this._onVisibilityChange = handler;\n }\n\n public setObject(object: Object3D): void {\n this._object = object;\n }\n\n public isInitialized(): Promise<void> {\n return this._initialized.wait();\n }\n\n public areDimensionsEnabled(): boolean {\n return this._enabled;\n }\n\n public clearScene(_scene: Scene): void {\n this._clear();\n }\n\n public addToObject(object: Object3D): void {\n if (!object || !this._dimensionLineGroup) {\n return;\n }\n object.add(this._dimensionLineGroup);\n }\n\n public enableDimensions(): void {\n this._enabled = true;\n this.addToObject(this._object);\n this.update(true);\n }\n\n public disableDimensions(): void {\n this._enabled = false;\n if (this._dimensionsVisible) {\n this._dimensionsVisible = false;\n this._visibilityChangedCallback();\n }\n this._clear();\n this.removeFromObject(this._object);\n }\n\n public enableTopDimensions(): void {\n this.enableDimensions();\n this._heightLineGroup.visible = false;\n this.update(true);\n }\n\n public disableTopDimensions(): void {\n this._heightLineGroup.visible = true;\n this.disableDimensions();\n }\n\n public getBoundingBox(): Box3 {\n const bbox = new Box3();\n bbox.expandByObject(this._dimensionLineGroup);\n return bbox;\n }\n\n public setCameraPosition(position: Vector3): void {\n this._cameraPosition = position;\n this.update();\n }\n\n private _performUpdate(force: boolean): void {\n if (!this._enabled && !force) {\n return;\n }\n if (!this._dimensions) {\n return;\n }\n\n let opacity = 1.0;\n\n if (\n this._object &&\n this._cameraPosition &&\n !this._cameraPosition.equals(new Vector3(0, 0, 0))\n ) {\n const distanceCheck = this._getCameraDistanceInfo();\n if (distanceCheck.tooClose) {\n this._dimensionLineGroup.visible = false;\n } else {\n this._dimensionLineGroup.visible = true;\n opacity = distanceCheck.opacity;\n this._mainLineMaterial.opacity = opacity;\n }\n }\n\n this._dimensionLineGroup.updateMatrixWorld(true);\n\n const widthConfig = this._getWidthLineConfig();\n const widthLabelText = this._unitFormatter.formatMMValueToUnitString(\n this._dimensions.x * 1000,\n );\n const widthPos = this._dimensionLineGroup.localToWorld(\n widthConfig.mainLine.getCenter(new Vector3()),\n );\n this.clearLineGroup(this._widthLineGroup);\n this.addLinesToLineGroup(\n this._widthLineGroup,\n widthConfig,\n this._mainLineMaterial,\n this._mainLineMaterial,\n );\n if (widthLabelText !== null) {\n this._widthLabel = this.addLabelToLineGroup(\n this._widthLineGroup,\n widthLabelText,\n widthPos,\n );\n }\n\n const heightConfig = this._getHeightLineConfig();\n const heightLabelText = this._unitFormatter.formatMMValueToUnitString(\n this._dimensions.y * 1000,\n );\n const heightPos = this._dimensionLineGroup.localToWorld(\n heightConfig.mainLine.getCenter(new Vector3()),\n );\n this.clearLineGroup(this._heightLineGroup);\n this.addLinesToLineGroup(\n this._heightLineGroup,\n heightConfig,\n this._mainLineMaterial,\n this._mainLineMaterial,\n );\n if (heightLabelText !== null) {\n this._heightLabel = this.addLabelToLineGroup(\n this._heightLineGroup,\n heightLabelText,\n heightPos,\n );\n }\n\n const depthConfig = this._getDepthLineConfig();\n const depthLabelText = this._unitFormatter.formatMMValueToUnitString(\n this._dimensions.z * -1000,\n );\n const depthPos = this._dimensionLineGroup.localToWorld(\n depthConfig.mainLine.getCenter(new Vector3()),\n );\n this.clearLineGroup(this._depthLineGroup);\n this.addLinesToLineGroup(\n this._depthLineGroup,\n depthConfig,\n this._mainLineMaterial,\n this._mainLineMaterial,\n );\n if (depthLabelText !== null) {\n this._depthLabel = this.addLabelToLineGroup(\n this._depthLineGroup,\n depthLabelText,\n depthPos,\n );\n }\n }\n\n private _clear(): void {\n this._lineMaterial.dispose();\n this._mainLineMaterial.dispose();\n [this._widthLineGroup, this._heightLineGroup, this._depthLineGroup].forEach(\n (group) => {\n this.clearLineGroup(group);\n },\n );\n }\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;AAAA,IAAqB,IAArB,MAAmC;CAMjC,YAAY,GAAY;AAEtB,EADA,KAAK,OAAO,GACZ,KAAK,OAAO;;CAGd,QAAgB;AACd,OAAK,WAAW,IAAI,SAAY,GAAS,MAAW;AAElD,GADA,KAAK,WAAW,GAChB,KAAK,UAAU;IACf;;CAGJ,QAAe,GAAmB;AAIhC,EAHI,KACF,KAAK,SAAS,EAAM,EAEtB,KAAK,UAAU;;CAGjB,OAAc,GAAgB;AAC5B,OAAK,QAAQ,EAAE;;CAGjB,OAA0B;AACxB,SAAO,KAAK;;CAGd,QAAe;AACb,OAAK,OAAO;;GCrBV,IA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gB,CAAC,SACjE,MAAU;AACT,QAAK,eAAe,EAAM;IAE7B;;;GAleF,GAAA,EAAA,eAAA,OAAA,CAAA,EAAA,EAAA,WAAA,kBAAA,KAAA,EAAA"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { dt as e, h as t } from "./threejs-utils-
|
|
2
|
-
import {
|
|
3
|
-
import { r as u } from "./three.module-
|
|
1
|
+
import { dt as e, h as t } from "./threejs-utils-CElderZe.mjs";
|
|
2
|
+
import { Br as n, Ln as r, On as i, Si as a, f as o, n as s, nt as c, w as l } from "./three.core-tV_4n8Wg.mjs";
|
|
3
|
+
import { r as u } from "./three.module-DC5fF9Zl.mjs";
|
|
4
4
|
import { n as d, r as f, t as p } from "./decorate-C9r0zXzz.mjs";
|
|
5
|
-
import { g as m, v as h } from "./common-utils-
|
|
6
|
-
import { $ as g, D as _, I as v, K as y, Q as b, T as x, Z as S, at as C, h as w, it as T, m as E, n as D, nt as O, p as k, r as A, rt as j, t as M, u as N, w as P } from "./main-
|
|
7
|
-
import { t as F } from "./script-loader-
|
|
5
|
+
import { g as m, v as h } from "./common-utils-B9PC_rvS.mjs";
|
|
6
|
+
import { $ as g, D as _, I as v, K as y, Q as b, T as x, Z as S, at as C, h as w, it as T, m as E, n as D, nt as O, p as k, r as A, rt as j, t as M, u as N, w as P } from "./main-QTvbXAvy.mjs";
|
|
7
|
+
import { t as F } from "./script-loader-3LiaLeLT.mjs";
|
|
8
8
|
//#region packages/glb-viewer-core/src/camera-control/adjustable-camera-control-3d.ts
|
|
9
9
|
var I = class extends P {
|
|
10
10
|
constructor(...e) {
|
|
11
11
|
super(...e), this.shouldIgnoreStandardBehavior = !1;
|
|
12
12
|
}
|
|
13
|
-
adjust(e, t, n,
|
|
14
|
-
this._boundingBox = new
|
|
15
|
-
let l = new
|
|
13
|
+
adjust(e, t, n, i, s) {
|
|
14
|
+
this._boundingBox = new o(new a(-e.x / 2, 0, -e.z / 2), new a(e.x / 2, e.y, e.z / 2));
|
|
15
|
+
let l = new c(-Math.PI / 2 + i, n, 0, "ZYX"), u = new r().setFromEuler(l);
|
|
16
16
|
this._camera.updateProjectionMatrix(), this._camera.quaternion.copy(u), this._camera.position.copy(t);
|
|
17
17
|
}
|
|
18
18
|
_update(e) {
|
|
@@ -23,7 +23,7 @@ var I = class extends P {
|
|
|
23
23
|
}
|
|
24
24
|
}, L = class extends _ {
|
|
25
25
|
constructor(e, t) {
|
|
26
|
-
super(e, t), this._params = { ambientLight: { color: "#ffffff" } }, this._ambientLight = new
|
|
26
|
+
super(e, t), this._params = { ambientLight: { color: "#ffffff" } }, this._ambientLight = new s(new l(this._params.ambientLight.color), .5), this.addToScene();
|
|
27
27
|
}
|
|
28
28
|
addToScene() {
|
|
29
29
|
this._scene.add(this._ambientLight);
|
|
@@ -38,7 +38,7 @@ var I = class extends P {
|
|
|
38
38
|
if (this._ambientLight) {
|
|
39
39
|
let t = e.addFolder("Ambient Light");
|
|
40
40
|
t.add(this._ambientLight, "visible"), t.add(this._ambientLight, "intensity").min(0).max(5).step(.1), t.addColor(this._params.ambientLight, "color").onChange((e) => {
|
|
41
|
-
this._ambientLight.color = new
|
|
41
|
+
this._ambientLight.color = new l(e);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -61,46 +61,46 @@ var I = class extends P {
|
|
|
61
61
|
let r = h(n);
|
|
62
62
|
return r ? this.loadGLB(r, !0, void 0, t) : Promise.reject(/* @__PURE__ */ Error("GLB Url not detected"));
|
|
63
63
|
}
|
|
64
|
-
loadGLB(e, t = !0, n = new
|
|
65
|
-
return this.clearScene(), new Promise((i,
|
|
66
|
-
this._loadGLB(e, new
|
|
64
|
+
loadGLB(e, t = !0, n = new a(1, 1, 1), r) {
|
|
65
|
+
return this.clearScene(), new Promise((i, s) => {
|
|
66
|
+
this._loadGLB(e, new a(0, 0, 0), 0, void 0, n, void 0, void 0, r).then((e) => {
|
|
67
67
|
this._currentGLB = e, this._scene.add(this._currentGLB);
|
|
68
|
-
let n = new
|
|
68
|
+
let n = new o().setFromObject(this._currentGLB);
|
|
69
69
|
t && this.cameraBehaviour.cameraControl instanceof I && this.glbViewerCameraBehaviour.updateCameraOnItemLoaded(n), this._updateBounds(n, void 0, !0), this._readyForRender(), i();
|
|
70
|
-
},
|
|
70
|
+
}, s);
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
preparePerspectiveImage(t = {},
|
|
74
|
-
let
|
|
75
|
-
if (
|
|
73
|
+
preparePerspectiveImage(t = {}, r) {
|
|
74
|
+
let a, o, s;
|
|
75
|
+
if (r) a = r, o = a.domElement.width, s = a.domElement.height;
|
|
76
76
|
else {
|
|
77
77
|
let e = t.size ?? 1e3;
|
|
78
|
-
|
|
78
|
+
o = e, s = e, a = new u({ antialias: !0 }), a.setSize(o, s), a.outputColorSpace = n, a.autoClear = !1, a.shadowMap.enabled = !0, a.shadowMap.type = 0;
|
|
79
79
|
}
|
|
80
|
-
return new Promise((n,
|
|
80
|
+
return new Promise((n, r) => {
|
|
81
81
|
let c = this.cameraBehaviour.cameraControl.getCamera().clone();
|
|
82
|
-
c instanceof
|
|
82
|
+
c instanceof i && (c.aspect = o / s, c.updateProjectionMatrix());
|
|
83
83
|
let l = this.getBounds();
|
|
84
|
-
if (l && c instanceof
|
|
84
|
+
if (l && c instanceof i) {
|
|
85
85
|
let n = k.getCameraTargetForBBox(l), r = -30 + e(t.rotationY ?? 0);
|
|
86
86
|
k.placeCameraForPerspectiveImage(c, n, -20, r);
|
|
87
87
|
}
|
|
88
88
|
this._lightSetting?.removeFromScene();
|
|
89
89
|
let u = new E(this._scene), d = t.preserveSceneBackground ?? !0, f = this._scene.fog, p = this._scene.background, m;
|
|
90
90
|
try {
|
|
91
|
-
d || (this._scene.background = null, this._scene.fog = null),
|
|
91
|
+
d || (this._scene.background = null, this._scene.fog = null), a.render(this._scene, c), m = a.domElement.toDataURL();
|
|
92
92
|
} finally {
|
|
93
93
|
d || (this._scene.background = p, this._scene.fog = f), u.removeFromScene(), this._lightSetting?.addToScene();
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
a.domElement.toBlob((e) => {
|
|
96
96
|
if (e === null) {
|
|
97
|
-
|
|
97
|
+
r(/* @__PURE__ */ Error("Failed to create blob from canvas"));
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
n({
|
|
101
101
|
image: m,
|
|
102
|
-
width:
|
|
103
|
-
height:
|
|
102
|
+
width: o,
|
|
103
|
+
height: s,
|
|
104
104
|
blob: e
|
|
105
105
|
});
|
|
106
106
|
}, "image/png");
|
|
@@ -108,7 +108,7 @@ var I = class extends P {
|
|
|
108
108
|
}
|
|
109
109
|
adjustCamera(e, t, n, r) {
|
|
110
110
|
if (this.cameraBehaviour.cameraControl instanceof I) {
|
|
111
|
-
let i = new
|
|
111
|
+
let i = new o().setFromObject(this._scene).getSize(new a());
|
|
112
112
|
this.cameraBehaviour.cameraControl.adjust(i, e, t, n, r), this._requestRender();
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -129,7 +129,7 @@ var I = class extends P {
|
|
|
129
129
|
}
|
|
130
130
|
sceneChanged() {}
|
|
131
131
|
getBounds() {
|
|
132
|
-
return this._currentGLB ? new
|
|
132
|
+
return this._currentGLB ? new o().setFromObject(this._currentGLB) : null;
|
|
133
133
|
}
|
|
134
134
|
get glbViewerCameraBehaviour() {
|
|
135
135
|
return this.cameraBehaviour;
|
|
@@ -155,11 +155,11 @@ p([f, d("design:type", Object)], R.prototype, "_glbInputManager", void 0), p([f,
|
|
|
155
155
|
//#endregion
|
|
156
156
|
//#region packages/glb-viewer-core/src/services/glb-render-worker.ts
|
|
157
157
|
var z = class {
|
|
158
|
-
constructor(e, t,
|
|
158
|
+
constructor(e, t, r) {
|
|
159
159
|
this._prefix = "https://furniture.roomle.com/3d/glb/", this._listeners = /* @__PURE__ */ new Set(), this._finishedItems = 0, this._sceneManager = e, this._renderer = new u({
|
|
160
160
|
antialias: !0,
|
|
161
161
|
alpha: !0
|
|
162
|
-
}), this._width = t, this._height =
|
|
162
|
+
}), this._width = t, this._height = r, this._renderer.setSize(t, r), this._renderer.setClearColor(16777215, 0), this._renderer.outputColorSpace = n;
|
|
163
163
|
}
|
|
164
164
|
addListener(e) {
|
|
165
165
|
this._listeners.add(e);
|
|
@@ -178,7 +178,7 @@ var z = class {
|
|
|
178
178
|
return {
|
|
179
179
|
name: e.path.replace(".glb", ".png"),
|
|
180
180
|
url: this._prefix + e.path,
|
|
181
|
-
position: new
|
|
181
|
+
position: new a(e.camera.position.x, e.camera.position.z, -e.camera.position.y),
|
|
182
182
|
fov: e.camera.fieldOfView * 2,
|
|
183
183
|
yaw: e.camera.rotation.z,
|
|
184
184
|
pitch: e.camera.rotation.x
|
|
@@ -226,7 +226,7 @@ var z = class {
|
|
|
226
226
|
this._sceneManager.clearScene();
|
|
227
227
|
}
|
|
228
228
|
loadGLB(e, t = 1, n) {
|
|
229
|
-
return this._currentIdOrUrl = e, this._rapiAccess.trackView(e), this._sceneManager.loadGLB(e, !0, new
|
|
229
|
+
return this._currentIdOrUrl = e, this._rapiAccess.trackView(e), this._sceneManager.loadGLB(e, !0, new a(t, t, t), n);
|
|
230
230
|
}
|
|
231
231
|
loadStaticItem(e, t) {
|
|
232
232
|
return this._currentIdOrUrl = e, this._rapiAccess.trackView(e), this._sceneManager.loadStaticItem(e, t);
|
|
@@ -328,4 +328,4 @@ var H = class extends v {}, U = [
|
|
|
328
328
|
//#endregion
|
|
329
329
|
export { V as n, W as t };
|
|
330
330
|
|
|
331
|
-
//# sourceMappingURL=glb-viewer-
|
|
331
|
+
//# sourceMappingURL=glb-viewer-BJJ9OIlH.mjs.map
|