@inweb/viewer-three 26.10.4 → 26.10.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.
@@ -21,7 +21,7 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { draggersRegistry, commandsRegistry, componentsRegistry, Loader, loadersRegistry, Options, CANVAS_EVENTS } from '@inweb/viewer-core';
24
+ import { draggersRegistry, commandsRegistry, Options, componentsRegistry, Loader, loadersRegistry, CANVAS_EVENTS } from '@inweb/viewer-core';
25
25
  export * from '@inweb/viewer-core';
26
26
  import { Line, Vector3, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, EventDispatcher, MOUSE, TOUCH, Spherical, Quaternion, Vector2, Plane, Object3D, Line3, Matrix4, Vector4, MathUtils, Raycaster, EdgesGeometry, Controls, Clock, Sphere, Box3, Color, PerspectiveCamera, OrthographicCamera, AmbientLight, DirectionalLight, HemisphereLight, MeshPhongMaterial, WebGLRenderTarget, UnsignedByteType, RGBAFormat, CylinderGeometry, Sprite, CanvasTexture, SRGBColorSpace, SpriteMaterial, LoadingManager, LoaderUtils, TextureLoader, BufferAttribute, PointsMaterial, Points, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, LineLoop, Group, NormalBlending, UniformsUtils, ShaderMaterial, AdditiveBlending, HalfFloatType, Scene, WebGLRenderer, LinearSRGBColorSpace } from 'three';
27
27
  import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
@@ -752,6 +752,9 @@ class OrbitDragger {
752
752
  this.orbit.object = this.viewer.camera;
753
753
  this.orbit.update();
754
754
  };
755
+ this.optionsChange = ({ data: options }) => {
756
+ this.orbit.zoomSpeed = Math.abs(this.orbit.zoomSpeed) * (options.reverseZoomWheel ? -1 : 1);
757
+ };
755
758
  this.controlsStart = () => {
756
759
  this.changed = false;
757
760
  };
@@ -807,6 +810,7 @@ class OrbitDragger {
807
810
  this.viewer.addEventListener("zoom", this.updateControls);
808
811
  this.viewer.addEventListener("drawviewpoint", this.updateControls);
809
812
  this.viewer.addEventListener("changecameramode", this.updateControlsCamera);
813
+ this.viewer.addEventListener("optionschange", this.optionsChange);
810
814
  this.viewer.addEventListener("contextmenu", this.stopContextMenu);
811
815
  this.updateControls();
812
816
  }
@@ -817,6 +821,7 @@ class OrbitDragger {
817
821
  this.viewer.removeEventListener("zoom", this.updateControls);
818
822
  this.viewer.removeEventListener("drawviewpoint", this.updateControls);
819
823
  this.viewer.removeEventListener("changecameramode", this.updateControlsCamera);
824
+ this.viewer.removeEventListener("optionschange", this.optionsChange);
820
825
  this.viewer.removeEventListener("contextmenu", this.stopContextMenu);
821
826
  this.orbit.removeEventListener("start", this.controlsStart);
822
827
  this.orbit.removeEventListener("change", this.controlsChange);
@@ -1126,12 +1131,14 @@ class MeasureSnapper {
1126
1131
  class MeasureOverlay {
1127
1132
  constructor(camera, canvas) {
1128
1133
  this.lines = [];
1129
- this.resizeContainer = (entries) => {
1130
- const { width, height } = entries[0].contentRect;
1131
- if (!width || !height)
1134
+ this.resizeContainer = () => {
1135
+ const { offsetLeft, offsetTop, offsetWidth, offsetHeight } = this.canvas;
1136
+ if (!offsetWidth || !offsetHeight)
1132
1137
  return;
1133
- this.container.style.width = `${width}px`;
1134
- this.container.style.height = `${height}px`;
1138
+ this.container.style.left = `${offsetLeft}px`;
1139
+ this.container.style.top = `${offsetTop}px`;
1140
+ this.container.style.width = `${offsetWidth}px`;
1141
+ this.container.style.height = `${offsetHeight}px`;
1135
1142
  };
1136
1143
  this.camera = camera;
1137
1144
  this.canvas = canvas;
@@ -1148,7 +1155,7 @@ class MeasureOverlay {
1148
1155
  if (!this.canvas.parentElement)
1149
1156
  return;
1150
1157
  this.canvas.parentElement.appendChild(this.container);
1151
- this.resizeObserver.observe(this.canvas.parentElement);
1158
+ this.resizeObserver.observe(this.canvas);
1152
1159
  }
1153
1160
  dispose() {
1154
1161
  this.clear();
@@ -2701,8 +2708,9 @@ class HighlighterComponent {
2701
2708
  });
2702
2709
  }
2703
2710
  syncHighlightColors() {
2704
- const { facesColor, facesTransparancy, facesOverlap } = this.viewer.options;
2705
- const { edgesColor, edgesVisibility, edgesOverlap } = this.viewer.options;
2711
+ const options = this.viewer.options.enableCustomHighlight ? this.viewer.options : Options.defaults();
2712
+ const { facesColor, facesTransparancy, facesOverlap } = options;
2713
+ const { edgesColor, edgesVisibility, edgesOverlap } = options;
2706
2714
  this.facesMaterial.color.setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
2707
2715
  this.facesMaterial.opacity = (255 - facesTransparancy) / 255;
2708
2716
  this.facesMaterial.depthTest = !facesOverlap;