@xviewer.js/core 1.0.4-alpha.3 → 1.0.4-alpha.5

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 CHANGED
@@ -8,7 +8,7 @@ var meshopt_decoder_module_js = require('three/examples/jsm/libs/meshopt_decoder
8
8
  var THREE = require('three');
9
9
  var RGBELoader_js = require('three/examples/jsm/loaders/RGBELoader.js');
10
10
  var SVGLoader_js = require('three/examples/jsm/loaders/SVGLoader.js');
11
- var KTX2Loader$1 = require('three/examples/jsm/loaders/KTX2Loader');
11
+ var KTX2Loader_js = require('three/examples/jsm/loaders/KTX2Loader.js');
12
12
  var Addons_js = require('three/examples/jsm/Addons.js');
13
13
 
14
14
  function _interopNamespaceDefault(e) {
@@ -165,7 +165,6 @@ function getClassInstance(constructor, args = []) {
165
165
 
166
166
  class Loader {
167
167
  static _setUserData(node) {
168
- const keys = Loader._texKeys;
169
168
  const meshes = [];
170
169
  const textures = {};
171
170
  const materials = {};
@@ -183,7 +182,7 @@ class Loader {
183
182
  queue.push(...object.children);
184
183
  }
185
184
  Object.values(materials).forEach((mat)=>{
186
- keys.forEach((k)=>{
185
+ Loader._texKeys.forEach((k)=>{
187
186
  let tex = mat[k];
188
187
  if (tex) {
189
188
  textures[tex.uuid] = tex;
@@ -244,13 +243,10 @@ class FBXLoader extends Loader {
244
243
  loader.manager = manager;
245
244
  loader.setPath(path);
246
245
  loader.setResourcePath(resourcePath);
247
- const loadCallback = (node)=>{
248
- onLoad(Loader._setUserData(node));
249
- };
250
246
  if (buffer) {
251
- loadCallback(loader.parse(buffer, resourcePath));
247
+ onLoad(loader.parse(buffer, resourcePath));
252
248
  } else {
253
- loader.load(url, loadCallback, onProgress, onError);
249
+ loader.load(url, onLoad, onProgress, onError);
254
250
  }
255
251
  }
256
252
  constructor(...args){
@@ -277,15 +273,10 @@ class GLTFLoader extends Loader {
277
273
  loader.manager = manager;
278
274
  loader.setPath(path);
279
275
  loader.setResourcePath(resourcePath);
280
- const loadCallback = (gltf)=>{
281
- const node = gltf.scene;
282
- node.animations.push(...gltf.animations);
283
- onLoad(Loader._setUserData(node));
284
- };
285
276
  if (buffer) {
286
- loader.parse(buffer, resourcePath, loadCallback, onError);
277
+ loader.parse(buffer, resourcePath, onLoad, onError);
287
278
  } else {
288
- loader.load(url, loadCallback, onProgress, onError);
279
+ loader.load(url, onLoad, onProgress, onError);
289
280
  }
290
281
  }
291
282
  constructor(...args){
@@ -379,15 +370,10 @@ class BINLoader extends Loader {
379
370
  loader.manager = manager;
380
371
  loader.setPath(path);
381
372
  loader.setResourcePath(resourcePath);
382
- const loadCallback = (gltf)=>{
383
- const node = gltf.scene;
384
- node.animations.push(...gltf.animations);
385
- onLoad(Loader._setUserData(node));
386
- };
387
373
  if (buffer) {
388
- loader.parse(buffer, resourcePath, loadCallback, onError);
374
+ loader.parse(buffer, resourcePath, onLoad, onError);
389
375
  } else {
390
- loader.load(url, loadCallback, onProgress, onError);
376
+ loader.load(url, onLoad, onProgress, onError);
391
377
  }
392
378
  }
393
379
  constructor(...args){
@@ -462,7 +448,7 @@ class KTX2Loader extends Loader {
462
448
  load({ url, path, resourcePath, transcoderPath, manager, texSettings, onLoad, onProgress, onError }) {
463
449
  let loader = this._loader;
464
450
  if (loader === undefined) {
465
- loader = this._loader = new KTX2Loader$1.KTX2Loader();
451
+ loader = this._loader = new KTX2Loader_js.KTX2Loader();
466
452
  loader.setTranscoderPath(transcoderPath);
467
453
  loader.detectSupport(this.viewer.renderer);
468
454
  }
@@ -2245,8 +2231,7 @@ class ComponentScheduler {
2245
2231
  if (comp.onEnable) {
2246
2232
  comp.onEnable();
2247
2233
  }
2248
- if (typeof comp.start === "function" && !comp.flags.isStartCalled) {
2249
- comp.flags.isStartCalled = true;
2234
+ if (typeof comp.start === "function") {
2250
2235
  this.startInvoker.add(comp);
2251
2236
  }
2252
2237
  if (typeof comp.update === "function") {
@@ -2287,11 +2272,22 @@ class ComponentScheduler {
2287
2272
  }
2288
2273
  }
2289
2274
  constructor(){
2290
- this.startInvoker = new InvokerOneCall((comp)=>comp.start());
2291
- this.updateInvoker = new Invoker((comp, dt)=>comp.update(dt));
2292
- this.lastUpdateInvoker = new Invoker((comp, dt)=>comp.lastUpdate(dt));
2293
- this.renderInvoker = new Invoker((comp, dt)=>comp.render(dt));
2294
- this.resizeInvoker = new Invoker((comp, width, height)=>comp.resize(width, height));
2275
+ this.startInvoker = new InvokerOneCall((comp)=>{
2276
+ comp.start();
2277
+ comp.start = undefined;
2278
+ });
2279
+ this.updateInvoker = new Invoker((comp, dt)=>{
2280
+ !comp.start && comp.update(dt);
2281
+ });
2282
+ this.lastUpdateInvoker = new Invoker((comp, dt)=>{
2283
+ !comp.start && comp.lastUpdate(dt);
2284
+ });
2285
+ this.renderInvoker = new Invoker((comp, dt)=>{
2286
+ !comp.start && comp.render(dt);
2287
+ });
2288
+ this.resizeInvoker = new Invoker((comp, width, height)=>{
2289
+ !comp.start && comp.resize(width, height);
2290
+ });
2295
2291
  }
2296
2292
  }
2297
2293
 
@@ -2476,12 +2472,12 @@ ComponentManager._infoMap = new Map();
2476
2472
 
2477
2473
  class Renderer extends Component {
2478
2474
  render(dt) {
2479
- const { renderer, scene, camera } = this.context;
2475
+ const { renderer, scene, camera } = this.viewer;
2480
2476
  renderer.setRenderTarget(null);
2481
2477
  renderer.render(scene, camera);
2482
2478
  }
2483
2479
  resize(width, height) {
2484
- const { renderer } = this.context;
2480
+ const { renderer } = this.viewer;
2485
2481
  renderer.setSize(width, height);
2486
2482
  }
2487
2483
  constructor(...args){
@@ -4876,6 +4872,9 @@ class Viewer extends EventEmitter {
4876
4872
  clearColor(renderTarget, color, alpha) {
4877
4873
  Viewer.ClearColor(this._renderer, renderTarget, color, alpha);
4878
4874
  }
4875
+ stash(renderTarget, callback, clearColor, clearAlpha) {
4876
+ Viewer.Stash(this._renderer, renderTarget, callback, clearColor, clearAlpha);
4877
+ }
4879
4878
  blur(blurLevel, shadingScale, inputBuffer, tempBuffer, outputBuffer, fixedOutput) {
4880
4879
  Viewer.Blur(this._renderer, blurLevel, shadingScale, inputBuffer, tempBuffer, outputBuffer, fixedOutput);
4881
4880
  }
@@ -4971,7 +4970,7 @@ class Viewer extends EventEmitter {
4971
4970
  renderer.autoClear = true;
4972
4971
  renderer.setRenderTarget(renderTarget);
4973
4972
  clearColor !== undefined && renderer.setClearColor(clearColor, clearAlpha);
4974
- callback && callback();
4973
+ callback && callback(renderer);
4975
4974
  renderer.autoClear = autoClear;
4976
4975
  renderer.setRenderTarget(RT);
4977
4976
  clearColor !== undefined && renderer.setClearColor(color, alpha);