@xviewer.js/core 1.0.0-alpha.40 → 1.0.0-alpha.42

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/main.js CHANGED
@@ -2753,14 +2753,14 @@ class FreelookVirtualCamera extends VirtualCamera {
2753
2753
  }
2754
2754
  }
2755
2755
  _calculateDistanceScale(scale) {
2756
- this._tempSmoothing = this.smoothing;
2756
+ this._tempRotateSmoothing = this.rotateSmoothing;
2757
2757
  if (this.forbidZ) {
2758
2758
  scale = 1;
2759
2759
  }
2760
2760
  return scale;
2761
2761
  }
2762
2762
  _calculateRotatelDelta(out, loc0, loc1) {
2763
- this._tempSmoothing = this.smoothing;
2763
+ this._tempRotateSmoothing = this.rotateSmoothing;
2764
2764
  const domElement = this.viewer.canvas;
2765
2765
  out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / domElement.height);
2766
2766
  out.y = -out.y;
@@ -2773,7 +2773,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2773
2773
  return out;
2774
2774
  }
2775
2775
  _calculatePanDelta(out, loc0, loc1) {
2776
- this._tempSmoothing = this.smoothing;
2776
+ this._tempRotateSmoothing = this.rotateSmoothing;
2777
2777
  const domElement = this.viewer.canvas;
2778
2778
  out.copy(loc1).sub(loc0).multiplyScalar(this.panSpeed / domElement.height);
2779
2779
  if (this.forbidPanX) {
@@ -2808,17 +2808,24 @@ class FreelookVirtualCamera extends VirtualCamera {
2808
2808
  this._targetPhi = clamp(this._targetPhi, this.phiMin, this.phiMax);
2809
2809
  this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
2810
2810
  }
2811
- gotoPOI({ duration = -1, easing = Easing.Cubic.InOut, springLength = this._targetSpringLength, theta = this._targetTheta, phi = this._targetPhi, lookAt = this._lookAt, fov = this.lens.fov, smoothing = this.smoothing }) {
2811
+ gotoPOI({ duration = -1, easing = Easing.Cubic.InOut, springLength = this._targetSpringLength, theta = this._targetTheta, phi = this._targetPhi, lookAt = this._lookAt, fov = this.lens.fov, smoothing = this.smoothing, rotateSmoothing = this.rotateSmoothing }) {
2812
2812
  this._targetFov = fov;
2813
2813
  this._tempSmoothing = smoothing;
2814
+ this._tempRotateSmoothing = rotateSmoothing;
2814
2815
  this._targetLookAt.copy(lookAt);
2816
+ const t1 = theta % PI2;
2817
+ const t0 = this._spherical.theta = this._spherical.theta % PI2;
2818
+ const thetas = [
2819
+ t1,
2820
+ t1 - PI2,
2821
+ t1 + PI2
2822
+ ];
2823
+ const diffs = thetas.map((v)=>abs(t0 - v));
2824
+ const min = Math.min(...diffs);
2825
+ this._targetTheta = thetas[diffs.findIndex((v)=>v === min)];
2815
2826
  this._targetSpringLength = springLength;
2816
2827
  this._targetPhi = phi;
2817
- this._targetTheta = theta;
2818
2828
  this._calculateTargetSpringArm();
2819
- const theta0 = three.MathUtils.euclideanModulo(this._spherical.theta, PI2);
2820
- const theta1 = theta0 - PI2;
2821
- this._spherical.theta = abs(theta0 - this._targetTheta) < abs(theta1 - this._targetTheta) ? theta0 : theta1;
2822
2829
  if (duration > 0) {
2823
2830
  this.locked = true;
2824
2831
  this.enabled = false;
@@ -2843,8 +2850,9 @@ class FreelookVirtualCamera extends VirtualCamera {
2843
2850
  }
2844
2851
  update(dt) {
2845
2852
  const smoothing = this._tempSmoothing;
2846
- this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, smoothing);
2847
- this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, smoothing);
2853
+ const rotateSmoothing = this._tempRotateSmoothing;
2854
+ this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
2855
+ this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
2848
2856
  this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
2849
2857
  this.lens.fov = FInterpTo(this.lens.fov, this._targetFov, dt, smoothing);
2850
2858
  VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
@@ -2859,7 +2867,8 @@ class FreelookVirtualCamera extends VirtualCamera {
2859
2867
  this._preLoc1 = new three.Vector2();
2860
2868
  this._spherical = new three.Spherical(1, Math.PI / 2);
2861
2869
  this._lookAt = new three.Vector3();
2862
- this._tempSmoothing = 0;
2870
+ this._tempSmoothing = 6;
2871
+ this._tempRotateSmoothing = 6;
2863
2872
  this._targetTheta = 0;
2864
2873
  this._targetPhi = 0;
2865
2874
  this._targetSpringLength = 1;
@@ -2874,6 +2883,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2874
2883
  this.panSpeed = 1;
2875
2884
  this.rotateSpeed = 1;
2876
2885
  this.smoothing = 5;
2886
+ this.rotateSmoothing = 5;
2877
2887
  this.phiMin = ESP;
2878
2888
  this.phiMax = Math.PI - ESP;
2879
2889
  this.thetaMin = -Infinity;
@@ -2941,6 +2951,12 @@ __decorate([
2941
2951
  step: 0.01
2942
2952
  })
2943
2953
  ], FreelookVirtualCamera.prototype, "smoothing", void 0);
2954
+ __decorate([
2955
+ property({
2956
+ dir: "set",
2957
+ step: 0.01
2958
+ })
2959
+ ], FreelookVirtualCamera.prototype, "rotateSmoothing", void 0);
2944
2960
  __decorate([
2945
2961
  property({
2946
2962
  dir: "set",
@@ -4214,12 +4230,12 @@ function parepareWebGL(canvas, props) {
4214
4230
  return null;
4215
4231
  }
4216
4232
 
4217
- var Orientation;
4233
+ exports.Orientation = void 0;
4218
4234
  (function(Orientation) {
4219
4235
  Orientation[Orientation["AUTO"] = 0] = "AUTO";
4220
4236
  Orientation[Orientation["LANDSCAPE"] = 1] = "LANDSCAPE";
4221
4237
  Orientation[Orientation["PORTRAIT"] = 2] = "PORTRAIT";
4222
- })(Orientation || (Orientation = {}));
4238
+ })(exports.Orientation || (exports.Orientation = {}));
4223
4239
 
4224
4240
  class ResourceManager {
4225
4241
  static extension(path) {
@@ -4644,7 +4660,7 @@ class Viewer extends EventEmitter {
4644
4660
  return this;
4645
4661
  }
4646
4662
  resize(width = window.innerWidth, height = window.innerHeight) {
4647
- this._rootRotated = this._orientation === Orientation.LANDSCAPE ? width < height : this._orientation === Orientation.PORTRAIT ? width > height : false;
4663
+ this._rootRotated = this._orientation === exports.Orientation.LANDSCAPE ? width < height : this._orientation === exports.Orientation.PORTRAIT ? width > height : false;
4648
4664
  if (this._rootRotated) {
4649
4665
  let tmp = width;
4650
4666
  width = height;
@@ -4888,7 +4904,7 @@ class Viewer extends EventEmitter {
4888
4904
  near: 0.1,
4889
4905
  far: 1000,
4890
4906
  position: new three.Vector3(0, 0, 4)
4891
- }, targetFrameRate = -1, colorSpace = three.SRGBColorSpace, toneMapping = three.LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", loader = {}, tasker = {}, ...webglOpts } = {}){
4907
+ }, targetFrameRate = -1, colorSpace = three.SRGBColorSpace, toneMapping = three.LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", orientation = exports.Orientation.AUTO, loader = {}, tasker = {}, ...webglOpts } = {}){
4892
4908
  super();
4893
4909
  this._dpr = 1;
4894
4910
  this._width = 1;
@@ -4898,7 +4914,7 @@ class Viewer extends EventEmitter {
4898
4914
  height: 1,
4899
4915
  factor: 1
4900
4916
  };
4901
- this._orientation = Orientation.AUTO;
4917
+ this._orientation = exports.Orientation.AUTO;
4902
4918
  this._running = false;
4903
4919
  this._rootRotated = false;
4904
4920
  this._time = 0;
@@ -4916,6 +4932,7 @@ class Viewer extends EventEmitter {
4916
4932
  this._RENDER_TARGET_FLOAT_TYPE = webgl.RENDER_TARGET_FLOAT_TYPE;
4917
4933
  this._DATA_FLOAT_TYPE = webgl.DATA_FLOAT_TYPE;
4918
4934
  this._dpr = Math.min(maxDPR, window.devicePixelRatio);
4935
+ this._orientation = orientation;
4919
4936
  this._scene = new three.Scene();
4920
4937
  this._camera = applyProps(new three.PerspectiveCamera(), camera);
4921
4938
  this._renderer = new three.WebGLRenderer({