@xviewer.js/core 1.0.0-alpha.44 → 1.0.0-alpha.45
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 +34 -22
- package/dist/main.js.map +1 -1
- package/dist/module.js +34 -22
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +11 -2
- package/types/asset/aLoader.d.ts +1 -1
- package/types/cinestation/FreelookVirtualCamera.d.ts +1 -1
package/dist/module.js
CHANGED
|
@@ -1050,7 +1050,7 @@ class TweenManager {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
|
|
1052
1052
|
class aLoader {
|
|
1053
|
-
static
|
|
1053
|
+
static _setUserData(node) {
|
|
1054
1054
|
const keys = aLoader._texKeys;
|
|
1055
1055
|
const meshes = [];
|
|
1056
1056
|
const textures = {};
|
|
@@ -1121,7 +1121,7 @@ class aEXRLoader extends aLoader {
|
|
|
1121
1121
|
class aFBXLoader extends aLoader {
|
|
1122
1122
|
load({ url, onLoad, onProgress, onError }) {
|
|
1123
1123
|
const loadCallback = (node)=>{
|
|
1124
|
-
onLoad(aLoader.
|
|
1124
|
+
onLoad(aLoader._setUserData(node));
|
|
1125
1125
|
};
|
|
1126
1126
|
const loader = new FBXLoader(this.manager.loadingManager);
|
|
1127
1127
|
loader.setPath(this.manager.path);
|
|
@@ -1141,7 +1141,7 @@ class aGLTFLoader extends aLoader {
|
|
|
1141
1141
|
const loadCallback = (gltf)=>{
|
|
1142
1142
|
const node = gltf.scene;
|
|
1143
1143
|
if (gltf.animations) node.animations = gltf.animations;
|
|
1144
|
-
onLoad(aLoader.
|
|
1144
|
+
onLoad(aLoader._setUserData(node));
|
|
1145
1145
|
};
|
|
1146
1146
|
let gltfLoader = new GLTFLoader(this.manager.loadingManager);
|
|
1147
1147
|
gltfLoader.setPath(this.manager.path);
|
|
@@ -2690,7 +2690,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2690
2690
|
this._button = e.button;
|
|
2691
2691
|
this._preLoc0.set(e.pageX, e.pageY);
|
|
2692
2692
|
}
|
|
2693
|
-
_onPointerUp(
|
|
2693
|
+
_onPointerUp(_) {
|
|
2694
2694
|
if (SystemInfo.isMobile) return;
|
|
2695
2695
|
this._button = -1;
|
|
2696
2696
|
}
|
|
@@ -2810,7 +2810,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2810
2810
|
this._targetPhi = clamp(this._targetPhi, this.phiMin, this.phiMax);
|
|
2811
2811
|
this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
|
|
2812
2812
|
}
|
|
2813
|
-
gotoPOI({ duration = -1, easing = Easing.Cubic.InOut, springLength = this._targetSpringLength, theta = this._targetTheta, phi = this._targetPhi, lookAt = this._lookAt, fov = this.lens.fov, smoothing = this.smoothing, rotateSmoothing =
|
|
2813
|
+
gotoPOI({ duration = -1, easing = Easing.Cubic.InOut, springLength = this._targetSpringLength, theta = this._targetTheta, phi = this._targetPhi, lookAt = this._lookAt, fov = this.lens.fov, smoothing = this.smoothing, rotateSmoothing = smoothing }) {
|
|
2814
2814
|
this._targetFov = fov;
|
|
2815
2815
|
this._tempSmoothing = smoothing;
|
|
2816
2816
|
this._tempRotateSmoothing = rotateSmoothing;
|
|
@@ -4518,33 +4518,44 @@ class Viewer extends EventEmitter {
|
|
|
4518
4518
|
static getChildByName(node, name) {
|
|
4519
4519
|
return Viewer.getObject(node, (v)=>v.name === name && v);
|
|
4520
4520
|
}
|
|
4521
|
-
static getObject(node, filter) {
|
|
4521
|
+
static getObject(node, filter, group = false) {
|
|
4522
4522
|
const queue = [
|
|
4523
4523
|
node
|
|
4524
4524
|
];
|
|
4525
|
+
const objects = [];
|
|
4525
4526
|
while(queue.length !== 0){
|
|
4526
4527
|
let object = queue.shift();
|
|
4527
4528
|
let target = filter(object);
|
|
4528
4529
|
if (target) {
|
|
4529
|
-
|
|
4530
|
+
objects.push(object);
|
|
4531
|
+
if (!group) {
|
|
4532
|
+
break;
|
|
4533
|
+
}
|
|
4530
4534
|
}
|
|
4531
4535
|
object.children.forEach((v)=>queue.push(v));
|
|
4532
4536
|
}
|
|
4537
|
+
if (group) {
|
|
4538
|
+
return objects;
|
|
4539
|
+
}
|
|
4540
|
+
return objects[0];
|
|
4533
4541
|
}
|
|
4534
|
-
static
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
const objects = [];
|
|
4539
|
-
while(queue.length !== 0){
|
|
4540
|
-
let object = queue.shift();
|
|
4541
|
-
let target = filter(object);
|
|
4542
|
-
if (target) {
|
|
4543
|
-
objects.push(object);
|
|
4542
|
+
static _getObjectValue(object, name, group = false) {
|
|
4543
|
+
if (name) {
|
|
4544
|
+
if (group) {
|
|
4545
|
+
return Object.values(object || Viewer.__emtpyObject).filter((v)=>v.name === name);
|
|
4544
4546
|
}
|
|
4545
|
-
object.
|
|
4547
|
+
return Object.values(object || Viewer.__emtpyObject).find((v)=>v.name === name);
|
|
4546
4548
|
}
|
|
4547
|
-
return
|
|
4549
|
+
return Object.values(object);
|
|
4550
|
+
}
|
|
4551
|
+
static getMaterial(node, name, group = false) {
|
|
4552
|
+
return Viewer._getObjectValue(node.userData.materials, name, group);
|
|
4553
|
+
}
|
|
4554
|
+
static getTexture(node, name, group = false) {
|
|
4555
|
+
return Viewer._getObjectValue(node.userData.textures, name, group);
|
|
4556
|
+
}
|
|
4557
|
+
static getMesh(node, name, group = false) {
|
|
4558
|
+
return Viewer._getObjectValue(node.userData.meshes, name, group);
|
|
4548
4559
|
}
|
|
4549
4560
|
get root() {
|
|
4550
4561
|
return this._root;
|
|
@@ -4740,12 +4751,12 @@ class Viewer extends EventEmitter {
|
|
|
4740
4751
|
this._tweenManager.killTweensOf(target);
|
|
4741
4752
|
}
|
|
4742
4753
|
traverseMaterials(callback) {
|
|
4743
|
-
Viewer.
|
|
4744
|
-
if (item.
|
|
4754
|
+
Viewer.getObject(this._scene, (item)=>{
|
|
4755
|
+
if (item.material) {
|
|
4745
4756
|
if (Array.isArray(item.material)) item.material.forEach(callback);
|
|
4746
4757
|
else callback(item.material);
|
|
4747
4758
|
}
|
|
4748
|
-
});
|
|
4759
|
+
}, true);
|
|
4749
4760
|
}
|
|
4750
4761
|
traversePlugins(callback) {
|
|
4751
4762
|
return this._pluginManager.traversePlugins(callback);
|
|
@@ -4977,6 +4988,7 @@ Viewer._shadowCameraKeys = [
|
|
|
4977
4988
|
"near",
|
|
4978
4989
|
"far"
|
|
4979
4990
|
];
|
|
4991
|
+
Viewer.__emtpyObject = {};
|
|
4980
4992
|
Viewer.fullscreenMesh = new Mesh(Viewer.createFullscreenTriangle());
|
|
4981
4993
|
Viewer.fullscreenCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
4982
4994
|
|