vim-web 0.3.43 → 0.3.44-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/types/core-viewers/ultra/viewer/camera.d.ts +1 -13
  2. package/dist/types/core-viewers/ultra/viewer/marshal.d.ts +37 -24
  3. package/dist/types/core-viewers/ultra/viewer/renderer.d.ts +3 -1
  4. package/dist/types/core-viewers/ultra/viewer/rpcClient.d.ts +9 -7
  5. package/dist/types/core-viewers/ultra/viewer/rpcSafeClient.d.ts +9 -1
  6. package/dist/types/core-viewers/ultra/viewer/sectionBox.d.ts +31 -0
  7. package/dist/types/core-viewers/ultra/viewer/socketClient.d.ts +4 -2
  8. package/dist/types/core-viewers/ultra/viewer/viewer.d.ts +5 -0
  9. package/dist/types/core-viewers/webgl/viewer/camera/ICamera.d.ts +102 -0
  10. package/dist/types/core-viewers/webgl/viewer/environment/cameraLight.d.ts +1 -1
  11. package/dist/types/core-viewers/webgl/viewer/environment/environment.d.ts +1 -1
  12. package/dist/types/core-viewers/webgl/viewer/environment/skybox.d.ts +1 -1
  13. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/SectionBoxMesh.d.ts +15 -0
  14. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBox.d.ts +55 -21
  15. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxGizmo.d.ts +13 -43
  16. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxHandle.d.ts +15 -0
  17. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxHandles.d.ts +19 -0
  18. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxInputs.d.ts +143 -28
  19. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxOutline.d.ts +15 -0
  20. package/dist/types/core-viewers/webgl/viewer/inputs/input.d.ts +4 -4
  21. package/dist/types/core-viewers/webgl/viewer/viewer.d.ts +1 -1
  22. package/dist/vim-web.iife.js +1118 -600
  23. package/dist/vim-web.iife.js.map +1 -1
  24. package/dist/vim-web.js +1118 -600
  25. package/dist/vim-web.js.map +1 -1
  26. package/package.json +1 -1
  27. /package/dist/types/core-viewers/webgl/viewer/inputs/{keyboard.d.ts → keyboardHandler.d.ts} +0 -0
  28. /package/dist/types/core-viewers/webgl/viewer/inputs/{mouse.d.ts → mouseHandler.d.ts} +0 -0
  29. /package/dist/types/core-viewers/webgl/viewer/inputs/{touch.d.ts → touchHandler.d.ts} +0 -0
@@ -47164,6 +47164,154 @@ void main() {
47164
47164
  this.scene.dispose();
47165
47165
  }
47166
47166
  };
47167
+ function mergeGeometries(geometries, useGroups = false) {
47168
+ const isIndexed = geometries[0].index !== null;
47169
+ const attributesUsed = new Set(Object.keys(geometries[0].attributes));
47170
+ const morphAttributesUsed = new Set(Object.keys(geometries[0].morphAttributes));
47171
+ const attributes = {};
47172
+ const morphAttributes = {};
47173
+ const morphTargetsRelative = geometries[0].morphTargetsRelative;
47174
+ const mergedGeometry = new BufferGeometry();
47175
+ let offset = 0;
47176
+ for (let i2 = 0; i2 < geometries.length; ++i2) {
47177
+ const geometry = geometries[i2];
47178
+ let attributesCount = 0;
47179
+ if (isIndexed !== (geometry.index !== null)) {
47180
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i2 + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
47181
+ return null;
47182
+ }
47183
+ for (const name in geometry.attributes) {
47184
+ if (!attributesUsed.has(name)) {
47185
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i2 + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.');
47186
+ return null;
47187
+ }
47188
+ if (attributes[name] === void 0) attributes[name] = [];
47189
+ attributes[name].push(geometry.attributes[name]);
47190
+ attributesCount++;
47191
+ }
47192
+ if (attributesCount !== attributesUsed.size) {
47193
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i2 + ". Make sure all geometries have the same number of attributes.");
47194
+ return null;
47195
+ }
47196
+ if (morphTargetsRelative !== geometry.morphTargetsRelative) {
47197
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i2 + ". .morphTargetsRelative must be consistent throughout all geometries.");
47198
+ return null;
47199
+ }
47200
+ for (const name in geometry.morphAttributes) {
47201
+ if (!morphAttributesUsed.has(name)) {
47202
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i2 + ". .morphAttributes must be consistent throughout all geometries.");
47203
+ return null;
47204
+ }
47205
+ if (morphAttributes[name] === void 0) morphAttributes[name] = [];
47206
+ morphAttributes[name].push(geometry.morphAttributes[name]);
47207
+ }
47208
+ if (useGroups) {
47209
+ let count;
47210
+ if (isIndexed) {
47211
+ count = geometry.index.count;
47212
+ } else if (geometry.attributes.position !== void 0) {
47213
+ count = geometry.attributes.position.count;
47214
+ } else {
47215
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i2 + ". The geometry must have either an index or a position attribute");
47216
+ return null;
47217
+ }
47218
+ mergedGeometry.addGroup(offset, count, i2);
47219
+ offset += count;
47220
+ }
47221
+ }
47222
+ if (isIndexed) {
47223
+ let indexOffset = 0;
47224
+ const mergedIndex = [];
47225
+ for (let i2 = 0; i2 < geometries.length; ++i2) {
47226
+ const index2 = geometries[i2].index;
47227
+ for (let j = 0; j < index2.count; ++j) {
47228
+ mergedIndex.push(index2.getX(j) + indexOffset);
47229
+ }
47230
+ indexOffset += geometries[i2].attributes.position.count;
47231
+ }
47232
+ mergedGeometry.setIndex(mergedIndex);
47233
+ }
47234
+ for (const name in attributes) {
47235
+ const mergedAttribute = mergeAttributes(attributes[name]);
47236
+ if (!mergedAttribute) {
47237
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + name + " attribute.");
47238
+ return null;
47239
+ }
47240
+ mergedGeometry.setAttribute(name, mergedAttribute);
47241
+ }
47242
+ for (const name in morphAttributes) {
47243
+ const numMorphTargets = morphAttributes[name][0].length;
47244
+ if (numMorphTargets === 0) break;
47245
+ mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};
47246
+ mergedGeometry.morphAttributes[name] = [];
47247
+ for (let i2 = 0; i2 < numMorphTargets; ++i2) {
47248
+ const morphAttributesToMerge = [];
47249
+ for (let j = 0; j < morphAttributes[name].length; ++j) {
47250
+ morphAttributesToMerge.push(morphAttributes[name][j][i2]);
47251
+ }
47252
+ const mergedMorphAttribute = mergeAttributes(morphAttributesToMerge);
47253
+ if (!mergedMorphAttribute) {
47254
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + name + " morphAttribute.");
47255
+ return null;
47256
+ }
47257
+ mergedGeometry.morphAttributes[name].push(mergedMorphAttribute);
47258
+ }
47259
+ }
47260
+ return mergedGeometry;
47261
+ }
47262
+ function mergeAttributes(attributes) {
47263
+ let TypedArray;
47264
+ let itemSize;
47265
+ let normalized;
47266
+ let gpuType = -1;
47267
+ let arrayLength = 0;
47268
+ for (let i2 = 0; i2 < attributes.length; ++i2) {
47269
+ const attribute = attributes[i2];
47270
+ if (TypedArray === void 0) TypedArray = attribute.array.constructor;
47271
+ if (TypedArray !== attribute.array.constructor) {
47272
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.");
47273
+ return null;
47274
+ }
47275
+ if (itemSize === void 0) itemSize = attribute.itemSize;
47276
+ if (itemSize !== attribute.itemSize) {
47277
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.");
47278
+ return null;
47279
+ }
47280
+ if (normalized === void 0) normalized = attribute.normalized;
47281
+ if (normalized !== attribute.normalized) {
47282
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.");
47283
+ return null;
47284
+ }
47285
+ if (gpuType === -1) gpuType = attribute.gpuType;
47286
+ if (gpuType !== attribute.gpuType) {
47287
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.");
47288
+ return null;
47289
+ }
47290
+ arrayLength += attribute.count * itemSize;
47291
+ }
47292
+ const array = new TypedArray(arrayLength);
47293
+ const result = new BufferAttribute(array, itemSize, normalized);
47294
+ let offset = 0;
47295
+ for (let i2 = 0; i2 < attributes.length; ++i2) {
47296
+ const attribute = attributes[i2];
47297
+ if (attribute.isInterleavedBufferAttribute) {
47298
+ const tupleOffset = offset / itemSize;
47299
+ for (let j = 0, l = attribute.count; j < l; j++) {
47300
+ for (let c = 0; c < itemSize; c++) {
47301
+ const value = attribute.getComponent(j, c);
47302
+ result.setComponent(j + tupleOffset, c, value);
47303
+ }
47304
+ }
47305
+ } else {
47306
+ array.set(attribute.array, offset);
47307
+ }
47308
+ offset += attribute.count * itemSize;
47309
+ }
47310
+ if (gpuType !== void 0) {
47311
+ result.gpuType = gpuType;
47312
+ }
47313
+ return result;
47314
+ }
47167
47315
  function estimateBytesUsed(geometry) {
47168
47316
  let mem = 0;
47169
47317
  for (const name in geometry.attributes) {
@@ -50120,7 +50268,7 @@ void main() {
50120
50268
  fov: 50,
50121
50269
  zoom: 1,
50122
50270
  // 45 deg down looking down z.
50123
- forward: new Vector3$1(1, -1, 1),
50271
+ forward: new Vector3$1(1, -1, -1),
50124
50272
  controls: {
50125
50273
  orbit: true,
50126
50274
  rotateSpeed: 1,
@@ -50444,18 +50592,18 @@ void main() {
50444
50592
  orbitTowards(direction) {
50445
50593
  const forward = this._camera.forward;
50446
50594
  const _direction = direction.clone();
50447
- if (_direction.x === 0 && _direction.z === 0) {
50595
+ if (_direction.x === 0 && _direction.y === 0) {
50448
50596
  _direction.x = this._camera.forward.x * 1e-3;
50449
- _direction.z = this._camera.forward.z * 1e-3;
50597
+ _direction.y = this._camera.forward.y * 1e-3;
50450
50598
  _direction.normalize();
50451
50599
  }
50452
- const flatForward = forward.clone().setY(0);
50453
- const flatDirection = _direction.clone().setY(0);
50600
+ const flatForward = forward.clone().setZ(0);
50601
+ const flatDirection = _direction.clone().setZ(0);
50454
50602
  const cross = flatForward.clone().cross(flatDirection);
50455
- const clockwise = cross.y === 0 ? 1 : Math.sign(cross.y);
50603
+ const clockwise = cross.z === 0 ? 1 : Math.sign(cross.z);
50456
50604
  const azimuth = flatForward.angleTo(flatDirection) * clockwise;
50457
- const angleForward = flatForward.angleTo(forward) * Math.sign(forward.y);
50458
- const angleDirection = flatDirection.angleTo(_direction) * Math.sign(_direction.y);
50605
+ const angleForward = flatForward.angleTo(forward) * Math.sign(forward.z);
50606
+ const angleDirection = flatDirection.angleTo(_direction) * Math.sign(_direction.z);
50459
50607
  const declination = angleForward - angleDirection;
50460
50608
  const angle = new Vector2$1(-declination, azimuth);
50461
50609
  angle.multiplyScalar(180 / Math.PI);
@@ -50663,12 +50811,30 @@ void main() {
50663
50811
  this.set(pos, target);
50664
50812
  }
50665
50813
  set(position, target) {
50666
- const locked = this.lockVector(position, this._camera.position);
50667
- this._camera.position.copy(locked);
50668
50814
  target = target ?? this._camera.target;
50815
+ const direction = new Vector3$1().subVectors(position, target);
50816
+ const dist2 = direction.length();
50817
+ if (dist2 > 1e-6) {
50818
+ const up = new Vector3$1(0, 0, 1);
50819
+ const angle = direction.angleTo(up);
50820
+ const minAngle = MathUtils.degToRad(5);
50821
+ const maxAngle = MathUtils.degToRad(175);
50822
+ if (angle < minAngle) {
50823
+ const axis = new Vector3$1().crossVectors(up, direction).normalize();
50824
+ const delta = minAngle - angle;
50825
+ direction.applyQuaternion(new Quaternion().setFromAxisAngle(axis, delta));
50826
+ } else if (angle > maxAngle) {
50827
+ const axis = new Vector3$1().crossVectors(up, direction).normalize();
50828
+ const delta = maxAngle - angle;
50829
+ direction.applyQuaternion(new Quaternion().setFromAxisAngle(axis, delta));
50830
+ }
50831
+ position.copy(target).add(direction);
50832
+ }
50833
+ const lockedPos = this.lockVector(position, this._camera.position);
50834
+ this._camera.position.copy(lockedPos);
50669
50835
  this._camera.target.copy(target);
50836
+ this._camera.camPerspective.camera.up.set(0, 0, 1);
50670
50837
  this._camera.camPerspective.camera.lookAt(target);
50671
- this._camera.camPerspective.camera.up.set(0, 1, 0);
50672
50838
  }
50673
50839
  lockVector(position, fallback) {
50674
50840
  const x = this._camera.allowedMovement.x === 0 ? fallback.x : position.x;
@@ -50679,17 +50845,14 @@ void main() {
50679
50845
  predictOrbit(angle) {
50680
50846
  const rotation = this.predictRotate(angle);
50681
50847
  const delta = new Vector3$1(0, 0, 1).applyQuaternion(rotation).multiplyScalar(this._camera.orbitDistance);
50682
- return this._camera.target.clone().add(delta);
50848
+ const pos = this._camera.target.clone().add(delta);
50849
+ return pos;
50683
50850
  }
50684
50851
  predictRotate(angle) {
50685
- const euler = new Euler(0, 0, 0, "YXZ");
50686
- euler.setFromQuaternion(this._camera.quaternion);
50687
- euler.x += angle.x * Math.PI / 180;
50688
- euler.y += angle.y * Math.PI / 180;
50689
- euler.z = 0;
50690
- const max2 = Math.PI * 0.4999;
50691
- euler.x = Math.max(-max2, Math.min(max2, euler.x));
50692
- const rotation = new Quaternion().setFromEuler(euler);
50852
+ const xQuat = new Quaternion().setFromAxisAngle(new Vector3$1(1, 0, 0), angle.x * Math.PI / 180);
50853
+ const zQuat = new Quaternion().setFromAxisAngle(new Vector3$1(0, 1, 0), angle.y * Math.PI / 180);
50854
+ const rotation = this._camera.quaternion.clone();
50855
+ rotation.multiply(xQuat).multiply(zQuat);
50693
50856
  return rotation;
50694
50857
  }
50695
50858
  }
@@ -50738,6 +50901,8 @@ void main() {
50738
50901
  __publicField(this, "_velocityBlendFactor", 1e-4);
50739
50902
  __publicField(this, "_moveSpeed", 1);
50740
50903
  this.camPerspective = new PerspectiveWrapper(new PerspectiveCamera());
50904
+ this.camPerspective.camera.up = new Vector3$1(0, 0, 1);
50905
+ this.camPerspective.camera.lookAt(new Vector3$1(0, 1, 0));
50741
50906
  this.camOrthographic = new OrthographicWrapper(
50742
50907
  new OrthographicCamera()
50743
50908
  );
@@ -50798,7 +50963,7 @@ void main() {
50798
50963
  }
50799
50964
  set defaultForward(value) {
50800
50965
  if (value.x === 0 && value.y === 0 && value.z === 0) {
50801
- this._defaultForward.set(1, -1, 1).normalize();
50966
+ this._defaultForward.set(1, -1, -1).normalize();
50802
50967
  } else {
50803
50968
  this._defaultForward.copy(value).normalize();
50804
50969
  }
@@ -54885,8 +55050,314 @@ void main() {
54885
55050
  this._meshes = void 0;
54886
55051
  }
54887
55052
  }
54888
- class BoxOutline extends LineSegments {
55053
+ const MIN_BOX_SIZE = 3;
55054
+ class BoxInputs {
55055
+ // -------------------------------------------------------------------------
55056
+ // Constructor
55057
+ // -------------------------------------------------------------------------
55058
+ /**
55059
+ * Creates a new BoxInputs instance for pointer-driven box resizing.
55060
+ *
55061
+ * @param viewer - The parent {@link Viewer} that renders the scene.
55062
+ * @param handles - A {@link SectionBoxHandles} instance containing the draggable mesh handles.
55063
+ * @param box - The shared bounding box (`Box3`) that will be updated by dragging.
55064
+ */
55065
+ constructor(viewer, handles, box) {
55066
+ // -------------------------------------------------------------------------
55067
+ // Dependencies and shared resources
55068
+ // -------------------------------------------------------------------------
55069
+ /** The parent Viewer controlling the scene. */
55070
+ __publicField(this, "_viewer");
55071
+ /** The handles mesh group containing the draggable cones/faces. */
55072
+ __publicField(this, "_handles");
55073
+ /** The main box that is being reshaped by dragging handles. */
55074
+ __publicField(this, "_sharedBox");
55075
+ // -------------------------------------------------------------------------
55076
+ // Internal state
55077
+ // -------------------------------------------------------------------------
55078
+ /** The currently hovered/dragged handle, if any. */
55079
+ __publicField(this, "_handle");
55080
+ /** The origin point for dragging, updated on pointer down. */
55081
+ __publicField(this, "_dragOrigin", new Vector3$1());
55082
+ /** The plane used for drag intersection (perpendicular to the camera direction). */
55083
+ __publicField(this, "_dragPlane", new Plane());
55084
+ /** Whether a pointer is currently down on a handle. */
55085
+ __publicField(this, "_mouseDown", false);
55086
+ /** A reusable Raycaster for picking and plane intersection. */
55087
+ __publicField(this, "_raycaster", new Raycaster$1());
55088
+ /** The box state before the current drag. */
55089
+ __publicField(this, "_lastBox", new Box3$1());
55090
+ /** A collection of unregister callbacks for event listeners. */
55091
+ __publicField(this, "_unregisters", []);
55092
+ /** The ID of the pointer that is captured, if any. */
55093
+ __publicField(this, "_capturedPointerId");
55094
+ // -------------------------------------------------------------------------
55095
+ // Callbacks
55096
+ // -------------------------------------------------------------------------
55097
+ /**
55098
+ * Called when the pointer enters or leaves a handle face.
55099
+ * @param normal - The normal (forward) vector of the hovered handle, or a zero vector if none.
55100
+ */
55101
+ __publicField(this, "onFaceEnter");
55102
+ /**
55103
+ * Called continuously as the box is reshaped by dragging.
55104
+ * @param box - The updated box after the latest drag move.
55105
+ */
55106
+ __publicField(this, "onBoxStretch");
55107
+ /**
55108
+ * Called when the user has finished reshaping the box (pointer up).
55109
+ * @param box - The final box after dragging ends.
55110
+ */
55111
+ __publicField(this, "onBoxConfirm");
55112
+ this._viewer = viewer;
55113
+ this._handles = handles;
55114
+ this._sharedBox = box;
55115
+ }
55116
+ // -------------------------------------------------------------------------
55117
+ // Public Methods
55118
+ // -------------------------------------------------------------------------
55119
+ /**
55120
+ * Registers pointer event listeners on the viewer's canvas.
55121
+ * If already registered, it does nothing.
55122
+ */
55123
+ register() {
55124
+ if (this._unregisters.length > 0) return;
55125
+ const canvas = this._viewer.viewport.canvas;
55126
+ this.reg(canvas, "pointerdown", (e) => this.onMouseDown(e));
55127
+ this.reg(canvas, "pointermove", (e) => this.onMouseMove(e));
55128
+ this.reg(canvas, "pointerup", (e) => this.onMouseUp(e));
55129
+ this.reg(canvas, "pointerleave", (e) => this.onPointerLeave(e));
55130
+ }
55131
+ /**
55132
+ * Unregisters any previously set pointer event listeners, releasing pointer capture
55133
+ * and resetting drag state.
55134
+ */
55135
+ unregister() {
55136
+ var _a2;
55137
+ this._mouseDown = false;
55138
+ (_a2 = this._handle) == null ? void 0 : _a2.highlight(false);
55139
+ this._handle = void 0;
55140
+ this.releasePointer();
55141
+ this._viewer.inputs.registerAll();
55142
+ this._unregisters.forEach((unreg) => unreg());
55143
+ this._unregisters.length = 0;
55144
+ }
55145
+ /**
55146
+ * Indicates if a pointer is currently captured for dragging.
55147
+ */
55148
+ get pointerCaptured() {
55149
+ return this._capturedPointerId !== void 0;
55150
+ }
55151
+ // -------------------------------------------------------------------------
55152
+ // Private Methods
55153
+ // -------------------------------------------------------------------------
55154
+ /**
55155
+ * A helper method to attach an event listener and store its unregister callback.
55156
+ *
55157
+ * @param handler - The DOM element or Window to attach the listener to.
55158
+ * @param type - The pointer event type, e.g. 'pointerdown'.
55159
+ * @param listener - The event handler function.
55160
+ */
55161
+ reg(handler, type, listener2) {
55162
+ handler.addEventListener(type, listener2);
55163
+ this._unregisters.push(() => handler.removeEventListener(type, listener2));
55164
+ }
55165
+ /**
55166
+ * Called when the pointer leaves the canvas. If not dragging,
55167
+ * invokes {@link onFaceEnter} to indicate no active handle is hovered.
55168
+ *
55169
+ * @param event - The pointerleave event.
55170
+ */
55171
+ onPointerLeave(event) {
55172
+ var _a2, _b2;
55173
+ if (!this.pointerCaptured) {
55174
+ (_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, ((_a2 = this._handle) == null ? void 0 : _a2.forward) ?? new Vector3$1());
55175
+ }
55176
+ }
55177
+ /**
55178
+ * Sets pointer capture on the canvas for a specific pointer (ID).
55179
+ *
55180
+ * @param pointerId - The pointer ID to capture.
55181
+ */
55182
+ capturePointer(pointerId) {
55183
+ this.releasePointer();
55184
+ this._viewer.viewport.canvas.setPointerCapture(pointerId);
55185
+ this._capturedPointerId = pointerId;
55186
+ }
55187
+ /**
55188
+ * Releases any captured pointer on the canvas, if present.
55189
+ */
55190
+ releasePointer() {
55191
+ if (this.pointerCaptured) {
55192
+ this._viewer.viewport.canvas.releasePointerCapture(this._capturedPointerId);
55193
+ this._capturedPointerId = void 0;
55194
+ }
55195
+ }
55196
+ /**
55197
+ * Handles pointer movement events.
55198
+ * - If dragging, calls {@link onDrag}.
55199
+ * - Otherwise, performs a raycast to detect which handle is under the pointer.
55200
+ *
55201
+ * @param event - The pointermove event.
55202
+ */
55203
+ onMouseMove(event) {
55204
+ var _a2, _b2, _c, _d;
55205
+ if (this._mouseDown) {
55206
+ this.onDrag(event);
55207
+ return;
55208
+ }
55209
+ const hits = this.raycast(new Vector2$1(event.offsetX, event.offsetY));
55210
+ const handle = (_b2 = (_a2 = hits == null ? void 0 : hits[0]) == null ? void 0 : _a2.object) == null ? void 0 : _b2.userData.handle;
55211
+ if (handle !== this._handle) {
55212
+ (_c = this._handle) == null ? void 0 : _c.highlight(false);
55213
+ handle == null ? void 0 : handle.highlight(true);
55214
+ this._handle = handle;
55215
+ (_d = this.onFaceEnter) == null ? void 0 : _d.call(this, (handle == null ? void 0 : handle.forward) ?? new Vector3$1());
55216
+ }
55217
+ }
55218
+ /**
55219
+ * Handles pointer up events. Ends dragging and triggers {@link onBoxConfirm}.
55220
+ *
55221
+ * @param event - The pointerup event.
55222
+ */
55223
+ onMouseUp(event) {
55224
+ var _a2, _b2;
55225
+ this.releasePointer();
55226
+ if (this._mouseDown) {
55227
+ this._mouseDown = false;
55228
+ this._viewer.inputs.registerAll();
55229
+ if (event.pointerType === "mouse") {
55230
+ this.onMouseMove(event);
55231
+ } else {
55232
+ this._handle = void 0;
55233
+ (_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, new Vector3$1());
55234
+ }
55235
+ (_b2 = this.onBoxConfirm) == null ? void 0 : _b2.call(this, this._sharedBox);
55236
+ }
55237
+ }
55238
+ /**
55239
+ * Handles pointer down events. Begins drag if a handle is hit, capturing the pointer.
55240
+ *
55241
+ * @param event - The pointerdown event.
55242
+ */
55243
+ onMouseDown(event) {
55244
+ var _a2, _b2, _c, _d;
55245
+ const hits = this.raycast(new Vector2$1(event.offsetX, event.offsetY));
55246
+ const handle = (_c = (_b2 = (_a2 = hits == null ? void 0 : hits[0]) == null ? void 0 : _a2.object) == null ? void 0 : _b2.userData) == null ? void 0 : _c.handle;
55247
+ if (!handle) return;
55248
+ this._handle = handle;
55249
+ this.capturePointer(event.pointerId);
55250
+ this._lastBox.copy(this._sharedBox);
55251
+ this._dragOrigin.copy(handle.position);
55252
+ const dist2 = handle.position.clone().dot(this._viewer.camera.forward);
55253
+ this._dragPlane.set(this._viewer.camera.forward, -dist2);
55254
+ this._mouseDown = true;
55255
+ this._viewer.inputs.unregisterAll();
55256
+ (_d = this.onFaceEnter) == null ? void 0 : _d.call(this, this._handle.forward.clone());
55257
+ }
55258
+ /**
55259
+ * Continues the drag operation. Determines the new position on the drag plane
55260
+ * and computes how far we moved along the handle's forward axis.
55261
+ *
55262
+ * @param event - The pointermove event while dragging.
55263
+ */
55264
+ onDrag(event) {
55265
+ var _a2;
55266
+ if (!this._handle) return;
55267
+ const point = this.raycastPlane(new Vector2$1(event.offsetX, event.offsetY)) ?? this._dragOrigin.clone();
55268
+ const delta = point.sub(this._dragOrigin);
55269
+ const amount = delta.dot(this._handle.forward);
55270
+ const box = this.stretch(this._handle.axis, this._handle.sign, amount);
55271
+ (_a2 = this.onBoxStretch) == null ? void 0 : _a2.call(this, box);
55272
+ }
55273
+ /**
55274
+ * Expands or contracts the `_sharedBox` along one axis by a certain amount,
55275
+ * ensuring the box cannot shrink below the minimum size (`MIN_BOX_SIZE`).
55276
+ *
55277
+ * @param axis - The axis ('x', 'y', or 'z') to stretch.
55278
+ * @param sign - +1 if stretching the 'max' side, -1 if stretching the 'min' side.
55279
+ * @param amount - The numeric offset along that axis to add or subtract.
55280
+ * @returns A **new** `Box3` instance with updated min/max coordinates.
55281
+ */
55282
+ stretch(axis, sign2, amount) {
55283
+ const box = this._sharedBox.clone();
55284
+ const direction = sign2 > 0 ? "max" : "min";
55285
+ const opposite = sign2 > 0 ? "min" : "max";
55286
+ const target = this._lastBox[direction][axis] + amount * sign2;
55287
+ const minBoundary = this._lastBox[opposite][axis] + MIN_BOX_SIZE * sign2;
55288
+ box[direction][axis] = target;
55289
+ if (sign2 * (target - minBoundary) < 0) {
55290
+ box[opposite][axis] = target - MIN_BOX_SIZE * sign2;
55291
+ }
55292
+ return box;
55293
+ }
55294
+ /**
55295
+ * Prepares the internal raycaster for a given 2D pointer position.
55296
+ *
55297
+ * @param position - The pointer position in canvas coordinates.
55298
+ * @returns The updated raycaster pointing from the camera through this position.
55299
+ */
55300
+ getRaycaster(position) {
55301
+ return this._viewer.raycaster.fromPoint2(position, this._raycaster);
55302
+ }
55303
+ /**
55304
+ * Raycasts into the handle meshes from the given pointer position.
55305
+ *
55306
+ * @param position - The pointer position in canvas coordinates.
55307
+ * @returns An array of intersection results, if any.
55308
+ */
55309
+ raycast(position) {
55310
+ return this.getRaycaster(position).intersectObject(this._handles.meshes);
55311
+ }
55312
+ /**
55313
+ * Raycasts into the drag plane from the given pointer position.
55314
+ *
55315
+ * @param position - The pointer position in canvas coordinates.
55316
+ * @returns The intersection point in 3D space, or `null` if none.
55317
+ */
55318
+ raycastPlane(position) {
55319
+ return this.getRaycaster(position).ray.intersectPlane(
55320
+ this._dragPlane,
55321
+ new Vector3$1()
55322
+ );
55323
+ }
55324
+ }
55325
+ class SectionBoxMesh extends Mesh {
54889
55326
  constructor() {
55327
+ const geo = new BoxGeometry();
55328
+ const mat = new MeshBasicMaterial({
55329
+ opacity: 0.3,
55330
+ transparent: true,
55331
+ color: new Color(20667),
55332
+ depthTest: false
55333
+ });
55334
+ super(geo, mat);
55335
+ }
55336
+ /**
55337
+ * Resize the mesh to the given box.
55338
+ */
55339
+ fitBox(box) {
55340
+ this.scale.set(
55341
+ box.max.x - box.min.x,
55342
+ box.max.y - box.min.y,
55343
+ box.max.z - box.min.z
55344
+ );
55345
+ this.position.set(
55346
+ (box.max.x + box.min.x) / 2,
55347
+ (box.max.y + box.min.y) / 2,
55348
+ (box.max.z + box.min.z) / 2
55349
+ );
55350
+ }
55351
+ /**
55352
+ * Disposes of all resources.
55353
+ */
55354
+ dispose() {
55355
+ this.geometry.dispose();
55356
+ this.material.dispose();
55357
+ }
55358
+ }
55359
+ class SectionBoxOutline extends LineSegments {
55360
+ constructor(color) {
54890
55361
  const vertices = new Float32Array([
54891
55362
  -0.5,
54892
55363
  -0.5,
@@ -54942,7 +55413,7 @@ void main() {
54942
55413
  const geo = new BufferGeometry();
54943
55414
  const mat = new LineBasicMaterial({
54944
55415
  opacity: 1,
54945
- color: new Color(0)
55416
+ color
54946
55417
  });
54947
55418
  geo.setAttribute("position", new BufferAttribute(vertices, 3));
54948
55419
  geo.setIndex(indices);
@@ -54971,305 +55442,169 @@ void main() {
54971
55442
  this.material.dispose();
54972
55443
  }
54973
55444
  }
54974
- class BoxMesh extends Mesh {
54975
- constructor() {
54976
- const geo = new BoxGeometry();
54977
- const mat = new MeshBasicMaterial({
54978
- opacity: 0.3,
55445
+ class SectionBoxHandle extends Mesh {
55446
+ constructor(axes, sign2, size, color) {
55447
+ const geo = createDoubleCone(size);
55448
+ geo.clearGroups();
55449
+ geo.addGroup(0, Infinity, 0);
55450
+ geo.addGroup(0, Infinity, 1);
55451
+ const matBehind = new MeshBasicMaterial({
54979
55452
  transparent: true,
54980
- color: new Color(20667),
54981
- depthTest: false
55453
+ opacity: 0.5,
55454
+ color: color ?? new Color(0),
55455
+ depthTest: false,
55456
+ side: FrontSide
54982
55457
  });
54983
- super(geo, mat);
55458
+ const matAlways = new MeshBasicMaterial({
55459
+ color: color ?? new Color(0),
55460
+ side: FrontSide
55461
+ });
55462
+ super(geo, [matAlways, matBehind]);
55463
+ __publicField(this, "axis");
55464
+ __publicField(this, "sign");
55465
+ __publicField(this, "_forward");
55466
+ __publicField(this, "_color");
55467
+ __publicField(this, "_highlightColor");
55468
+ __publicField(this, "_materials");
55469
+ this._materials = [matAlways, matBehind];
55470
+ this._forward = new Vector3$1();
55471
+ this.forward[axes] = sign2;
55472
+ this.axis = axes;
55473
+ this.sign = sign2;
55474
+ this._color = color ?? new Color(0);
55475
+ this._highlightColor = this._color.clone().lerp(new Color(13421772), 0.8);
55476
+ this.userData.handle = this;
55477
+ this.quaternion.setFromUnitVectors(new Vector3$1(0, -1, 0), this._forward);
54984
55478
  }
54985
- /**
54986
- * Resize the mesh to the given box.
54987
- */
54988
- fitBox(box) {
54989
- this.scale.set(
54990
- box.max.x - box.min.x,
54991
- box.max.y - box.min.y,
54992
- box.max.z - box.min.z
54993
- );
54994
- this.position.set(
54995
- (box.max.x + box.min.x) / 2,
54996
- (box.max.y + box.min.y) / 2,
54997
- (box.max.z + box.min.z) / 2
54998
- );
55479
+ setPosition(position) {
55480
+ this.position.copy(position);
55481
+ }
55482
+ get forward() {
55483
+ return this._forward;
55484
+ }
55485
+ highlight(value) {
55486
+ this.material[0].color.set(value ? this._highlightColor : this._color);
55487
+ this.material[1].color.set(value ? this._highlightColor : this._color);
54999
55488
  }
55000
- /**
55001
- * Disposes of all resources.
55002
- */
55003
55489
  dispose() {
55004
55490
  this.geometry.dispose();
55005
- this.material.dispose();
55006
- }
55007
- }
55008
- class BoxHighlight extends Mesh {
55491
+ this._materials.forEach((m) => m.dispose());
55492
+ }
55493
+ }
55494
+ function createDoubleCone(size) {
55495
+ const coneHeight = 2 * size;
55496
+ const cone1 = new ConeGeometry(size, coneHeight, 12);
55497
+ cone1.translate(0, coneHeight * 0.75, 0);
55498
+ const cone2 = new ConeGeometry(size, coneHeight, 12);
55499
+ cone2.rotateZ(Math.PI);
55500
+ cone2.translate(0, -coneHeight * 0.75, 0);
55501
+ const mergedGeo = mergeGeometries([cone1, cone2]);
55502
+ cone1.dispose();
55503
+ cone2.dispose();
55504
+ return mergedGeo;
55505
+ }
55506
+ class SectionBoxHandles {
55009
55507
  constructor() {
55010
- const geo = new BufferGeometry();
55011
- geo.setAttribute(
55012
- "position",
55013
- new BufferAttribute(new Float32Array(12), 3)
55014
- );
55015
- geo.setIndex([0, 1, 2, 0, 2, 3]);
55016
- const mat = new MeshBasicMaterial({
55017
- opacity: 0.7,
55018
- transparent: true,
55019
- depthTest: false,
55020
- side: DoubleSide
55021
- });
55022
- super(geo, mat);
55023
- this.renderOrder = 1;
55024
- this.frustumCulled = false;
55508
+ __publicField(this, "up");
55509
+ __publicField(this, "down");
55510
+ __publicField(this, "left");
55511
+ __publicField(this, "right");
55512
+ __publicField(this, "front");
55513
+ __publicField(this, "back");
55514
+ __publicField(this, "meshes");
55515
+ const size = 2;
55516
+ this.up = new SectionBoxHandle("y", 1, size, new Color(65280));
55517
+ this.down = new SectionBoxHandle("y", -1, size, new Color(65280));
55518
+ this.left = new SectionBoxHandle("x", -1, size, new Color(16711680));
55519
+ this.right = new SectionBoxHandle("x", 1, size, new Color(16711680));
55520
+ this.front = new SectionBoxHandle("z", 1, size, new Color(255));
55521
+ this.back = new SectionBoxHandle("z", -1, size, new Color(255));
55522
+ this.meshes = new Group();
55523
+ this.meshes.add(this.up);
55524
+ this.meshes.add(this.down);
55525
+ this.meshes.add(this.left);
55526
+ this.meshes.add(this.right);
55527
+ this.meshes.add(this.front);
55528
+ this.meshes.add(this.back);
55025
55529
  }
55026
- /**
55027
- * Sets the face to highlight
55028
- * @param normal a direction vector from theses options (X,-X, Y,-Y, Z,-Z)
55029
- */
55030
- highlight(box, normal) {
55031
- this.visible = false;
55032
- const positions = this.geometry.getAttribute("position");
55033
- if (normal.x > 0.1) {
55034
- positions.setXYZ(0, box.max.x, box.max.y, box.max.z);
55035
- positions.setXYZ(1, box.max.x, box.min.y, box.max.z);
55036
- positions.setXYZ(2, box.max.x, box.min.y, box.min.z);
55037
- positions.setXYZ(3, box.max.x, box.max.y, box.min.z);
55038
- this.visible = true;
55039
- }
55040
- if (normal.x < -0.1) {
55041
- positions.setXYZ(0, box.min.x, box.max.y, box.max.z);
55042
- positions.setXYZ(1, box.min.x, box.min.y, box.max.z);
55043
- positions.setXYZ(2, box.min.x, box.min.y, box.min.z);
55044
- positions.setXYZ(3, box.min.x, box.max.y, box.min.z);
55045
- this.visible = true;
55046
- }
55047
- if (normal.y > 0.1) {
55048
- positions.setXYZ(0, box.max.x, box.max.y, box.max.z);
55049
- positions.setXYZ(1, box.min.x, box.max.y, box.max.z);
55050
- positions.setXYZ(2, box.min.x, box.max.y, box.min.z);
55051
- positions.setXYZ(3, box.max.x, box.max.y, box.min.z);
55052
- this.visible = true;
55053
- }
55054
- if (normal.y < -0.1) {
55055
- positions.setXYZ(0, box.max.x, box.min.y, box.max.z);
55056
- positions.setXYZ(1, box.min.x, box.min.y, box.max.z);
55057
- positions.setXYZ(2, box.min.x, box.min.y, box.min.z);
55058
- positions.setXYZ(3, box.max.x, box.min.y, box.min.z);
55059
- this.visible = true;
55060
- }
55061
- if (normal.z > 0.1) {
55062
- positions.setXYZ(0, box.max.x, box.max.y, box.max.z);
55063
- positions.setXYZ(1, box.min.x, box.max.y, box.max.z);
55064
- positions.setXYZ(2, box.min.x, box.min.y, box.max.z);
55065
- positions.setXYZ(3, box.max.x, box.min.y, box.max.z);
55066
- this.visible = true;
55067
- }
55068
- if (normal.z < -0.1) {
55069
- positions.setXYZ(0, box.max.x, box.max.y, box.min.z);
55070
- positions.setXYZ(1, box.min.x, box.max.y, box.min.z);
55071
- positions.setXYZ(2, box.min.x, box.min.y, box.min.z);
55072
- positions.setXYZ(3, box.max.x, box.min.y, box.min.z);
55073
- this.visible = true;
55074
- }
55075
- positions.needsUpdate = true;
55530
+ get visible() {
55531
+ return this.meshes.visible;
55532
+ }
55533
+ set visible(value) {
55534
+ this.meshes.visible = value;
55535
+ }
55536
+ fitBox(box) {
55537
+ const center = box.getCenter(new Vector3$1());
55538
+ this.up.setPosition(new Vector3$1(center.x, box.max.y, center.z));
55539
+ this.down.setPosition(new Vector3$1(center.x, box.min.y, center.z));
55540
+ this.left.setPosition(new Vector3$1(box.min.x, center.y, center.z));
55541
+ this.right.setPosition(new Vector3$1(box.max.x, center.y, center.z));
55542
+ this.front.setPosition(new Vector3$1(center.x, center.y, box.max.z));
55543
+ this.back.setPosition(new Vector3$1(center.x, center.y, box.min.z));
55076
55544
  }
55077
- /**
55078
- * Disposes all resources.
55079
- */
55080
55545
  dispose() {
55081
- this.geometry.dispose();
55082
- this.material.dispose();
55546
+ this.up.dispose();
55547
+ this.down.dispose();
55548
+ this.left.dispose();
55549
+ this.right.dispose();
55550
+ this.front.dispose();
55551
+ this.back.dispose();
55083
55552
  }
55084
55553
  }
55085
- class BoxInputs {
55086
- constructor(viewer, cube, box) {
55087
- // dependencies
55088
- __publicField(this, "viewer");
55554
+ class SectionBoxGizmo {
55555
+ constructor(renderer) {
55556
+ __publicField(this, "_renderer");
55089
55557
  __publicField(this, "cube");
55090
- __publicField(this, "sharedBox");
55091
- // state
55092
- __publicField(this, "faceNormal", new Vector3$1());
55093
- __publicField(this, "dragOrigin", new Vector3$1());
55094
- __publicField(this, "dragpPlane", new Plane());
55095
- __publicField(this, "mouseDown");
55096
- __publicField(this, "raycaster", new Raycaster$1());
55097
- __publicField(this, "lastBox", new Box3$1());
55098
- __publicField(this, "unregisters", []);
55099
- __publicField(this, "lastMouse");
55100
- __publicField(this, "ctrlDown", false);
55101
- __publicField(this, "capturedId");
55102
- // Called when mouse enters or leave a face
55103
- __publicField(this, "onFaceEnter");
55104
- // Called the box is reshaped
55105
- __publicField(this, "onBoxStretch");
55106
- // Called when the user is done reshaping the box
55107
- __publicField(this, "onBoxConfirm");
55108
- __publicField(this, "reg", (handler, type, listener2) => {
55109
- handler.addEventListener(type, listener2);
55110
- this.unregisters.push(() => handler.removeEventListener(type, listener2));
55111
- });
55112
- this.viewer = viewer;
55113
- this.cube = cube;
55114
- this.sharedBox = box;
55115
- }
55116
- register() {
55117
- if (this.unregister.length > 0) return;
55118
- const canvas = this.viewer.viewport.canvas;
55119
- this.reg(window, "keydown", this.onKey.bind(this));
55120
- this.reg(window, "keyup", this.onKey.bind(this));
55121
- this.reg(canvas, "pointerdown", this.onMouseDown.bind(this));
55122
- this.reg(canvas, "pointermove", this.onMouseMove.bind(this));
55123
- this.reg(canvas, "pointerup", this.onMouseUp.bind(this));
55124
- this.reg(canvas, "pointerleave", this.onPointerLeave.bind(this));
55125
- }
55126
- onPointerLeave(event) {
55127
- var _a2;
55128
- if (this.capturedId !== void 0) {
55129
- return;
55130
- }
55131
- this.faceNormal.set(0, 0, 0);
55132
- (_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, this.faceNormal);
55133
- }
55134
- capturePointer(pointerId) {
55135
- this.releasePointer();
55136
- this.viewer.viewport.canvas.setPointerCapture(pointerId);
55137
- this.capturedId = pointerId;
55138
- }
55139
- releasePointer() {
55140
- if (this.capturedId === void 0) return;
55141
- this.viewer.viewport.canvas.releasePointerCapture(this.capturedId);
55142
- this.capturedId = void 0;
55143
- }
55144
- unregister() {
55145
- this.ctrlDown = false;
55146
- this.mouseDown = false;
55147
- this.releasePointer();
55148
- this.viewer.inputs.registerAll();
55149
- this.unregisters.forEach((unreg) => unreg());
55150
- this.unregisters.length = 0;
55151
- }
55152
- onKey(event) {
55153
- if (this.ctrlDown !== event.ctrlKey) {
55154
- this.ctrlDown = event.ctrlKey;
55155
- this.onMouseMove(this.lastMouse);
55156
- }
55157
- }
55158
- onMouseMove(event) {
55159
- var _a2, _b2, _c;
55160
- this.lastMouse = event;
55161
- if (this.mouseDown) {
55162
- this.onDrag(event);
55163
- return;
55164
- }
55165
- const hits = this.raycast(
55166
- new Vector2$1(event.offsetX, event.offsetY),
55167
- this.ctrlDown
55168
- );
55169
- const hit = hits == null ? void 0 : hits[0];
55170
- const norm = (_a2 = hit == null ? void 0 : hit.face) == null ? void 0 : _a2.normal;
55171
- if (!norm) {
55172
- if (this.faceNormal.x !== 0 || this.faceNormal.y !== 0 || this.faceNormal.z !== 0) {
55173
- this.faceNormal.set(0, 0, 0);
55174
- (_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, this.faceNormal);
55175
- }
55176
- return;
55177
- }
55178
- if (this.faceNormal.equals(norm)) {
55179
- return;
55180
- }
55181
- this.faceNormal = norm;
55182
- (_c = this.onFaceEnter) == null ? void 0 : _c.call(this, this.faceNormal);
55183
- }
55184
- onMouseUp(event) {
55185
- var _a2, _b2;
55186
- this.releasePointer();
55187
- if (this.mouseDown) {
55188
- this.mouseDown = false;
55189
- this.viewer.inputs.registerAll();
55190
- if (event.pointerType === "mouse") {
55191
- this.onMouseMove(event);
55192
- } else {
55193
- this.faceNormal = new Vector3$1();
55194
- (_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, this.faceNormal);
55195
- }
55196
- (_b2 = this.onBoxConfirm) == null ? void 0 : _b2.call(this, this.sharedBox);
55197
- }
55558
+ __publicField(this, "outline");
55559
+ __publicField(this, "handles");
55560
+ __publicField(this, "_visible", false);
55561
+ this._renderer = renderer;
55562
+ this.cube = new SectionBoxMesh();
55563
+ this.outline = new SectionBoxOutline(new Color(8882833));
55564
+ this.handles = new SectionBoxHandles();
55565
+ this._renderer.add(this.outline);
55566
+ this._renderer.add(this.handles.meshes);
55567
+ this.visible = false;
55198
55568
  }
55199
- onMouseDown(event) {
55200
- var _a2, _b2;
55201
- const hits = this.raycast(
55202
- new Vector2$1(event.offsetX, event.offsetY),
55203
- this.ctrlDown
55204
- );
55205
- const hit = hits == null ? void 0 : hits[0];
55206
- if (!((_a2 = hit == null ? void 0 : hit.face) == null ? void 0 : _a2.normal)) return;
55207
- this.capturePointer(event.pointerId);
55208
- this.lastBox.copy(this.sharedBox);
55209
- this.faceNormal = hit.face.normal;
55210
- this.dragOrigin.copy(hit.point);
55211
- const dist2 = hit.point.clone().dot(this.viewer.camera.forward);
55212
- this.dragpPlane.set(this.viewer.camera.forward, -dist2);
55213
- this.mouseDown = true;
55214
- this.viewer.inputs.unregisterAll();
55215
- (_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, this.faceNormal);
55569
+ get visible() {
55570
+ return this._visible;
55216
55571
  }
55217
- onDrag(event) {
55218
- var _a2;
55219
- this.raycaster = this.viewer.raycaster.fromPoint2(
55220
- new Vector2$1(event.offsetX, event.offsetY),
55221
- this.raycaster
55222
- );
55223
- const point = this.raycaster.ray.intersectPlane(this.dragpPlane, new Vector3$1()) ?? this.dragOrigin.clone();
55224
- const delta = point.sub(this.dragOrigin);
55225
- const amount = delta.dot(this.faceNormal);
55226
- const box = this.stretch(this.faceNormal, amount);
55227
- (_a2 = this.onBoxStretch) == null ? void 0 : _a2.call(this, box);
55572
+ set visible(value) {
55573
+ this._visible = value;
55574
+ this.cube.visible = value;
55575
+ this.outline.visible = value;
55576
+ this.handles.visible = value;
55228
55577
  }
55229
- stretch(normal, amount) {
55230
- const result = this.sharedBox.clone();
55231
- if (normal.x > 0.1) {
55232
- result.max.setX(Math.max(this.lastBox.max.x + amount, result.min.x - 1));
55233
- }
55234
- if (normal.x < -0.1) {
55235
- result.min.setX(Math.min(this.lastBox.min.x - amount, result.max.x + 1));
55236
- }
55237
- if (normal.y > 0.1) {
55238
- result.max.setY(Math.max(this.lastBox.max.y + amount, result.min.y - 1));
55239
- }
55240
- if (normal.y < -0.1) {
55241
- result.min.setY(Math.min(this.lastBox.min.y - amount, result.max.y + 1));
55242
- }
55243
- if (normal.z > 0.1) {
55244
- result.max.setZ(Math.max(this.lastBox.max.z + amount, result.min.z - 1));
55245
- }
55246
- if (normal.z < -0.1) {
55247
- result.min.setZ(Math.min(this.lastBox.min.z - amount, result.max.z + 1));
55248
- }
55249
- return result;
55578
+ fitBox(box) {
55579
+ this.cube.fitBox(box);
55580
+ this.outline.fitBox(box);
55581
+ this.handles.fitBox(box);
55250
55582
  }
55251
- raycast(position, reverse) {
55252
- this.raycaster = this.viewer.raycaster.fromPoint2(position, this.raycaster);
55253
- if (reverse) {
55254
- this.raycaster.ray.set(
55255
- this.raycaster.ray.origin.clone().add(this.raycaster.ray.direction.clone().multiplyScalar(this.viewer.settings.camera.far)),
55256
- this.raycaster.ray.direction.negate()
55257
- );
55258
- }
55259
- return this.raycaster.intersectObject(this.cube);
55583
+ dispose() {
55584
+ this._renderer.remove(this.cube);
55585
+ this._renderer.remove(this.outline);
55586
+ this._renderer.remove(this.handles.meshes);
55587
+ this.cube.dispose();
55588
+ this.outline.dispose();
55589
+ this.handles.dispose();
55260
55590
  }
55261
55591
  }
55262
- class SectionBox {
55592
+ let SectionBox$1 = class SectionBox {
55593
+ // -------------------------------------------------------------------------
55594
+ // Constructor
55595
+ // -------------------------------------------------------------------------
55596
+ /**
55597
+ * Creates a new SectionBox gizmo controller.
55598
+ *
55599
+ * @param viewer - The parent {@link Viewer} in which the section box is rendered.
55600
+ */
55263
55601
  constructor(viewer) {
55264
- // dependencies
55602
+ // -------------------------------------------------------------------------
55603
+ // Private fields
55604
+ // -------------------------------------------------------------------------
55265
55605
  __publicField(this, "_viewer");
55266
- // resources
55606
+ __publicField(this, "_gizmos");
55267
55607
  __publicField(this, "_inputs");
55268
- __publicField(this, "_cube");
55269
- __publicField(this, "_outline");
55270
- __publicField(this, "_highlight");
55271
- // State
55272
- __publicField(this, "_normal");
55273
55608
  __publicField(this, "_clip");
55274
55609
  __publicField(this, "_visible");
55275
55610
  __publicField(this, "_interactive");
@@ -55277,21 +55612,13 @@ void main() {
55277
55612
  __publicField(this, "_onBoxConfirm", new distExports.SimpleEventDispatcher());
55278
55613
  __publicField(this, "_onHover", new distExports.SimpleEventDispatcher());
55279
55614
  this._viewer = viewer;
55280
- this._normal = new Vector3$1();
55281
- this._cube = new BoxMesh();
55282
- this._outline = new BoxOutline();
55283
- this._highlight = new BoxHighlight();
55284
- this.renderer.add(this._cube);
55285
- this.renderer.add(this._outline);
55286
- this.renderer.add(this._highlight);
55615
+ this._gizmos = new SectionBoxGizmo(viewer.renderer);
55287
55616
  this._inputs = new BoxInputs(
55288
55617
  viewer,
55289
- this._cube,
55618
+ this._gizmos.handles,
55290
55619
  this._viewer.renderer.section.box
55291
55620
  );
55292
55621
  this._inputs.onFaceEnter = (normal) => {
55293
- this._normal = normal;
55294
- if (this.visible) this._highlight.highlight(this.section.box, normal);
55295
55622
  this._onHover.dispatch(normal.x !== 0 || normal.y !== 0 || normal.z !== 0);
55296
55623
  this.renderer.needsUpdate = true;
55297
55624
  };
@@ -55306,37 +55633,61 @@ void main() {
55306
55633
  this.update();
55307
55634
  }
55308
55635
  /**
55309
- * Signal dispatched when clip, show, or interactive are updated.
55636
+ * @internal
55637
+ * A convenience getter to the viewer's renderer.
55638
+ */
55639
+ get renderer() {
55640
+ return this._viewer.renderer;
55641
+ }
55642
+ /**
55643
+ * @internal
55644
+ * A convenience getter to the `Section` module in the renderer.
55645
+ */
55646
+ get section() {
55647
+ return this._viewer.renderer.section;
55648
+ }
55649
+ // -------------------------------------------------------------------------
55650
+ // Public Signals
55651
+ // -------------------------------------------------------------------------
55652
+ /**
55653
+ * Dispatches when any of the following properties change:
55654
+ * - {@link clip} (clipping planes active)
55655
+ * - {@link visible} (gizmo visibility)
55656
+ * - {@link interactive} (pointer inputs active)
55310
55657
  */
55311
55658
  get onStateChanged() {
55312
55659
  return this._onStateChanged.asEvent();
55313
55660
  }
55314
55661
  /**
55315
- * Signal dispatched when user is done manipulating the box.
55662
+ * Dispatches when the user finishes manipulating (dragging) the box.
55663
+ * The payload is the final {@link THREE.Box3} used for clipping.
55316
55664
  */
55317
55665
  get onBoxConfirm() {
55318
55666
  return this._onBoxConfirm.asEvent();
55319
55667
  }
55320
55668
  /**
55321
- * Signal dispatched with true when pointer enters box and false when pointer leaves.
55669
+ * Dispatches a boolean indicating pointer hover state on the box handles:
55670
+ * - `true` if the pointer has entered a handle
55671
+ * - `false` if it has left or no handle is hovered
55322
55672
  */
55323
55673
  get onHover() {
55324
55674
  return this._onHover.asEvent();
55325
55675
  }
55326
- get renderer() {
55327
- return this._viewer.renderer;
55328
- }
55329
- get section() {
55330
- return this._viewer.renderer.section;
55331
- }
55676
+ // -------------------------------------------------------------------------
55677
+ // Public Properties
55678
+ // -------------------------------------------------------------------------
55332
55679
  /**
55333
- * Section bounding box, to update the box use fitBox.
55680
+ * The shared bounding box that defines the section region.
55681
+ *
55682
+ * To programmatically update the box, see {@link fitBox}.
55334
55683
  */
55335
55684
  get box() {
55336
55685
  return this.section.box;
55337
55686
  }
55338
55687
  /**
55339
- * Determines whether the section gizmo will section the model with clipping planes.
55688
+ * Determines whether the section gizmo applies clipping planes to the model.
55689
+ *
55690
+ * When `true`, `renderer.section.active` is enabled.
55340
55691
  */
55341
55692
  get clip() {
55342
55693
  return this._clip ?? false;
@@ -55348,71 +55699,79 @@ void main() {
55348
55699
  this._onStateChanged.dispatch();
55349
55700
  }
55350
55701
  /**
55351
- * Determines whether the gizmo reacts to user inputs.
55702
+ * Determines whether the gizmo is interactive (i.e. responds to pointer events).
55703
+ *
55704
+ * When `true`, pointer events are registered and box handles can be dragged.
55352
55705
  */
55353
55706
  get interactive() {
55354
55707
  return this._interactive ?? false;
55355
55708
  }
55356
55709
  set interactive(value) {
55357
55710
  if (value === this._interactive) return;
55358
- if (!this._interactive && value) this._inputs.register();
55359
- if (this._interactive && !value) this._inputs.unregister();
55711
+ if (!this._interactive && value) {
55712
+ this._inputs.register();
55713
+ }
55714
+ if (this._interactive && !value) {
55715
+ this._inputs.unregister();
55716
+ }
55360
55717
  this._interactive = value;
55361
- this._highlight.visible = false;
55362
55718
  this.renderer.needsUpdate = true;
55363
55719
  this._onStateChanged.dispatch();
55364
55720
  }
55365
55721
  /**
55366
- * Determines whether the gizmo will be rendered.
55722
+ * Determines whether the section box gizmo is visible in the scene.
55367
55723
  */
55368
55724
  get visible() {
55369
55725
  return this._visible ?? false;
55370
55726
  }
55371
55727
  set visible(value) {
55372
55728
  if (value === this._visible) return;
55373
- this._visible = value;
55374
- this._cube.visible = value;
55375
- this._outline.visible = value;
55376
- this._highlight.visible = value;
55377
- if (value) this.update();
55729
+ this._gizmos.visible = value;
55730
+ if (value) {
55731
+ this.update();
55732
+ }
55378
55733
  this.renderer.needsUpdate = true;
55379
55734
  this._onStateChanged.dispatch();
55380
55735
  }
55736
+ // -------------------------------------------------------------------------
55737
+ // Public Methods
55738
+ // -------------------------------------------------------------------------
55381
55739
  /**
55382
- * Sets the section gizmo size to match the given box.
55383
- * @param {THREE.Box3} box - The box to match the section gizmo size to.
55384
- * @param {number} [padding=1] - The padding to apply to the box.
55740
+ * Resizes the section gizmo to match the given box, optionally expanded by a padding.
55741
+ * After resizing, this method also updates the renderer's clipping box.
55742
+ *
55743
+ * @param box - The bounding box to match (required).
55744
+ * @param padding - The scalar amount by which to expand the bounding box. Default is `1`.
55385
55745
  */
55386
55746
  fitBox(box, padding = 1) {
55387
55747
  if (!box) return;
55388
55748
  const b = box.expandByScalar(padding);
55389
- this._cube.fitBox(b);
55390
- this._outline.fitBox(b);
55749
+ this._gizmos.fitBox(b);
55391
55750
  this.renderer.section.fitBox(b);
55392
55751
  this._onBoxConfirm.dispatch(this.box);
55393
55752
  this.renderer.needsUpdate = true;
55394
55753
  }
55395
55754
  /**
55396
- * Call this if there were direct changes to renderer.section
55755
+ * Updates the section box to match the current size of `this.section.box`.
55756
+ *
55757
+ * Call this if the renderer's section box is changed by code outside this class.
55397
55758
  */
55398
55759
  update() {
55399
55760
  this.fitBox(this.section.box, 0);
55400
- this._highlight.highlight(this.section.box, this._normal);
55401
55761
  this.renderer.needsUpdate = true;
55402
55762
  }
55403
55763
  /**
55404
- * Removes gizmo from rendering and inputs and dispose all resources.
55764
+ * Disposes of the gizmo and input event listeners, cleaning up related resources.
55765
+ *
55766
+ * After disposal, this `SectionBox` instance should no longer be used.
55405
55767
  */
55406
55768
  dispose() {
55407
- this.renderer.remove(this._cube);
55408
- this.renderer.remove(this._outline);
55409
- this.renderer.remove(this._highlight);
55769
+ this._onBoxConfirm.clear();
55770
+ this._onHover.clear();
55771
+ this._gizmos.dispose();
55410
55772
  this._inputs.unregister();
55411
- this._cube.dispose();
55412
- this._outline.dispose();
55413
- this._highlight.dispose();
55414
55773
  }
55415
- }
55774
+ };
55416
55775
  class Gizmos {
55417
55776
  constructor(viewer, camera2) {
55418
55777
  __publicField(this, "viewer");
@@ -55444,7 +55803,7 @@ void main() {
55444
55803
  var _a2;
55445
55804
  this.viewer = viewer;
55446
55805
  this._measure = new Measure(viewer);
55447
- this.section = new SectionBox(viewer);
55806
+ this.section = new SectionBox$1(viewer);
55448
55807
  this.loading = new GizmoLoading(viewer);
55449
55808
  this.orbit = new GizmoOrbit(
55450
55809
  viewer.renderer,
@@ -57677,17 +58036,16 @@ void main() {
57677
58036
  class Marshal {
57678
58037
  constructor(initialSize = 1024) {
57679
58038
  __publicField(this, "buffer");
57680
- __publicField(this, "dataView");
57681
- __publicField(this, "readOffset", 0);
57682
- __publicField(this, "writeOffset", 0);
58039
+ __publicField(this, "_dataView");
58040
+ __publicField(this, "_offset", 0);
57683
58041
  this.buffer = new ArrayBuffer(initialSize);
57684
- this.dataView = new DataView(this.buffer);
58042
+ this._dataView = new DataView(this.buffer);
57685
58043
  }
57686
58044
  getBuffer() {
57687
- return this.buffer.slice(0, this.writeOffset);
58045
+ return this.buffer.slice(0, this._offset);
57688
58046
  }
57689
58047
  ensureCapacity(additionalSize) {
57690
- const requiredSize = this.writeOffset + additionalSize;
58048
+ const requiredSize = this._offset + additionalSize;
57691
58049
  if (requiredSize > this.buffer.byteLength) {
57692
58050
  let newLength = this.buffer.byteLength;
57693
58051
  while (newLength < requiredSize) {
@@ -57696,21 +58054,162 @@ void main() {
57696
58054
  const newBuffer = new ArrayBuffer(newLength);
57697
58055
  new Uint8Array(newBuffer).set(new Uint8Array(this.buffer));
57698
58056
  this.buffer = newBuffer;
57699
- this.dataView = new DataView(this.buffer);
58057
+ this._dataView = new DataView(this.buffer);
57700
58058
  }
57701
58059
  }
57702
58060
  writeData(data2) {
57703
58061
  this.ensureCapacity(data2.byteLength);
57704
- new Uint8Array(this.buffer, this.writeOffset).set(new Uint8Array(data2));
57705
- this.writeOffset += data2.byteLength;
58062
+ new Uint8Array(this.buffer, this._offset).set(new Uint8Array(data2));
58063
+ this._offset += data2.byteLength;
57706
58064
  }
57707
- // -------------------- Matrix44 Methods --------------------
58065
+ // -------------------- Matrix44 -------------------
57708
58066
  writeMatrix44(data2) {
57709
58067
  this.ensureCapacity(4 * 4 * 4);
57710
58068
  this.writeArray(data2.toArray(), 4, (element) => {
57711
58069
  this.writeFloat(element);
57712
58070
  });
57713
58071
  }
58072
+ // -------------------- Boolean -------------------
58073
+ writeBoolean(value) {
58074
+ this.ensureCapacity(4);
58075
+ this._dataView.setUint32(this._offset, value ? 1 : 0, true);
58076
+ this._offset += 4;
58077
+ }
58078
+ // -------------------- Int -------------------
58079
+ writeInt(value) {
58080
+ this.ensureCapacity(4);
58081
+ this._dataView.setInt32(this._offset, value, true);
58082
+ this._offset += 4;
58083
+ }
58084
+ // -------------------- UInt -------------------
58085
+ writeUInt(value) {
58086
+ this.ensureCapacity(4);
58087
+ this._dataView.setUint32(this._offset, value, true);
58088
+ this._offset += 4;
58089
+ }
58090
+ // -------------------- Float -------------------
58091
+ writeFloat(value) {
58092
+ this.ensureCapacity(4);
58093
+ this._dataView.setFloat32(this._offset, value, true);
58094
+ this._offset += 4;
58095
+ }
58096
+ // -------------------- String -------------------
58097
+ writeString(value) {
58098
+ const textEncoder = new TextEncoder();
58099
+ const encodedString = textEncoder.encode(value + "\0");
58100
+ this.ensureCapacity(4 + encodedString.byteLength);
58101
+ this.writeUInt(encodedString.length);
58102
+ new Uint8Array(this.buffer, this._offset).set(encodedString);
58103
+ this._offset += encodedString.length;
58104
+ }
58105
+ // -------------------- HitCheckResult -------------------
58106
+ writeHitCheckResult(data2) {
58107
+ this.ensureCapacity(4 + 4 + 4 * 3 + 4 * 3);
58108
+ this.writeUInt(data2.vimHandle);
58109
+ this.writeUInt(data2.nodeIndex);
58110
+ this.writeVector3(data2.worldPosition);
58111
+ this.writeVector3(data2.worldNormal);
58112
+ }
58113
+ // -------------------- VimStatus -------------------
58114
+ writeVimStatus(data2) {
58115
+ this.ensureCapacity(4 + 4);
58116
+ this.writeUInt(data2.status);
58117
+ this.writeFloat(data2.progress);
58118
+ }
58119
+ // -------------------- Vector2 -------------------
58120
+ writeVector2(data2) {
58121
+ this.ensureCapacity(4 + 4);
58122
+ this.writeFloat(data2.x);
58123
+ this.writeFloat(data2.y);
58124
+ }
58125
+ // -------------------- Vector3 -------------------
58126
+ writeVector3(data2) {
58127
+ this.ensureCapacity(4 + 4 + 4);
58128
+ this.writeFloat(data2.x);
58129
+ this.writeFloat(data2.y);
58130
+ this.writeFloat(data2.z);
58131
+ }
58132
+ // -------------------- Vector4 -------------------
58133
+ writeVector4(data2) {
58134
+ this.ensureCapacity(4 + 4 + 4 + 4);
58135
+ this.writeFloat(data2.x);
58136
+ this.writeFloat(data2.y);
58137
+ this.writeFloat(data2.z);
58138
+ this.writeFloat(data2.w);
58139
+ }
58140
+ // -------------------- RGBA -------------------
58141
+ writeRGBA(color) {
58142
+ this.ensureCapacity(4 + 4 + 4 + 4);
58143
+ this.writeFloat(color.r);
58144
+ this.writeFloat(color.g);
58145
+ this.writeFloat(color.b);
58146
+ this.writeFloat(color.a);
58147
+ }
58148
+ // -------------------- RGB -------------------
58149
+ writeRGB(color) {
58150
+ this.ensureCapacity(4 + 4 + 4 + 4);
58151
+ this.writeFloat(color.r);
58152
+ this.writeFloat(color.g);
58153
+ this.writeFloat(color.b);
58154
+ }
58155
+ // -------------------- RGBA32 -------------------
58156
+ writeRGBA32(color) {
58157
+ this.ensureCapacity(4);
58158
+ this.writeUInt(color.hex);
58159
+ }
58160
+ // -------------------- CameraPositionAndTarget -------------------
58161
+ writeSegment(segment) {
58162
+ this.ensureCapacity(4 * 3 * 2);
58163
+ this.writeVector3(segment.origin);
58164
+ this.writeVector3(segment.target);
58165
+ }
58166
+ // -------------------- Box3 -------------------
58167
+ writeBox3(data2) {
58168
+ this.ensureCapacity(4 * 3 * 2);
58169
+ this.writeVector3(data2.min);
58170
+ this.writeVector3(data2.max);
58171
+ }
58172
+ // -------------------- SectionBox -------------------
58173
+ writeSectionBoxState(data2) {
58174
+ this.writeBoolean(data2.enabled);
58175
+ this.writeBoolean(data2.visible);
58176
+ this.writeBoolean(data2.interactible);
58177
+ this.writeBoolean(data2.clip);
58178
+ this.writeBox3(data2.box);
58179
+ }
58180
+ // -------------------- Array of Int -------------------
58181
+ writeArrayOfInt(values) {
58182
+ this.writeArray(values, 4, (v) => this.writeInt(v));
58183
+ }
58184
+ // -------------------- Array of UInt -------------------
58185
+ writeArrayOfUInt(values) {
58186
+ this.writeArray(values, 4, (v) => this.writeUInt(v));
58187
+ }
58188
+ // -------------------- Array of Float -------------------
58189
+ writeArrayOfFloat(values) {
58190
+ this.writeArray(values, 4, (v) => this.writeFloat(v));
58191
+ }
58192
+ // -------------------- Array of Bool -------------------
58193
+ writeArrayOfBool(values) {
58194
+ this.writeArray(values, 4, (v) => this.writeBoolean(v));
58195
+ }
58196
+ // -------------------- Array of RGBA32 -------------------
58197
+ writeArrayOfRGBA32(values) {
58198
+ this.writeArray(values, 4, (v) => this.writeRGBA32(v));
58199
+ }
58200
+ // -------------------- Helpers --------------------
58201
+ writeArray(data2, sizeT, write) {
58202
+ this.ensureCapacity(4 + data2.length * sizeT);
58203
+ this.writeUInt(data2.length);
58204
+ data2.forEach((value) => write(value));
58205
+ }
58206
+ }
58207
+ class ReadMarshal {
58208
+ constructor(buffer) {
58209
+ __publicField(this, "_dataView");
58210
+ __publicField(this, "_offset", 0);
58211
+ this._dataView = new DataView(buffer);
58212
+ }
57714
58213
  readMatrix44() {
57715
58214
  const m00 = this.readFloat();
57716
58215
  const m01 = this.readFloat();
@@ -57730,74 +58229,33 @@ void main() {
57730
58229
  const m33 = this.readFloat();
57731
58230
  return new Matrix4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33);
57732
58231
  }
57733
- // -------------------- Boolean Methods --------------------
57734
- writeBoolean(value) {
57735
- this.ensureCapacity(4);
57736
- this.dataView.setUint32(this.writeOffset, value ? 1 : 0, true);
57737
- this.writeOffset += 4;
57738
- }
57739
- readBoolean() {
57740
- const value = this.dataView.getUint32(this.readOffset, true);
57741
- this.readOffset += 4;
57742
- return value !== 0;
57743
- }
57744
- // -------------------- Int Methods --------------------
57745
- writeInt(value) {
57746
- this.ensureCapacity(4);
57747
- this.dataView.setInt32(this.writeOffset, value, true);
57748
- this.writeOffset += 4;
57749
- }
57750
58232
  readInt() {
57751
- const value = this.dataView.getInt32(this.readOffset, true);
57752
- this.readOffset += 4;
58233
+ const value = this._dataView.getInt32(this._offset, true);
58234
+ this._offset += 4;
57753
58235
  return value;
57754
58236
  }
57755
- // -------------------- UInt Methods --------------------
57756
- writeUInt(value) {
57757
- this.ensureCapacity(4);
57758
- this.dataView.setUint32(this.writeOffset, value, true);
57759
- this.writeOffset += 4;
57760
- }
57761
58237
  readUInt() {
57762
- const value = this.dataView.getUint32(this.readOffset, true);
57763
- this.readOffset += 4;
58238
+ const value = this._dataView.getUint32(this._offset, true);
58239
+ this._offset += 4;
57764
58240
  return value;
57765
58241
  }
57766
- // -------------------- Float Methods --------------------
57767
- writeFloat(value) {
57768
- this.ensureCapacity(4);
57769
- this.dataView.setFloat32(this.writeOffset, value, true);
57770
- this.writeOffset += 4;
57771
- }
57772
58242
  readFloat() {
57773
- const value = this.dataView.getFloat32(this.readOffset, true);
57774
- this.readOffset += 4;
58243
+ const value = this._dataView.getFloat32(this._offset, true);
58244
+ this._offset += 4;
57775
58245
  return value;
57776
58246
  }
57777
- // -------------------- String Methods --------------------
57778
- writeString(value) {
57779
- const textEncoder = new TextEncoder();
57780
- const encodedString = textEncoder.encode(value + "\0");
57781
- this.ensureCapacity(4 + encodedString.byteLength);
57782
- this.writeUInt(encodedString.length);
57783
- new Uint8Array(this.buffer, this.writeOffset).set(encodedString);
57784
- this.writeOffset += encodedString.length;
58247
+ readBoolean() {
58248
+ const value = this._dataView.getUint32(this._offset, true);
58249
+ this._offset += 4;
58250
+ return value !== 0;
57785
58251
  }
57786
58252
  readString() {
57787
58253
  const length = this.readUInt();
57788
58254
  const textDecoder = new TextDecoder();
57789
- const stringData = new Uint8Array(this.buffer, this.readOffset, length - 1);
57790
- this.readOffset += length;
58255
+ const stringData = new Uint8Array(this._dataView.buffer, this._offset, length - 1);
58256
+ this._offset += length;
57791
58257
  return textDecoder.decode(stringData);
57792
58258
  }
57793
- // -------------------- HitCheckResult Methods --------------------
57794
- writeHitCheckResult(data2) {
57795
- this.ensureCapacity(4 + 4 + 4 * 3 + 4 * 3);
57796
- this.writeUInt(data2.vimHandle);
57797
- this.writeUInt(data2.nodeIndex);
57798
- this.writeVector3(data2.worldPosition);
57799
- this.writeVector3(data2.worldNormal);
57800
- }
57801
58259
  readHitCheckResult() {
57802
58260
  const vimHandle = this.readUInt();
57803
58261
  const nodeIndex = this.readUInt();
@@ -57810,12 +58268,6 @@ void main() {
57810
58268
  worldNormal
57811
58269
  };
57812
58270
  }
57813
- // -------------------- VimStatus Methods --------------------
57814
- writeVimStatus(data2) {
57815
- this.ensureCapacity(4 + 4);
57816
- this.writeUInt(data2.status);
57817
- this.writeFloat(data2.progress);
57818
- }
57819
58271
  readVimStatus() {
57820
58272
  const status = this.readUInt();
57821
58273
  const progress = this.readFloat();
@@ -57824,38 +58276,17 @@ void main() {
57824
58276
  progress
57825
58277
  };
57826
58278
  }
57827
- // -------------------- Vector2 Methods --------------------
57828
- writeVector2(data2) {
57829
- this.ensureCapacity(4 + 4);
57830
- this.writeFloat(data2.x);
57831
- this.writeFloat(data2.y);
57832
- }
57833
58279
  readVector2() {
57834
58280
  const x = this.readFloat();
57835
58281
  const y = this.readFloat();
57836
58282
  return new Vector2(x, y);
57837
58283
  }
57838
- // -------------------- Vector3 Methods --------------------
57839
- writeVector3(data2) {
57840
- this.ensureCapacity(4 + 4 + 4);
57841
- this.writeFloat(data2.x);
57842
- this.writeFloat(data2.y);
57843
- this.writeFloat(data2.z);
57844
- }
57845
58284
  readVector3() {
57846
58285
  const x = this.readFloat();
57847
58286
  const y = this.readFloat();
57848
58287
  const z = this.readFloat();
57849
58288
  return new Vector3(x, y, z);
57850
58289
  }
57851
- // -------------------- Vector4 Methods --------------------
57852
- writeVector4(data2) {
57853
- this.ensureCapacity(4 + 4 + 4 + 4);
57854
- this.writeFloat(data2.x);
57855
- this.writeFloat(data2.y);
57856
- this.writeFloat(data2.z);
57857
- this.writeFloat(data2.w);
57858
- }
57859
58290
  readVector4() {
57860
58291
  const x = this.readFloat();
57861
58292
  const y = this.readFloat();
@@ -57868,14 +58299,6 @@ void main() {
57868
58299
  w
57869
58300
  };
57870
58301
  }
57871
- // -------------------- RGBA Methods --------------------
57872
- writeRGBA(color) {
57873
- this.ensureCapacity(4 + 4 + 4 + 4);
57874
- this.writeFloat(color.r);
57875
- this.writeFloat(color.g);
57876
- this.writeFloat(color.b);
57877
- this.writeFloat(color.a);
57878
- }
57879
58302
  readRGBA() {
57880
58303
  const r = this.readFloat();
57881
58304
  const g = this.readFloat();
@@ -57883,91 +58306,55 @@ void main() {
57883
58306
  const a = this.readFloat();
57884
58307
  return new RGBA(r, g, b, a);
57885
58308
  }
57886
- // -------------------- RGB Methods --------------------
57887
- writeRGB(color) {
57888
- this.ensureCapacity(4 + 4 + 4 + 4);
57889
- this.writeFloat(color.r);
57890
- this.writeFloat(color.g);
57891
- this.writeFloat(color.b);
57892
- }
57893
58309
  readRGB() {
57894
58310
  const r = this.readFloat();
57895
58311
  const g = this.readFloat();
57896
58312
  const b = this.readFloat();
57897
58313
  return new RGB(r, g, b);
57898
58314
  }
57899
- // -------------------- RGBA32 Methods --------------------
57900
- writeRGBA32(color) {
57901
- this.ensureCapacity(4);
57902
- this.writeUInt(color.hex);
57903
- }
57904
58315
  readRGBA32() {
57905
58316
  const hex = this.readUInt();
57906
58317
  return new RGBA32(hex);
57907
58318
  }
57908
- // -------------------- CameraPositionAndTarget Methods --------------------
57909
- writeSegment(segment) {
57910
- this.ensureCapacity(4 * 3 * 2);
57911
- this.writeVector3(segment.origin);
57912
- this.writeVector3(segment.target);
58319
+ readBox3() {
58320
+ const min2 = this.readVector3();
58321
+ const max2 = this.readVector3();
58322
+ return new Box3(min2, max2);
57913
58323
  }
57914
58324
  readSegment() {
57915
58325
  const position = this.readVector3();
57916
58326
  const target = this.readVector3();
57917
58327
  return new Segment(position, target);
57918
58328
  }
57919
- // -------------------- Box3 Methods --------------------
57920
- writeBox3(data2) {
57921
- this.ensureCapacity(4 * 3 * 2);
57922
- this.writeVector3(data2.min);
57923
- this.writeVector3(data2.max);
57924
- }
57925
- readBox3() {
57926
- const min2 = this.readVector3();
57927
- const max2 = this.readVector3();
57928
- return new Box3(min2, max2);
57929
- }
57930
- // -------------------- Array of Int Methods --------------------
57931
- writeArrayOfInt(values) {
57932
- this.writeArray(values, 4, (v) => this.writeInt(v));
58329
+ readSectionBoxState() {
58330
+ const enabled = this.readBoolean();
58331
+ const visible2 = this.readBoolean();
58332
+ const interactible = this.readBoolean();
58333
+ const clip = this.readBoolean();
58334
+ const box = this.readBox3();
58335
+ return {
58336
+ enabled,
58337
+ visible: visible2,
58338
+ interactible,
58339
+ clip,
58340
+ box
58341
+ };
57933
58342
  }
57934
58343
  readArrayOfInt() {
57935
58344
  return this.readArray(() => this.readInt());
57936
58345
  }
57937
- // -------------------- Array of UInt Methods --------------------
57938
- writeArrayOfUInt(values) {
57939
- this.writeArray(values, 4, (v) => this.writeUInt(v));
57940
- }
57941
58346
  readArrayOfUInt() {
57942
58347
  return this.readArray(() => this.readUInt());
57943
58348
  }
57944
- // -------------------- Array of Float Methods --------------------
57945
- writeArrayOfFloat(values) {
57946
- this.writeArray(values, 4, (v) => this.writeFloat(v));
57947
- }
57948
58349
  readArrayOfFloat() {
57949
58350
  return this.readArray(() => this.readFloat());
57950
58351
  }
57951
- // -------------------- Array of Bool Methods --------------------
57952
- writeArrayOfBool(values) {
57953
- this.writeArray(values, 4, (v) => this.writeBoolean(v));
57954
- }
57955
58352
  readArrayOfBool() {
57956
58353
  return this.readArray(() => this.readBoolean());
57957
58354
  }
57958
- // -------------------- Array of RGBA32 Methods --------------------
57959
- writeArrayOfRGBA32(values) {
57960
- this.writeArray(values, 4, (v) => this.writeRGBA32(v));
57961
- }
57962
58355
  readArrayOfRGBA32() {
57963
58356
  return this.readArray(() => this.readRGBA32());
57964
58357
  }
57965
- // -------------------- Helpers --------------------
57966
- writeArray(data2, sizeT, write) {
57967
- this.ensureCapacity(4 + data2.length * sizeT);
57968
- this.writeUInt(data2.length);
57969
- data2.forEach((value) => write(value));
57970
- }
57971
58358
  readArray(read) {
57972
58359
  const length = this.readUInt();
57973
58360
  const array = [];
@@ -58002,17 +58389,17 @@ void main() {
58002
58389
  MaterialHandles.Invisible
58003
58390
  ];
58004
58391
  class RpcClient {
58005
- constructor(_messenger) {
58006
- __publicField(this, "_messenger");
58392
+ constructor(_socket) {
58393
+ __publicField(this, "_socket");
58007
58394
  // RPC Generated Code
58008
- __publicField(this, "API_VERSION", "5.0.0");
58009
- this._messenger = _messenger;
58010
- }
58011
- get url() {
58012
- return this._messenger.url;
58395
+ __publicField(this, "API_VERSION", "5.1.0");
58396
+ this._socket = _socket;
58013
58397
  }
58014
58398
  get connected() {
58015
- return this._messenger.state.status === "connected";
58399
+ return this._socket.state.status === "connected";
58400
+ }
58401
+ get url() {
58402
+ return this._socket.url;
58016
58403
  }
58017
58404
  RPCAddNodeFlags(componentHandle, nodes, flags) {
58018
58405
  const marshal = new Marshal();
@@ -58020,18 +58407,18 @@ void main() {
58020
58407
  marshal.writeUInt(componentHandle);
58021
58408
  marshal.writeArrayOfUInt(nodes);
58022
58409
  marshal.writeUInt(flags);
58023
- this._messenger.sendRPC(marshal);
58410
+ this._socket.sendRPC(marshal);
58024
58411
  }
58025
58412
  RPCClearMaterialOverrides(componentHandle) {
58026
58413
  const marshal = new Marshal();
58027
58414
  marshal.writeString("RPCClearMaterialOverrides");
58028
58415
  marshal.writeUInt(componentHandle);
58029
- this._messenger.sendRPC(marshal);
58416
+ this._socket.sendRPC(marshal);
58030
58417
  }
58031
58418
  RPCClearScene() {
58032
58419
  const marshal = new Marshal();
58033
58420
  marshal.writeString("RPCClearScene");
58034
- this._messenger.sendRPC(marshal);
58421
+ this._socket.sendRPC(marshal);
58035
58422
  }
58036
58423
  async RPCCreateMaterialInstances(materialHandle, smoothness, colors) {
58037
58424
  const marshal = new Marshal();
@@ -58039,7 +58426,7 @@ void main() {
58039
58426
  marshal.writeUInt(materialHandle);
58040
58427
  marshal.writeUInt(smoothness);
58041
58428
  marshal.writeArrayOfRGBA32(colors);
58042
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58429
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58043
58430
  const ret = returnMarshal.readUInt();
58044
58431
  return ret;
58045
58432
  }
@@ -58049,7 +58436,7 @@ void main() {
58049
58436
  marshal.writeVector3(position);
58050
58437
  marshal.writeRGBA32(color);
58051
58438
  marshal.writeString(text);
58052
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58439
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58053
58440
  const ret = returnMarshal.readUInt();
58054
58441
  return ret;
58055
58442
  }
@@ -58057,25 +58444,19 @@ void main() {
58057
58444
  const marshal = new Marshal();
58058
58445
  marshal.writeString("RPCDestroyMaterialInstances");
58059
58446
  marshal.writeArrayOfUInt(materialInstanceHandle);
58060
- this._messenger.sendRPC(marshal);
58447
+ this._socket.sendRPC(marshal);
58061
58448
  }
58062
58449
  RPCDestroyText(componentHandle) {
58063
58450
  const marshal = new Marshal();
58064
58451
  marshal.writeString("RPCDestroyText");
58065
58452
  marshal.writeUInt(componentHandle);
58066
- this._messenger.sendRPC(marshal);
58067
- }
58068
- RPCEnableSectionBox(enable) {
58069
- const marshal = new Marshal();
58070
- marshal.writeString("RPCEnableSectionBox");
58071
- marshal.writeBoolean(enable);
58072
- this._messenger.sendRPC(marshal);
58453
+ this._socket.sendRPC(marshal);
58073
58454
  }
58074
58455
  async RPCFrameAll(blendTime) {
58075
58456
  const marshal = new Marshal();
58076
58457
  marshal.writeString("RPCFrameAll");
58077
58458
  marshal.writeFloat(blendTime);
58078
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58459
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58079
58460
  const ret = returnMarshal.readSegment();
58080
58461
  return ret;
58081
58462
  }
@@ -58084,7 +58465,7 @@ void main() {
58084
58465
  marshal.writeString("RPCFrameBox");
58085
58466
  marshal.writeBox3(box);
58086
58467
  marshal.writeFloat(blendTime);
58087
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58468
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58088
58469
  const ret = returnMarshal.readSegment();
58089
58470
  return ret;
58090
58471
  }
@@ -58094,7 +58475,7 @@ void main() {
58094
58475
  marshal.writeUInt(componentHandle);
58095
58476
  marshal.writeArrayOfUInt(nodes);
58096
58477
  marshal.writeFloat(blendTime);
58097
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58478
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58098
58479
  const ret = returnMarshal.readSegment();
58099
58480
  return ret;
58100
58481
  }
@@ -58103,14 +58484,14 @@ void main() {
58103
58484
  marshal.writeString("RPCFrameVim");
58104
58485
  marshal.writeUInt(componentHandle);
58105
58486
  marshal.writeFloat(blendTime);
58106
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58487
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58107
58488
  const ret = returnMarshal.readSegment();
58108
58489
  return ret;
58109
58490
  }
58110
58491
  async RPCGetAPIVersion() {
58111
58492
  const marshal = new Marshal();
58112
58493
  marshal.writeString("RPCGetAPIVersion");
58113
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58494
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58114
58495
  const ret = returnMarshal.readString();
58115
58496
  return ret;
58116
58497
  }
@@ -58119,36 +58500,58 @@ void main() {
58119
58500
  marshal.writeString("RPCGetBoundingBox");
58120
58501
  marshal.writeUInt(componentHandle);
58121
58502
  marshal.writeArrayOfUInt(nodes);
58122
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58503
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58504
+ const ret = returnMarshal.readBox3();
58505
+ return ret;
58506
+ }
58507
+ async RPCGetBoundingBoxAll(componentHandle) {
58508
+ const marshal = new Marshal();
58509
+ marshal.writeString("RPCGetBoundingBoxAll");
58510
+ marshal.writeUInt(componentHandle);
58511
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58123
58512
  const ret = returnMarshal.readBox3();
58124
58513
  return ret;
58125
58514
  }
58126
58515
  async RPCGetCameraPosition() {
58127
58516
  const marshal = new Marshal();
58128
58517
  marshal.writeString("RPCGetCameraPosition");
58129
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58518
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58130
58519
  const ret = returnMarshal.readSegment();
58131
58520
  return ret;
58132
58521
  }
58133
58522
  async RPCGetIblRotation() {
58134
58523
  const marshal = new Marshal();
58135
58524
  marshal.writeString("RPCGetIblRotation");
58136
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58525
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58137
58526
  const ret = returnMarshal.readMatrix44();
58138
58527
  return ret;
58139
58528
  }
58140
58529
  async RPCGetLastError() {
58141
58530
  const marshal = new Marshal();
58142
58531
  marshal.writeString("RPCGetLastError");
58143
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58532
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58144
58533
  const ret = returnMarshal.readString();
58145
58534
  return ret;
58146
58535
  }
58536
+ async RPCGetSceneAABB() {
58537
+ const marshal = new Marshal();
58538
+ marshal.writeString("RPCGetSceneAABB");
58539
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58540
+ const ret = returnMarshal.readBox3();
58541
+ return ret;
58542
+ }
58543
+ async RPCGetSectionBox() {
58544
+ const marshal = new Marshal();
58545
+ marshal.writeString("RPCGetSectionBox");
58546
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58547
+ const ret = returnMarshal.readSectionBoxState();
58548
+ return ret;
58549
+ }
58147
58550
  async RPCGetVimLoadingState(componentHandle) {
58148
58551
  const marshal = new Marshal();
58149
58552
  marshal.writeString("RPCGetVimLoadingState");
58150
58553
  marshal.writeUInt(componentHandle);
58151
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58554
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58152
58555
  const ret = returnMarshal.readVimStatus();
58153
58556
  return ret;
58154
58557
  }
@@ -58157,65 +58560,65 @@ void main() {
58157
58560
  marshal.writeString("RPCGhost");
58158
58561
  marshal.writeUInt(componentHandle);
58159
58562
  marshal.writeArrayOfUInt(nodes);
58160
- this._messenger.sendRPC(marshal);
58563
+ this._socket.sendRPC(marshal);
58161
58564
  }
58162
58565
  RPCGhostAll(componentHandle) {
58163
58566
  const marshal = new Marshal();
58164
58567
  marshal.writeString("RPCGhostAll");
58165
58568
  marshal.writeUInt(componentHandle);
58166
- this._messenger.sendRPC(marshal);
58569
+ this._socket.sendRPC(marshal);
58167
58570
  }
58168
58571
  RPCHide(componentHandle, nodes) {
58169
58572
  const marshal = new Marshal();
58170
58573
  marshal.writeString("RPCHide");
58171
58574
  marshal.writeUInt(componentHandle);
58172
58575
  marshal.writeArrayOfUInt(nodes);
58173
- this._messenger.sendRPC(marshal);
58576
+ this._socket.sendRPC(marshal);
58174
58577
  }
58175
58578
  RPCHideAABBs(componentHandle, nodes) {
58176
58579
  const marshal = new Marshal();
58177
58580
  marshal.writeString("RPCHideAABBs");
58178
58581
  marshal.writeUInt(componentHandle);
58179
58582
  marshal.writeArrayOfUInt(nodes);
58180
- this._messenger.sendRPC(marshal);
58583
+ this._socket.sendRPC(marshal);
58181
58584
  }
58182
58585
  RPCHideAll(componentHandle) {
58183
58586
  const marshal = new Marshal();
58184
58587
  marshal.writeString("RPCHideAll");
58185
58588
  marshal.writeUInt(componentHandle);
58186
- this._messenger.sendRPC(marshal);
58589
+ this._socket.sendRPC(marshal);
58187
58590
  }
58188
58591
  RPCHideAllAABBs(componentHandle) {
58189
58592
  const marshal = new Marshal();
58190
58593
  marshal.writeString("RPCHideAllAABBs");
58191
58594
  marshal.writeUInt(componentHandle);
58192
- this._messenger.sendRPC(marshal);
58595
+ this._socket.sendRPC(marshal);
58193
58596
  }
58194
58597
  RPCHighlight(componentHandle, nodes) {
58195
58598
  const marshal = new Marshal();
58196
58599
  marshal.writeString("RPCHighlight");
58197
58600
  marshal.writeUInt(componentHandle);
58198
58601
  marshal.writeArrayOfUInt(nodes);
58199
- this._messenger.sendRPC(marshal);
58602
+ this._socket.sendRPC(marshal);
58200
58603
  }
58201
58604
  RPCHighlightAll(componentHandle) {
58202
58605
  const marshal = new Marshal();
58203
58606
  marshal.writeString("RPCHighlightAll");
58204
58607
  marshal.writeUInt(componentHandle);
58205
- this._messenger.sendRPC(marshal);
58608
+ this._socket.sendRPC(marshal);
58206
58609
  }
58207
58610
  RPCKeyEvent(keyCode, down) {
58208
58611
  const marshal = new Marshal();
58209
58612
  marshal.writeString("RPCKeyEvent");
58210
58613
  marshal.writeInt(keyCode);
58211
58614
  marshal.writeBoolean(down);
58212
- this._messenger.sendRPC(marshal);
58615
+ this._socket.sendRPC(marshal);
58213
58616
  }
58214
58617
  async RPCLoadVim(fileName) {
58215
58618
  const marshal = new Marshal();
58216
58619
  marshal.writeString("RPCLoadVim");
58217
58620
  marshal.writeString(fileName);
58218
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58621
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58219
58622
  const ret = returnMarshal.readUInt();
58220
58623
  return ret;
58221
58624
  }
@@ -58224,7 +58627,7 @@ void main() {
58224
58627
  marshal.writeString("RPCLoadVimURL");
58225
58628
  marshal.writeString(url);
58226
58629
  marshal.writeString(authToken);
58227
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58630
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58228
58631
  const ret = returnMarshal.readUInt();
58229
58632
  return ret;
58230
58633
  }
@@ -58232,7 +58635,7 @@ void main() {
58232
58635
  const marshal = new Marshal();
58233
58636
  marshal.writeString("RPCLockIblRotation");
58234
58637
  marshal.writeBoolean(lock);
58235
- this._messenger.sendRPC(marshal);
58638
+ this._socket.sendRPC(marshal);
58236
58639
  }
58237
58640
  RPCMouseButtonEvent(mousePos, mouseButton, down) {
58238
58641
  const marshal = new Marshal();
@@ -58240,33 +58643,33 @@ void main() {
58240
58643
  marshal.writeVector2(mousePos);
58241
58644
  marshal.writeInt(mouseButton);
58242
58645
  marshal.writeBoolean(down);
58243
- this._messenger.sendRPC(marshal);
58646
+ this._socket.sendRPC(marshal);
58244
58647
  }
58245
58648
  RPCMouseDoubleClickEvent(mousePos, mouseButton) {
58246
58649
  const marshal = new Marshal();
58247
58650
  marshal.writeString("RPCMouseDoubleClickEvent");
58248
58651
  marshal.writeVector2(mousePos);
58249
58652
  marshal.writeInt(mouseButton);
58250
- this._messenger.sendRPC(marshal);
58653
+ this._socket.sendRPC(marshal);
58251
58654
  }
58252
58655
  RPCMouseMoveEvent(mousePos) {
58253
58656
  const marshal = new Marshal();
58254
58657
  marshal.writeString("RPCMouseMoveEvent");
58255
58658
  marshal.writeVector2(mousePos);
58256
- this._messenger.sendRPC(marshal);
58659
+ this._socket.sendRPC(marshal);
58257
58660
  }
58258
58661
  RPCMouseScrollEvent(scrollValue) {
58259
58662
  const marshal = new Marshal();
58260
58663
  marshal.writeString("RPCMouseScrollEvent");
58261
58664
  marshal.writeInt(scrollValue);
58262
- this._messenger.sendRPC(marshal);
58665
+ this._socket.sendRPC(marshal);
58263
58666
  }
58264
58667
  RPCMouseSelectEvent(mousePos, mouseButton) {
58265
58668
  const marshal = new Marshal();
58266
58669
  marshal.writeString("RPCMouseSelectEvent");
58267
58670
  marshal.writeVector2(mousePos);
58268
58671
  marshal.writeInt(mouseButton);
58269
- this._messenger.sendRPC(marshal);
58672
+ this._socket.sendRPC(marshal);
58270
58673
  }
58271
58674
  RPCMoveCameraTo(usePosition, useTarget, position, target, blendTime) {
58272
58675
  const marshal = new Marshal();
@@ -58276,19 +58679,19 @@ void main() {
58276
58679
  marshal.writeVector3(position);
58277
58680
  marshal.writeVector3(target);
58278
58681
  marshal.writeFloat(blendTime);
58279
- this._messenger.sendRPC(marshal);
58682
+ this._socket.sendRPC(marshal);
58280
58683
  }
58281
58684
  RPCPauseRendering(pause) {
58282
58685
  const marshal = new Marshal();
58283
58686
  marshal.writeString("RPCPauseRendering");
58284
58687
  marshal.writeBoolean(pause);
58285
- this._messenger.sendRPC(marshal);
58688
+ this._socket.sendRPC(marshal);
58286
58689
  }
58287
58690
  async RPCPerformHitTest(pos) {
58288
58691
  const marshal = new Marshal();
58289
58692
  marshal.writeString("RPCPerformHitTest");
58290
58693
  marshal.writeVector2(pos);
58291
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58694
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58292
58695
  const ret = returnMarshal.readHitCheckResult();
58293
58696
  return ret;
58294
58697
  }
@@ -58298,39 +58701,39 @@ void main() {
58298
58701
  marshal.writeUInt(componentHandle);
58299
58702
  marshal.writeArrayOfUInt(nodes);
58300
58703
  marshal.writeUInt(flags);
58301
- this._messenger.sendRPC(marshal);
58704
+ this._socket.sendRPC(marshal);
58302
58705
  }
58303
58706
  RPCSetAspectRatio(width, height) {
58304
58707
  const marshal = new Marshal();
58305
58708
  marshal.writeString("RPCSetAspectRatio");
58306
58709
  marshal.writeUInt(width);
58307
58710
  marshal.writeUInt(height);
58308
- this._messenger.sendRPC(marshal);
58711
+ this._socket.sendRPC(marshal);
58309
58712
  }
58310
58713
  RPCSetCameraMode(orbit2) {
58311
58714
  const marshal = new Marshal();
58312
58715
  marshal.writeString("RPCSetCameraMode");
58313
58716
  marshal.writeBoolean(orbit2);
58314
- this._messenger.sendRPC(marshal);
58717
+ this._socket.sendRPC(marshal);
58315
58718
  }
58316
58719
  RPCSetCameraPosition(state, blendTime) {
58317
58720
  const marshal = new Marshal();
58318
58721
  marshal.writeString("RPCSetCameraPosition");
58319
58722
  marshal.writeSegment(state);
58320
58723
  marshal.writeFloat(blendTime);
58321
- this._messenger.sendRPC(marshal);
58724
+ this._socket.sendRPC(marshal);
58322
58725
  }
58323
58726
  RPCSetGhostColor(ghostColor) {
58324
58727
  const marshal = new Marshal();
58325
58728
  marshal.writeString("RPCSetGhostColor");
58326
58729
  marshal.writeRGBA(ghostColor);
58327
- this._messenger.sendRPC(marshal);
58730
+ this._socket.sendRPC(marshal);
58328
58731
  }
58329
58732
  RPCSetIblRotation(transform) {
58330
58733
  const marshal = new Marshal();
58331
58734
  marshal.writeString("RPCSetIblRotation");
58332
58735
  marshal.writeMatrix44(transform);
58333
- this._messenger.sendRPC(marshal);
58736
+ this._socket.sendRPC(marshal);
58334
58737
  }
58335
58738
  RPCSetLighting(toneMappingWhitePoint, hdrScale, hdrBackgroundScale, hdrBackgroundSaturation, backgroundBlur, backgroundColor) {
58336
58739
  const marshal = new Marshal();
@@ -58341,7 +58744,7 @@ void main() {
58341
58744
  marshal.writeFloat(hdrBackgroundSaturation);
58342
58745
  marshal.writeFloat(backgroundBlur);
58343
58746
  marshal.writeRGBA(backgroundColor);
58344
- this._messenger.sendRPC(marshal);
58747
+ this._socket.sendRPC(marshal);
58345
58748
  }
58346
58749
  RPCSetMaterialOverrides(componentHandle, nodes, materialInstanceHandles) {
58347
58750
  const marshal = new Marshal();
@@ -58349,26 +58752,26 @@ void main() {
58349
58752
  marshal.writeUInt(componentHandle);
58350
58753
  marshal.writeArrayOfUInt(nodes);
58351
58754
  marshal.writeArrayOfUInt(materialInstanceHandles);
58352
- this._messenger.sendRPC(marshal);
58755
+ this._socket.sendRPC(marshal);
58353
58756
  }
58354
58757
  RPCSetMoveSpeed(speed) {
58355
58758
  const marshal = new Marshal();
58356
58759
  marshal.writeString("RPCSetMoveSpeed");
58357
58760
  marshal.writeFloat(speed);
58358
- this._messenger.sendRPC(marshal);
58761
+ this._socket.sendRPC(marshal);
58359
58762
  }
58360
- RPCSetSectionBox(aabb) {
58763
+ RPCSetSectionBox(state) {
58361
58764
  const marshal = new Marshal();
58362
58765
  marshal.writeString("RPCSetSectionBox");
58363
- marshal.writeBox3(aabb);
58364
- this._messenger.sendRPC(marshal);
58766
+ marshal.writeSectionBoxState(state);
58767
+ this._socket.sendRPC(marshal);
58365
58768
  }
58366
58769
  RPCShow(componentHandle, nodes) {
58367
58770
  const marshal = new Marshal();
58368
58771
  marshal.writeString("RPCShow");
58369
58772
  marshal.writeUInt(componentHandle);
58370
58773
  marshal.writeArrayOfUInt(nodes);
58371
- this._messenger.sendRPC(marshal);
58774
+ this._socket.sendRPC(marshal);
58372
58775
  }
58373
58776
  RPCShowAABBs(componentHandle, nodes, colors) {
58374
58777
  const marshal = new Marshal();
@@ -58376,13 +58779,13 @@ void main() {
58376
58779
  marshal.writeUInt(componentHandle);
58377
58780
  marshal.writeArrayOfUInt(nodes);
58378
58781
  marshal.writeArrayOfRGBA32(colors);
58379
- this._messenger.sendRPC(marshal);
58782
+ this._socket.sendRPC(marshal);
58380
58783
  }
58381
58784
  RPCShowAll(componentHandle) {
58382
58785
  const marshal = new Marshal();
58383
58786
  marshal.writeString("RPCShowAll");
58384
58787
  marshal.writeUInt(componentHandle);
58385
- this._messenger.sendRPC(marshal);
58788
+ this._socket.sendRPC(marshal);
58386
58789
  }
58387
58790
  async RPCStartScene(toneMappingWhitePoint, hdrScale, hdrBackgroundScale, hdrBackgroundSaturation, backgroundBlur, backgroundColor) {
58388
58791
  const marshal = new Marshal();
@@ -58393,20 +58796,20 @@ void main() {
58393
58796
  marshal.writeFloat(hdrBackgroundSaturation);
58394
58797
  marshal.writeFloat(backgroundBlur);
58395
58798
  marshal.writeRGBA(backgroundColor);
58396
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58799
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58397
58800
  const ret = returnMarshal.readBoolean();
58398
58801
  return ret;
58399
58802
  }
58400
58803
  RPCTriggerRenderDocCapture() {
58401
58804
  const marshal = new Marshal();
58402
58805
  marshal.writeString("RPCTriggerRenderDocCapture");
58403
- this._messenger.sendRPC(marshal);
58806
+ this._socket.sendRPC(marshal);
58404
58807
  }
58405
58808
  RPCUnloadVim(componentHandle) {
58406
58809
  const marshal = new Marshal();
58407
58810
  marshal.writeString("RPCUnloadVim");
58408
58811
  marshal.writeUInt(componentHandle);
58409
- this._messenger.sendRPC(marshal);
58812
+ this._socket.sendRPC(marshal);
58410
58813
  }
58411
58814
  }
58412
58815
  class Validation {
@@ -58755,6 +59158,12 @@ void main() {
58755
59158
  RPCLockIblRotation(lock) {
58756
59159
  this.rpc.RPCLockIblRotation(lock);
58757
59160
  }
59161
+ RPCGetSceneAABB() {
59162
+ return this.safeCall(
59163
+ () => this.rpc.RPCGetSceneAABB(),
59164
+ void 0
59165
+ );
59166
+ }
58758
59167
  /*******************************************************************************
58759
59168
  * NODE VISIBILITY METHODS
58760
59169
  * Methods for controlling node visibility, including show/hide, ghosting,
@@ -58885,6 +59294,19 @@ void main() {
58885
59294
  if (!Validation.isComponentHandle(componentHandle)) return;
58886
59295
  this.rpc.RPCDestroyText(componentHandle);
58887
59296
  }
59297
+ /*******************************************************************************
59298
+ * SECTION BOX METHODS
59299
+ * Methods for controlling section box visibility and position.
59300
+ ******************************************************************************/
59301
+ RPCSetSectionBox(state) {
59302
+ this.rpc.RPCSetSectionBox(state);
59303
+ }
59304
+ async RPCGetSectionBox() {
59305
+ return await this.safeCall(
59306
+ () => this.rpc.RPCGetSectionBox(),
59307
+ void 0
59308
+ );
59309
+ }
58888
59310
  /*******************************************************************************
58889
59311
  * CAMERA AND VIEW METHODS
58890
59312
  * Methods for controlling camera position, movement, framing, and view settings.
@@ -58910,6 +59332,12 @@ void main() {
58910
59332
  blendTime = Validation.clamp01(blendTime);
58911
59333
  this.rpc.RPCSetCameraPosition(segment, blendTime);
58912
59334
  }
59335
+ async RPCGetBoundingBoxAll(componentHandle) {
59336
+ return await this.safeCall(
59337
+ () => this.rpc.RPCGetBoundingBoxAll(componentHandle),
59338
+ void 0
59339
+ );
59340
+ }
58913
59341
  /**
58914
59342
  * Calculates the bounding box for specified nodes in a component.
58915
59343
  * Large node arrays are automatically processed in batches for better performance.
@@ -59503,9 +59931,6 @@ void main() {
59503
59931
  * Starts logging the stream metrics.
59504
59932
  */
59505
59933
  startLoggging() {
59506
- this._id = setInterval(() => {
59507
- this.logMetrics();
59508
- }, 5e3);
59509
59934
  }
59510
59935
  /**
59511
59936
  * Stops logging the stream metrics.
@@ -59617,6 +60042,8 @@ Averrage Date/Second ${avgDataRatePS} kb
59617
60042
  */
59618
60043
  __publicField(this, "onVideoFrame", () => {
59619
60044
  });
60045
+ __publicField(this, "onCameraPose", () => {
60046
+ });
59620
60047
  __publicField(this, "_state", { status: "disconnected" });
59621
60048
  __publicField(this, "_onStatusUpdate", new distExports.SimpleEventDispatcher());
59622
60049
  __publicField(this, "_connectPromise", new ResolvedPromise(void 0));
@@ -59674,7 +60101,7 @@ Averrage Date/Second ${avgDataRatePS} kb
59674
60101
  return Promise.reject(new Error(`Invalid WebSocket URL: ${url}`));
59675
60102
  }
59676
60103
  if (this._socket) {
59677
- if (this._socket.url === url) {
60104
+ if (this._connectionSettings.url === url) {
59678
60105
  return this._connectPromise.promise;
59679
60106
  } else {
59680
60107
  this._clearSocket();
@@ -59761,6 +60188,10 @@ Averrage Date/Second ${avgDataRatePS} kb
59761
60188
  this.handleRPCResponse(msg.dataBuffer);
59762
60189
  return;
59763
60190
  case 254:
60191
+ const m = new ReadMarshal(msg.dataBuffer);
60192
+ if (this.onCameraPose) {
60193
+ this.onCameraPose(m.readSegment());
60194
+ }
59764
60195
  return;
59765
60196
  case 0:
59766
60197
  case 1:
@@ -59774,8 +60205,7 @@ Averrage Date/Second ${avgDataRatePS} kb
59774
60205
  * @param buffer - The ArrayBuffer containing the response data.
59775
60206
  */
59776
60207
  handleRPCResponse(buffer) {
59777
- const m = new Marshal();
59778
- m.writeData(buffer);
60208
+ const m = new ReadMarshal(buffer);
59779
60209
  const callId = m.readUInt();
59780
60210
  const pendingRPC = this._pendingRPCs.get(callId);
59781
60211
  if (pendingRPC !== void 0) {
@@ -60478,12 +60908,12 @@ Averrage Date/Second ${avgDataRatePS} kb
60478
60908
  * @throws Error if 'all' is passed, as this feature is not supported yet.
60479
60909
  */
60480
60910
  async getBoundingBox(nodes) {
60481
- if (nodes === "all") {
60482
- throw new Error("Feature not supported yet.");
60483
- }
60484
60911
  if (!this.connected || nodes.length === 0) {
60485
60912
  return Promise.resolve(void 0);
60486
60913
  }
60914
+ if (nodes === "all") {
60915
+ return await this._rpc.RPCGetBoundingBoxAll(this._handle);
60916
+ }
60487
60917
  return await this._rpc.RPCGetBoundingBox(this._handle, nodes);
60488
60918
  }
60489
60919
  /**
@@ -60945,7 +61375,7 @@ Averrage Date/Second ${avgDataRatePS} kb
60945
61375
  }
60946
61376
  /**
60947
61377
  * Restores the camera to its last tracked position
60948
- * @param blendTime - Duration of the camera animation in seconds
61378
+ * @param blendTime - Duration of the camera animation in seconds
60949
61379
  */
60950
61380
  restoreLastPosition(blendTime = this._defaultBlendTime) {
60951
61381
  var _a2;
@@ -60958,29 +61388,10 @@ Averrage Date/Second ${avgDataRatePS} kb
60958
61388
  * Handles camera initialization when connection is established
60959
61389
  */
60960
61390
  onConnect() {
60961
- this.startTracking();
60962
61391
  this.restoreLastPosition();
60963
61392
  }
60964
- /**
60965
- * Starts tracking camera position at regular intervals
60966
- */
60967
- startTracking() {
60968
- clearInterval(this._interval);
60969
- this._interval = setInterval(() => this.update(), 1e3);
60970
- }
60971
- /**
60972
- * Stops tracking camera position
60973
- */
60974
- stopTracking() {
60975
- clearInterval(this._interval);
60976
- this._interval = void 0;
60977
- }
60978
- /**
60979
- * Updates the stored camera position
60980
- * @private
60981
- */
60982
- async update() {
60983
- this._lastPosition = await this._rpc.RPCGetCameraPosition();
61393
+ onCameraPose(pose) {
61394
+ this._lastPosition = pose;
60984
61395
  }
60985
61396
  /**
60986
61397
  * Pauses or resumes rendering
@@ -61421,6 +61832,9 @@ Averrage Date/Second ${avgDataRatePS} kb
61421
61832
  this._updateLighting = true;
61422
61833
  this.requestSettingsUpdate();
61423
61834
  }
61835
+ getBoundingBox() {
61836
+ return this._rpc.RPCGetSceneAABB();
61837
+ }
61424
61838
  /**
61425
61839
  * Requests an update to be performed on the next animation frame.
61426
61840
  * Multiple setting changes will be batched into a single update.
@@ -61452,6 +61866,103 @@ Averrage Date/Second ${avgDataRatePS} kb
61452
61866
  }
61453
61867
  }
61454
61868
  }
61869
+ class SectionBox {
61870
+ constructor(rpc) {
61871
+ __publicField(this, "_enabled", false);
61872
+ __publicField(this, "_visible", true);
61873
+ __publicField(this, "_interactible", true);
61874
+ __publicField(this, "_clip", true);
61875
+ __publicField(this, "_box", new Box3());
61876
+ __publicField(this, "_rpc");
61877
+ __publicField(this, "_interval");
61878
+ __publicField(this, "_animationFrame");
61879
+ // Signals
61880
+ __publicField(this, "_onUpdate", new distExports$1.SignalDispatcher());
61881
+ this._rpc = rpc;
61882
+ }
61883
+ get onUpdate() {
61884
+ return this._onUpdate.asEvent();
61885
+ }
61886
+ get needUpdate() {
61887
+ return this._animationFrame > 0;
61888
+ }
61889
+ async onConnect() {
61890
+ this.push();
61891
+ this._interval = setInterval(() => this.pull(), 1e3);
61892
+ }
61893
+ scheduleUpdate() {
61894
+ if (this._animationFrame) return;
61895
+ this._animationFrame = requestAnimationFrame(() => {
61896
+ this._animationFrame = void 0;
61897
+ this.push();
61898
+ });
61899
+ }
61900
+ async pull() {
61901
+ if (this.needUpdate) return;
61902
+ const state = await this._rpc.RPCGetSectionBox();
61903
+ let changed = false;
61904
+ if (state.enabled !== this._enabled || state.visible !== this._visible || state.interactible !== this._interactible || state.clip !== this._clip || state.box !== this._box) {
61905
+ changed = true;
61906
+ }
61907
+ this._enabled = state.enabled;
61908
+ this._visible = state.visible;
61909
+ this._interactible = state.interactible;
61910
+ this._clip = state.clip;
61911
+ this._box = state.box;
61912
+ if (changed) {
61913
+ this._onUpdate.dispatch();
61914
+ }
61915
+ }
61916
+ async push() {
61917
+ await this._rpc.RPCSetSectionBox({
61918
+ enabled: this._enabled,
61919
+ visible: this._visible,
61920
+ interactible: this._interactible,
61921
+ clip: this._clip,
61922
+ box: this._box
61923
+ });
61924
+ }
61925
+ get enabled() {
61926
+ return this._enabled;
61927
+ }
61928
+ set enabled(value) {
61929
+ this._enabled = value;
61930
+ this.scheduleUpdate();
61931
+ }
61932
+ get visible() {
61933
+ return this._visible;
61934
+ }
61935
+ set visible(value) {
61936
+ this._visible = value;
61937
+ this.scheduleUpdate();
61938
+ }
61939
+ get interactible() {
61940
+ return this._interactible;
61941
+ }
61942
+ set interactible(value) {
61943
+ this._interactible = value;
61944
+ this.scheduleUpdate();
61945
+ }
61946
+ get clip() {
61947
+ return this._clip;
61948
+ }
61949
+ set clip(value) {
61950
+ this._clip = value;
61951
+ this.scheduleUpdate();
61952
+ }
61953
+ fitBox(box) {
61954
+ this._box = box;
61955
+ this.scheduleUpdate();
61956
+ }
61957
+ getBox() {
61958
+ return this._box;
61959
+ }
61960
+ dispose() {
61961
+ clearInterval(this._interval);
61962
+ cancelAnimationFrame(this._animationFrame);
61963
+ this._onUpdate.clear();
61964
+ }
61965
+ }
61455
61966
  const INVALID_HANDLE = 4294967295;
61456
61967
  class Viewer {
61457
61968
  /**
@@ -61479,6 +61990,10 @@ Averrage Date/Second ${avgDataRatePS} kb
61479
61990
  * API to create, manage, and destroy colors.
61480
61991
  */
61481
61992
  __publicField(this, "colors");
61993
+ /**
61994
+ * The section box API for controlling the section box.
61995
+ */
61996
+ __publicField(this, "sectionBox");
61482
61997
  this._logger = logger ?? defaultLogger;
61483
61998
  this._socketClient = new SocketClient(this._logger, () => this.validateConnection());
61484
61999
  this.rpc = new RpcSafeClient(new RpcClient(this._socketClient));
@@ -61491,7 +62006,9 @@ Averrage Date/Second ${avgDataRatePS} kb
61491
62006
  this.colors = new ColorManager(this.rpc);
61492
62007
  this._camera = new Camera(this.rpc);
61493
62008
  this._input = new Inputs(canvas, this.rpc, this._selection, this._camera, this._renderer);
62009
+ this.sectionBox = new SectionBox(this.rpc);
61494
62010
  this._socketClient.onVideoFrame = (msg) => this._decoder.enqueue(msg);
62011
+ this._socketClient.onCameraPose = (pose) => this._camera.onCameraPose(pose);
61495
62012
  this._socketClient.onStatusUpdate.subscribe((state) => {
61496
62013
  if (state.status === "disconnected") {
61497
62014
  this.onDisconnect();
@@ -61576,6 +62093,7 @@ Averrage Date/Second ${avgDataRatePS} kb
61576
62093
  this._input.onConnect();
61577
62094
  this._camera.onConnect();
61578
62095
  this._vims.getAll().forEach((vim) => vim.connect());
62096
+ this.sectionBox.onConnect();
61579
62097
  this._viewport.update();
61580
62098
  this._decoder.start();
61581
62099
  }
@@ -61613,7 +62131,6 @@ Averrage Date/Second ${avgDataRatePS} kb
61613
62131
  * Cleans up resources and stops tracking.
61614
62132
  */
61615
62133
  onDisconnect() {
61616
- this._camera.stopTracking();
61617
62134
  this._decoder.stop();
61618
62135
  this._decoder.clear();
61619
62136
  this.colors.clear();
@@ -61680,6 +62197,7 @@ Averrage Date/Second ${avgDataRatePS} kb
61680
62197
  this._viewport.dispose();
61681
62198
  this._decoder.dispose();
61682
62199
  this._input.dispose();
62200
+ this.sectionBox.dispose();
61683
62201
  this._canvas.remove();
61684
62202
  window.onbeforeunload = null;
61685
62203
  }
@@ -75719,7 +76237,7 @@ Averrage Date/Second ${avgDataRatePS} kb
75719
76237
  }
75720
76238
  if (state.status === "connecting") {
75721
76239
  if (modal.current === void 0 || modal.current.type === "loading") {
75722
- modal.loading({ message: "Initializing..." });
76240
+ modal.loading({ message: "Connecting to VIM Ultra server..." });
75723
76241
  }
75724
76242
  }
75725
76243
  if (state.status === "error") {