@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/main.cjs +119 -55
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +120 -57
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +3 -0
- package/types/components/FreelookVirtualCamera.d.ts +14 -7
- package/types/components/Reflector.d.ts +6 -3
- package/types/index.d.ts +1 -1
- package/types/loaders/GLTFLoader.d.ts +8 -0
- package/types/loaders/index.d.ts +1 -1
package/dist/main.cjs
CHANGED
|
@@ -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,
|
|
295
|
+
loader.parse(buffer, resourcePath, cb, onError);
|
|
278
296
|
} else {
|
|
279
|
-
loader.load(url,
|
|
297
|
+
loader.load(url, cb, onProgress, onError);
|
|
280
298
|
}
|
|
281
299
|
}
|
|
282
300
|
constructor(...args){
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
|
@@ -3140,6 +3162,13 @@ const { tan, PI } = Math;
|
|
|
3140
3162
|
const PI2 = PI * 2;
|
|
3141
3163
|
const ESP = 0.001;
|
|
3142
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
|
+
}
|
|
3143
3172
|
get lookAt() {
|
|
3144
3173
|
return this._lookAt;
|
|
3145
3174
|
}
|
|
@@ -3154,11 +3183,11 @@ class FreelookVirtualCamera extends Component {
|
|
|
3154
3183
|
this._offset.copy(v);
|
|
3155
3184
|
this._targetOffset.copy(v);
|
|
3156
3185
|
}
|
|
3157
|
-
get
|
|
3186
|
+
get radius() {
|
|
3158
3187
|
return this._spherical.radius;
|
|
3159
3188
|
}
|
|
3160
|
-
set
|
|
3161
|
-
this._spherical.radius = this.
|
|
3189
|
+
set radius(v) {
|
|
3190
|
+
this._spherical.radius = this._targetRadius = clamp(v, this.radiusMin, this.radiusMax);
|
|
3162
3191
|
}
|
|
3163
3192
|
get theta() {
|
|
3164
3193
|
return this._spherical.theta;
|
|
@@ -3210,18 +3239,20 @@ class FreelookVirtualCamera extends Component {
|
|
|
3210
3239
|
this._targetFar = this.far;
|
|
3211
3240
|
this._targetTheta = this.theta;
|
|
3212
3241
|
this._targetPhi = this.phi;
|
|
3213
|
-
this.
|
|
3242
|
+
this._targetRadius = this.radius;
|
|
3214
3243
|
this._targetLookAt.copy(this._lookAt);
|
|
3244
|
+
this._targetUp.copy(this._up);
|
|
3215
3245
|
}
|
|
3216
|
-
goto({ phi = this._targetPhi, theta = this._targetTheta,
|
|
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 }) {
|
|
3217
3247
|
const t0 = this._spherical.theta = this._spherical.theta % PI2;
|
|
3218
3248
|
const t1 = theta % PI2;
|
|
3219
3249
|
const delta = THREE.MathUtils.euclideanModulo(t1 - t0 + Math.PI, PI2) - Math.PI;
|
|
3220
3250
|
this._targetTheta = clamp(t0 + delta, this.thetaMin, this.thetaMax);
|
|
3221
3251
|
this._targetPhi = clamp(phi, this.phiMin, this.phiMax);
|
|
3222
|
-
this.
|
|
3252
|
+
this._targetRadius = clamp(radius, this.radiusMin, this.radiusMax);
|
|
3223
3253
|
this._targetLookAt.copy(lookAt);
|
|
3224
3254
|
this._targetOffset.copy(offset);
|
|
3255
|
+
this._targetUp.copy(up);
|
|
3225
3256
|
this._targetFov = fov;
|
|
3226
3257
|
this._targetNear = near;
|
|
3227
3258
|
this._targetFar = far;
|
|
@@ -3230,7 +3261,9 @@ class FreelookVirtualCamera extends Component {
|
|
|
3230
3261
|
}
|
|
3231
3262
|
update(dt) {
|
|
3232
3263
|
this._lerpCamera(dt);
|
|
3233
|
-
this.
|
|
3264
|
+
if (this.sync) {
|
|
3265
|
+
this._syncCamera();
|
|
3266
|
+
}
|
|
3234
3267
|
}
|
|
3235
3268
|
_onPointerDown(e) {
|
|
3236
3269
|
if (SystemInfo.isMobile) return;
|
|
@@ -3282,7 +3315,7 @@ class FreelookVirtualCamera extends Component {
|
|
|
3282
3315
|
}
|
|
3283
3316
|
_calculateDistanceScale(scale) {
|
|
3284
3317
|
this._tempRotateSmoothing = this.rotateSmoothing;
|
|
3285
|
-
if (this.forbidZ) {
|
|
3318
|
+
if (this.forbitAll || this.forbidZ) {
|
|
3286
3319
|
scale = 1;
|
|
3287
3320
|
}
|
|
3288
3321
|
return this._onDistanceScale(scale);
|
|
@@ -3291,10 +3324,10 @@ class FreelookVirtualCamera extends Component {
|
|
|
3291
3324
|
this._tempRotateSmoothing = this.rotateSmoothing;
|
|
3292
3325
|
out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / this.viewer.height);
|
|
3293
3326
|
out.y = -out.y;
|
|
3294
|
-
if (this.forbidX) {
|
|
3327
|
+
if (this.forbitAll || this.forbidX) {
|
|
3295
3328
|
out.x = 0;
|
|
3296
3329
|
}
|
|
3297
|
-
if (this.forbidY) {
|
|
3330
|
+
if (this.forbitAll || this.forbidY) {
|
|
3298
3331
|
out.y = 0;
|
|
3299
3332
|
}
|
|
3300
3333
|
return out;
|
|
@@ -3302,10 +3335,10 @@ class FreelookVirtualCamera extends Component {
|
|
|
3302
3335
|
_calculatePanDelta(out, loc0, loc1) {
|
|
3303
3336
|
this._tempRotateSmoothing = this.rotateSmoothing;
|
|
3304
3337
|
this._onCalculatePan(out, loc0, loc1);
|
|
3305
|
-
if (this.forbidPanX) {
|
|
3338
|
+
if (this.forbitAll || this.forbidPanX) {
|
|
3306
3339
|
out.x = 0;
|
|
3307
3340
|
}
|
|
3308
|
-
if (this.forbidPanY) {
|
|
3341
|
+
if (this.forbitAll || this.forbidPanY) {
|
|
3309
3342
|
out.y = 0;
|
|
3310
3343
|
}
|
|
3311
3344
|
return out;
|
|
@@ -3314,7 +3347,7 @@ class FreelookVirtualCamera extends Component {
|
|
|
3314
3347
|
const { xAxis, yAxis, posDelta } = FreelookVirtualCamera;
|
|
3315
3348
|
xAxis.setFromMatrixColumn(this.node.matrix, 0);
|
|
3316
3349
|
yAxis.setFromMatrixColumn(this.node.matrix, 1);
|
|
3317
|
-
if (this.forbitPanOffsetY) {
|
|
3350
|
+
if (this.forbitAll || this.forbitPanOffsetY) {
|
|
3318
3351
|
yAxis.y = 0;
|
|
3319
3352
|
yAxis.normalize();
|
|
3320
3353
|
}
|
|
@@ -3337,11 +3370,11 @@ class FreelookVirtualCamera extends Component {
|
|
|
3337
3370
|
this._targetPosition.y += panOffset.y;
|
|
3338
3371
|
}
|
|
3339
3372
|
_setTargetSpringLength(scale) {
|
|
3340
|
-
this.
|
|
3341
|
-
this.
|
|
3373
|
+
this._targetRadius *= scale;
|
|
3374
|
+
this._targetRadius = clamp(this._targetRadius, this.radiusMin, this.radiusMax);
|
|
3342
3375
|
}
|
|
3343
3376
|
constructor(){
|
|
3344
|
-
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.
|
|
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;
|
|
3345
3378
|
this.node = new THREE.Object3D();
|
|
3346
3379
|
this.node.isCamera = true;
|
|
3347
3380
|
this.onLoad = ()=>{
|
|
@@ -3384,10 +3417,12 @@ class FreelookVirtualCamera extends Component {
|
|
|
3384
3417
|
const rotateSmoothing = this._tempRotateSmoothing;
|
|
3385
3418
|
this._spherical.theta = FInterpTo(this._spherical.theta, this._targetTheta, dt, rotateSmoothing);
|
|
3386
3419
|
this._spherical.phi = FInterpTo(this._spherical.phi, this._targetPhi, dt, rotateSmoothing);
|
|
3387
|
-
this._spherical.radius = FInterpTo(this._spherical.radius, this.
|
|
3420
|
+
this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
|
|
3388
3421
|
VInterpTo(this._lookAt, this._targetLookAt, dt, smoothing);
|
|
3389
3422
|
VInterpTo(this._offset, this._targetOffset, dt, smoothing);
|
|
3423
|
+
VInterpTo(this._up, this._targetUp, dt, smoothing);
|
|
3390
3424
|
this._calculateLookAtOffset(this._offset, this._finalLookAt).add(this._lookAt);
|
|
3425
|
+
this.node.up.copy(this._up);
|
|
3391
3426
|
this.node.position.setFromSpherical(this._spherical).add(this._finalLookAt);
|
|
3392
3427
|
this.node.lookAt(this._finalLookAt);
|
|
3393
3428
|
this._fov = FInterpTo(this._fov, this._targetFov, dt, smoothing);
|
|
@@ -3407,7 +3442,7 @@ class FreelookVirtualCamera extends Component {
|
|
|
3407
3442
|
}
|
|
3408
3443
|
};
|
|
3409
3444
|
} else if (camera instanceof THREE.OrthographicCamera) {
|
|
3410
|
-
this.
|
|
3445
|
+
this.radius = camera.zoom;
|
|
3411
3446
|
this._onDistanceScale = (scale)=>{
|
|
3412
3447
|
return 1 / scale;
|
|
3413
3448
|
};
|
|
@@ -3437,7 +3472,7 @@ class FreelookVirtualCamera extends Component {
|
|
|
3437
3472
|
const smoothing = this._tempSmoothing;
|
|
3438
3473
|
this.node.position.x = FInterpTo(this.node.position.x, this._targetPosition.x, dt, smoothing);
|
|
3439
3474
|
this.node.position.y = FInterpTo(this.node.position.y, this._targetPosition.y, dt, smoothing);
|
|
3440
|
-
this._spherical.radius = FInterpTo(this._spherical.radius, this.
|
|
3475
|
+
this._spherical.radius = FInterpTo(this._spherical.radius, this._targetRadius, dt, smoothing);
|
|
3441
3476
|
};
|
|
3442
3477
|
this._syncCamera = ()=>{
|
|
3443
3478
|
const { zoom } = camera;
|
|
@@ -3463,6 +3498,14 @@ FreelookVirtualCamera.lookAtOffset = new THREE.Vector3();
|
|
|
3463
3498
|
FreelookVirtualCamera.xAxis = new THREE.Vector3();
|
|
3464
3499
|
FreelookVirtualCamera.yAxis = new THREE.Vector3();
|
|
3465
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);
|
|
3466
3509
|
__decorate([
|
|
3467
3510
|
property({
|
|
3468
3511
|
dir: "set"
|
|
@@ -3546,24 +3589,33 @@ __decorate([
|
|
|
3546
3589
|
dir: "set",
|
|
3547
3590
|
step: 0.01
|
|
3548
3591
|
})
|
|
3549
|
-
], FreelookVirtualCamera.prototype, "
|
|
3592
|
+
], FreelookVirtualCamera.prototype, "radiusMin", void 0);
|
|
3550
3593
|
__decorate([
|
|
3551
3594
|
property({
|
|
3552
3595
|
dir: "set",
|
|
3553
3596
|
step: 0.01
|
|
3554
3597
|
})
|
|
3555
|
-
], FreelookVirtualCamera.prototype, "
|
|
3598
|
+
], FreelookVirtualCamera.prototype, "radiusMax", void 0);
|
|
3556
3599
|
__decorate([
|
|
3557
|
-
property
|
|
3600
|
+
property({
|
|
3601
|
+
step: 0.01
|
|
3602
|
+
})
|
|
3603
|
+
], FreelookVirtualCamera.prototype, "up", null);
|
|
3604
|
+
__decorate([
|
|
3605
|
+
property({
|
|
3606
|
+
step: 0.01
|
|
3607
|
+
})
|
|
3558
3608
|
], FreelookVirtualCamera.prototype, "lookAt", null);
|
|
3559
3609
|
__decorate([
|
|
3560
|
-
property
|
|
3610
|
+
property({
|
|
3611
|
+
step: 0.01
|
|
3612
|
+
})
|
|
3561
3613
|
], FreelookVirtualCamera.prototype, "offset", null);
|
|
3562
3614
|
__decorate([
|
|
3563
3615
|
property({
|
|
3564
3616
|
step: 0.01
|
|
3565
3617
|
})
|
|
3566
|
-
], FreelookVirtualCamera.prototype, "
|
|
3618
|
+
], FreelookVirtualCamera.prototype, "radius", null);
|
|
3567
3619
|
__decorate([
|
|
3568
3620
|
property({
|
|
3569
3621
|
step: 0.01
|
|
@@ -4040,8 +4092,8 @@ class ReflectorMaterial extends THREE.ShaderMaterial {
|
|
|
4040
4092
|
get: ()=>this.uniforms.opacity.value,
|
|
4041
4093
|
set: (v)=>this.uniforms.opacity.value = v
|
|
4042
4094
|
});
|
|
4043
|
-
this.uniforms.reflectMap.value = reflector.
|
|
4044
|
-
this.uniforms.textureMatrix.value = reflector.
|
|
4095
|
+
this.uniforms.reflectMap.value = reflector.texture;
|
|
4096
|
+
this.uniforms.textureMatrix.value = reflector.textureMatrix;
|
|
4045
4097
|
this.setValues(parameters);
|
|
4046
4098
|
}
|
|
4047
4099
|
}
|
|
@@ -4758,6 +4810,12 @@ class Viewer extends EventEmitter {
|
|
|
4758
4810
|
get renderer() {
|
|
4759
4811
|
return this._renderer;
|
|
4760
4812
|
}
|
|
4813
|
+
get freeze() {
|
|
4814
|
+
return this._freeze;
|
|
4815
|
+
}
|
|
4816
|
+
set freeze(v) {
|
|
4817
|
+
this._freeze = v;
|
|
4818
|
+
}
|
|
4761
4819
|
destroy() {
|
|
4762
4820
|
this.stop();
|
|
4763
4821
|
this._renderer.dispose();
|
|
@@ -4789,7 +4847,9 @@ class Viewer extends EventEmitter {
|
|
|
4789
4847
|
dt = Math.min(dt, 0.067);
|
|
4790
4848
|
this._renderer.info.reset();
|
|
4791
4849
|
this._componentManager.update(dt);
|
|
4792
|
-
this.
|
|
4850
|
+
if (!this._freeze) {
|
|
4851
|
+
this._componentManager.render(dt);
|
|
4852
|
+
}
|
|
4793
4853
|
}
|
|
4794
4854
|
};
|
|
4795
4855
|
const frame = (time)=>{
|
|
@@ -4812,10 +4872,8 @@ class Viewer extends EventEmitter {
|
|
|
4812
4872
|
start() {
|
|
4813
4873
|
if (this._active === false) {
|
|
4814
4874
|
this._active = true;
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
this.resize();
|
|
4818
|
-
});
|
|
4875
|
+
this.rotate();
|
|
4876
|
+
this.resize();
|
|
4819
4877
|
}
|
|
4820
4878
|
return this;
|
|
4821
4879
|
}
|
|
@@ -4930,7 +4988,7 @@ class Viewer extends EventEmitter {
|
|
|
4930
4988
|
this._taskManager.add(new Task(excute));
|
|
4931
4989
|
return target;
|
|
4932
4990
|
}
|
|
4933
|
-
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 } = {}) {
|
|
4934
4992
|
let mount = false;
|
|
4935
4993
|
let ins = getClassInstance(object, args);
|
|
4936
4994
|
if (ins.isObject3D) {
|
|
@@ -4955,7 +5013,7 @@ class Viewer extends EventEmitter {
|
|
|
4955
5013
|
if (parent === undefined) {
|
|
4956
5014
|
parent = mount ? this._mount : this._scene;
|
|
4957
5015
|
}
|
|
4958
|
-
if (parent !== node
|
|
5016
|
+
if (parent !== node) {
|
|
4959
5017
|
parent.add(node);
|
|
4960
5018
|
}
|
|
4961
5019
|
if (component) {
|
|
@@ -4966,6 +5024,12 @@ class Viewer extends EventEmitter {
|
|
|
4966
5024
|
this._componentManager.addComponent(node, comp);
|
|
4967
5025
|
}
|
|
4968
5026
|
}
|
|
5027
|
+
if (children) {
|
|
5028
|
+
const children_ = Array.isArray(children) ? children : [
|
|
5029
|
+
children
|
|
5030
|
+
];
|
|
5031
|
+
node.add(...children_);
|
|
5032
|
+
}
|
|
4969
5033
|
if (layerMask) {
|
|
4970
5034
|
node.layers.mask = layerMask;
|
|
4971
5035
|
}
|
|
@@ -5178,7 +5242,7 @@ class Viewer extends EventEmitter {
|
|
|
5178
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 = ()=>[
|
|
5179
5243
|
window.innerWidth,
|
|
5180
5244
|
window.innerHeight
|
|
5181
|
-
], this._orientation = Orientation.AUTO;
|
|
5245
|
+
], this._orientation = Orientation.AUTO, this._freeze = false;
|
|
5182
5246
|
const el = canvas || document.getElementById("canvas");
|
|
5183
5247
|
const webgl = checkWebGL(el, webglOpts);
|
|
5184
5248
|
if (!webgl) {
|
|
@@ -5315,8 +5379,6 @@ class MergeRefectPass {
|
|
|
5315
5379
|
this._cubeMapMaterial = _getCubeMapMaterial();
|
|
5316
5380
|
this._copyTexMaterial = _getClearMaterial();
|
|
5317
5381
|
this._copyMesh = new THREE.Mesh(Viewer.fullscreenMesh.geometry, this._copyTexMaterial);
|
|
5318
|
-
this._lodMeshes = this._lodPlanes.map((v)=>new THREE.Mesh(v, this._cubeMapMaterial));
|
|
5319
|
-
this._sourceInit = false;
|
|
5320
5382
|
return target;
|
|
5321
5383
|
};
|
|
5322
5384
|
pmremGenerator._fromCubeTexture = function(texture) {
|
|
@@ -5447,7 +5509,6 @@ class MergeMipBlurPass {
|
|
|
5447
5509
|
const target = this._allocateTargets();
|
|
5448
5510
|
this._mipBlurMaterial = _getMipBlurMaterial(this._lodMax, target.width, target.height);
|
|
5449
5511
|
this._mipCopyMaterial = _getMipCopyMaterial(this._lodMax, target.width, target.height);
|
|
5450
|
-
this._lodMeshes = this._lodPlanes.map((v)=>new THREE.Mesh(v, this._mipBlurMaterial));
|
|
5451
5512
|
return target;
|
|
5452
5513
|
};
|
|
5453
5514
|
pmremGenerator._applyMipBlur = function(sourceTarget, texture, blurMinLod, blurMaxLod, sigma, exposure = 1) {
|
|
@@ -5648,7 +5709,7 @@ class BoxProjection extends Component {
|
|
|
5648
5709
|
`);
|
|
5649
5710
|
THREE.ShaderLib.physical.fragmentShader = THREE.ShaderLib.physical.fragmentShader.replace("varying vec3 vViewPosition;", `
|
|
5650
5711
|
varying vec3 vViewPosition;
|
|
5651
|
-
#if defined(USE_BOX_PROJECTION)
|
|
5712
|
+
#if defined(USE_TRANSMISSION) || defined(USE_BOX_PROJECTION)
|
|
5652
5713
|
varying vec3 vWorldPosition;
|
|
5653
5714
|
#endif
|
|
5654
5715
|
`);
|
|
@@ -5688,7 +5749,6 @@ class BoxProjection extends Component {
|
|
|
5688
5749
|
worldNormal = boxProjection(worldNormal, vWorldPosition, probePos.xyz, probeBoxMin.xyz, probeBoxMax.xyz);
|
|
5689
5750
|
}
|
|
5690
5751
|
#endif
|
|
5691
|
-
|
|
5692
5752
|
`);
|
|
5693
5753
|
}
|
|
5694
5754
|
useBoxProjection(shader) {
|
|
@@ -6528,6 +6588,9 @@ void main() {
|
|
|
6528
6588
|
|
|
6529
6589
|
color.a *= u_opacity;
|
|
6530
6590
|
gl_FragColor = color;
|
|
6591
|
+
|
|
6592
|
+
#include <tonemapping_fragment>
|
|
6593
|
+
#include <colorspace_fragment>
|
|
6531
6594
|
}
|
|
6532
6595
|
`;
|
|
6533
6596
|
class BMFontAtlas {
|
|
@@ -6609,13 +6672,13 @@ class BMFontAtlas {
|
|
|
6609
6672
|
value: 0.2
|
|
6610
6673
|
},
|
|
6611
6674
|
u_strokeColor: {
|
|
6612
|
-
value: new THREE.Color(
|
|
6675
|
+
value: new THREE.Color(0xffffff)
|
|
6613
6676
|
},
|
|
6614
6677
|
u_strokeWidth: {
|
|
6615
6678
|
value: 0
|
|
6616
6679
|
},
|
|
6617
6680
|
u_shadowColor: {
|
|
6618
|
-
value: new THREE.Color(
|
|
6681
|
+
value: new THREE.Color(0xffffff)
|
|
6619
6682
|
},
|
|
6620
6683
|
u_shadowBlur: {
|
|
6621
6684
|
value: 0
|
|
@@ -6726,6 +6789,7 @@ exports.mixin = mixin;
|
|
|
6726
6789
|
exports.property = property;
|
|
6727
6790
|
exports.quarticDamp = quarticDamp;
|
|
6728
6791
|
exports.queryValues = queryValues;
|
|
6792
|
+
exports.single = single;
|
|
6729
6793
|
exports.smoothDamp = smoothDamp;
|
|
6730
6794
|
exports.vert_fullscreen = vert_fullscreen;
|
|
6731
6795
|
//# sourceMappingURL=main.cjs.map
|