@xviewer.js/core 1.0.0-alpha.55 → 1.0.0-alpha.56
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 +39 -11
- package/dist/main.js.map +1 -1
- package/dist/module.js +39 -12
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Task.d.ts +2 -0
- package/types/Viewer.d.ts +10 -2
- package/types/asset/ResourceManager.d.ts +4 -2
- package/types/asset/aLoader.d.ts +1 -0
- package/types/index.d.ts +1 -1
- package/types/loaders/aFBXLoader.d.ts +1 -1
- package/types/loaders/aGLTFLoader.d.ts +1 -1
package/dist/main.js
CHANGED
|
@@ -1121,14 +1121,18 @@ class aEXRLoader extends aLoader {
|
|
|
1121
1121
|
}
|
|
1122
1122
|
|
|
1123
1123
|
class aFBXLoader extends aLoader {
|
|
1124
|
-
load({ url, onLoad, onProgress, onError }) {
|
|
1124
|
+
load({ url, buffer, onLoad, onProgress, onError }) {
|
|
1125
1125
|
const loadCallback = (node)=>{
|
|
1126
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);
|
|
1130
1130
|
loader.setResourcePath(this.manager.resourcePath);
|
|
1131
|
-
|
|
1131
|
+
if (buffer) {
|
|
1132
|
+
loadCallback(loader.parse(buffer, this.manager.path));
|
|
1133
|
+
} else {
|
|
1134
|
+
loader.load(url, loadCallback, onProgress, onError);
|
|
1135
|
+
}
|
|
1132
1136
|
}
|
|
1133
1137
|
constructor(...args){
|
|
1134
1138
|
super(...args);
|
|
@@ -1139,7 +1143,7 @@ class aFBXLoader extends aLoader {
|
|
|
1139
1143
|
}
|
|
1140
1144
|
|
|
1141
1145
|
class aGLTFLoader extends aLoader {
|
|
1142
|
-
load({ url, onLoad, onProgress, onError }) {
|
|
1146
|
+
load({ url, buffer, onLoad, onProgress, onError }) {
|
|
1143
1147
|
const loadCallback = (gltf)=>{
|
|
1144
1148
|
const node = gltf.scene;
|
|
1145
1149
|
if (gltf.animations) node.animations = gltf.animations;
|
|
@@ -1152,7 +1156,11 @@ class aGLTFLoader extends aLoader {
|
|
|
1152
1156
|
dracoLoader.setDecoderPath(this.manager.dracoPath);
|
|
1153
1157
|
gltfLoader.setDRACOLoader(dracoLoader);
|
|
1154
1158
|
gltfLoader.setMeshoptDecoder(meshopt_decoder_module_js.MeshoptDecoder);
|
|
1155
|
-
|
|
1159
|
+
if (buffer) {
|
|
1160
|
+
gltfLoader.parse(buffer, this.manager.path, loadCallback, onError);
|
|
1161
|
+
} else {
|
|
1162
|
+
gltfLoader.load(url, loadCallback, onProgress, onError);
|
|
1163
|
+
}
|
|
1156
1164
|
}
|
|
1157
1165
|
constructor(...args){
|
|
1158
1166
|
super(...args);
|
|
@@ -1165,13 +1173,13 @@ class aGLTFLoader extends aLoader {
|
|
|
1165
1173
|
|
|
1166
1174
|
class aHDRLoader extends aLoader {
|
|
1167
1175
|
load({ url, onLoad, onProgress, onError, texSettings }) {
|
|
1168
|
-
|
|
1176
|
+
const settings = Object.assign({
|
|
1169
1177
|
mapping: three.EquirectangularReflectionMapping
|
|
1170
1178
|
}, texSettings);
|
|
1171
1179
|
const loader = new RGBELoader_js.RGBELoader(this.manager.loadingManager);
|
|
1172
1180
|
loader.setPath(this.manager.path);
|
|
1173
1181
|
loader.setResourcePath(this.manager.resourcePath);
|
|
1174
|
-
loader.load(url, (tex)=>onLoad(Object.assign(tex,
|
|
1182
|
+
loader.load(url, (tex)=>onLoad(Object.assign(tex, settings)), onProgress, onError);
|
|
1175
1183
|
}
|
|
1176
1184
|
constructor(...args){
|
|
1177
1185
|
super(...args);
|
|
@@ -4243,7 +4251,7 @@ class ResourceManager {
|
|
|
4243
4251
|
static extension(path) {
|
|
4244
4252
|
let str = path.split(".");
|
|
4245
4253
|
if (str.length > 1) {
|
|
4246
|
-
return str.pop();
|
|
4254
|
+
return str.pop().toLowerCase();
|
|
4247
4255
|
}
|
|
4248
4256
|
return "";
|
|
4249
4257
|
}
|
|
@@ -4281,13 +4289,16 @@ class ResourceManager {
|
|
|
4281
4289
|
this._caches.clear();
|
|
4282
4290
|
this._loaders.clear();
|
|
4283
4291
|
}
|
|
4292
|
+
getLoader(ext) {
|
|
4293
|
+
return this._loaders.get(ext);
|
|
4294
|
+
}
|
|
4284
4295
|
addLoader(Loader) {
|
|
4285
4296
|
let loader = new Loader(this);
|
|
4286
4297
|
for (let ext of loader.extension){
|
|
4287
4298
|
this._loaders.set(ext, loader);
|
|
4288
4299
|
}
|
|
4289
4300
|
}
|
|
4290
|
-
loadAsset({ url, ext, onProgress, ...props }) {
|
|
4301
|
+
loadAsset({ url, buffer, ext, onProgress, ...props }) {
|
|
4291
4302
|
return new Promise((resolve, reject)=>{
|
|
4292
4303
|
const ext_ = ResourceManager.extension(url);
|
|
4293
4304
|
const texSettings = ResourceManager._splitTextureSettings(props);
|
|
@@ -4300,10 +4311,11 @@ class ResourceManager {
|
|
|
4300
4311
|
this._caches.set(key, file);
|
|
4301
4312
|
resolve(file);
|
|
4302
4313
|
};
|
|
4303
|
-
|
|
4314
|
+
const sel = ext || ext_;
|
|
4304
4315
|
if (this._loaders.has(sel)) {
|
|
4305
4316
|
this._loaders.get(sel).load({
|
|
4306
4317
|
url,
|
|
4318
|
+
buffer,
|
|
4307
4319
|
texSettings,
|
|
4308
4320
|
onProgress,
|
|
4309
4321
|
onLoad,
|
|
@@ -4312,7 +4324,7 @@ class ResourceManager {
|
|
|
4312
4324
|
}
|
|
4313
4325
|
});
|
|
4314
4326
|
} else {
|
|
4315
|
-
reject("ResourceManager.loadAsset: missing loader for " +
|
|
4327
|
+
reject("ResourceManager.loadAsset: missing loader for " + url);
|
|
4316
4328
|
}
|
|
4317
4329
|
}
|
|
4318
4330
|
});
|
|
@@ -4589,6 +4601,15 @@ class Viewer extends EventEmitter {
|
|
|
4589
4601
|
set targetFrameRate(v) {
|
|
4590
4602
|
this._targetFrameRate = Math.max(0.001, v);
|
|
4591
4603
|
}
|
|
4604
|
+
get loadingManager() {
|
|
4605
|
+
return this._loadingManager;
|
|
4606
|
+
}
|
|
4607
|
+
get resourceManager() {
|
|
4608
|
+
return this._resourceManager;
|
|
4609
|
+
}
|
|
4610
|
+
get taskManager() {
|
|
4611
|
+
return this._taskManager;
|
|
4612
|
+
}
|
|
4592
4613
|
destroy() {
|
|
4593
4614
|
this.stop();
|
|
4594
4615
|
this._renderer.dispose();
|
|
@@ -4715,6 +4736,9 @@ class Viewer extends EventEmitter {
|
|
|
4715
4736
|
loadAsset(props) {
|
|
4716
4737
|
return this._resourceManager.loadAsset(props);
|
|
4717
4738
|
}
|
|
4739
|
+
getLoader(ext) {
|
|
4740
|
+
return this._resourceManager.getLoader(ext);
|
|
4741
|
+
}
|
|
4718
4742
|
addLoader(Loader) {
|
|
4719
4743
|
this._resourceManager.addLoader(Loader);
|
|
4720
4744
|
}
|
|
@@ -4758,6 +4782,9 @@ class Viewer extends EventEmitter {
|
|
|
4758
4782
|
removeComponent(node, component) {
|
|
4759
4783
|
return this._componentManager.removeComponent(node, component);
|
|
4760
4784
|
}
|
|
4785
|
+
addTask(task) {
|
|
4786
|
+
this._taskManager.add(task);
|
|
4787
|
+
}
|
|
4761
4788
|
addNode(object, { args, debug, scale, position, rotation, layer, shadowArgs, makeDefault, component, parent = this._scene, ...props } = {}) {
|
|
4762
4789
|
let node = null;
|
|
4763
4790
|
let ins = getClassInstance(object, args);
|
|
@@ -4936,7 +4963,7 @@ class Viewer extends EventEmitter {
|
|
|
4936
4963
|
this._renderer.shadowMap.enabled = !!shadows;
|
|
4937
4964
|
this._renderer.shadowMap.type = typeof shadows === "boolean" ? three.PCFSoftShadowMap : shadows;
|
|
4938
4965
|
this._renderer.info.autoReset = false;
|
|
4939
|
-
const loadingManager = new three.LoadingManager(loader.onLoad, loader.onProgress, loader.onError);
|
|
4966
|
+
const loadingManager = this._loadingManager = new three.LoadingManager(loader.onLoad, loader.onProgress, loader.onError);
|
|
4940
4967
|
this._resourceManager = new ResourceManager({
|
|
4941
4968
|
path,
|
|
4942
4969
|
resourcePath,
|
|
@@ -5570,6 +5597,7 @@ exports.Quat_quarticDamp = Quat_quarticDamp;
|
|
|
5570
5597
|
exports.Quat_smoothDamp = Quat_smoothDamp;
|
|
5571
5598
|
exports.Reflector = Reflector;
|
|
5572
5599
|
exports.ReflectorMaterial = ReflectorMaterial;
|
|
5600
|
+
exports.ResourceManager = ResourceManager;
|
|
5573
5601
|
exports.Sphere = Sphere;
|
|
5574
5602
|
exports.SystemInfo = SystemInfo;
|
|
5575
5603
|
exports.Tween = Tween;
|