@xviewer.js/core 1.0.4-alpha.2 → 1.0.4-alpha.4
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 +32 -37
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +32 -37
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Component.d.ts +0 -1
- package/types/Viewer.d.ts +2 -1
- package/types/asset/ResourceManager.d.ts +2 -1
package/dist/module.js
CHANGED
|
@@ -145,7 +145,6 @@ function getClassInstance(constructor, args = []) {
|
|
|
145
145
|
|
|
146
146
|
class Loader {
|
|
147
147
|
static _setUserData(node) {
|
|
148
|
-
const keys = Loader._texKeys;
|
|
149
148
|
const meshes = [];
|
|
150
149
|
const textures = {};
|
|
151
150
|
const materials = {};
|
|
@@ -163,7 +162,7 @@ class Loader {
|
|
|
163
162
|
queue.push(...object.children);
|
|
164
163
|
}
|
|
165
164
|
Object.values(materials).forEach((mat)=>{
|
|
166
|
-
|
|
165
|
+
Loader._texKeys.forEach((k)=>{
|
|
167
166
|
let tex = mat[k];
|
|
168
167
|
if (tex) {
|
|
169
168
|
textures[tex.uuid] = tex;
|
|
@@ -224,13 +223,10 @@ class FBXLoader extends Loader {
|
|
|
224
223
|
loader.manager = manager;
|
|
225
224
|
loader.setPath(path);
|
|
226
225
|
loader.setResourcePath(resourcePath);
|
|
227
|
-
const loadCallback = (node)=>{
|
|
228
|
-
onLoad(Loader._setUserData(node));
|
|
229
|
-
};
|
|
230
226
|
if (buffer) {
|
|
231
|
-
|
|
227
|
+
onLoad(loader.parse(buffer, resourcePath));
|
|
232
228
|
} else {
|
|
233
|
-
loader.load(url,
|
|
229
|
+
loader.load(url, onLoad, onProgress, onError);
|
|
234
230
|
}
|
|
235
231
|
}
|
|
236
232
|
constructor(...args){
|
|
@@ -257,15 +253,10 @@ class GLTFLoader extends Loader {
|
|
|
257
253
|
loader.manager = manager;
|
|
258
254
|
loader.setPath(path);
|
|
259
255
|
loader.setResourcePath(resourcePath);
|
|
260
|
-
const loadCallback = (gltf)=>{
|
|
261
|
-
const node = gltf.scene;
|
|
262
|
-
node.animations.push(...gltf.animations);
|
|
263
|
-
onLoad(Loader._setUserData(node));
|
|
264
|
-
};
|
|
265
256
|
if (buffer) {
|
|
266
|
-
loader.parse(buffer, resourcePath,
|
|
257
|
+
loader.parse(buffer, resourcePath, onLoad, onError);
|
|
267
258
|
} else {
|
|
268
|
-
loader.load(url,
|
|
259
|
+
loader.load(url, onLoad, onProgress, onError);
|
|
269
260
|
}
|
|
270
261
|
}
|
|
271
262
|
constructor(...args){
|
|
@@ -359,15 +350,10 @@ class BINLoader extends Loader {
|
|
|
359
350
|
loader.manager = manager;
|
|
360
351
|
loader.setPath(path);
|
|
361
352
|
loader.setResourcePath(resourcePath);
|
|
362
|
-
const loadCallback = (gltf)=>{
|
|
363
|
-
const node = gltf.scene;
|
|
364
|
-
node.animations.push(...gltf.animations);
|
|
365
|
-
onLoad(Loader._setUserData(node));
|
|
366
|
-
};
|
|
367
353
|
if (buffer) {
|
|
368
|
-
loader.parse(buffer, resourcePath,
|
|
354
|
+
loader.parse(buffer, resourcePath, onLoad, onError);
|
|
369
355
|
} else {
|
|
370
|
-
loader.load(url,
|
|
356
|
+
loader.load(url, onLoad, onProgress, onError);
|
|
371
357
|
}
|
|
372
358
|
}
|
|
373
359
|
constructor(...args){
|
|
@@ -2225,8 +2211,7 @@ class ComponentScheduler {
|
|
|
2225
2211
|
if (comp.onEnable) {
|
|
2226
2212
|
comp.onEnable();
|
|
2227
2213
|
}
|
|
2228
|
-
if (typeof comp.start === "function"
|
|
2229
|
-
comp.flags.isStartCalled = true;
|
|
2214
|
+
if (typeof comp.start === "function") {
|
|
2230
2215
|
this.startInvoker.add(comp);
|
|
2231
2216
|
}
|
|
2232
2217
|
if (typeof comp.update === "function") {
|
|
@@ -2267,11 +2252,22 @@ class ComponentScheduler {
|
|
|
2267
2252
|
}
|
|
2268
2253
|
}
|
|
2269
2254
|
constructor(){
|
|
2270
|
-
this.startInvoker = new InvokerOneCall((comp)=>
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
this.
|
|
2255
|
+
this.startInvoker = new InvokerOneCall((comp)=>{
|
|
2256
|
+
comp.start();
|
|
2257
|
+
comp.start = undefined;
|
|
2258
|
+
});
|
|
2259
|
+
this.updateInvoker = new Invoker((comp, dt)=>{
|
|
2260
|
+
!comp.start && comp.update(dt);
|
|
2261
|
+
});
|
|
2262
|
+
this.lastUpdateInvoker = new Invoker((comp, dt)=>{
|
|
2263
|
+
!comp.start && comp.lastUpdate(dt);
|
|
2264
|
+
});
|
|
2265
|
+
this.renderInvoker = new Invoker((comp, dt)=>{
|
|
2266
|
+
!comp.start && comp.render(dt);
|
|
2267
|
+
});
|
|
2268
|
+
this.resizeInvoker = new Invoker((comp, width, height)=>{
|
|
2269
|
+
!comp.start && comp.resize(width, height);
|
|
2270
|
+
});
|
|
2275
2271
|
}
|
|
2276
2272
|
}
|
|
2277
2273
|
|
|
@@ -2456,12 +2452,12 @@ ComponentManager._infoMap = new Map();
|
|
|
2456
2452
|
|
|
2457
2453
|
class Renderer extends Component {
|
|
2458
2454
|
render(dt) {
|
|
2459
|
-
const { renderer, scene, camera } = this.
|
|
2455
|
+
const { renderer, scene, camera } = this.viewer;
|
|
2460
2456
|
renderer.setRenderTarget(null);
|
|
2461
2457
|
renderer.render(scene, camera);
|
|
2462
2458
|
}
|
|
2463
2459
|
resize(width, height) {
|
|
2464
|
-
const { renderer } = this.
|
|
2460
|
+
const { renderer } = this.viewer;
|
|
2465
2461
|
renderer.setSize(width, height);
|
|
2466
2462
|
}
|
|
2467
2463
|
constructor(...args){
|
|
@@ -4391,19 +4387,15 @@ class ResourceManager {
|
|
|
4391
4387
|
}
|
|
4392
4388
|
return loader;
|
|
4393
4389
|
}
|
|
4394
|
-
loadAsset({ url,
|
|
4390
|
+
loadAsset({ url, ext, onProgress, ...props }) {
|
|
4395
4391
|
return new Promise((resolve, reject)=>{
|
|
4396
4392
|
const sel = ext || url && ResourceManager.extension(url) || "";
|
|
4397
4393
|
const texSettings = ResourceManager._splitTextureSettings(props);
|
|
4398
4394
|
if (this._loaders.has(sel)) {
|
|
4399
4395
|
this._loaders.get(sel).load({
|
|
4400
4396
|
url,
|
|
4401
|
-
buffer,
|
|
4402
4397
|
texSettings,
|
|
4403
|
-
|
|
4404
|
-
resourcePath,
|
|
4405
|
-
dracoPath,
|
|
4406
|
-
manager,
|
|
4398
|
+
...props,
|
|
4407
4399
|
onProgress,
|
|
4408
4400
|
onLoad: resolve,
|
|
4409
4401
|
onError: (err)=>{
|
|
@@ -4860,6 +4852,9 @@ class Viewer extends EventEmitter {
|
|
|
4860
4852
|
clearColor(renderTarget, color, alpha) {
|
|
4861
4853
|
Viewer.ClearColor(this._renderer, renderTarget, color, alpha);
|
|
4862
4854
|
}
|
|
4855
|
+
stash(renderTarget, callback, clearColor, clearAlpha) {
|
|
4856
|
+
Viewer.Stash(this._renderer, renderTarget, callback, clearColor, clearAlpha);
|
|
4857
|
+
}
|
|
4863
4858
|
blur(blurLevel, shadingScale, inputBuffer, tempBuffer, outputBuffer, fixedOutput) {
|
|
4864
4859
|
Viewer.Blur(this._renderer, blurLevel, shadingScale, inputBuffer, tempBuffer, outputBuffer, fixedOutput);
|
|
4865
4860
|
}
|
|
@@ -4955,7 +4950,7 @@ class Viewer extends EventEmitter {
|
|
|
4955
4950
|
renderer.autoClear = true;
|
|
4956
4951
|
renderer.setRenderTarget(renderTarget);
|
|
4957
4952
|
clearColor !== undefined && renderer.setClearColor(clearColor, clearAlpha);
|
|
4958
|
-
callback && callback();
|
|
4953
|
+
callback && callback(renderer);
|
|
4959
4954
|
renderer.autoClear = autoClear;
|
|
4960
4955
|
renderer.setRenderTarget(RT);
|
|
4961
4956
|
clearColor !== undefined && renderer.setClearColor(color, alpha);
|