@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/main.cjs CHANGED
@@ -6,7 +6,7 @@ var GLTFLoader_js = require('three/examples/jsm/loaders/GLTFLoader.js');
6
6
  var DRACOLoader_js = require('three/examples/jsm/loaders/DRACOLoader.js');
7
7
  var meshopt_decoder_module_js = require('three/examples/jsm/libs/meshopt_decoder.module.js');
8
8
  var THREE = require('three');
9
- var RGBELoader_js = require('three/examples/jsm/loaders/RGBELoader.js');
9
+ var HDRLoader_js = require('three/examples/jsm/loaders/HDRLoader.js');
10
10
  var SVGLoader_js = require('three/examples/jsm/loaders/SVGLoader.js');
11
11
  var KTX2Loader_js = require('three/examples/jsm/loaders/KTX2Loader.js');
12
12
  var Addons_js = require('three/examples/jsm/Addons.js');
@@ -273,10 +273,28 @@ class GLTFLoader extends Loader {
273
273
  loader.manager = manager;
274
274
  loader.setPath(path);
275
275
  loader.setResourcePath(resourcePath);
276
+ const cb = (gltf)=>{
277
+ const meshes = new Map();
278
+ const materials = new Map();
279
+ gltf.scene.traverse((mesh)=>{
280
+ if (mesh.isMesh) {
281
+ gltf.mesh = mesh;
282
+ gltf.material = mesh.material;
283
+ meshes.set(mesh.name, mesh);
284
+ const arr = Array.isArray(mesh.material) ? mesh.material : [
285
+ mesh.material
286
+ ];
287
+ arr.forEach((m)=>materials.set(m.name, m));
288
+ }
289
+ });
290
+ gltf.meshes = meshes;
291
+ gltf.materials = materials;
292
+ onLoad(gltf);
293
+ };
276
294
  if (buffer) {
277
- loader.parse(buffer, resourcePath, onLoad, onError);
295
+ loader.parse(buffer, resourcePath, cb, onError);
278
296
  } else {
279
- loader.load(url, onLoad, onProgress, onError);
297
+ loader.load(url, cb, onProgress, onError);
280
298
  }
281
299
  }
282
300
  constructor(...args){
@@ -291,7 +309,7 @@ class HDRLoader extends Loader {
291
309
  load({ url, path, resourcePath, manager, texSettings, onLoad, onProgress, onError }) {
292
310
  let loader = this._loader;
293
311
  if (loader === undefined) {
294
- loader = this._loader = new RGBELoader_js.RGBELoader();
312
+ loader = this._loader = new HDRLoader_js.HDRLoader();
295
313
  }
296
314
  loader.manager = manager;
297
315
  loader.setPath(path);
@@ -1330,8 +1348,17 @@ class Component extends ObjectInstance {
1330
1348
  }
1331
1349
 
1332
1350
  class Reflector extends Component {
1351
+ get texture() {
1352
+ return this._renderTarget.texture;
1353
+ }
1354
+ get textureMatrix() {
1355
+ return this._textureMatrix;
1356
+ }
1357
+ onDestroy() {
1358
+ this._renderTarget.dispose();
1359
+ }
1333
1360
  constructor({ resolution = 512, clipBias = 0, multisample = 4, layerMask = 1 << 0, normal = new THREE.Vector3(0, 1, 0), mipmap = false } = {}){
1334
- super(), this.node = new THREE.Object3D(), this.layerMask = 1 << 0;
1361
+ super(), this.node = new THREE.Object3D(), this.layerMask = 1 << 0, this._renderTarget = null, this._textureMatrix = new THREE.Matrix4();
1335
1362
  this.layerMask = layerMask;
1336
1363
  const reflectorPlane = new THREE.Plane();
1337
1364
  const reflectorNormal = new THREE.Vector3();
@@ -1343,15 +1370,14 @@ class Reflector extends Component {
1343
1370
  const view = new THREE.Vector3();
1344
1371
  const target = new THREE.Vector3();
1345
1372
  const q = new THREE.Vector4();
1346
- const textureMatrix = new THREE.Matrix4();
1347
1373
  const virtualCamera = new THREE.PerspectiveCamera();
1348
- const renderTarget = new THREE.WebGLRenderTarget(resolution, resolution, {
1374
+ this._renderTarget = new THREE.WebGLRenderTarget(resolution, resolution, {
1349
1375
  samples: multisample,
1350
1376
  type: THREE.HalfFloatType,
1351
1377
  minFilter: mipmap ? THREE.LinearMipMapLinearFilter : THREE.LinearFilter,
1352
1378
  generateMipmaps: mipmap
1353
1379
  });
1354
- const update = ()=>{
1380
+ this.lastUpdate = ()=>{
1355
1381
  const node = this.node;
1356
1382
  const { renderer, camera, scene } = this.context;
1357
1383
  reflectorWorldPosition.setFromMatrixPosition(node.matrixWorld);
@@ -1382,9 +1408,9 @@ class Reflector extends Component {
1382
1408
  virtualCamera.updateMatrixWorld();
1383
1409
  virtualCamera.projectionMatrix.copy(camera.projectionMatrix);
1384
1410
  // Update the texture matrix
1385
- 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);
1386
- textureMatrix.multiply(virtualCamera.projectionMatrix);
1387
- textureMatrix.multiply(virtualCamera.matrixWorldInverse);
1411
+ 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);
1412
+ this.textureMatrix.multiply(virtualCamera.projectionMatrix);
1413
+ this.textureMatrix.multiply(virtualCamera.matrixWorldInverse);
1388
1414
  // Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
1389
1415
  // Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
1390
1416
  reflectorPlane.setFromNormalAndCoplanarPoint(reflectorNormal, reflectorWorldPosition);
@@ -1413,7 +1439,7 @@ class Reflector extends Component {
1413
1439
  renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
1414
1440
  const clearAlpha = renderer.getClearAlpha();
1415
1441
  renderer.setClearAlpha(0);
1416
- renderer.setRenderTarget(renderTarget);
1442
+ renderer.setRenderTarget(this._renderTarget);
1417
1443
  renderer.state.buffers.depth.setMask(true); // make sure the depth buffer is writable so it can be properly cleared, see #18897
1418
1444
  if (renderer.autoClear === false) renderer.clear();
1419
1445
  renderer.render(scene, virtualCamera);
@@ -1428,10 +1454,6 @@ class Reflector extends Component {
1428
1454
  }
1429
1455
  node.visible = true;
1430
1456
  };
1431
- this.lastUpdate = update;
1432
- this.onDestroy = ()=>renderTarget.dispose();
1433
- this.getRenderTarget = ()=>renderTarget;
1434
- this.getTextureMatrix = ()=>textureMatrix;
1435
1457
  }
1436
1458
  }
1437
1459
 
@@ -2647,9 +2669,15 @@ class DeviceInput extends Component {
2647
2669
  get pointerPixel() {
2648
2670
  return this._pointerPixel;
2649
2671
  }
2672
+ get pointerDown() {
2673
+ return this._pointerDown;
2674
+ }
2650
2675
  get pointerButton() {
2651
2676
  return this._pointerButton;
2652
2677
  }
2678
+ get pointerMoving() {
2679
+ return this._pointerMoving;
2680
+ }
2653
2681
  get prePointer() {
2654
2682
  return this._prePointer;
2655
2683
  }
@@ -2677,6 +2705,9 @@ class DeviceInput extends Component {
2677
2705
  get keys() {
2678
2706
  return this._keys;
2679
2707
  }
2708
+ get pressability() {
2709
+ return this._pressability;
2710
+ }
2680
2711
  onEnable() {
2681
2712
  const dom = this._target;
2682
2713
  this._addEventListener(dom, 'contextmenu', (e)=>e.preventDefault());
@@ -2729,6 +2760,8 @@ class DeviceInput extends Component {
2729
2760
  this._listeners = [];
2730
2761
  }
2731
2762
  lastUpdate(dt) {
2763
+ this._pointerDown = false;
2764
+ this._pointerMoving = false;
2732
2765
  this._prePointer.copy(this._pointer);
2733
2766
  this._prePointerPixel.copy(this._pointerPixel);
2734
2767
  for(let i = this._touchCount; i--;){
@@ -2813,6 +2846,7 @@ class DeviceInput extends Component {
2813
2846
  }
2814
2847
  _onPointerDown(e) {
2815
2848
  e = this._remapPointer(e);
2849
+ this._pointerDown = true;
2816
2850
  this._pointerButton = e.button;
2817
2851
  this._computePointer(e);
2818
2852
  this._prePointer.copy(this._pointer);
@@ -2830,6 +2864,7 @@ class DeviceInput extends Component {
2830
2864
  _onPointerMove(e) {
2831
2865
  e = this._remapPointer(e);
2832
2866
  this._computePointer(e);
2867
+ this._pointerMoving = true;
2833
2868
  this._pressability.pointerMove(this._pointer, this.viewer.camera);
2834
2869
  this.viewer.emit(DeviceInput.POINTER_MOVE, e);
2835
2870
  }
@@ -2897,7 +2932,7 @@ class DeviceInput extends Component {
2897
2932
  this.viewer.emit(DeviceInput.KEYUP, e);
2898
2933
  }
2899
2934
  constructor(option){
2900
- super(), this._listeners = [], this._touches = [], this._touchCount = 0, this._touchStart = false, this._touchMoving = false, this._pointer = new THREE.Vector2(), this._pointerPixel = new THREE.Vector2(), this._pointerButton = -1, this._prePointer = new THREE.Vector2(), this._prePointerPixel = new THREE.Vector2(), this._preTouches = [], this._mouseWheel = 0, this._keys = {}, this._pressability = new Pressability();
2935
+ super(), this._listeners = [], this._touches = [], this._touchCount = 0, this._touchStart = false, this._touchMoving = false, this._pointer = new THREE.Vector2(), this._pointerPixel = new THREE.Vector2(), this._pointerButton = -1, this._pointerDown = false, this._pointerMoving = false, this._prePointer = new THREE.Vector2(), this._prePointerPixel = new THREE.Vector2(), this._preTouches = [], this._mouseWheel = 0, this._keys = {}, this._pressability = new Pressability();
2901
2936
  this._target = option.source;
2902
2937
  this._normalizeWheel = option.normalizeWheel || normalizeWheel;
2903
2938
  }
@@ -3127,6 +3162,13 @@ const { tan, PI } = Math;
3127
3162
  const PI2 = PI * 2;
3128
3163
  const ESP = 0.001;
3129
3164
  class FreelookVirtualCamera extends Component {
3165
+ get up() {
3166
+ return this._up;
3167
+ }
3168
+ set up(v) {
3169
+ this._up.copy(v);
3170
+ this._targetUp.copy(v);
3171
+ }
3130
3172
  get lookAt() {
3131
3173
  return this._lookAt;
3132
3174
  }
@@ -3141,11 +3183,11 @@ class FreelookVirtualCamera extends Component {
3141
3183
  this._offset.copy(v);
3142
3184
  this._targetOffset.copy(v);
3143
3185
  }
3144
- get springLength() {
3186
+ get radius() {
3145
3187
  return this._spherical.radius;
3146
3188
  }
3147
- set springLength(v) {
3148
- this._spherical.radius = this._targetSpringLength = clamp(v, this.distanceMin, this.distanceMax);
3189
+ set radius(v) {
3190
+ this._spherical.radius = this._targetRadius = clamp(v, this.radiusMin, this.radiusMax);
3149
3191
  }
3150
3192
  get theta() {
3151
3193
  return this._spherical.theta;
@@ -3197,18 +3239,20 @@ class FreelookVirtualCamera extends Component {
3197
3239
  this._targetFar = this.far;
3198
3240
  this._targetTheta = this.theta;
3199
3241
  this._targetPhi = this.phi;
3200
- this._targetSpringLength = this.springLength;
3242
+ this._targetRadius = this.radius;
3201
3243
  this._targetLookAt.copy(this._lookAt);
3244
+ this._targetUp.copy(this._up);
3202
3245
  }
3203
- 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 }) {
3246
+ 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 }) {
3204
3247
  const t0 = this._spherical.theta = this._spherical.theta % PI2;
3205
3248
  const t1 = theta % PI2;
3206
3249
  const delta = THREE.MathUtils.euclideanModulo(t1 - t0 + Math.PI, PI2) - Math.PI;
3207
3250
  this._targetTheta = clamp(t0 + delta, this.thetaMin, this.thetaMax);
3208
3251
  this._targetPhi = clamp(phi, this.phiMin, this.phiMax);
3209
- this._targetSpringLength = clamp(springLength, this.distanceMin, this.distanceMax);
3252
+ this._targetRadius = clamp(radius, this.radiusMin, this.radiusMax);
3210
3253
  this._targetLookAt.copy(lookAt);
3211
3254
  this._targetOffset.copy(offset);
3255
+ this._targetUp.copy(up);
3212
3256
  this._targetFov = fov;
3213
3257
  this._targetNear = near;
3214
3258
  this._targetFar = far;
@@ -3217,7 +3261,9 @@ class FreelookVirtualCamera extends Component {
3217
3261
  }
3218
3262
  update(dt) {
3219
3263
  this._lerpCamera(dt);
3220
- this._syncCamera();
3264
+ if (this.sync) {
3265
+ this._syncCamera();
3266
+ }
3221
3267
  }
3222
3268
  _onPointerDown(e) {
3223
3269
  if (SystemInfo.isMobile) return;
@@ -3269,7 +3315,7 @@ class FreelookVirtualCamera extends Component {
3269
3315
  }
3270
3316
  _calculateDistanceScale(scale) {
3271
3317
  this._tempRotateSmoothing = this.rotateSmoothing;
3272
- if (this.forbidZ) {
3318
+ if (this.forbitAll || this.forbidZ) {
3273
3319
  scale = 1;
3274
3320
  }
3275
3321
  return this._onDistanceScale(scale);
@@ -3278,10 +3324,10 @@ class FreelookVirtualCamera extends Component {
3278
3324
  this._tempRotateSmoothing = this.rotateSmoothing;
3279
3325
  out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / this.viewer.height);
3280
3326
  out.y = -out.y;
3281
- if (this.forbidX) {
3327
+ if (this.forbitAll || this.forbidX) {
3282
3328
  out.x = 0;
3283
3329
  }
3284
- if (this.forbidY) {
3330
+ if (this.forbitAll || this.forbidY) {
3285
3331
  out.y = 0;
3286
3332
  }
3287
3333
  return out;
@@ -3289,10 +3335,10 @@ class FreelookVirtualCamera extends Component {
3289
3335
  _calculatePanDelta(out, loc0, loc1) {
3290
3336
  this._tempRotateSmoothing = this.rotateSmoothing;
3291
3337
  this._onCalculatePan(out, loc0, loc1);
3292
- if (this.forbidPanX) {
3338
+ if (this.forbitAll || this.forbidPanX) {
3293
3339
  out.x = 0;
3294
3340
  }
3295
- if (this.forbidPanY) {
3341
+ if (this.forbitAll || this.forbidPanY) {
3296
3342
  out.y = 0;
3297
3343
  }
3298
3344
  return out;
@@ -3301,7 +3347,7 @@ class FreelookVirtualCamera extends Component {
3301
3347
  const { xAxis, yAxis, posDelta } = FreelookVirtualCamera;
3302
3348
  xAxis.setFromMatrixColumn(this.node.matrix, 0);
3303
3349
  yAxis.setFromMatrixColumn(this.node.matrix, 1);
3304
- if (this.forbitPanOffsetY) {
3350
+ if (this.forbitAll || this.forbitPanOffsetY) {
3305
3351
  yAxis.y = 0;
3306
3352
  yAxis.normalize();
3307
3353
  }
@@ -3324,11 +3370,11 @@ class FreelookVirtualCamera extends Component {
3324
3370
  this._targetPosition.y += panOffset.y;
3325
3371
  }
3326
3372
  _setTargetSpringLength(scale) {
3327
- this._targetSpringLength *= scale;
3328
- this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
3373
+ this._targetRadius *= scale;
3374
+ this._targetRadius = clamp(this._targetRadius, this.radiusMin, this.radiusMax);
3329
3375
  }
3330
3376
  constructor(){
3331
- super(), this._button = -1, this._touchID = -1, this._preLoc0 = new THREE.Vector2(), this._preLoc1 = new THREE.Vector2(), this._spherical = new THREE.Spherical(4, Math.PI / 2), this._lookAt = new THREE.Vector3(), this._offset = new THREE.Vector2(), this._fov = 45, this._near = 0.1, this._far = 1000, this._tempSmoothing = 6, this._tempRotateSmoothing = 8, this._targetPosition = new THREE.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 THREE.Vector3(), this._targetOffset = new THREE.Vector2(), this._finalLookAt = new THREE.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;
3377
+ super(), this._button = -1, this._touchID = -1, this._preLoc0 = new THREE.Vector2(), this._preLoc1 = new THREE.Vector2(), this._spherical = new THREE.Spherical(4, Math.PI / 2), this._lookAt = new THREE.Vector3(), this._up = new THREE.Vector3(0, 1, 0), this._offset = new THREE.Vector2(), this._fov = 45, this._near = 0.1, this._far = 1000, this._tempSmoothing = 6, this._tempRotateSmoothing = 8, this._targetPosition = new THREE.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 THREE.Vector3(), this._targetOffset = new THREE.Vector2(), this._targetUp = new THREE.Vector3(0, 1, 0), this._finalLookAt = new THREE.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;
3332
3378
  this.node = new THREE.Object3D();
3333
3379
  this.node.isCamera = true;
3334
3380
  this.onLoad = ()=>{
@@ -3371,10 +3417,12 @@ class FreelookVirtualCamera extends Component {
3371
3417
  const rotateSmoothing = this._tempRotateSmoothing;
3372
3418
  this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
3373
3419
  this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
3374
- this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
3420
+ this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
3375
3421
  VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
3376
3422
  VInterpTo(this._offset, this._targetOffset, dt, smoothing);
3423
+ VInterpTo(this._up, this._targetUp, dt, smoothing);
3377
3424
  this._calculateLookAtOffset(this._offset, this._finalLookAt).add(this._lookAt);
3425
+ this.node.up.copy(this._up);
3378
3426
  this.node.position.setFromSpherical(this._spherical).add(this._finalLookAt);
3379
3427
  this.node.lookAt(this._finalLookAt);
3380
3428
  this._fov = FInterpTo(this._fov, this._targetFov, dt, smoothing);
@@ -3394,7 +3442,7 @@ class FreelookVirtualCamera extends Component {
3394
3442
  }
3395
3443
  };
3396
3444
  } else if (camera instanceof THREE.OrthographicCamera) {
3397
- this.springLength = camera.zoom;
3445
+ this.radius = camera.zoom;
3398
3446
  this._onDistanceScale = (scale)=>{
3399
3447
  return 1 / scale;
3400
3448
  };
@@ -3424,7 +3472,7 @@ class FreelookVirtualCamera extends Component {
3424
3472
  const smoothing = this._tempSmoothing;
3425
3473
  this.node.position.x = FInterpTo(this.node.position.x, this._targetPosition.x, dt, smoothing);
3426
3474
  this.node.position.y = FInterpTo(this.node.position.y, this._targetPosition.y, dt, smoothing);
3427
- this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpringLength, dt, smoothing);
3475
+ this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
3428
3476
  };
3429
3477
  this._syncCamera = ()=>{
3430
3478
  const { zoom } = camera;
@@ -3450,6 +3498,14 @@ FreelookVirtualCamera.lookAtOffset = new THREE.Vector3();
3450
3498
  FreelookVirtualCamera.xAxis = new THREE.Vector3();
3451
3499
  FreelookVirtualCamera.yAxis = new THREE.Vector3();
3452
3500
  FreelookVirtualCamera.quat = new THREE.Quaternion();
3501
+ __decorate([
3502
+ property
3503
+ ], FreelookVirtualCamera.prototype, "sync", void 0);
3504
+ __decorate([
3505
+ property({
3506
+ dir: "set"
3507
+ })
3508
+ ], FreelookVirtualCamera.prototype, "forbitAll", void 0);
3453
3509
  __decorate([
3454
3510
  property({
3455
3511
  dir: "set"
@@ -3533,24 +3589,33 @@ __decorate([
3533
3589
  dir: "set",
3534
3590
  step: 0.01
3535
3591
  })
3536
- ], FreelookVirtualCamera.prototype, "distanceMin", void 0);
3592
+ ], FreelookVirtualCamera.prototype, "radiusMin", void 0);
3537
3593
  __decorate([
3538
3594
  property({
3539
3595
  dir: "set",
3540
3596
  step: 0.01
3541
3597
  })
3542
- ], FreelookVirtualCamera.prototype, "distanceMax", void 0);
3598
+ ], FreelookVirtualCamera.prototype, "radiusMax", void 0);
3543
3599
  __decorate([
3544
- property
3600
+ property({
3601
+ step: 0.01
3602
+ })
3603
+ ], FreelookVirtualCamera.prototype, "up", null);
3604
+ __decorate([
3605
+ property({
3606
+ step: 0.01
3607
+ })
3545
3608
  ], FreelookVirtualCamera.prototype, "lookAt", null);
3546
3609
  __decorate([
3547
- property
3610
+ property({
3611
+ step: 0.01
3612
+ })
3548
3613
  ], FreelookVirtualCamera.prototype, "offset", null);
3549
3614
  __decorate([
3550
3615
  property({
3551
3616
  step: 0.01
3552
3617
  })
3553
- ], FreelookVirtualCamera.prototype, "springLength", null);
3618
+ ], FreelookVirtualCamera.prototype, "radius", null);
3554
3619
  __decorate([
3555
3620
  property({
3556
3621
  step: 0.01
@@ -3934,6 +3999,12 @@ class ReflectorMaterial extends THREE.ShaderMaterial {
3934
3999
  set aoMap(v) {
3935
4000
  this.uniforms.aoMap.value = v;
3936
4001
  }
4002
+ get aoMapIntensity() {
4003
+ return this.uniforms.aoMapIntensity.value;
4004
+ }
4005
+ set aoMapIntensity(v) {
4006
+ this.uniforms.aoMapIntensity.value = v;
4007
+ }
3937
4008
  get lightMap() {
3938
4009
  return this.uniforms.lightMap.value;
3939
4010
  }
@@ -4012,14 +4083,17 @@ class ReflectorMaterial extends THREE.ShaderMaterial {
4012
4083
  },
4013
4084
  lightMapIntensity: {
4014
4085
  value: 1
4086
+ },
4087
+ dfgLUT: {
4088
+ value: null
4015
4089
  }
4016
4090
  };
4017
4091
  Object.defineProperty(this, "opacity", {
4018
4092
  get: ()=>this.uniforms.opacity.value,
4019
4093
  set: (v)=>this.uniforms.opacity.value = v
4020
4094
  });
4021
- this.uniforms.reflectMap.value = reflector.getRenderTarget().texture;
4022
- this.uniforms.textureMatrix.value = reflector.getTextureMatrix();
4095
+ this.uniforms.reflectMap.value = reflector.texture;
4096
+ this.uniforms.textureMatrix.value = reflector.textureMatrix;
4023
4097
  this.setValues(parameters);
4024
4098
  }
4025
4099
  }
@@ -4058,6 +4132,12 @@ __decorate([
4058
4132
  __decorate([
4059
4133
  property
4060
4134
  ], ReflectorMaterial.prototype, "aoMap", null);
4135
+ __decorate([
4136
+ property({
4137
+ min: 0,
4138
+ max: 1
4139
+ })
4140
+ ], ReflectorMaterial.prototype, "aoMapIntensity", null);
4061
4141
  __decorate([
4062
4142
  property
4063
4143
  ], ReflectorMaterial.prototype, "lightMap", null);
@@ -4730,6 +4810,12 @@ class Viewer extends EventEmitter {
4730
4810
  get renderer() {
4731
4811
  return this._renderer;
4732
4812
  }
4813
+ get freeze() {
4814
+ return this._freeze;
4815
+ }
4816
+ set freeze(v) {
4817
+ this._freeze = v;
4818
+ }
4733
4819
  destroy() {
4734
4820
  this.stop();
4735
4821
  this._renderer.dispose();
@@ -4751,44 +4837,43 @@ class Viewer extends EventEmitter {
4751
4837
  };
4752
4838
  }
4753
4839
  }
4754
- _frame(time) {
4755
- this._time = time;
4756
- if (this._targetFrameRate > -1) {
4757
- const interval = 1 / this._targetFrameRate;
4758
- const delta = this._time - this._lastFrameTime;
4759
- if (delta >= interval) {
4760
- this.loop(this._fixedFrameTime ? interval : this._time - this._lastTime);
4761
- this._lastTime = this._time;
4762
- this._lastFrameTime = this._time - delta % interval;
4840
+ animate() {
4841
+ const loop = (dt)=>{
4842
+ if (!this._active) return;
4843
+ if (this._resourceManager.isComplete) {
4844
+ this._taskManager.isComplete ? this._running = true : this._taskManager.update();
4763
4845
  }
4764
- } else {
4765
- this.loop(this._time - this._lastTime);
4766
- this._lastTime = this._time;
4767
- }
4768
- }
4769
- loop(dt) {
4770
- if (this._resourceManager.isComplete) {
4771
- this._taskManager.update();
4772
- if (this._taskManager.isComplete) {
4773
- this._running = true;
4846
+ if (this._running) {
4847
+ dt = Math.min(dt, 0.067);
4848
+ this._renderer.info.reset();
4849
+ this._componentManager.update(dt);
4850
+ if (!this._freeze) {
4851
+ this._componentManager.render(dt);
4852
+ }
4774
4853
  }
4775
- }
4776
- if (this._running) {
4777
- dt = Math.min(dt, 0.067);
4778
- this._renderer.info.reset();
4779
- this._componentManager.update(dt);
4780
- this._componentManager.render(dt);
4781
- }
4854
+ };
4855
+ const frame = (time)=>{
4856
+ this._time = time * 0.001;
4857
+ if (this._targetFrameRate > -1) {
4858
+ const interval = 1 / this._targetFrameRate;
4859
+ const delta = this._time - this._lastFrameTime;
4860
+ if (delta >= interval) {
4861
+ loop(this._fixedFrameTime ? interval : this._time - this._lastTime);
4862
+ this._lastTime = this._time;
4863
+ this._lastFrameTime = this._time - delta % interval;
4864
+ }
4865
+ } else {
4866
+ loop(this._time - this._lastTime);
4867
+ this._lastTime = this._time;
4868
+ }
4869
+ };
4870
+ this._renderer.setAnimationLoop(frame);
4782
4871
  }
4783
4872
  start() {
4784
- if (this._active == false) {
4873
+ if (this._active === false) {
4785
4874
  this._active = true;
4786
- const frameCallback = (time)=>{
4787
- if (this._active) {
4788
- this._frame(time * 0.001);
4789
- }
4790
- };
4791
- this._renderer.setAnimationLoop(frameCallback);
4875
+ this.rotate();
4876
+ this.resize();
4792
4877
  }
4793
4878
  return this;
4794
4879
  }
@@ -4903,7 +4988,7 @@ class Viewer extends EventEmitter {
4903
4988
  this._taskManager.add(new Task(excute));
4904
4989
  return target;
4905
4990
  }
4906
- add(object, { node, args, scale, parent, position, rotation, manual, makeDefault, component, layerMask, ...props } = {}) {
4991
+ add(object, { node, args, scale, parent, position, rotation, manual, makeDefault, component, layerMask, children, ...props } = {}) {
4907
4992
  let mount = false;
4908
4993
  let ins = getClassInstance(object, args);
4909
4994
  if (ins.isObject3D) {
@@ -4928,7 +5013,7 @@ class Viewer extends EventEmitter {
4928
5013
  if (parent === undefined) {
4929
5014
  parent = mount ? this._mount : this._scene;
4930
5015
  }
4931
- if (parent && !node.parent) {
5016
+ if (parent !== node) {
4932
5017
  parent.add(node);
4933
5018
  }
4934
5019
  if (component) {
@@ -4939,6 +5024,12 @@ class Viewer extends EventEmitter {
4939
5024
  this._componentManager.addComponent(node, comp);
4940
5025
  }
4941
5026
  }
5027
+ if (children) {
5028
+ const children_ = Array.isArray(children) ? children : [
5029
+ children
5030
+ ];
5031
+ node.add(...children_);
5032
+ }
4942
5033
  if (layerMask) {
4943
5034
  node.layers.mask = layerMask;
4944
5035
  }
@@ -5148,10 +5239,10 @@ class Viewer extends EventEmitter {
5148
5239
  width: 1,
5149
5240
  height: 1,
5150
5241
  factor: 1
5151
- }, 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 = ()=>[
5242
+ }, 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 = ()=>[
5152
5243
  window.innerWidth,
5153
5244
  window.innerHeight
5154
- ], this._orientation = Orientation.AUTO;
5245
+ ], this._orientation = Orientation.AUTO, this._freeze = false;
5155
5246
  const el = canvas || document.getElementById("canvas");
5156
5247
  const webgl = checkWebGL(el, webglOpts);
5157
5248
  if (!webgl) {
@@ -5206,11 +5297,9 @@ class Viewer extends EventEmitter {
5206
5297
  this.addLoader(BINLoader);
5207
5298
  this.addLoader(SVGLoader);
5208
5299
  this.addLoader(KTX2Loader);
5209
- setTimeout(()=>{
5210
- this.rotate();
5211
- this.resize();
5212
- this.start();
5213
- });
5300
+ this.rotate();
5301
+ this.resize();
5302
+ this.animate();
5214
5303
  }
5215
5304
  }
5216
5305
  Viewer.instanceCount = 0;
@@ -5290,8 +5379,6 @@ class MergeRefectPass {
5290
5379
  this._cubeMapMaterial = _getCubeMapMaterial();
5291
5380
  this._copyTexMaterial = _getClearMaterial();
5292
5381
  this._copyMesh = new THREE.Mesh(Viewer.fullscreenMesh.geometry, this._copyTexMaterial);
5293
- this._lodMeshes = this._lodPlanes.map((v)=>new THREE.Mesh(v, this._cubeMapMaterial));
5294
- this._sourceInit = false;
5295
5382
  return target;
5296
5383
  };
5297
5384
  pmremGenerator._fromCubeTexture = function(texture) {
@@ -5422,7 +5509,6 @@ class MergeMipBlurPass {
5422
5509
  const target = this._allocateTargets();
5423
5510
  this._mipBlurMaterial = _getMipBlurMaterial(this._lodMax, target.width, target.height);
5424
5511
  this._mipCopyMaterial = _getMipCopyMaterial(this._lodMax, target.width, target.height);
5425
- this._lodMeshes = this._lodPlanes.map((v)=>new THREE.Mesh(v, this._mipBlurMaterial));
5426
5512
  return target;
5427
5513
  };
5428
5514
  pmremGenerator._applyMipBlur = function(sourceTarget, texture, blurMinLod, blurMaxLod, sigma, exposure = 1) {
@@ -5623,7 +5709,7 @@ class BoxProjection extends Component {
5623
5709
  `);
5624
5710
  THREE.ShaderLib.physical.fragmentShader = THREE.ShaderLib.physical.fragmentShader.replace("varying vec3 vViewPosition;", `
5625
5711
  varying vec3 vViewPosition;
5626
- #if defined(USE_BOX_PROJECTION)
5712
+ #if defined(USE_TRANSMISSION) || defined(USE_BOX_PROJECTION)
5627
5713
  varying vec3 vWorldPosition;
5628
5714
  #endif
5629
5715
  `);
@@ -5663,7 +5749,6 @@ class BoxProjection extends Component {
5663
5749
  worldNormal = boxProjection(worldNormal, vWorldPosition, probePos.xyz, probeBoxMin.xyz, probeBoxMax.xyz);
5664
5750
  }
5665
5751
  #endif
5666
-
5667
5752
  `);
5668
5753
  }
5669
5754
  useBoxProjection(shader) {
@@ -6503,6 +6588,9 @@ void main() {
6503
6588
 
6504
6589
  color.a *= u_opacity;
6505
6590
  gl_FragColor = color;
6591
+
6592
+ #include <tonemapping_fragment>
6593
+ #include <colorspace_fragment>
6506
6594
  }
6507
6595
  `;
6508
6596
  class BMFontAtlas {
@@ -6584,13 +6672,13 @@ class BMFontAtlas {
6584
6672
  value: 0.2
6585
6673
  },
6586
6674
  u_strokeColor: {
6587
- value: new THREE.Color(0xff0000)
6675
+ value: new THREE.Color(0xffffff)
6588
6676
  },
6589
6677
  u_strokeWidth: {
6590
6678
  value: 0
6591
6679
  },
6592
6680
  u_shadowColor: {
6593
- value: new THREE.Color(0xff0000)
6681
+ value: new THREE.Color(0xffffff)
6594
6682
  },
6595
6683
  u_shadowBlur: {
6596
6684
  value: 0
@@ -6701,6 +6789,7 @@ exports.mixin = mixin;
6701
6789
  exports.property = property;
6702
6790
  exports.quarticDamp = quarticDamp;
6703
6791
  exports.queryValues = queryValues;
6792
+ exports.single = single;
6704
6793
  exports.smoothDamp = smoothDamp;
6705
6794
  exports.vert_fullscreen = vert_fullscreen;
6706
6795
  //# sourceMappingURL=main.cjs.map