@xviewer.js/core 1.0.5-alhpa.2 → 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,7 +4,7 @@ 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';
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
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';
@@ -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){
@@ -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
 
@@ -3120,6 +3142,13 @@ const { tan, PI } = Math;
3120
3142
  const PI2 = PI * 2;
3121
3143
  const ESP = 0.001;
3122
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
+ }
3123
3152
  get lookAt() {
3124
3153
  return this._lookAt;
3125
3154
  }
@@ -3134,11 +3163,11 @@ class FreelookVirtualCamera extends Component {
3134
3163
  this._offset.copy(v);
3135
3164
  this._targetOffset.copy(v);
3136
3165
  }
3137
- get springLength() {
3166
+ get radius() {
3138
3167
  return this._spherical.radius;
3139
3168
  }
3140
- set springLength(v) {
3141
- 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);
3142
3171
  }
3143
3172
  get theta() {
3144
3173
  return this._spherical.theta;
@@ -3190,18 +3219,20 @@ class FreelookVirtualCamera extends Component {
3190
3219
  this._targetFar = this.far;
3191
3220
  this._targetTheta = this.theta;
3192
3221
  this._targetPhi = this.phi;
3193
- this._targetSpringLength = this.springLength;
3222
+ this._targetRadius = this.radius;
3194
3223
  this._targetLookAt.copy(this._lookAt);
3224
+ this._targetUp.copy(this._up);
3195
3225
  }
3196
- 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 }) {
3197
3227
  const t0 = this._spherical.theta = this._spherical.theta % PI2;
3198
3228
  const t1 = theta % PI2;
3199
3229
  const delta = MathUtils.euclideanModulo(t1 - t0 + Math.PI, PI2) - Math.PI;
3200
3230
  this._targetTheta = clamp(t0 + delta, this.thetaMin, this.thetaMax);
3201
3231
  this._targetPhi = clamp(phi, this.phiMin, this.phiMax);
3202
- this._targetSpringLength = clamp(springLength, this.distanceMin, this.distanceMax);
3232
+ this._targetRadius = clamp(radius, this.radiusMin, this.radiusMax);
3203
3233
  this._targetLookAt.copy(lookAt);
3204
3234
  this._targetOffset.copy(offset);
3235
+ this._targetUp.copy(up);
3205
3236
  this._targetFov = fov;
3206
3237
  this._targetNear = near;
3207
3238
  this._targetFar = far;
@@ -3210,7 +3241,9 @@ class FreelookVirtualCamera extends Component {
3210
3241
  }
3211
3242
  update(dt) {
3212
3243
  this._lerpCamera(dt);
3213
- this._syncCamera();
3244
+ if (this.sync) {
3245
+ this._syncCamera();
3246
+ }
3214
3247
  }
3215
3248
  _onPointerDown(e) {
3216
3249
  if (SystemInfo.isMobile) return;
@@ -3262,7 +3295,7 @@ class FreelookVirtualCamera extends Component {
3262
3295
  }
3263
3296
  _calculateDistanceScale(scale) {
3264
3297
  this._tempRotateSmoothing = this.rotateSmoothing;
3265
- if (this.forbidZ) {
3298
+ if (this.forbitAll || this.forbidZ) {
3266
3299
  scale = 1;
3267
3300
  }
3268
3301
  return this._onDistanceScale(scale);
@@ -3271,10 +3304,10 @@ class FreelookVirtualCamera extends Component {
3271
3304
  this._tempRotateSmoothing = this.rotateSmoothing;
3272
3305
  out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / this.viewer.height);
3273
3306
  out.y = -out.y;
3274
- if (this.forbidX) {
3307
+ if (this.forbitAll || this.forbidX) {
3275
3308
  out.x = 0;
3276
3309
  }
3277
- if (this.forbidY) {
3310
+ if (this.forbitAll || this.forbidY) {
3278
3311
  out.y = 0;
3279
3312
  }
3280
3313
  return out;
@@ -3282,10 +3315,10 @@ class FreelookVirtualCamera extends Component {
3282
3315
  _calculatePanDelta(out, loc0, loc1) {
3283
3316
  this._tempRotateSmoothing = this.rotateSmoothing;
3284
3317
  this._onCalculatePan(out, loc0, loc1);
3285
- if (this.forbidPanX) {
3318
+ if (this.forbitAll || this.forbidPanX) {
3286
3319
  out.x = 0;
3287
3320
  }
3288
- if (this.forbidPanY) {
3321
+ if (this.forbitAll || this.forbidPanY) {
3289
3322
  out.y = 0;
3290
3323
  }
3291
3324
  return out;
@@ -3294,7 +3327,7 @@ class FreelookVirtualCamera extends Component {
3294
3327
  const { xAxis, yAxis, posDelta } = FreelookVirtualCamera;
3295
3328
  xAxis.setFromMatrixColumn(this.node.matrix, 0);
3296
3329
  yAxis.setFromMatrixColumn(this.node.matrix, 1);
3297
- if (this.forbitPanOffsetY) {
3330
+ if (this.forbitAll || this.forbitPanOffsetY) {
3298
3331
  yAxis.y = 0;
3299
3332
  yAxis.normalize();
3300
3333
  }
@@ -3317,11 +3350,11 @@ class FreelookVirtualCamera extends Component {
3317
3350
  this._targetPosition.y += panOffset.y;
3318
3351
  }
3319
3352
  _setTargetSpringLength(scale) {
3320
- this._targetSpringLength *= scale;
3321
- this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
3353
+ this._targetRadius *= scale;
3354
+ this._targetRadius = clamp(this._targetRadius, this.radiusMin, this.radiusMax);
3322
3355
  }
3323
3356
  constructor(){
3324
- 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;
3325
3358
  this.node = new Object3D();
3326
3359
  this.node.isCamera = true;
3327
3360
  this.onLoad = ()=>{
@@ -3364,10 +3397,12 @@ class FreelookVirtualCamera extends Component {
3364
3397
  const rotateSmoothing = this._tempRotateSmoothing;
3365
3398
  this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
3366
3399
  this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
3367
- this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
3400
+ this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
3368
3401
  VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
3369
3402
  VInterpTo(this._offset, this._targetOffset, dt, smoothing);
3403
+ VInterpTo(this._up, this._targetUp, dt, smoothing);
3370
3404
  this._calculateLookAtOffset(this._offset, this._finalLookAt).add(this._lookAt);
3405
+ this.node.up.copy(this._up);
3371
3406
  this.node.position.setFromSpherical(this._spherical).add(this._finalLookAt);
3372
3407
  this.node.lookAt(this._finalLookAt);
3373
3408
  this._fov = FInterpTo(this._fov, this._targetFov, dt, smoothing);
@@ -3387,7 +3422,7 @@ class FreelookVirtualCamera extends Component {
3387
3422
  }
3388
3423
  };
3389
3424
  } else if (camera instanceof OrthographicCamera) {
3390
- this.springLength = camera.zoom;
3425
+ this.radius = camera.zoom;
3391
3426
  this._onDistanceScale = (scale)=>{
3392
3427
  return 1 / scale;
3393
3428
  };
@@ -3417,7 +3452,7 @@ class FreelookVirtualCamera extends Component {
3417
3452
  const smoothing = this._tempSmoothing;
3418
3453
  this.node.position.x = FInterpTo(this.node.position.x, this._targetPosition.x, dt, smoothing);
3419
3454
  this.node.position.y = FInterpTo(this.node.position.y, this._targetPosition.y, dt, smoothing);
3420
- this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
3455
+ this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
3421
3456
  };
3422
3457
  this._syncCamera = ()=>{
3423
3458
  const { zoom } = camera;
@@ -3443,6 +3478,14 @@ FreelookVirtualCamera.lookAtOffset = new Vector3();
3443
3478
  FreelookVirtualCamera.xAxis = new Vector3();
3444
3479
  FreelookVirtualCamera.yAxis = new Vector3();
3445
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);
3446
3489
  __decorate([
3447
3490
  property({
3448
3491
  dir: "set"
@@ -3526,24 +3569,33 @@ __decorate([
3526
3569
  dir: "set",
3527
3570
  step: 0.01
3528
3571
  })
3529
- ], FreelookVirtualCamera.prototype, "distanceMin", void 0);
3572
+ ], FreelookVirtualCamera.prototype, "radiusMin", void 0);
3530
3573
  __decorate([
3531
3574
  property({
3532
3575
  dir: "set",
3533
3576
  step: 0.01
3534
3577
  })
3535
- ], FreelookVirtualCamera.prototype, "distanceMax", void 0);
3578
+ ], FreelookVirtualCamera.prototype, "radiusMax", void 0);
3536
3579
  __decorate([
3537
- property
3580
+ property({
3581
+ step: 0.01
3582
+ })
3583
+ ], FreelookVirtualCamera.prototype, "up", null);
3584
+ __decorate([
3585
+ property({
3586
+ step: 0.01
3587
+ })
3538
3588
  ], FreelookVirtualCamera.prototype, "lookAt", null);
3539
3589
  __decorate([
3540
- property
3590
+ property({
3591
+ step: 0.01
3592
+ })
3541
3593
  ], FreelookVirtualCamera.prototype, "offset", null);
3542
3594
  __decorate([
3543
3595
  property({
3544
3596
  step: 0.01
3545
3597
  })
3546
- ], FreelookVirtualCamera.prototype, "springLength", null);
3598
+ ], FreelookVirtualCamera.prototype, "radius", null);
3547
3599
  __decorate([
3548
3600
  property({
3549
3601
  step: 0.01
@@ -4020,8 +4072,8 @@ class ReflectorMaterial extends ShaderMaterial {
4020
4072
  get: ()=>this.uniforms.opacity.value,
4021
4073
  set: (v)=>this.uniforms.opacity.value = v
4022
4074
  });
4023
- this.uniforms.reflectMap.value = reflector.getRenderTarget().texture;
4024
- this.uniforms.textureMatrix.value = reflector.getTextureMatrix();
4075
+ this.uniforms.reflectMap.value = reflector.texture;
4076
+ this.uniforms.textureMatrix.value = reflector.textureMatrix;
4025
4077
  this.setValues(parameters);
4026
4078
  }
4027
4079
  }
@@ -4738,6 +4790,12 @@ class Viewer extends EventEmitter {
4738
4790
  get renderer() {
4739
4791
  return this._renderer;
4740
4792
  }
4793
+ get freeze() {
4794
+ return this._freeze;
4795
+ }
4796
+ set freeze(v) {
4797
+ this._freeze = v;
4798
+ }
4741
4799
  destroy() {
4742
4800
  this.stop();
4743
4801
  this._renderer.dispose();
@@ -4769,7 +4827,9 @@ class Viewer extends EventEmitter {
4769
4827
  dt = Math.min(dt, 0.067);
4770
4828
  this._renderer.info.reset();
4771
4829
  this._componentManager.update(dt);
4772
- this._componentManager.render(dt);
4830
+ if (!this._freeze) {
4831
+ this._componentManager.render(dt);
4832
+ }
4773
4833
  }
4774
4834
  };
4775
4835
  const frame = (time)=>{
@@ -4792,10 +4852,8 @@ class Viewer extends EventEmitter {
4792
4852
  start() {
4793
4853
  if (this._active === false) {
4794
4854
  this._active = true;
4795
- requestAnimationFrame(()=>{
4796
- this.rotate();
4797
- this.resize();
4798
- });
4855
+ this.rotate();
4856
+ this.resize();
4799
4857
  }
4800
4858
  return this;
4801
4859
  }
@@ -4910,7 +4968,7 @@ class Viewer extends EventEmitter {
4910
4968
  this._taskManager.add(new Task(excute));
4911
4969
  return target;
4912
4970
  }
4913
- 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 } = {}) {
4914
4972
  let mount = false;
4915
4973
  let ins = getClassInstance(object, args);
4916
4974
  if (ins.isObject3D) {
@@ -4935,7 +4993,7 @@ class Viewer extends EventEmitter {
4935
4993
  if (parent === undefined) {
4936
4994
  parent = mount ? this._mount : this._scene;
4937
4995
  }
4938
- if (parent !== node && !node.parent) {
4996
+ if (parent !== node) {
4939
4997
  parent.add(node);
4940
4998
  }
4941
4999
  if (component) {
@@ -4946,6 +5004,12 @@ class Viewer extends EventEmitter {
4946
5004
  this._componentManager.addComponent(node, comp);
4947
5005
  }
4948
5006
  }
5007
+ if (children) {
5008
+ const children_ = Array.isArray(children) ? children : [
5009
+ children
5010
+ ];
5011
+ node.add(...children_);
5012
+ }
4949
5013
  if (layerMask) {
4950
5014
  node.layers.mask = layerMask;
4951
5015
  }
@@ -5158,7 +5222,7 @@ class Viewer extends EventEmitter {
5158
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 = ()=>[
5159
5223
  window.innerWidth,
5160
5224
  window.innerHeight
5161
- ], this._orientation = Orientation.AUTO;
5225
+ ], this._orientation = Orientation.AUTO, this._freeze = false;
5162
5226
  const el = canvas || document.getElementById("canvas");
5163
5227
  const webgl = checkWebGL(el, webglOpts);
5164
5228
  if (!webgl) {
@@ -5295,8 +5359,6 @@ class MergeRefectPass {
5295
5359
  this._cubeMapMaterial = _getCubeMapMaterial();
5296
5360
  this._copyTexMaterial = _getClearMaterial();
5297
5361
  this._copyMesh = new Mesh(Viewer.fullscreenMesh.geometry, this._copyTexMaterial);
5298
- this._lodMeshes = this._lodPlanes.map((v)=>new Mesh(v, this._cubeMapMaterial));
5299
- this._sourceInit = false;
5300
5362
  return target;
5301
5363
  };
5302
5364
  pmremGenerator._fromCubeTexture = function(texture) {
@@ -5427,7 +5489,6 @@ class MergeMipBlurPass {
5427
5489
  const target = this._allocateTargets();
5428
5490
  this._mipBlurMaterial = _getMipBlurMaterial(this._lodMax, target.width, target.height);
5429
5491
  this._mipCopyMaterial = _getMipCopyMaterial(this._lodMax, target.width, target.height);
5430
- this._lodMeshes = this._lodPlanes.map((v)=>new Mesh(v, this._mipBlurMaterial));
5431
5492
  return target;
5432
5493
  };
5433
5494
  pmremGenerator._applyMipBlur = function(sourceTarget, texture, blurMinLod, blurMaxLod, sigma, exposure = 1) {
@@ -5628,7 +5689,7 @@ class BoxProjection extends Component {
5628
5689
  `);
5629
5690
  ShaderLib.physical.fragmentShader = ShaderLib.physical.fragmentShader.replace("varying vec3 vViewPosition;", `
5630
5691
  varying vec3 vViewPosition;
5631
- #if defined(USE_BOX_PROJECTION)
5692
+ #if defined(USE_TRANSMISSION) || defined(USE_BOX_PROJECTION)
5632
5693
  varying vec3 vWorldPosition;
5633
5694
  #endif
5634
5695
  `);
@@ -5668,7 +5729,6 @@ class BoxProjection extends Component {
5668
5729
  worldNormal = boxProjection(worldNormal, vWorldPosition, probePos.xyz, probeBoxMin.xyz, probeBoxMax.xyz);
5669
5730
  }
5670
5731
  #endif
5671
-
5672
5732
  `);
5673
5733
  }
5674
5734
  useBoxProjection(shader) {
@@ -6508,6 +6568,9 @@ void main() {
6508
6568
 
6509
6569
  color.a *= u_opacity;
6510
6570
  gl_FragColor = color;
6571
+
6572
+ #include <tonemapping_fragment>
6573
+ #include <colorspace_fragment>
6511
6574
  }
6512
6575
  `;
6513
6576
  class BMFontAtlas {
@@ -6589,13 +6652,13 @@ class BMFontAtlas {
6589
6652
  value: 0.2
6590
6653
  },
6591
6654
  u_strokeColor: {
6592
- value: new Color(0xff0000)
6655
+ value: new Color(0xffffff)
6593
6656
  },
6594
6657
  u_strokeWidth: {
6595
6658
  value: 0
6596
6659
  },
6597
6660
  u_shadowColor: {
6598
- value: new Color(0xff0000)
6661
+ value: new Color(0xffffff)
6599
6662
  },
6600
6663
  u_shadowBlur: {
6601
6664
  value: 0
@@ -6623,5 +6686,5 @@ class BMFontAtlas {
6623
6686
  }
6624
6687
  }
6625
6688
 
6626
- 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 };
6627
6690
  //# sourceMappingURL=module.js.map