@skewedaspect/sage 0.12.0 → 0.13.0

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.
@@ -3,6 +3,10 @@ import { EventBus } from '@skewedaspect/sage-core';
3
3
  import { SceneEngine } from "../engines/scene.js";
4
4
  import { Disposable } from "../interfaces/lifecycle.js";
5
5
  import { LoggingUtility } from "../utils/logger.js";
6
+ /** How `instantiate` copies a file's meshes (design/engine.md#the-asset-manager). */
7
+ export interface InstantiateOptions {
8
+ instances?: boolean;
9
+ }
6
10
  /**
7
11
  * Central asset cache with preloading, GLB fragment extraction, mesh instancing, and reference counting.
8
12
  *
@@ -79,9 +83,10 @@ export declare class AssetManager implements Disposable {
79
83
  clone(path: string, into: Scene): Mesh;
80
84
  /**
81
85
  * Copies a whole file into the scene it is handed: every mesh and node, with the file's skeletons and animation
82
- * groups. The meshes are cloned and share the container's materials. The copy is the caller's to dispose.
86
+ * groups. The meshes are cloned and share the container's materials, or, given `instances`, every mesh Babylon
87
+ * can instance is an instance of the container's. The copy is the caller's to dispose.
83
88
  */
84
- instantiate(path: string, scene: Scene): Promise<InstantiatedEntries>;
89
+ instantiate(path: string, scene: Scene, options?: InstantiateOptions): Promise<InstantiatedEntries>;
85
90
  /**
86
91
  * Preload a batch of asset paths, up to `MAX_CONCURRENT_LOADS` at a time, so a batch costs about as
87
92
  * long as its slowest asset rather than the sum of them all.
package/dist/sage.d.ts CHANGED
@@ -19,6 +19,7 @@ export declare function createGameEngine<Registry extends NodeEntityRegistry = N
19
19
  export * from "./interfaces/game.js";
20
20
  export * from "./interfaces/logger.js";
21
21
  export { AssetManager, AudioEngine, GameEngine, GameManager, LevelManager, SceneEngine };
22
+ export type { InstantiateOptions } from "./managers/asset.js";
22
23
  export type { DebugTools, Engines, GameHook, Managers, RebuildSimulationOptions, SimulationFactory, } from "./classes/gameEngine.js";
23
24
  export * from "./classes/level.js";
24
25
  export * from "./classes/gameLevel.js";
package/dist/sage.es.js CHANGED
@@ -68,7 +68,7 @@ var He = class {
68
68
  configurable: !0
69
69
  });
70
70
  }
71
- }, j = "0.12.0", Ue = class e {
71
+ }, j = "0.13.0", Ue = class e {
72
72
  canvas;
73
73
  renderEngine;
74
74
  managers;
@@ -920,15 +920,15 @@ var dt = class {
920
920
  });
921
921
  return r.metadata = null, r;
922
922
  }
923
- async instantiate(e, t) {
924
- let { basePath: n, fragment: r } = this._parsePath(e);
925
- if (r) throw Error(`Cannot instantiate '${e}': the fragment '${r}' is one mesh. clone() copies one mesh.`);
926
- let i = (await this._containerForScene(n, t)).instantiateModelsToScene(void 0, !1, { doNotInstantiate: !0 });
927
- for (let e of i.rootNodes) {
923
+ async instantiate(e, t, n) {
924
+ let { basePath: r, fragment: i } = this._parsePath(e);
925
+ if (i) throw Error(`Cannot instantiate '${e}': the fragment '${i}' is one mesh. clone() copies one mesh.`);
926
+ let a = await this._containerForScene(r, t), o = n?.instances ?? !1, s = a.instantiateModelsToScene(void 0, !1, { doNotInstantiate: !o });
927
+ for (let e of s.rootNodes) {
928
928
  e.metadata = null;
929
929
  for (let t of e.getDescendants()) t.metadata = null;
930
930
  }
931
- return i;
931
+ return s;
932
932
  }
933
933
  async preload(e) {
934
934
  let t = e.length, n = [], r = 0, i = 0, a = async () => {