@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/module.js CHANGED
@@ -1065,15 +1065,17 @@ class aLoader {
1065
1065
  const mat = object.material;
1066
1066
  if (Array.isArray(mat)) mat.forEach((v)=>materials[v.name] = v);
1067
1067
  else materials[mat.name] = mat;
1068
- keys.forEach((k)=>{
1069
- let tex = mat[k];
1070
- if (tex) {
1071
- textures[tex.uuid] = tex;
1072
- }
1073
- });
1074
1068
  }
1075
- object.children.forEach((v)=>queue.push(v));
1069
+ queue.push(...object.children);
1076
1070
  }
1071
+ Object.values(materials).forEach((mat)=>{
1072
+ keys.forEach((k)=>{
1073
+ let tex = mat[k];
1074
+ if (tex) {
1075
+ textures[tex.uuid] = tex;
1076
+ }
1077
+ });
1078
+ });
1077
1079
  node.userData.meshData = {
1078
1080
  meshes,
1079
1081
  materials,
@@ -1086,6 +1088,7 @@ class aLoader {
1086
1088
  }
1087
1089
  }
1088
1090
  aLoader._texKeys = [
1091
+ "map",
1089
1092
  "alphaMap",
1090
1093
  "aoMap",
1091
1094
  "bumpMap",
@@ -1096,7 +1099,8 @@ aLoader._texKeys = [
1096
1099
  "metalnessMap",
1097
1100
  "normalMap",
1098
1101
  "roughnessMap",
1099
- "specularMap"
1102
+ "specularMap",
1103
+ "alphaMap"
1100
1104
  ];
1101
1105
 
1102
1106
  class aEXRLoader extends aLoader {
@@ -2751,14 +2755,14 @@ class FreelookVirtualCamera extends VirtualCamera {
2751
2755
  }
2752
2756
  }
2753
2757
  _calculateDistanceScale(scale) {
2754
- this._tempSmoothing = this.smoothing;
2758
+ this._tempRotateSmoothing = this.rotateSmoothing;
2755
2759
  if (this.forbidZ) {
2756
2760
  scale = 1;
2757
2761
  }
2758
2762
  return scale;
2759
2763
  }
2760
2764
  _calculateRotatelDelta(out, loc0, loc1) {
2761
- this._tempSmoothing = this.smoothing;
2765
+ this._tempRotateSmoothing = this.rotateSmoothing;
2762
2766
  const domElement = this.viewer.canvas;
2763
2767
  out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / domElement.height);
2764
2768
  out.y = -out.y;
@@ -2771,7 +2775,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2771
2775
  return out;
2772
2776
  }
2773
2777
  _calculatePanDelta(out, loc0, loc1) {
2774
- this._tempSmoothing = this.smoothing;
2778
+ this._tempRotateSmoothing = this.rotateSmoothing;
2775
2779
  const domElement = this.viewer.canvas;
2776
2780
  out.copy(loc1).sub(loc0).multiplyScalar(this.panSpeed / domElement.height);
2777
2781
  if (this.forbidPanX) {
@@ -2806,17 +2810,24 @@ class FreelookVirtualCamera extends VirtualCamera {
2806
2810
  this._targetPhi = clamp(this._targetPhi, this.phiMin, this.phiMax);
2807
2811
  this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
2808
2812
  }
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 }) {
2813
+ 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
2814
  this._targetFov = fov;
2811
2815
  this._tempSmoothing = smoothing;
2816
+ this._tempRotateSmoothing = rotateSmoothing;
2812
2817
  this._targetLookAt.copy(lookAt);
2818
+ const t1 = theta % PI2;
2819
+ const t0 = this._spherical.theta = this._spherical.theta % PI2;
2820
+ const thetas = [
2821
+ t1,
2822
+ t1 - PI2,
2823
+ t1 + PI2
2824
+ ];
2825
+ const diffs = thetas.map((v)=>abs(t0 - v));
2826
+ const min = Math.min(...diffs);
2827
+ this._targetTheta = thetas[diffs.findIndex((v)=>v === min)];
2813
2828
  this._targetSpringLength = springLength;
2814
2829
  this._targetPhi = phi;
2815
- this._targetTheta = theta;
2816
2830
  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
2831
  if (duration > 0) {
2821
2832
  this.locked = true;
2822
2833
  this.enabled = false;
@@ -2841,8 +2852,9 @@ class FreelookVirtualCamera extends VirtualCamera {
2841
2852
  }
2842
2853
  update(dt) {
2843
2854
  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);
2855
+ const rotateSmoothing = this._tempRotateSmoothing;
2856
+ this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
2857
+ this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
2846
2858
  this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
2847
2859
  this.lens.fov = FInterpTo(this.lens.fov, this._targetFov, dt, smoothing);
2848
2860
  VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
@@ -2857,7 +2869,8 @@ class FreelookVirtualCamera extends VirtualCamera {
2857
2869
  this._preLoc1 = new Vector2();
2858
2870
  this._spherical = new Spherical(1, Math.PI / 2);
2859
2871
  this._lookAt = new Vector3();
2860
- this._tempSmoothing = 0;
2872
+ this._tempSmoothing = 6;
2873
+ this._tempRotateSmoothing = 6;
2861
2874
  this._targetTheta = 0;
2862
2875
  this._targetPhi = 0;
2863
2876
  this._targetSpringLength = 1;
@@ -2872,6 +2885,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2872
2885
  this.panSpeed = 1;
2873
2886
  this.rotateSpeed = 1;
2874
2887
  this.smoothing = 5;
2888
+ this.rotateSmoothing = 5;
2875
2889
  this.phiMin = ESP;
2876
2890
  this.phiMax = Math.PI - ESP;
2877
2891
  this.thetaMin = -Infinity;
@@ -2939,6 +2953,12 @@ __decorate([
2939
2953
  step: 0.01
2940
2954
  })
2941
2955
  ], FreelookVirtualCamera.prototype, "smoothing", void 0);
2956
+ __decorate([
2957
+ property({
2958
+ dir: "set",
2959
+ step: 0.01
2960
+ })
2961
+ ], FreelookVirtualCamera.prototype, "rotateSmoothing", void 0);
2942
2962
  __decorate([
2943
2963
  property({
2944
2964
  dir: "set",
@@ -4886,7 +4906,7 @@ class Viewer extends EventEmitter {
4886
4906
  near: 0.1,
4887
4907
  far: 1000,
4888
4908
  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 } = {}){
4909
+ }, 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
4910
  super();
4891
4911
  this._dpr = 1;
4892
4912
  this._width = 1;
@@ -4914,6 +4934,7 @@ class Viewer extends EventEmitter {
4914
4934
  this._RENDER_TARGET_FLOAT_TYPE = webgl.RENDER_TARGET_FLOAT_TYPE;
4915
4935
  this._DATA_FLOAT_TYPE = webgl.DATA_FLOAT_TYPE;
4916
4936
  this._dpr = Math.min(maxDPR, window.devicePixelRatio);
4937
+ this._orientation = orientation;
4917
4938
  this._scene = new Scene();
4918
4939
  this._camera = applyProps(new PerspectiveCamera(), camera);
4919
4940
  this._renderer = new WebGLRenderer({
@@ -5431,5 +5452,5 @@ __decorate([
5431
5452
  property
5432
5453
  ], BoxProjectionPlugin.prototype, "boxMax", null);
5433
5454
 
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 };
5455
+ 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
5456
  //# sourceMappingURL=module.js.map