@xviewer.js/core 1.0.5-alhpa.1 → 1.0.5-alhpa.3

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
@@ -4,8 +4,8 @@ import { GLTFLoader as GLTFLoader$1 } from 'three/examples/jsm/loaders/GLTFLoade
4
4
  import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
5
5
  import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
6
6
  import * as THREE from 'three';
7
- import { EquirectangularReflectionMapping, FileLoader, TextureLoader as TextureLoader$1, SRGBColorSpace, CubeUVReflectionMapping, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, MathUtils, Vector3, Vector2, LinearInterpolant, Object3D, Plane as Plane$1, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, LinearMipMapLinearFilter, LinearFilter, HalfFloatType, AnimationMixer, Color, OrthographicCamera, MeshDepthMaterial, ShaderMaterial, Euler, Group, REVISION, Box3, Sphere as Sphere$1, Raycaster, Quaternion, Spherical, UniformsUtils, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, LinearSRGBColorSpace, NearestFilter, ClampToEdgeWrapping, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, BufferGeometry, Float32BufferAttribute, Scene, WebGLRenderer, LinearToneMapping, PCFSoftShadowMap, LoadingManager, PMREMGenerator, CubeCamera, ShaderLib, ShaderChunk, BufferAttribute, NormalBlending } from 'three';
8
- import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
7
+ import { EquirectangularReflectionMapping, FileLoader, TextureLoader as TextureLoader$1, SRGBColorSpace, CubeUVReflectionMapping, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, MathUtils, Vector3, Vector2, LinearInterpolant, Object3D, Matrix4, Plane as Plane$1, Vector4, PerspectiveCamera, WebGLRenderTarget, LinearMipMapLinearFilter, LinearFilter, HalfFloatType, AnimationMixer, Color, OrthographicCamera, MeshDepthMaterial, ShaderMaterial, Euler, Group, REVISION, Box3, Sphere as Sphere$1, Raycaster, Quaternion, Spherical, UniformsUtils, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, LinearSRGBColorSpace, NearestFilter, ClampToEdgeWrapping, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, BufferGeometry, Float32BufferAttribute, Scene, WebGLRenderer, LinearToneMapping, PCFSoftShadowMap, LoadingManager, PMREMGenerator, CubeCamera, ShaderLib, ShaderChunk, BufferAttribute, NormalBlending } from 'three';
8
+ import { HDRLoader as HDRLoader$1 } from 'three/examples/jsm/loaders/HDRLoader.js';
9
9
  import { SVGLoader as SVGLoader$1 } from 'three/examples/jsm/loaders/SVGLoader.js';
10
10
  import { KTX2Loader as KTX2Loader$1 } from 'three/examples/jsm/loaders/KTX2Loader.js';
11
11
  import { HorizontalBlurShader, VerticalBlurShader } from 'three/examples/jsm/Addons.js';
@@ -253,10 +253,28 @@ class GLTFLoader extends Loader {
253
253
  loader.manager = manager;
254
254
  loader.setPath(path);
255
255
  loader.setResourcePath(resourcePath);
256
+ const cb = (gltf)=>{
257
+ const meshes = new Map();
258
+ const materials = new Map();
259
+ gltf.scene.traverse((mesh)=>{
260
+ if (mesh.isMesh) {
261
+ gltf.mesh = mesh;
262
+ gltf.material = mesh.material;
263
+ meshes.set(mesh.name, mesh);
264
+ const arr = Array.isArray(mesh.material) ? mesh.material : [
265
+ mesh.material
266
+ ];
267
+ arr.forEach((m)=>materials.set(m.name, m));
268
+ }
269
+ });
270
+ gltf.meshes = meshes;
271
+ gltf.materials = materials;
272
+ onLoad(gltf);
273
+ };
256
274
  if (buffer) {
257
- loader.parse(buffer, resourcePath, onLoad, onError);
275
+ loader.parse(buffer, resourcePath, cb, onError);
258
276
  } else {
259
- loader.load(url, onLoad, onProgress, onError);
277
+ loader.load(url, cb, onProgress, onError);
260
278
  }
261
279
  }
262
280
  constructor(...args){
@@ -271,7 +289,7 @@ class HDRLoader extends Loader {
271
289
  load({ url, path, resourcePath, manager, texSettings, onLoad, onProgress, onError }) {
272
290
  let loader = this._loader;
273
291
  if (loader === undefined) {
274
- loader = this._loader = new RGBELoader();
292
+ loader = this._loader = new HDRLoader$1();
275
293
  }
276
294
  loader.manager = manager;
277
295
  loader.setPath(path);
@@ -1310,8 +1328,17 @@ class Component extends ObjectInstance {
1310
1328
  }
1311
1329
 
1312
1330
  class Reflector extends Component {
1331
+ get texture() {
1332
+ return this._renderTarget.texture;
1333
+ }
1334
+ get textureMatrix() {
1335
+ return this._textureMatrix;
1336
+ }
1337
+ onDestroy() {
1338
+ this._renderTarget.dispose();
1339
+ }
1313
1340
  constructor({ resolution = 512, clipBias = 0, multisample = 4, layerMask = 1 << 0, normal = new Vector3(0, 1, 0), mipmap = false } = {}){
1314
- super(), this.node = new Object3D(), this.layerMask = 1 << 0;
1341
+ super(), this.node = new Object3D(), this.layerMask = 1 << 0, this._renderTarget = null, this._textureMatrix = new Matrix4();
1315
1342
  this.layerMask = layerMask;
1316
1343
  const reflectorPlane = new Plane$1();
1317
1344
  const reflectorNormal = new Vector3();
@@ -1323,15 +1350,14 @@ class Reflector extends Component {
1323
1350
  const view = new Vector3();
1324
1351
  const target = new Vector3();
1325
1352
  const q = new Vector4();
1326
- const textureMatrix = new Matrix4();
1327
1353
  const virtualCamera = new PerspectiveCamera();
1328
- const renderTarget = new WebGLRenderTarget(resolution, resolution, {
1354
+ this._renderTarget = new WebGLRenderTarget(resolution, resolution, {
1329
1355
  samples: multisample,
1330
1356
  type: HalfFloatType,
1331
1357
  minFilter: mipmap ? LinearMipMapLinearFilter : LinearFilter,
1332
1358
  generateMipmaps: mipmap
1333
1359
  });
1334
- const update = ()=>{
1360
+ this.lastUpdate = ()=>{
1335
1361
  const node = this.node;
1336
1362
  const { renderer, camera, scene } = this.context;
1337
1363
  reflectorWorldPosition.setFromMatrixPosition(node.matrixWorld);
@@ -1362,9 +1388,9 @@ class Reflector extends Component {
1362
1388
  virtualCamera.updateMatrixWorld();
1363
1389
  virtualCamera.projectionMatrix.copy(camera.projectionMatrix);
1364
1390
  // Update the texture matrix
1365
- textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
1366
- textureMatrix.multiply(virtualCamera.projectionMatrix);
1367
- textureMatrix.multiply(virtualCamera.matrixWorldInverse);
1391
+ this.textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
1392
+ this.textureMatrix.multiply(virtualCamera.projectionMatrix);
1393
+ this.textureMatrix.multiply(virtualCamera.matrixWorldInverse);
1368
1394
  // Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
1369
1395
  // Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
1370
1396
  reflectorPlane.setFromNormalAndCoplanarPoint(reflectorNormal, reflectorWorldPosition);
@@ -1393,7 +1419,7 @@ class Reflector extends Component {
1393
1419
  renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
1394
1420
  const clearAlpha = renderer.getClearAlpha();
1395
1421
  renderer.setClearAlpha(0);
1396
- renderer.setRenderTarget(renderTarget);
1422
+ renderer.setRenderTarget(this._renderTarget);
1397
1423
  renderer.state.buffers.depth.setMask(true); // make sure the depth buffer is writable so it can be properly cleared, see #18897
1398
1424
  if (renderer.autoClear === false) renderer.clear();
1399
1425
  renderer.render(scene, virtualCamera);
@@ -1408,10 +1434,6 @@ class Reflector extends Component {
1408
1434
  }
1409
1435
  node.visible = true;
1410
1436
  };
1411
- this.lastUpdate = update;
1412
- this.onDestroy = ()=>renderTarget.dispose();
1413
- this.getRenderTarget = ()=>renderTarget;
1414
- this.getTextureMatrix = ()=>textureMatrix;
1415
1437
  }
1416
1438
  }
1417
1439
 
@@ -2627,9 +2649,15 @@ class DeviceInput extends Component {
2627
2649
  get pointerPixel() {
2628
2650
  return this._pointerPixel;
2629
2651
  }
2652
+ get pointerDown() {
2653
+ return this._pointerDown;
2654
+ }
2630
2655
  get pointerButton() {
2631
2656
  return this._pointerButton;
2632
2657
  }
2658
+ get pointerMoving() {
2659
+ return this._pointerMoving;
2660
+ }
2633
2661
  get prePointer() {
2634
2662
  return this._prePointer;
2635
2663
  }
@@ -2657,6 +2685,9 @@ class DeviceInput extends Component {
2657
2685
  get keys() {
2658
2686
  return this._keys;
2659
2687
  }
2688
+ get pressability() {
2689
+ return this._pressability;
2690
+ }
2660
2691
  onEnable() {
2661
2692
  const dom = this._target;
2662
2693
  this._addEventListener(dom, 'contextmenu', (e)=>e.preventDefault());
@@ -2709,6 +2740,8 @@ class DeviceInput extends Component {
2709
2740
  this._listeners = [];
2710
2741
  }
2711
2742
  lastUpdate(dt) {
2743
+ this._pointerDown = false;
2744
+ this._pointerMoving = false;
2712
2745
  this._prePointer.copy(this._pointer);
2713
2746
  this._prePointerPixel.copy(this._pointerPixel);
2714
2747
  for(let i = this._touchCount; i--;){
@@ -2793,6 +2826,7 @@ class DeviceInput extends Component {
2793
2826
  }
2794
2827
  _onPointerDown(e) {
2795
2828
  e = this._remapPointer(e);
2829
+ this._pointerDown = true;
2796
2830
  this._pointerButton = e.button;
2797
2831
  this._computePointer(e);
2798
2832
  this._prePointer.copy(this._pointer);
@@ -2810,6 +2844,7 @@ class DeviceInput extends Component {
2810
2844
  _onPointerMove(e) {
2811
2845
  e = this._remapPointer(e);
2812
2846
  this._computePointer(e);
2847
+ this._pointerMoving = true;
2813
2848
  this._pressability.pointerMove(this._pointer, this.viewer.camera);
2814
2849
  this.viewer.emit(DeviceInput.POINTER_MOVE, e);
2815
2850
  }
@@ -2877,7 +2912,7 @@ class DeviceInput extends Component {
2877
2912
  this.viewer.emit(DeviceInput.KEYUP, e);
2878
2913
  }
2879
2914
  constructor(option){
2880
- super(), this._listeners = [], this._touches = [], this._touchCount = 0, this._touchStart = false, this._touchMoving = false, this._pointer = new Vector2(), this._pointerPixel = new Vector2(), this._pointerButton = -1, this._prePointer = new Vector2(), this._prePointerPixel = new Vector2(), this._preTouches = [], this._mouseWheel = 0, this._keys = {}, this._pressability = new Pressability();
2915
+ super(), this._listeners = [], this._touches = [], this._touchCount = 0, this._touchStart = false, this._touchMoving = false, this._pointer = new Vector2(), this._pointerPixel = new Vector2(), this._pointerButton = -1, this._pointerDown = false, this._pointerMoving = false, this._prePointer = new Vector2(), this._prePointerPixel = new Vector2(), this._preTouches = [], this._mouseWheel = 0, this._keys = {}, this._pressability = new Pressability();
2881
2916
  this._target = option.source;
2882
2917
  this._normalizeWheel = option.normalizeWheel || normalizeWheel;
2883
2918
  }
@@ -3107,6 +3142,13 @@ const { tan, PI } = Math;
3107
3142
  const PI2 = PI * 2;
3108
3143
  const ESP = 0.001;
3109
3144
  class FreelookVirtualCamera extends Component {
3145
+ get up() {
3146
+ return this._up;
3147
+ }
3148
+ set up(v) {
3149
+ this._up.copy(v);
3150
+ this._targetUp.copy(v);
3151
+ }
3110
3152
  get lookAt() {
3111
3153
  return this._lookAt;
3112
3154
  }
@@ -3121,11 +3163,11 @@ class FreelookVirtualCamera extends Component {
3121
3163
  this._offset.copy(v);
3122
3164
  this._targetOffset.copy(v);
3123
3165
  }
3124
- get springLength() {
3166
+ get radius() {
3125
3167
  return this._spherical.radius;
3126
3168
  }
3127
- set springLength(v) {
3128
- this._spherical.radius = this._targetSpringLength = clamp(v, this.distanceMin, this.distanceMax);
3169
+ set radius(v) {
3170
+ this._spherical.radius = this._targetRadius = clamp(v, this.radiusMin, this.radiusMax);
3129
3171
  }
3130
3172
  get theta() {
3131
3173
  return this._spherical.theta;
@@ -3177,18 +3219,20 @@ class FreelookVirtualCamera extends Component {
3177
3219
  this._targetFar = this.far;
3178
3220
  this._targetTheta = this.theta;
3179
3221
  this._targetPhi = this.phi;
3180
- this._targetSpringLength = this.springLength;
3222
+ this._targetRadius = this.radius;
3181
3223
  this._targetLookAt.copy(this._lookAt);
3224
+ this._targetUp.copy(this._up);
3182
3225
  }
3183
- goto({ phi = this._targetPhi, theta = this._targetTheta, springLength = this._targetSpringLength, offset = this._targetOffset, lookAt = this._lookAt, fov = this._fov, near = this._near, far = this._far, smoothing = this.smoothing, rotateSmoothing = this.smoothing }) {
3226
+ goto({ phi = this._targetPhi, theta = this._targetTheta, radius = this._targetRadius, offset = this._targetOffset, lookAt = this._lookAt, up = this._up, fov = this._fov, near = this._near, far = this._far, smoothing = this.smoothing, rotateSmoothing = this.smoothing }) {
3184
3227
  const t0 = this._spherical.theta = this._spherical.theta % PI2;
3185
3228
  const t1 = theta % PI2;
3186
3229
  const delta = MathUtils.euclideanModulo(t1 - t0 + Math.PI, PI2) - Math.PI;
3187
3230
  this._targetTheta = clamp(t0 + delta, this.thetaMin, this.thetaMax);
3188
3231
  this._targetPhi = clamp(phi, this.phiMin, this.phiMax);
3189
- this._targetSpringLength = clamp(springLength, this.distanceMin, this.distanceMax);
3232
+ this._targetRadius = clamp(radius, this.radiusMin, this.radiusMax);
3190
3233
  this._targetLookAt.copy(lookAt);
3191
3234
  this._targetOffset.copy(offset);
3235
+ this._targetUp.copy(up);
3192
3236
  this._targetFov = fov;
3193
3237
  this._targetNear = near;
3194
3238
  this._targetFar = far;
@@ -3197,7 +3241,9 @@ class FreelookVirtualCamera extends Component {
3197
3241
  }
3198
3242
  update(dt) {
3199
3243
  this._lerpCamera(dt);
3200
- this._syncCamera();
3244
+ if (this.sync) {
3245
+ this._syncCamera();
3246
+ }
3201
3247
  }
3202
3248
  _onPointerDown(e) {
3203
3249
  if (SystemInfo.isMobile) return;
@@ -3249,7 +3295,7 @@ class FreelookVirtualCamera extends Component {
3249
3295
  }
3250
3296
  _calculateDistanceScale(scale) {
3251
3297
  this._tempRotateSmoothing = this.rotateSmoothing;
3252
- if (this.forbidZ) {
3298
+ if (this.forbitAll || this.forbidZ) {
3253
3299
  scale = 1;
3254
3300
  }
3255
3301
  return this._onDistanceScale(scale);
@@ -3258,10 +3304,10 @@ class FreelookVirtualCamera extends Component {
3258
3304
  this._tempRotateSmoothing = this.rotateSmoothing;
3259
3305
  out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / this.viewer.height);
3260
3306
  out.y = -out.y;
3261
- if (this.forbidX) {
3307
+ if (this.forbitAll || this.forbidX) {
3262
3308
  out.x = 0;
3263
3309
  }
3264
- if (this.forbidY) {
3310
+ if (this.forbitAll || this.forbidY) {
3265
3311
  out.y = 0;
3266
3312
  }
3267
3313
  return out;
@@ -3269,10 +3315,10 @@ class FreelookVirtualCamera extends Component {
3269
3315
  _calculatePanDelta(out, loc0, loc1) {
3270
3316
  this._tempRotateSmoothing = this.rotateSmoothing;
3271
3317
  this._onCalculatePan(out, loc0, loc1);
3272
- if (this.forbidPanX) {
3318
+ if (this.forbitAll || this.forbidPanX) {
3273
3319
  out.x = 0;
3274
3320
  }
3275
- if (this.forbidPanY) {
3321
+ if (this.forbitAll || this.forbidPanY) {
3276
3322
  out.y = 0;
3277
3323
  }
3278
3324
  return out;
@@ -3281,7 +3327,7 @@ class FreelookVirtualCamera extends Component {
3281
3327
  const { xAxis, yAxis, posDelta } = FreelookVirtualCamera;
3282
3328
  xAxis.setFromMatrixColumn(this.node.matrix, 0);
3283
3329
  yAxis.setFromMatrixColumn(this.node.matrix, 1);
3284
- if (this.forbitPanOffsetY) {
3330
+ if (this.forbitAll || this.forbitPanOffsetY) {
3285
3331
  yAxis.y = 0;
3286
3332
  yAxis.normalize();
3287
3333
  }
@@ -3304,11 +3350,11 @@ class FreelookVirtualCamera extends Component {
3304
3350
  this._targetPosition.y += panOffset.y;
3305
3351
  }
3306
3352
  _setTargetSpringLength(scale) {
3307
- this._targetSpringLength *= scale;
3308
- this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
3353
+ this._targetRadius *= scale;
3354
+ this._targetRadius = clamp(this._targetRadius, this.radiusMin, this.radiusMax);
3309
3355
  }
3310
3356
  constructor(){
3311
- super(), this._button = -1, this._touchID = -1, this._preLoc0 = new Vector2(), this._preLoc1 = new Vector2(), this._spherical = new Spherical(4, Math.PI / 2), this._lookAt = new Vector3(), this._offset = new Vector2(), this._fov = 45, this._near = 0.1, this._far = 1000, this._tempSmoothing = 6, this._tempRotateSmoothing = 8, this._targetPosition = new Vector3(), this._targetTheta = 0, this._targetPhi = 0, this._targetSpringLength = 4, this._targetFov = this._fov, this._targetNear = this._near, this._targetFar = this._far, this._targetLookAt = new Vector3(), this._targetOffset = new Vector2(), this._finalLookAt = new Vector3(), this.name = "FreelookVirtualCamera", this.forbidX = false, this.forbidY = false, this.forbidZ = false, this.forbidPanX = false, this.forbidPanY = false, this.forbitPanOffsetY = false, this.panSpeed = 1, this.rotateSpeed = 1, this.smoothing = 5, this.rotateSmoothing = 8, this.phiMin = ESP, this.phiMax = Math.PI - ESP, this.thetaMin = -Infinity, this.thetaMax = Infinity, this.distanceMin = ESP, this.distanceMax = Infinity;
3357
+ super(), this._button = -1, this._touchID = -1, this._preLoc0 = new Vector2(), this._preLoc1 = new Vector2(), this._spherical = new Spherical(4, Math.PI / 2), this._lookAt = new Vector3(), this._up = new Vector3(0, 1, 0), this._offset = new Vector2(), this._fov = 45, this._near = 0.1, this._far = 1000, this._tempSmoothing = 6, this._tempRotateSmoothing = 8, this._targetPosition = new Vector3(), this._targetTheta = 0, this._targetPhi = 0, this._targetRadius = 4, this._targetFov = this._fov, this._targetNear = this._near, this._targetFar = this._far, this._targetLookAt = new Vector3(), this._targetOffset = new Vector2(), this._targetUp = new Vector3(0, 1, 0), this._finalLookAt = new Vector3(), this.name = "FreelookVirtualCamera", this.sync = true, this.forbitAll = false, this.forbidX = false, this.forbidY = false, this.forbidZ = false, this.forbidPanX = false, this.forbidPanY = false, this.forbitPanOffsetY = false, this.panSpeed = 1, this.rotateSpeed = 1, this.smoothing = 5, this.rotateSmoothing = 8, this.phiMin = ESP, this.phiMax = Math.PI - ESP, this.thetaMin = -Infinity, this.thetaMax = Infinity, this.radiusMin = ESP, this.radiusMax = Infinity;
3312
3358
  this.node = new Object3D();
3313
3359
  this.node.isCamera = true;
3314
3360
  this.onLoad = ()=>{
@@ -3351,10 +3397,12 @@ class FreelookVirtualCamera extends Component {
3351
3397
  const rotateSmoothing = this._tempRotateSmoothing;
3352
3398
  this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
3353
3399
  this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
3354
- this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
3400
+ this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
3355
3401
  VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
3356
3402
  VInterpTo(this._offset, this._targetOffset, dt, smoothing);
3403
+ VInterpTo(this._up, this._targetUp, dt, smoothing);
3357
3404
  this._calculateLookAtOffset(this._offset, this._finalLookAt).add(this._lookAt);
3405
+ this.node.up.copy(this._up);
3358
3406
  this.node.position.setFromSpherical(this._spherical).add(this._finalLookAt);
3359
3407
  this.node.lookAt(this._finalLookAt);
3360
3408
  this._fov = FInterpTo(this._fov, this._targetFov, dt, smoothing);
@@ -3374,7 +3422,7 @@ class FreelookVirtualCamera extends Component {
3374
3422
  }
3375
3423
  };
3376
3424
  } else if (camera instanceof OrthographicCamera) {
3377
- this.springLength = camera.zoom;
3425
+ this.radius = camera.zoom;
3378
3426
  this._onDistanceScale = (scale)=>{
3379
3427
  return 1 / scale;
3380
3428
  };
@@ -3404,7 +3452,7 @@ class FreelookVirtualCamera extends Component {
3404
3452
  const smoothing = this._tempSmoothing;
3405
3453
  this.node.position.x = FInterpTo(this.node.position.x, this._targetPosition.x, dt, smoothing);
3406
3454
  this.node.position.y = FInterpTo(this.node.position.y, this._targetPosition.y, dt, smoothing);
3407
- this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
3455
+ this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
3408
3456
  };
3409
3457
  this._syncCamera = ()=>{
3410
3458
  const { zoom } = camera;
@@ -3430,6 +3478,14 @@ FreelookVirtualCamera.lookAtOffset = new Vector3();
3430
3478
  FreelookVirtualCamera.xAxis = new Vector3();
3431
3479
  FreelookVirtualCamera.yAxis = new Vector3();
3432
3480
  FreelookVirtualCamera.quat = new Quaternion();
3481
+ __decorate([
3482
+ property
3483
+ ], FreelookVirtualCamera.prototype, "sync", void 0);
3484
+ __decorate([
3485
+ property({
3486
+ dir: "set"
3487
+ })
3488
+ ], FreelookVirtualCamera.prototype, "forbitAll", void 0);
3433
3489
  __decorate([
3434
3490
  property({
3435
3491
  dir: "set"
@@ -3513,24 +3569,33 @@ __decorate([
3513
3569
  dir: "set",
3514
3570
  step: 0.01
3515
3571
  })
3516
- ], FreelookVirtualCamera.prototype, "distanceMin", void 0);
3572
+ ], FreelookVirtualCamera.prototype, "radiusMin", void 0);
3517
3573
  __decorate([
3518
3574
  property({
3519
3575
  dir: "set",
3520
3576
  step: 0.01
3521
3577
  })
3522
- ], FreelookVirtualCamera.prototype, "distanceMax", void 0);
3578
+ ], FreelookVirtualCamera.prototype, "radiusMax", void 0);
3523
3579
  __decorate([
3524
- property
3580
+ property({
3581
+ step: 0.01
3582
+ })
3583
+ ], FreelookVirtualCamera.prototype, "up", null);
3584
+ __decorate([
3585
+ property({
3586
+ step: 0.01
3587
+ })
3525
3588
  ], FreelookVirtualCamera.prototype, "lookAt", null);
3526
3589
  __decorate([
3527
- property
3590
+ property({
3591
+ step: 0.01
3592
+ })
3528
3593
  ], FreelookVirtualCamera.prototype, "offset", null);
3529
3594
  __decorate([
3530
3595
  property({
3531
3596
  step: 0.01
3532
3597
  })
3533
- ], FreelookVirtualCamera.prototype, "springLength", null);
3598
+ ], FreelookVirtualCamera.prototype, "radius", null);
3534
3599
  __decorate([
3535
3600
  property({
3536
3601
  step: 0.01
@@ -3914,6 +3979,12 @@ class ReflectorMaterial extends ShaderMaterial {
3914
3979
  set aoMap(v) {
3915
3980
  this.uniforms.aoMap.value = v;
3916
3981
  }
3982
+ get aoMapIntensity() {
3983
+ return this.uniforms.aoMapIntensity.value;
3984
+ }
3985
+ set aoMapIntensity(v) {
3986
+ this.uniforms.aoMapIntensity.value = v;
3987
+ }
3917
3988
  get lightMap() {
3918
3989
  return this.uniforms.lightMap.value;
3919
3990
  }
@@ -3992,14 +4063,17 @@ class ReflectorMaterial extends ShaderMaterial {
3992
4063
  },
3993
4064
  lightMapIntensity: {
3994
4065
  value: 1
4066
+ },
4067
+ dfgLUT: {
4068
+ value: null
3995
4069
  }
3996
4070
  };
3997
4071
  Object.defineProperty(this, "opacity", {
3998
4072
  get: ()=>this.uniforms.opacity.value,
3999
4073
  set: (v)=>this.uniforms.opacity.value = v
4000
4074
  });
4001
- this.uniforms.reflectMap.value = reflector.getRenderTarget().texture;
4002
- this.uniforms.textureMatrix.value = reflector.getTextureMatrix();
4075
+ this.uniforms.reflectMap.value = reflector.texture;
4076
+ this.uniforms.textureMatrix.value = reflector.textureMatrix;
4003
4077
  this.setValues(parameters);
4004
4078
  }
4005
4079
  }
@@ -4038,6 +4112,12 @@ __decorate([
4038
4112
  __decorate([
4039
4113
  property
4040
4114
  ], ReflectorMaterial.prototype, "aoMap", null);
4115
+ __decorate([
4116
+ property({
4117
+ min: 0,
4118
+ max: 1
4119
+ })
4120
+ ], ReflectorMaterial.prototype, "aoMapIntensity", null);
4041
4121
  __decorate([
4042
4122
  property
4043
4123
  ], ReflectorMaterial.prototype, "lightMap", null);
@@ -4710,6 +4790,12 @@ class Viewer extends EventEmitter {
4710
4790
  get renderer() {
4711
4791
  return this._renderer;
4712
4792
  }
4793
+ get freeze() {
4794
+ return this._freeze;
4795
+ }
4796
+ set freeze(v) {
4797
+ this._freeze = v;
4798
+ }
4713
4799
  destroy() {
4714
4800
  this.stop();
4715
4801
  this._renderer.dispose();
@@ -4731,44 +4817,43 @@ class Viewer extends EventEmitter {
4731
4817
  };
4732
4818
  }
4733
4819
  }
4734
- _frame(time) {
4735
- this._time = time;
4736
- if (this._targetFrameRate > -1) {
4737
- const interval = 1 / this._targetFrameRate;
4738
- const delta = this._time - this._lastFrameTime;
4739
- if (delta >= interval) {
4740
- this.loop(this._fixedFrameTime ? interval : this._time - this._lastTime);
4741
- this._lastTime = this._time;
4742
- this._lastFrameTime = this._time - delta % interval;
4820
+ animate() {
4821
+ const loop = (dt)=>{
4822
+ if (!this._active) return;
4823
+ if (this._resourceManager.isComplete) {
4824
+ this._taskManager.isComplete ? this._running = true : this._taskManager.update();
4743
4825
  }
4744
- } else {
4745
- this.loop(this._time - this._lastTime);
4746
- this._lastTime = this._time;
4747
- }
4748
- }
4749
- loop(dt) {
4750
- if (this._resourceManager.isComplete) {
4751
- this._taskManager.update();
4752
- if (this._taskManager.isComplete) {
4753
- this._running = true;
4826
+ if (this._running) {
4827
+ dt = Math.min(dt, 0.067);
4828
+ this._renderer.info.reset();
4829
+ this._componentManager.update(dt);
4830
+ if (!this._freeze) {
4831
+ this._componentManager.render(dt);
4832
+ }
4754
4833
  }
4755
- }
4756
- if (this._running) {
4757
- dt = Math.min(dt, 0.067);
4758
- this._renderer.info.reset();
4759
- this._componentManager.update(dt);
4760
- this._componentManager.render(dt);
4761
- }
4834
+ };
4835
+ const frame = (time)=>{
4836
+ this._time = time * 0.001;
4837
+ if (this._targetFrameRate > -1) {
4838
+ const interval = 1 / this._targetFrameRate;
4839
+ const delta = this._time - this._lastFrameTime;
4840
+ if (delta >= interval) {
4841
+ loop(this._fixedFrameTime ? interval : this._time - this._lastTime);
4842
+ this._lastTime = this._time;
4843
+ this._lastFrameTime = this._time - delta % interval;
4844
+ }
4845
+ } else {
4846
+ loop(this._time - this._lastTime);
4847
+ this._lastTime = this._time;
4848
+ }
4849
+ };
4850
+ this._renderer.setAnimationLoop(frame);
4762
4851
  }
4763
4852
  start() {
4764
- if (this._active == false) {
4853
+ if (this._active === false) {
4765
4854
  this._active = true;
4766
- const frameCallback = (time)=>{
4767
- if (this._active) {
4768
- this._frame(time * 0.001);
4769
- }
4770
- };
4771
- this._renderer.setAnimationLoop(frameCallback);
4855
+ this.rotate();
4856
+ this.resize();
4772
4857
  }
4773
4858
  return this;
4774
4859
  }
@@ -4883,7 +4968,7 @@ class Viewer extends EventEmitter {
4883
4968
  this._taskManager.add(new Task(excute));
4884
4969
  return target;
4885
4970
  }
4886
- add(object, { node, args, scale, parent, position, rotation, manual, makeDefault, component, layerMask, ...props } = {}) {
4971
+ add(object, { node, args, scale, parent, position, rotation, manual, makeDefault, component, layerMask, children, ...props } = {}) {
4887
4972
  let mount = false;
4888
4973
  let ins = getClassInstance(object, args);
4889
4974
  if (ins.isObject3D) {
@@ -4908,7 +4993,7 @@ class Viewer extends EventEmitter {
4908
4993
  if (parent === undefined) {
4909
4994
  parent = mount ? this._mount : this._scene;
4910
4995
  }
4911
- if (parent && !node.parent) {
4996
+ if (parent !== node) {
4912
4997
  parent.add(node);
4913
4998
  }
4914
4999
  if (component) {
@@ -4919,6 +5004,12 @@ class Viewer extends EventEmitter {
4919
5004
  this._componentManager.addComponent(node, comp);
4920
5005
  }
4921
5006
  }
5007
+ if (children) {
5008
+ const children_ = Array.isArray(children) ? children : [
5009
+ children
5010
+ ];
5011
+ node.add(...children_);
5012
+ }
4922
5013
  if (layerMask) {
4923
5014
  node.layers.mask = layerMask;
4924
5015
  }
@@ -5128,10 +5219,10 @@ class Viewer extends EventEmitter {
5128
5219
  width: 1,
5129
5220
  height: 1,
5130
5221
  factor: 1
5131
- }, this._active = false, this._loading = false, this._tasking = false, this._running = false, this._rootRotated = false, this._time = 0, this._lastTime = 0, this._lastFrameTime = 0, this._targetFrameRate = -1, this._fixedFrameTime = false, this._windowSize = ()=>[
5222
+ }, this._active = false, this._running = false, this._rootRotated = false, this._time = 0, this._lastTime = 0, this._lastFrameTime = 0, this._targetFrameRate = -1, this._fixedFrameTime = false, this._windowSize = ()=>[
5132
5223
  window.innerWidth,
5133
5224
  window.innerHeight
5134
- ], this._orientation = Orientation.AUTO;
5225
+ ], this._orientation = Orientation.AUTO, this._freeze = false;
5135
5226
  const el = canvas || document.getElementById("canvas");
5136
5227
  const webgl = checkWebGL(el, webglOpts);
5137
5228
  if (!webgl) {
@@ -5186,11 +5277,9 @@ class Viewer extends EventEmitter {
5186
5277
  this.addLoader(BINLoader);
5187
5278
  this.addLoader(SVGLoader);
5188
5279
  this.addLoader(KTX2Loader);
5189
- setTimeout(()=>{
5190
- this.rotate();
5191
- this.resize();
5192
- this.start();
5193
- });
5280
+ this.rotate();
5281
+ this.resize();
5282
+ this.animate();
5194
5283
  }
5195
5284
  }
5196
5285
  Viewer.instanceCount = 0;
@@ -5270,8 +5359,6 @@ class MergeRefectPass {
5270
5359
  this._cubeMapMaterial = _getCubeMapMaterial();
5271
5360
  this._copyTexMaterial = _getClearMaterial();
5272
5361
  this._copyMesh = new Mesh(Viewer.fullscreenMesh.geometry, this._copyTexMaterial);
5273
- this._lodMeshes = this._lodPlanes.map((v)=>new Mesh(v, this._cubeMapMaterial));
5274
- this._sourceInit = false;
5275
5362
  return target;
5276
5363
  };
5277
5364
  pmremGenerator._fromCubeTexture = function(texture) {
@@ -5402,7 +5489,6 @@ class MergeMipBlurPass {
5402
5489
  const target = this._allocateTargets();
5403
5490
  this._mipBlurMaterial = _getMipBlurMaterial(this._lodMax, target.width, target.height);
5404
5491
  this._mipCopyMaterial = _getMipCopyMaterial(this._lodMax, target.width, target.height);
5405
- this._lodMeshes = this._lodPlanes.map((v)=>new Mesh(v, this._mipBlurMaterial));
5406
5492
  return target;
5407
5493
  };
5408
5494
  pmremGenerator._applyMipBlur = function(sourceTarget, texture, blurMinLod, blurMaxLod, sigma, exposure = 1) {
@@ -5603,7 +5689,7 @@ class BoxProjection extends Component {
5603
5689
  `);
5604
5690
  ShaderLib.physical.fragmentShader = ShaderLib.physical.fragmentShader.replace("varying vec3 vViewPosition;", `
5605
5691
  varying vec3 vViewPosition;
5606
- #if defined(USE_BOX_PROJECTION)
5692
+ #if defined(USE_TRANSMISSION) || defined(USE_BOX_PROJECTION)
5607
5693
  varying vec3 vWorldPosition;
5608
5694
  #endif
5609
5695
  `);
@@ -5643,7 +5729,6 @@ class BoxProjection extends Component {
5643
5729
  worldNormal = boxProjection(worldNormal, vWorldPosition, probePos.xyz, probeBoxMin.xyz, probeBoxMax.xyz);
5644
5730
  }
5645
5731
  #endif
5646
-
5647
5732
  `);
5648
5733
  }
5649
5734
  useBoxProjection(shader) {
@@ -6483,6 +6568,9 @@ void main() {
6483
6568
 
6484
6569
  color.a *= u_opacity;
6485
6570
  gl_FragColor = color;
6571
+
6572
+ #include <tonemapping_fragment>
6573
+ #include <colorspace_fragment>
6486
6574
  }
6487
6575
  `;
6488
6576
  class BMFontAtlas {
@@ -6564,13 +6652,13 @@ class BMFontAtlas {
6564
6652
  value: 0.2
6565
6653
  },
6566
6654
  u_strokeColor: {
6567
- value: new Color(0xff0000)
6655
+ value: new Color(0xffffff)
6568
6656
  },
6569
6657
  u_strokeWidth: {
6570
6658
  value: 0
6571
6659
  },
6572
6660
  u_shadowColor: {
6573
- value: new Color(0xff0000)
6661
+ value: new Color(0xffffff)
6574
6662
  },
6575
6663
  u_shadowBlur: {
6576
6664
  value: 0
@@ -6598,5 +6686,5 @@ class BMFontAtlas {
6598
6686
  }
6599
6687
  }
6600
6688
 
6601
- export { AccumulativeShadows, Animation, AnimationCurve, BINLoader, BMFontAtlas, BMFontTextGeometry, BMFontTextLayout, Box, BoxProjection, Center, Component, ContactShadows, DependentMode, DeviceInput, DropFile, EXRLoader, Easing, Environment, EventEmitter, FBXLoader, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, GLTFLoader, HDRLoader, JSONLoader, KTX2Loader, Label, Loader, Logger, ObjectInstance, Orientation, PerformanceMonitor, Perlin, Plane, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, RandomizedLight, Reflector, ReflectorMaterial, RenderTexture, Renderer, ResizeMode, ResourceManager, SVGLoader, ShadowMaterial, Sphere, SystemInfo, Task, TextureLoader, 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, applyProps, dependencies, exponentialDamp, find, frag_BoxfilterBlur, frag_cubeMapToPanorama, frag_panoramaToCubeMap, getChildByName, getChildren, getClassInstance, getShaderMaterial, mixin, property, quarticDamp, queryValues, smoothDamp, vert_fullscreen };
6689
+ export { AccumulativeShadows, Animation, AnimationCurve, BINLoader, BMFontAtlas, BMFontTextGeometry, BMFontTextLayout, Box, BoxProjection, Center, Component, ContactShadows, DependentMode, DeviceInput, DropFile, EXRLoader, Easing, Environment, EventEmitter, FBXLoader, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, GLTFLoader, HDRLoader, JSONLoader, KTX2Loader, Label, Loader, Logger, ObjectInstance, Orientation, PerformanceMonitor, Perlin, Plane, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, RandomizedLight, Reflector, ReflectorMaterial, RenderTexture, Renderer, ResizeMode, ResourceManager, SVGLoader, ShadowMaterial, Sphere, SystemInfo, Task, TextureLoader, 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, applyProps, dependencies, exponentialDamp, find, frag_BoxfilterBlur, frag_cubeMapToPanorama, frag_panoramaToCubeMap, getChildByName, getChildren, getClassInstance, getShaderMaterial, mixin, property, quarticDamp, queryValues, single, smoothDamp, vert_fullscreen };
6602
6690
  //# sourceMappingURL=module.js.map