Needle Engine

Changes between version 4.0.2-alpha.1 and 4.0.3-alpha
Files changed (5) hide show
  1. src/engine/engine_context.ts +1 -0
  2. src/engine/engine_lods.ts +5 -0
  3. src/engine/engine_networking_instantiate.ts +0 -1
  4. src/engine/engine_scenetools.ts +9 -8
  5. src/engine-components/NestedGltf.ts +7 -2
src/engine/engine_context.ts CHANGED
@@ -597,6 +597,7 @@
597
597
  this.addressables?.dispose();
598
598
  this.lightmaps?.clear();
599
599
  this.physics?.engine?.clearCaches();
600
+ this.lodsManager.disable();
600
601
 
601
602
  if (!this.isManagedExternally) {
602
603
  if (this.renderer) {
src/engine/engine_lods.ts CHANGED
@@ -59,7 +59,12 @@
59
59
  this._lodsManager.enable();
60
60
  }
61
61
 
62
+ disable() {
63
+ this._lodsManager?.disable();
64
+ _LODsManager.removePlugin(this);
65
+ }
62
66
 
67
+
63
68
  /** @internal */
64
69
  onAfterUpdatedLOD(_renderer: WebGLRenderer, _scene: Scene, camera: Camera, mesh: Mesh, level: LOD_Results): void {
65
70
  if (debug) this.onRenderDebug(camera, mesh, level);
src/engine/engine_networking_instantiate.ts CHANGED
@@ -306,7 +306,6 @@
306
306
  console.warn("could not find object that was instantiated: " + model.guid);
307
307
  return;
308
308
  }
309
- console.log(obj);
310
309
  const options = new InstantiateOptions();
311
310
  if (model.position)
312
311
  options.position = new Vector3(model.position.x, model.position.y, model.position.z);
src/engine/engine_scenetools.ts CHANGED
@@ -98,6 +98,7 @@
98
98
  await getLoader().createBuiltinComponents(context, gltfId, gltf, seed, componentsExtension);
99
99
  }
100
100
 
101
+
101
102
  export async function createLoader(url: string, context: Context): Promise<GLTFLoader | FBXLoader | USDZLoader | OBJLoader | null> {
102
103
 
103
104
  const type = await tryDetermineFileTypeFromURL(url) || "unknown";
@@ -331,7 +332,7 @@
331
332
  if ((result as Object3D)?.isObject3D) {
332
333
  const obj = result as Object3D;
333
334
 
334
- if (loader instanceof FBXLoader) {
335
+ if (loader instanceof FBXLoader || loader instanceof OBJLoader) {
335
336
  obj.traverse((child) => {
336
337
  const mesh = child as Mesh;
337
338
 
@@ -341,18 +342,18 @@
341
342
  }
342
343
  });
343
344
  }
344
- else if (loader instanceof OBJLoader) {
345
+ // else if (loader instanceof OBJLoader) {
345
346
 
346
- obj.traverse(_child => {
347
+ // obj.traverse(_child => {
347
348
 
348
- // TODO: Needs testing
349
+ // // TODO: Needs testing
349
350
 
350
- // if (!(child instanceof Mesh)) return;
351
+ // // if (!(child instanceof Mesh)) return;
351
352
 
352
- // child.material = new MeshStandardMaterial();
353
+ // // child.material = new MeshStandardMaterial();
353
354
 
354
- });
355
- }
355
+ // });
356
+ // }
356
357
 
357
358
 
358
359
  }
src/engine-components/NestedGltf.ts CHANGED
@@ -17,6 +17,11 @@
17
17
  @serializable(AssetReference)
18
18
  filePath?: AssetReference;
19
19
 
20
+ /**
21
+ * EXPERIMENTAL for cloud asset loading
22
+ */
23
+ loadAssetInParent = true;
24
+
20
25
  private _isLoadingOrDoneLoading: boolean = false;
21
26
 
22
27
  /** Register a callback that will be called when the progress of the loading changes */
@@ -40,13 +45,13 @@
40
45
  const opts = new InstantiateOptions();
41
46
  // we need to provide stable guids for creating nested gltfs
42
47
  opts.idProvider = new InstantiateIdProvider(this.hash(this.guid));
43
- opts.parent = parent;
48
+ opts.parent = this.loadAssetInParent !== false ? parent : this.gameObject;
44
49
  this.gameObject.updateMatrix();
45
50
  const matrix = this.gameObject.matrix;
46
51
  if (debug) console.log("Load nested:", this.filePath?.url ?? this.filePath, this.gameObject.position);
47
52
  const res = await this.filePath?.instantiate?.call(this.filePath, opts);
48
53
  if (debug) console.log("Nested loaded:", this.filePath?.url ?? this.filePath, res);
49
- if (res) {
54
+ if (res && this.loadAssetInParent !== false) {
50
55
  res.matrixAutoUpdate = false;
51
56
  res.matrix.identity();
52
57
  res.applyMatrix4(matrix);