@xviewer.js/core 1.0.2 → 1.0.4-alpha.0

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
@@ -1366,75 +1366,6 @@ class ObjectInstance {
1366
1366
  }
1367
1367
  ObjectInstance._instanceCount = 0;
1368
1368
 
1369
- function applyProps(target, props) {
1370
- for(let k in props){
1371
- let prop = props[k];
1372
- if (prop === undefined) {
1373
- continue;
1374
- }
1375
- if (target[k] !== undefined) {
1376
- let des = Object.getOwnPropertyDescriptor(target, k);
1377
- if (!des || des.writable || des.set) {
1378
- target[k] = prop;
1379
- } else {
1380
- let value = target[k];
1381
- if (value && value.copy) {
1382
- value.copy(prop);
1383
- }
1384
- }
1385
- }
1386
- }
1387
- return target;
1388
- }
1389
- function find(node, path) {
1390
- let child = null;
1391
- let parts = path.split("/");
1392
- let children = node.children;
1393
- for (let part of parts){
1394
- child = children.find((v)=>v.name === part);
1395
- if (child) {
1396
- children = child.children;
1397
- } else {
1398
- return null;
1399
- }
1400
- }
1401
- return child;
1402
- }
1403
- function getChildren(node, filter, group = false) {
1404
- const queue = [
1405
- node
1406
- ];
1407
- const objects = [];
1408
- while(queue.length !== 0){
1409
- let object = queue.shift();
1410
- let target = filter(object);
1411
- if (target) {
1412
- objects.push(object);
1413
- if (!group) {
1414
- break;
1415
- }
1416
- }
1417
- object.children.forEach((v)=>queue.push(v));
1418
- }
1419
- if (group) {
1420
- return objects;
1421
- }
1422
- return objects[0];
1423
- }
1424
- function getChildByName(node, name) {
1425
- return getChildren(node, (v)=>v && v.name === name);
1426
- }
1427
- const __emtpyObject = {};
1428
- function queryValues(object, name, group = false) {
1429
- if (name) {
1430
- if (group) {
1431
- return Object.values(object || __emtpyObject).filter((v)=>v.name === name);
1432
- }
1433
- return Object.values(object || __emtpyObject).find((v)=>v.name === name);
1434
- }
1435
- return Object.values(object);
1436
- }
1437
-
1438
1369
  class Component extends ObjectInstance {
1439
1370
  get enabled() {
1440
1371
  return this._enabled;
@@ -1477,9 +1408,6 @@ class Component extends ObjectInstance {
1477
1408
  }
1478
1409
  this.flags.Destroyed = true;
1479
1410
  }
1480
- apply(props) {
1481
- return applyProps(this, props);
1482
- }
1483
1411
  constructor(...args){
1484
1412
  super(...args);
1485
1413
  this._enabled = true;
@@ -2702,6 +2630,75 @@ class Animation extends Component {
2702
2630
  }
2703
2631
  }
2704
2632
 
2633
+ function applyProps(target, props) {
2634
+ for(let k in props){
2635
+ let prop = props[k];
2636
+ if (prop === undefined) {
2637
+ continue;
2638
+ }
2639
+ if (target[k] !== undefined) {
2640
+ let des = Object.getOwnPropertyDescriptor(target, k);
2641
+ if (!des || des.writable || des.set) {
2642
+ target[k] = prop;
2643
+ } else {
2644
+ let value = target[k];
2645
+ if (value && value.copy) {
2646
+ value.copy(prop);
2647
+ }
2648
+ }
2649
+ }
2650
+ }
2651
+ return target;
2652
+ }
2653
+ function find(node, path) {
2654
+ let child = null;
2655
+ let parts = path.split("/");
2656
+ let children = node.children;
2657
+ for (let part of parts){
2658
+ child = children.find((v)=>v.name === part);
2659
+ if (child) {
2660
+ children = child.children;
2661
+ } else {
2662
+ return null;
2663
+ }
2664
+ }
2665
+ return child;
2666
+ }
2667
+ function getChildren(node, filter, group = false) {
2668
+ const queue = [
2669
+ node
2670
+ ];
2671
+ const objects = [];
2672
+ while(queue.length !== 0){
2673
+ let object = queue.shift();
2674
+ let target = filter(object);
2675
+ if (target) {
2676
+ objects.push(object);
2677
+ if (!group) {
2678
+ break;
2679
+ }
2680
+ }
2681
+ object.children.forEach((v)=>queue.push(v));
2682
+ }
2683
+ if (group) {
2684
+ return objects;
2685
+ }
2686
+ return objects[0];
2687
+ }
2688
+ function getChildByName(node, name) {
2689
+ return getChildren(node, (v)=>v && v.name === name);
2690
+ }
2691
+ const __emtpyObject = {};
2692
+ function queryValues(object, name, group = false) {
2693
+ if (name) {
2694
+ if (group) {
2695
+ return Object.values(object || __emtpyObject).filter((v)=>v.name === name);
2696
+ }
2697
+ return Object.values(object || __emtpyObject).find((v)=>v.name === name);
2698
+ }
2699
+ return Object.values(object);
2700
+ }
2701
+
2705
2702
  class ContactShadows extends Component {
2706
2703
  get visible() {
2707
2704
  return this.node.visible;
@@ -4597,9 +4594,6 @@ ResourceManager._texSettingKeys = [
4597
4594
  "channel"
4598
4595
  ];
4599
4596
 
4600
- THREE.Object3D.prototype.apply = function(props) {
4601
- return applyProps(this, props);
4602
- };
4603
4597
  class Viewer extends EventEmitter {
4604
4598
  static _setDirectLightShadow(shadow, props) {
4605
4599
  const shadowCamera = shadow.camera;