@xviewer.js/core 1.0.0-alpha.43 → 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 +38 -26
- package/dist/main.js.map +1 -1
- package/dist/module.js +38 -26
- 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/main.js
CHANGED
|
@@ -1052,7 +1052,7 @@ class TweenManager {
|
|
|
1052
1052
|
}
|
|
1053
1053
|
|
|
1054
1054
|
class aLoader {
|
|
1055
|
-
static
|
|
1055
|
+
static _setUserData(node) {
|
|
1056
1056
|
const keys = aLoader._texKeys;
|
|
1057
1057
|
const meshes = [];
|
|
1058
1058
|
const textures = {};
|
|
@@ -1065,8 +1065,8 @@ class aLoader {
|
|
|
1065
1065
|
if (object.isMesh) {
|
|
1066
1066
|
meshes.push(object);
|
|
1067
1067
|
const mat = object.material;
|
|
1068
|
-
if (Array.isArray(mat)) mat.forEach((v)=>materials[v.
|
|
1069
|
-
else materials[mat.
|
|
1068
|
+
if (Array.isArray(mat)) mat.forEach((v)=>materials[v.uuid] = v);
|
|
1069
|
+
else materials[mat.uuid] = mat;
|
|
1070
1070
|
}
|
|
1071
1071
|
queue.push(...object.children);
|
|
1072
1072
|
}
|
|
@@ -1078,11 +1078,11 @@ class aLoader {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
});
|
|
1080
1080
|
});
|
|
1081
|
-
node.userData
|
|
1081
|
+
Object.assign(node.userData, {
|
|
1082
1082
|
meshes,
|
|
1083
1083
|
materials,
|
|
1084
1084
|
textures
|
|
1085
|
-
};
|
|
1085
|
+
});
|
|
1086
1086
|
return node;
|
|
1087
1087
|
}
|
|
1088
1088
|
constructor(manager){
|
|
@@ -1123,7 +1123,7 @@ class aEXRLoader extends aLoader {
|
|
|
1123
1123
|
class aFBXLoader extends aLoader {
|
|
1124
1124
|
load({ url, onLoad, onProgress, onError }) {
|
|
1125
1125
|
const loadCallback = (node)=>{
|
|
1126
|
-
onLoad(aLoader.
|
|
1126
|
+
onLoad(aLoader._setUserData(node));
|
|
1127
1127
|
};
|
|
1128
1128
|
const loader = new FBXLoader_js.FBXLoader(this.manager.loadingManager);
|
|
1129
1129
|
loader.setPath(this.manager.path);
|
|
@@ -1143,7 +1143,7 @@ class aGLTFLoader extends aLoader {
|
|
|
1143
1143
|
const loadCallback = (gltf)=>{
|
|
1144
1144
|
const node = gltf.scene;
|
|
1145
1145
|
if (gltf.animations) node.animations = gltf.animations;
|
|
1146
|
-
onLoad(aLoader.
|
|
1146
|
+
onLoad(aLoader._setUserData(node));
|
|
1147
1147
|
};
|
|
1148
1148
|
let gltfLoader = new GLTFLoader_js.GLTFLoader(this.manager.loadingManager);
|
|
1149
1149
|
gltfLoader.setPath(this.manager.path);
|
|
@@ -2692,7 +2692,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2692
2692
|
this._button = e.button;
|
|
2693
2693
|
this._preLoc0.set(e.pageX, e.pageY);
|
|
2694
2694
|
}
|
|
2695
|
-
_onPointerUp(
|
|
2695
|
+
_onPointerUp(_) {
|
|
2696
2696
|
if (SystemInfo.isMobile) return;
|
|
2697
2697
|
this._button = -1;
|
|
2698
2698
|
}
|
|
@@ -2812,7 +2812,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2812
2812
|
this._targetPhi = clamp(this._targetPhi, this.phiMin, this.phiMax);
|
|
2813
2813
|
this._targetSpringLength = clamp(this._targetSpringLength, this.distanceMin, this.distanceMax);
|
|
2814
2814
|
}
|
|
2815
|
-
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 =
|
|
2815
|
+
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 }) {
|
|
2816
2816
|
this._targetFov = fov;
|
|
2817
2817
|
this._tempSmoothing = smoothing;
|
|
2818
2818
|
this._tempRotateSmoothing = rotateSmoothing;
|
|
@@ -4520,33 +4520,44 @@ class Viewer extends EventEmitter {
|
|
|
4520
4520
|
static getChildByName(node, name) {
|
|
4521
4521
|
return Viewer.getObject(node, (v)=>v.name === name && v);
|
|
4522
4522
|
}
|
|
4523
|
-
static getObject(node, filter) {
|
|
4523
|
+
static getObject(node, filter, group = false) {
|
|
4524
4524
|
const queue = [
|
|
4525
4525
|
node
|
|
4526
4526
|
];
|
|
4527
|
+
const objects = [];
|
|
4527
4528
|
while(queue.length !== 0){
|
|
4528
4529
|
let object = queue.shift();
|
|
4529
4530
|
let target = filter(object);
|
|
4530
4531
|
if (target) {
|
|
4531
|
-
|
|
4532
|
+
objects.push(object);
|
|
4533
|
+
if (!group) {
|
|
4534
|
+
break;
|
|
4535
|
+
}
|
|
4532
4536
|
}
|
|
4533
4537
|
object.children.forEach((v)=>queue.push(v));
|
|
4534
4538
|
}
|
|
4539
|
+
if (group) {
|
|
4540
|
+
return objects;
|
|
4541
|
+
}
|
|
4542
|
+
return objects[0];
|
|
4535
4543
|
}
|
|
4536
|
-
static
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
const objects = [];
|
|
4541
|
-
while(queue.length !== 0){
|
|
4542
|
-
let object = queue.shift();
|
|
4543
|
-
let target = filter(object);
|
|
4544
|
-
if (target) {
|
|
4545
|
-
objects.push(object);
|
|
4544
|
+
static _getObjectValue(object, name, group = false) {
|
|
4545
|
+
if (name) {
|
|
4546
|
+
if (group) {
|
|
4547
|
+
return Object.values(object || Viewer.__emtpyObject).filter((v)=>v.name === name);
|
|
4546
4548
|
}
|
|
4547
|
-
object.
|
|
4549
|
+
return Object.values(object || Viewer.__emtpyObject).find((v)=>v.name === name);
|
|
4548
4550
|
}
|
|
4549
|
-
return
|
|
4551
|
+
return Object.values(object);
|
|
4552
|
+
}
|
|
4553
|
+
static getMaterial(node, name, group = false) {
|
|
4554
|
+
return Viewer._getObjectValue(node.userData.materials, name, group);
|
|
4555
|
+
}
|
|
4556
|
+
static getTexture(node, name, group = false) {
|
|
4557
|
+
return Viewer._getObjectValue(node.userData.textures, name, group);
|
|
4558
|
+
}
|
|
4559
|
+
static getMesh(node, name, group = false) {
|
|
4560
|
+
return Viewer._getObjectValue(node.userData.meshes, name, group);
|
|
4550
4561
|
}
|
|
4551
4562
|
get root() {
|
|
4552
4563
|
return this._root;
|
|
@@ -4742,12 +4753,12 @@ class Viewer extends EventEmitter {
|
|
|
4742
4753
|
this._tweenManager.killTweensOf(target);
|
|
4743
4754
|
}
|
|
4744
4755
|
traverseMaterials(callback) {
|
|
4745
|
-
Viewer.
|
|
4746
|
-
if (item.
|
|
4756
|
+
Viewer.getObject(this._scene, (item)=>{
|
|
4757
|
+
if (item.material) {
|
|
4747
4758
|
if (Array.isArray(item.material)) item.material.forEach(callback);
|
|
4748
4759
|
else callback(item.material);
|
|
4749
4760
|
}
|
|
4750
|
-
});
|
|
4761
|
+
}, true);
|
|
4751
4762
|
}
|
|
4752
4763
|
traversePlugins(callback) {
|
|
4753
4764
|
return this._pluginManager.traversePlugins(callback);
|
|
@@ -4979,6 +4990,7 @@ Viewer._shadowCameraKeys = [
|
|
|
4979
4990
|
"near",
|
|
4980
4991
|
"far"
|
|
4981
4992
|
];
|
|
4993
|
+
Viewer.__emtpyObject = {};
|
|
4982
4994
|
Viewer.fullscreenMesh = new three.Mesh(Viewer.createFullscreenTriangle());
|
|
4983
4995
|
Viewer.fullscreenCamera = new three.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
4984
4996
|
|