@xviewer.js/core 1.0.0-alpha.23 → 1.0.0-alpha.25
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.js +31 -17
- package/dist/main.js.map +1 -1
- package/dist/module.js +31 -17
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +8 -7
package/dist/main.js
CHANGED
|
@@ -4246,14 +4246,14 @@ class Viewer extends EventEmitter {
|
|
|
4246
4246
|
}
|
|
4247
4247
|
return shadow;
|
|
4248
4248
|
}
|
|
4249
|
-
static
|
|
4249
|
+
static compileMaterial(renderer, scene, camera, target) {
|
|
4250
4250
|
Viewer.fullscreenMesh.material = target;
|
|
4251
4251
|
renderer.compile(Viewer.fullscreenMesh, camera, scene);
|
|
4252
4252
|
}
|
|
4253
|
-
static
|
|
4253
|
+
static compileObject3D(renderer, scene, camera, target) {
|
|
4254
4254
|
renderer.compile(target, camera, scene);
|
|
4255
4255
|
}
|
|
4256
|
-
static
|
|
4256
|
+
static compileTexture(renderer, target) {
|
|
4257
4257
|
if (Array.isArray(target)) {
|
|
4258
4258
|
for (let v of target){
|
|
4259
4259
|
renderer.initTexture(v);
|
|
@@ -4269,7 +4269,7 @@ class Viewer extends EventEmitter {
|
|
|
4269
4269
|
renderer.render(Viewer.fullscreenMesh, Viewer.fullscreenCamera);
|
|
4270
4270
|
renderer.setRenderTarget(RT);
|
|
4271
4271
|
}
|
|
4272
|
-
static
|
|
4272
|
+
static createFullscreenTriangle() {
|
|
4273
4273
|
let geometry = new three.BufferGeometry();
|
|
4274
4274
|
geometry.setAttribute('position', new three.Float32BufferAttribute([
|
|
4275
4275
|
-1,
|
|
@@ -4292,10 +4292,24 @@ class Viewer extends EventEmitter {
|
|
|
4292
4292
|
], 2));
|
|
4293
4293
|
return geometry;
|
|
4294
4294
|
}
|
|
4295
|
-
static
|
|
4296
|
-
|
|
4295
|
+
static findChild(node, path) {
|
|
4296
|
+
let child = null;
|
|
4297
|
+
let parts = path.split("/");
|
|
4298
|
+
let children = node.children;
|
|
4299
|
+
for (let part of parts){
|
|
4300
|
+
child = children.find((v)=>v.name === part);
|
|
4301
|
+
if (child) {
|
|
4302
|
+
children = child.children;
|
|
4303
|
+
} else {
|
|
4304
|
+
return null;
|
|
4305
|
+
}
|
|
4306
|
+
}
|
|
4307
|
+
return child;
|
|
4308
|
+
}
|
|
4309
|
+
static getChildByName(node, name) {
|
|
4310
|
+
return Viewer.getObject(node, (v)=>v.name === name && v);
|
|
4297
4311
|
}
|
|
4298
|
-
static
|
|
4312
|
+
static getObject(node, filter) {
|
|
4299
4313
|
const queue = [
|
|
4300
4314
|
node
|
|
4301
4315
|
];
|
|
@@ -4308,7 +4322,7 @@ class Viewer extends EventEmitter {
|
|
|
4308
4322
|
object.children.forEach((v)=>queue.push(v));
|
|
4309
4323
|
}
|
|
4310
4324
|
}
|
|
4311
|
-
static
|
|
4325
|
+
static getObjects(node, filter) {
|
|
4312
4326
|
const queue = [
|
|
4313
4327
|
node
|
|
4314
4328
|
];
|
|
@@ -4517,7 +4531,7 @@ class Viewer extends EventEmitter {
|
|
|
4517
4531
|
this._tweenManager.killTweensOf(target);
|
|
4518
4532
|
}
|
|
4519
4533
|
traverseMaterials(callback) {
|
|
4520
|
-
Viewer.
|
|
4534
|
+
Viewer.getObjects(this._scene, (item)=>{
|
|
4521
4535
|
if (item.isMesh) {
|
|
4522
4536
|
if (Array.isArray(item.material)) item.material.forEach(callback);
|
|
4523
4537
|
else callback(item.material);
|
|
@@ -4651,28 +4665,28 @@ class Viewer extends EventEmitter {
|
|
|
4651
4665
|
compile(target) {
|
|
4652
4666
|
if (Array.isArray(target)) {
|
|
4653
4667
|
if (target.every((v)=>v.isMaterial)) {
|
|
4654
|
-
Viewer.
|
|
4668
|
+
Viewer.compileMaterial(this._renderer, this._scene, this._camera, target);
|
|
4655
4669
|
} else {
|
|
4656
4670
|
throw Error("Viewer.compile: unsuport material");
|
|
4657
4671
|
}
|
|
4658
4672
|
} else if (typeof target === "object") {
|
|
4659
4673
|
if (target.isMaterial) {
|
|
4660
|
-
Viewer.
|
|
4674
|
+
Viewer.compileMaterial(this._renderer, this._scene, this._camera, target);
|
|
4661
4675
|
} else if (target.isObject3D) {
|
|
4662
4676
|
if (target.meshData.materials) {
|
|
4663
|
-
Viewer.
|
|
4677
|
+
Viewer.compileMaterial(this._renderer, this._scene, this._camera, Object.values(target.meshData.materials));
|
|
4664
4678
|
}
|
|
4665
4679
|
if (target.meshData.textures) {
|
|
4666
|
-
Viewer.
|
|
4680
|
+
Viewer.compileTexture(this._renderer, Object.values(target.meshData.textures));
|
|
4667
4681
|
}
|
|
4668
4682
|
if (!target.meshData.meshes) {
|
|
4669
|
-
Viewer.
|
|
4683
|
+
Viewer.compileObject3D(this._renderer, this._scene, this._camera, target);
|
|
4670
4684
|
}
|
|
4671
4685
|
} else if (target.isTexture) {
|
|
4672
|
-
Viewer.
|
|
4686
|
+
Viewer.compileTexture(this._renderer, target);
|
|
4673
4687
|
}
|
|
4674
4688
|
} else {
|
|
4675
|
-
Viewer.
|
|
4689
|
+
Viewer.compileObject3D(this._renderer, this._scene, this._camera, this._scene);
|
|
4676
4690
|
}
|
|
4677
4691
|
}
|
|
4678
4692
|
constructor({ root, canvas, autoStart = true, autoResize = true, shadows = false, camera = {
|
|
@@ -4750,7 +4764,7 @@ Viewer._shadowCameraKeys = [
|
|
|
4750
4764
|
"near",
|
|
4751
4765
|
"far"
|
|
4752
4766
|
];
|
|
4753
|
-
Viewer.fullscreenMesh = new three.Mesh(Viewer.
|
|
4767
|
+
Viewer.fullscreenMesh = new three.Mesh(Viewer.createFullscreenTriangle());
|
|
4754
4768
|
Viewer.fullscreenCamera = new three.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
4755
4769
|
|
|
4756
4770
|
class MergeRefectPass {
|