vim-web 0.3.44-dev.44 → 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 +3 -5
- package/dist/types/react-viewers/state/sectionBoxState.d.ts +1 -1
- package/dist/vim-web.iife.js +219 -198
- package/dist/vim-web.iife.js.map +1 -1
- package/dist/vim-web.js +219 -198
- package/dist/vim-web.js.map +1 -1
- package/package.json +1 -1
package/dist/vim-web.iife.js
CHANGED
|
@@ -50680,13 +50680,11 @@ void main() {
|
|
|
50680
50680
|
return this._clock.running;
|
|
50681
50681
|
}
|
|
50682
50682
|
init(duration) {
|
|
50683
|
-
console.log("init lerp");
|
|
50684
50683
|
this.cancel();
|
|
50685
50684
|
this._duration = Math.max(duration, 0.01);
|
|
50686
50685
|
this._clock.start();
|
|
50687
50686
|
}
|
|
50688
50687
|
cancel() {
|
|
50689
|
-
console.log("cancel");
|
|
50690
50688
|
this._clock.stop();
|
|
50691
50689
|
this.onProgress = void 0;
|
|
50692
50690
|
}
|
|
@@ -51670,24 +51668,24 @@ void main() {
|
|
|
51670
51668
|
__publicField(this, "intersections");
|
|
51671
51669
|
__publicField(this, "firstHit");
|
|
51672
51670
|
this.intersections = intersections;
|
|
51673
|
-
const [markerHit, marker] = this.
|
|
51671
|
+
const [markerHit, marker] = this.getFirstMarkerHit(intersections);
|
|
51674
51672
|
if (marker) {
|
|
51675
51673
|
this.object = marker;
|
|
51676
51674
|
this.firstHit = markerHit;
|
|
51677
51675
|
return;
|
|
51678
51676
|
}
|
|
51679
|
-
const [objectHit, obj] = this.
|
|
51677
|
+
const [objectHit, obj] = this.getFirstVimHit(intersections);
|
|
51680
51678
|
this.firstHit = objectHit;
|
|
51681
51679
|
this.object = obj;
|
|
51682
51680
|
}
|
|
51683
|
-
|
|
51681
|
+
getFirstVimHit(intersections) {
|
|
51684
51682
|
for (let i2 = 0; i2 < intersections.length; i2++) {
|
|
51685
51683
|
const obj = this.getVimObjectFromHit(intersections[i2]);
|
|
51686
51684
|
if (obj == null ? void 0 : obj.visible) return [intersections[i2], obj];
|
|
51687
51685
|
}
|
|
51688
51686
|
return [];
|
|
51689
51687
|
}
|
|
51690
|
-
|
|
51688
|
+
getFirstMarkerHit(intersections) {
|
|
51691
51689
|
for (let i2 = 0; i2 < intersections.length; i2++) {
|
|
51692
51690
|
const data2 = intersections[i2].object.userData.vim;
|
|
51693
51691
|
if (data2 instanceof GizmoMarkers) {
|
|
@@ -51704,7 +51702,7 @@ void main() {
|
|
|
51704
51702
|
const sub = mesh.merged ? mesh.getSubmeshFromFace(hit.faceIndex) : mesh.getSubMesh(hit.instanceId);
|
|
51705
51703
|
return sub.object;
|
|
51706
51704
|
}
|
|
51707
|
-
// Convenience
|
|
51705
|
+
// Convenience getters for hit information
|
|
51708
51706
|
get isHit() {
|
|
51709
51707
|
return !!this.firstHit;
|
|
51710
51708
|
}
|
|
@@ -51726,28 +51724,27 @@ void main() {
|
|
|
51726
51724
|
}
|
|
51727
51725
|
}
|
|
51728
51726
|
class Raycaster {
|
|
51729
|
-
constructor(
|
|
51730
|
-
__publicField(this, "_viewport");
|
|
51727
|
+
constructor(camera2, scene, renderer) {
|
|
51731
51728
|
__publicField(this, "_camera");
|
|
51732
51729
|
__publicField(this, "_scene");
|
|
51733
51730
|
__publicField(this, "_renderer");
|
|
51734
51731
|
__publicField(this, "_raycaster", new Raycaster$1());
|
|
51735
|
-
this._viewport = viewport;
|
|
51736
51732
|
this._camera = camera2;
|
|
51737
51733
|
this._scene = scene;
|
|
51738
51734
|
this._renderer = renderer;
|
|
51739
51735
|
}
|
|
51740
51736
|
/**
|
|
51741
|
-
* Performs a raycast
|
|
51742
|
-
*
|
|
51737
|
+
* Performs a raycast from the camera using normalized screen coordinates.
|
|
51738
|
+
* Coordinates must be within [0, 1] for both x and y.
|
|
51739
|
+
* If the coordinates are out of bounds, an error is logged and an empty result is returned.
|
|
51740
|
+
*
|
|
51741
|
+
* @param {THREE.Vector2} position - The normalized screen position for raycasting.
|
|
51743
51742
|
*/
|
|
51744
|
-
|
|
51745
|
-
if (position.x < 0 || position.y < 0) {
|
|
51743
|
+
raycastFromScreen(position) {
|
|
51744
|
+
if (position.x < 0 || position.y < 0 || position.x > 1 || position.y > 1) {
|
|
51746
51745
|
console.error("Invalid position for raycasting");
|
|
51747
51746
|
return new RaycastResult([]);
|
|
51748
51747
|
}
|
|
51749
|
-
position.x *= position.x < 1 ? this._viewport.getSize().x : 1;
|
|
51750
|
-
position.y *= position.y < 1 ? this._viewport.getSize().y : 1;
|
|
51751
51748
|
this._raycaster = this.fromPoint2(position, this._raycaster);
|
|
51752
51749
|
let hits = this._raycaster.intersectObjects(this._scene.scene.children);
|
|
51753
51750
|
hits = this.filterHits(hits);
|
|
@@ -51757,35 +51754,46 @@ void main() {
|
|
|
51757
51754
|
return this._renderer.section.active ? hits.filter((i2) => this._renderer.section.box.containsPoint(i2.point)) : hits;
|
|
51758
51755
|
}
|
|
51759
51756
|
/**
|
|
51760
|
-
* Performs a raycast
|
|
51761
|
-
*
|
|
51757
|
+
* Performs a raycast from the camera towards a specified world position.
|
|
51758
|
+
*
|
|
51759
|
+
* @param {THREE.Vector3} position - The target world position for raycasting.
|
|
51762
51760
|
*/
|
|
51763
|
-
|
|
51761
|
+
raycastFromWorld(position) {
|
|
51764
51762
|
this._raycaster = this.fromPoint3(position, this._raycaster);
|
|
51765
51763
|
let hits = this._raycaster.intersectObjects(this._scene.scene.children);
|
|
51766
51764
|
hits = this.filterHits(hits);
|
|
51767
51765
|
return new RaycastResult(hits);
|
|
51768
51766
|
}
|
|
51769
51767
|
/**
|
|
51770
|
-
* Performs a raycast
|
|
51768
|
+
* Performs a raycast starting from the camera's current target position.
|
|
51771
51769
|
*/
|
|
51772
51770
|
raycastForward() {
|
|
51773
|
-
return this.
|
|
51771
|
+
return this.raycastFromWorld(this._camera.target);
|
|
51774
51772
|
}
|
|
51775
51773
|
/**
|
|
51776
|
-
*
|
|
51774
|
+
* Creates and returns a THREE.Raycaster that casts a ray from the camera's position
|
|
51775
|
+
* through the provided normalized screen coordinate (x and y in the range [0, 1]).
|
|
51776
|
+
*
|
|
51777
|
+
* @param {THREE.Vector2} position - The normalized screen position for raycasting.
|
|
51778
|
+
* @param {THREE.Raycaster} target - Optional existing raycaster instance to update.
|
|
51779
|
+
* @returns {THREE.Raycaster} A configured raycaster for performing raycasting.
|
|
51777
51780
|
*/
|
|
51778
51781
|
fromPoint2(position, target = new Raycaster$1()) {
|
|
51779
|
-
const
|
|
51780
|
-
|
|
51781
|
-
|
|
51782
|
-
|
|
51782
|
+
const pos = new Vector2(
|
|
51783
|
+
position.x * 2 - 1,
|
|
51784
|
+
-position.y * 2 + 1
|
|
51785
|
+
);
|
|
51786
|
+
target.setFromCamera(pos, this._camera.three);
|
|
51783
51787
|
return target;
|
|
51784
51788
|
}
|
|
51785
51789
|
/**
|
|
51786
|
-
*
|
|
51787
|
-
*
|
|
51788
|
-
*
|
|
51790
|
+
* Creates and returns a THREE.Raycaster that casts a ray from the camera's position
|
|
51791
|
+
* towards the specified world position.
|
|
51792
|
+
* The ray's direction is computed as the normalized vector from the camera position to the target position.
|
|
51793
|
+
*
|
|
51794
|
+
* @param {THREE.Vector3} position - The world position for raycasting.
|
|
51795
|
+
* @param {THREE.Raycaster} target - Optional existing raycaster instance to update.
|
|
51796
|
+
* @returns {THREE.Raycaster} A configured raycaster for performing raycasting.
|
|
51789
51797
|
*/
|
|
51790
51798
|
fromPoint3(position, target = new Raycaster$1()) {
|
|
51791
51799
|
const direction = position.clone().sub(this._camera.position).normalize();
|
|
@@ -51793,37 +51801,6 @@ void main() {
|
|
|
51793
51801
|
return target;
|
|
51794
51802
|
}
|
|
51795
51803
|
}
|
|
51796
|
-
class InputAction {
|
|
51797
|
-
constructor(type, modifier, position, raycaster) {
|
|
51798
|
-
__publicField(this, "position");
|
|
51799
|
-
__publicField(this, "modifier");
|
|
51800
|
-
__publicField(this, "type");
|
|
51801
|
-
__publicField(this, "_raycaster");
|
|
51802
|
-
__publicField(this, "_raycast");
|
|
51803
|
-
this.type = type;
|
|
51804
|
-
this.modifier = modifier;
|
|
51805
|
-
this.position = position;
|
|
51806
|
-
this._raycaster = raycaster;
|
|
51807
|
-
}
|
|
51808
|
-
/**
|
|
51809
|
-
* A THREE.Raycaster object for custom raycasting.
|
|
51810
|
-
*/
|
|
51811
|
-
get raycaster() {
|
|
51812
|
-
return this._raycaster.fromPoint2(this.position);
|
|
51813
|
-
}
|
|
51814
|
-
/**
|
|
51815
|
-
* Performs raycasting for VIM objects at the current point. This operation can be computationally expensive.
|
|
51816
|
-
*/
|
|
51817
|
-
get raycast() {
|
|
51818
|
-
return this._raycast ?? (this._raycast = this._raycaster.raycast2(this.position));
|
|
51819
|
-
}
|
|
51820
|
-
/**
|
|
51821
|
-
* Returns the object at the current point. This operation can cause a computationally expensive raycast evaluation.
|
|
51822
|
-
*/
|
|
51823
|
-
get object() {
|
|
51824
|
-
return this.raycast.object;
|
|
51825
|
-
}
|
|
51826
|
-
}
|
|
51827
51804
|
class CSS2DObject extends Object3D$1 {
|
|
51828
51805
|
constructor(element = document.createElement("div")) {
|
|
51829
51806
|
super();
|
|
@@ -52921,7 +52898,7 @@ void main() {
|
|
|
52921
52898
|
*/
|
|
52922
52899
|
getClosestHit() {
|
|
52923
52900
|
if (!this.points) return;
|
|
52924
|
-
const hits = this.points.map((p) => this.viewer.raycaster.
|
|
52901
|
+
const hits = this.points.map((p) => this.viewer.raycaster.raycastFromWorld(p)).filter((h) => h.isHit);
|
|
52925
52902
|
let position;
|
|
52926
52903
|
let dist2;
|
|
52927
52904
|
hits.forEach((h) => {
|
|
@@ -53898,7 +53875,7 @@ void main() {
|
|
|
53898
53875
|
this._stage = "ready";
|
|
53899
53876
|
this._previousOnClick = this._viewer.inputs.mouse.onClick;
|
|
53900
53877
|
this._viewer.inputs.mouse.onClick = (pos, ctrl) => {
|
|
53901
|
-
const hit = this._viewer.raycaster.
|
|
53878
|
+
const hit = this._viewer.raycaster.raycastFromScreen(pos);
|
|
53902
53879
|
if (!hit.isHit) return;
|
|
53903
53880
|
switch (this._stage) {
|
|
53904
53881
|
case "ready":
|
|
@@ -54023,10 +54000,8 @@ void main() {
|
|
|
54023
54000
|
__publicField(this, "_raycaster", new Raycaster$1());
|
|
54024
54001
|
/** The box state before the current drag. */
|
|
54025
54002
|
__publicField(this, "_lastBox", new Box3());
|
|
54026
|
-
/** A
|
|
54027
|
-
__publicField(this, "
|
|
54028
|
-
/** The ID of the pointer that is captured, if any. */
|
|
54029
|
-
__publicField(this, "_capturedPointerId");
|
|
54003
|
+
/** A callback to restore the original input listeners after unregistering. */
|
|
54004
|
+
__publicField(this, "_restoreOriginalInputs");
|
|
54030
54005
|
// -------------------------------------------------------------------------
|
|
54031
54006
|
// Callbacks
|
|
54032
54007
|
// -------------------------------------------------------------------------
|
|
@@ -54057,78 +54032,50 @@ void main() {
|
|
|
54057
54032
|
* If already registered, it does nothing.
|
|
54058
54033
|
*/
|
|
54059
54034
|
register() {
|
|
54060
|
-
if (this.
|
|
54061
|
-
const
|
|
54062
|
-
|
|
54063
|
-
|
|
54064
|
-
|
|
54065
|
-
|
|
54035
|
+
if (this._restoreOriginalInputs) return;
|
|
54036
|
+
const mouse = this._viewer.inputs.mouse;
|
|
54037
|
+
const up = mouse.onButtonUp;
|
|
54038
|
+
const down = mouse.onButtonDown;
|
|
54039
|
+
const move = mouse.onMouseMove;
|
|
54040
|
+
const drag = mouse.onDrag;
|
|
54041
|
+
this._restoreOriginalInputs = () => {
|
|
54042
|
+
mouse.onButtonUp = up;
|
|
54043
|
+
mouse.onButtonDown = down;
|
|
54044
|
+
mouse.onMouseMove = move;
|
|
54045
|
+
mouse.onDrag = drag;
|
|
54046
|
+
};
|
|
54047
|
+
mouse.onButtonUp = (pos, btn) => {
|
|
54048
|
+
up(pos, btn);
|
|
54049
|
+
this.onMouseUp(pos);
|
|
54050
|
+
};
|
|
54051
|
+
mouse.onButtonDown = (pos, btn) => {
|
|
54052
|
+
down(pos, btn);
|
|
54053
|
+
this.onMouseDown(pos);
|
|
54054
|
+
};
|
|
54055
|
+
mouse.onMouseMove = (pos) => {
|
|
54056
|
+
move(pos);
|
|
54057
|
+
this.onMouseMove(pos);
|
|
54058
|
+
};
|
|
54059
|
+
mouse.onDrag = (pos, btn) => {
|
|
54060
|
+
if (this._handle) return;
|
|
54061
|
+
drag(pos, btn);
|
|
54062
|
+
};
|
|
54066
54063
|
}
|
|
54067
54064
|
/**
|
|
54068
54065
|
* Unregisters any previously set pointer event listeners, releasing pointer capture
|
|
54069
54066
|
* and resetting drag state.
|
|
54070
54067
|
*/
|
|
54071
54068
|
unregister() {
|
|
54072
|
-
var _a2;
|
|
54069
|
+
var _a2, _b2;
|
|
54073
54070
|
this._mouseDown = false;
|
|
54074
54071
|
(_a2 = this._handle) == null ? void 0 : _a2.highlight(false);
|
|
54075
54072
|
this._handle = void 0;
|
|
54076
|
-
this.
|
|
54077
|
-
this.
|
|
54078
|
-
this._unregisters.forEach((unreg) => unreg());
|
|
54079
|
-
this._unregisters.length = 0;
|
|
54080
|
-
}
|
|
54081
|
-
/**
|
|
54082
|
-
* Indicates if a pointer is currently captured for dragging.
|
|
54083
|
-
*/
|
|
54084
|
-
get pointerCaptured() {
|
|
54085
|
-
return this._capturedPointerId !== void 0;
|
|
54073
|
+
(_b2 = this._restoreOriginalInputs) == null ? void 0 : _b2.call(this);
|
|
54074
|
+
this._restoreOriginalInputs = void 0;
|
|
54086
54075
|
}
|
|
54087
54076
|
// -------------------------------------------------------------------------
|
|
54088
54077
|
// Private Methods
|
|
54089
54078
|
// -------------------------------------------------------------------------
|
|
54090
|
-
/**
|
|
54091
|
-
* A helper method to attach an event listener and store its unregister callback.
|
|
54092
|
-
*
|
|
54093
|
-
* @param handler - The DOM element or Window to attach the listener to.
|
|
54094
|
-
* @param type - The pointer event type, e.g. 'pointerdown'.
|
|
54095
|
-
* @param listener - The event handler function.
|
|
54096
|
-
*/
|
|
54097
|
-
reg(handler, type, listener2) {
|
|
54098
|
-
handler.addEventListener(type, listener2);
|
|
54099
|
-
this._unregisters.push(() => handler.removeEventListener(type, listener2));
|
|
54100
|
-
}
|
|
54101
|
-
/**
|
|
54102
|
-
* Called when the pointer leaves the canvas. If not dragging,
|
|
54103
|
-
* invokes {@link onFaceEnter} to indicate no active handle is hovered.
|
|
54104
|
-
*
|
|
54105
|
-
* @param event - The pointerleave event.
|
|
54106
|
-
*/
|
|
54107
|
-
onPointerLeave(event) {
|
|
54108
|
-
var _a2, _b2;
|
|
54109
|
-
if (!this.pointerCaptured) {
|
|
54110
|
-
(_b2 = this.onFaceEnter) == null ? void 0 : _b2.call(this, ((_a2 = this._handle) == null ? void 0 : _a2.forward) ?? new Vector3());
|
|
54111
|
-
}
|
|
54112
|
-
}
|
|
54113
|
-
/**
|
|
54114
|
-
* Sets pointer capture on the canvas for a specific pointer (ID).
|
|
54115
|
-
*
|
|
54116
|
-
* @param pointerId - The pointer ID to capture.
|
|
54117
|
-
*/
|
|
54118
|
-
capturePointer(pointerId) {
|
|
54119
|
-
this.releasePointer();
|
|
54120
|
-
this._viewer.viewport.canvas.setPointerCapture(pointerId);
|
|
54121
|
-
this._capturedPointerId = pointerId;
|
|
54122
|
-
}
|
|
54123
|
-
/**
|
|
54124
|
-
* Releases any captured pointer on the canvas, if present.
|
|
54125
|
-
*/
|
|
54126
|
-
releasePointer() {
|
|
54127
|
-
if (this.pointerCaptured) {
|
|
54128
|
-
this._viewer.viewport.canvas.releasePointerCapture(this._capturedPointerId);
|
|
54129
|
-
this._capturedPointerId = void 0;
|
|
54130
|
-
}
|
|
54131
|
-
}
|
|
54132
54079
|
/**
|
|
54133
54080
|
* Handles pointer movement events.
|
|
54134
54081
|
* - If dragging, calls {@link onDrag}.
|
|
@@ -54136,19 +54083,19 @@ void main() {
|
|
|
54136
54083
|
*
|
|
54137
54084
|
* @param event - The pointermove event.
|
|
54138
54085
|
*/
|
|
54139
|
-
onMouseMove(
|
|
54140
|
-
var _a2, _b2, _c, _d;
|
|
54086
|
+
onMouseMove(position) {
|
|
54087
|
+
var _a2, _b2, _c, _d, _e;
|
|
54141
54088
|
if (this._mouseDown) {
|
|
54142
|
-
this.onDrag(
|
|
54089
|
+
this.onDrag(position);
|
|
54143
54090
|
return;
|
|
54144
54091
|
}
|
|
54145
|
-
const hits = this.raycast(
|
|
54146
|
-
const handle = (_b2 = (_a2 = hits == null ? void 0 : hits[0]) == null ? void 0 : _a2.object) == null ? void 0 : _b2.userData.handle;
|
|
54092
|
+
const hits = this.raycast(position);
|
|
54093
|
+
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;
|
|
54147
54094
|
if (handle !== this._handle) {
|
|
54148
|
-
(
|
|
54095
|
+
(_d = this._handle) == null ? void 0 : _d.highlight(false);
|
|
54149
54096
|
handle == null ? void 0 : handle.highlight(true);
|
|
54150
54097
|
this._handle = handle;
|
|
54151
|
-
(
|
|
54098
|
+
(_e = this.onFaceEnter) == null ? void 0 : _e.call(this, (handle == null ? void 0 : handle.forward) ?? new Vector3());
|
|
54152
54099
|
}
|
|
54153
54100
|
}
|
|
54154
54101
|
/**
|
|
@@ -54156,39 +54103,29 @@ void main() {
|
|
|
54156
54103
|
*
|
|
54157
54104
|
* @param event - The pointerup event.
|
|
54158
54105
|
*/
|
|
54159
|
-
onMouseUp(
|
|
54160
|
-
var _a2
|
|
54161
|
-
this.
|
|
54162
|
-
|
|
54163
|
-
|
|
54164
|
-
|
|
54165
|
-
if (event.pointerType === "mouse") {
|
|
54166
|
-
this.onMouseMove(event);
|
|
54167
|
-
} else {
|
|
54168
|
-
this._handle = void 0;
|
|
54169
|
-
(_a2 = this.onFaceEnter) == null ? void 0 : _a2.call(this, new Vector3());
|
|
54170
|
-
}
|
|
54171
|
-
(_b2 = this.onBoxConfirm) == null ? void 0 : _b2.call(this, this._sharedBox);
|
|
54172
|
-
}
|
|
54106
|
+
onMouseUp(position) {
|
|
54107
|
+
var _a2;
|
|
54108
|
+
if (!this._mouseDown) return;
|
|
54109
|
+
this._mouseDown = false;
|
|
54110
|
+
this.onMouseMove(position);
|
|
54111
|
+
(_a2 = this.onBoxConfirm) == null ? void 0 : _a2.call(this, this._sharedBox);
|
|
54173
54112
|
}
|
|
54174
54113
|
/**
|
|
54175
54114
|
* Handles pointer down events. Begins drag if a handle is hit, capturing the pointer.
|
|
54176
54115
|
*
|
|
54177
54116
|
* @param event - The pointerdown event.
|
|
54178
54117
|
*/
|
|
54179
|
-
onMouseDown(
|
|
54118
|
+
onMouseDown(position) {
|
|
54180
54119
|
var _a2, _b2, _c, _d;
|
|
54181
|
-
const hits = this.raycast(
|
|
54120
|
+
const hits = this.raycast(position);
|
|
54182
54121
|
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;
|
|
54183
54122
|
if (!handle) return;
|
|
54184
54123
|
this._handle = handle;
|
|
54185
|
-
this.capturePointer(event.pointerId);
|
|
54186
54124
|
this._lastBox.copy(this._sharedBox);
|
|
54187
54125
|
this._dragOrigin.copy(handle.position);
|
|
54188
54126
|
const dist2 = handle.position.clone().dot(this._viewer.camera.forward);
|
|
54189
54127
|
this._dragPlane.set(this._viewer.camera.forward, -dist2);
|
|
54190
54128
|
this._mouseDown = true;
|
|
54191
|
-
this._viewer.inputs.unregisterAll();
|
|
54192
54129
|
(_d = this.onFaceEnter) == null ? void 0 : _d.call(this, this._handle.forward.clone());
|
|
54193
54130
|
}
|
|
54194
54131
|
/**
|
|
@@ -54197,10 +54134,10 @@ void main() {
|
|
|
54197
54134
|
*
|
|
54198
54135
|
* @param event - The pointermove event while dragging.
|
|
54199
54136
|
*/
|
|
54200
|
-
onDrag(
|
|
54137
|
+
onDrag(position) {
|
|
54201
54138
|
var _a2;
|
|
54202
54139
|
if (!this._handle) return;
|
|
54203
|
-
const point = this.raycastPlane(
|
|
54140
|
+
const point = this.raycastPlane(position) ?? this._dragOrigin.clone();
|
|
54204
54141
|
const delta = point.sub(this._dragOrigin);
|
|
54205
54142
|
const amount = delta.dot(this._handle.forward);
|
|
54206
54143
|
const box = this.stretch(this._handle.axis, this._handle.sign, amount);
|
|
@@ -57081,7 +57018,7 @@ void main() {
|
|
|
57081
57018
|
rot.multiplyScalar(180 * speed);
|
|
57082
57019
|
return rot;
|
|
57083
57020
|
}
|
|
57084
|
-
function
|
|
57021
|
+
function webglInputHandler(viewer) {
|
|
57085
57022
|
return new CoreInputHandler(
|
|
57086
57023
|
viewer.viewport.canvas,
|
|
57087
57024
|
createAdapter$1(viewer),
|
|
@@ -57121,7 +57058,7 @@ void main() {
|
|
|
57121
57058
|
}
|
|
57122
57059
|
},
|
|
57123
57060
|
selectAtPointer: (pos, add) => {
|
|
57124
|
-
const pointer = viewer.raycaster.
|
|
57061
|
+
const pointer = viewer.raycaster.raycastFromScreen(pos);
|
|
57125
57062
|
if (add) {
|
|
57126
57063
|
viewer.selection.add(pointer.object);
|
|
57127
57064
|
} else {
|
|
@@ -57129,7 +57066,7 @@ void main() {
|
|
|
57129
57066
|
}
|
|
57130
57067
|
},
|
|
57131
57068
|
frameAtPointer: (pos) => {
|
|
57132
|
-
const pointer = viewer.raycaster.
|
|
57069
|
+
const pointer = viewer.raycaster.raycastFromScreen(pos);
|
|
57133
57070
|
viewer.camera.lerp(0.75).frame(pointer.object);
|
|
57134
57071
|
},
|
|
57135
57072
|
zoom: (value) => {
|
|
@@ -57208,13 +57145,12 @@ void main() {
|
|
|
57208
57145
|
this._camera,
|
|
57209
57146
|
this.settings
|
|
57210
57147
|
);
|
|
57211
|
-
this.inputs =
|
|
57148
|
+
this.inputs = webglInputHandler(this);
|
|
57212
57149
|
this.gizmos = new Gizmos(this, this._camera);
|
|
57213
57150
|
this.materials.applySettings(this.settings);
|
|
57214
57151
|
this.environment = new Environment(this.camera, this.renderer, this.materials, this.settings);
|
|
57215
57152
|
this.selection = new Selection(this.materials);
|
|
57216
57153
|
this.raycaster = new Raycaster(
|
|
57217
|
-
this.viewport,
|
|
57218
57154
|
this._camera,
|
|
57219
57155
|
scene,
|
|
57220
57156
|
this.renderer
|
|
@@ -57500,7 +57436,6 @@ void main() {
|
|
|
57500
57436
|
},
|
|
57501
57437
|
HitTestResult: RaycastResult,
|
|
57502
57438
|
IProgressLogs: distExports$2.IProgressLogs,
|
|
57503
|
-
InputAction,
|
|
57504
57439
|
InsertableMesh,
|
|
57505
57440
|
Object3D,
|
|
57506
57441
|
Scene,
|
|
@@ -61031,7 +60966,7 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
61031
60966
|
const defaultRenderSettings = {
|
|
61032
60967
|
...defaultSceneSettings,
|
|
61033
60968
|
lockIblRotation: true,
|
|
61034
|
-
ghostColor: new RGBA(
|
|
60969
|
+
ghostColor: new RGBA(14 / 255, 14 / 255, 14 / 255, 1 / 255)
|
|
61035
60970
|
};
|
|
61036
60971
|
class Renderer {
|
|
61037
60972
|
/**
|
|
@@ -61382,16 +61317,13 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
61382
61317
|
viewer.rpc.RPCSetMoveSpeed(10);
|
|
61383
61318
|
},
|
|
61384
61319
|
orbitCamera: (value) => {
|
|
61385
|
-
console.log("orbitCamera");
|
|
61386
61320
|
},
|
|
61387
61321
|
rotateCamera: (value) => {
|
|
61388
|
-
console.log("rotateCamera");
|
|
61389
61322
|
},
|
|
61390
61323
|
panCamera: (value) => {
|
|
61391
|
-
console.log("panCamera");
|
|
61392
61324
|
},
|
|
61393
61325
|
toggleOrthographic: () => {
|
|
61394
|
-
console.log("toggleOrthographic");
|
|
61326
|
+
console.log("toggleOrthographic. Not supported yet");
|
|
61395
61327
|
},
|
|
61396
61328
|
resetCamera: () => {
|
|
61397
61329
|
viewer.camera.restoreSavedPosition();
|
|
@@ -61403,9 +61335,7 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
61403
61335
|
frameContext(viewer);
|
|
61404
61336
|
},
|
|
61405
61337
|
selectAtPointer: async (pos, add) => {
|
|
61406
|
-
console.log("selectAtPointer", pos, add);
|
|
61407
61338
|
const hit = await viewer.selection.hitTest(pos);
|
|
61408
|
-
console.log("hit", hit);
|
|
61409
61339
|
if (!hit) {
|
|
61410
61340
|
viewer.selection.clear();
|
|
61411
61341
|
return;
|
|
@@ -61428,7 +61358,6 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
61428
61358
|
viewer.rpc.RPCMouseScrollEvent(value >= 1 ? 1 : -1);
|
|
61429
61359
|
},
|
|
61430
61360
|
moveCamera: (value) => {
|
|
61431
|
-
console.log("moveCamera");
|
|
61432
61361
|
},
|
|
61433
61362
|
keyDown: (code) => {
|
|
61434
61363
|
const key = CODE_TO_KEYCODE[code];
|
|
@@ -67511,7 +67440,7 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
67511
67440
|
tip: "Reset Section",
|
|
67512
67441
|
enabled: () => section.enable.get(),
|
|
67513
67442
|
style: (on) => buttonDefaultStyle(on),
|
|
67514
|
-
action: () => section.
|
|
67443
|
+
action: () => section.sectionScene.call(),
|
|
67515
67444
|
icon: sectionBoxReset
|
|
67516
67445
|
},
|
|
67517
67446
|
{
|
|
@@ -75312,26 +75241,50 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75312
75241
|
event.current.dispatch(finalValue);
|
|
75313
75242
|
};
|
|
75314
75243
|
return {
|
|
75244
|
+
/**
|
|
75245
|
+
* Returns the current state value.
|
|
75246
|
+
*/
|
|
75315
75247
|
get() {
|
|
75316
75248
|
return ref.current;
|
|
75317
75249
|
},
|
|
75318
75250
|
set: set2,
|
|
75251
|
+
/**
|
|
75252
|
+
* Confirms the current state by applying the confirm function and updating the state.
|
|
75253
|
+
*/
|
|
75319
75254
|
confirm() {
|
|
75320
75255
|
set2(confirm.current(ref.current));
|
|
75321
75256
|
},
|
|
75257
|
+
/**
|
|
75258
|
+
* Registers a callback to be invoked when the state changes.
|
|
75259
|
+
* @param on - The callback function that receives the new state value.
|
|
75260
|
+
*/
|
|
75322
75261
|
useOnChange(on) {
|
|
75323
75262
|
React2.useEffect(() => {
|
|
75324
75263
|
return event.current.subscribe(on);
|
|
75325
75264
|
}, []);
|
|
75326
75265
|
},
|
|
75266
|
+
/**
|
|
75267
|
+
* Memoizes a value based on the current state and additional dependencies.
|
|
75268
|
+
* @param on - A function that computes a value based on the current state.
|
|
75269
|
+
* @param deps - Optional additional dependencies.
|
|
75270
|
+
* @returns The memoized value.
|
|
75271
|
+
*/
|
|
75327
75272
|
useMemo(on, deps) {
|
|
75328
75273
|
return React2.useMemo(() => on(value), [...deps || [], value]);
|
|
75329
75274
|
},
|
|
75275
|
+
/**
|
|
75276
|
+
* Sets a validation function to process any new state value before updating.
|
|
75277
|
+
* @param on - A function that validates (and optionally transforms) the new state value.
|
|
75278
|
+
*/
|
|
75330
75279
|
useValidate(on) {
|
|
75331
75280
|
React2.useEffect(() => {
|
|
75332
75281
|
validate.current = on;
|
|
75333
75282
|
}, []);
|
|
75334
75283
|
},
|
|
75284
|
+
/**
|
|
75285
|
+
* Sets a confirmation function to process the state value during confirmation.
|
|
75286
|
+
* @param on - A function that confirms (and optionally transforms) the current state value.
|
|
75287
|
+
*/
|
|
75335
75288
|
useConfirm(on) {
|
|
75336
75289
|
React2.useEffect(() => {
|
|
75337
75290
|
confirm.current = on;
|
|
@@ -75348,8 +75301,22 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75348
75301
|
get() {
|
|
75349
75302
|
return ref.current;
|
|
75350
75303
|
},
|
|
75351
|
-
set(
|
|
75352
|
-
ref.current =
|
|
75304
|
+
set(fn) {
|
|
75305
|
+
ref.current = fn;
|
|
75306
|
+
},
|
|
75307
|
+
prepend(fn) {
|
|
75308
|
+
const oldFn = ref.current;
|
|
75309
|
+
ref.current = () => {
|
|
75310
|
+
fn();
|
|
75311
|
+
oldFn();
|
|
75312
|
+
};
|
|
75313
|
+
},
|
|
75314
|
+
append(fn) {
|
|
75315
|
+
const oldFn = ref.current;
|
|
75316
|
+
ref.current = () => {
|
|
75317
|
+
oldFn();
|
|
75318
|
+
fn();
|
|
75319
|
+
};
|
|
75353
75320
|
}
|
|
75354
75321
|
};
|
|
75355
75322
|
}
|
|
@@ -75359,30 +75326,83 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75359
75326
|
call(arg) {
|
|
75360
75327
|
ref == null ? void 0 : ref.current(arg);
|
|
75361
75328
|
},
|
|
75362
|
-
|
|
75363
|
-
ref.current
|
|
75329
|
+
get() {
|
|
75330
|
+
return ref.current;
|
|
75331
|
+
},
|
|
75332
|
+
set(fn) {
|
|
75333
|
+
ref.current = fn;
|
|
75334
|
+
},
|
|
75335
|
+
prepend(fn) {
|
|
75336
|
+
const oldFn = ref.current;
|
|
75337
|
+
ref.current = (arg) => {
|
|
75338
|
+
fn(arg);
|
|
75339
|
+
oldFn(arg);
|
|
75340
|
+
};
|
|
75341
|
+
},
|
|
75342
|
+
append(fn) {
|
|
75343
|
+
const oldFn = ref.current;
|
|
75344
|
+
ref.current = (arg) => {
|
|
75345
|
+
oldFn(arg);
|
|
75346
|
+
fn(arg);
|
|
75347
|
+
};
|
|
75364
75348
|
}
|
|
75365
75349
|
};
|
|
75366
75350
|
}
|
|
75367
|
-
function useFuncRef(
|
|
75368
|
-
const ref = React2.useRef(
|
|
75351
|
+
function useFuncRef(fn) {
|
|
75352
|
+
const ref = React2.useRef(fn);
|
|
75369
75353
|
return {
|
|
75370
75354
|
call() {
|
|
75371
75355
|
return ref == null ? void 0 : ref.current();
|
|
75372
75356
|
},
|
|
75373
|
-
|
|
75374
|
-
ref.current
|
|
75357
|
+
get() {
|
|
75358
|
+
return ref.current;
|
|
75359
|
+
},
|
|
75360
|
+
set(fn2) {
|
|
75361
|
+
ref.current = fn2;
|
|
75362
|
+
},
|
|
75363
|
+
prepend(fn2) {
|
|
75364
|
+
const oldFn = ref.current;
|
|
75365
|
+
ref.current = () => {
|
|
75366
|
+
fn2();
|
|
75367
|
+
return oldFn();
|
|
75368
|
+
};
|
|
75369
|
+
},
|
|
75370
|
+
append(fn2) {
|
|
75371
|
+
const oldFn = ref.current;
|
|
75372
|
+
ref.current = () => {
|
|
75373
|
+
const result = oldFn();
|
|
75374
|
+
fn2();
|
|
75375
|
+
return result;
|
|
75376
|
+
};
|
|
75375
75377
|
}
|
|
75376
75378
|
};
|
|
75377
75379
|
}
|
|
75378
|
-
function useAsyncFuncRef(
|
|
75379
|
-
const ref = React2.useRef(
|
|
75380
|
+
function useAsyncFuncRef(fn) {
|
|
75381
|
+
const ref = React2.useRef(fn);
|
|
75380
75382
|
return {
|
|
75381
75383
|
async call() {
|
|
75382
75384
|
return ref == null ? void 0 : ref.current();
|
|
75383
75385
|
},
|
|
75384
|
-
|
|
75385
|
-
ref.current
|
|
75386
|
+
get() {
|
|
75387
|
+
return ref.current;
|
|
75388
|
+
},
|
|
75389
|
+
set(fn2) {
|
|
75390
|
+
ref.current = fn2;
|
|
75391
|
+
},
|
|
75392
|
+
prepend(fn2) {
|
|
75393
|
+
const oldFn = ref.current;
|
|
75394
|
+
ref.current = async () => {
|
|
75395
|
+
await fn2();
|
|
75396
|
+
return await oldFn();
|
|
75397
|
+
};
|
|
75398
|
+
},
|
|
75399
|
+
append(fn2) {
|
|
75400
|
+
const oldFn = ref.current;
|
|
75401
|
+
ref.current = async () => {
|
|
75402
|
+
const result = await oldFn();
|
|
75403
|
+
await fn2();
|
|
75404
|
+
return result;
|
|
75405
|
+
};
|
|
75386
75406
|
}
|
|
75387
75407
|
};
|
|
75388
75408
|
}
|
|
@@ -75449,9 +75469,10 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75449
75469
|
sideOffset,
|
|
75450
75470
|
bottomOffset,
|
|
75451
75471
|
sectionSelection,
|
|
75452
|
-
|
|
75472
|
+
sectionScene,
|
|
75453
75473
|
sectionBox: sectionBox2,
|
|
75454
75474
|
getBox: () => adapter.getBox(),
|
|
75475
|
+
// TODO - Remove these from here, it should be overriden at the component level.
|
|
75455
75476
|
getSceneBox,
|
|
75456
75477
|
getSelectionBox
|
|
75457
75478
|
};
|
|
@@ -75493,7 +75514,7 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75493
75514
|
};
|
|
75494
75515
|
return useSectionBox(vimAdapter);
|
|
75495
75516
|
}
|
|
75496
|
-
function useCamera(adapter) {
|
|
75517
|
+
function useCamera(adapter, section) {
|
|
75497
75518
|
const autoCamera2 = useStateRef(false);
|
|
75498
75519
|
autoCamera2.useOnChange((v) => {
|
|
75499
75520
|
if (v) {
|
|
@@ -75501,22 +75522,25 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75501
75522
|
}
|
|
75502
75523
|
});
|
|
75503
75524
|
React2.useEffect(() => {
|
|
75504
|
-
|
|
75525
|
+
const refresh = () => {
|
|
75505
75526
|
if (autoCamera2.get()) {
|
|
75506
75527
|
frameSelection2.call();
|
|
75507
75528
|
}
|
|
75508
|
-
}
|
|
75529
|
+
};
|
|
75530
|
+
section.sectionSelection.append(refresh);
|
|
75531
|
+
section.sectionScene.append(refresh);
|
|
75532
|
+
adapter.onSelectionChanged.sub(refresh);
|
|
75509
75533
|
}, []);
|
|
75510
75534
|
const reset = useActionRef(() => adapter.resetCamera(1));
|
|
75511
75535
|
const getSelectionBox = useAsyncFuncRef(adapter.getSelectionBox);
|
|
75512
75536
|
const getSceneBox = useAsyncFuncRef(adapter.getSceneBox);
|
|
75513
75537
|
const frameSelection2 = useAsyncFuncRef(async () => {
|
|
75514
75538
|
const box = await getSelectionBox.call() ?? await getSceneBox.call();
|
|
75515
|
-
frame(adapter, box);
|
|
75539
|
+
frame(adapter, section, box);
|
|
75516
75540
|
});
|
|
75517
75541
|
const frameScene = useAsyncFuncRef(async () => {
|
|
75518
75542
|
const box = await getSceneBox.call();
|
|
75519
|
-
frame(adapter, box);
|
|
75543
|
+
frame(adapter, section, box);
|
|
75520
75544
|
});
|
|
75521
75545
|
return {
|
|
75522
75546
|
getSelectionBox,
|
|
@@ -75527,14 +75551,15 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75527
75551
|
frameScene
|
|
75528
75552
|
};
|
|
75529
75553
|
}
|
|
75530
|
-
function frame(adapter, box) {
|
|
75531
|
-
if (
|
|
75532
|
-
|
|
75554
|
+
function frame(adapter, section, box) {
|
|
75555
|
+
if (!box) return;
|
|
75556
|
+
if (section.enable.get()) {
|
|
75557
|
+
const sectionBox2 = section.getBox();
|
|
75533
75558
|
if (section) {
|
|
75534
|
-
box.intersect(
|
|
75559
|
+
box.intersect(sectionBox2);
|
|
75535
75560
|
}
|
|
75536
75561
|
if (box.isEmpty()) {
|
|
75537
|
-
box.copy(
|
|
75562
|
+
box.copy(sectionBox2);
|
|
75538
75563
|
}
|
|
75539
75564
|
}
|
|
75540
75565
|
adapter.frameCamera(box, 1);
|
|
@@ -75545,10 +75570,8 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
75545
75570
|
frameCamera: (box, duration) => viewer.camera.lerp(duration).frame(box),
|
|
75546
75571
|
resetCamera: (duration) => viewer.camera.lerp(duration).reset(),
|
|
75547
75572
|
getSelectionBox: () => Promise.resolve(viewer.selection.getBoundingBox()),
|
|
75548
|
-
|
|
75549
|
-
|
|
75550
|
-
isSectionBoxEnabled: () => section.enable.get()
|
|
75551
|
-
});
|
|
75573
|
+
getSceneBox: () => Promise.resolve(viewer.renderer.getBoundingBox())
|
|
75574
|
+
}, section);
|
|
75552
75575
|
}
|
|
75553
75576
|
function createWebglComponent(container, componentSettings = {}, viewerSettings = {}) {
|
|
75554
75577
|
const promise2 = new DeferredPromise();
|
|
@@ -76080,10 +76103,8 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
76080
76103
|
frameCamera: (box, duration) => void viewer.camera.frameBox(box, duration),
|
|
76081
76104
|
resetCamera: (duration) => viewer.camera.restoreSavedPosition(duration),
|
|
76082
76105
|
getSelectionBox: () => viewer.selection.getBoundingBox(),
|
|
76083
|
-
getSceneBox: () => viewer.renderer.getBoundingBox()
|
|
76084
|
-
|
|
76085
|
-
isSectionBoxEnabled: () => section.enable.get()
|
|
76086
|
-
});
|
|
76106
|
+
getSceneBox: () => viewer.renderer.getBoundingBox()
|
|
76107
|
+
}, section);
|
|
76087
76108
|
}
|
|
76088
76109
|
function createUltraComponent(container) {
|
|
76089
76110
|
const promise2 = new DeferredPromise();
|