@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/module.js CHANGED
@@ -2751,14 +2751,14 @@ class FreelookVirtualCamera extends VirtualCamera {
2751
2751
  }
2752
2752
  }
2753
2753
  _calculateDistanceScale(scale) {
2754
- this._tempSmoothing = this.smoothing;
2754
+ this._tempRotateSmoothing = this.rotateSmoothing;
2755
2755
  if (this.forbidZ) {
2756
2756
  scale = 1;
2757
2757
  }
2758
2758
  return scale;
2759
2759
  }
2760
2760
  _calculateRotatelDelta(out, loc0, loc1) {
2761
- this._tempSmoothing = this.smoothing;
2761
+ this._tempRotateSmoothing = this.rotateSmoothing;
2762
2762
  const domElement = this.viewer.canvas;
2763
2763
  out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / domElement.height);
2764
2764
  out.y = -out.y;
@@ -2771,7 +2771,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2771
2771
  return out;
2772
2772
  }
2773
2773
  _calculatePanDelta(out, loc0, loc1) {
2774
- this._tempSmoothing = this.smoothing;
2774
+ this._tempRotateSmoothing = this.rotateSmoothing;
2775
2775
  const domElement = this.viewer.canvas;
2776
2776
  out.copy(loc1).sub(loc0).multiplyScalar(this.panSpeed / domElement.height);
2777
2777
  if (this.forbidPanX) {
@@ -2806,17 +2806,24 @@ class FreelookVirtualCamera extends VirtualCamera {
2806
2806
  this._targetPhi = clamp(this._targetPhi, this.phiMin, this.phiMax);
2807
2807
  this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
2808
2808
  }
2809
- 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 }) {
2809
+ 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 }) {
2810
2810
  this._targetFov = fov;
2811
2811
  this._tempSmoothing = smoothing;
2812
+ this._tempRotateSmoothing = rotateSmoothing;
2812
2813
  this._targetLookAt.copy(lookAt);
2814
+ const t1 = theta % PI2;
2815
+ const t0 = this._spherical.theta = this._spherical.theta % PI2;
2816
+ const thetas = [
2817
+ t1,
2818
+ t1 - PI2,
2819
+ t1 + PI2
2820
+ ];
2821
+ const diffs = thetas.map((v)=>abs(t0 - v));
2822
+ const min = Math.min(...diffs);
2823
+ this._targetTheta = thetas[diffs.findIndex((v)=>v === min)];
2813
2824
  this._targetSpringLength = springLength;
2814
2825
  this._targetPhi = phi;
2815
- this._targetTheta = theta;
2816
2826
  this._calculateTargetSpringArm();
2817
- const theta0 = MathUtils.euclideanModulo(this._spherical.theta, PI2);
2818
- const theta1 = theta0 - PI2;
2819
- this._spherical.theta = abs(theta0 - this._targetTheta) < abs(theta1 - this._targetTheta) ? theta0 : theta1;
2820
2827
  if (duration > 0) {
2821
2828
  this.locked = true;
2822
2829
  this.enabled = false;
@@ -2841,8 +2848,9 @@ class FreelookVirtualCamera extends VirtualCamera {
2841
2848
  }
2842
2849
  update(dt) {
2843
2850
  const smoothing = this._tempSmoothing;
2844
- this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, smoothing);
2845
- this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, smoothing);
2851
+ const rotateSmoothing = this._tempRotateSmoothing;
2852
+ this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
2853
+ this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
2846
2854
  this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
2847
2855
  this.lens.fov = FInterpTo(this.lens.fov, this._targetFov, dt, smoothing);
2848
2856
  VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
@@ -2857,7 +2865,8 @@ class FreelookVirtualCamera extends VirtualCamera {
2857
2865
  this._preLoc1 = new Vector2();
2858
2866
  this._spherical = new Spherical(1, Math.PI / 2);
2859
2867
  this._lookAt = new Vector3();
2860
- this._tempSmoothing = 0;
2868
+ this._tempSmoothing = 6;
2869
+ this._tempRotateSmoothing = 6;
2861
2870
  this._targetTheta = 0;
2862
2871
  this._targetPhi = 0;
2863
2872
  this._targetSpringLength = 1;
@@ -2872,6 +2881,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2872
2881
  this.panSpeed = 1;
2873
2882
  this.rotateSpeed = 1;
2874
2883
  this.smoothing = 5;
2884
+ this.rotateSmoothing = 5;
2875
2885
  this.phiMin = ESP;
2876
2886
  this.phiMax = Math.PI - ESP;
2877
2887
  this.thetaMin = -Infinity;
@@ -2939,6 +2949,12 @@ __decorate([
2939
2949
  step: 0.01
2940
2950
  })
2941
2951
  ], FreelookVirtualCamera.prototype, "smoothing", void 0);
2952
+ __decorate([
2953
+ property({
2954
+ dir: "set",
2955
+ step: 0.01
2956
+ })
2957
+ ], FreelookVirtualCamera.prototype, "rotateSmoothing", void 0);
2942
2958
  __decorate([
2943
2959
  property({
2944
2960
  dir: "set",
@@ -4886,7 +4902,7 @@ class Viewer extends EventEmitter {
4886
4902
  near: 0.1,
4887
4903
  far: 1000,
4888
4904
  position: new Vector3(0, 0, 4)
4889
- }, targetFrameRate = -1, colorSpace = SRGBColorSpace, toneMapping = LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", loader = {}, tasker = {}, ...webglOpts } = {}){
4905
+ }, targetFrameRate = -1, colorSpace = SRGBColorSpace, toneMapping = LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", orientation = Orientation.AUTO, loader = {}, tasker = {}, ...webglOpts } = {}){
4890
4906
  super();
4891
4907
  this._dpr = 1;
4892
4908
  this._width = 1;
@@ -4914,6 +4930,7 @@ class Viewer extends EventEmitter {
4914
4930
  this._RENDER_TARGET_FLOAT_TYPE = webgl.RENDER_TARGET_FLOAT_TYPE;
4915
4931
  this._DATA_FLOAT_TYPE = webgl.DATA_FLOAT_TYPE;
4916
4932
  this._dpr = Math.min(maxDPR, window.devicePixelRatio);
4933
+ this._orientation = orientation;
4917
4934
  this._scene = new Scene();
4918
4935
  this._camera = applyProps(new PerspectiveCamera(), camera);
4919
4936
  this._renderer = new WebGLRenderer({
@@ -5431,5 +5448,5 @@ __decorate([
5431
5448
  property
5432
5449
  ], BoxProjectionPlugin.prototype, "boxMax", null);
5433
5450
 
5434
- export { AnimationCurve, Box, BoxProjectionPlugin, CinestationBlendDefinition, CinestationBrain, Component, DebugPlugin, DeviceInput, Easing, EnvironmentPlugin, EventEmitter, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, Logger, ObjectInstance, Perlin, Plane, Plugin, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, Reflector, ReflectorMaterial, Sphere, SystemInfo, Tween, TweenChain, TweenManager, VInterpConstantTo, VInterpTo, Vec3_smoothDamp, Vector3_NEG_ONE, Vector3_ONE, Vector3_RIGHT, Vector3_UNIT_X, Vector3_UNIT_Y, Vector3_UNIT_Z, Vector3_UP, Vector3_ZERO, Viewer, VirtualCamera, aEXRLoader, aFBXLoader, aGLTFLoader, aHDRLoader, aJSONLoader, aLoader, aTextureLoader, exponentialDamp, frag_BoxfilterBlur, frag_cubeMapToPanorama, frag_panoramaToCubeMap, getClassInstance, getShaderMaterial, mixin, property, quarticDamp, smoothDamp, vert_fullscreen };
5451
+ export { AnimationCurve, Box, BoxProjectionPlugin, CinestationBlendDefinition, CinestationBrain, Component, DebugPlugin, DeviceInput, Easing, EnvironmentPlugin, EventEmitter, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, Logger, ObjectInstance, Orientation, Perlin, Plane, Plugin, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, Reflector, ReflectorMaterial, Sphere, SystemInfo, Tween, TweenChain, TweenManager, VInterpConstantTo, VInterpTo, Vec3_smoothDamp, Vector3_NEG_ONE, Vector3_ONE, Vector3_RIGHT, Vector3_UNIT_X, Vector3_UNIT_Y, Vector3_UNIT_Z, Vector3_UP, Vector3_ZERO, Viewer, VirtualCamera, aEXRLoader, aFBXLoader, aGLTFLoader, aHDRLoader, aJSONLoader, aLoader, aTextureLoader, exponentialDamp, frag_BoxfilterBlur, frag_cubeMapToPanorama, frag_panoramaToCubeMap, getClassInstance, getShaderMaterial, mixin, property, quarticDamp, smoothDamp, vert_fullscreen };
5435
5452
  //# sourceMappingURL=module.js.map