@xviewer.js/core 1.0.0-alpha.61 → 1.0.0-alpha.62
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 +54 -58
- package/dist/main.js.map +1 -1
- package/dist/module.js +50 -59
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Utils.d.ts +7 -0
- package/types/Viewer.d.ts +0 -13
- package/types/index.d.ts +1 -0
package/dist/main.js
CHANGED
|
@@ -4489,6 +4489,54 @@ function applyProps(target, props) {
|
|
|
4489
4489
|
}
|
|
4490
4490
|
return target;
|
|
4491
4491
|
}
|
|
4492
|
+
function find(node, path) {
|
|
4493
|
+
let child = null;
|
|
4494
|
+
let parts = path.split("/");
|
|
4495
|
+
let children = node.children;
|
|
4496
|
+
for (let part of parts){
|
|
4497
|
+
child = children.find((v)=>v.name === part);
|
|
4498
|
+
if (child) {
|
|
4499
|
+
children = child.children;
|
|
4500
|
+
} else {
|
|
4501
|
+
return null;
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
return child;
|
|
4505
|
+
}
|
|
4506
|
+
function getObject(node, filter, group = false) {
|
|
4507
|
+
const queue = [
|
|
4508
|
+
node
|
|
4509
|
+
];
|
|
4510
|
+
const objects = [];
|
|
4511
|
+
while(queue.length !== 0){
|
|
4512
|
+
let object = queue.shift();
|
|
4513
|
+
let target = filter(object);
|
|
4514
|
+
if (target) {
|
|
4515
|
+
objects.push(object);
|
|
4516
|
+
if (!group) {
|
|
4517
|
+
break;
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
object.children.forEach((v)=>queue.push(v));
|
|
4521
|
+
}
|
|
4522
|
+
if (group) {
|
|
4523
|
+
return objects;
|
|
4524
|
+
}
|
|
4525
|
+
return objects[0];
|
|
4526
|
+
}
|
|
4527
|
+
function getObjectByName(node, name) {
|
|
4528
|
+
return getObject(node, (v)=>v && v.name === name);
|
|
4529
|
+
}
|
|
4530
|
+
const __emtpyObject = {};
|
|
4531
|
+
function getObjectValue(object, name, group = false) {
|
|
4532
|
+
if (name) {
|
|
4533
|
+
if (group) {
|
|
4534
|
+
return Object.values(object || __emtpyObject).filter((v)=>v.name === name);
|
|
4535
|
+
}
|
|
4536
|
+
return Object.values(object || __emtpyObject).find((v)=>v.name === name);
|
|
4537
|
+
}
|
|
4538
|
+
return Object.values(object);
|
|
4539
|
+
}
|
|
4492
4540
|
|
|
4493
4541
|
class PluginManager {
|
|
4494
4542
|
get viewer() {
|
|
@@ -4604,62 +4652,6 @@ class Viewer extends EventEmitter {
|
|
|
4604
4652
|
], 2));
|
|
4605
4653
|
return geometry;
|
|
4606
4654
|
}
|
|
4607
|
-
static findChild(node, path) {
|
|
4608
|
-
let child = null;
|
|
4609
|
-
let parts = path.split("/");
|
|
4610
|
-
let children = node.children;
|
|
4611
|
-
for (let part of parts){
|
|
4612
|
-
child = children.find((v)=>v.name === part);
|
|
4613
|
-
if (child) {
|
|
4614
|
-
children = child.children;
|
|
4615
|
-
} else {
|
|
4616
|
-
return null;
|
|
4617
|
-
}
|
|
4618
|
-
}
|
|
4619
|
-
return child;
|
|
4620
|
-
}
|
|
4621
|
-
static getChildByName(node, name) {
|
|
4622
|
-
return Viewer.getObject(node, (v)=>v.name === name && v);
|
|
4623
|
-
}
|
|
4624
|
-
static getObject(node, filter, group = false) {
|
|
4625
|
-
const queue = [
|
|
4626
|
-
node
|
|
4627
|
-
];
|
|
4628
|
-
const objects = [];
|
|
4629
|
-
while(queue.length !== 0){
|
|
4630
|
-
let object = queue.shift();
|
|
4631
|
-
let target = filter(object);
|
|
4632
|
-
if (target) {
|
|
4633
|
-
objects.push(object);
|
|
4634
|
-
if (!group) {
|
|
4635
|
-
break;
|
|
4636
|
-
}
|
|
4637
|
-
}
|
|
4638
|
-
object.children.forEach((v)=>queue.push(v));
|
|
4639
|
-
}
|
|
4640
|
-
if (group) {
|
|
4641
|
-
return objects;
|
|
4642
|
-
}
|
|
4643
|
-
return objects[0];
|
|
4644
|
-
}
|
|
4645
|
-
static _getObjectValue(object, name, group = false) {
|
|
4646
|
-
if (name) {
|
|
4647
|
-
if (group) {
|
|
4648
|
-
return Object.values(object || Viewer.__emtpyObject).filter((v)=>v.name === name);
|
|
4649
|
-
}
|
|
4650
|
-
return Object.values(object || Viewer.__emtpyObject).find((v)=>v.name === name);
|
|
4651
|
-
}
|
|
4652
|
-
return Object.values(object);
|
|
4653
|
-
}
|
|
4654
|
-
static getMaterial(node, name, group = false) {
|
|
4655
|
-
return Viewer._getObjectValue(node.userData.materials, name, group);
|
|
4656
|
-
}
|
|
4657
|
-
static getTexture(node, name, group = false) {
|
|
4658
|
-
return Viewer._getObjectValue(node.userData.textures, name, group);
|
|
4659
|
-
}
|
|
4660
|
-
static getMesh(node, name, group = false) {
|
|
4661
|
-
return Viewer._getObjectValue(node.userData.meshes, name, group);
|
|
4662
|
-
}
|
|
4663
4655
|
get root() {
|
|
4664
4656
|
return this._root;
|
|
4665
4657
|
}
|
|
@@ -4861,7 +4853,7 @@ class Viewer extends EventEmitter {
|
|
|
4861
4853
|
this._tweenManager.killTweensOf(target);
|
|
4862
4854
|
}
|
|
4863
4855
|
traverseMaterials(callback) {
|
|
4864
|
-
|
|
4856
|
+
getObject(this._scene, (item)=>{
|
|
4865
4857
|
if (item.material) {
|
|
4866
4858
|
if (Array.isArray(item.material)) item.material.forEach(callback);
|
|
4867
4859
|
else callback(item.material);
|
|
@@ -5107,7 +5099,6 @@ Viewer._shadowCameraKeys = [
|
|
|
5107
5099
|
"near",
|
|
5108
5100
|
"far"
|
|
5109
5101
|
];
|
|
5110
|
-
Viewer.__emtpyObject = {};
|
|
5111
5102
|
Viewer.fullscreenMesh = new three.Mesh(Viewer.createFullscreenTriangle());
|
|
5112
5103
|
Viewer.fullscreenCamera = new three.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
5113
5104
|
Viewer._instanceCount = 0;
|
|
@@ -5887,11 +5878,16 @@ exports.aHDRLoader = aHDRLoader;
|
|
|
5887
5878
|
exports.aJSONLoader = aJSONLoader;
|
|
5888
5879
|
exports.aLoader = aLoader;
|
|
5889
5880
|
exports.aTextureLoader = aTextureLoader;
|
|
5881
|
+
exports.applyProps = applyProps;
|
|
5890
5882
|
exports.exponentialDamp = exponentialDamp;
|
|
5883
|
+
exports.find = find;
|
|
5891
5884
|
exports.frag_BoxfilterBlur = frag_BoxfilterBlur;
|
|
5892
5885
|
exports.frag_cubeMapToPanorama = frag_cubeMapToPanorama;
|
|
5893
5886
|
exports.frag_panoramaToCubeMap = frag_panoramaToCubeMap;
|
|
5894
5887
|
exports.getClassInstance = getClassInstance;
|
|
5888
|
+
exports.getObject = getObject;
|
|
5889
|
+
exports.getObjectByName = getObjectByName;
|
|
5890
|
+
exports.getObjectValue = getObjectValue;
|
|
5895
5891
|
exports.getShaderMaterial = getShaderMaterial;
|
|
5896
5892
|
exports.mixin = mixin;
|
|
5897
5893
|
exports.property = property;
|