@xeokit/xeokit-sdk 2.6.63 → 2.6.64
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/xeokit-sdk.cjs.js +506 -1069
- package/dist/xeokit-sdk.es.js +506 -1069
- package/dist/xeokit-sdk.es5.js +120 -151
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/plugins/SectionPlanesPlugin/Control.js +527 -1118
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -97135,6 +97135,14 @@ class MousePanRotateDollyHandler {
|
|
|
97135
97135
|
keyDown[keyCode] = false;
|
|
97136
97136
|
});
|
|
97137
97137
|
|
|
97138
|
+
document.addEventListener("visibilitychange", this._onVisibilityChange = () => {
|
|
97139
|
+
keyDown.splice(0);
|
|
97140
|
+
});
|
|
97141
|
+
|
|
97142
|
+
window.addEventListener("blur", this._onBlur = () => {
|
|
97143
|
+
keyDown.splice(0);
|
|
97144
|
+
});
|
|
97145
|
+
|
|
97138
97146
|
function setMousedownState(pick = true) {
|
|
97139
97147
|
setMousedownPositions();
|
|
97140
97148
|
if (pick) {
|
|
@@ -97400,6 +97408,8 @@ class MousePanRotateDollyHandler {
|
|
|
97400
97408
|
|
|
97401
97409
|
document.removeEventListener("keydown", this._documentKeyDownHandler);
|
|
97402
97410
|
document.removeEventListener("keyup", this._documentKeyUpHandler);
|
|
97411
|
+
document.removeEventListener("visibilitychange", this._onVisibilityChange);
|
|
97412
|
+
window.removeEventListener("blur", this._onBlur);
|
|
97403
97413
|
canvas.removeEventListener("mousedown", this._mouseDownHandler);
|
|
97404
97414
|
document.removeEventListener("mousemove", this._documentMouseMoveHandler);
|
|
97405
97415
|
canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
|
|
@@ -97955,6 +97965,14 @@ class KeyboardPanRotateDollyHandler {
|
|
|
97955
97965
|
}
|
|
97956
97966
|
});
|
|
97957
97967
|
|
|
97968
|
+
document.addEventListener("visibilitychange", this._onVisibilityChange = () => {
|
|
97969
|
+
keyDownMap.splice(0);
|
|
97970
|
+
});
|
|
97971
|
+
|
|
97972
|
+
window.addEventListener("blur", this._onBlur = () => {
|
|
97973
|
+
keyDownMap.splice(0);
|
|
97974
|
+
});
|
|
97975
|
+
|
|
97958
97976
|
this._onTick = scene.on("tick", (e) => {
|
|
97959
97977
|
|
|
97960
97978
|
if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
|
|
@@ -98084,6 +98102,8 @@ class KeyboardPanRotateDollyHandler {
|
|
|
98084
98102
|
|
|
98085
98103
|
this._scene.input.off(this._onSceneMouseMove);
|
|
98086
98104
|
this._scene.input.off(this._onSceneKeyDown);
|
|
98105
|
+
document.removeEventListener("visibilitychange", this._onVisibilityChange);
|
|
98106
|
+
window.removeEventListener("blur", this._onBlur);
|
|
98087
98107
|
this._scene.input.off(this._onSceneKeyUp);
|
|
98088
98108
|
}
|
|
98089
98109
|
}
|
|
@@ -120732,322 +120752,317 @@ class Control {
|
|
|
120732
120752
|
*/
|
|
120733
120753
|
this.id = null;
|
|
120734
120754
|
|
|
120735
|
-
|
|
120755
|
+
const viewer = plugin.viewer;
|
|
120756
|
+
const camera = viewer.camera;
|
|
120757
|
+
const cameraControl = viewer.cameraControl;
|
|
120758
|
+
const scene = viewer.scene;
|
|
120759
|
+
const canvas = scene.canvas.canvas;
|
|
120736
120760
|
|
|
120737
120761
|
this._visible = false;
|
|
120738
|
-
this._pos = math.vec3(); // Full-precision position of the center of the Control
|
|
120739
|
-
this._origin = math.vec3();
|
|
120740
|
-
this._rtcPos = math.vec3();
|
|
120741
|
-
|
|
120742
|
-
this._baseDir = math.vec3(); // Saves direction of clip plane when we start dragging an arrow or ring.
|
|
120743
|
-
this._rootNode = null; // Root of Node graph that represents this control in the 3D scene
|
|
120744
|
-
this._displayMeshes = null; // Meshes that are always visible
|
|
120745
|
-
this._affordanceMeshes = null; // Meshes displayed momentarily for affordance
|
|
120746
|
-
|
|
120747
|
-
this._ignoreNextSectionPlaneDirUpdate = false;
|
|
120748
|
-
|
|
120749
|
-
this._createNodes();
|
|
120750
|
-
this._bindEvents();
|
|
120751
|
-
}
|
|
120752
120762
|
|
|
120753
|
-
|
|
120754
|
-
* Called by SectionPlanesPlugin to assign this Control to a SectionPlane.
|
|
120755
|
-
* SectionPlanesPlugin keeps SectionPlaneControls in a reuse pool.
|
|
120756
|
-
* Call with a null or undefined value to disconnect the Control ffrom whatever SectionPlane it was assigned to.
|
|
120757
|
-
* @private
|
|
120758
|
-
*/
|
|
120759
|
-
_setSectionPlane(sectionPlane) {
|
|
120760
|
-
if (this._sectionPlane) {
|
|
120761
|
-
this._sectionPlane.off(this._onSectionPlanePos);
|
|
120762
|
-
this._sectionPlane.off(this._onSectionPlaneDir);
|
|
120763
|
-
this._onSectionPlanePos = null;
|
|
120764
|
-
this._onSectionPlaneDir = null;
|
|
120765
|
-
this._sectionPlane = null;
|
|
120766
|
-
}
|
|
120767
|
-
if (sectionPlane) {
|
|
120768
|
-
this.id = sectionPlane.id;
|
|
120769
|
-
this._setPos(sectionPlane.pos);
|
|
120770
|
-
this._setDir(sectionPlane.dir);
|
|
120771
|
-
this._sectionPlane = sectionPlane;
|
|
120772
|
-
this._onSectionPlanePos = sectionPlane.on("pos", () => {
|
|
120773
|
-
this._setPos(this._sectionPlane.pos);
|
|
120774
|
-
});
|
|
120775
|
-
this._onSectionPlaneDir = sectionPlane.on("dir", () => {
|
|
120776
|
-
if (!this._ignoreNextSectionPlaneDirUpdate) {
|
|
120777
|
-
this._setDir(this._sectionPlane.dir);
|
|
120778
|
-
} else {
|
|
120779
|
-
this._ignoreNextSectionPlaneDirUpdate = false;
|
|
120780
|
-
}
|
|
120781
|
-
});
|
|
120782
|
-
}
|
|
120783
|
-
}
|
|
120763
|
+
let ignoreNextSectionPlaneDirUpdate = false;
|
|
120784
120764
|
|
|
120785
|
-
|
|
120786
|
-
|
|
120787
|
-
|
|
120788
|
-
|
|
120789
|
-
|
|
120790
|
-
return this._sectionPlane;
|
|
120791
|
-
}
|
|
120765
|
+
// Builds the Entities that represent this Control.
|
|
120766
|
+
const NO_STATE_INHERIT = false;
|
|
120767
|
+
const arrowLength = 1.0;
|
|
120768
|
+
const handleRadius = 0.09;
|
|
120769
|
+
const tubeRadius = 0.01;
|
|
120792
120770
|
|
|
120793
|
-
|
|
120794
|
-
|
|
120771
|
+
const rootNode = new Node$2(scene, { // Root of Node graph that represents this control in the 3D scene
|
|
120772
|
+
position: [0, 0, 0],
|
|
120773
|
+
scale: [5, 5, 5],
|
|
120774
|
+
isObject: false
|
|
120775
|
+
});
|
|
120795
120776
|
|
|
120796
|
-
|
|
120777
|
+
const pos = math.vec3();
|
|
120778
|
+
const setPos = (function() {
|
|
120779
|
+
const origin = math.vec3();
|
|
120780
|
+
const rtcPos = math.vec3();
|
|
120781
|
+
return function(p) {
|
|
120782
|
+
pos.set(p);
|
|
120783
|
+
worldToRTCPos(p, origin, rtcPos);
|
|
120784
|
+
rootNode.origin = origin;
|
|
120785
|
+
rootNode.position = rtcPos;
|
|
120786
|
+
};
|
|
120787
|
+
})();
|
|
120797
120788
|
|
|
120798
|
-
|
|
120789
|
+
const arrowGeometry = (radiusBottom, height) => new ReadableGeometry(rootNode, buildCylinderGeometry({
|
|
120790
|
+
radiusTop: 0.001,
|
|
120791
|
+
radiusBottom: radiusBottom,
|
|
120792
|
+
radialSegments: 32,
|
|
120793
|
+
heightSegments: 1,
|
|
120794
|
+
height: height,
|
|
120795
|
+
openEnded: false
|
|
120796
|
+
}));
|
|
120799
120797
|
|
|
120800
|
-
|
|
120801
|
-
|
|
120802
|
-
|
|
120798
|
+
const tubeGeometry = (radius, height, radialSegments) => new ReadableGeometry(rootNode, buildCylinderGeometry({
|
|
120799
|
+
radiusTop: radius,
|
|
120800
|
+
radiusBottom: radius,
|
|
120801
|
+
radialSegments: radialSegments,
|
|
120802
|
+
heightSegments: 1,
|
|
120803
|
+
height: height,
|
|
120804
|
+
openEnded: false
|
|
120805
|
+
}));
|
|
120803
120806
|
|
|
120804
|
-
|
|
120805
|
-
|
|
120806
|
-
|
|
120807
|
-
|
|
120808
|
-
|
|
120807
|
+
const torusGeometry = (tube, arcFraction, tubeSegments) => new ReadableGeometry(rootNode, buildTorusGeometry({
|
|
120808
|
+
radius: arrowLength - 0.2,
|
|
120809
|
+
tube: tube,
|
|
120810
|
+
radialSegments: 64,
|
|
120811
|
+
tubeSegments: tubeSegments,
|
|
120812
|
+
arc: (Math.PI * 2.0) * arcFraction
|
|
120813
|
+
}));
|
|
120809
120814
|
|
|
120810
|
-
|
|
120811
|
-
if (this._sectionPlane) {
|
|
120812
|
-
this._ignoreNextSectionPlaneDirUpdate = true;
|
|
120813
|
-
this._sectionPlane.dir = dir;
|
|
120814
|
-
}
|
|
120815
|
-
}
|
|
120815
|
+
const shapes = {// Reusable geometries
|
|
120816
120816
|
|
|
120817
|
-
|
|
120818
|
-
|
|
120819
|
-
|
|
120820
|
-
* @type {Boolean}
|
|
120821
|
-
*/
|
|
120822
|
-
setVisible(visible = true) {
|
|
120823
|
-
if (this._visible === visible) {
|
|
120824
|
-
return;
|
|
120825
|
-
}
|
|
120826
|
-
this._visible = visible;
|
|
120827
|
-
var id;
|
|
120828
|
-
for (id in this._displayMeshes) {
|
|
120829
|
-
if (this._displayMeshes.hasOwnProperty(id)) {
|
|
120830
|
-
this._displayMeshes[id].visible = visible;
|
|
120831
|
-
}
|
|
120832
|
-
}
|
|
120833
|
-
if (!visible) {
|
|
120834
|
-
for (id in this._affordanceMeshes) {
|
|
120835
|
-
if (this._affordanceMeshes.hasOwnProperty(id)) {
|
|
120836
|
-
this._affordanceMeshes[id].visible = visible;
|
|
120837
|
-
}
|
|
120838
|
-
}
|
|
120839
|
-
}
|
|
120840
|
-
}
|
|
120817
|
+
curve: torusGeometry(tubeRadius, 0.25, 14),
|
|
120818
|
+
curveHandle: torusGeometry(handleRadius, 0.25, 14),
|
|
120819
|
+
hoop: torusGeometry(tubeRadius, 1, 8),
|
|
120841
120820
|
|
|
120842
|
-
|
|
120843
|
-
|
|
120844
|
-
|
|
120845
|
-
* @type {Boolean}
|
|
120846
|
-
*/
|
|
120847
|
-
getVisible() {
|
|
120848
|
-
return this._visible;
|
|
120849
|
-
}
|
|
120821
|
+
arrowHead: arrowGeometry(0.07, 0.2),
|
|
120822
|
+
arrowHeadBig: arrowGeometry(0.09, 0.25),
|
|
120823
|
+
arrowHeadHandle: tubeGeometry(handleRadius, 0.37, 8),
|
|
120850
120824
|
|
|
120851
|
-
|
|
120852
|
-
|
|
120853
|
-
|
|
120854
|
-
* @param culled
|
|
120855
|
-
*/
|
|
120856
|
-
setCulled(culled) {
|
|
120857
|
-
var id;
|
|
120858
|
-
for (id in this._displayMeshes) {
|
|
120859
|
-
if (this._displayMeshes.hasOwnProperty(id)) {
|
|
120860
|
-
this._displayMeshes[id].culled = culled;
|
|
120861
|
-
}
|
|
120862
|
-
}
|
|
120863
|
-
if (!culled) {
|
|
120864
|
-
for (id in this._affordanceMeshes) {
|
|
120865
|
-
if (this._affordanceMeshes.hasOwnProperty(id)) {
|
|
120866
|
-
this._affordanceMeshes[id].culled = culled;
|
|
120867
|
-
}
|
|
120868
|
-
}
|
|
120869
|
-
}
|
|
120870
|
-
}
|
|
120825
|
+
axis: tubeGeometry(tubeRadius, arrowLength, 20),
|
|
120826
|
+
axisHandle: tubeGeometry(handleRadius, arrowLength, 20)
|
|
120827
|
+
};
|
|
120871
120828
|
|
|
120872
|
-
|
|
120873
|
-
|
|
120874
|
-
|
|
120875
|
-
|
|
120876
|
-
|
|
120829
|
+
const colorMaterial = (rgb) => new PhongMaterial(rootNode, {
|
|
120830
|
+
diffuse: rgb,
|
|
120831
|
+
emissive: rgb,
|
|
120832
|
+
ambient: [0.0, 0.0, 0.0],
|
|
120833
|
+
specular: [.6, .6, .3],
|
|
120834
|
+
shininess: 80,
|
|
120835
|
+
lineWidth: 2
|
|
120836
|
+
});
|
|
120877
120837
|
|
|
120878
|
-
const
|
|
120879
|
-
|
|
120880
|
-
|
|
120881
|
-
|
|
120882
|
-
|
|
120883
|
-
|
|
120884
|
-
const arrowRadius = 0.07;
|
|
120838
|
+
const highlightMaterial = (rgb, fillAlpha) => new EmphasisMaterial(rootNode, {
|
|
120839
|
+
edges: false,
|
|
120840
|
+
fill: true,
|
|
120841
|
+
fillColor: rgb,
|
|
120842
|
+
fillAlpha: fillAlpha
|
|
120843
|
+
});
|
|
120885
120844
|
|
|
120886
|
-
|
|
120887
|
-
|
|
120888
|
-
|
|
120889
|
-
|
|
120845
|
+
const pickableMaterial = new PhongMaterial(rootNode, { // Invisible material for pickable handles, which define a pickable 3D area
|
|
120846
|
+
diffuse: [1, 1, 0],
|
|
120847
|
+
alpha: 0, // Invisible
|
|
120848
|
+
alphaMode: "blend"
|
|
120890
120849
|
});
|
|
120891
120850
|
|
|
120892
|
-
const
|
|
120851
|
+
const handlers = { };
|
|
120852
|
+
const addAxis = (rgb, axisDirection, hoopDirection) => {
|
|
120853
|
+
const material = colorMaterial(rgb);
|
|
120893
120854
|
|
|
120894
|
-
|
|
120855
|
+
const rotateToHorizontal = math.rotationMat4v(270 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
120856
|
+
const hoopRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], hoopDirection), math.identityMat4());
|
|
120857
|
+
const hoopMatrix = math.mulMat4(hoopRotation, rotateToHorizontal, math.identityMat4());
|
|
120895
120858
|
|
|
120896
|
-
|
|
120897
|
-
radiusTop: 0.001,
|
|
120898
|
-
radiusBottom: arrowRadius,
|
|
120899
|
-
radialSegments: 32,
|
|
120900
|
-
heightSegments: 1,
|
|
120901
|
-
height: 0.2,
|
|
120902
|
-
openEnded: false
|
|
120903
|
-
})),
|
|
120859
|
+
const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
|
|
120904
120860
|
|
|
120905
|
-
|
|
120906
|
-
|
|
120907
|
-
|
|
120908
|
-
|
|
120909
|
-
|
|
120910
|
-
|
|
120911
|
-
|
|
120912
|
-
})),
|
|
120861
|
+
const scaledArrowMatrix = (t, matR) => {
|
|
120862
|
+
const matT = math.translateMat4v(t, math.identityMat4());
|
|
120863
|
+
const ret = math.identityMat4();
|
|
120864
|
+
math.mulMat4(matT, matR, ret);
|
|
120865
|
+
math.mulMat4(hoopMatrix, ret, ret);
|
|
120866
|
+
return math.mulMat4(ret, scale, math.identityMat4());
|
|
120867
|
+
};
|
|
120913
120868
|
|
|
120914
|
-
|
|
120915
|
-
|
|
120916
|
-
|
|
120917
|
-
|
|
120918
|
-
|
|
120919
|
-
|
|
120920
|
-
|
|
120921
|
-
|
|
120869
|
+
const curve = rootNode.addChild(new Mesh(rootNode, {
|
|
120870
|
+
geometry: shapes.curve,
|
|
120871
|
+
material: material,
|
|
120872
|
+
matrix: hoopMatrix,
|
|
120873
|
+
pickable: false,
|
|
120874
|
+
collidable: true,
|
|
120875
|
+
clippable: false,
|
|
120876
|
+
backfaces: true,
|
|
120877
|
+
visible: false,
|
|
120878
|
+
isObject: false
|
|
120879
|
+
}), NO_STATE_INHERIT);
|
|
120922
120880
|
|
|
120923
|
-
|
|
120924
|
-
|
|
120925
|
-
|
|
120926
|
-
|
|
120927
|
-
|
|
120928
|
-
|
|
120929
|
-
|
|
120881
|
+
const rotateHandle = rootNode.addChild(new Mesh(rootNode, {
|
|
120882
|
+
geometry: shapes.curveHandle,
|
|
120883
|
+
material: pickableMaterial,
|
|
120884
|
+
matrix: hoopMatrix,
|
|
120885
|
+
pickable: true,
|
|
120886
|
+
collidable: true,
|
|
120887
|
+
clippable: false,
|
|
120888
|
+
backfaces: true,
|
|
120889
|
+
visible: false,
|
|
120890
|
+
isObject: false
|
|
120891
|
+
}), NO_STATE_INHERIT);
|
|
120930
120892
|
|
|
120931
|
-
|
|
120932
|
-
|
|
120933
|
-
|
|
120934
|
-
|
|
120935
|
-
|
|
120936
|
-
|
|
120937
|
-
|
|
120893
|
+
const arrow1 = rootNode.addChild(new Mesh(rootNode, {
|
|
120894
|
+
geometry: shapes.arrowHead,
|
|
120895
|
+
material: material,
|
|
120896
|
+
matrix: scaledArrowMatrix([ .8, .07, 0 ], math.rotationMat4v(180 * math.DEGTORAD, [0, 0, 1], math.identityMat4())),
|
|
120897
|
+
pickable: true,
|
|
120898
|
+
collidable: true,
|
|
120899
|
+
clippable: false,
|
|
120900
|
+
visible: false,
|
|
120901
|
+
isObject: false
|
|
120902
|
+
}), NO_STATE_INHERIT);
|
|
120938
120903
|
|
|
120939
|
-
|
|
120940
|
-
|
|
120941
|
-
|
|
120942
|
-
|
|
120943
|
-
|
|
120944
|
-
|
|
120945
|
-
|
|
120904
|
+
const arrow2 = rootNode.addChild(new Mesh(rootNode, {
|
|
120905
|
+
geometry: shapes.arrowHead,
|
|
120906
|
+
material: material,
|
|
120907
|
+
matrix: scaledArrowMatrix([ .07, .8, 0 ], math.rotationMat4v(90 * math.DEGTORAD, [0, 0, 1], math.identityMat4())),
|
|
120908
|
+
pickable: true,
|
|
120909
|
+
collidable: true,
|
|
120910
|
+
clippable: false,
|
|
120911
|
+
visible: false,
|
|
120912
|
+
isObject: false
|
|
120913
|
+
}), NO_STATE_INHERIT);
|
|
120946
120914
|
|
|
120947
|
-
|
|
120948
|
-
|
|
120949
|
-
|
|
120950
|
-
|
|
120951
|
-
|
|
120952
|
-
|
|
120953
|
-
|
|
120954
|
-
|
|
120915
|
+
const hoop = rootNode.addChild(new Mesh(rootNode, {
|
|
120916
|
+
geometry: shapes.hoop,
|
|
120917
|
+
material: material,
|
|
120918
|
+
highlighted: true,
|
|
120919
|
+
highlightMaterial: highlightMaterial(rgb, 0.6),
|
|
120920
|
+
matrix: hoopMatrix,
|
|
120921
|
+
pickable: false,
|
|
120922
|
+
collidable: true,
|
|
120923
|
+
clippable: false,
|
|
120924
|
+
visible: false,
|
|
120925
|
+
isObject: false
|
|
120926
|
+
}), NO_STATE_INHERIT);
|
|
120955
120927
|
|
|
120956
|
-
axisHandle: new ReadableGeometry(rootNode, buildCylinderGeometry({
|
|
120957
|
-
radiusTop: 0.08,
|
|
120958
|
-
radiusBottom: 0.08,
|
|
120959
|
-
radialSegments: 20,
|
|
120960
|
-
heightSegments: 1,
|
|
120961
|
-
height: radius,
|
|
120962
|
-
openEnded: false
|
|
120963
|
-
}))
|
|
120964
|
-
};
|
|
120965
120928
|
|
|
120966
|
-
|
|
120929
|
+
const axisRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], axisDirection), math.identityMat4());
|
|
120967
120930
|
|
|
120968
|
-
|
|
120969
|
-
|
|
120970
|
-
|
|
120971
|
-
alphaMode: "blend"
|
|
120972
|
-
}),
|
|
120931
|
+
const translatedAxisMatrix = (yOffset) => math.mulMat4(axisRotation, math.translateMat4c(0, yOffset, 0, math.identityMat4()), math.identityMat4());
|
|
120932
|
+
const arrowMatrix = translatedAxisMatrix(arrowLength + .1);
|
|
120933
|
+
const shaftMatrix = translatedAxisMatrix(arrowLength / 2);
|
|
120973
120934
|
|
|
120974
|
-
|
|
120975
|
-
|
|
120976
|
-
|
|
120977
|
-
|
|
120978
|
-
|
|
120979
|
-
|
|
120980
|
-
|
|
120981
|
-
|
|
120935
|
+
const arrow = rootNode.addChild(new Mesh(rootNode, {
|
|
120936
|
+
geometry: shapes.arrowHead,
|
|
120937
|
+
material: material,
|
|
120938
|
+
matrix: arrowMatrix,
|
|
120939
|
+
pickable: false,
|
|
120940
|
+
collidable: true,
|
|
120941
|
+
clippable: false,
|
|
120942
|
+
visible: false,
|
|
120943
|
+
isObject: false
|
|
120944
|
+
}), NO_STATE_INHERIT);
|
|
120982
120945
|
|
|
120983
|
-
|
|
120984
|
-
|
|
120985
|
-
|
|
120986
|
-
|
|
120987
|
-
|
|
120988
|
-
|
|
120946
|
+
const arrowHandle = rootNode.addChild(new Mesh(rootNode, {
|
|
120947
|
+
geometry: shapes.arrowHeadHandle,
|
|
120948
|
+
material: pickableMaterial,
|
|
120949
|
+
matrix: arrowMatrix,
|
|
120950
|
+
pickable: true,
|
|
120951
|
+
collidable: true,
|
|
120952
|
+
clippable: false,
|
|
120953
|
+
visible: false,
|
|
120954
|
+
isObject: false
|
|
120955
|
+
}), NO_STATE_INHERIT);
|
|
120989
120956
|
|
|
120990
|
-
|
|
120991
|
-
|
|
120992
|
-
|
|
120993
|
-
|
|
120994
|
-
|
|
120995
|
-
|
|
120996
|
-
|
|
120997
|
-
|
|
120957
|
+
const shaft = rootNode.addChild(new Mesh(rootNode, {
|
|
120958
|
+
geometry: shapes.axis,
|
|
120959
|
+
material: material,
|
|
120960
|
+
matrix: shaftMatrix,
|
|
120961
|
+
pickable: false,
|
|
120962
|
+
collidable: true,
|
|
120963
|
+
clippable: false,
|
|
120964
|
+
visible: false,
|
|
120965
|
+
isObject: false
|
|
120966
|
+
}), NO_STATE_INHERIT);
|
|
120998
120967
|
|
|
120999
|
-
|
|
121000
|
-
|
|
121001
|
-
|
|
121002
|
-
|
|
121003
|
-
|
|
121004
|
-
|
|
120968
|
+
const shaftHandle = rootNode.addChild(new Mesh(rootNode, {
|
|
120969
|
+
geometry: shapes.axisHandle,
|
|
120970
|
+
material: pickableMaterial,
|
|
120971
|
+
matrix: shaftMatrix,
|
|
120972
|
+
pickable: true,
|
|
120973
|
+
collidable: true,
|
|
120974
|
+
clippable: false,
|
|
120975
|
+
visible: false,
|
|
120976
|
+
isObject: false
|
|
120977
|
+
}), NO_STATE_INHERIT);
|
|
121005
120978
|
|
|
121006
|
-
|
|
121007
|
-
|
|
121008
|
-
|
|
121009
|
-
|
|
121010
|
-
|
|
121011
|
-
|
|
121012
|
-
|
|
121013
|
-
|
|
120979
|
+
const bigArrowHead = rootNode.addChild(new Mesh(rootNode, {
|
|
120980
|
+
geometry: shapes.arrowHeadBig,
|
|
120981
|
+
material: material,
|
|
120982
|
+
matrix: arrowMatrix,
|
|
120983
|
+
pickable: false,
|
|
120984
|
+
collidable: true,
|
|
120985
|
+
clippable: false,
|
|
120986
|
+
visible: false,
|
|
120987
|
+
isObject: false
|
|
120988
|
+
}), NO_STATE_INHERIT);
|
|
121014
120989
|
|
|
121015
|
-
|
|
121016
|
-
|
|
121017
|
-
|
|
121018
|
-
|
|
121019
|
-
|
|
121020
|
-
|
|
120990
|
+
const closestPointOnAxis = (function() {
|
|
120991
|
+
const worldAxis = math.vec4();
|
|
120992
|
+
const org = math.vec3();
|
|
120993
|
+
const dir = math.vec3();
|
|
120994
|
+
return (canvasPos, dst) => {
|
|
120995
|
+
localToWorldVec(rgb, worldAxis);
|
|
121021
120996
|
|
|
121022
|
-
|
|
121023
|
-
|
|
121024
|
-
emissive: [0, 0, 0],
|
|
121025
|
-
ambient: [0.0, 0.0, 0.0],
|
|
121026
|
-
specular: [.6, .6, .3],
|
|
121027
|
-
shininess: 80
|
|
121028
|
-
}),
|
|
120997
|
+
const P = pos;
|
|
120998
|
+
const D = worldAxis;
|
|
121029
120999
|
|
|
121030
|
-
|
|
121031
|
-
edges: false,
|
|
121032
|
-
fill: true,
|
|
121033
|
-
fillColor: [0.5, 0.5, 0.5],
|
|
121034
|
-
fillAlpha: 0.5,
|
|
121035
|
-
vertices: false
|
|
121036
|
-
}),
|
|
121000
|
+
math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, org, dir);
|
|
121037
121001
|
|
|
121038
|
-
|
|
121039
|
-
|
|
121040
|
-
|
|
121041
|
-
|
|
121042
|
-
|
|
121043
|
-
fillAlpha: 0.5,
|
|
121044
|
-
vertices: false
|
|
121045
|
-
})
|
|
121046
|
-
};
|
|
121002
|
+
const d01 = math.dotVec3(D, dir);
|
|
121003
|
+
const v = math.subVec3(org, P, dst);
|
|
121004
|
+
const v0 = math.dotVec3(v, D);
|
|
121005
|
+
const v1 = math.dotVec3(v, dir);
|
|
121006
|
+
const det = 1 - d01 * d01;
|
|
121047
121007
|
|
|
121048
|
-
|
|
121008
|
+
if (Math.abs(det) > 1e-10) { // if lines are not parallel
|
|
121009
|
+
const s = (v0 - d01 * v1) / det;
|
|
121010
|
+
math.addVec3(P, math.mulVec3Scalar(D, s, dst), dst);
|
|
121011
|
+
return true;
|
|
121012
|
+
} else {
|
|
121013
|
+
return false;
|
|
121014
|
+
}
|
|
121015
|
+
};
|
|
121016
|
+
})();
|
|
121017
|
+
const initOffset = math.vec3();
|
|
121018
|
+
const tempVec3 = math.vec3();
|
|
121019
|
+
handlers[arrowHandle.id] = handlers[shaftHandle.id] = {
|
|
121020
|
+
setActivated: a => bigArrowHead.visible = a,
|
|
121021
|
+
initDragAction: (initCanvasPos) => {
|
|
121022
|
+
return closestPointOnAxis(initCanvasPos, initOffset) && math.subVec3(initOffset, pos, initOffset) && ((canvasPos) => {
|
|
121023
|
+
if (closestPointOnAxis(canvasPos, tempVec3)) {
|
|
121024
|
+
math.subVec3(tempVec3, initOffset, tempVec3);
|
|
121025
|
+
setPos(tempVec3);
|
|
121026
|
+
if (self._sectionPlane) {
|
|
121027
|
+
self._sectionPlane.pos = tempVec3;
|
|
121028
|
+
}
|
|
121029
|
+
}
|
|
121030
|
+
});
|
|
121031
|
+
}
|
|
121032
|
+
};
|
|
121049
121033
|
|
|
121050
|
-
|
|
121034
|
+
const lastCanvasPos = math.vec2();
|
|
121035
|
+
handlers[rotateHandle.id] = {
|
|
121036
|
+
setActivated: a => hoop.visible = a,
|
|
121037
|
+
initDragAction: (initCanvasPos) => {
|
|
121038
|
+
lastCanvasPos.set(initCanvasPos);
|
|
121039
|
+
return canvasPos => {
|
|
121040
|
+
dragRotateSectionPlane(rgb, lastCanvasPos, canvasPos);
|
|
121041
|
+
lastCanvasPos.set(canvasPos);
|
|
121042
|
+
};
|
|
121043
|
+
}
|
|
121044
|
+
};
|
|
121045
|
+
|
|
121046
|
+
return {
|
|
121047
|
+
set visible(v) {
|
|
121048
|
+
arrow.visible = arrowHandle.visible = shaft.visible = shaftHandle.visible = curve.visible = rotateHandle.visible = arrow1.visible = arrow2.visible = v;
|
|
121049
|
+
if (! v) {
|
|
121050
|
+
bigArrowHead.visible = v;
|
|
121051
|
+
hoop.visible = v;
|
|
121052
|
+
}
|
|
121053
|
+
},
|
|
121054
|
+
set culled(c) {
|
|
121055
|
+
arrow.culled = arrowHandle.culled = shaft.culled = shaftHandle.culled = curve.culled = rotateHandle.culled = arrow1.culled = arrow2.culled = c;
|
|
121056
|
+
if (! c) {
|
|
121057
|
+
bigArrowHead.culled = c;
|
|
121058
|
+
hoop.culled = c;
|
|
121059
|
+
}
|
|
121060
|
+
}
|
|
121061
|
+
};
|
|
121062
|
+
};
|
|
121063
|
+
|
|
121064
|
+
this._displayMeshes = [ // Meshes that are always visible
|
|
121065
|
+
rootNode.addChild(new Mesh(rootNode, { // plane
|
|
121051
121066
|
geometry: new ReadableGeometry(rootNode, {
|
|
121052
121067
|
primitive: "triangles",
|
|
121053
121068
|
positions: [
|
|
@@ -121081,7 +121096,7 @@ class Control {
|
|
|
121081
121096
|
isObject: false
|
|
121082
121097
|
}), NO_STATE_INHERIT),
|
|
121083
121098
|
|
|
121084
|
-
|
|
121099
|
+
rootNode.addChild(new Mesh(rootNode, { // Visible frame
|
|
121085
121100
|
geometry: new ReadableGeometry(rootNode, buildTorusGeometry({
|
|
121086
121101
|
center: [0, 0, 0],
|
|
121087
121102
|
radius: 1.7,
|
|
@@ -121113,660 +121128,87 @@ class Control {
|
|
|
121113
121128
|
isObject: false
|
|
121114
121129
|
}), NO_STATE_INHERIT),
|
|
121115
121130
|
|
|
121116
|
-
|
|
121117
|
-
//
|
|
121118
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121119
|
-
|
|
121120
|
-
xCurve: rootNode.addChild(new Mesh(rootNode, { // Red hoop about Y-axis
|
|
121121
|
-
geometry: shapes.curve,
|
|
121122
|
-
material: materials.red,
|
|
121123
|
-
matrix: (function () {
|
|
121124
|
-
const rotate2 = math.rotationMat4v(90 * math.DEGTORAD, [0, 1, 0], math.identityMat4());
|
|
121125
|
-
const rotate1 = math.rotationMat4v(270 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121126
|
-
return math.mulMat4(rotate1, rotate2, math.identityMat4());
|
|
121127
|
-
})(),
|
|
121128
|
-
pickable: false,
|
|
121129
|
-
collidable: true,
|
|
121130
|
-
clippable: false,
|
|
121131
|
-
backfaces: true,
|
|
121132
|
-
visible: false,
|
|
121133
|
-
isObject: false
|
|
121134
|
-
}), NO_STATE_INHERIT),
|
|
121135
|
-
|
|
121136
|
-
xCurveHandle: rootNode.addChild(new Mesh(rootNode, { // Red hoop about Y-axis
|
|
121137
|
-
geometry: shapes.curveHandle,
|
|
121138
|
-
material: materials.pickable,
|
|
121139
|
-
matrix: (function () {
|
|
121140
|
-
const rotate2 = math.rotationMat4v(90 * math.DEGTORAD, [0, 1, 0], math.identityMat4());
|
|
121141
|
-
const rotate1 = math.rotationMat4v(270 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121142
|
-
return math.mulMat4(rotate1, rotate2, math.identityMat4());
|
|
121143
|
-
})(),
|
|
121144
|
-
pickable: true,
|
|
121145
|
-
collidable: true,
|
|
121146
|
-
clippable: false,
|
|
121147
|
-
backfaces: true,
|
|
121148
|
-
visible: false,
|
|
121149
|
-
isObject: false
|
|
121150
|
-
}), NO_STATE_INHERIT),
|
|
121151
|
-
|
|
121152
|
-
xCurveArrow1: rootNode.addChild(new Mesh(rootNode, {
|
|
121153
|
-
geometry: shapes.arrowHead,
|
|
121154
|
-
material: materials.red,
|
|
121155
|
-
matrix: (function () {
|
|
121156
|
-
const translate = math.translateMat4c(0., -0.07, -0.8, math.identityMat4());
|
|
121157
|
-
const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
|
|
121158
|
-
const rotate = math.rotationMat4v(0 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121159
|
-
return math.mulMat4(math.mulMat4(translate, scale, math.identityMat4()), rotate, math.identityMat4());
|
|
121160
|
-
})(),
|
|
121161
|
-
pickable: true,
|
|
121162
|
-
collidable: true,
|
|
121163
|
-
clippable: false,
|
|
121164
|
-
visible: false,
|
|
121165
|
-
isObject: false
|
|
121166
|
-
}), NO_STATE_INHERIT),
|
|
121167
|
-
|
|
121168
|
-
xCurveArrow2: rootNode.addChild(new Mesh(rootNode, {
|
|
121169
|
-
geometry: shapes.arrowHead,
|
|
121170
|
-
material: materials.red,
|
|
121171
|
-
matrix: (function () {
|
|
121172
|
-
const translate = math.translateMat4c(0.0, -0.8, -0.07, math.identityMat4());
|
|
121173
|
-
const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
|
|
121174
|
-
const rotate = math.rotationMat4v(90 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121175
|
-
return math.mulMat4(math.mulMat4(translate, scale, math.identityMat4()), rotate, math.identityMat4());
|
|
121176
|
-
})(),
|
|
121177
|
-
pickable: true,
|
|
121178
|
-
collidable: true,
|
|
121179
|
-
clippable: false,
|
|
121180
|
-
visible: false,
|
|
121181
|
-
isObject: false
|
|
121182
|
-
}), NO_STATE_INHERIT),
|
|
121183
|
-
|
|
121184
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121185
|
-
//
|
|
121186
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121187
|
-
|
|
121188
|
-
yCurve: rootNode.addChild(new Mesh(rootNode, {
|
|
121189
|
-
geometry: shapes.curve,
|
|
121190
|
-
material: materials.green,
|
|
121191
|
-
rotation: [-90, 0, 0],
|
|
121192
|
-
pickable: false,
|
|
121193
|
-
collidable: true,
|
|
121194
|
-
clippable: false,
|
|
121195
|
-
backfaces: true,
|
|
121196
|
-
visible: false,
|
|
121197
|
-
isObject: false
|
|
121198
|
-
}), NO_STATE_INHERIT),
|
|
121199
|
-
|
|
121200
|
-
yCurveHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121201
|
-
geometry: shapes.curveHandle,
|
|
121202
|
-
material: materials.pickable,
|
|
121203
|
-
rotation: [-90, 0, 0],
|
|
121204
|
-
pickable: true,
|
|
121205
|
-
collidable: true,
|
|
121206
|
-
clippable: false,
|
|
121207
|
-
backfaces: true,
|
|
121208
|
-
visible: false,
|
|
121209
|
-
isObject: false
|
|
121210
|
-
}), NO_STATE_INHERIT),
|
|
121211
|
-
|
|
121212
|
-
yCurveArrow1: rootNode.addChild(new Mesh(rootNode, {
|
|
121213
|
-
geometry: shapes.arrowHead,
|
|
121214
|
-
material: materials.green,
|
|
121215
|
-
matrix: (function () {
|
|
121216
|
-
const translate = math.translateMat4c(0.07, 0, -0.8, math.identityMat4());
|
|
121217
|
-
const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
|
|
121218
|
-
const rotate = math.rotationMat4v(90 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121219
|
-
return math.mulMat4(math.mulMat4(translate, scale, math.identityMat4()), rotate, math.identityMat4());
|
|
121220
|
-
})(),
|
|
121221
|
-
pickable: true,
|
|
121222
|
-
collidable: true,
|
|
121223
|
-
clippable: false,
|
|
121224
|
-
visible: false,
|
|
121225
|
-
isObject: false
|
|
121226
|
-
}), NO_STATE_INHERIT),
|
|
121227
|
-
|
|
121228
|
-
yCurveArrow2: rootNode.addChild(new Mesh(rootNode, {
|
|
121229
|
-
geometry: shapes.arrowHead,
|
|
121230
|
-
material: materials.green,
|
|
121231
|
-
matrix: (function () {
|
|
121232
|
-
const translate = math.translateMat4c(0.8, 0.0, -0.07, math.identityMat4());
|
|
121233
|
-
const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
|
|
121234
|
-
const rotate = math.rotationMat4v(90 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121235
|
-
return math.mulMat4(math.mulMat4(translate, scale, math.identityMat4()), rotate, math.identityMat4());
|
|
121236
|
-
})(),
|
|
121237
|
-
pickable: true,
|
|
121238
|
-
collidable: true,
|
|
121239
|
-
clippable: false,
|
|
121240
|
-
visible: false,
|
|
121241
|
-
isObject: false
|
|
121242
|
-
}), NO_STATE_INHERIT),
|
|
121243
|
-
|
|
121244
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121245
|
-
//
|
|
121246
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121247
|
-
|
|
121248
|
-
zCurve: rootNode.addChild(new Mesh(rootNode, { // Blue hoop about Z-axis
|
|
121249
|
-
geometry: shapes.curve,
|
|
121250
|
-
material: materials.blue,
|
|
121251
|
-
matrix: math.rotationMat4v(180 * math.DEGTORAD, [1, 0, 0], math.identityMat4()),
|
|
121252
|
-
pickable: false,
|
|
121253
|
-
collidable: true,
|
|
121254
|
-
clippable: false,
|
|
121255
|
-
visible: false,
|
|
121256
|
-
isObject: false
|
|
121257
|
-
}), NO_STATE_INHERIT),
|
|
121258
|
-
|
|
121259
|
-
zCurveHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121260
|
-
geometry: shapes.curveHandle,
|
|
121261
|
-
material: materials.pickable,
|
|
121262
|
-
matrix: math.rotationMat4v(180 * math.DEGTORAD, [1, 0, 0], math.identityMat4()),
|
|
121263
|
-
pickable: true,
|
|
121264
|
-
collidable: true,
|
|
121265
|
-
clippable: false,
|
|
121266
|
-
visible: false,
|
|
121267
|
-
isObject: false
|
|
121268
|
-
}), NO_STATE_INHERIT),
|
|
121269
|
-
|
|
121270
|
-
zCurveCurveArrow1: rootNode.addChild(new Mesh(rootNode, {
|
|
121271
|
-
geometry: shapes.arrowHead,
|
|
121272
|
-
material: materials.blue,
|
|
121273
|
-
matrix: (function () {
|
|
121274
|
-
const translate = math.translateMat4c(.8, -0.07, 0, math.identityMat4());
|
|
121275
|
-
const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
|
|
121276
|
-
return math.mulMat4(translate, scale, math.identityMat4());
|
|
121277
|
-
})(),
|
|
121278
|
-
pickable: true,
|
|
121279
|
-
collidable: true,
|
|
121280
|
-
clippable: false,
|
|
121281
|
-
visible: false,
|
|
121282
|
-
isObject: false
|
|
121283
|
-
}), NO_STATE_INHERIT),
|
|
121284
|
-
|
|
121285
|
-
zCurveArrow2: rootNode.addChild(new Mesh(rootNode, {
|
|
121286
|
-
geometry: shapes.arrowHead,
|
|
121287
|
-
material: materials.blue,
|
|
121288
|
-
matrix: (function () {
|
|
121289
|
-
const translate = math.translateMat4c(.05, -0.8, 0, math.identityMat4());
|
|
121290
|
-
const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
|
|
121291
|
-
const rotate = math.rotationMat4v(90 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121292
|
-
return math.mulMat4(math.mulMat4(translate, scale, math.identityMat4()), rotate, math.identityMat4());
|
|
121293
|
-
})(),
|
|
121294
|
-
pickable: true,
|
|
121295
|
-
collidable: true,
|
|
121296
|
-
clippable: false,
|
|
121297
|
-
visible: false,
|
|
121298
|
-
isObject: false
|
|
121299
|
-
}), NO_STATE_INHERIT),
|
|
121300
|
-
|
|
121301
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121302
|
-
//
|
|
121303
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121304
|
-
|
|
121305
|
-
center: rootNode.addChild(new Mesh(rootNode, {
|
|
121131
|
+
rootNode.addChild(new Mesh(rootNode, { // center
|
|
121306
121132
|
geometry: new ReadableGeometry(rootNode, buildSphereGeometry({
|
|
121307
121133
|
radius: 0.05
|
|
121308
121134
|
})),
|
|
121309
|
-
material: materials.center,
|
|
121310
|
-
pickable: false,
|
|
121311
|
-
collidable: true,
|
|
121312
|
-
clippable: false,
|
|
121313
|
-
visible: false,
|
|
121314
|
-
isObject: false
|
|
121315
|
-
}), NO_STATE_INHERIT),
|
|
121316
|
-
|
|
121317
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121318
|
-
//
|
|
121319
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121320
|
-
|
|
121321
|
-
xAxisArrow: rootNode.addChild(new Mesh(rootNode, {
|
|
121322
|
-
geometry: shapes.arrowHead,
|
|
121323
|
-
material: materials.red,
|
|
121324
|
-
matrix: (function () {
|
|
121325
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121326
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121327
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121328
|
-
})(),
|
|
121329
|
-
pickable: false,
|
|
121330
|
-
collidable: true,
|
|
121331
|
-
clippable: false,
|
|
121332
|
-
visible: false,
|
|
121333
|
-
isObject: false
|
|
121334
|
-
}), NO_STATE_INHERIT),
|
|
121335
|
-
|
|
121336
|
-
xAxisArrowHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121337
|
-
geometry: shapes.arrowHeadHandle,
|
|
121338
|
-
material: materials.pickable,
|
|
121339
|
-
matrix: (function () {
|
|
121340
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121341
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121342
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121343
|
-
})(),
|
|
121344
|
-
pickable: true,
|
|
121345
|
-
collidable: true,
|
|
121346
|
-
clippable: false,
|
|
121347
|
-
visible: false,
|
|
121348
|
-
isObject: false
|
|
121349
|
-
}), NO_STATE_INHERIT),
|
|
121350
|
-
|
|
121351
|
-
xAxis: rootNode.addChild(new Mesh(rootNode, {
|
|
121352
|
-
geometry: shapes.axis,
|
|
121353
|
-
material: materials.red,
|
|
121354
|
-
matrix: (function () {
|
|
121355
|
-
const translate = math.translateMat4c(0, radius / 2, 0, math.identityMat4());
|
|
121356
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121357
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121358
|
-
})(),
|
|
121359
|
-
pickable: false,
|
|
121360
|
-
collidable: true,
|
|
121361
|
-
clippable: false,
|
|
121362
|
-
visible: false,
|
|
121363
|
-
isObject: false
|
|
121364
|
-
}), NO_STATE_INHERIT),
|
|
121365
|
-
|
|
121366
|
-
xAxisHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121367
|
-
geometry: shapes.axisHandle,
|
|
121368
|
-
material: materials.pickable,
|
|
121369
|
-
matrix: (function () {
|
|
121370
|
-
const translate = math.translateMat4c(0, radius / 2, 0, math.identityMat4());
|
|
121371
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121372
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121373
|
-
})(),
|
|
121374
|
-
pickable: true,
|
|
121375
|
-
collidable: true,
|
|
121376
|
-
clippable: false,
|
|
121377
|
-
visible: false,
|
|
121378
|
-
isObject: false
|
|
121379
|
-
}), NO_STATE_INHERIT),
|
|
121380
|
-
|
|
121381
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121382
|
-
//
|
|
121383
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121384
|
-
|
|
121385
|
-
yAxisArrow: rootNode.addChild(new Mesh(rootNode, {
|
|
121386
|
-
geometry: shapes.arrowHead,
|
|
121387
|
-
material: materials.green,
|
|
121388
|
-
matrix: (function () {
|
|
121389
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121390
|
-
const rotate = math.rotationMat4v(180 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121391
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121392
|
-
})(),
|
|
121393
|
-
pickable: false,
|
|
121394
|
-
collidable: true,
|
|
121395
|
-
clippable: false,
|
|
121396
|
-
visible: false,
|
|
121397
|
-
isObject: false
|
|
121398
|
-
}), NO_STATE_INHERIT),
|
|
121399
|
-
|
|
121400
|
-
yAxisArrowHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121401
|
-
geometry: shapes.arrowHeadHandle,
|
|
121402
|
-
material: materials.pickable,
|
|
121403
|
-
matrix: (function () {
|
|
121404
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121405
|
-
const rotate = math.rotationMat4v(180 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121406
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121407
|
-
})(),
|
|
121408
|
-
pickable: true,
|
|
121409
|
-
collidable: true,
|
|
121410
|
-
clippable: false,
|
|
121411
|
-
visible: false,
|
|
121412
|
-
opacity: 0.2,
|
|
121413
|
-
isObject: false
|
|
121414
|
-
}), NO_STATE_INHERIT),
|
|
121415
|
-
|
|
121416
|
-
yShaft: rootNode.addChild(new Mesh(rootNode, {
|
|
121417
|
-
geometry: shapes.axis,
|
|
121418
|
-
material: materials.green,
|
|
121419
|
-
position: [0, -radius / 2, 0],
|
|
121420
|
-
pickable: false,
|
|
121421
|
-
collidable: true,
|
|
121422
|
-
clippable: false,
|
|
121423
|
-
visible: false,
|
|
121424
|
-
isObject: false
|
|
121425
|
-
}), NO_STATE_INHERIT),
|
|
121426
|
-
|
|
121427
|
-
yShaftHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121428
|
-
geometry: shapes.axisHandle,
|
|
121429
|
-
material: materials.pickable,
|
|
121430
|
-
position: [0, -radius / 2, 0],
|
|
121431
|
-
pickable: true,
|
|
121432
|
-
collidable: true,
|
|
121433
|
-
clippable: false,
|
|
121434
|
-
visible: false,
|
|
121435
|
-
isObject: false
|
|
121436
|
-
}), NO_STATE_INHERIT),
|
|
121437
|
-
|
|
121438
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121439
|
-
//
|
|
121440
|
-
//----------------------------------------------------------------------------------------------------------
|
|
121441
|
-
|
|
121442
|
-
zAxisArrow: rootNode.addChild(new Mesh(rootNode, {
|
|
121443
|
-
geometry: shapes.arrowHead,
|
|
121444
|
-
material: materials.blue,
|
|
121445
|
-
matrix: (function () {
|
|
121446
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121447
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0.8, 0, 0], math.identityMat4());
|
|
121448
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121449
|
-
})(),
|
|
121450
|
-
pickable: false,
|
|
121451
|
-
collidable: true,
|
|
121452
|
-
clippable: false,
|
|
121453
|
-
visible: false,
|
|
121454
|
-
isObject: false
|
|
121455
|
-
}), NO_STATE_INHERIT),
|
|
121456
|
-
|
|
121457
|
-
zAxisArrowHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121458
|
-
geometry: shapes.arrowHeadHandle,
|
|
121459
|
-
material: materials.pickable,
|
|
121460
|
-
matrix: (function () {
|
|
121461
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121462
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0.8, 0, 0], math.identityMat4());
|
|
121463
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121464
|
-
})(),
|
|
121465
|
-
pickable: true,
|
|
121466
|
-
collidable: true,
|
|
121467
|
-
clippable: false,
|
|
121468
|
-
visible: false,
|
|
121469
|
-
isObject: false
|
|
121470
|
-
}), NO_STATE_INHERIT),
|
|
121471
|
-
|
|
121472
|
-
|
|
121473
|
-
zShaft: rootNode.addChild(new Mesh(rootNode, {
|
|
121474
|
-
geometry: shapes.axis,
|
|
121475
|
-
material: materials.blue,
|
|
121476
|
-
matrix: (function () {
|
|
121477
|
-
const translate = math.translateMat4c(0, radius / 2, 0, math.identityMat4());
|
|
121478
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121479
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121480
|
-
})(),
|
|
121481
|
-
clippable: false,
|
|
121482
|
-
pickable: false,
|
|
121483
|
-
collidable: true,
|
|
121484
|
-
visible: false,
|
|
121485
|
-
isObject: false
|
|
121486
|
-
}), NO_STATE_INHERIT),
|
|
121487
|
-
|
|
121488
|
-
zAxisHandle: rootNode.addChild(new Mesh(rootNode, {
|
|
121489
|
-
geometry: shapes.axisHandle,
|
|
121490
|
-
material: materials.pickable,
|
|
121491
|
-
matrix: (function () {
|
|
121492
|
-
const translate = math.translateMat4c(0, radius / 2, 0, math.identityMat4());
|
|
121493
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121494
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121495
|
-
})(),
|
|
121496
|
-
clippable: false,
|
|
121497
|
-
pickable: true,
|
|
121498
|
-
collidable: true,
|
|
121499
|
-
visible: false,
|
|
121500
|
-
isObject: false
|
|
121501
|
-
}), NO_STATE_INHERIT)
|
|
121502
|
-
};
|
|
121503
|
-
|
|
121504
|
-
this._affordanceMeshes = {
|
|
121505
|
-
|
|
121506
|
-
planeFrame: rootNode.addChild(new Mesh(rootNode, {
|
|
121507
|
-
geometry: new ReadableGeometry(rootNode, buildTorusGeometry({
|
|
121508
|
-
center: [0, 0, 0],
|
|
121509
|
-
radius: 2,
|
|
121510
|
-
tube: tubeRadius,
|
|
121511
|
-
radialSegments: 4,
|
|
121512
|
-
tubeSegments: 4,
|
|
121513
|
-
arc: Math.PI * 2.0
|
|
121514
|
-
})),
|
|
121515
121135
|
material: new PhongMaterial(rootNode, {
|
|
121516
|
-
|
|
121517
|
-
|
|
121518
|
-
|
|
121519
|
-
|
|
121520
|
-
|
|
121521
|
-
highlightMaterial: new EmphasisMaterial(rootNode, {
|
|
121522
|
-
edges: false,
|
|
121523
|
-
filled: true,
|
|
121524
|
-
fillColor: [1, 1, 0],
|
|
121525
|
-
fillAlpha: 1.0
|
|
121136
|
+
diffuse: [0.0, 0.0, 0.0],
|
|
121137
|
+
emissive: [0, 0, 0],
|
|
121138
|
+
ambient: [0.0, 0.0, 0.0],
|
|
121139
|
+
specular: [.6, .6, .3],
|
|
121140
|
+
shininess: 80
|
|
121526
121141
|
}),
|
|
121527
121142
|
pickable: false,
|
|
121528
|
-
collidable: false,
|
|
121529
|
-
clippable: false,
|
|
121530
|
-
visible: false,
|
|
121531
|
-
scale: [1, 1, 1],
|
|
121532
|
-
rotation: [0, 0, 45],
|
|
121533
|
-
isObject: false
|
|
121534
|
-
}), NO_STATE_INHERIT),
|
|
121535
|
-
|
|
121536
|
-
xHoop: rootNode.addChild(new Mesh(rootNode, { // Full
|
|
121537
|
-
geometry: shapes.hoop,
|
|
121538
|
-
material: materials.red,
|
|
121539
|
-
highlighted: true,
|
|
121540
|
-
highlightMaterial: materials.highlightRed,
|
|
121541
|
-
matrix: (function () {
|
|
121542
|
-
const rotate2 = math.rotationMat4v(90 * math.DEGTORAD, [0, 1, 0], math.identityMat4());
|
|
121543
|
-
const rotate1 = math.rotationMat4v(270 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121544
|
-
return math.mulMat4(rotate1, rotate2, math.identityMat4());
|
|
121545
|
-
})(),
|
|
121546
|
-
pickable: false,
|
|
121547
121143
|
collidable: true,
|
|
121548
121144
|
clippable: false,
|
|
121549
121145
|
visible: false,
|
|
121550
121146
|
isObject: false
|
|
121551
121147
|
}), NO_STATE_INHERIT),
|
|
121552
121148
|
|
|
121553
|
-
|
|
121554
|
-
|
|
121555
|
-
|
|
121556
|
-
highlighted: true,
|
|
121557
|
-
highlightMaterial: materials.highlightGreen,
|
|
121558
|
-
rotation: [-90, 0, 0],
|
|
121559
|
-
pickable: false,
|
|
121560
|
-
collidable: true,
|
|
121561
|
-
clippable: false,
|
|
121562
|
-
visible: false,
|
|
121563
|
-
isObject: false
|
|
121564
|
-
}), NO_STATE_INHERIT),
|
|
121565
|
-
|
|
121566
|
-
zHoop: rootNode.addChild(new Mesh(rootNode, { // Blue hoop about Z-axis
|
|
121567
|
-
geometry: shapes.hoop,
|
|
121568
|
-
material: materials.blue,
|
|
121569
|
-
highlighted: true,
|
|
121570
|
-
highlightMaterial: materials.highlightBlue,
|
|
121571
|
-
matrix: math.rotationMat4v(180 * math.DEGTORAD, [1, 0, 0], math.identityMat4()),
|
|
121572
|
-
pickable: false,
|
|
121573
|
-
collidable: true,
|
|
121574
|
-
clippable: false,
|
|
121575
|
-
backfaces: true,
|
|
121576
|
-
visible: false,
|
|
121577
|
-
isObject: false
|
|
121578
|
-
}), NO_STATE_INHERIT),
|
|
121579
|
-
|
|
121580
|
-
xAxisArrow: rootNode.addChild(new Mesh(rootNode, {
|
|
121581
|
-
geometry: shapes.arrowHeadBig,
|
|
121582
|
-
material: materials.red,
|
|
121583
|
-
matrix: (function () {
|
|
121584
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121585
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0, 0, 1], math.identityMat4());
|
|
121586
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121587
|
-
})(),
|
|
121588
|
-
pickable: false,
|
|
121589
|
-
collidable: true,
|
|
121590
|
-
clippable: false,
|
|
121591
|
-
visible: false,
|
|
121592
|
-
isObject: false
|
|
121593
|
-
}), NO_STATE_INHERIT),
|
|
121594
|
-
|
|
121595
|
-
yAxisArrow: rootNode.addChild(new Mesh(rootNode, {
|
|
121596
|
-
geometry: shapes.arrowHeadBig,
|
|
121597
|
-
material: materials.green,
|
|
121598
|
-
matrix: (function () {
|
|
121599
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121600
|
-
const rotate = math.rotationMat4v(180 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
|
|
121601
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121602
|
-
})(),
|
|
121603
|
-
pickable: false,
|
|
121604
|
-
collidable: true,
|
|
121605
|
-
clippable: false,
|
|
121606
|
-
visible: false,
|
|
121607
|
-
isObject: false
|
|
121608
|
-
}), NO_STATE_INHERIT),
|
|
121609
|
-
|
|
121610
|
-
zAxisArrow: rootNode.addChild(new Mesh(rootNode, {
|
|
121611
|
-
geometry: shapes.arrowHeadBig,
|
|
121612
|
-
material: materials.blue,
|
|
121613
|
-
matrix: (function () {
|
|
121614
|
-
const translate = math.translateMat4c(0, radius + .1, 0, math.identityMat4());
|
|
121615
|
-
const rotate = math.rotationMat4v(-90 * math.DEGTORAD, [0.8, 0, 0], math.identityMat4());
|
|
121616
|
-
return math.mulMat4(rotate, translate, math.identityMat4());
|
|
121617
|
-
})(),
|
|
121618
|
-
pickable: false,
|
|
121619
|
-
collidable: true,
|
|
121620
|
-
clippable: false,
|
|
121621
|
-
visible: false,
|
|
121622
|
-
isObject: false
|
|
121623
|
-
}), NO_STATE_INHERIT)
|
|
121624
|
-
};
|
|
121625
|
-
}
|
|
121626
|
-
|
|
121627
|
-
_bindEvents() {
|
|
121628
|
-
|
|
121629
|
-
const self = this;
|
|
121630
|
-
|
|
121631
|
-
var grabbed = false;
|
|
121632
|
-
|
|
121633
|
-
const DRAG_ACTIONS = {
|
|
121634
|
-
none: -1,
|
|
121635
|
-
xTranslate: 0,
|
|
121636
|
-
yTranslate: 1,
|
|
121637
|
-
zTranslate: 2,
|
|
121638
|
-
xRotate: 3,
|
|
121639
|
-
yRotate: 4,
|
|
121640
|
-
zRotate: 5
|
|
121641
|
-
};
|
|
121642
|
-
|
|
121643
|
-
const rootNode = this._rootNode;
|
|
121644
|
-
|
|
121645
|
-
var nextDragAction = null; // As we hover grabbed an arrow or hoop, self is the action we would do if we then dragged it.
|
|
121646
|
-
var dragAction = null; // Action we're doing while we drag an arrow or hoop.
|
|
121647
|
-
const lastCanvasPos = math.vec2();
|
|
121149
|
+
//----------------------------------------------------------------------------------------------------------
|
|
121150
|
+
//
|
|
121151
|
+
//----------------------------------------------------------------------------------------------------------
|
|
121648
121152
|
|
|
121649
|
-
|
|
121650
|
-
|
|
121651
|
-
|
|
121153
|
+
addAxis([1,0,0], [ 1, 0, 0 ], [ 1, 0, 0 ]),
|
|
121154
|
+
addAxis([0,1,0], [ 0, -1, 0 ], [ 0, 1, 0 ]),
|
|
121155
|
+
addAxis([0,0,1], [ 0, 0, -1 ], [ 0, 0, -1 ])
|
|
121156
|
+
];
|
|
121652
121157
|
|
|
121653
|
-
const
|
|
121654
|
-
const camera = this._viewer.camera;
|
|
121655
|
-
const scene = this._viewer.scene;
|
|
121158
|
+
const cleanups = [ ];
|
|
121656
121159
|
|
|
121657
121160
|
{ // Keep gizmo screen size constant
|
|
121658
|
-
|
|
121659
|
-
const tempVec3a = math.vec3([0, 0, 0]);
|
|
121660
121161
|
let lastDist = -1;
|
|
121661
|
-
|
|
121662
|
-
|
|
121663
|
-
|
|
121664
|
-
|
|
121665
|
-
|
|
121666
|
-
|
|
121667
|
-
|
|
121668
|
-
this._onSceneTick = scene.on("tick", () => {
|
|
121669
|
-
|
|
121670
|
-
const dist = Math.abs(math.lenVec3(math.subVec3(scene.camera.eye, this._pos, tempVec3a)));
|
|
121671
|
-
|
|
121672
|
-
if (dist !== lastDist) {
|
|
121673
|
-
if (camera.projection === "perspective") {
|
|
121674
|
-
const worldSize = (Math.tan(camera.perspective.fov * math.DEGTORAD)) * dist;
|
|
121675
|
-
const size = 0.07 * worldSize;
|
|
121676
|
-
rootNode.scale = [size, size, size];
|
|
121677
|
-
lastDist = dist;
|
|
121162
|
+
const setRootNodeScale = size => rootNode.scale = [size, size, size];
|
|
121163
|
+
const onSceneTick = scene.on("tick", () => {
|
|
121164
|
+
const dist = Math.abs(math.distVec3(camera.eye, pos));
|
|
121165
|
+
if (camera.projection === "perspective") {
|
|
121166
|
+
if (dist !== lastDist) {
|
|
121167
|
+
setRootNodeScale(0.07 * dist * Math.tan(camera.perspective.fov * math.DEGTORAD));
|
|
121678
121168
|
}
|
|
121169
|
+
} else if (camera.projection === "ortho") {
|
|
121170
|
+
setRootNodeScale(camera.ortho.scale / 10);
|
|
121679
121171
|
}
|
|
121680
|
-
|
|
121681
|
-
if (camera.projection === "ortho") {
|
|
121682
|
-
const worldSize = camera.ortho.scale / 10;
|
|
121683
|
-
const size = worldSize;
|
|
121684
|
-
rootNode.scale = [size, size, size];
|
|
121685
|
-
lastDist = dist;
|
|
121686
|
-
}
|
|
121172
|
+
lastDist = dist;
|
|
121687
121173
|
});
|
|
121174
|
+
cleanups.push(() => scene.off(onSceneTick));
|
|
121688
121175
|
}
|
|
121689
121176
|
|
|
121690
|
-
const getClickCoordsWithinElement = (function () {
|
|
121691
|
-
const canvasPos = new Float64Array(2);
|
|
121692
|
-
return function (event) {
|
|
121693
|
-
if (!event) {
|
|
121694
|
-
event = window.event;
|
|
121695
|
-
canvasPos[0] = event.x;
|
|
121696
|
-
canvasPos[1] = event.y;
|
|
121697
|
-
} else {
|
|
121698
|
-
var element = event.target;
|
|
121699
|
-
var totalOffsetLeft = 0;
|
|
121700
|
-
var totalOffsetTop = 0;
|
|
121701
|
-
|
|
121702
|
-
while (element.offsetParent) {
|
|
121703
|
-
totalOffsetLeft += element.offsetLeft;
|
|
121704
|
-
totalOffsetTop += element.offsetTop;
|
|
121705
|
-
element = element.offsetParent;
|
|
121706
|
-
}
|
|
121707
|
-
canvasPos[0] = event.pageX - totalOffsetLeft;
|
|
121708
|
-
canvasPos[1] = event.pageY - totalOffsetTop;
|
|
121709
|
-
}
|
|
121710
|
-
return canvasPos;
|
|
121711
|
-
};
|
|
121712
|
-
})();
|
|
121713
|
-
|
|
121714
121177
|
const localToWorldVec = (function () {
|
|
121715
121178
|
const mat = math.mat4();
|
|
121716
121179
|
return function (localVec, worldVec) {
|
|
121717
|
-
math.quaternionToMat4(
|
|
121180
|
+
math.quaternionToMat4(rootNode.quaternion, mat);
|
|
121718
121181
|
math.transformVec3(mat, localVec, worldVec);
|
|
121719
121182
|
math.normalizeVec3(worldVec);
|
|
121720
121183
|
return worldVec;
|
|
121721
121184
|
};
|
|
121722
121185
|
})();
|
|
121723
121186
|
|
|
121724
|
-
|
|
121725
|
-
const
|
|
121726
|
-
|
|
121727
|
-
|
|
121728
|
-
|
|
121729
|
-
|
|
121730
|
-
} else {
|
|
121731
|
-
math.cross3Vec3(worldAxis, [1, 0, 0], planeNormal);
|
|
121732
|
-
}
|
|
121733
|
-
math.cross3Vec3(planeNormal, worldAxis, planeNormal);
|
|
121734
|
-
math.normalizeVec3(planeNormal);
|
|
121735
|
-
return planeNormal;
|
|
121736
|
-
}
|
|
121737
|
-
})();
|
|
121738
|
-
|
|
121739
|
-
const dragTranslateSectionPlane = (function () {
|
|
121740
|
-
const p1 = math.vec3();
|
|
121741
|
-
const p2 = math.vec3();
|
|
121742
|
-
const worldAxis = math.vec4();
|
|
121743
|
-
return function (baseAxis, fromMouse, toMouse) {
|
|
121744
|
-
localToWorldVec(baseAxis, worldAxis);
|
|
121745
|
-
const planeNormal = getTranslationPlane(worldAxis, fromMouse, toMouse);
|
|
121746
|
-
getPointerPlaneIntersect(fromMouse, planeNormal, p1);
|
|
121747
|
-
getPointerPlaneIntersect(toMouse, planeNormal, p2);
|
|
121748
|
-
math.subVec3(p2, p1);
|
|
121749
|
-
const dot = math.dotVec3(p2, worldAxis);
|
|
121750
|
-
self._pos[0] += worldAxis[0] * dot;
|
|
121751
|
-
self._pos[1] += worldAxis[1] * dot;
|
|
121752
|
-
self._pos[2] += worldAxis[2] * dot;
|
|
121753
|
-
self._rootNode.position = self._pos;
|
|
121754
|
-
if (self._sectionPlane) {
|
|
121755
|
-
self._sectionPlane.pos = self._pos;
|
|
121756
|
-
}
|
|
121187
|
+
const getTranslationPlane = (worldAxis, planeNormal) => {
|
|
121188
|
+
const absX = Math.abs(worldAxis[0]);
|
|
121189
|
+
if (absX > Math.abs(worldAxis[1]) && absX > Math.abs(worldAxis[2])) {
|
|
121190
|
+
math.cross3Vec3(worldAxis, [0, 1, 0], planeNormal);
|
|
121191
|
+
} else {
|
|
121192
|
+
math.cross3Vec3(worldAxis, [1, 0, 0], planeNormal);
|
|
121757
121193
|
}
|
|
121758
|
-
|
|
121194
|
+
math.cross3Vec3(planeNormal, worldAxis, planeNormal);
|
|
121195
|
+
math.normalizeVec3(planeNormal);
|
|
121196
|
+
};
|
|
121759
121197
|
|
|
121198
|
+
const self = this;
|
|
121760
121199
|
var dragRotateSectionPlane = (function () {
|
|
121761
121200
|
const p1 = math.vec4();
|
|
121762
121201
|
const p2 = math.vec4();
|
|
121763
121202
|
const c = math.vec4();
|
|
121764
121203
|
const worldAxis = math.vec4();
|
|
121204
|
+
const dir = math.vec3();
|
|
121205
|
+
const mat = math.mat4();
|
|
121206
|
+
const planeNormal = math.vec3();
|
|
121765
121207
|
return function (baseAxis, fromMouse, toMouse) {
|
|
121766
121208
|
localToWorldVec(baseAxis, worldAxis);
|
|
121767
121209
|
const hasData = getPointerPlaneIntersect(fromMouse, worldAxis, p1) && getPointerPlaneIntersect(toMouse, worldAxis, p2);
|
|
121768
121210
|
if (!hasData) { // Find intersections with view plane and project down to origin
|
|
121769
|
-
|
|
121211
|
+
getTranslationPlane(worldAxis, planeNormal);
|
|
121770
121212
|
getPointerPlaneIntersect(fromMouse, planeNormal, p1, 1); // Ensure plane moves closer to camera so angles become workable
|
|
121771
121213
|
getPointerPlaneIntersect(toMouse, planeNormal, p2, 1);
|
|
121772
121214
|
var dot = math.dotVec3(p1, worldAxis);
|
|
@@ -121787,9 +121229,15 @@ class Control {
|
|
|
121787
121229
|
if (math.dotVec3(c, worldAxis) < 0.0) {
|
|
121788
121230
|
incDegrees = -incDegrees;
|
|
121789
121231
|
}
|
|
121790
|
-
|
|
121791
|
-
|
|
121792
|
-
|
|
121232
|
+
rootNode.rotate(baseAxis, incDegrees);
|
|
121233
|
+
|
|
121234
|
+
if (self._sectionPlane) {
|
|
121235
|
+
math.quaternionToMat4(rootNode.quaternion, mat); // << ---
|
|
121236
|
+
math.transformVec3(mat, [0, 0, 1], dir);
|
|
121237
|
+
ignoreNextSectionPlaneDirUpdate = true;
|
|
121238
|
+
self._sectionPlane.dir = dir;
|
|
121239
|
+
}
|
|
121240
|
+
};
|
|
121793
121241
|
})();
|
|
121794
121242
|
|
|
121795
121243
|
var getPointerPlaneIntersect = (function () {
|
|
@@ -121818,221 +121266,210 @@ class Control {
|
|
|
121818
121266
|
return true;
|
|
121819
121267
|
}
|
|
121820
121268
|
return false;
|
|
121821
|
-
}
|
|
121822
|
-
})();
|
|
121823
|
-
|
|
121824
|
-
const rotateSectionPlane = (function () {
|
|
121825
|
-
const dir = math.vec3();
|
|
121826
|
-
const mat = math.mat4();
|
|
121827
|
-
return function () {
|
|
121828
|
-
if (self.sectionPlane) {
|
|
121829
|
-
math.quaternionToMat4(rootNode.quaternion, mat); // << ---
|
|
121830
|
-
math.transformVec3(mat, [0, 0, 1], dir);
|
|
121831
|
-
self._setSectionPlaneDir(dir);
|
|
121832
|
-
}
|
|
121833
121269
|
};
|
|
121834
121270
|
})();
|
|
121835
121271
|
|
|
121836
121272
|
{
|
|
121837
|
-
|
|
121838
|
-
|
|
121839
|
-
|
|
121840
|
-
|
|
121841
|
-
|
|
121842
|
-
|
|
121843
|
-
|
|
121844
|
-
|
|
121845
|
-
|
|
121846
|
-
|
|
121847
|
-
grabbed = false;
|
|
121848
|
-
if (lastAffordanceMesh) {
|
|
121849
|
-
lastAffordanceMesh.visible = false;
|
|
121850
|
-
}
|
|
121851
|
-
var affordanceMesh;
|
|
121852
|
-
const meshId = hit.entity.id;
|
|
121853
|
-
switch (meshId) {
|
|
121854
|
-
|
|
121855
|
-
case this._displayMeshes.xAxisArrowHandle.id:
|
|
121856
|
-
affordanceMesh = this._affordanceMeshes.xAxisArrow;
|
|
121857
|
-
nextDragAction = DRAG_ACTIONS.xTranslate;
|
|
121858
|
-
break;
|
|
121859
|
-
|
|
121860
|
-
case this._displayMeshes.xAxisHandle.id:
|
|
121861
|
-
affordanceMesh = this._affordanceMeshes.xAxisArrow;
|
|
121862
|
-
nextDragAction = DRAG_ACTIONS.xTranslate;
|
|
121863
|
-
break;
|
|
121864
|
-
|
|
121865
|
-
case this._displayMeshes.yAxisArrowHandle.id:
|
|
121866
|
-
affordanceMesh = this._affordanceMeshes.yAxisArrow;
|
|
121867
|
-
nextDragAction = DRAG_ACTIONS.yTranslate;
|
|
121868
|
-
break;
|
|
121869
|
-
|
|
121870
|
-
case this._displayMeshes.yShaftHandle.id:
|
|
121871
|
-
affordanceMesh = this._affordanceMeshes.yAxisArrow;
|
|
121872
|
-
nextDragAction = DRAG_ACTIONS.yTranslate;
|
|
121873
|
-
break;
|
|
121874
|
-
|
|
121875
|
-
case this._displayMeshes.zAxisArrowHandle.id:
|
|
121876
|
-
affordanceMesh = this._affordanceMeshes.zAxisArrow;
|
|
121877
|
-
nextDragAction = DRAG_ACTIONS.zTranslate;
|
|
121878
|
-
break;
|
|
121273
|
+
let deactivateActive = null;
|
|
121274
|
+
let currentDrag = null;
|
|
121275
|
+
cleanups.push(() => { if (currentDrag) { currentDrag.cleanup(); } });
|
|
121276
|
+
const canvasPos = math.vec2();
|
|
121277
|
+
|
|
121278
|
+
const copyCanvasPos = (event, vec2) => {
|
|
121279
|
+
vec2[0] = event.clientX;
|
|
121280
|
+
vec2[1] = event.clientY;
|
|
121281
|
+
transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
|
|
121282
|
+
};
|
|
121879
121283
|
|
|
121880
|
-
|
|
121881
|
-
|
|
121882
|
-
|
|
121883
|
-
|
|
121284
|
+
const pickHandler = (e) => {
|
|
121285
|
+
copyCanvasPos(e, canvasPos);
|
|
121286
|
+
const pickResult = viewer.scene.pick({ canvasPos: canvasPos });
|
|
121287
|
+
const pickEntity = pickResult && pickResult.entity;
|
|
121288
|
+
const pickId = pickEntity && pickEntity.id;
|
|
121289
|
+
return (pickId in handlers) && handlers[pickId];
|
|
121290
|
+
};
|
|
121884
121291
|
|
|
121885
|
-
|
|
121886
|
-
|
|
121887
|
-
|
|
121888
|
-
|
|
121292
|
+
const startDrag = (event, matchesEvent) => {
|
|
121293
|
+
const handler = pickHandler(matchesEvent(event));
|
|
121294
|
+
if (handler) {
|
|
121295
|
+
if (currentDrag) {
|
|
121296
|
+
currentDrag.cleanup();
|
|
121297
|
+
}
|
|
121889
121298
|
|
|
121890
|
-
|
|
121891
|
-
|
|
121892
|
-
|
|
121893
|
-
|
|
121299
|
+
const dragAction = handler.initDragAction(canvasPos);
|
|
121300
|
+
if (dragAction) {
|
|
121301
|
+
cameraControl.pointerEnabled = false; // or .active = false ?
|
|
121302
|
+
handler.setActivated(true);
|
|
121303
|
+
|
|
121304
|
+
currentDrag = {
|
|
121305
|
+
onChange: event => {
|
|
121306
|
+
const e = matchesEvent(event);
|
|
121307
|
+
if (e) {
|
|
121308
|
+
copyCanvasPos(e, canvasPos);
|
|
121309
|
+
dragAction(canvasPos);
|
|
121310
|
+
}
|
|
121311
|
+
},
|
|
121312
|
+
cleanup: function() {
|
|
121313
|
+
currentDrag = null;
|
|
121314
|
+
cameraControl.pointerEnabled = true; // or .active = true ?
|
|
121315
|
+
handler.setActivated(false);
|
|
121316
|
+
}
|
|
121317
|
+
};
|
|
121318
|
+
}
|
|
121319
|
+
}
|
|
121320
|
+
};
|
|
121894
121321
|
|
|
121895
|
-
|
|
121896
|
-
|
|
121897
|
-
|
|
121898
|
-
|
|
121322
|
+
const addCanvasEventListener = (type, listener) => {
|
|
121323
|
+
canvas.addEventListener(type, listener);
|
|
121324
|
+
cleanups.push(() => canvas.removeEventListener(type, listener));
|
|
121325
|
+
};
|
|
121899
121326
|
|
|
121900
|
-
|
|
121901
|
-
|
|
121902
|
-
|
|
121903
|
-
|
|
121904
|
-
if (affordanceMesh) {
|
|
121905
|
-
affordanceMesh.visible = true;
|
|
121327
|
+
addCanvasEventListener("mousedown", (e) => {
|
|
121328
|
+
e.preventDefault();
|
|
121329
|
+
if (e.which === 1) {
|
|
121330
|
+
startDrag(e, event => (event.which === 1) && event);
|
|
121906
121331
|
}
|
|
121907
|
-
lastAffordanceMesh = affordanceMesh;
|
|
121908
|
-
grabbed = true;
|
|
121909
121332
|
});
|
|
121910
121333
|
|
|
121911
|
-
|
|
121912
|
-
if (
|
|
121913
|
-
|
|
121914
|
-
}
|
|
121915
|
-
|
|
121916
|
-
|
|
121334
|
+
addCanvasEventListener("mousemove", (e) => {
|
|
121335
|
+
if (currentDrag) {
|
|
121336
|
+
currentDrag.onChange(e);
|
|
121337
|
+
} else {
|
|
121338
|
+
if (deactivateActive) {
|
|
121339
|
+
deactivateActive();
|
|
121340
|
+
}
|
|
121341
|
+
const handler = pickHandler(e);
|
|
121342
|
+
if (handler) {
|
|
121343
|
+
handler.setActivated(true);
|
|
121344
|
+
deactivateActive = () => handler.setActivated(false);
|
|
121345
|
+
} else {
|
|
121346
|
+
deactivateActive = null;
|
|
121347
|
+
}
|
|
121917
121348
|
}
|
|
121918
|
-
lastAffordanceMesh = null;
|
|
121919
|
-
nextDragAction = DRAG_ACTIONS.none;
|
|
121920
121349
|
});
|
|
121921
121350
|
|
|
121922
|
-
|
|
121923
|
-
|
|
121924
|
-
|
|
121925
|
-
|
|
121926
|
-
}
|
|
121927
|
-
if (!grabbed) {
|
|
121928
|
-
return;
|
|
121929
|
-
}
|
|
121930
|
-
this._viewer.cameraControl.pointerEnabled = false;
|
|
121931
|
-
switch (e.which) {
|
|
121932
|
-
case 1: // Left button
|
|
121933
|
-
down = true;
|
|
121934
|
-
var canvasPos = getClickCoordsWithinElement(e);
|
|
121935
|
-
dragAction = nextDragAction;
|
|
121936
|
-
lastCanvasPos[0] = canvasPos[0];
|
|
121937
|
-
lastCanvasPos[1] = canvasPos[1];
|
|
121938
|
-
break;
|
|
121351
|
+
addCanvasEventListener("mouseup", (e) => {
|
|
121352
|
+
if (currentDrag) {
|
|
121353
|
+
currentDrag.onChange(e);
|
|
121354
|
+
currentDrag.cleanup();
|
|
121939
121355
|
}
|
|
121940
121356
|
});
|
|
121941
121357
|
|
|
121942
|
-
canvas.addEventListener("mousemove", this._canvasMouseMoveListener = (e) => {
|
|
121943
|
-
if (!this._visible) {
|
|
121944
|
-
return;
|
|
121945
|
-
}
|
|
121946
|
-
if (!down) {
|
|
121947
|
-
return;
|
|
121948
|
-
}
|
|
121949
|
-
var canvasPos = getClickCoordsWithinElement(e);
|
|
121950
|
-
const x = canvasPos[0];
|
|
121951
|
-
const y = canvasPos[1];
|
|
121952
121358
|
|
|
121953
|
-
|
|
121954
|
-
|
|
121955
|
-
|
|
121956
|
-
|
|
121957
|
-
|
|
121958
|
-
|
|
121959
|
-
break;
|
|
121960
|
-
case DRAG_ACTIONS.zTranslate:
|
|
121961
|
-
dragTranslateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
121962
|
-
break;
|
|
121963
|
-
case DRAG_ACTIONS.xRotate:
|
|
121964
|
-
dragRotateSectionPlane(xBaseAxis, lastCanvasPos, canvasPos);
|
|
121965
|
-
break;
|
|
121966
|
-
case DRAG_ACTIONS.yRotate:
|
|
121967
|
-
dragRotateSectionPlane(yBaseAxis, lastCanvasPos, canvasPos);
|
|
121968
|
-
break;
|
|
121969
|
-
case DRAG_ACTIONS.zRotate:
|
|
121970
|
-
dragRotateSectionPlane(zBaseAxis, lastCanvasPos, canvasPos);
|
|
121971
|
-
break;
|
|
121359
|
+
addCanvasEventListener("touchstart", event => {
|
|
121360
|
+
event.preventDefault();
|
|
121361
|
+
if (event.touches.length === 1)
|
|
121362
|
+
{
|
|
121363
|
+
const touchStartId = event.touches[0].identifier;
|
|
121364
|
+
startDrag(event, event => [...event.changedTouches].find(e => e.identifier === touchStartId));
|
|
121972
121365
|
}
|
|
121366
|
+
});
|
|
121973
121367
|
|
|
121974
|
-
|
|
121975
|
-
|
|
121368
|
+
addCanvasEventListener("touchmove", event => {
|
|
121369
|
+
event.preventDefault();
|
|
121370
|
+
currentDrag && currentDrag.onChange(event);
|
|
121976
121371
|
});
|
|
121977
121372
|
|
|
121978
|
-
|
|
121979
|
-
|
|
121980
|
-
|
|
121981
|
-
|
|
121982
|
-
|
|
121983
|
-
if (!down) {
|
|
121984
|
-
return;
|
|
121373
|
+
addCanvasEventListener("touchend", event => {
|
|
121374
|
+
event.preventDefault();
|
|
121375
|
+
if (currentDrag) {
|
|
121376
|
+
currentDrag.onChange(event);
|
|
121377
|
+
currentDrag.cleanup();
|
|
121985
121378
|
}
|
|
121986
|
-
switch (e.which) {
|
|
121987
|
-
}
|
|
121988
|
-
down = false;
|
|
121989
|
-
grabbed = false;
|
|
121990
121379
|
});
|
|
121380
|
+
}
|
|
121991
121381
|
|
|
121992
|
-
|
|
121993
|
-
|
|
121994
|
-
|
|
121995
|
-
|
|
121996
|
-
|
|
121997
|
-
|
|
121998
|
-
|
|
121382
|
+
this._unbindSectionPlane = () => { };
|
|
121383
|
+
|
|
121384
|
+
this.__setSectionPlane = sectionPlane => {
|
|
121385
|
+
this.id = sectionPlane.id;
|
|
121386
|
+
this._sectionPlane = sectionPlane;
|
|
121387
|
+
const setPosFromSectionPlane = () => setPos(sectionPlane.pos);
|
|
121388
|
+
const setDirFromSectionPlane = () => rootNode.quaternion = math.vec3PairToQuaternion(zeroVec$1, sectionPlane.dir, quat$1);
|
|
121389
|
+
setPosFromSectionPlane();
|
|
121390
|
+
setDirFromSectionPlane();
|
|
121391
|
+
const onSectionPlanePos = sectionPlane.on("pos", setPosFromSectionPlane);
|
|
121392
|
+
const onSectionPlaneDir = sectionPlane.on("dir", () => {
|
|
121393
|
+
if (!ignoreNextSectionPlaneDirUpdate) {
|
|
121394
|
+
setDirFromSectionPlane();
|
|
121395
|
+
} else {
|
|
121396
|
+
ignoreNextSectionPlaneDirUpdate = false;
|
|
121999
121397
|
}
|
|
122000
121398
|
});
|
|
122001
|
-
|
|
121399
|
+
|
|
121400
|
+
this._unbindSectionPlane = () => {
|
|
121401
|
+
this.id = null;
|
|
121402
|
+
this._sectionPlane = null;
|
|
121403
|
+
sectionPlane.off(onSectionPlanePos);
|
|
121404
|
+
sectionPlane.off(onSectionPlaneDir);
|
|
121405
|
+
this._unbindSectionPlane = () => { };
|
|
121406
|
+
};
|
|
121407
|
+
};
|
|
121408
|
+
|
|
121409
|
+
this.__destroy = () => {
|
|
121410
|
+
cleanups.forEach(c => c());
|
|
121411
|
+
this._unbindSectionPlane();
|
|
121412
|
+
rootNode.destroy();
|
|
121413
|
+
this._displayMeshes = [ ];
|
|
121414
|
+
for (let id in handlers) {
|
|
121415
|
+
delete handlers[id];
|
|
121416
|
+
}
|
|
121417
|
+
};
|
|
122002
121418
|
}
|
|
122003
121419
|
|
|
122004
121420
|
_destroy() {
|
|
122005
|
-
this.
|
|
122006
|
-
this._destroyNodes();
|
|
121421
|
+
this.__destroy();
|
|
122007
121422
|
}
|
|
122008
121423
|
|
|
122009
|
-
|
|
122010
|
-
|
|
122011
|
-
|
|
122012
|
-
|
|
122013
|
-
|
|
122014
|
-
|
|
122015
|
-
|
|
122016
|
-
|
|
122017
|
-
|
|
121424
|
+
/**
|
|
121425
|
+
* Called by SectionPlanesPlugin to assign this Control to a SectionPlane.
|
|
121426
|
+
* SectionPlanesPlugin keeps SectionPlaneControls in a reuse pool.
|
|
121427
|
+
* Call with a null or undefined value to disconnect the Control ffrom whatever SectionPlane it was assigned to.
|
|
121428
|
+
* @private
|
|
121429
|
+
*/
|
|
121430
|
+
_setSectionPlane(sectionPlane) {
|
|
121431
|
+
this._unbindSectionPlane();
|
|
121432
|
+
if (sectionPlane) {
|
|
121433
|
+
this.__setSectionPlane(sectionPlane);
|
|
121434
|
+
}
|
|
121435
|
+
}
|
|
122018
121436
|
|
|
122019
|
-
|
|
122020
|
-
|
|
122021
|
-
|
|
122022
|
-
|
|
121437
|
+
/**
|
|
121438
|
+
* Gets the {@link SectionPlane} controlled by this Control.
|
|
121439
|
+
* @returns {SectionPlane} The SectionPlane.
|
|
121440
|
+
*/
|
|
121441
|
+
get sectionPlane() {
|
|
121442
|
+
return this._sectionPlane;
|
|
121443
|
+
}
|
|
122023
121444
|
|
|
122024
|
-
|
|
122025
|
-
|
|
121445
|
+
/**
|
|
121446
|
+
* Sets if this Control is visible.
|
|
121447
|
+
*
|
|
121448
|
+
* @type {Boolean}
|
|
121449
|
+
*/
|
|
121450
|
+
setVisible(visible = true) {
|
|
121451
|
+
if (this._visible !== visible) {
|
|
121452
|
+
this._visible = visible;
|
|
121453
|
+
this._displayMeshes.forEach(m => m.visible = visible);
|
|
121454
|
+
}
|
|
121455
|
+
}
|
|
122026
121456
|
|
|
122027
|
-
|
|
122028
|
-
|
|
121457
|
+
/**
|
|
121458
|
+
* Gets if this Control is visible.
|
|
121459
|
+
*
|
|
121460
|
+
* @type {Boolean}
|
|
121461
|
+
*/
|
|
121462
|
+
getVisible() {
|
|
121463
|
+
return this._visible;
|
|
122029
121464
|
}
|
|
122030
121465
|
|
|
122031
|
-
|
|
122032
|
-
|
|
122033
|
-
|
|
122034
|
-
|
|
122035
|
-
|
|
121466
|
+
/**
|
|
121467
|
+
* Sets if this Control is culled. This is called by SectionPlanesPlugin to
|
|
121468
|
+
* temporarily hide the Control while a snapshot is being taken by Viewer#getSnapshot().
|
|
121469
|
+
* @param culled
|
|
121470
|
+
*/
|
|
121471
|
+
setCulled(culled) {
|
|
121472
|
+
this._displayMeshes.forEach(m => m.culled = culled);
|
|
122036
121473
|
}
|
|
122037
121474
|
}
|
|
122038
121475
|
|