vim-web 0.3.44-dev.42 → 0.3.44-dev.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/core-viewers/webgl/index.d.ts +1 -1
- package/dist/types/core-viewers/webgl/viewer/gizmos/sectionBox/sectionBoxInputs.d.ts +2 -33
- package/dist/types/core-viewers/webgl/viewer/raycaster.d.ts +30 -41
- package/dist/types/core-viewers/webgl/viewer/webglInputsAdapter.d.ts +1 -1
- package/dist/types/react-viewers/helpers/reactUtils.d.ts +233 -9
- package/dist/types/react-viewers/state/cameraState.d.ts +5 -7
- package/dist/types/react-viewers/state/sectionBoxState.d.ts +5 -3
- package/dist/vim-web.iife.js +232 -211
- package/dist/vim-web.iife.js.map +1 -1
- package/dist/vim-web.js +232 -211
- package/dist/vim-web.js.map +1 -1
- package/package.json +1 -1
package/dist/vim-web.js
CHANGED
|
@@ -50664,13 +50664,11 @@ class CameraLerp extends CameraMovement {
|
|
|
50664
50664
|
return this._clock.running;
|
|
50665
50665
|
}
|
|
50666
50666
|
init(duration) {
|
|
50667
|
-
console.log("init lerp");
|
|
50668
50667
|
this.cancel();
|
|
50669
50668
|
this._duration = Math.max(duration, 0.01);
|
|
50670
50669
|
this._clock.start();
|
|
50671
50670
|
}
|
|
50672
50671
|
cancel() {
|
|
50673
|
-
console.log("cancel");
|
|
50674
50672
|
this._clock.stop();
|
|
50675
50673
|
this.onProgress = void 0;
|
|
50676
50674
|
}
|
|
@@ -51654,24 +51652,24 @@ class RaycastResult {
|
|
|
51654
51652
|
__publicField(this, "intersections");
|
|
51655
51653
|
__publicField(this, "firstHit");
|
|
51656
51654
|
this.intersections = intersections;
|
|
51657
|
-
const [markerHit, marker] = this.
|
|
51655
|
+
const [markerHit, marker] = this.getFirstMarkerHit(intersections);
|
|
51658
51656
|
if (marker) {
|
|
51659
51657
|
this.object = marker;
|
|
51660
51658
|
this.firstHit = markerHit;
|
|
51661
51659
|
return;
|
|
51662
51660
|
}
|
|
51663
|
-
const [objectHit, obj] = this.
|
|
51661
|
+
const [objectHit, obj] = this.getFirstVimHit(intersections);
|
|
51664
51662
|
this.firstHit = objectHit;
|
|
51665
51663
|
this.object = obj;
|
|
51666
51664
|
}
|
|
51667
|
-
|
|
51665
|
+
getFirstVimHit(intersections) {
|
|
51668
51666
|
for (let i = 0; i < intersections.length; i++) {
|
|
51669
51667
|
const obj = this.getVimObjectFromHit(intersections[i]);
|
|
51670
51668
|
if (obj == null ? void 0 : obj.visible) return [intersections[i], obj];
|
|
51671
51669
|
}
|
|
51672
51670
|
return [];
|
|
51673
51671
|
}
|
|
51674
|
-
|
|
51672
|
+
getFirstMarkerHit(intersections) {
|
|
51675
51673
|
for (let i = 0; i < intersections.length; i++) {
|
|
51676
51674
|
const data2 = intersections[i].object.userData.vim;
|
|
51677
51675
|
if (data2 instanceof GizmoMarkers) {
|
|
@@ -51688,7 +51686,7 @@ class RaycastResult {
|
|
|
51688
51686
|
const sub = mesh.merged ? mesh.getSubmeshFromFace(hit.faceIndex) : mesh.getSubMesh(hit.instanceId);
|
|
51689
51687
|
return sub.object;
|
|
51690
51688
|
}
|
|
51691
|
-
// Convenience
|
|
51689
|
+
// Convenience getters for hit information
|
|
51692
51690
|
get isHit() {
|
|
51693
51691
|
return !!this.firstHit;
|
|
51694
51692
|
}
|
|
@@ -51710,28 +51708,27 @@ class RaycastResult {
|
|
|
51710
51708
|
}
|
|
51711
51709
|
}
|
|
51712
51710
|
class Raycaster2 {
|
|
51713
|
-
constructor(
|
|
51714
|
-
__publicField(this, "_viewport");
|
|
51711
|
+
constructor(camera2, scene, renderer) {
|
|
51715
51712
|
__publicField(this, "_camera");
|
|
51716
51713
|
__publicField(this, "_scene");
|
|
51717
51714
|
__publicField(this, "_renderer");
|
|
51718
51715
|
__publicField(this, "_raycaster", new Raycaster$1());
|
|
51719
|
-
this._viewport = viewport;
|
|
51720
51716
|
this._camera = camera2;
|
|
51721
51717
|
this._scene = scene;
|
|
51722
51718
|
this._renderer = renderer;
|
|
51723
51719
|
}
|
|
51724
51720
|
/**
|
|
51725
|
-
* Performs a raycast
|
|
51726
|
-
*
|
|
51721
|
+
* Performs a raycast from the camera using normalized screen coordinates.
|
|
51722
|
+
* Coordinates must be within [0, 1] for both x and y.
|
|
51723
|
+
* If the coordinates are out of bounds, an error is logged and an empty result is returned.
|
|
51724
|
+
*
|
|
51725
|
+
* @param {THREE.Vector2} position - The normalized screen position for raycasting.
|
|
51727
51726
|
*/
|
|
51728
|
-
|
|
51729
|
-
if (position.x < 0 || position.y < 0) {
|
|
51727
|
+
raycastFromScreen(position) {
|
|
51728
|
+
if (position.x < 0 || position.y < 0 || position.x > 1 || position.y > 1) {
|
|
51730
51729
|
console.error("Invalid position for raycasting");
|
|
51731
51730
|
return new RaycastResult([]);
|
|
51732
51731
|
}
|
|
51733
|
-
position.x *= position.x < 1 ? this._viewport.getSize().x : 1;
|
|
51734
|
-
position.y *= position.y < 1 ? this._viewport.getSize().y : 1;
|
|
51735
51732
|
this._raycaster = this.fromPoint2(position, this._raycaster);
|
|
51736
51733
|
let hits = this._raycaster.intersectObjects(this._scene.scene.children);
|
|
51737
51734
|
hits = this.filterHits(hits);
|
|
@@ -51741,35 +51738,46 @@ class Raycaster2 {
|
|
|
51741
51738
|
return this._renderer.section.active ? hits.filter((i) => this._renderer.section.box.containsPoint(i.point)) : hits;
|
|
51742
51739
|
}
|
|
51743
51740
|
/**
|
|
51744
|
-
* Performs a raycast
|
|
51745
|
-
*
|
|
51741
|
+
* Performs a raycast from the camera towards a specified world position.
|
|
51742
|
+
*
|
|
51743
|
+
* @param {THREE.Vector3} position - The target world position for raycasting.
|
|
51746
51744
|
*/
|
|
51747
|
-
|
|
51745
|
+
raycastFromWorld(position) {
|
|
51748
51746
|
this._raycaster = this.fromPoint3(position, this._raycaster);
|
|
51749
51747
|
let hits = this._raycaster.intersectObjects(this._scene.scene.children);
|
|
51750
51748
|
hits = this.filterHits(hits);
|
|
51751
51749
|
return new RaycastResult(hits);
|
|
51752
51750
|
}
|
|
51753
51751
|
/**
|
|
51754
|
-
* Performs a raycast
|
|
51752
|
+
* Performs a raycast starting from the camera's current target position.
|
|
51755
51753
|
*/
|
|
51756
51754
|
raycastForward() {
|
|
51757
|
-
return this.
|
|
51755
|
+
return this.raycastFromWorld(this._camera.target);
|
|
51758
51756
|
}
|
|
51759
51757
|
/**
|
|
51760
|
-
*
|
|
51758
|
+
* Creates and returns a THREE.Raycaster that casts a ray from the camera's position
|
|
51759
|
+
* through the provided normalized screen coordinate (x and y in the range [0, 1]).
|
|
51760
|
+
*
|
|
51761
|
+
* @param {THREE.Vector2} position - The normalized screen position for raycasting.
|
|
51762
|
+
* @param {THREE.Raycaster} target - Optional existing raycaster instance to update.
|
|
51763
|
+
* @returns {THREE.Raycaster} A configured raycaster for performing raycasting.
|
|
51761
51764
|
*/
|
|
51762
51765
|
fromPoint2(position, target = new Raycaster$1()) {
|
|
51763
|
-
const
|
|
51764
|
-
|
|
51765
|
-
|
|
51766
|
-
|
|
51766
|
+
const pos = new Vector2(
|
|
51767
|
+
position.x * 2 - 1,
|
|
51768
|
+
-position.y * 2 + 1
|
|
51769
|
+
);
|
|
51770
|
+
target.setFromCamera(pos, this._camera.three);
|
|
51767
51771
|
return target;
|
|
51768
51772
|
}
|
|
51769
51773
|
/**
|
|
51770
|
-
*
|
|
51771
|
-
*
|
|
51772
|
-
*
|
|
51774
|
+
* Creates and returns a THREE.Raycaster that casts a ray from the camera's position
|
|
51775
|
+
* towards the specified world position.
|
|
51776
|
+
* The ray's direction is computed as the normalized vector from the camera position to the target position.
|
|
51777
|
+
*
|
|
51778
|
+
* @param {THREE.Vector3} position - The world position for raycasting.
|
|
51779
|
+
* @param {THREE.Raycaster} target - Optional existing raycaster instance to update.
|
|
51780
|
+
* @returns {THREE.Raycaster} A configured raycaster for performing raycasting.
|
|
51773
51781
|
*/
|
|
51774
51782
|
fromPoint3(position, target = new Raycaster$1()) {
|
|
51775
51783
|
const direction = position.clone().sub(this._camera.position).normalize();
|
|
@@ -51777,37 +51785,6 @@ class Raycaster2 {
|
|
|
51777
51785
|
return target;
|
|
51778
51786
|
}
|
|
51779
51787
|
}
|
|
51780
|
-
class InputAction {
|
|
51781
|
-
constructor(type, modifier, position, raycaster) {
|
|
51782
|
-
__publicField(this, "position");
|
|
51783
|
-
__publicField(this, "modifier");
|
|
51784
|
-
__publicField(this, "type");
|
|
51785
|
-
__publicField(this, "_raycaster");
|
|
51786
|
-
__publicField(this, "_raycast");
|
|
51787
|
-
this.type = type;
|
|
51788
|
-
this.modifier = modifier;
|
|
51789
|
-
this.position = position;
|
|
51790
|
-
this._raycaster = raycaster;
|
|
51791
|
-
}
|
|
51792
|
-
/**
|
|
51793
|
-
* A THREE.Raycaster object for custom raycasting.
|
|
51794
|
-
*/
|
|
51795
|
-
get raycaster() {
|
|
51796
|
-
return this._raycaster.fromPoint2(this.position);
|
|
51797
|
-
}
|
|
51798
|
-
/**
|
|
51799
|
-
* Performs raycasting for VIM objects at the current point. This operation can be computationally expensive.
|
|
51800
|
-
*/
|
|
51801
|
-
get raycast() {
|
|
51802
|
-
return this._raycast ?? (this._raycast = this._raycaster.raycast2(this.position));
|
|
51803
|
-
}
|
|
51804
|
-
/**
|
|
51805
|
-
* Returns the object at the current point. This operation can cause a computationally expensive raycast evaluation.
|
|
51806
|
-
*/
|
|
51807
|
-
get object() {
|
|
51808
|
-
return this.raycast.object;
|
|
51809
|
-
}
|
|
51810
|
-
}
|
|
51811
51788
|
class CSS2DObject extends Object3D$1 {
|
|
51812
51789
|
constructor(element = document.createElement("div")) {
|
|
51813
51790
|
super();
|
|
@@ -52905,7 +52882,7 @@ class GizmoRectangle {
|
|
|
52905
52882
|
*/
|
|
52906
52883
|
getClosestHit() {
|
|
52907
52884
|
if (!this.points) return;
|
|
52908
|
-
const hits = this.points.map((p) => this.viewer.raycaster.
|
|
52885
|
+
const hits = this.points.map((p) => this.viewer.raycaster.raycastFromWorld(p)).filter((h) => h.isHit);
|
|
52909
52886
|
let position;
|
|
52910
52887
|
let dist2;
|
|
52911
52888
|
hits.forEach((h) => {
|
|
@@ -53882,7 +53859,7 @@ class Measure {
|
|
|
53882
53859
|
this._stage = "ready";
|
|
53883
53860
|
this._previousOnClick = this._viewer.inputs.mouse.onClick;
|
|
53884
53861
|
this._viewer.inputs.mouse.onClick = (pos, ctrl) => {
|
|
53885
|
-
const hit = this._viewer.raycaster.
|
|
53862
|
+
const hit = this._viewer.raycaster.raycastFromScreen(pos);
|
|
53886
53863
|
if (!hit.isHit) return;
|
|
53887
53864
|
switch (this._stage) {
|
|
53888
53865
|
case "ready":
|
|
@@ -54007,10 +53984,8 @@ class BoxInputs {
|
|
|
54007
53984
|
__publicField(this, "_raycaster", new Raycaster$1());
|
|
54008
53985
|
/** The box state before the current drag. */
|
|
54009
53986
|
__publicField(this, "_lastBox", new Box3());
|
|
54010
|
-
/** A
|
|
54011
|
-
__publicField(this, "
|
|
54012
|
-
/** The ID of the pointer that is captured, if any. */
|
|
54013
|
-
__publicField(this, "_capturedPointerId");
|
|
53987
|
+
/** A callback to restore the original input listeners after unregistering. */
|
|
53988
|
+
__publicField(this, "_restoreOriginalInputs");
|
|
54014
53989
|
// -------------------------------------------------------------------------
|
|
54015
53990
|
// Callbacks
|
|
54016
53991
|
// -------------------------------------------------------------------------
|
|
@@ -54041,78 +54016,50 @@ class BoxInputs {
|
|
|
54041
54016
|
* If already registered, it does nothing.
|
|
54042
54017
|
*/
|
|
54043
54018
|
register() {
|
|
54044
|
-
if (this.
|
|
54045
|
-
const
|
|
54046
|
-
|
|
54047
|
-
|
|
54048
|
-
|
|
54049
|
-
|
|
54019
|
+
if (this._restoreOriginalInputs) return;
|
|
54020
|
+
const mouse = this._viewer.inputs.mouse;
|
|
54021
|
+
const up = mouse.onButtonUp;
|
|
54022
|
+
const down = mouse.onButtonDown;
|
|
54023
|
+
const move = mouse.onMouseMove;
|
|
54024
|
+
const drag = mouse.onDrag;
|
|
54025
|
+
this._restoreOriginalInputs = () => {
|
|
54026
|
+
mouse.onButtonUp = up;
|
|
54027
|
+
mouse.onButtonDown = down;
|
|
54028
|
+
mouse.onMouseMove = move;
|
|
54029
|
+
mouse.onDrag = drag;
|
|
54030
|
+
};
|
|
54031
|
+
mouse.onButtonUp = (pos, btn) => {
|
|
54032
|
+
up(pos, btn);
|
|
54033
|
+
this.onMouseUp(pos);
|
|
54034
|
+
};
|
|
54035
|
+
mouse.onButtonDown = (pos, btn) => {
|
|
54036
|
+
down(pos, btn);
|
|
54037
|
+
this.onMouseDown(pos);
|
|
54038
|
+
};
|
|
54039
|
+
mouse.onMouseMove = (pos) => {
|
|
54040
|
+
move(pos);
|
|
54041
|
+
this.onMouseMove(pos);
|
|
54042
|
+
};
|
|
54043
|
+
mouse.onDrag = (pos, btn) => {
|
|
54044
|
+
if (this._handle) return;
|
|
54045
|
+
drag(pos, btn);
|
|
54046
|
+
};
|
|
54050
54047
|
}
|
|
54051
54048
|
/**
|
|
54052
54049
|
* Unregisters any previously set pointer event listeners, releasing pointer capture
|
|
54053
54050
|
* and resetting drag state.
|
|
54054
54051
|
*/
|
|
54055
54052
|
unregister() {
|
|
54056
|
-
var _a2;
|
|
54053
|
+
var _a2, _b2;
|
|
54057
54054
|
this._mouseDown = false;
|
|
54058
54055
|
(_a2 = this._handle) == null ? void 0 : _a2.highlight(false);
|
|
54059
54056
|
this._handle = void 0;
|
|
54060
|
-
this.
|
|
54061
|
-
this.
|
|
54062
|
-
this._unregisters.forEach((unreg) => unreg());
|
|
54063
|
-
this._unregisters.length = 0;
|
|
54064
|
-
}
|
|
54065
|
-
/**
|
|
54066
|
-
* Indicates if a pointer is currently captured for dragging.
|
|
54067
|
-
*/
|
|
54068
|
-
get pointerCaptured() {
|
|
54069
|
-
return this._capturedPointerId !== void 0;
|
|
54057
|
+
(_b2 = this._restoreOriginalInputs) == null ? void 0 : _b2.call(this);
|
|
54058
|
+
this._restoreOriginalInputs = void 0;
|
|
54070
54059
|
}
|
|
54071
54060
|
// -------------------------------------------------------------------------
|
|
54072
54061
|
// Private Methods
|
|
54073
54062
|
// -------------------------------------------------------------------------
|
|
54074
|
-
/**
|
|
54075
|
-
* A helper method to attach an event listener and store its unregister callback.
|
|
54076
|
-
*
|
|
54077
|
-
* @param handler - The DOM element or Window to attach the listener to.
|
|
54078
|
-
* @param type - The pointer event type, e.g. 'pointerdown'.
|
|
54079
|
-
* @param listener - The event handler function.
|
|
54080
|
-
*/
|
|
54081
|
-
reg(handler, type, listener2) {
|
|
54082
|
-
handler.addEventListener(type, listener2);
|
|
54083
|
-
this._unregisters.push(() => handler.removeEventListener(type, listener2));
|
|
54084
|
-
}
|
|
54085
|
-
/**
|
|
54086
|
-
* Called when the pointer leaves the canvas. If not dragging,
|
|
54087
|
-
* invokes {@link onFaceEnter} to indicate no active handle is hovered.
|
|
54088
|
-
*
|
|
54089
|
-
* @param event - The pointerleave event.
|
|
54090
|
-
*/
|
|
54091
|
-
onPointerLeave(event) {
|
|
54092
|
-
var _a2, _b2;
|
|
54093
|
-
if (!this.pointerCaptured) {
|
|
54094
|
-
(_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, ((_a2 = this._handle) == null ? void 0 : _a2.forward) ?? new Vector3());
|
|
54095
|
-
}
|
|
54096
|
-
}
|
|
54097
|
-
/**
|
|
54098
|
-
* Sets pointer capture on the canvas for a specific pointer (ID).
|
|
54099
|
-
*
|
|
54100
|
-
* @param pointerId - The pointer ID to capture.
|
|
54101
|
-
*/
|
|
54102
|
-
capturePointer(pointerId) {
|
|
54103
|
-
this.releasePointer();
|
|
54104
|
-
this._viewer.viewport.canvas.setPointerCapture(pointerId);
|
|
54105
|
-
this._capturedPointerId = pointerId;
|
|
54106
|
-
}
|
|
54107
|
-
/**
|
|
54108
|
-
* Releases any captured pointer on the canvas, if present.
|
|
54109
|
-
*/
|
|
54110
|
-
releasePointer() {
|
|
54111
|
-
if (this.pointerCaptured) {
|
|
54112
|
-
this._viewer.viewport.canvas.releasePointerCapture(this._capturedPointerId);
|
|
54113
|
-
this._capturedPointerId = void 0;
|
|
54114
|
-
}
|
|
54115
|
-
}
|
|
54116
54063
|
/**
|
|
54117
54064
|
* Handles pointer movement events.
|
|
54118
54065
|
* - If dragging, calls {@link onDrag}.
|
|
@@ -54120,19 +54067,19 @@ class BoxInputs {
|
|
|
54120
54067
|
*
|
|
54121
54068
|
* @param event - The pointermove event.
|
|
54122
54069
|
*/
|
|
54123
|
-
onMouseMove(
|
|
54124
|
-
var _a2, _b2, _c, _d;
|
|
54070
|
+
onMouseMove(position) {
|
|
54071
|
+
var _a2, _b2, _c, _d, _e;
|
|
54125
54072
|
if (this._mouseDown) {
|
|
54126
|
-
this.onDrag(
|
|
54073
|
+
this.onDrag(position);
|
|
54127
54074
|
return;
|
|
54128
54075
|
}
|
|
54129
|
-
const hits = this.raycast(
|
|
54130
|
-
const handle = (_b2 = (_a2 = hits == null ? void 0 : hits[0]) == null ? void 0 : _a2.object) == null ? void 0 : _b2.userData.handle;
|
|
54076
|
+
const hits = this.raycast(position);
|
|
54077
|
+
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;
|
|
54131
54078
|
if (handle !== this._handle) {
|
|
54132
|
-
(
|
|
54079
|
+
(_d = this._handle) == null ? void 0 : _d.highlight(false);
|
|
54133
54080
|
handle == null ? void 0 : handle.highlight(true);
|
|
54134
54081
|
this._handle = handle;
|
|
54135
|
-
(
|
|
54082
|
+
(_e = this.onFaceEnter) == null ? void 0 : _e.call(this, (handle == null ? void 0 : handle.forward) ?? new Vector3());
|
|
54136
54083
|
}
|
|
54137
54084
|
}
|
|
54138
54085
|
/**
|
|
@@ -54140,39 +54087,29 @@ class BoxInputs {
|
|
|
54140
54087
|
*
|
|
54141
54088
|
* @param event - The pointerup event.
|
|
54142
54089
|
*/
|
|
54143
|
-
onMouseUp(
|
|
54144
|
-
var _a2
|
|
54145
|
-
this.
|
|
54146
|
-
|
|
54147
|
-
|
|
54148
|
-
|
|
54149
|
-
if (event.pointerType === "mouse") {
|
|
54150
|
-
this.onMouseMove(event);
|
|
54151
|
-
} else {
|
|
54152
|
-
this._handle = void 0;
|
|
54153
|
-
(_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, new Vector3());
|
|
54154
|
-
}
|
|
54155
|
-
(_b2 = this.onBoxConfirm) == null ? void 0 : _b2.call(this, this._sharedBox);
|
|
54156
|
-
}
|
|
54090
|
+
onMouseUp(position) {
|
|
54091
|
+
var _a2;
|
|
54092
|
+
if (!this._mouseDown) return;
|
|
54093
|
+
this._mouseDown = false;
|
|
54094
|
+
this.onMouseMove(position);
|
|
54095
|
+
(_a2 = this.onBoxConfirm) == null ? void 0 : _a2.call(this, this._sharedBox);
|
|
54157
54096
|
}
|
|
54158
54097
|
/**
|
|
54159
54098
|
* Handles pointer down events. Begins drag if a handle is hit, capturing the pointer.
|
|
54160
54099
|
*
|
|
54161
54100
|
* @param event - The pointerdown event.
|
|
54162
54101
|
*/
|
|
54163
|
-
onMouseDown(
|
|
54102
|
+
onMouseDown(position) {
|
|
54164
54103
|
var _a2, _b2, _c, _d;
|
|
54165
|
-
const hits = this.raycast(
|
|
54104
|
+
const hits = this.raycast(position);
|
|
54166
54105
|
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;
|
|
54167
54106
|
if (!handle) return;
|
|
54168
54107
|
this._handle = handle;
|
|
54169
|
-
this.capturePointer(event.pointerId);
|
|
54170
54108
|
this._lastBox.copy(this._sharedBox);
|
|
54171
54109
|
this._dragOrigin.copy(handle.position);
|
|
54172
54110
|
const dist2 = handle.position.clone().dot(this._viewer.camera.forward);
|
|
54173
54111
|
this._dragPlane.set(this._viewer.camera.forward, -dist2);
|
|
54174
54112
|
this._mouseDown = true;
|
|
54175
|
-
this._viewer.inputs.unregisterAll();
|
|
54176
54113
|
(_d = this.onFaceEnter) == null ? void 0 : _d.call(this, this._handle.forward.clone());
|
|
54177
54114
|
}
|
|
54178
54115
|
/**
|
|
@@ -54181,10 +54118,10 @@ class BoxInputs {
|
|
|
54181
54118
|
*
|
|
54182
54119
|
* @param event - The pointermove event while dragging.
|
|
54183
54120
|
*/
|
|
54184
|
-
onDrag(
|
|
54121
|
+
onDrag(position) {
|
|
54185
54122
|
var _a2;
|
|
54186
54123
|
if (!this._handle) return;
|
|
54187
|
-
const point = this.raycastPlane(
|
|
54124
|
+
const point = this.raycastPlane(position) ?? this._dragOrigin.clone();
|
|
54188
54125
|
const delta = point.sub(this._dragOrigin);
|
|
54189
54126
|
const amount = delta.dot(this._handle.forward);
|
|
54190
54127
|
const box = this.stretch(this._handle.axis, this._handle.sign, amount);
|
|
@@ -57065,7 +57002,7 @@ function toRotation(delta, speed) {
|
|
|
57065
57002
|
rot.multiplyScalar(180 * speed);
|
|
57066
57003
|
return rot;
|
|
57067
57004
|
}
|
|
57068
|
-
function
|
|
57005
|
+
function webglInputHandler(viewer) {
|
|
57069
57006
|
return new CoreInputHandler(
|
|
57070
57007
|
viewer.viewport.canvas,
|
|
57071
57008
|
createAdapter$1(viewer),
|
|
@@ -57105,7 +57042,7 @@ function createAdapter$1(viewer) {
|
|
|
57105
57042
|
}
|
|
57106
57043
|
},
|
|
57107
57044
|
selectAtPointer: (pos, add) => {
|
|
57108
|
-
const pointer = viewer.raycaster.
|
|
57045
|
+
const pointer = viewer.raycaster.raycastFromScreen(pos);
|
|
57109
57046
|
if (add) {
|
|
57110
57047
|
viewer.selection.add(pointer.object);
|
|
57111
57048
|
} else {
|
|
@@ -57113,7 +57050,7 @@ function createAdapter$1(viewer) {
|
|
|
57113
57050
|
}
|
|
57114
57051
|
},
|
|
57115
57052
|
frameAtPointer: (pos) => {
|
|
57116
|
-
const pointer = viewer.raycaster.
|
|
57053
|
+
const pointer = viewer.raycaster.raycastFromScreen(pos);
|
|
57117
57054
|
viewer.camera.lerp(0.75).frame(pointer.object);
|
|
57118
57055
|
},
|
|
57119
57056
|
zoom: (value) => {
|
|
@@ -57192,13 +57129,12 @@ class Viewer {
|
|
|
57192
57129
|
this._camera,
|
|
57193
57130
|
this.settings
|
|
57194
57131
|
);
|
|
57195
|
-
this.inputs =
|
|
57132
|
+
this.inputs = webglInputHandler(this);
|
|
57196
57133
|
this.gizmos = new Gizmos(this, this._camera);
|
|
57197
57134
|
this.materials.applySettings(this.settings);
|
|
57198
57135
|
this.environment = new Environment(this.camera, this.renderer, this.materials, this.settings);
|
|
57199
57136
|
this.selection = new Selection(this.materials);
|
|
57200
57137
|
this.raycaster = new Raycaster2(
|
|
57201
|
-
this.viewport,
|
|
57202
57138
|
this._camera,
|
|
57203
57139
|
scene,
|
|
57204
57140
|
this.renderer
|
|
@@ -57484,7 +57420,6 @@ const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
57484
57420
|
},
|
|
57485
57421
|
HitTestResult: RaycastResult,
|
|
57486
57422
|
IProgressLogs: distExports$2.IProgressLogs,
|
|
57487
|
-
InputAction,
|
|
57488
57423
|
InsertableMesh,
|
|
57489
57424
|
Object3D: Object3D2,
|
|
57490
57425
|
Scene: Scene2,
|
|
@@ -61015,7 +60950,7 @@ class VimCollection {
|
|
|
61015
60950
|
const defaultRenderSettings = {
|
|
61016
60951
|
...defaultSceneSettings,
|
|
61017
60952
|
lockIblRotation: true,
|
|
61018
|
-
ghostColor: new RGBA(
|
|
60953
|
+
ghostColor: new RGBA(14 / 255, 14 / 255, 14 / 255, 1 / 255)
|
|
61019
60954
|
};
|
|
61020
60955
|
class Renderer2 {
|
|
61021
60956
|
/**
|
|
@@ -61366,16 +61301,13 @@ function createAdapter(viewer) {
|
|
|
61366
61301
|
viewer.rpc.RPCSetMoveSpeed(10);
|
|
61367
61302
|
},
|
|
61368
61303
|
orbitCamera: (value) => {
|
|
61369
|
-
console.log("orbitCamera");
|
|
61370
61304
|
},
|
|
61371
61305
|
rotateCamera: (value) => {
|
|
61372
|
-
console.log("rotateCamera");
|
|
61373
61306
|
},
|
|
61374
61307
|
panCamera: (value) => {
|
|
61375
|
-
console.log("panCamera");
|
|
61376
61308
|
},
|
|
61377
61309
|
toggleOrthographic: () => {
|
|
61378
|
-
console.log("toggleOrthographic");
|
|
61310
|
+
console.log("toggleOrthographic. Not supported yet");
|
|
61379
61311
|
},
|
|
61380
61312
|
resetCamera: () => {
|
|
61381
61313
|
viewer.camera.restoreSavedPosition();
|
|
@@ -61387,9 +61319,7 @@ function createAdapter(viewer) {
|
|
|
61387
61319
|
frameContext(viewer);
|
|
61388
61320
|
},
|
|
61389
61321
|
selectAtPointer: async (pos, add) => {
|
|
61390
|
-
console.log("selectAtPointer", pos, add);
|
|
61391
61322
|
const hit = await viewer.selection.hitTest(pos);
|
|
61392
|
-
console.log("hit", hit);
|
|
61393
61323
|
if (!hit) {
|
|
61394
61324
|
viewer.selection.clear();
|
|
61395
61325
|
return;
|
|
@@ -61412,7 +61342,6 @@ function createAdapter(viewer) {
|
|
|
61412
61342
|
viewer.rpc.RPCMouseScrollEvent(value >= 1 ? 1 : -1);
|
|
61413
61343
|
},
|
|
61414
61344
|
moveCamera: (value) => {
|
|
61415
|
-
console.log("moveCamera");
|
|
61416
61345
|
},
|
|
61417
61346
|
keyDown: (code) => {
|
|
61418
61347
|
const key = CODE_TO_KEYCODE[code];
|
|
@@ -67495,7 +67424,7 @@ function controlBarSectionBox(section, hasSelection) {
|
|
|
67495
67424
|
tip: "Reset Section",
|
|
67496
67425
|
enabled: () => section.enable.get(),
|
|
67497
67426
|
style: (on) => buttonDefaultStyle(on),
|
|
67498
|
-
action: () => section.
|
|
67427
|
+
action: () => section.sectionScene.call(),
|
|
67499
67428
|
icon: sectionBoxReset
|
|
67500
67429
|
},
|
|
67501
67430
|
{
|
|
@@ -75296,26 +75225,50 @@ function useStateRef(initialValue) {
|
|
|
75296
75225
|
event.current.dispatch(finalValue);
|
|
75297
75226
|
};
|
|
75298
75227
|
return {
|
|
75228
|
+
/**
|
|
75229
|
+
* Returns the current state value.
|
|
75230
|
+
*/
|
|
75299
75231
|
get() {
|
|
75300
75232
|
return ref.current;
|
|
75301
75233
|
},
|
|
75302
75234
|
set: set3,
|
|
75235
|
+
/**
|
|
75236
|
+
* Confirms the current state by applying the confirm function and updating the state.
|
|
75237
|
+
*/
|
|
75303
75238
|
confirm() {
|
|
75304
75239
|
set3(confirm.current(ref.current));
|
|
75305
75240
|
},
|
|
75241
|
+
/**
|
|
75242
|
+
* Registers a callback to be invoked when the state changes.
|
|
75243
|
+
* @param on - The callback function that receives the new state value.
|
|
75244
|
+
*/
|
|
75306
75245
|
useOnChange(on) {
|
|
75307
75246
|
useEffect(() => {
|
|
75308
75247
|
return event.current.subscribe(on);
|
|
75309
75248
|
}, []);
|
|
75310
75249
|
},
|
|
75250
|
+
/**
|
|
75251
|
+
* Memoizes a value based on the current state and additional dependencies.
|
|
75252
|
+
* @param on - A function that computes a value based on the current state.
|
|
75253
|
+
* @param deps - Optional additional dependencies.
|
|
75254
|
+
* @returns The memoized value.
|
|
75255
|
+
*/
|
|
75311
75256
|
useMemo(on, deps) {
|
|
75312
75257
|
return useMemo(() => on(value), [...deps || [], value]);
|
|
75313
75258
|
},
|
|
75259
|
+
/**
|
|
75260
|
+
* Sets a validation function to process any new state value before updating.
|
|
75261
|
+
* @param on - A function that validates (and optionally transforms) the new state value.
|
|
75262
|
+
*/
|
|
75314
75263
|
useValidate(on) {
|
|
75315
75264
|
useEffect(() => {
|
|
75316
75265
|
validate.current = on;
|
|
75317
75266
|
}, []);
|
|
75318
75267
|
},
|
|
75268
|
+
/**
|
|
75269
|
+
* Sets a confirmation function to process the state value during confirmation.
|
|
75270
|
+
* @param on - A function that confirms (and optionally transforms) the current state value.
|
|
75271
|
+
*/
|
|
75319
75272
|
useConfirm(on) {
|
|
75320
75273
|
useEffect(() => {
|
|
75321
75274
|
confirm.current = on;
|
|
@@ -75332,8 +75285,22 @@ function useActionRef(action) {
|
|
|
75332
75285
|
get() {
|
|
75333
75286
|
return ref.current;
|
|
75334
75287
|
},
|
|
75335
|
-
set(
|
|
75336
|
-
ref.current =
|
|
75288
|
+
set(fn) {
|
|
75289
|
+
ref.current = fn;
|
|
75290
|
+
},
|
|
75291
|
+
prepend(fn) {
|
|
75292
|
+
const oldFn = ref.current;
|
|
75293
|
+
ref.current = () => {
|
|
75294
|
+
fn();
|
|
75295
|
+
oldFn();
|
|
75296
|
+
};
|
|
75297
|
+
},
|
|
75298
|
+
append(fn) {
|
|
75299
|
+
const oldFn = ref.current;
|
|
75300
|
+
ref.current = () => {
|
|
75301
|
+
oldFn();
|
|
75302
|
+
fn();
|
|
75303
|
+
};
|
|
75337
75304
|
}
|
|
75338
75305
|
};
|
|
75339
75306
|
}
|
|
@@ -75343,30 +75310,83 @@ function useArgActionRef(action) {
|
|
|
75343
75310
|
call(arg) {
|
|
75344
75311
|
ref == null ? void 0 : ref.current(arg);
|
|
75345
75312
|
},
|
|
75346
|
-
|
|
75347
|
-
ref.current
|
|
75313
|
+
get() {
|
|
75314
|
+
return ref.current;
|
|
75315
|
+
},
|
|
75316
|
+
set(fn) {
|
|
75317
|
+
ref.current = fn;
|
|
75318
|
+
},
|
|
75319
|
+
prepend(fn) {
|
|
75320
|
+
const oldFn = ref.current;
|
|
75321
|
+
ref.current = (arg) => {
|
|
75322
|
+
fn(arg);
|
|
75323
|
+
oldFn(arg);
|
|
75324
|
+
};
|
|
75325
|
+
},
|
|
75326
|
+
append(fn) {
|
|
75327
|
+
const oldFn = ref.current;
|
|
75328
|
+
ref.current = (arg) => {
|
|
75329
|
+
oldFn(arg);
|
|
75330
|
+
fn(arg);
|
|
75331
|
+
};
|
|
75348
75332
|
}
|
|
75349
75333
|
};
|
|
75350
75334
|
}
|
|
75351
|
-
function useFuncRef(
|
|
75352
|
-
const ref = useRef(
|
|
75335
|
+
function useFuncRef(fn) {
|
|
75336
|
+
const ref = useRef(fn);
|
|
75353
75337
|
return {
|
|
75354
75338
|
call() {
|
|
75355
75339
|
return ref == null ? void 0 : ref.current();
|
|
75356
75340
|
},
|
|
75357
|
-
|
|
75358
|
-
ref.current
|
|
75341
|
+
get() {
|
|
75342
|
+
return ref.current;
|
|
75343
|
+
},
|
|
75344
|
+
set(fn2) {
|
|
75345
|
+
ref.current = fn2;
|
|
75346
|
+
},
|
|
75347
|
+
prepend(fn2) {
|
|
75348
|
+
const oldFn = ref.current;
|
|
75349
|
+
ref.current = () => {
|
|
75350
|
+
fn2();
|
|
75351
|
+
return oldFn();
|
|
75352
|
+
};
|
|
75353
|
+
},
|
|
75354
|
+
append(fn2) {
|
|
75355
|
+
const oldFn = ref.current;
|
|
75356
|
+
ref.current = () => {
|
|
75357
|
+
const result = oldFn();
|
|
75358
|
+
fn2();
|
|
75359
|
+
return result;
|
|
75360
|
+
};
|
|
75359
75361
|
}
|
|
75360
75362
|
};
|
|
75361
75363
|
}
|
|
75362
|
-
function useAsyncFuncRef(
|
|
75363
|
-
const ref = useRef(
|
|
75364
|
+
function useAsyncFuncRef(fn) {
|
|
75365
|
+
const ref = useRef(fn);
|
|
75364
75366
|
return {
|
|
75365
75367
|
async call() {
|
|
75366
75368
|
return ref == null ? void 0 : ref.current();
|
|
75367
75369
|
},
|
|
75368
|
-
|
|
75369
|
-
ref.current
|
|
75370
|
+
get() {
|
|
75371
|
+
return ref.current;
|
|
75372
|
+
},
|
|
75373
|
+
set(fn2) {
|
|
75374
|
+
ref.current = fn2;
|
|
75375
|
+
},
|
|
75376
|
+
prepend(fn2) {
|
|
75377
|
+
const oldFn = ref.current;
|
|
75378
|
+
ref.current = async () => {
|
|
75379
|
+
await fn2();
|
|
75380
|
+
return await oldFn();
|
|
75381
|
+
};
|
|
75382
|
+
},
|
|
75383
|
+
append(fn2) {
|
|
75384
|
+
const oldFn = ref.current;
|
|
75385
|
+
ref.current = async () => {
|
|
75386
|
+
const result = await oldFn();
|
|
75387
|
+
await fn2();
|
|
75388
|
+
return result;
|
|
75389
|
+
};
|
|
75370
75390
|
}
|
|
75371
75391
|
};
|
|
75372
75392
|
}
|
|
@@ -75379,6 +75399,8 @@ function useSectionBox(adapter) {
|
|
|
75379
75399
|
const sideOffset = useStateRef("1");
|
|
75380
75400
|
const bottomOffset = useStateRef("1");
|
|
75381
75401
|
const boxRef = useRef(adapter.getBox());
|
|
75402
|
+
const getSelectionBox = useAsyncFuncRef(adapter.getSelectionBox);
|
|
75403
|
+
const getSceneBox = useAsyncFuncRef(adapter.getSceneBox);
|
|
75382
75404
|
useEffect(() => {
|
|
75383
75405
|
adapter.setVisible(false);
|
|
75384
75406
|
adapter.setClip(false);
|
|
@@ -75393,7 +75415,7 @@ function useSectionBox(adapter) {
|
|
|
75393
75415
|
if (v && auto.get()) {
|
|
75394
75416
|
sectionSelection.call();
|
|
75395
75417
|
} else {
|
|
75396
|
-
|
|
75418
|
+
sectionScene.call();
|
|
75397
75419
|
}
|
|
75398
75420
|
});
|
|
75399
75421
|
visible2.useValidate((v) => enable.get() && v);
|
|
@@ -75415,15 +75437,11 @@ function useSectionBox(adapter) {
|
|
|
75415
75437
|
adapter.setBox(newBox);
|
|
75416
75438
|
});
|
|
75417
75439
|
const sectionSelection = useFuncRef(async () => {
|
|
75418
|
-
|
|
75419
|
-
|
|
75420
|
-
sectionBox2.call(box);
|
|
75421
|
-
} catch (e) {
|
|
75422
|
-
console.error(e);
|
|
75423
|
-
}
|
|
75440
|
+
const box = await getSelectionBox.call() ?? await getSceneBox.call();
|
|
75441
|
+
sectionBox2.call(box);
|
|
75424
75442
|
});
|
|
75425
|
-
const
|
|
75426
|
-
const box = await
|
|
75443
|
+
const sectionScene = useFuncRef(async () => {
|
|
75444
|
+
const box = await getSceneBox.call();
|
|
75427
75445
|
sectionBox2.call(box);
|
|
75428
75446
|
});
|
|
75429
75447
|
return {
|
|
@@ -75435,9 +75453,12 @@ function useSectionBox(adapter) {
|
|
|
75435
75453
|
sideOffset,
|
|
75436
75454
|
bottomOffset,
|
|
75437
75455
|
sectionSelection,
|
|
75438
|
-
|
|
75456
|
+
sectionScene,
|
|
75439
75457
|
sectionBox: sectionBox2,
|
|
75440
|
-
getBox: () => adapter.getBox()
|
|
75458
|
+
getBox: () => adapter.getBox(),
|
|
75459
|
+
// TODO - Remove these from here, it should be overriden at the component level.
|
|
75460
|
+
getSceneBox,
|
|
75461
|
+
getSelectionBox
|
|
75441
75462
|
};
|
|
75442
75463
|
}
|
|
75443
75464
|
const sanitize = (value, strict) => {
|
|
@@ -75472,12 +75493,12 @@ function useWebglSectionBox(viewer) {
|
|
|
75472
75493
|
getBox: () => viewer.gizmos.sectionBox.getBox(),
|
|
75473
75494
|
setBox: (box) => viewer.gizmos.sectionBox.setBox(box),
|
|
75474
75495
|
getSelectionBox: () => Promise.resolve(viewer.selection.getBoundingBox()),
|
|
75475
|
-
|
|
75496
|
+
getSceneBox: () => Promise.resolve(viewer.renderer.getBoundingBox()),
|
|
75476
75497
|
onSelectionChanged: viewer.selection.onValueChanged
|
|
75477
75498
|
};
|
|
75478
75499
|
return useSectionBox(vimAdapter);
|
|
75479
75500
|
}
|
|
75480
|
-
function useCamera(adapter) {
|
|
75501
|
+
function useCamera(adapter, section) {
|
|
75481
75502
|
const autoCamera2 = useStateRef(false);
|
|
75482
75503
|
autoCamera2.useOnChange((v) => {
|
|
75483
75504
|
if (v) {
|
|
@@ -75485,22 +75506,25 @@ function useCamera(adapter) {
|
|
|
75485
75506
|
}
|
|
75486
75507
|
});
|
|
75487
75508
|
useEffect(() => {
|
|
75488
|
-
|
|
75509
|
+
const refresh = () => {
|
|
75489
75510
|
if (autoCamera2.get()) {
|
|
75490
75511
|
frameSelection2.call();
|
|
75491
75512
|
}
|
|
75492
|
-
}
|
|
75513
|
+
};
|
|
75514
|
+
section.sectionSelection.append(refresh);
|
|
75515
|
+
section.sectionScene.append(refresh);
|
|
75516
|
+
adapter.onSelectionChanged.sub(refresh);
|
|
75493
75517
|
}, []);
|
|
75494
75518
|
const reset = useActionRef(() => adapter.resetCamera(1));
|
|
75495
75519
|
const getSelectionBox = useAsyncFuncRef(adapter.getSelectionBox);
|
|
75496
75520
|
const getSceneBox = useAsyncFuncRef(adapter.getSceneBox);
|
|
75497
75521
|
const frameSelection2 = useAsyncFuncRef(async () => {
|
|
75498
75522
|
const box = await getSelectionBox.call() ?? await getSceneBox.call();
|
|
75499
|
-
frame(adapter, box);
|
|
75523
|
+
frame(adapter, section, box);
|
|
75500
75524
|
});
|
|
75501
75525
|
const frameScene = useAsyncFuncRef(async () => {
|
|
75502
75526
|
const box = await getSceneBox.call();
|
|
75503
|
-
frame(adapter, box);
|
|
75527
|
+
frame(adapter, section, box);
|
|
75504
75528
|
});
|
|
75505
75529
|
return {
|
|
75506
75530
|
getSelectionBox,
|
|
@@ -75511,14 +75535,15 @@ function useCamera(adapter) {
|
|
|
75511
75535
|
frameScene
|
|
75512
75536
|
};
|
|
75513
75537
|
}
|
|
75514
|
-
function frame(adapter, box) {
|
|
75515
|
-
if (
|
|
75516
|
-
|
|
75538
|
+
function frame(adapter, section, box) {
|
|
75539
|
+
if (!box) return;
|
|
75540
|
+
if (section.enable.get()) {
|
|
75541
|
+
const sectionBox2 = section.getBox();
|
|
75517
75542
|
if (section) {
|
|
75518
|
-
box.intersect(
|
|
75543
|
+
box.intersect(sectionBox2);
|
|
75519
75544
|
}
|
|
75520
75545
|
if (box.isEmpty()) {
|
|
75521
|
-
box.copy(
|
|
75546
|
+
box.copy(sectionBox2);
|
|
75522
75547
|
}
|
|
75523
75548
|
}
|
|
75524
75549
|
adapter.frameCamera(box, 1);
|
|
@@ -75529,10 +75554,8 @@ function useWebglCamera(viewer, section) {
|
|
|
75529
75554
|
frameCamera: (box, duration) => viewer.camera.lerp(duration).frame(box),
|
|
75530
75555
|
resetCamera: (duration) => viewer.camera.lerp(duration).reset(),
|
|
75531
75556
|
getSelectionBox: () => Promise.resolve(viewer.selection.getBoundingBox()),
|
|
75532
|
-
|
|
75533
|
-
|
|
75534
|
-
isSectionBoxEnabled: () => section.enable.get()
|
|
75535
|
-
});
|
|
75557
|
+
getSceneBox: () => Promise.resolve(viewer.renderer.getBoundingBox())
|
|
75558
|
+
}, section);
|
|
75536
75559
|
}
|
|
75537
75560
|
function createWebglComponent(container, componentSettings = {}, viewerSettings = {}) {
|
|
75538
75561
|
const promise2 = new DeferredPromise();
|
|
@@ -76026,9 +76049,9 @@ function useUltraSectionBox(viewer) {
|
|
|
76026
76049
|
},
|
|
76027
76050
|
getBox: () => viewer.sectionBox.getBox(),
|
|
76028
76051
|
setBox: (box) => viewer.sectionBox.fitBox(box),
|
|
76052
|
+
onSelectionChanged: viewer.selection.onValueChanged,
|
|
76029
76053
|
getSelectionBox: () => viewer.selection.getBoundingBox(),
|
|
76030
|
-
|
|
76031
|
-
onSelectionChanged: viewer.selection.onValueChanged
|
|
76054
|
+
getSceneBox: () => viewer.renderer.getBoundingBox()
|
|
76032
76055
|
};
|
|
76033
76056
|
return useSectionBox(ultraAdapter);
|
|
76034
76057
|
}
|
|
@@ -76064,10 +76087,8 @@ function useUltraCamera(viewer, section) {
|
|
|
76064
76087
|
frameCamera: (box, duration) => void viewer.camera.frameBox(box, duration),
|
|
76065
76088
|
resetCamera: (duration) => viewer.camera.restoreSavedPosition(duration),
|
|
76066
76089
|
getSelectionBox: () => viewer.selection.getBoundingBox(),
|
|
76067
|
-
getSceneBox: () => viewer.renderer.getBoundingBox()
|
|
76068
|
-
|
|
76069
|
-
isSectionBoxEnabled: () => section.enable.get()
|
|
76070
|
-
});
|
|
76090
|
+
getSceneBox: () => viewer.renderer.getBoundingBox()
|
|
76091
|
+
}, section);
|
|
76071
76092
|
}
|
|
76072
76093
|
function createUltraComponent(container) {
|
|
76073
76094
|
const promise2 = new DeferredPromise();
|