vim-web 0.3.43 → 0.3.44-dev.0

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 (28) 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/rpcClient.d.ts +9 -7
  4. package/dist/types/core-viewers/ultra/viewer/rpcSafeClient.d.ts +8 -1
  5. package/dist/types/core-viewers/ultra/viewer/sectionBox.d.ts +31 -0
  6. package/dist/types/core-viewers/ultra/viewer/socketClient.d.ts +4 -2
  7. package/dist/types/core-viewers/ultra/viewer/viewer.d.ts +5 -0
  8. package/dist/types/core-viewers/webgl/viewer/camera/ICamera.d.ts +102 -0
  9. package/dist/types/core-viewers/webgl/viewer/environment/cameraLight.d.ts +1 -1
  10. package/dist/types/core-viewers/webgl/viewer/environment/environment.d.ts +1 -1
  11. package/dist/types/core-viewers/webgl/viewer/environment/skybox.d.ts +1 -1
  12. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/SectionBoxMesh.d.ts +15 -0
  13. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBox.d.ts +55 -21
  14. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxGizmo.d.ts +13 -43
  15. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxHandle.d.ts +15 -0
  16. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxHandles.d.ts +19 -0
  17. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxInputs.d.ts +143 -28
  18. package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxOutline.d.ts +15 -0
  19. package/dist/types/core-viewers/webgl/viewer/inputs/input.d.ts +4 -4
  20. package/dist/types/core-viewers/webgl/viewer/viewer.d.ts +1 -1
  21. package/dist/vim-web.iife.js +1109 -600
  22. package/dist/vim-web.iife.js.map +1 -1
  23. package/dist/vim-web.js +1109 -600
  24. package/dist/vim-web.js.map +1 -1
  25. package/package.json +1 -1
  26. /package/dist/types/core-viewers/webgl/viewer/inputs/{keyboard.d.ts → keyboardHandler.d.ts} +0 -0
  27. /package/dist/types/core-viewers/webgl/viewer/inputs/{mouse.d.ts → mouseHandler.d.ts} +0 -0
  28. /package/dist/types/core-viewers/webgl/viewer/inputs/{touch.d.ts → touchHandler.d.ts} +0 -0
package/dist/vim-web.js CHANGED
@@ -47148,6 +47148,154 @@ let Vim$1 = class Vim {
47148
47148
  this.scene.dispose();
47149
47149
  }
47150
47150
  };
47151
+ function mergeGeometries(geometries, useGroups = false) {
47152
+ const isIndexed = geometries[0].index !== null;
47153
+ const attributesUsed = new Set(Object.keys(geometries[0].attributes));
47154
+ const morphAttributesUsed = new Set(Object.keys(geometries[0].morphAttributes));
47155
+ const attributes = {};
47156
+ const morphAttributes = {};
47157
+ const morphTargetsRelative = geometries[0].morphTargetsRelative;
47158
+ const mergedGeometry = new BufferGeometry();
47159
+ let offset = 0;
47160
+ for (let i = 0; i < geometries.length; ++i) {
47161
+ const geometry = geometries[i];
47162
+ let attributesCount = 0;
47163
+ if (isIndexed !== (geometry.index !== null)) {
47164
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
47165
+ return null;
47166
+ }
47167
+ for (const name in geometry.attributes) {
47168
+ if (!attributesUsed.has(name)) {
47169
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.');
47170
+ return null;
47171
+ }
47172
+ if (attributes[name] === void 0) attributes[name] = [];
47173
+ attributes[name].push(geometry.attributes[name]);
47174
+ attributesCount++;
47175
+ }
47176
+ if (attributesCount !== attributesUsed.size) {
47177
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + ". Make sure all geometries have the same number of attributes.");
47178
+ return null;
47179
+ }
47180
+ if (morphTargetsRelative !== geometry.morphTargetsRelative) {
47181
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + ". .morphTargetsRelative must be consistent throughout all geometries.");
47182
+ return null;
47183
+ }
47184
+ for (const name in geometry.morphAttributes) {
47185
+ if (!morphAttributesUsed.has(name)) {
47186
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + ". .morphAttributes must be consistent throughout all geometries.");
47187
+ return null;
47188
+ }
47189
+ if (morphAttributes[name] === void 0) morphAttributes[name] = [];
47190
+ morphAttributes[name].push(geometry.morphAttributes[name]);
47191
+ }
47192
+ if (useGroups) {
47193
+ let count;
47194
+ if (isIndexed) {
47195
+ count = geometry.index.count;
47196
+ } else if (geometry.attributes.position !== void 0) {
47197
+ count = geometry.attributes.position.count;
47198
+ } else {
47199
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + i + ". The geometry must have either an index or a position attribute");
47200
+ return null;
47201
+ }
47202
+ mergedGeometry.addGroup(offset, count, i);
47203
+ offset += count;
47204
+ }
47205
+ }
47206
+ if (isIndexed) {
47207
+ let indexOffset = 0;
47208
+ const mergedIndex = [];
47209
+ for (let i = 0; i < geometries.length; ++i) {
47210
+ const index2 = geometries[i].index;
47211
+ for (let j = 0; j < index2.count; ++j) {
47212
+ mergedIndex.push(index2.getX(j) + indexOffset);
47213
+ }
47214
+ indexOffset += geometries[i].attributes.position.count;
47215
+ }
47216
+ mergedGeometry.setIndex(mergedIndex);
47217
+ }
47218
+ for (const name in attributes) {
47219
+ const mergedAttribute = mergeAttributes(attributes[name]);
47220
+ if (!mergedAttribute) {
47221
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + name + " attribute.");
47222
+ return null;
47223
+ }
47224
+ mergedGeometry.setAttribute(name, mergedAttribute);
47225
+ }
47226
+ for (const name in morphAttributes) {
47227
+ const numMorphTargets = morphAttributes[name][0].length;
47228
+ if (numMorphTargets === 0) break;
47229
+ mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};
47230
+ mergedGeometry.morphAttributes[name] = [];
47231
+ for (let i = 0; i < numMorphTargets; ++i) {
47232
+ const morphAttributesToMerge = [];
47233
+ for (let j = 0; j < morphAttributes[name].length; ++j) {
47234
+ morphAttributesToMerge.push(morphAttributes[name][j][i]);
47235
+ }
47236
+ const mergedMorphAttribute = mergeAttributes(morphAttributesToMerge);
47237
+ if (!mergedMorphAttribute) {
47238
+ console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + name + " morphAttribute.");
47239
+ return null;
47240
+ }
47241
+ mergedGeometry.morphAttributes[name].push(mergedMorphAttribute);
47242
+ }
47243
+ }
47244
+ return mergedGeometry;
47245
+ }
47246
+ function mergeAttributes(attributes) {
47247
+ let TypedArray;
47248
+ let itemSize;
47249
+ let normalized;
47250
+ let gpuType = -1;
47251
+ let arrayLength = 0;
47252
+ for (let i = 0; i < attributes.length; ++i) {
47253
+ const attribute = attributes[i];
47254
+ if (TypedArray === void 0) TypedArray = attribute.array.constructor;
47255
+ if (TypedArray !== attribute.array.constructor) {
47256
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.");
47257
+ return null;
47258
+ }
47259
+ if (itemSize === void 0) itemSize = attribute.itemSize;
47260
+ if (itemSize !== attribute.itemSize) {
47261
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.");
47262
+ return null;
47263
+ }
47264
+ if (normalized === void 0) normalized = attribute.normalized;
47265
+ if (normalized !== attribute.normalized) {
47266
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.");
47267
+ return null;
47268
+ }
47269
+ if (gpuType === -1) gpuType = attribute.gpuType;
47270
+ if (gpuType !== attribute.gpuType) {
47271
+ console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.");
47272
+ return null;
47273
+ }
47274
+ arrayLength += attribute.count * itemSize;
47275
+ }
47276
+ const array = new TypedArray(arrayLength);
47277
+ const result = new BufferAttribute(array, itemSize, normalized);
47278
+ let offset = 0;
47279
+ for (let i = 0; i < attributes.length; ++i) {
47280
+ const attribute = attributes[i];
47281
+ if (attribute.isInterleavedBufferAttribute) {
47282
+ const tupleOffset = offset / itemSize;
47283
+ for (let j = 0, l = attribute.count; j < l; j++) {
47284
+ for (let c = 0; c < itemSize; c++) {
47285
+ const value = attribute.getComponent(j, c);
47286
+ result.setComponent(j + tupleOffset, c, value);
47287
+ }
47288
+ }
47289
+ } else {
47290
+ array.set(attribute.array, offset);
47291
+ }
47292
+ offset += attribute.count * itemSize;
47293
+ }
47294
+ if (gpuType !== void 0) {
47295
+ result.gpuType = gpuType;
47296
+ }
47297
+ return result;
47298
+ }
47151
47299
  function estimateBytesUsed(geometry) {
47152
47300
  let mem = 0;
47153
47301
  for (const name in geometry.attributes) {
@@ -50104,7 +50252,7 @@ const defaultViewerSettings = {
50104
50252
  fov: 50,
50105
50253
  zoom: 1,
50106
50254
  // 45 deg down looking down z.
50107
- forward: new Vector3$1(1, -1, 1),
50255
+ forward: new Vector3$1(1, -1, -1),
50108
50256
  controls: {
50109
50257
  orbit: true,
50110
50258
  rotateSpeed: 1,
@@ -50428,18 +50576,18 @@ class CameraMovement {
50428
50576
  orbitTowards(direction) {
50429
50577
  const forward = this._camera.forward;
50430
50578
  const _direction = direction.clone();
50431
- if (_direction.x === 0 && _direction.z === 0) {
50579
+ if (_direction.x === 0 && _direction.y === 0) {
50432
50580
  _direction.x = this._camera.forward.x * 1e-3;
50433
- _direction.z = this._camera.forward.z * 1e-3;
50581
+ _direction.y = this._camera.forward.y * 1e-3;
50434
50582
  _direction.normalize();
50435
50583
  }
50436
- const flatForward = forward.clone().setY(0);
50437
- const flatDirection = _direction.clone().setY(0);
50584
+ const flatForward = forward.clone().setZ(0);
50585
+ const flatDirection = _direction.clone().setZ(0);
50438
50586
  const cross = flatForward.clone().cross(flatDirection);
50439
- const clockwise = cross.y === 0 ? 1 : Math.sign(cross.y);
50587
+ const clockwise = cross.z === 0 ? 1 : Math.sign(cross.z);
50440
50588
  const azimuth = flatForward.angleTo(flatDirection) * clockwise;
50441
- const angleForward = flatForward.angleTo(forward) * Math.sign(forward.y);
50442
- const angleDirection = flatDirection.angleTo(_direction) * Math.sign(_direction.y);
50589
+ const angleForward = flatForward.angleTo(forward) * Math.sign(forward.z);
50590
+ const angleDirection = flatDirection.angleTo(_direction) * Math.sign(_direction.z);
50443
50591
  const declination = angleForward - angleDirection;
50444
50592
  const angle = new Vector2$1(-declination, azimuth);
50445
50593
  angle.multiplyScalar(180 / Math.PI);
@@ -50647,12 +50795,30 @@ class CameraMovementSnap extends CameraMovement {
50647
50795
  this.set(pos, target);
50648
50796
  }
50649
50797
  set(position, target) {
50650
- const locked = this.lockVector(position, this._camera.position);
50651
- this._camera.position.copy(locked);
50652
50798
  target = target ?? this._camera.target;
50799
+ const direction = new Vector3$1().subVectors(position, target);
50800
+ const dist2 = direction.length();
50801
+ if (dist2 > 1e-6) {
50802
+ const up = new Vector3$1(0, 0, 1);
50803
+ const angle = direction.angleTo(up);
50804
+ const minAngle = MathUtils.degToRad(5);
50805
+ const maxAngle = MathUtils.degToRad(175);
50806
+ if (angle < minAngle) {
50807
+ const axis = new Vector3$1().crossVectors(up, direction).normalize();
50808
+ const delta = minAngle - angle;
50809
+ direction.applyQuaternion(new Quaternion().setFromAxisAngle(axis, delta));
50810
+ } else if (angle > maxAngle) {
50811
+ const axis = new Vector3$1().crossVectors(up, direction).normalize();
50812
+ const delta = maxAngle - angle;
50813
+ direction.applyQuaternion(new Quaternion().setFromAxisAngle(axis, delta));
50814
+ }
50815
+ position.copy(target).add(direction);
50816
+ }
50817
+ const lockedPos = this.lockVector(position, this._camera.position);
50818
+ this._camera.position.copy(lockedPos);
50653
50819
  this._camera.target.copy(target);
50820
+ this._camera.camPerspective.camera.up.set(0, 0, 1);
50654
50821
  this._camera.camPerspective.camera.lookAt(target);
50655
- this._camera.camPerspective.camera.up.set(0, 1, 0);
50656
50822
  }
50657
50823
  lockVector(position, fallback) {
50658
50824
  const x = this._camera.allowedMovement.x === 0 ? fallback.x : position.x;
@@ -50663,17 +50829,14 @@ class CameraMovementSnap extends CameraMovement {
50663
50829
  predictOrbit(angle) {
50664
50830
  const rotation = this.predictRotate(angle);
50665
50831
  const delta = new Vector3$1(0, 0, 1).applyQuaternion(rotation).multiplyScalar(this._camera.orbitDistance);
50666
- return this._camera.target.clone().add(delta);
50832
+ const pos = this._camera.target.clone().add(delta);
50833
+ return pos;
50667
50834
  }
50668
50835
  predictRotate(angle) {
50669
- const euler = new Euler(0, 0, 0, "YXZ");
50670
- euler.setFromQuaternion(this._camera.quaternion);
50671
- euler.x += angle.x * Math.PI / 180;
50672
- euler.y += angle.y * Math.PI / 180;
50673
- euler.z = 0;
50674
- const max2 = Math.PI * 0.4999;
50675
- euler.x = Math.max(-max2, Math.min(max2, euler.x));
50676
- const rotation = new Quaternion().setFromEuler(euler);
50836
+ const xQuat = new Quaternion().setFromAxisAngle(new Vector3$1(1, 0, 0), angle.x * Math.PI / 180);
50837
+ const zQuat = new Quaternion().setFromAxisAngle(new Vector3$1(0, 1, 0), angle.y * Math.PI / 180);
50838
+ const rotation = this._camera.quaternion.clone();
50839
+ rotation.multiply(xQuat).multiply(zQuat);
50677
50840
  return rotation;
50678
50841
  }
50679
50842
  }
@@ -50722,6 +50885,8 @@ let Camera$1 = class Camera2 {
50722
50885
  __publicField(this, "_velocityBlendFactor", 1e-4);
50723
50886
  __publicField(this, "_moveSpeed", 1);
50724
50887
  this.camPerspective = new PerspectiveWrapper(new PerspectiveCamera());
50888
+ this.camPerspective.camera.up = new Vector3$1(0, 0, 1);
50889
+ this.camPerspective.camera.lookAt(new Vector3$1(0, 1, 0));
50725
50890
  this.camOrthographic = new OrthographicWrapper(
50726
50891
  new OrthographicCamera()
50727
50892
  );
@@ -50782,7 +50947,7 @@ let Camera$1 = class Camera2 {
50782
50947
  }
50783
50948
  set defaultForward(value) {
50784
50949
  if (value.x === 0 && value.y === 0 && value.z === 0) {
50785
- this._defaultForward.set(1, -1, 1).normalize();
50950
+ this._defaultForward.set(1, -1, -1).normalize();
50786
50951
  } else {
50787
50952
  this._defaultForward.copy(value).normalize();
50788
50953
  }
@@ -54869,8 +55034,314 @@ class Measure {
54869
55034
  this._meshes = void 0;
54870
55035
  }
54871
55036
  }
54872
- class BoxOutline extends LineSegments {
55037
+ const MIN_BOX_SIZE = 3;
55038
+ class BoxInputs {
55039
+ // -------------------------------------------------------------------------
55040
+ // Constructor
55041
+ // -------------------------------------------------------------------------
55042
+ /**
55043
+ * Creates a new BoxInputs instance for pointer-driven box resizing.
55044
+ *
55045
+ * @param viewer - The parent {@link Viewer} that renders the scene.
55046
+ * @param handles - A {@link SectionBoxHandles} instance containing the draggable mesh handles.
55047
+ * @param box - The shared bounding box (`Box3`) that will be updated by dragging.
55048
+ */
55049
+ constructor(viewer, handles, box) {
55050
+ // -------------------------------------------------------------------------
55051
+ // Dependencies and shared resources
55052
+ // -------------------------------------------------------------------------
55053
+ /** The parent Viewer controlling the scene. */
55054
+ __publicField(this, "_viewer");
55055
+ /** The handles mesh group containing the draggable cones/faces. */
55056
+ __publicField(this, "_handles");
55057
+ /** The main box that is being reshaped by dragging handles. */
55058
+ __publicField(this, "_sharedBox");
55059
+ // -------------------------------------------------------------------------
55060
+ // Internal state
55061
+ // -------------------------------------------------------------------------
55062
+ /** The currently hovered/dragged handle, if any. */
55063
+ __publicField(this, "_handle");
55064
+ /** The origin point for dragging, updated on pointer down. */
55065
+ __publicField(this, "_dragOrigin", new Vector3$1());
55066
+ /** The plane used for drag intersection (perpendicular to the camera direction). */
55067
+ __publicField(this, "_dragPlane", new Plane());
55068
+ /** Whether a pointer is currently down on a handle. */
55069
+ __publicField(this, "_mouseDown", false);
55070
+ /** A reusable Raycaster for picking and plane intersection. */
55071
+ __publicField(this, "_raycaster", new Raycaster$1());
55072
+ /** The box state before the current drag. */
55073
+ __publicField(this, "_lastBox", new Box3$1());
55074
+ /** A collection of unregister callbacks for event listeners. */
55075
+ __publicField(this, "_unregisters", []);
55076
+ /** The ID of the pointer that is captured, if any. */
55077
+ __publicField(this, "_capturedPointerId");
55078
+ // -------------------------------------------------------------------------
55079
+ // Callbacks
55080
+ // -------------------------------------------------------------------------
55081
+ /**
55082
+ * Called when the pointer enters or leaves a handle face.
55083
+ * @param normal - The normal (forward) vector of the hovered handle, or a zero vector if none.
55084
+ */
55085
+ __publicField(this, "onFaceEnter");
55086
+ /**
55087
+ * Called continuously as the box is reshaped by dragging.
55088
+ * @param box - The updated box after the latest drag move.
55089
+ */
55090
+ __publicField(this, "onBoxStretch");
55091
+ /**
55092
+ * Called when the user has finished reshaping the box (pointer up).
55093
+ * @param box - The final box after dragging ends.
55094
+ */
55095
+ __publicField(this, "onBoxConfirm");
55096
+ this._viewer = viewer;
55097
+ this._handles = handles;
55098
+ this._sharedBox = box;
55099
+ }
55100
+ // -------------------------------------------------------------------------
55101
+ // Public Methods
55102
+ // -------------------------------------------------------------------------
55103
+ /**
55104
+ * Registers pointer event listeners on the viewer's canvas.
55105
+ * If already registered, it does nothing.
55106
+ */
55107
+ register() {
55108
+ if (this._unregisters.length > 0) return;
55109
+ const canvas = this._viewer.viewport.canvas;
55110
+ this.reg(canvas, "pointerdown", (e) => this.onMouseDown(e));
55111
+ this.reg(canvas, "pointermove", (e) => this.onMouseMove(e));
55112
+ this.reg(canvas, "pointerup", (e) => this.onMouseUp(e));
55113
+ this.reg(canvas, "pointerleave", (e) => this.onPointerLeave(e));
55114
+ }
55115
+ /**
55116
+ * Unregisters any previously set pointer event listeners, releasing pointer capture
55117
+ * and resetting drag state.
55118
+ */
55119
+ unregister() {
55120
+ var _a2;
55121
+ this._mouseDown = false;
55122
+ (_a2 = this._handle) == null ? void 0 : _a2.highlight(false);
55123
+ this._handle = void 0;
55124
+ this.releasePointer();
55125
+ this._viewer.inputs.registerAll();
55126
+ this._unregisters.forEach((unreg) => unreg());
55127
+ this._unregisters.length = 0;
55128
+ }
55129
+ /**
55130
+ * Indicates if a pointer is currently captured for dragging.
55131
+ */
55132
+ get pointerCaptured() {
55133
+ return this._capturedPointerId !== void 0;
55134
+ }
55135
+ // -------------------------------------------------------------------------
55136
+ // Private Methods
55137
+ // -------------------------------------------------------------------------
55138
+ /**
55139
+ * A helper method to attach an event listener and store its unregister callback.
55140
+ *
55141
+ * @param handler - The DOM element or Window to attach the listener to.
55142
+ * @param type - The pointer event type, e.g. 'pointerdown'.
55143
+ * @param listener - The event handler function.
55144
+ */
55145
+ reg(handler, type, listener2) {
55146
+ handler.addEventListener(type, listener2);
55147
+ this._unregisters.push(() => handler.removeEventListener(type, listener2));
55148
+ }
55149
+ /**
55150
+ * Called when the pointer leaves the canvas. If not dragging,
55151
+ * invokes {@link onFaceEnter} to indicate no active handle is hovered.
55152
+ *
55153
+ * @param event - The pointerleave event.
55154
+ */
55155
+ onPointerLeave(event) {
55156
+ var _a2, _b2;
55157
+ if (!this.pointerCaptured) {
55158
+ (_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, ((_a2 = this._handle) == null ? void 0 : _a2.forward) ?? new Vector3$1());
55159
+ }
55160
+ }
55161
+ /**
55162
+ * Sets pointer capture on the canvas for a specific pointer (ID).
55163
+ *
55164
+ * @param pointerId - The pointer ID to capture.
55165
+ */
55166
+ capturePointer(pointerId) {
55167
+ this.releasePointer();
55168
+ this._viewer.viewport.canvas.setPointerCapture(pointerId);
55169
+ this._capturedPointerId = pointerId;
55170
+ }
55171
+ /**
55172
+ * Releases any captured pointer on the canvas, if present.
55173
+ */
55174
+ releasePointer() {
55175
+ if (this.pointerCaptured) {
55176
+ this._viewer.viewport.canvas.releasePointerCapture(this._capturedPointerId);
55177
+ this._capturedPointerId = void 0;
55178
+ }
55179
+ }
55180
+ /**
55181
+ * Handles pointer movement events.
55182
+ * - If dragging, calls {@link onDrag}.
55183
+ * - Otherwise, performs a raycast to detect which handle is under the pointer.
55184
+ *
55185
+ * @param event - The pointermove event.
55186
+ */
55187
+ onMouseMove(event) {
55188
+ var _a2, _b2, _c, _d;
55189
+ if (this._mouseDown) {
55190
+ this.onDrag(event);
55191
+ return;
55192
+ }
55193
+ const hits = this.raycast(new Vector2$1(event.offsetX, event.offsetY));
55194
+ const handle = (_b2 = (_a2 = hits == null ? void 0 : hits[0]) == null ? void 0 : _a2.object) == null ? void 0 : _b2.userData.handle;
55195
+ if (handle !== this._handle) {
55196
+ (_c = this._handle) == null ? void 0 : _c.highlight(false);
55197
+ handle == null ? void 0 : handle.highlight(true);
55198
+ this._handle = handle;
55199
+ (_d = this.onFaceEnter) == null ? void 0 : _d.call(this, (handle == null ? void 0 : handle.forward) ?? new Vector3$1());
55200
+ }
55201
+ }
55202
+ /**
55203
+ * Handles pointer up events. Ends dragging and triggers {@link onBoxConfirm}.
55204
+ *
55205
+ * @param event - The pointerup event.
55206
+ */
55207
+ onMouseUp(event) {
55208
+ var _a2, _b2;
55209
+ this.releasePointer();
55210
+ if (this._mouseDown) {
55211
+ this._mouseDown = false;
55212
+ this._viewer.inputs.registerAll();
55213
+ if (event.pointerType === "mouse") {
55214
+ this.onMouseMove(event);
55215
+ } else {
55216
+ this._handle = void 0;
55217
+ (_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, new Vector3$1());
55218
+ }
55219
+ (_b2 = this.onBoxConfirm) == null ? void 0 : _b2.call(this, this._sharedBox);
55220
+ }
55221
+ }
55222
+ /**
55223
+ * Handles pointer down events. Begins drag if a handle is hit, capturing the pointer.
55224
+ *
55225
+ * @param event - The pointerdown event.
55226
+ */
55227
+ onMouseDown(event) {
55228
+ var _a2, _b2, _c, _d;
55229
+ const hits = this.raycast(new Vector2$1(event.offsetX, event.offsetY));
55230
+ 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;
55231
+ if (!handle) return;
55232
+ this._handle = handle;
55233
+ this.capturePointer(event.pointerId);
55234
+ this._lastBox.copy(this._sharedBox);
55235
+ this._dragOrigin.copy(handle.position);
55236
+ const dist2 = handle.position.clone().dot(this._viewer.camera.forward);
55237
+ this._dragPlane.set(this._viewer.camera.forward, -dist2);
55238
+ this._mouseDown = true;
55239
+ this._viewer.inputs.unregisterAll();
55240
+ (_d = this.onFaceEnter) == null ? void 0 : _d.call(this, this._handle.forward.clone());
55241
+ }
55242
+ /**
55243
+ * Continues the drag operation. Determines the new position on the drag plane
55244
+ * and computes how far we moved along the handle's forward axis.
55245
+ *
55246
+ * @param event - The pointermove event while dragging.
55247
+ */
55248
+ onDrag(event) {
55249
+ var _a2;
55250
+ if (!this._handle) return;
55251
+ const point = this.raycastPlane(new Vector2$1(event.offsetX, event.offsetY)) ?? this._dragOrigin.clone();
55252
+ const delta = point.sub(this._dragOrigin);
55253
+ const amount = delta.dot(this._handle.forward);
55254
+ const box = this.stretch(this._handle.axis, this._handle.sign, amount);
55255
+ (_a2 = this.onBoxStretch) == null ? void 0 : _a2.call(this, box);
55256
+ }
55257
+ /**
55258
+ * Expands or contracts the `_sharedBox` along one axis by a certain amount,
55259
+ * ensuring the box cannot shrink below the minimum size (`MIN_BOX_SIZE`).
55260
+ *
55261
+ * @param axis - The axis ('x', 'y', or 'z') to stretch.
55262
+ * @param sign - +1 if stretching the 'max' side, -1 if stretching the 'min' side.
55263
+ * @param amount - The numeric offset along that axis to add or subtract.
55264
+ * @returns A **new** `Box3` instance with updated min/max coordinates.
55265
+ */
55266
+ stretch(axis, sign2, amount) {
55267
+ const box = this._sharedBox.clone();
55268
+ const direction = sign2 > 0 ? "max" : "min";
55269
+ const opposite = sign2 > 0 ? "min" : "max";
55270
+ const target = this._lastBox[direction][axis] + amount * sign2;
55271
+ const minBoundary = this._lastBox[opposite][axis] + MIN_BOX_SIZE * sign2;
55272
+ box[direction][axis] = target;
55273
+ if (sign2 * (target - minBoundary) < 0) {
55274
+ box[opposite][axis] = target - MIN_BOX_SIZE * sign2;
55275
+ }
55276
+ return box;
55277
+ }
55278
+ /**
55279
+ * Prepares the internal raycaster for a given 2D pointer position.
55280
+ *
55281
+ * @param position - The pointer position in canvas coordinates.
55282
+ * @returns The updated raycaster pointing from the camera through this position.
55283
+ */
55284
+ getRaycaster(position) {
55285
+ return this._viewer.raycaster.fromPoint2(position, this._raycaster);
55286
+ }
55287
+ /**
55288
+ * Raycasts into the handle meshes from the given pointer position.
55289
+ *
55290
+ * @param position - The pointer position in canvas coordinates.
55291
+ * @returns An array of intersection results, if any.
55292
+ */
55293
+ raycast(position) {
55294
+ return this.getRaycaster(position).intersectObject(this._handles.meshes);
55295
+ }
55296
+ /**
55297
+ * Raycasts into the drag plane from the given pointer position.
55298
+ *
55299
+ * @param position - The pointer position in canvas coordinates.
55300
+ * @returns The intersection point in 3D space, or `null` if none.
55301
+ */
55302
+ raycastPlane(position) {
55303
+ return this.getRaycaster(position).ray.intersectPlane(
55304
+ this._dragPlane,
55305
+ new Vector3$1()
55306
+ );
55307
+ }
55308
+ }
55309
+ class SectionBoxMesh extends Mesh {
54873
55310
  constructor() {
55311
+ const geo = new BoxGeometry();
55312
+ const mat = new MeshBasicMaterial({
55313
+ opacity: 0.3,
55314
+ transparent: true,
55315
+ color: new Color(20667),
55316
+ depthTest: false
55317
+ });
55318
+ super(geo, mat);
55319
+ }
55320
+ /**
55321
+ * Resize the mesh to the given box.
55322
+ */
55323
+ fitBox(box) {
55324
+ this.scale.set(
55325
+ box.max.x - box.min.x,
55326
+ box.max.y - box.min.y,
55327
+ box.max.z - box.min.z
55328
+ );
55329
+ this.position.set(
55330
+ (box.max.x + box.min.x) / 2,
55331
+ (box.max.y + box.min.y) / 2,
55332
+ (box.max.z + box.min.z) / 2
55333
+ );
55334
+ }
55335
+ /**
55336
+ * Disposes of all resources.
55337
+ */
55338
+ dispose() {
55339
+ this.geometry.dispose();
55340
+ this.material.dispose();
55341
+ }
55342
+ }
55343
+ class SectionBoxOutline extends LineSegments {
55344
+ constructor(color) {
54874
55345
  const vertices = new Float32Array([
54875
55346
  -0.5,
54876
55347
  -0.5,
@@ -54926,7 +55397,7 @@ class BoxOutline extends LineSegments {
54926
55397
  const geo = new BufferGeometry();
54927
55398
  const mat = new LineBasicMaterial({
54928
55399
  opacity: 1,
54929
- color: new Color(0)
55400
+ color
54930
55401
  });
54931
55402
  geo.setAttribute("position", new BufferAttribute(vertices, 3));
54932
55403
  geo.setIndex(indices);
@@ -54955,305 +55426,169 @@ class BoxOutline extends LineSegments {
54955
55426
  this.material.dispose();
54956
55427
  }
54957
55428
  }
54958
- class BoxMesh extends Mesh {
54959
- constructor() {
54960
- const geo = new BoxGeometry();
54961
- const mat = new MeshBasicMaterial({
54962
- opacity: 0.3,
55429
+ class SectionBoxHandle extends Mesh {
55430
+ constructor(axes, sign2, size, color) {
55431
+ const geo = createDoubleCone(size);
55432
+ geo.clearGroups();
55433
+ geo.addGroup(0, Infinity, 0);
55434
+ geo.addGroup(0, Infinity, 1);
55435
+ const matBehind = new MeshBasicMaterial({
54963
55436
  transparent: true,
54964
- color: new Color(20667),
54965
- depthTest: false
55437
+ opacity: 0.5,
55438
+ color: color ?? new Color(0),
55439
+ depthTest: false,
55440
+ side: FrontSide
54966
55441
  });
54967
- super(geo, mat);
55442
+ const matAlways = new MeshBasicMaterial({
55443
+ color: color ?? new Color(0),
55444
+ side: FrontSide
55445
+ });
55446
+ super(geo, [matAlways, matBehind]);
55447
+ __publicField(this, "axis");
55448
+ __publicField(this, "sign");
55449
+ __publicField(this, "_forward");
55450
+ __publicField(this, "_color");
55451
+ __publicField(this, "_highlightColor");
55452
+ __publicField(this, "_materials");
55453
+ this._materials = [matAlways, matBehind];
55454
+ this._forward = new Vector3$1();
55455
+ this.forward[axes] = sign2;
55456
+ this.axis = axes;
55457
+ this.sign = sign2;
55458
+ this._color = color ?? new Color(0);
55459
+ this._highlightColor = this._color.clone().lerp(new Color(13421772), 0.8);
55460
+ this.userData.handle = this;
55461
+ this.quaternion.setFromUnitVectors(new Vector3$1(0, -1, 0), this._forward);
54968
55462
  }
54969
- /**
54970
- * Resize the mesh to the given box.
54971
- */
54972
- fitBox(box) {
54973
- this.scale.set(
54974
- box.max.x - box.min.x,
54975
- box.max.y - box.min.y,
54976
- box.max.z - box.min.z
54977
- );
54978
- this.position.set(
54979
- (box.max.x + box.min.x) / 2,
54980
- (box.max.y + box.min.y) / 2,
54981
- (box.max.z + box.min.z) / 2
54982
- );
55463
+ setPosition(position) {
55464
+ this.position.copy(position);
55465
+ }
55466
+ get forward() {
55467
+ return this._forward;
55468
+ }
55469
+ highlight(value) {
55470
+ this.material[0].color.set(value ? this._highlightColor : this._color);
55471
+ this.material[1].color.set(value ? this._highlightColor : this._color);
54983
55472
  }
54984
- /**
54985
- * Disposes of all resources.
54986
- */
54987
55473
  dispose() {
54988
55474
  this.geometry.dispose();
54989
- this.material.dispose();
54990
- }
54991
- }
54992
- class BoxHighlight extends Mesh {
55475
+ this._materials.forEach((m) => m.dispose());
55476
+ }
55477
+ }
55478
+ function createDoubleCone(size) {
55479
+ const coneHeight = 2 * size;
55480
+ const cone1 = new ConeGeometry(size, coneHeight, 12);
55481
+ cone1.translate(0, coneHeight * 0.75, 0);
55482
+ const cone2 = new ConeGeometry(size, coneHeight, 12);
55483
+ cone2.rotateZ(Math.PI);
55484
+ cone2.translate(0, -coneHeight * 0.75, 0);
55485
+ const mergedGeo = mergeGeometries([cone1, cone2]);
55486
+ cone1.dispose();
55487
+ cone2.dispose();
55488
+ return mergedGeo;
55489
+ }
55490
+ class SectionBoxHandles {
54993
55491
  constructor() {
54994
- const geo = new BufferGeometry();
54995
- geo.setAttribute(
54996
- "position",
54997
- new BufferAttribute(new Float32Array(12), 3)
54998
- );
54999
- geo.setIndex([0, 1, 2, 0, 2, 3]);
55000
- const mat = new MeshBasicMaterial({
55001
- opacity: 0.7,
55002
- transparent: true,
55003
- depthTest: false,
55004
- side: DoubleSide
55005
- });
55006
- super(geo, mat);
55007
- this.renderOrder = 1;
55008
- this.frustumCulled = false;
55492
+ __publicField(this, "up");
55493
+ __publicField(this, "down");
55494
+ __publicField(this, "left");
55495
+ __publicField(this, "right");
55496
+ __publicField(this, "front");
55497
+ __publicField(this, "back");
55498
+ __publicField(this, "meshes");
55499
+ const size = 2;
55500
+ this.up = new SectionBoxHandle("y", 1, size, new Color(65280));
55501
+ this.down = new SectionBoxHandle("y", -1, size, new Color(65280));
55502
+ this.left = new SectionBoxHandle("x", -1, size, new Color(16711680));
55503
+ this.right = new SectionBoxHandle("x", 1, size, new Color(16711680));
55504
+ this.front = new SectionBoxHandle("z", 1, size, new Color(255));
55505
+ this.back = new SectionBoxHandle("z", -1, size, new Color(255));
55506
+ this.meshes = new Group();
55507
+ this.meshes.add(this.up);
55508
+ this.meshes.add(this.down);
55509
+ this.meshes.add(this.left);
55510
+ this.meshes.add(this.right);
55511
+ this.meshes.add(this.front);
55512
+ this.meshes.add(this.back);
55009
55513
  }
55010
- /**
55011
- * Sets the face to highlight
55012
- * @param normal a direction vector from theses options (X,-X, Y,-Y, Z,-Z)
55013
- */
55014
- highlight(box, normal) {
55015
- this.visible = false;
55016
- const positions = this.geometry.getAttribute("position");
55017
- if (normal.x > 0.1) {
55018
- positions.setXYZ(0, box.max.x, box.max.y, box.max.z);
55019
- positions.setXYZ(1, box.max.x, box.min.y, box.max.z);
55020
- positions.setXYZ(2, box.max.x, box.min.y, box.min.z);
55021
- positions.setXYZ(3, box.max.x, box.max.y, box.min.z);
55022
- this.visible = true;
55023
- }
55024
- if (normal.x < -0.1) {
55025
- positions.setXYZ(0, box.min.x, box.max.y, box.max.z);
55026
- positions.setXYZ(1, box.min.x, box.min.y, box.max.z);
55027
- positions.setXYZ(2, box.min.x, box.min.y, box.min.z);
55028
- positions.setXYZ(3, box.min.x, box.max.y, box.min.z);
55029
- this.visible = true;
55030
- }
55031
- if (normal.y > 0.1) {
55032
- positions.setXYZ(0, box.max.x, box.max.y, box.max.z);
55033
- positions.setXYZ(1, box.min.x, box.max.y, box.max.z);
55034
- positions.setXYZ(2, box.min.x, box.max.y, box.min.z);
55035
- positions.setXYZ(3, box.max.x, box.max.y, box.min.z);
55036
- this.visible = true;
55037
- }
55038
- if (normal.y < -0.1) {
55039
- positions.setXYZ(0, box.max.x, box.min.y, box.max.z);
55040
- positions.setXYZ(1, box.min.x, box.min.y, box.max.z);
55041
- positions.setXYZ(2, box.min.x, box.min.y, box.min.z);
55042
- positions.setXYZ(3, box.max.x, box.min.y, box.min.z);
55043
- this.visible = true;
55044
- }
55045
- if (normal.z > 0.1) {
55046
- positions.setXYZ(0, box.max.x, box.max.y, box.max.z);
55047
- positions.setXYZ(1, box.min.x, box.max.y, box.max.z);
55048
- positions.setXYZ(2, box.min.x, box.min.y, box.max.z);
55049
- positions.setXYZ(3, box.max.x, box.min.y, box.max.z);
55050
- this.visible = true;
55051
- }
55052
- if (normal.z < -0.1) {
55053
- positions.setXYZ(0, box.max.x, box.max.y, box.min.z);
55054
- positions.setXYZ(1, box.min.x, box.max.y, box.min.z);
55055
- positions.setXYZ(2, box.min.x, box.min.y, box.min.z);
55056
- positions.setXYZ(3, box.max.x, box.min.y, box.min.z);
55057
- this.visible = true;
55058
- }
55059
- positions.needsUpdate = true;
55514
+ get visible() {
55515
+ return this.meshes.visible;
55516
+ }
55517
+ set visible(value) {
55518
+ this.meshes.visible = value;
55519
+ }
55520
+ fitBox(box) {
55521
+ const center = box.getCenter(new Vector3$1());
55522
+ this.up.setPosition(new Vector3$1(center.x, box.max.y, center.z));
55523
+ this.down.setPosition(new Vector3$1(center.x, box.min.y, center.z));
55524
+ this.left.setPosition(new Vector3$1(box.min.x, center.y, center.z));
55525
+ this.right.setPosition(new Vector3$1(box.max.x, center.y, center.z));
55526
+ this.front.setPosition(new Vector3$1(center.x, center.y, box.max.z));
55527
+ this.back.setPosition(new Vector3$1(center.x, center.y, box.min.z));
55060
55528
  }
55061
- /**
55062
- * Disposes all resources.
55063
- */
55064
55529
  dispose() {
55065
- this.geometry.dispose();
55066
- this.material.dispose();
55530
+ this.up.dispose();
55531
+ this.down.dispose();
55532
+ this.left.dispose();
55533
+ this.right.dispose();
55534
+ this.front.dispose();
55535
+ this.back.dispose();
55067
55536
  }
55068
55537
  }
55069
- class BoxInputs {
55070
- constructor(viewer, cube, box) {
55071
- // dependencies
55072
- __publicField(this, "viewer");
55538
+ class SectionBoxGizmo {
55539
+ constructor(renderer) {
55540
+ __publicField(this, "_renderer");
55073
55541
  __publicField(this, "cube");
55074
- __publicField(this, "sharedBox");
55075
- // state
55076
- __publicField(this, "faceNormal", new Vector3$1());
55077
- __publicField(this, "dragOrigin", new Vector3$1());
55078
- __publicField(this, "dragpPlane", new Plane());
55079
- __publicField(this, "mouseDown");
55080
- __publicField(this, "raycaster", new Raycaster$1());
55081
- __publicField(this, "lastBox", new Box3$1());
55082
- __publicField(this, "unregisters", []);
55083
- __publicField(this, "lastMouse");
55084
- __publicField(this, "ctrlDown", false);
55085
- __publicField(this, "capturedId");
55086
- // Called when mouse enters or leave a face
55087
- __publicField(this, "onFaceEnter");
55088
- // Called the box is reshaped
55089
- __publicField(this, "onBoxStretch");
55090
- // Called when the user is done reshaping the box
55091
- __publicField(this, "onBoxConfirm");
55092
- __publicField(this, "reg", (handler, type, listener2) => {
55093
- handler.addEventListener(type, listener2);
55094
- this.unregisters.push(() => handler.removeEventListener(type, listener2));
55095
- });
55096
- this.viewer = viewer;
55097
- this.cube = cube;
55098
- this.sharedBox = box;
55099
- }
55100
- register() {
55101
- if (this.unregister.length > 0) return;
55102
- const canvas = this.viewer.viewport.canvas;
55103
- this.reg(window, "keydown", this.onKey.bind(this));
55104
- this.reg(window, "keyup", this.onKey.bind(this));
55105
- this.reg(canvas, "pointerdown", this.onMouseDown.bind(this));
55106
- this.reg(canvas, "pointermove", this.onMouseMove.bind(this));
55107
- this.reg(canvas, "pointerup", this.onMouseUp.bind(this));
55108
- this.reg(canvas, "pointerleave", this.onPointerLeave.bind(this));
55109
- }
55110
- onPointerLeave(event) {
55111
- var _a2;
55112
- if (this.capturedId !== void 0) {
55113
- return;
55114
- }
55115
- this.faceNormal.set(0, 0, 0);
55116
- (_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, this.faceNormal);
55117
- }
55118
- capturePointer(pointerId) {
55119
- this.releasePointer();
55120
- this.viewer.viewport.canvas.setPointerCapture(pointerId);
55121
- this.capturedId = pointerId;
55122
- }
55123
- releasePointer() {
55124
- if (this.capturedId === void 0) return;
55125
- this.viewer.viewport.canvas.releasePointerCapture(this.capturedId);
55126
- this.capturedId = void 0;
55127
- }
55128
- unregister() {
55129
- this.ctrlDown = false;
55130
- this.mouseDown = false;
55131
- this.releasePointer();
55132
- this.viewer.inputs.registerAll();
55133
- this.unregisters.forEach((unreg) => unreg());
55134
- this.unregisters.length = 0;
55135
- }
55136
- onKey(event) {
55137
- if (this.ctrlDown !== event.ctrlKey) {
55138
- this.ctrlDown = event.ctrlKey;
55139
- this.onMouseMove(this.lastMouse);
55140
- }
55141
- }
55142
- onMouseMove(event) {
55143
- var _a2, _b2, _c;
55144
- this.lastMouse = event;
55145
- if (this.mouseDown) {
55146
- this.onDrag(event);
55147
- return;
55148
- }
55149
- const hits = this.raycast(
55150
- new Vector2$1(event.offsetX, event.offsetY),
55151
- this.ctrlDown
55152
- );
55153
- const hit = hits == null ? void 0 : hits[0];
55154
- const norm = (_a2 = hit == null ? void 0 : hit.face) == null ? void 0 : _a2.normal;
55155
- if (!norm) {
55156
- if (this.faceNormal.x !== 0 || this.faceNormal.y !== 0 || this.faceNormal.z !== 0) {
55157
- this.faceNormal.set(0, 0, 0);
55158
- (_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, this.faceNormal);
55159
- }
55160
- return;
55161
- }
55162
- if (this.faceNormal.equals(norm)) {
55163
- return;
55164
- }
55165
- this.faceNormal = norm;
55166
- (_c = this.onFaceEnter) == null ? void 0 : _c.call(this, this.faceNormal);
55167
- }
55168
- onMouseUp(event) {
55169
- var _a2, _b2;
55170
- this.releasePointer();
55171
- if (this.mouseDown) {
55172
- this.mouseDown = false;
55173
- this.viewer.inputs.registerAll();
55174
- if (event.pointerType === "mouse") {
55175
- this.onMouseMove(event);
55176
- } else {
55177
- this.faceNormal = new Vector3$1();
55178
- (_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, this.faceNormal);
55179
- }
55180
- (_b2 = this.onBoxConfirm) == null ? void 0 : _b2.call(this, this.sharedBox);
55181
- }
55542
+ __publicField(this, "outline");
55543
+ __publicField(this, "handles");
55544
+ __publicField(this, "_visible", false);
55545
+ this._renderer = renderer;
55546
+ this.cube = new SectionBoxMesh();
55547
+ this.outline = new SectionBoxOutline(new Color(8882833));
55548
+ this.handles = new SectionBoxHandles();
55549
+ this._renderer.add(this.outline);
55550
+ this._renderer.add(this.handles.meshes);
55551
+ this.visible = false;
55182
55552
  }
55183
- onMouseDown(event) {
55184
- var _a2, _b2;
55185
- const hits = this.raycast(
55186
- new Vector2$1(event.offsetX, event.offsetY),
55187
- this.ctrlDown
55188
- );
55189
- const hit = hits == null ? void 0 : hits[0];
55190
- if (!((_a2 = hit == null ? void 0 : hit.face) == null ? void 0 : _a2.normal)) return;
55191
- this.capturePointer(event.pointerId);
55192
- this.lastBox.copy(this.sharedBox);
55193
- this.faceNormal = hit.face.normal;
55194
- this.dragOrigin.copy(hit.point);
55195
- const dist2 = hit.point.clone().dot(this.viewer.camera.forward);
55196
- this.dragpPlane.set(this.viewer.camera.forward, -dist2);
55197
- this.mouseDown = true;
55198
- this.viewer.inputs.unregisterAll();
55199
- (_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, this.faceNormal);
55553
+ get visible() {
55554
+ return this._visible;
55200
55555
  }
55201
- onDrag(event) {
55202
- var _a2;
55203
- this.raycaster = this.viewer.raycaster.fromPoint2(
55204
- new Vector2$1(event.offsetX, event.offsetY),
55205
- this.raycaster
55206
- );
55207
- const point = this.raycaster.ray.intersectPlane(this.dragpPlane, new Vector3$1()) ?? this.dragOrigin.clone();
55208
- const delta = point.sub(this.dragOrigin);
55209
- const amount = delta.dot(this.faceNormal);
55210
- const box = this.stretch(this.faceNormal, amount);
55211
- (_a2 = this.onBoxStretch) == null ? void 0 : _a2.call(this, box);
55556
+ set visible(value) {
55557
+ this._visible = value;
55558
+ this.cube.visible = value;
55559
+ this.outline.visible = value;
55560
+ this.handles.visible = value;
55212
55561
  }
55213
- stretch(normal, amount) {
55214
- const result = this.sharedBox.clone();
55215
- if (normal.x > 0.1) {
55216
- result.max.setX(Math.max(this.lastBox.max.x + amount, result.min.x - 1));
55217
- }
55218
- if (normal.x < -0.1) {
55219
- result.min.setX(Math.min(this.lastBox.min.x - amount, result.max.x + 1));
55220
- }
55221
- if (normal.y > 0.1) {
55222
- result.max.setY(Math.max(this.lastBox.max.y + amount, result.min.y - 1));
55223
- }
55224
- if (normal.y < -0.1) {
55225
- result.min.setY(Math.min(this.lastBox.min.y - amount, result.max.y + 1));
55226
- }
55227
- if (normal.z > 0.1) {
55228
- result.max.setZ(Math.max(this.lastBox.max.z + amount, result.min.z - 1));
55229
- }
55230
- if (normal.z < -0.1) {
55231
- result.min.setZ(Math.min(this.lastBox.min.z - amount, result.max.z + 1));
55232
- }
55233
- return result;
55562
+ fitBox(box) {
55563
+ this.cube.fitBox(box);
55564
+ this.outline.fitBox(box);
55565
+ this.handles.fitBox(box);
55234
55566
  }
55235
- raycast(position, reverse) {
55236
- this.raycaster = this.viewer.raycaster.fromPoint2(position, this.raycaster);
55237
- if (reverse) {
55238
- this.raycaster.ray.set(
55239
- this.raycaster.ray.origin.clone().add(this.raycaster.ray.direction.clone().multiplyScalar(this.viewer.settings.camera.far)),
55240
- this.raycaster.ray.direction.negate()
55241
- );
55242
- }
55243
- return this.raycaster.intersectObject(this.cube);
55567
+ dispose() {
55568
+ this._renderer.remove(this.cube);
55569
+ this._renderer.remove(this.outline);
55570
+ this._renderer.remove(this.handles.meshes);
55571
+ this.cube.dispose();
55572
+ this.outline.dispose();
55573
+ this.handles.dispose();
55244
55574
  }
55245
55575
  }
55246
- class SectionBox {
55576
+ let SectionBox$1 = class SectionBox {
55577
+ // -------------------------------------------------------------------------
55578
+ // Constructor
55579
+ // -------------------------------------------------------------------------
55580
+ /**
55581
+ * Creates a new SectionBox gizmo controller.
55582
+ *
55583
+ * @param viewer - The parent {@link Viewer} in which the section box is rendered.
55584
+ */
55247
55585
  constructor(viewer) {
55248
- // dependencies
55586
+ // -------------------------------------------------------------------------
55587
+ // Private fields
55588
+ // -------------------------------------------------------------------------
55249
55589
  __publicField(this, "_viewer");
55250
- // resources
55590
+ __publicField(this, "_gizmos");
55251
55591
  __publicField(this, "_inputs");
55252
- __publicField(this, "_cube");
55253
- __publicField(this, "_outline");
55254
- __publicField(this, "_highlight");
55255
- // State
55256
- __publicField(this, "_normal");
55257
55592
  __publicField(this, "_clip");
55258
55593
  __publicField(this, "_visible");
55259
55594
  __publicField(this, "_interactive");
@@ -55261,21 +55596,13 @@ class SectionBox {
55261
55596
  __publicField(this, "_onBoxConfirm", new distExports.SimpleEventDispatcher());
55262
55597
  __publicField(this, "_onHover", new distExports.SimpleEventDispatcher());
55263
55598
  this._viewer = viewer;
55264
- this._normal = new Vector3$1();
55265
- this._cube = new BoxMesh();
55266
- this._outline = new BoxOutline();
55267
- this._highlight = new BoxHighlight();
55268
- this.renderer.add(this._cube);
55269
- this.renderer.add(this._outline);
55270
- this.renderer.add(this._highlight);
55599
+ this._gizmos = new SectionBoxGizmo(viewer.renderer);
55271
55600
  this._inputs = new BoxInputs(
55272
55601
  viewer,
55273
- this._cube,
55602
+ this._gizmos.handles,
55274
55603
  this._viewer.renderer.section.box
55275
55604
  );
55276
55605
  this._inputs.onFaceEnter = (normal) => {
55277
- this._normal = normal;
55278
- if (this.visible) this._highlight.highlight(this.section.box, normal);
55279
55606
  this._onHover.dispatch(normal.x !== 0 || normal.y !== 0 || normal.z !== 0);
55280
55607
  this.renderer.needsUpdate = true;
55281
55608
  };
@@ -55290,37 +55617,61 @@ class SectionBox {
55290
55617
  this.update();
55291
55618
  }
55292
55619
  /**
55293
- * Signal dispatched when clip, show, or interactive are updated.
55620
+ * @internal
55621
+ * A convenience getter to the viewer's renderer.
55622
+ */
55623
+ get renderer() {
55624
+ return this._viewer.renderer;
55625
+ }
55626
+ /**
55627
+ * @internal
55628
+ * A convenience getter to the `Section` module in the renderer.
55629
+ */
55630
+ get section() {
55631
+ return this._viewer.renderer.section;
55632
+ }
55633
+ // -------------------------------------------------------------------------
55634
+ // Public Signals
55635
+ // -------------------------------------------------------------------------
55636
+ /**
55637
+ * Dispatches when any of the following properties change:
55638
+ * - {@link clip} (clipping planes active)
55639
+ * - {@link visible} (gizmo visibility)
55640
+ * - {@link interactive} (pointer inputs active)
55294
55641
  */
55295
55642
  get onStateChanged() {
55296
55643
  return this._onStateChanged.asEvent();
55297
55644
  }
55298
55645
  /**
55299
- * Signal dispatched when user is done manipulating the box.
55646
+ * Dispatches when the user finishes manipulating (dragging) the box.
55647
+ * The payload is the final {@link THREE.Box3} used for clipping.
55300
55648
  */
55301
55649
  get onBoxConfirm() {
55302
55650
  return this._onBoxConfirm.asEvent();
55303
55651
  }
55304
55652
  /**
55305
- * Signal dispatched with true when pointer enters box and false when pointer leaves.
55653
+ * Dispatches a boolean indicating pointer hover state on the box handles:
55654
+ * - `true` if the pointer has entered a handle
55655
+ * - `false` if it has left or no handle is hovered
55306
55656
  */
55307
55657
  get onHover() {
55308
55658
  return this._onHover.asEvent();
55309
55659
  }
55310
- get renderer() {
55311
- return this._viewer.renderer;
55312
- }
55313
- get section() {
55314
- return this._viewer.renderer.section;
55315
- }
55660
+ // -------------------------------------------------------------------------
55661
+ // Public Properties
55662
+ // -------------------------------------------------------------------------
55316
55663
  /**
55317
- * Section bounding box, to update the box use fitBox.
55664
+ * The shared bounding box that defines the section region.
55665
+ *
55666
+ * To programmatically update the box, see {@link fitBox}.
55318
55667
  */
55319
55668
  get box() {
55320
55669
  return this.section.box;
55321
55670
  }
55322
55671
  /**
55323
- * Determines whether the section gizmo will section the model with clipping planes.
55672
+ * Determines whether the section gizmo applies clipping planes to the model.
55673
+ *
55674
+ * When `true`, `renderer.section.active` is enabled.
55324
55675
  */
55325
55676
  get clip() {
55326
55677
  return this._clip ?? false;
@@ -55332,71 +55683,79 @@ class SectionBox {
55332
55683
  this._onStateChanged.dispatch();
55333
55684
  }
55334
55685
  /**
55335
- * Determines whether the gizmo reacts to user inputs.
55686
+ * Determines whether the gizmo is interactive (i.e. responds to pointer events).
55687
+ *
55688
+ * When `true`, pointer events are registered and box handles can be dragged.
55336
55689
  */
55337
55690
  get interactive() {
55338
55691
  return this._interactive ?? false;
55339
55692
  }
55340
55693
  set interactive(value) {
55341
55694
  if (value === this._interactive) return;
55342
- if (!this._interactive && value) this._inputs.register();
55343
- if (this._interactive && !value) this._inputs.unregister();
55695
+ if (!this._interactive && value) {
55696
+ this._inputs.register();
55697
+ }
55698
+ if (this._interactive && !value) {
55699
+ this._inputs.unregister();
55700
+ }
55344
55701
  this._interactive = value;
55345
- this._highlight.visible = false;
55346
55702
  this.renderer.needsUpdate = true;
55347
55703
  this._onStateChanged.dispatch();
55348
55704
  }
55349
55705
  /**
55350
- * Determines whether the gizmo will be rendered.
55706
+ * Determines whether the section box gizmo is visible in the scene.
55351
55707
  */
55352
55708
  get visible() {
55353
55709
  return this._visible ?? false;
55354
55710
  }
55355
55711
  set visible(value) {
55356
55712
  if (value === this._visible) return;
55357
- this._visible = value;
55358
- this._cube.visible = value;
55359
- this._outline.visible = value;
55360
- this._highlight.visible = value;
55361
- if (value) this.update();
55713
+ this._gizmos.visible = value;
55714
+ if (value) {
55715
+ this.update();
55716
+ }
55362
55717
  this.renderer.needsUpdate = true;
55363
55718
  this._onStateChanged.dispatch();
55364
55719
  }
55720
+ // -------------------------------------------------------------------------
55721
+ // Public Methods
55722
+ // -------------------------------------------------------------------------
55365
55723
  /**
55366
- * Sets the section gizmo size to match the given box.
55367
- * @param {THREE.Box3} box - The box to match the section gizmo size to.
55368
- * @param {number} [padding=1] - The padding to apply to the box.
55724
+ * Resizes the section gizmo to match the given box, optionally expanded by a padding.
55725
+ * After resizing, this method also updates the renderer's clipping box.
55726
+ *
55727
+ * @param box - The bounding box to match (required).
55728
+ * @param padding - The scalar amount by which to expand the bounding box. Default is `1`.
55369
55729
  */
55370
55730
  fitBox(box, padding = 1) {
55371
55731
  if (!box) return;
55372
55732
  const b = box.expandByScalar(padding);
55373
- this._cube.fitBox(b);
55374
- this._outline.fitBox(b);
55733
+ this._gizmos.fitBox(b);
55375
55734
  this.renderer.section.fitBox(b);
55376
55735
  this._onBoxConfirm.dispatch(this.box);
55377
55736
  this.renderer.needsUpdate = true;
55378
55737
  }
55379
55738
  /**
55380
- * Call this if there were direct changes to renderer.section
55739
+ * Updates the section box to match the current size of `this.section.box`.
55740
+ *
55741
+ * Call this if the renderer's section box is changed by code outside this class.
55381
55742
  */
55382
55743
  update() {
55383
55744
  this.fitBox(this.section.box, 0);
55384
- this._highlight.highlight(this.section.box, this._normal);
55385
55745
  this.renderer.needsUpdate = true;
55386
55746
  }
55387
55747
  /**
55388
- * Removes gizmo from rendering and inputs and dispose all resources.
55748
+ * Disposes of the gizmo and input event listeners, cleaning up related resources.
55749
+ *
55750
+ * After disposal, this `SectionBox` instance should no longer be used.
55389
55751
  */
55390
55752
  dispose() {
55391
- this.renderer.remove(this._cube);
55392
- this.renderer.remove(this._outline);
55393
- this.renderer.remove(this._highlight);
55753
+ this._onBoxConfirm.clear();
55754
+ this._onHover.clear();
55755
+ this._gizmos.dispose();
55394
55756
  this._inputs.unregister();
55395
- this._cube.dispose();
55396
- this._outline.dispose();
55397
- this._highlight.dispose();
55398
55757
  }
55399
- }
55758
+ };
55400
55759
  class Gizmos {
55401
55760
  constructor(viewer, camera2) {
55402
55761
  __publicField(this, "viewer");
@@ -55428,7 +55787,7 @@ class Gizmos {
55428
55787
  var _a2;
55429
55788
  this.viewer = viewer;
55430
55789
  this._measure = new Measure(viewer);
55431
- this.section = new SectionBox(viewer);
55790
+ this.section = new SectionBox$1(viewer);
55432
55791
  this.loading = new GizmoLoading(viewer);
55433
55792
  this.orbit = new GizmoOrbit(
55434
55793
  viewer.renderer,
@@ -57661,17 +58020,16 @@ function isWebSocketUrl(input) {
57661
58020
  class Marshal {
57662
58021
  constructor(initialSize = 1024) {
57663
58022
  __publicField(this, "buffer");
57664
- __publicField(this, "dataView");
57665
- __publicField(this, "readOffset", 0);
57666
- __publicField(this, "writeOffset", 0);
58023
+ __publicField(this, "_dataView");
58024
+ __publicField(this, "_offset", 0);
57667
58025
  this.buffer = new ArrayBuffer(initialSize);
57668
- this.dataView = new DataView(this.buffer);
58026
+ this._dataView = new DataView(this.buffer);
57669
58027
  }
57670
58028
  getBuffer() {
57671
- return this.buffer.slice(0, this.writeOffset);
58029
+ return this.buffer.slice(0, this._offset);
57672
58030
  }
57673
58031
  ensureCapacity(additionalSize) {
57674
- const requiredSize = this.writeOffset + additionalSize;
58032
+ const requiredSize = this._offset + additionalSize;
57675
58033
  if (requiredSize > this.buffer.byteLength) {
57676
58034
  let newLength = this.buffer.byteLength;
57677
58035
  while (newLength < requiredSize) {
@@ -57680,21 +58038,162 @@ class Marshal {
57680
58038
  const newBuffer = new ArrayBuffer(newLength);
57681
58039
  new Uint8Array(newBuffer).set(new Uint8Array(this.buffer));
57682
58040
  this.buffer = newBuffer;
57683
- this.dataView = new DataView(this.buffer);
58041
+ this._dataView = new DataView(this.buffer);
57684
58042
  }
57685
58043
  }
57686
58044
  writeData(data2) {
57687
58045
  this.ensureCapacity(data2.byteLength);
57688
- new Uint8Array(this.buffer, this.writeOffset).set(new Uint8Array(data2));
57689
- this.writeOffset += data2.byteLength;
58046
+ new Uint8Array(this.buffer, this._offset).set(new Uint8Array(data2));
58047
+ this._offset += data2.byteLength;
57690
58048
  }
57691
- // -------------------- Matrix44 Methods --------------------
58049
+ // -------------------- Matrix44 -------------------
57692
58050
  writeMatrix44(data2) {
57693
58051
  this.ensureCapacity(4 * 4 * 4);
57694
58052
  this.writeArray(data2.toArray(), 4, (element) => {
57695
58053
  this.writeFloat(element);
57696
58054
  });
57697
58055
  }
58056
+ // -------------------- Boolean -------------------
58057
+ writeBoolean(value) {
58058
+ this.ensureCapacity(4);
58059
+ this._dataView.setUint32(this._offset, value ? 1 : 0, true);
58060
+ this._offset += 4;
58061
+ }
58062
+ // -------------------- Int -------------------
58063
+ writeInt(value) {
58064
+ this.ensureCapacity(4);
58065
+ this._dataView.setInt32(this._offset, value, true);
58066
+ this._offset += 4;
58067
+ }
58068
+ // -------------------- UInt -------------------
58069
+ writeUInt(value) {
58070
+ this.ensureCapacity(4);
58071
+ this._dataView.setUint32(this._offset, value, true);
58072
+ this._offset += 4;
58073
+ }
58074
+ // -------------------- Float -------------------
58075
+ writeFloat(value) {
58076
+ this.ensureCapacity(4);
58077
+ this._dataView.setFloat32(this._offset, value, true);
58078
+ this._offset += 4;
58079
+ }
58080
+ // -------------------- String -------------------
58081
+ writeString(value) {
58082
+ const textEncoder = new TextEncoder();
58083
+ const encodedString = textEncoder.encode(value + "\0");
58084
+ this.ensureCapacity(4 + encodedString.byteLength);
58085
+ this.writeUInt(encodedString.length);
58086
+ new Uint8Array(this.buffer, this._offset).set(encodedString);
58087
+ this._offset += encodedString.length;
58088
+ }
58089
+ // -------------------- HitCheckResult -------------------
58090
+ writeHitCheckResult(data2) {
58091
+ this.ensureCapacity(4 + 4 + 4 * 3 + 4 * 3);
58092
+ this.writeUInt(data2.vimHandle);
58093
+ this.writeUInt(data2.nodeIndex);
58094
+ this.writeVector3(data2.worldPosition);
58095
+ this.writeVector3(data2.worldNormal);
58096
+ }
58097
+ // -------------------- VimStatus -------------------
58098
+ writeVimStatus(data2) {
58099
+ this.ensureCapacity(4 + 4);
58100
+ this.writeUInt(data2.status);
58101
+ this.writeFloat(data2.progress);
58102
+ }
58103
+ // -------------------- Vector2 -------------------
58104
+ writeVector2(data2) {
58105
+ this.ensureCapacity(4 + 4);
58106
+ this.writeFloat(data2.x);
58107
+ this.writeFloat(data2.y);
58108
+ }
58109
+ // -------------------- Vector3 -------------------
58110
+ writeVector3(data2) {
58111
+ this.ensureCapacity(4 + 4 + 4);
58112
+ this.writeFloat(data2.x);
58113
+ this.writeFloat(data2.y);
58114
+ this.writeFloat(data2.z);
58115
+ }
58116
+ // -------------------- Vector4 -------------------
58117
+ writeVector4(data2) {
58118
+ this.ensureCapacity(4 + 4 + 4 + 4);
58119
+ this.writeFloat(data2.x);
58120
+ this.writeFloat(data2.y);
58121
+ this.writeFloat(data2.z);
58122
+ this.writeFloat(data2.w);
58123
+ }
58124
+ // -------------------- RGBA -------------------
58125
+ writeRGBA(color) {
58126
+ this.ensureCapacity(4 + 4 + 4 + 4);
58127
+ this.writeFloat(color.r);
58128
+ this.writeFloat(color.g);
58129
+ this.writeFloat(color.b);
58130
+ this.writeFloat(color.a);
58131
+ }
58132
+ // -------------------- RGB -------------------
58133
+ writeRGB(color) {
58134
+ this.ensureCapacity(4 + 4 + 4 + 4);
58135
+ this.writeFloat(color.r);
58136
+ this.writeFloat(color.g);
58137
+ this.writeFloat(color.b);
58138
+ }
58139
+ // -------------------- RGBA32 -------------------
58140
+ writeRGBA32(color) {
58141
+ this.ensureCapacity(4);
58142
+ this.writeUInt(color.hex);
58143
+ }
58144
+ // -------------------- CameraPositionAndTarget -------------------
58145
+ writeSegment(segment) {
58146
+ this.ensureCapacity(4 * 3 * 2);
58147
+ this.writeVector3(segment.origin);
58148
+ this.writeVector3(segment.target);
58149
+ }
58150
+ // -------------------- Box3 -------------------
58151
+ writeBox3(data2) {
58152
+ this.ensureCapacity(4 * 3 * 2);
58153
+ this.writeVector3(data2.min);
58154
+ this.writeVector3(data2.max);
58155
+ }
58156
+ // -------------------- SectionBox -------------------
58157
+ writeSectionBoxState(data2) {
58158
+ this.writeBoolean(data2.enabled);
58159
+ this.writeBoolean(data2.visible);
58160
+ this.writeBoolean(data2.interactible);
58161
+ this.writeBoolean(data2.clip);
58162
+ this.writeBox3(data2.box);
58163
+ }
58164
+ // -------------------- Array of Int -------------------
58165
+ writeArrayOfInt(values) {
58166
+ this.writeArray(values, 4, (v) => this.writeInt(v));
58167
+ }
58168
+ // -------------------- Array of UInt -------------------
58169
+ writeArrayOfUInt(values) {
58170
+ this.writeArray(values, 4, (v) => this.writeUInt(v));
58171
+ }
58172
+ // -------------------- Array of Float -------------------
58173
+ writeArrayOfFloat(values) {
58174
+ this.writeArray(values, 4, (v) => this.writeFloat(v));
58175
+ }
58176
+ // -------------------- Array of Bool -------------------
58177
+ writeArrayOfBool(values) {
58178
+ this.writeArray(values, 4, (v) => this.writeBoolean(v));
58179
+ }
58180
+ // -------------------- Array of RGBA32 -------------------
58181
+ writeArrayOfRGBA32(values) {
58182
+ this.writeArray(values, 4, (v) => this.writeRGBA32(v));
58183
+ }
58184
+ // -------------------- Helpers --------------------
58185
+ writeArray(data2, sizeT, write) {
58186
+ this.ensureCapacity(4 + data2.length * sizeT);
58187
+ this.writeUInt(data2.length);
58188
+ data2.forEach((value) => write(value));
58189
+ }
58190
+ }
58191
+ class ReadMarshal {
58192
+ constructor(buffer) {
58193
+ __publicField(this, "_dataView");
58194
+ __publicField(this, "_offset", 0);
58195
+ this._dataView = new DataView(buffer);
58196
+ }
57698
58197
  readMatrix44() {
57699
58198
  const m00 = this.readFloat();
57700
58199
  const m01 = this.readFloat();
@@ -57714,74 +58213,33 @@ class Marshal {
57714
58213
  const m33 = this.readFloat();
57715
58214
  return new Matrix4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33);
57716
58215
  }
57717
- // -------------------- Boolean Methods --------------------
57718
- writeBoolean(value) {
57719
- this.ensureCapacity(4);
57720
- this.dataView.setUint32(this.writeOffset, value ? 1 : 0, true);
57721
- this.writeOffset += 4;
57722
- }
57723
- readBoolean() {
57724
- const value = this.dataView.getUint32(this.readOffset, true);
57725
- this.readOffset += 4;
57726
- return value !== 0;
57727
- }
57728
- // -------------------- Int Methods --------------------
57729
- writeInt(value) {
57730
- this.ensureCapacity(4);
57731
- this.dataView.setInt32(this.writeOffset, value, true);
57732
- this.writeOffset += 4;
57733
- }
57734
58216
  readInt() {
57735
- const value = this.dataView.getInt32(this.readOffset, true);
57736
- this.readOffset += 4;
58217
+ const value = this._dataView.getInt32(this._offset, true);
58218
+ this._offset += 4;
57737
58219
  return value;
57738
58220
  }
57739
- // -------------------- UInt Methods --------------------
57740
- writeUInt(value) {
57741
- this.ensureCapacity(4);
57742
- this.dataView.setUint32(this.writeOffset, value, true);
57743
- this.writeOffset += 4;
57744
- }
57745
58221
  readUInt() {
57746
- const value = this.dataView.getUint32(this.readOffset, true);
57747
- this.readOffset += 4;
58222
+ const value = this._dataView.getUint32(this._offset, true);
58223
+ this._offset += 4;
57748
58224
  return value;
57749
58225
  }
57750
- // -------------------- Float Methods --------------------
57751
- writeFloat(value) {
57752
- this.ensureCapacity(4);
57753
- this.dataView.setFloat32(this.writeOffset, value, true);
57754
- this.writeOffset += 4;
57755
- }
57756
58226
  readFloat() {
57757
- const value = this.dataView.getFloat32(this.readOffset, true);
57758
- this.readOffset += 4;
58227
+ const value = this._dataView.getFloat32(this._offset, true);
58228
+ this._offset += 4;
57759
58229
  return value;
57760
58230
  }
57761
- // -------------------- String Methods --------------------
57762
- writeString(value) {
57763
- const textEncoder = new TextEncoder();
57764
- const encodedString = textEncoder.encode(value + "\0");
57765
- this.ensureCapacity(4 + encodedString.byteLength);
57766
- this.writeUInt(encodedString.length);
57767
- new Uint8Array(this.buffer, this.writeOffset).set(encodedString);
57768
- this.writeOffset += encodedString.length;
58231
+ readBoolean() {
58232
+ const value = this._dataView.getUint32(this._offset, true);
58233
+ this._offset += 4;
58234
+ return value !== 0;
57769
58235
  }
57770
58236
  readString() {
57771
58237
  const length = this.readUInt();
57772
58238
  const textDecoder = new TextDecoder();
57773
- const stringData = new Uint8Array(this.buffer, this.readOffset, length - 1);
57774
- this.readOffset += length;
58239
+ const stringData = new Uint8Array(this._dataView.buffer, this._offset, length - 1);
58240
+ this._offset += length;
57775
58241
  return textDecoder.decode(stringData);
57776
58242
  }
57777
- // -------------------- HitCheckResult Methods --------------------
57778
- writeHitCheckResult(data2) {
57779
- this.ensureCapacity(4 + 4 + 4 * 3 + 4 * 3);
57780
- this.writeUInt(data2.vimHandle);
57781
- this.writeUInt(data2.nodeIndex);
57782
- this.writeVector3(data2.worldPosition);
57783
- this.writeVector3(data2.worldNormal);
57784
- }
57785
58243
  readHitCheckResult() {
57786
58244
  const vimHandle = this.readUInt();
57787
58245
  const nodeIndex = this.readUInt();
@@ -57794,12 +58252,6 @@ class Marshal {
57794
58252
  worldNormal
57795
58253
  };
57796
58254
  }
57797
- // -------------------- VimStatus Methods --------------------
57798
- writeVimStatus(data2) {
57799
- this.ensureCapacity(4 + 4);
57800
- this.writeUInt(data2.status);
57801
- this.writeFloat(data2.progress);
57802
- }
57803
58255
  readVimStatus() {
57804
58256
  const status = this.readUInt();
57805
58257
  const progress = this.readFloat();
@@ -57808,38 +58260,17 @@ class Marshal {
57808
58260
  progress
57809
58261
  };
57810
58262
  }
57811
- // -------------------- Vector2 Methods --------------------
57812
- writeVector2(data2) {
57813
- this.ensureCapacity(4 + 4);
57814
- this.writeFloat(data2.x);
57815
- this.writeFloat(data2.y);
57816
- }
57817
58263
  readVector2() {
57818
58264
  const x = this.readFloat();
57819
58265
  const y = this.readFloat();
57820
58266
  return new Vector22(x, y);
57821
58267
  }
57822
- // -------------------- Vector3 Methods --------------------
57823
- writeVector3(data2) {
57824
- this.ensureCapacity(4 + 4 + 4);
57825
- this.writeFloat(data2.x);
57826
- this.writeFloat(data2.y);
57827
- this.writeFloat(data2.z);
57828
- }
57829
58268
  readVector3() {
57830
58269
  const x = this.readFloat();
57831
58270
  const y = this.readFloat();
57832
58271
  const z = this.readFloat();
57833
58272
  return new Vector32(x, y, z);
57834
58273
  }
57835
- // -------------------- Vector4 Methods --------------------
57836
- writeVector4(data2) {
57837
- this.ensureCapacity(4 + 4 + 4 + 4);
57838
- this.writeFloat(data2.x);
57839
- this.writeFloat(data2.y);
57840
- this.writeFloat(data2.z);
57841
- this.writeFloat(data2.w);
57842
- }
57843
58274
  readVector4() {
57844
58275
  const x = this.readFloat();
57845
58276
  const y = this.readFloat();
@@ -57852,14 +58283,6 @@ class Marshal {
57852
58283
  w
57853
58284
  };
57854
58285
  }
57855
- // -------------------- RGBA Methods --------------------
57856
- writeRGBA(color) {
57857
- this.ensureCapacity(4 + 4 + 4 + 4);
57858
- this.writeFloat(color.r);
57859
- this.writeFloat(color.g);
57860
- this.writeFloat(color.b);
57861
- this.writeFloat(color.a);
57862
- }
57863
58286
  readRGBA() {
57864
58287
  const r = this.readFloat();
57865
58288
  const g = this.readFloat();
@@ -57867,91 +58290,55 @@ class Marshal {
57867
58290
  const a = this.readFloat();
57868
58291
  return new RGBA(r, g, b, a);
57869
58292
  }
57870
- // -------------------- RGB Methods --------------------
57871
- writeRGB(color) {
57872
- this.ensureCapacity(4 + 4 + 4 + 4);
57873
- this.writeFloat(color.r);
57874
- this.writeFloat(color.g);
57875
- this.writeFloat(color.b);
57876
- }
57877
58293
  readRGB() {
57878
58294
  const r = this.readFloat();
57879
58295
  const g = this.readFloat();
57880
58296
  const b = this.readFloat();
57881
58297
  return new RGB(r, g, b);
57882
58298
  }
57883
- // -------------------- RGBA32 Methods --------------------
57884
- writeRGBA32(color) {
57885
- this.ensureCapacity(4);
57886
- this.writeUInt(color.hex);
57887
- }
57888
58299
  readRGBA32() {
57889
58300
  const hex = this.readUInt();
57890
58301
  return new RGBA32(hex);
57891
58302
  }
57892
- // -------------------- CameraPositionAndTarget Methods --------------------
57893
- writeSegment(segment) {
57894
- this.ensureCapacity(4 * 3 * 2);
57895
- this.writeVector3(segment.origin);
57896
- this.writeVector3(segment.target);
58303
+ readBox3() {
58304
+ const min2 = this.readVector3();
58305
+ const max2 = this.readVector3();
58306
+ return new Box32(min2, max2);
57897
58307
  }
57898
58308
  readSegment() {
57899
58309
  const position = this.readVector3();
57900
58310
  const target = this.readVector3();
57901
58311
  return new Segment(position, target);
57902
58312
  }
57903
- // -------------------- Box3 Methods --------------------
57904
- writeBox3(data2) {
57905
- this.ensureCapacity(4 * 3 * 2);
57906
- this.writeVector3(data2.min);
57907
- this.writeVector3(data2.max);
57908
- }
57909
- readBox3() {
57910
- const min2 = this.readVector3();
57911
- const max2 = this.readVector3();
57912
- return new Box32(min2, max2);
57913
- }
57914
- // -------------------- Array of Int Methods --------------------
57915
- writeArrayOfInt(values) {
57916
- this.writeArray(values, 4, (v) => this.writeInt(v));
58313
+ readSectionBoxState() {
58314
+ const enabled = this.readBoolean();
58315
+ const visible2 = this.readBoolean();
58316
+ const interactible = this.readBoolean();
58317
+ const clip = this.readBoolean();
58318
+ const box = this.readBox3();
58319
+ return {
58320
+ enabled,
58321
+ visible: visible2,
58322
+ interactible,
58323
+ clip,
58324
+ box
58325
+ };
57917
58326
  }
57918
58327
  readArrayOfInt() {
57919
58328
  return this.readArray(() => this.readInt());
57920
58329
  }
57921
- // -------------------- Array of UInt Methods --------------------
57922
- writeArrayOfUInt(values) {
57923
- this.writeArray(values, 4, (v) => this.writeUInt(v));
57924
- }
57925
58330
  readArrayOfUInt() {
57926
58331
  return this.readArray(() => this.readUInt());
57927
58332
  }
57928
- // -------------------- Array of Float Methods --------------------
57929
- writeArrayOfFloat(values) {
57930
- this.writeArray(values, 4, (v) => this.writeFloat(v));
57931
- }
57932
58333
  readArrayOfFloat() {
57933
58334
  return this.readArray(() => this.readFloat());
57934
58335
  }
57935
- // -------------------- Array of Bool Methods --------------------
57936
- writeArrayOfBool(values) {
57937
- this.writeArray(values, 4, (v) => this.writeBoolean(v));
57938
- }
57939
58336
  readArrayOfBool() {
57940
58337
  return this.readArray(() => this.readBoolean());
57941
58338
  }
57942
- // -------------------- Array of RGBA32 Methods --------------------
57943
- writeArrayOfRGBA32(values) {
57944
- this.writeArray(values, 4, (v) => this.writeRGBA32(v));
57945
- }
57946
58339
  readArrayOfRGBA32() {
57947
58340
  return this.readArray(() => this.readRGBA32());
57948
58341
  }
57949
- // -------------------- Helpers --------------------
57950
- writeArray(data2, sizeT, write) {
57951
- this.ensureCapacity(4 + data2.length * sizeT);
57952
- this.writeUInt(data2.length);
57953
- data2.forEach((value) => write(value));
57954
- }
57955
58342
  readArray(read) {
57956
58343
  const length = this.readUInt();
57957
58344
  const array = [];
@@ -57986,17 +58373,17 @@ const materialHandles = [
57986
58373
  MaterialHandles.Invisible
57987
58374
  ];
57988
58375
  class RpcClient {
57989
- constructor(_messenger) {
57990
- __publicField(this, "_messenger");
58376
+ constructor(_socket) {
58377
+ __publicField(this, "_socket");
57991
58378
  // RPC Generated Code
57992
- __publicField(this, "API_VERSION", "5.0.0");
57993
- this._messenger = _messenger;
57994
- }
57995
- get url() {
57996
- return this._messenger.url;
58379
+ __publicField(this, "API_VERSION", "5.1.0");
58380
+ this._socket = _socket;
57997
58381
  }
57998
58382
  get connected() {
57999
- return this._messenger.state.status === "connected";
58383
+ return this._socket.state.status === "connected";
58384
+ }
58385
+ get url() {
58386
+ return this._socket.url;
58000
58387
  }
58001
58388
  RPCAddNodeFlags(componentHandle, nodes, flags) {
58002
58389
  const marshal = new Marshal();
@@ -58004,18 +58391,18 @@ class RpcClient {
58004
58391
  marshal.writeUInt(componentHandle);
58005
58392
  marshal.writeArrayOfUInt(nodes);
58006
58393
  marshal.writeUInt(flags);
58007
- this._messenger.sendRPC(marshal);
58394
+ this._socket.sendRPC(marshal);
58008
58395
  }
58009
58396
  RPCClearMaterialOverrides(componentHandle) {
58010
58397
  const marshal = new Marshal();
58011
58398
  marshal.writeString("RPCClearMaterialOverrides");
58012
58399
  marshal.writeUInt(componentHandle);
58013
- this._messenger.sendRPC(marshal);
58400
+ this._socket.sendRPC(marshal);
58014
58401
  }
58015
58402
  RPCClearScene() {
58016
58403
  const marshal = new Marshal();
58017
58404
  marshal.writeString("RPCClearScene");
58018
- this._messenger.sendRPC(marshal);
58405
+ this._socket.sendRPC(marshal);
58019
58406
  }
58020
58407
  async RPCCreateMaterialInstances(materialHandle, smoothness, colors) {
58021
58408
  const marshal = new Marshal();
@@ -58023,7 +58410,7 @@ class RpcClient {
58023
58410
  marshal.writeUInt(materialHandle);
58024
58411
  marshal.writeUInt(smoothness);
58025
58412
  marshal.writeArrayOfRGBA32(colors);
58026
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58413
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58027
58414
  const ret = returnMarshal.readUInt();
58028
58415
  return ret;
58029
58416
  }
@@ -58033,7 +58420,7 @@ class RpcClient {
58033
58420
  marshal.writeVector3(position);
58034
58421
  marshal.writeRGBA32(color);
58035
58422
  marshal.writeString(text);
58036
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58423
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58037
58424
  const ret = returnMarshal.readUInt();
58038
58425
  return ret;
58039
58426
  }
@@ -58041,25 +58428,19 @@ class RpcClient {
58041
58428
  const marshal = new Marshal();
58042
58429
  marshal.writeString("RPCDestroyMaterialInstances");
58043
58430
  marshal.writeArrayOfUInt(materialInstanceHandle);
58044
- this._messenger.sendRPC(marshal);
58431
+ this._socket.sendRPC(marshal);
58045
58432
  }
58046
58433
  RPCDestroyText(componentHandle) {
58047
58434
  const marshal = new Marshal();
58048
58435
  marshal.writeString("RPCDestroyText");
58049
58436
  marshal.writeUInt(componentHandle);
58050
- this._messenger.sendRPC(marshal);
58051
- }
58052
- RPCEnableSectionBox(enable) {
58053
- const marshal = new Marshal();
58054
- marshal.writeString("RPCEnableSectionBox");
58055
- marshal.writeBoolean(enable);
58056
- this._messenger.sendRPC(marshal);
58437
+ this._socket.sendRPC(marshal);
58057
58438
  }
58058
58439
  async RPCFrameAll(blendTime) {
58059
58440
  const marshal = new Marshal();
58060
58441
  marshal.writeString("RPCFrameAll");
58061
58442
  marshal.writeFloat(blendTime);
58062
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58443
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58063
58444
  const ret = returnMarshal.readSegment();
58064
58445
  return ret;
58065
58446
  }
@@ -58068,7 +58449,7 @@ class RpcClient {
58068
58449
  marshal.writeString("RPCFrameBox");
58069
58450
  marshal.writeBox3(box);
58070
58451
  marshal.writeFloat(blendTime);
58071
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58452
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58072
58453
  const ret = returnMarshal.readSegment();
58073
58454
  return ret;
58074
58455
  }
@@ -58078,7 +58459,7 @@ class RpcClient {
58078
58459
  marshal.writeUInt(componentHandle);
58079
58460
  marshal.writeArrayOfUInt(nodes);
58080
58461
  marshal.writeFloat(blendTime);
58081
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58462
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58082
58463
  const ret = returnMarshal.readSegment();
58083
58464
  return ret;
58084
58465
  }
@@ -58087,14 +58468,14 @@ class RpcClient {
58087
58468
  marshal.writeString("RPCFrameVim");
58088
58469
  marshal.writeUInt(componentHandle);
58089
58470
  marshal.writeFloat(blendTime);
58090
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58471
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58091
58472
  const ret = returnMarshal.readSegment();
58092
58473
  return ret;
58093
58474
  }
58094
58475
  async RPCGetAPIVersion() {
58095
58476
  const marshal = new Marshal();
58096
58477
  marshal.writeString("RPCGetAPIVersion");
58097
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58478
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58098
58479
  const ret = returnMarshal.readString();
58099
58480
  return ret;
58100
58481
  }
@@ -58103,36 +58484,58 @@ class RpcClient {
58103
58484
  marshal.writeString("RPCGetBoundingBox");
58104
58485
  marshal.writeUInt(componentHandle);
58105
58486
  marshal.writeArrayOfUInt(nodes);
58106
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58487
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58488
+ const ret = returnMarshal.readBox3();
58489
+ return ret;
58490
+ }
58491
+ async RPCGetBoundingBoxAll(componentHandle) {
58492
+ const marshal = new Marshal();
58493
+ marshal.writeString("RPCGetBoundingBoxAll");
58494
+ marshal.writeUInt(componentHandle);
58495
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58107
58496
  const ret = returnMarshal.readBox3();
58108
58497
  return ret;
58109
58498
  }
58110
58499
  async RPCGetCameraPosition() {
58111
58500
  const marshal = new Marshal();
58112
58501
  marshal.writeString("RPCGetCameraPosition");
58113
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58502
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58114
58503
  const ret = returnMarshal.readSegment();
58115
58504
  return ret;
58116
58505
  }
58117
58506
  async RPCGetIblRotation() {
58118
58507
  const marshal = new Marshal();
58119
58508
  marshal.writeString("RPCGetIblRotation");
58120
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58509
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58121
58510
  const ret = returnMarshal.readMatrix44();
58122
58511
  return ret;
58123
58512
  }
58124
58513
  async RPCGetLastError() {
58125
58514
  const marshal = new Marshal();
58126
58515
  marshal.writeString("RPCGetLastError");
58127
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58516
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58128
58517
  const ret = returnMarshal.readString();
58129
58518
  return ret;
58130
58519
  }
58520
+ async RPCGetSceneAABB() {
58521
+ const marshal = new Marshal();
58522
+ marshal.writeString("RPCGetSceneAABB");
58523
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58524
+ const ret = returnMarshal.readBox3();
58525
+ return ret;
58526
+ }
58527
+ async RPCGetSectionBox() {
58528
+ const marshal = new Marshal();
58529
+ marshal.writeString("RPCGetSectionBox");
58530
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58531
+ const ret = returnMarshal.readSectionBoxState();
58532
+ return ret;
58533
+ }
58131
58534
  async RPCGetVimLoadingState(componentHandle) {
58132
58535
  const marshal = new Marshal();
58133
58536
  marshal.writeString("RPCGetVimLoadingState");
58134
58537
  marshal.writeUInt(componentHandle);
58135
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58538
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58136
58539
  const ret = returnMarshal.readVimStatus();
58137
58540
  return ret;
58138
58541
  }
@@ -58141,65 +58544,65 @@ class RpcClient {
58141
58544
  marshal.writeString("RPCGhost");
58142
58545
  marshal.writeUInt(componentHandle);
58143
58546
  marshal.writeArrayOfUInt(nodes);
58144
- this._messenger.sendRPC(marshal);
58547
+ this._socket.sendRPC(marshal);
58145
58548
  }
58146
58549
  RPCGhostAll(componentHandle) {
58147
58550
  const marshal = new Marshal();
58148
58551
  marshal.writeString("RPCGhostAll");
58149
58552
  marshal.writeUInt(componentHandle);
58150
- this._messenger.sendRPC(marshal);
58553
+ this._socket.sendRPC(marshal);
58151
58554
  }
58152
58555
  RPCHide(componentHandle, nodes) {
58153
58556
  const marshal = new Marshal();
58154
58557
  marshal.writeString("RPCHide");
58155
58558
  marshal.writeUInt(componentHandle);
58156
58559
  marshal.writeArrayOfUInt(nodes);
58157
- this._messenger.sendRPC(marshal);
58560
+ this._socket.sendRPC(marshal);
58158
58561
  }
58159
58562
  RPCHideAABBs(componentHandle, nodes) {
58160
58563
  const marshal = new Marshal();
58161
58564
  marshal.writeString("RPCHideAABBs");
58162
58565
  marshal.writeUInt(componentHandle);
58163
58566
  marshal.writeArrayOfUInt(nodes);
58164
- this._messenger.sendRPC(marshal);
58567
+ this._socket.sendRPC(marshal);
58165
58568
  }
58166
58569
  RPCHideAll(componentHandle) {
58167
58570
  const marshal = new Marshal();
58168
58571
  marshal.writeString("RPCHideAll");
58169
58572
  marshal.writeUInt(componentHandle);
58170
- this._messenger.sendRPC(marshal);
58573
+ this._socket.sendRPC(marshal);
58171
58574
  }
58172
58575
  RPCHideAllAABBs(componentHandle) {
58173
58576
  const marshal = new Marshal();
58174
58577
  marshal.writeString("RPCHideAllAABBs");
58175
58578
  marshal.writeUInt(componentHandle);
58176
- this._messenger.sendRPC(marshal);
58579
+ this._socket.sendRPC(marshal);
58177
58580
  }
58178
58581
  RPCHighlight(componentHandle, nodes) {
58179
58582
  const marshal = new Marshal();
58180
58583
  marshal.writeString("RPCHighlight");
58181
58584
  marshal.writeUInt(componentHandle);
58182
58585
  marshal.writeArrayOfUInt(nodes);
58183
- this._messenger.sendRPC(marshal);
58586
+ this._socket.sendRPC(marshal);
58184
58587
  }
58185
58588
  RPCHighlightAll(componentHandle) {
58186
58589
  const marshal = new Marshal();
58187
58590
  marshal.writeString("RPCHighlightAll");
58188
58591
  marshal.writeUInt(componentHandle);
58189
- this._messenger.sendRPC(marshal);
58592
+ this._socket.sendRPC(marshal);
58190
58593
  }
58191
58594
  RPCKeyEvent(keyCode, down) {
58192
58595
  const marshal = new Marshal();
58193
58596
  marshal.writeString("RPCKeyEvent");
58194
58597
  marshal.writeInt(keyCode);
58195
58598
  marshal.writeBoolean(down);
58196
- this._messenger.sendRPC(marshal);
58599
+ this._socket.sendRPC(marshal);
58197
58600
  }
58198
58601
  async RPCLoadVim(fileName) {
58199
58602
  const marshal = new Marshal();
58200
58603
  marshal.writeString("RPCLoadVim");
58201
58604
  marshal.writeString(fileName);
58202
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58605
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58203
58606
  const ret = returnMarshal.readUInt();
58204
58607
  return ret;
58205
58608
  }
@@ -58208,7 +58611,7 @@ class RpcClient {
58208
58611
  marshal.writeString("RPCLoadVimURL");
58209
58612
  marshal.writeString(url);
58210
58613
  marshal.writeString(authToken);
58211
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58614
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58212
58615
  const ret = returnMarshal.readUInt();
58213
58616
  return ret;
58214
58617
  }
@@ -58216,7 +58619,7 @@ class RpcClient {
58216
58619
  const marshal = new Marshal();
58217
58620
  marshal.writeString("RPCLockIblRotation");
58218
58621
  marshal.writeBoolean(lock);
58219
- this._messenger.sendRPC(marshal);
58622
+ this._socket.sendRPC(marshal);
58220
58623
  }
58221
58624
  RPCMouseButtonEvent(mousePos, mouseButton, down) {
58222
58625
  const marshal = new Marshal();
@@ -58224,33 +58627,33 @@ class RpcClient {
58224
58627
  marshal.writeVector2(mousePos);
58225
58628
  marshal.writeInt(mouseButton);
58226
58629
  marshal.writeBoolean(down);
58227
- this._messenger.sendRPC(marshal);
58630
+ this._socket.sendRPC(marshal);
58228
58631
  }
58229
58632
  RPCMouseDoubleClickEvent(mousePos, mouseButton) {
58230
58633
  const marshal = new Marshal();
58231
58634
  marshal.writeString("RPCMouseDoubleClickEvent");
58232
58635
  marshal.writeVector2(mousePos);
58233
58636
  marshal.writeInt(mouseButton);
58234
- this._messenger.sendRPC(marshal);
58637
+ this._socket.sendRPC(marshal);
58235
58638
  }
58236
58639
  RPCMouseMoveEvent(mousePos) {
58237
58640
  const marshal = new Marshal();
58238
58641
  marshal.writeString("RPCMouseMoveEvent");
58239
58642
  marshal.writeVector2(mousePos);
58240
- this._messenger.sendRPC(marshal);
58643
+ this._socket.sendRPC(marshal);
58241
58644
  }
58242
58645
  RPCMouseScrollEvent(scrollValue) {
58243
58646
  const marshal = new Marshal();
58244
58647
  marshal.writeString("RPCMouseScrollEvent");
58245
58648
  marshal.writeInt(scrollValue);
58246
- this._messenger.sendRPC(marshal);
58649
+ this._socket.sendRPC(marshal);
58247
58650
  }
58248
58651
  RPCMouseSelectEvent(mousePos, mouseButton) {
58249
58652
  const marshal = new Marshal();
58250
58653
  marshal.writeString("RPCMouseSelectEvent");
58251
58654
  marshal.writeVector2(mousePos);
58252
58655
  marshal.writeInt(mouseButton);
58253
- this._messenger.sendRPC(marshal);
58656
+ this._socket.sendRPC(marshal);
58254
58657
  }
58255
58658
  RPCMoveCameraTo(usePosition, useTarget, position, target, blendTime) {
58256
58659
  const marshal = new Marshal();
@@ -58260,19 +58663,19 @@ class RpcClient {
58260
58663
  marshal.writeVector3(position);
58261
58664
  marshal.writeVector3(target);
58262
58665
  marshal.writeFloat(blendTime);
58263
- this._messenger.sendRPC(marshal);
58666
+ this._socket.sendRPC(marshal);
58264
58667
  }
58265
58668
  RPCPauseRendering(pause) {
58266
58669
  const marshal = new Marshal();
58267
58670
  marshal.writeString("RPCPauseRendering");
58268
58671
  marshal.writeBoolean(pause);
58269
- this._messenger.sendRPC(marshal);
58672
+ this._socket.sendRPC(marshal);
58270
58673
  }
58271
58674
  async RPCPerformHitTest(pos) {
58272
58675
  const marshal = new Marshal();
58273
58676
  marshal.writeString("RPCPerformHitTest");
58274
58677
  marshal.writeVector2(pos);
58275
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58678
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58276
58679
  const ret = returnMarshal.readHitCheckResult();
58277
58680
  return ret;
58278
58681
  }
@@ -58282,39 +58685,39 @@ class RpcClient {
58282
58685
  marshal.writeUInt(componentHandle);
58283
58686
  marshal.writeArrayOfUInt(nodes);
58284
58687
  marshal.writeUInt(flags);
58285
- this._messenger.sendRPC(marshal);
58688
+ this._socket.sendRPC(marshal);
58286
58689
  }
58287
58690
  RPCSetAspectRatio(width, height) {
58288
58691
  const marshal = new Marshal();
58289
58692
  marshal.writeString("RPCSetAspectRatio");
58290
58693
  marshal.writeUInt(width);
58291
58694
  marshal.writeUInt(height);
58292
- this._messenger.sendRPC(marshal);
58695
+ this._socket.sendRPC(marshal);
58293
58696
  }
58294
58697
  RPCSetCameraMode(orbit2) {
58295
58698
  const marshal = new Marshal();
58296
58699
  marshal.writeString("RPCSetCameraMode");
58297
58700
  marshal.writeBoolean(orbit2);
58298
- this._messenger.sendRPC(marshal);
58701
+ this._socket.sendRPC(marshal);
58299
58702
  }
58300
58703
  RPCSetCameraPosition(state, blendTime) {
58301
58704
  const marshal = new Marshal();
58302
58705
  marshal.writeString("RPCSetCameraPosition");
58303
58706
  marshal.writeSegment(state);
58304
58707
  marshal.writeFloat(blendTime);
58305
- this._messenger.sendRPC(marshal);
58708
+ this._socket.sendRPC(marshal);
58306
58709
  }
58307
58710
  RPCSetGhostColor(ghostColor) {
58308
58711
  const marshal = new Marshal();
58309
58712
  marshal.writeString("RPCSetGhostColor");
58310
58713
  marshal.writeRGBA(ghostColor);
58311
- this._messenger.sendRPC(marshal);
58714
+ this._socket.sendRPC(marshal);
58312
58715
  }
58313
58716
  RPCSetIblRotation(transform) {
58314
58717
  const marshal = new Marshal();
58315
58718
  marshal.writeString("RPCSetIblRotation");
58316
58719
  marshal.writeMatrix44(transform);
58317
- this._messenger.sendRPC(marshal);
58720
+ this._socket.sendRPC(marshal);
58318
58721
  }
58319
58722
  RPCSetLighting(toneMappingWhitePoint, hdrScale, hdrBackgroundScale, hdrBackgroundSaturation, backgroundBlur, backgroundColor) {
58320
58723
  const marshal = new Marshal();
@@ -58325,7 +58728,7 @@ class RpcClient {
58325
58728
  marshal.writeFloat(hdrBackgroundSaturation);
58326
58729
  marshal.writeFloat(backgroundBlur);
58327
58730
  marshal.writeRGBA(backgroundColor);
58328
- this._messenger.sendRPC(marshal);
58731
+ this._socket.sendRPC(marshal);
58329
58732
  }
58330
58733
  RPCSetMaterialOverrides(componentHandle, nodes, materialInstanceHandles) {
58331
58734
  const marshal = new Marshal();
@@ -58333,26 +58736,26 @@ class RpcClient {
58333
58736
  marshal.writeUInt(componentHandle);
58334
58737
  marshal.writeArrayOfUInt(nodes);
58335
58738
  marshal.writeArrayOfUInt(materialInstanceHandles);
58336
- this._messenger.sendRPC(marshal);
58739
+ this._socket.sendRPC(marshal);
58337
58740
  }
58338
58741
  RPCSetMoveSpeed(speed) {
58339
58742
  const marshal = new Marshal();
58340
58743
  marshal.writeString("RPCSetMoveSpeed");
58341
58744
  marshal.writeFloat(speed);
58342
- this._messenger.sendRPC(marshal);
58745
+ this._socket.sendRPC(marshal);
58343
58746
  }
58344
- RPCSetSectionBox(aabb) {
58747
+ RPCSetSectionBox(state) {
58345
58748
  const marshal = new Marshal();
58346
58749
  marshal.writeString("RPCSetSectionBox");
58347
- marshal.writeBox3(aabb);
58348
- this._messenger.sendRPC(marshal);
58750
+ marshal.writeSectionBoxState(state);
58751
+ this._socket.sendRPC(marshal);
58349
58752
  }
58350
58753
  RPCShow(componentHandle, nodes) {
58351
58754
  const marshal = new Marshal();
58352
58755
  marshal.writeString("RPCShow");
58353
58756
  marshal.writeUInt(componentHandle);
58354
58757
  marshal.writeArrayOfUInt(nodes);
58355
- this._messenger.sendRPC(marshal);
58758
+ this._socket.sendRPC(marshal);
58356
58759
  }
58357
58760
  RPCShowAABBs(componentHandle, nodes, colors) {
58358
58761
  const marshal = new Marshal();
@@ -58360,13 +58763,13 @@ class RpcClient {
58360
58763
  marshal.writeUInt(componentHandle);
58361
58764
  marshal.writeArrayOfUInt(nodes);
58362
58765
  marshal.writeArrayOfRGBA32(colors);
58363
- this._messenger.sendRPC(marshal);
58766
+ this._socket.sendRPC(marshal);
58364
58767
  }
58365
58768
  RPCShowAll(componentHandle) {
58366
58769
  const marshal = new Marshal();
58367
58770
  marshal.writeString("RPCShowAll");
58368
58771
  marshal.writeUInt(componentHandle);
58369
- this._messenger.sendRPC(marshal);
58772
+ this._socket.sendRPC(marshal);
58370
58773
  }
58371
58774
  async RPCStartScene(toneMappingWhitePoint, hdrScale, hdrBackgroundScale, hdrBackgroundSaturation, backgroundBlur, backgroundColor) {
58372
58775
  const marshal = new Marshal();
@@ -58377,20 +58780,20 @@ class RpcClient {
58377
58780
  marshal.writeFloat(hdrBackgroundSaturation);
58378
58781
  marshal.writeFloat(backgroundBlur);
58379
58782
  marshal.writeRGBA(backgroundColor);
58380
- const returnMarshal = await this._messenger.sendRPCWithReturn(marshal);
58783
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58381
58784
  const ret = returnMarshal.readBoolean();
58382
58785
  return ret;
58383
58786
  }
58384
58787
  RPCTriggerRenderDocCapture() {
58385
58788
  const marshal = new Marshal();
58386
58789
  marshal.writeString("RPCTriggerRenderDocCapture");
58387
- this._messenger.sendRPC(marshal);
58790
+ this._socket.sendRPC(marshal);
58388
58791
  }
58389
58792
  RPCUnloadVim(componentHandle) {
58390
58793
  const marshal = new Marshal();
58391
58794
  marshal.writeString("RPCUnloadVim");
58392
58795
  marshal.writeUInt(componentHandle);
58393
- this._messenger.sendRPC(marshal);
58796
+ this._socket.sendRPC(marshal);
58394
58797
  }
58395
58798
  }
58396
58799
  class Validation {
@@ -58869,6 +59272,19 @@ class RpcSafeClient {
58869
59272
  if (!Validation.isComponentHandle(componentHandle)) return;
58870
59273
  this.rpc.RPCDestroyText(componentHandle);
58871
59274
  }
59275
+ /*******************************************************************************
59276
+ * SECTION BOX METHODS
59277
+ * Methods for controlling section box visibility and position.
59278
+ ******************************************************************************/
59279
+ RPCSetSectionBox(state) {
59280
+ this.rpc.RPCSetSectionBox(state);
59281
+ }
59282
+ async RPCGetSectionBox() {
59283
+ return await this.safeCall(
59284
+ () => this.rpc.RPCGetSectionBox(),
59285
+ void 0
59286
+ );
59287
+ }
58872
59288
  /*******************************************************************************
58873
59289
  * CAMERA AND VIEW METHODS
58874
59290
  * Methods for controlling camera position, movement, framing, and view settings.
@@ -58894,6 +59310,12 @@ class RpcSafeClient {
58894
59310
  blendTime = Validation.clamp01(blendTime);
58895
59311
  this.rpc.RPCSetCameraPosition(segment, blendTime);
58896
59312
  }
59313
+ async RPCGetBoundingBoxAll(componentHandle) {
59314
+ return await this.safeCall(
59315
+ () => this.rpc.RPCGetBoundingBoxAll(componentHandle),
59316
+ void 0
59317
+ );
59318
+ }
58897
59319
  /**
58898
59320
  * Calculates the bounding box for specified nodes in a component.
58899
59321
  * Large node arrays are automatically processed in batches for better performance.
@@ -59487,9 +59909,6 @@ class StreamLogger {
59487
59909
  * Starts logging the stream metrics.
59488
59910
  */
59489
59911
  startLoggging() {
59490
- this._id = setInterval(() => {
59491
- this.logMetrics();
59492
- }, 5e3);
59493
59912
  }
59494
59913
  /**
59495
59914
  * Stops logging the stream metrics.
@@ -59601,6 +60020,8 @@ class SocketClient {
59601
60020
  */
59602
60021
  __publicField(this, "onVideoFrame", () => {
59603
60022
  });
60023
+ __publicField(this, "onCameraPose", () => {
60024
+ });
59604
60025
  __publicField(this, "_state", { status: "disconnected" });
59605
60026
  __publicField(this, "_onStatusUpdate", new distExports.SimpleEventDispatcher());
59606
60027
  __publicField(this, "_connectPromise", new ResolvedPromise(void 0));
@@ -59658,7 +60079,7 @@ class SocketClient {
59658
60079
  return Promise.reject(new Error(`Invalid WebSocket URL: ${url}`));
59659
60080
  }
59660
60081
  if (this._socket) {
59661
- if (this._socket.url === url) {
60082
+ if (this._connectionSettings.url === url) {
59662
60083
  return this._connectPromise.promise;
59663
60084
  } else {
59664
60085
  this._clearSocket();
@@ -59745,6 +60166,10 @@ class SocketClient {
59745
60166
  this.handleRPCResponse(msg.dataBuffer);
59746
60167
  return;
59747
60168
  case 254:
60169
+ const m = new ReadMarshal(msg.dataBuffer);
60170
+ if (this.onCameraPose) {
60171
+ this.onCameraPose(m.readSegment());
60172
+ }
59748
60173
  return;
59749
60174
  case 0:
59750
60175
  case 1:
@@ -59758,8 +60183,7 @@ class SocketClient {
59758
60183
  * @param buffer - The ArrayBuffer containing the response data.
59759
60184
  */
59760
60185
  handleRPCResponse(buffer) {
59761
- const m = new Marshal();
59762
- m.writeData(buffer);
60186
+ const m = new ReadMarshal(buffer);
59763
60187
  const callId = m.readUInt();
59764
60188
  const pendingRPC = this._pendingRPCs.get(callId);
59765
60189
  if (pendingRPC !== void 0) {
@@ -60462,12 +60886,12 @@ class Vim2 {
60462
60886
  * @throws Error if 'all' is passed, as this feature is not supported yet.
60463
60887
  */
60464
60888
  async getBoundingBox(nodes) {
60465
- if (nodes === "all") {
60466
- throw new Error("Feature not supported yet.");
60467
- }
60468
60889
  if (!this.connected || nodes.length === 0) {
60469
60890
  return Promise.resolve(void 0);
60470
60891
  }
60892
+ if (nodes === "all") {
60893
+ return await this._rpc.RPCGetBoundingBoxAll(this._handle);
60894
+ }
60471
60895
  return await this._rpc.RPCGetBoundingBox(this._handle, nodes);
60472
60896
  }
60473
60897
  /**
@@ -60929,7 +61353,7 @@ class Camera3 {
60929
61353
  }
60930
61354
  /**
60931
61355
  * Restores the camera to its last tracked position
60932
- * @param blendTime - Duration of the camera animation in seconds
61356
+ * @param blendTime - Duration of the camera animation in seconds
60933
61357
  */
60934
61358
  restoreLastPosition(blendTime = this._defaultBlendTime) {
60935
61359
  var _a2;
@@ -60942,29 +61366,10 @@ class Camera3 {
60942
61366
  * Handles camera initialization when connection is established
60943
61367
  */
60944
61368
  onConnect() {
60945
- this.startTracking();
60946
61369
  this.restoreLastPosition();
60947
61370
  }
60948
- /**
60949
- * Starts tracking camera position at regular intervals
60950
- */
60951
- startTracking() {
60952
- clearInterval(this._interval);
60953
- this._interval = setInterval(() => this.update(), 1e3);
60954
- }
60955
- /**
60956
- * Stops tracking camera position
60957
- */
60958
- stopTracking() {
60959
- clearInterval(this._interval);
60960
- this._interval = void 0;
60961
- }
60962
- /**
60963
- * Updates the stored camera position
60964
- * @private
60965
- */
60966
- async update() {
60967
- this._lastPosition = await this._rpc.RPCGetCameraPosition();
61371
+ onCameraPose(pose) {
61372
+ this._lastPosition = pose;
60968
61373
  }
60969
61374
  /**
60970
61375
  * Pauses or resumes rendering
@@ -61436,6 +61841,103 @@ class Renderer2 {
61436
61841
  }
61437
61842
  }
61438
61843
  }
61844
+ class SectionBox2 {
61845
+ constructor(rpc) {
61846
+ __publicField(this, "_enabled", false);
61847
+ __publicField(this, "_visible", true);
61848
+ __publicField(this, "_interactible", true);
61849
+ __publicField(this, "_clip", true);
61850
+ __publicField(this, "_box", new Box32());
61851
+ __publicField(this, "_rpc");
61852
+ __publicField(this, "_interval");
61853
+ __publicField(this, "_animationFrame");
61854
+ // Signals
61855
+ __publicField(this, "_onUpdate", new distExports$1.SignalDispatcher());
61856
+ this._rpc = rpc;
61857
+ }
61858
+ get onUpdate() {
61859
+ return this._onUpdate.asEvent();
61860
+ }
61861
+ get needUpdate() {
61862
+ return this._animationFrame > 0;
61863
+ }
61864
+ async onConnect() {
61865
+ this.push();
61866
+ this._interval = setInterval(() => this.pull(), 1e3);
61867
+ }
61868
+ scheduleUpdate() {
61869
+ if (this._animationFrame) return;
61870
+ this._animationFrame = requestAnimationFrame(() => {
61871
+ this._animationFrame = void 0;
61872
+ this.push();
61873
+ });
61874
+ }
61875
+ async pull() {
61876
+ if (this.needUpdate) return;
61877
+ const state = await this._rpc.RPCGetSectionBox();
61878
+ let changed = false;
61879
+ if (state.enabled !== this._enabled || state.visible !== this._visible || state.interactible !== this._interactible || state.clip !== this._clip || state.box !== this._box) {
61880
+ changed = true;
61881
+ }
61882
+ this._enabled = state.enabled;
61883
+ this._visible = state.visible;
61884
+ this._interactible = state.interactible;
61885
+ this._clip = state.clip;
61886
+ this._box = state.box;
61887
+ if (changed) {
61888
+ this._onUpdate.dispatch();
61889
+ }
61890
+ }
61891
+ async push() {
61892
+ await this._rpc.RPCSetSectionBox({
61893
+ enabled: this._enabled,
61894
+ visible: this._visible,
61895
+ interactible: this._interactible,
61896
+ clip: this._clip,
61897
+ box: this._box
61898
+ });
61899
+ }
61900
+ get enabled() {
61901
+ return this._enabled;
61902
+ }
61903
+ set enabled(value) {
61904
+ this._enabled = value;
61905
+ this.scheduleUpdate();
61906
+ }
61907
+ get visible() {
61908
+ return this._visible;
61909
+ }
61910
+ set visible(value) {
61911
+ this._visible = value;
61912
+ this.scheduleUpdate();
61913
+ }
61914
+ get interactible() {
61915
+ return this._interactible;
61916
+ }
61917
+ set interactible(value) {
61918
+ this._interactible = value;
61919
+ this.scheduleUpdate();
61920
+ }
61921
+ get clip() {
61922
+ return this._clip;
61923
+ }
61924
+ set clip(value) {
61925
+ this._clip = value;
61926
+ this.scheduleUpdate();
61927
+ }
61928
+ fitBox(box) {
61929
+ this._box = box;
61930
+ this.scheduleUpdate();
61931
+ }
61932
+ getBox() {
61933
+ return this._box;
61934
+ }
61935
+ dispose() {
61936
+ clearInterval(this._interval);
61937
+ cancelAnimationFrame(this._animationFrame);
61938
+ this._onUpdate.clear();
61939
+ }
61940
+ }
61439
61941
  const INVALID_HANDLE = 4294967295;
61440
61942
  class Viewer2 {
61441
61943
  /**
@@ -61463,6 +61965,10 @@ class Viewer2 {
61463
61965
  * API to create, manage, and destroy colors.
61464
61966
  */
61465
61967
  __publicField(this, "colors");
61968
+ /**
61969
+ * The section box API for controlling the section box.
61970
+ */
61971
+ __publicField(this, "sectionBox");
61466
61972
  this._logger = logger ?? defaultLogger;
61467
61973
  this._socketClient = new SocketClient(this._logger, () => this.validateConnection());
61468
61974
  this.rpc = new RpcSafeClient(new RpcClient(this._socketClient));
@@ -61475,7 +61981,9 @@ class Viewer2 {
61475
61981
  this.colors = new ColorManager(this.rpc);
61476
61982
  this._camera = new Camera3(this.rpc);
61477
61983
  this._input = new Inputs(canvas, this.rpc, this._selection, this._camera, this._renderer);
61984
+ this.sectionBox = new SectionBox2(this.rpc);
61478
61985
  this._socketClient.onVideoFrame = (msg) => this._decoder.enqueue(msg);
61986
+ this._socketClient.onCameraPose = (pose) => this._camera.onCameraPose(pose);
61479
61987
  this._socketClient.onStatusUpdate.subscribe((state) => {
61480
61988
  if (state.status === "disconnected") {
61481
61989
  this.onDisconnect();
@@ -61560,6 +62068,7 @@ class Viewer2 {
61560
62068
  this._input.onConnect();
61561
62069
  this._camera.onConnect();
61562
62070
  this._vims.getAll().forEach((vim) => vim.connect());
62071
+ this.sectionBox.onConnect();
61563
62072
  this._viewport.update();
61564
62073
  this._decoder.start();
61565
62074
  }
@@ -61597,7 +62106,6 @@ class Viewer2 {
61597
62106
  * Cleans up resources and stops tracking.
61598
62107
  */
61599
62108
  onDisconnect() {
61600
- this._camera.stopTracking();
61601
62109
  this._decoder.stop();
61602
62110
  this._decoder.clear();
61603
62111
  this.colors.clear();
@@ -61664,6 +62172,7 @@ class Viewer2 {
61664
62172
  this._viewport.dispose();
61665
62173
  this._decoder.dispose();
61666
62174
  this._input.dispose();
62175
+ this.sectionBox.dispose();
61667
62176
  this._canvas.remove();
61668
62177
  window.onbeforeunload = null;
61669
62178
  }
@@ -75703,7 +76212,7 @@ function updateModal(modal, state) {
75703
76212
  }
75704
76213
  if (state.status === "connecting") {
75705
76214
  if (modal.current === void 0 || modal.current.type === "loading") {
75706
- modal.loading({ message: "Initializing..." });
76215
+ modal.loading({ message: "Connecting to VIM Ultra server..." });
75707
76216
  }
75708
76217
  }
75709
76218
  if (state.status === "error") {