@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/module.js CHANGED
@@ -7,7 +7,7 @@ import * as THREE from 'three';
7
7
  import { EquirectangularReflectionMapping, FileLoader, TextureLoader as TextureLoader$1, SRGBColorSpace, CubeUVReflectionMapping, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, MathUtils, Vector3, Vector2, LinearInterpolant, Object3D, Plane as Plane$1, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, LinearMipMapLinearFilter, LinearFilter, HalfFloatType, AnimationMixer, Color, OrthographicCamera, MeshDepthMaterial, ShaderMaterial, Euler, Group, REVISION, Box3, Sphere as Sphere$1, Raycaster, Quaternion, Spherical, UniformsUtils, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, LinearSRGBColorSpace, NearestFilter, ClampToEdgeWrapping, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, BufferGeometry, Float32BufferAttribute, Scene, WebGLRenderer, LinearToneMapping, PCFSoftShadowMap, LoadingManager, PMREMGenerator, CubeCamera, ShaderLib, ShaderChunk } from 'three';
8
8
  import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
9
9
  import { SVGLoader as SVGLoader$1 } from 'three/examples/jsm/loaders/SVGLoader.js';
10
- import { KTX2Loader as KTX2Loader$1 } from 'three/examples/jsm/loaders/KTX2Loader';
10
+ import { KTX2Loader as KTX2Loader$1 } from 'three/examples/jsm/loaders/KTX2Loader.js';
11
11
  import { HorizontalBlurShader, VerticalBlurShader } from 'three/examples/jsm/Addons.js';
12
12
 
13
13
  class EventEmitter {
@@ -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
- keys.forEach((k)=>{
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
- loadCallback(loader.parse(buffer, resourcePath));
227
+ onLoad(loader.parse(buffer, resourcePath));
232
228
  } else {
233
- loader.load(url, loadCallback, onProgress, onError);
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, loadCallback, onError);
257
+ loader.parse(buffer, resourcePath, onLoad, onError);
267
258
  } else {
268
- loader.load(url, loadCallback, onProgress, onError);
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, loadCallback, onError);
354
+ loader.parse(buffer, resourcePath, onLoad, onError);
369
355
  } else {
370
- loader.load(url, loadCallback, onProgress, onError);
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" && !comp.flags.isStartCalled) {
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)=>comp.start());
2271
- this.updateInvoker = new Invoker((comp, dt)=>comp.update(dt));
2272
- this.lastUpdateInvoker = new Invoker((comp, dt)=>comp.lastUpdate(dt));
2273
- this.renderInvoker = new Invoker((comp, dt)=>comp.render(dt));
2274
- this.resizeInvoker = new Invoker((comp, width, height)=>comp.resize(width, height));
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.context;
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.context;
2460
+ const { renderer } = this.viewer;
2465
2461
  renderer.setSize(width, height);
2466
2462
  }
2467
2463
  constructor(...args){
@@ -4856,6 +4852,9 @@ class Viewer extends EventEmitter {
4856
4852
  clearColor(renderTarget, color, alpha) {
4857
4853
  Viewer.ClearColor(this._renderer, renderTarget, color, alpha);
4858
4854
  }
4855
+ stash(renderTarget, callback, clearColor, clearAlpha) {
4856
+ Viewer.Stash(this._renderer, renderTarget, callback, clearColor, clearAlpha);
4857
+ }
4859
4858
  blur(blurLevel, shadingScale, inputBuffer, tempBuffer, outputBuffer, fixedOutput) {
4860
4859
  Viewer.Blur(this._renderer, blurLevel, shadingScale, inputBuffer, tempBuffer, outputBuffer, fixedOutput);
4861
4860
  }
@@ -4951,7 +4950,7 @@ class Viewer extends EventEmitter {
4951
4950
  renderer.autoClear = true;
4952
4951
  renderer.setRenderTarget(renderTarget);
4953
4952
  clearColor !== undefined && renderer.setClearColor(clearColor, clearAlpha);
4954
- callback && callback();
4953
+ callback && callback(renderer);
4955
4954
  renderer.autoClear = autoClear;
4956
4955
  renderer.setRenderTarget(RT);
4957
4956
  clearColor !== undefined && renderer.setClearColor(color, alpha);