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