@xviewer.js/core 1.0.0-alpha.41 → 1.0.0-alpha.43

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
@@ -1067,15 +1067,17 @@ class aLoader {
1067
1067
  const mat = object.material;
1068
1068
  if (Array.isArray(mat)) mat.forEach((v)=>materials[v.name] = v);
1069
1069
  else materials[mat.name] = mat;
1070
- keys.forEach((k)=>{
1071
- let tex = mat[k];
1072
- if (tex) {
1073
- textures[tex.uuid] = tex;
1074
- }
1075
- });
1076
1070
  }
1077
- object.children.forEach((v)=>queue.push(v));
1071
+ queue.push(...object.children);
1078
1072
  }
1073
+ Object.values(materials).forEach((mat)=>{
1074
+ keys.forEach((k)=>{
1075
+ let tex = mat[k];
1076
+ if (tex) {
1077
+ textures[tex.uuid] = tex;
1078
+ }
1079
+ });
1080
+ });
1079
1081
  node.userData.meshData = {
1080
1082
  meshes,
1081
1083
  materials,
@@ -1088,6 +1090,7 @@ class aLoader {
1088
1090
  }
1089
1091
  }
1090
1092
  aLoader._texKeys = [
1093
+ "map",
1091
1094
  "alphaMap",
1092
1095
  "aoMap",
1093
1096
  "bumpMap",
@@ -1098,7 +1101,8 @@ aLoader._texKeys = [
1098
1101
  "metalnessMap",
1099
1102
  "normalMap",
1100
1103
  "roughnessMap",
1101
- "specularMap"
1104
+ "specularMap",
1105
+ "alphaMap"
1102
1106
  ];
1103
1107
 
1104
1108
  class aEXRLoader extends aLoader {
@@ -2753,14 +2757,14 @@ class FreelookVirtualCamera extends VirtualCamera {
2753
2757
  }
2754
2758
  }
2755
2759
  _calculateDistanceScale(scale) {
2756
- this._tempSmoothing = this.smoothing;
2760
+ this._tempRotateSmoothing = this.rotateSmoothing;
2757
2761
  if (this.forbidZ) {
2758
2762
  scale = 1;
2759
2763
  }
2760
2764
  return scale;
2761
2765
  }
2762
2766
  _calculateRotatelDelta(out, loc0, loc1) {
2763
- this._tempSmoothing = this.smoothing;
2767
+ this._tempRotateSmoothing = this.rotateSmoothing;
2764
2768
  const domElement = this.viewer.canvas;
2765
2769
  out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / domElement.height);
2766
2770
  out.y = -out.y;
@@ -2773,7 +2777,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2773
2777
  return out;
2774
2778
  }
2775
2779
  _calculatePanDelta(out, loc0, loc1) {
2776
- this._tempSmoothing = this.smoothing;
2780
+ this._tempRotateSmoothing = this.rotateSmoothing;
2777
2781
  const domElement = this.viewer.canvas;
2778
2782
  out.copy(loc1).sub(loc0).multiplyScalar(this.panSpeed / domElement.height);
2779
2783
  if (this.forbidPanX) {
@@ -2808,17 +2812,24 @@ class FreelookVirtualCamera extends VirtualCamera {
2808
2812
  this._targetPhi = clamp(this._targetPhi, this.phiMin, this.phiMax);
2809
2813
  this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
2810
2814
  }
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 }) {
2815
+ 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
2816
  this._targetFov = fov;
2813
2817
  this._tempSmoothing = smoothing;
2818
+ this._tempRotateSmoothing = rotateSmoothing;
2814
2819
  this._targetLookAt.copy(lookAt);
2820
+ const t1 = theta % PI2;
2821
+ const t0 = this._spherical.theta = this._spherical.theta % PI2;
2822
+ const thetas = [
2823
+ t1,
2824
+ t1 - PI2,
2825
+ t1 + PI2
2826
+ ];
2827
+ const diffs = thetas.map((v)=>abs(t0 - v));
2828
+ const min = Math.min(...diffs);
2829
+ this._targetTheta = thetas[diffs.findIndex((v)=>v === min)];
2815
2830
  this._targetSpringLength = springLength;
2816
2831
  this._targetPhi = phi;
2817
- this._targetTheta = theta;
2818
2832
  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
2833
  if (duration > 0) {
2823
2834
  this.locked = true;
2824
2835
  this.enabled = false;
@@ -2843,8 +2854,9 @@ class FreelookVirtualCamera extends VirtualCamera {
2843
2854
  }
2844
2855
  update(dt) {
2845
2856
  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);
2857
+ const rotateSmoothing = this._tempRotateSmoothing;
2858
+ this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
2859
+ this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
2848
2860
  this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
2849
2861
  this.lens.fov = FInterpTo(this.lens.fov, this._targetFov, dt, smoothing);
2850
2862
  VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
@@ -2859,7 +2871,8 @@ class FreelookVirtualCamera extends VirtualCamera {
2859
2871
  this._preLoc1 = new three.Vector2();
2860
2872
  this._spherical = new three.Spherical(1, Math.PI / 2);
2861
2873
  this._lookAt = new three.Vector3();
2862
- this._tempSmoothing = 0;
2874
+ this._tempSmoothing = 6;
2875
+ this._tempRotateSmoothing = 6;
2863
2876
  this._targetTheta = 0;
2864
2877
  this._targetPhi = 0;
2865
2878
  this._targetSpringLength = 1;
@@ -2874,6 +2887,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2874
2887
  this.panSpeed = 1;
2875
2888
  this.rotateSpeed = 1;
2876
2889
  this.smoothing = 5;
2890
+ this.rotateSmoothing = 5;
2877
2891
  this.phiMin = ESP;
2878
2892
  this.phiMax = Math.PI - ESP;
2879
2893
  this.thetaMin = -Infinity;
@@ -2941,6 +2955,12 @@ __decorate([
2941
2955
  step: 0.01
2942
2956
  })
2943
2957
  ], FreelookVirtualCamera.prototype, "smoothing", void 0);
2958
+ __decorate([
2959
+ property({
2960
+ dir: "set",
2961
+ step: 0.01
2962
+ })
2963
+ ], FreelookVirtualCamera.prototype, "rotateSmoothing", void 0);
2944
2964
  __decorate([
2945
2965
  property({
2946
2966
  dir: "set",
@@ -4214,12 +4234,12 @@ function parepareWebGL(canvas, props) {
4214
4234
  return null;
4215
4235
  }
4216
4236
 
4217
- var Orientation;
4237
+ exports.Orientation = void 0;
4218
4238
  (function(Orientation) {
4219
4239
  Orientation[Orientation["AUTO"] = 0] = "AUTO";
4220
4240
  Orientation[Orientation["LANDSCAPE"] = 1] = "LANDSCAPE";
4221
4241
  Orientation[Orientation["PORTRAIT"] = 2] = "PORTRAIT";
4222
- })(Orientation || (Orientation = {}));
4242
+ })(exports.Orientation || (exports.Orientation = {}));
4223
4243
 
4224
4244
  class ResourceManager {
4225
4245
  static extension(path) {
@@ -4644,7 +4664,7 @@ class Viewer extends EventEmitter {
4644
4664
  return this;
4645
4665
  }
4646
4666
  resize(width = window.innerWidth, height = window.innerHeight) {
4647
- this._rootRotated = this._orientation === Orientation.LANDSCAPE ? width < height : this._orientation === Orientation.PORTRAIT ? width > height : false;
4667
+ this._rootRotated = this._orientation === exports.Orientation.LANDSCAPE ? width < height : this._orientation === exports.Orientation.PORTRAIT ? width > height : false;
4648
4668
  if (this._rootRotated) {
4649
4669
  let tmp = width;
4650
4670
  width = height;
@@ -4888,7 +4908,7 @@ class Viewer extends EventEmitter {
4888
4908
  near: 0.1,
4889
4909
  far: 1000,
4890
4910
  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 } = {}){
4911
+ }, 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
4912
  super();
4893
4913
  this._dpr = 1;
4894
4914
  this._width = 1;
@@ -4898,7 +4918,7 @@ class Viewer extends EventEmitter {
4898
4918
  height: 1,
4899
4919
  factor: 1
4900
4920
  };
4901
- this._orientation = Orientation.AUTO;
4921
+ this._orientation = exports.Orientation.AUTO;
4902
4922
  this._running = false;
4903
4923
  this._rootRotated = false;
4904
4924
  this._time = 0;
@@ -4916,6 +4936,7 @@ class Viewer extends EventEmitter {
4916
4936
  this._RENDER_TARGET_FLOAT_TYPE = webgl.RENDER_TARGET_FLOAT_TYPE;
4917
4937
  this._DATA_FLOAT_TYPE = webgl.DATA_FLOAT_TYPE;
4918
4938
  this._dpr = Math.min(maxDPR, window.devicePixelRatio);
4939
+ this._orientation = orientation;
4919
4940
  this._scene = new three.Scene();
4920
4941
  this._camera = applyProps(new three.PerspectiveCamera(), camera);
4921
4942
  this._renderer = new three.WebGLRenderer({