three-cad-viewer 1.5.8 → 1.5.9

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/Readme.md CHANGED
@@ -128,3 +128,7 @@ v1.5.8
128
128
 
129
129
  - fixed glass and tools paramewter handling
130
130
  - fixed initial zoom for wide cad views with low height
131
+
132
+ v1.5.9
133
+
134
+ - fixed a regression from v1.5.8 around initial zoom value handling)
@@ -57030,6 +57030,13 @@ class Controls {
57030
57030
  return this.controls.target;
57031
57031
  }
57032
57032
 
57033
+ /**
57034
+ * Get the initial zoom value of the camera.
57035
+ **/
57036
+ getZoom0() {
57037
+ return this.controls.zoom0;
57038
+ }
57039
+
57033
57040
  /**
57034
57041
  * Get the lookAt target of the camera.
57035
57042
  * @param {number[]} target - camera target as THREE.Vector3.
@@ -57551,11 +57558,10 @@ class Viewer {
57551
57558
  this.position = null;
57552
57559
  this.quaternion = null;
57553
57560
  this.target = null;
57554
- this.zoom = null;
57561
+
57562
+ this.zoom = 4 / 3;
57555
57563
  if (this.cadWidth >= this.height) {
57556
- this.zoom0 = (4 / 3) * (this.height / this.cadWidth);
57557
- } else {
57558
- this.zoom0 = 4 / 3;
57564
+ this.zoom *= this.height / this.cadWidth;
57559
57565
  }
57560
57566
 
57561
57567
  this.panSpeed = 0.5;
@@ -57613,7 +57619,7 @@ class Viewer {
57613
57619
  console.log("- glass", this.glass);
57614
57620
  console.log("- transparent", this.transparent);
57615
57621
  console.log("- zoom", this.zoom);
57616
- console.log("- zoom0", this.zoom0);
57622
+ console.log("- zoom0", this.controls.getZoom0());
57617
57623
  console.log("- zoomSpeed", this.zoomSpeed);
57618
57624
  }
57619
57625
  // - - - - - - - - - - - - - - - - - - - - - - - -
@@ -57952,7 +57958,6 @@ class Viewer {
57952
57958
  * @param {ViewerOptions} options - the Viewer options
57953
57959
  */
57954
57960
  render(group, tree, states, options) {
57955
- console.log(options);
57956
57961
  this.setViewerDefaults(options);
57957
57962
 
57958
57963
  this.animation.cleanBackup();
@@ -58018,10 +58023,10 @@ class Viewer {
58018
58023
 
58019
58024
  // this needs to happen after the controls have been established
58020
58025
  if (options.position == null && options.quaternion == null) {
58021
- this.presetCamera("iso", options.zoom);
58026
+ this.presetCamera("iso", this.zoom);
58022
58027
  this.display.highlightButton("iso");
58023
58028
  } else if (options.position != null) {
58024
- this.setCamera(false, options.position, options.quaternion, options.zoom);
58029
+ this.setCamera(false, options.position, options.quaternion, this.zoom);
58025
58030
  if (options.quaternion == null) {
58026
58031
  this.camera.lookAtTarget();
58027
58032
  }
@@ -58029,7 +58034,7 @@ class Viewer {
58029
58034
  this.info.addHtml(
58030
58035
  "<b>quaternion needs position to be provided, falling back to ISO view</b>",
58031
58036
  );
58032
- this.presetCamera("iso", options.zoom);
58037
+ this.presetCamera("iso", this.zoom);
58033
58038
  }
58034
58039
  this.controls.update();
58035
58040
 
@@ -58175,7 +58180,6 @@ class Viewer {
58175
58180
  );
58176
58181
 
58177
58182
  this.display.autoCollapse();
58178
- this.resize();
58179
58183
 
58180
58184
  //
58181
58185
  // show the rendering
@@ -58273,7 +58277,7 @@ class Viewer {
58273
58277
  * @function
58274
58278
  */
58275
58279
  resize = () => {
58276
- this.camera.setZoom(this.zoom0);
58280
+ this.camera.setZoom(this.controls.getZoom0());
58277
58281
  this.camera.updateProjectionMatrix();
58278
58282
  this.update(true);
58279
58283
  };