@inweb/viewer-visualize 26.12.4 → 26.12.6

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.
@@ -1563,7 +1563,7 @@
1563
1563
  this.deltaAngle = Math.PI / 3600;
1564
1564
  this.autoSelect = true;
1565
1565
  this.isJoyStickMoving = false;
1566
- this.addJoyStickDragger();
1566
+ this.addJoyStickDragger(subject.canvas.parentElement);
1567
1567
  }
1568
1568
  initialize() {
1569
1569
  super.initialize();
@@ -1768,13 +1768,13 @@
1768
1768
  const volume = [xmax - xmin, ymax - ymin, zmax - zmin];
1769
1769
  return Math.max(...volume);
1770
1770
  }
1771
- addJoyStickDragger() {
1771
+ addJoyStickDragger(parentElement) {
1772
1772
  this.joyStickOverlayElement = document.createElement("div");
1773
1773
  this.joyStickOverlayElement.id = "joyStickDiv";
1774
1774
  this.joyStickOverlayElement.style.background = "rgba(0,0,0,0)";
1775
1775
  this.joyStickOverlayElement.style.position = "fixed";
1776
1776
  this.joyStickOverlayElement.style.zIndex = "0";
1777
- document.body.appendChild(this.joyStickOverlayElement);
1777
+ parentElement.appendChild(this.joyStickOverlayElement);
1778
1778
  this.joyStickDragger = new OdJoyStickDragger(this, this.joyStickOverlayElement, (stickData) => {
1779
1779
  if (Math.sqrt(stickData.x * stickData.x + stickData.y * stickData.y) > 20) {
1780
1780
  this.lastJoyStickCoord = { x: stickData.x, y: stickData.y };
@@ -1839,31 +1839,11 @@
1839
1839
  this.lastFrameJoyStickTS = 0;
1840
1840
  this.animationId = undefined;
1841
1841
  this.processMovement = this.processMovement.bind(this);
1842
- this.processJoyMovement = this.processJoyMovement.bind(this);
1842
+ this.processJoyStickMovement = this.processJoyStickMovement.bind(this);
1843
1843
  this.deltaAngle = Math.PI / 3600;
1844
1844
  this.autoSelect = true;
1845
- this.moving = false;
1846
- this.joyStickOverlayElement = document.createElement("div");
1847
- this.joyStickOverlayElement.id = "joyStickDiv";
1848
- this.joyStickOverlayElement.style.background = "rgba(0,0,0,0)";
1849
- this.joyStickOverlayElement.style.position = "fixed";
1850
- this.joyStickOverlayElement.style.zIndex = "0";
1851
- document.body.appendChild(this.joyStickOverlayElement);
1852
- this.joyStickDragger = new OdJoyStickDragger(this, this.joyStickOverlayElement, (stickData) => {
1853
- if (Math.sqrt(stickData.x * stickData.x + stickData.y * stickData.y) > 20) {
1854
- this.lastJoyStickCoord = { x: stickData.x, y: stickData.y };
1855
- if (!this.animationId && !this.moving) {
1856
- this.moving = true;
1857
- this.processJoyMovement(0);
1858
- }
1859
- }
1860
- else {
1861
- this.moving = false;
1862
- window.cancelAnimationFrame(this.animationId);
1863
- this.animationId = undefined;
1864
- this.lastFrameJoyStickTS = 0;
1865
- }
1866
- }, this.m_module.canvas);
1845
+ this.isJoyStickMoving = false;
1846
+ this.addJoyStickDragger(subject.canvas.parentElement);
1867
1847
  }
1868
1848
  initialize() {
1869
1849
  super.initialize();
@@ -2046,10 +2026,33 @@
2046
2026
  const volume = [xmax - xmin, ymax - ymin, zmax - zmin];
2047
2027
  return Math.max(...volume);
2048
2028
  }
2049
- processJoyMovement(timestamp) {
2050
- if (!this.moving)
2029
+ addJoyStickDragger(parentElement) {
2030
+ this.joyStickOverlayElement = document.createElement("div");
2031
+ this.joyStickOverlayElement.id = "joyStickDiv";
2032
+ this.joyStickOverlayElement.style.background = "rgba(0,0,0,0)";
2033
+ this.joyStickOverlayElement.style.position = "fixed";
2034
+ this.joyStickOverlayElement.style.zIndex = "0";
2035
+ parentElement.appendChild(this.joyStickOverlayElement);
2036
+ this.joyStickDragger = new OdJoyStickDragger(this, this.joyStickOverlayElement, (stickData) => {
2037
+ if (Math.sqrt(stickData.x * stickData.x + stickData.y * stickData.y) > 20) {
2038
+ this.lastJoyStickCoord = { x: stickData.x, y: stickData.y };
2039
+ if (!this.animationId && !this.isJoyStickMoving) {
2040
+ this.isJoyStickMoving = true;
2041
+ this.processJoyStickMovement(0);
2042
+ }
2043
+ }
2044
+ else {
2045
+ this.isJoyStickMoving = false;
2046
+ window.cancelAnimationFrame(this.animationId);
2047
+ this.animationId = undefined;
2048
+ this.lastFrameJoyStickTS = 0;
2049
+ }
2050
+ }, this.m_module.canvas);
2051
+ }
2052
+ processJoyStickMovement(timestamp) {
2053
+ if (!this.isJoyStickMoving)
2051
2054
  return;
2052
- this.animationId = requestAnimationFrame(this.processJoyMovement);
2055
+ this.animationId = requestAnimationFrame(this.processJoyStickMovement);
2053
2056
  if (this.lastFrameJoyStickTS !== 0) {
2054
2057
  const deltaTS = timestamp - this.lastFrameJoyStickTS;
2055
2058
  if (deltaTS > 0) {
@@ -3056,7 +3059,6 @@
3056
3059
  function resetView(viewer) {
3057
3060
  if (!viewer.visualizeJs)
3058
3061
  return;
3059
- const reset = viewer.getComponent("ResetComponent");
3060
3062
  viewer.executeCommand("setActiveDragger");
3061
3063
  viewer.executeCommand("clearSlices");
3062
3064
  viewer.executeCommand("clearOverlay");
@@ -3065,7 +3067,6 @@
3065
3067
  viewer.executeCommand("showAll");
3066
3068
  viewer.executeCommand("explode", 0);
3067
3069
  viewer.executeCommand("zoomToExtents", true);
3068
- reset.resetCameraPosition();
3069
3070
  viewer.emit({ type: "resetview" });
3070
3071
  }
3071
3072
 
@@ -3580,8 +3581,10 @@
3580
3581
  };
3581
3582
  this.viewer = viewer;
3582
3583
  this.viewer.addEventListener("databasechunk", this.onDatabaseChunk);
3584
+ this.viewer.on("resetview", this.resetCameraPosition);
3583
3585
  }
3584
3586
  dispose() {
3587
+ this.viewer.off("resetview", this.resetCameraPosition);
3585
3588
  this.viewer.removeEventListener("databasechunk", this.onDatabaseChunk);
3586
3589
  }
3587
3590
  resetCameraPosition() {