@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/module.js CHANGED
@@ -4,7 +4,7 @@ import { GLTFLoader as GLTFLoader$1 } from 'three/examples/jsm/loaders/GLTFLoade
4
4
  import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
5
5
  import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
6
6
  import * as THREE from 'three';
7
- import { EquirectangularReflectionMapping, FileLoader, TextureLoader as TextureLoader$1, SRGBColorSpace, MathUtils, Vector3, Vector2, LinearInterpolant, Quaternion, Raycaster, Spherical, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, Plane as Plane$1, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, HalfFloatType, LinearMipMapLinearFilter, LinearFilter, AnimationMixer, Color, OrthographicCamera, MeshDepthMaterial, ShaderMaterial, Euler, Group, REVISION, Box3, Sphere as Sphere$1, UniformsUtils, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, Object3D, BufferGeometry, Float32BufferAttribute, ClampToEdgeWrapping, NearestFilter, LinearSRGBColorSpace, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene, WebGLRenderer, PCFSoftShadowMap, LoadingManager, LinearToneMapping, PMREMGenerator, CubeCamera, ShaderLib, ShaderChunk } from 'three';
7
+ import { EquirectangularReflectionMapping, FileLoader, TextureLoader as TextureLoader$1, SRGBColorSpace, MathUtils, Vector3, Vector2, LinearInterpolant, Quaternion, Raycaster, Spherical, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, Plane as Plane$1, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, HalfFloatType, LinearMipMapLinearFilter, LinearFilter, AnimationMixer, Color, OrthographicCamera, MeshDepthMaterial, ShaderMaterial, Euler, Group, REVISION, Box3, Sphere as Sphere$1, UniformsUtils, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, BufferGeometry, Float32BufferAttribute, Object3D, ClampToEdgeWrapping, NearestFilter, LinearSRGBColorSpace, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene, WebGLRenderer, PCFSoftShadowMap, LoadingManager, LinearToneMapping, PMREMGenerator, CubeCamera, ShaderLib, ShaderChunk } from 'three';
8
8
  import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
9
9
  import { HorizontalBlurShader, VerticalBlurShader } from 'three/examples/jsm/Addons.js';
10
10
 
@@ -1346,75 +1346,6 @@ class ObjectInstance {
1346
1346
  }
1347
1347
  ObjectInstance._instanceCount = 0;
1348
1348
 
1349
- function applyProps(target, props) {
1350
- for(let k in props){
1351
- let prop = props[k];
1352
- if (prop === undefined) {
1353
- continue;
1354
- }
1355
- if (target[k] !== undefined) {
1356
- let des = Object.getOwnPropertyDescriptor(target, k);
1357
- if (!des || des.writable || des.set) {
1358
- target[k] = prop;
1359
- } else {
1360
- let value = target[k];
1361
- if (value && value.copy) {
1362
- value.copy(prop);
1363
- }
1364
- }
1365
- }
1366
- }
1367
- return target;
1368
- }
1369
- function find(node, path) {
1370
- let child = null;
1371
- let parts = path.split("/");
1372
- let children = node.children;
1373
- for (let part of parts){
1374
- child = children.find((v)=>v.name === part);
1375
- if (child) {
1376
- children = child.children;
1377
- } else {
1378
- return null;
1379
- }
1380
- }
1381
- return child;
1382
- }
1383
- function getChildren(node, filter, group = false) {
1384
- const queue = [
1385
- node
1386
- ];
1387
- const objects = [];
1388
- while(queue.length !== 0){
1389
- let object = queue.shift();
1390
- let target = filter(object);
1391
- if (target) {
1392
- objects.push(object);
1393
- if (!group) {
1394
- break;
1395
- }
1396
- }
1397
- object.children.forEach((v)=>queue.push(v));
1398
- }
1399
- if (group) {
1400
- return objects;
1401
- }
1402
- return objects[0];
1403
- }
1404
- function getChildByName(node, name) {
1405
- return getChildren(node, (v)=>v && v.name === name);
1406
- }
1407
- const __emtpyObject = {};
1408
- function queryValues(object, name, group = false) {
1409
- if (name) {
1410
- if (group) {
1411
- return Object.values(object || __emtpyObject).filter((v)=>v.name === name);
1412
- }
1413
- return Object.values(object || __emtpyObject).find((v)=>v.name === name);
1414
- }
1415
- return Object.values(object);
1416
- }
1417
-
1418
1349
  class Component extends ObjectInstance {
1419
1350
  get enabled() {
1420
1351
  return this._enabled;
@@ -1457,9 +1388,6 @@ class Component extends ObjectInstance {
1457
1388
  }
1458
1389
  this.flags.Destroyed = true;
1459
1390
  }
1460
- apply(props) {
1461
- return applyProps(this, props);
1462
- }
1463
1391
  constructor(...args){
1464
1392
  super(...args);
1465
1393
  this._enabled = true;
@@ -2682,6 +2610,75 @@ class Animation extends Component {
2682
2610
  }
2683
2611
  }
2684
2612
 
2613
+ function applyProps(target, props) {
2614
+ for(let k in props){
2615
+ let prop = props[k];
2616
+ if (prop === undefined) {
2617
+ continue;
2618
+ }
2619
+ if (target[k] !== undefined) {
2620
+ let des = Object.getOwnPropertyDescriptor(target, k);
2621
+ if (!des || des.writable || des.set) {
2622
+ target[k] = prop;
2623
+ } else {
2624
+ let value = target[k];
2625
+ if (value && value.copy) {
2626
+ value.copy(prop);
2627
+ }
2628
+ }
2629
+ }
2630
+ }
2631
+ return target;
2632
+ }
2633
+ function find(node, path) {
2634
+ let child = null;
2635
+ let parts = path.split("/");
2636
+ let children = node.children;
2637
+ for (let part of parts){
2638
+ child = children.find((v)=>v.name === part);
2639
+ if (child) {
2640
+ children = child.children;
2641
+ } else {
2642
+ return null;
2643
+ }
2644
+ }
2645
+ return child;
2646
+ }
2647
+ function getChildren(node, filter, group = false) {
2648
+ const queue = [
2649
+ node
2650
+ ];
2651
+ const objects = [];
2652
+ while(queue.length !== 0){
2653
+ let object = queue.shift();
2654
+ let target = filter(object);
2655
+ if (target) {
2656
+ objects.push(object);
2657
+ if (!group) {
2658
+ break;
2659
+ }
2660
+ }
2661
+ object.children.forEach((v)=>queue.push(v));
2662
+ }
2663
+ if (group) {
2664
+ return objects;
2665
+ }
2666
+ return objects[0];
2667
+ }
2668
+ function getChildByName(node, name) {
2669
+ return getChildren(node, (v)=>v && v.name === name);
2670
+ }
2671
+ const __emtpyObject = {};
2672
+ function queryValues(object, name, group = false) {
2673
+ if (name) {
2674
+ if (group) {
2675
+ return Object.values(object || __emtpyObject).filter((v)=>v.name === name);
2676
+ }
2677
+ return Object.values(object || __emtpyObject).find((v)=>v.name === name);
2678
+ }
2679
+ return Object.values(object);
2680
+ }
2681
+
2685
2682
  class ContactShadows extends Component {
2686
2683
  get visible() {
2687
2684
  return this.node.visible;
@@ -4577,9 +4574,6 @@ ResourceManager._texSettingKeys = [
4577
4574
  "channel"
4578
4575
  ];
4579
4576
 
4580
- Object3D.prototype.apply = function(props) {
4581
- return applyProps(this, props);
4582
- };
4583
4577
  class Viewer extends EventEmitter {
4584
4578
  static _setDirectLightShadow(shadow, props) {
4585
4579
  const shadowCamera = shadow.camera;