@series-inc/rundot-3d-engine 0.6.20 → 0.6.22

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/SKILL.md CHANGED
@@ -13,10 +13,18 @@ class MyGame extends VenusGame {
13
13
  // Load assets
14
14
  const stowkit = StowKitSystem.getInstance()
15
15
  const buildJson = (await import("../prefabs/build.json")).default
16
- await stowkit.loadFromBuildJson(buildJson, {
17
- fetchBlob: (path) => fetch(path).then(r => r.blob()),
16
+
17
+ // Step 1: Parse build.json (pure, no network)
18
+ const { prefabs, mounts } = stowkit.parseBuildJson(buildJson, {
19
+ materialConverter: (mat) => mat, // optional
18
20
  })
19
21
 
22
+ // Step 2: Download and register each pack
23
+ await Promise.all(mounts.map(async (mount) => {
24
+ const blob = await fetch(mount.path).then(r => r.blob())
25
+ await stowkit.registerAssetsFromBlob(mount.alias, blob)
26
+ }))
27
+
20
28
  // Create a player
21
29
  const player = new GameObject("Player")
22
30
  player.position.set(0, 1, 0)
@@ -310,18 +318,32 @@ animGraph.getCurrentState()
310
318
 
311
319
  ### StowKitSystem — Asset Loading
312
320
 
321
+ Two-step loading: parse build.json first (pure, no network), then download and register each pack.
322
+
313
323
  ```typescript
314
324
  import { StowKitSystem } from "@series-inc/rundot-3d-engine/systems"
315
325
 
316
326
  const stowkit = StowKitSystem.getInstance()
317
-
318
- // Load from build.json
319
- await stowkit.loadFromBuildJson(buildJson, {
320
- fetchBlob: (path) => fetch(path).then(r => r.blob()),
327
+ const buildJson = (await import("../prefabs/build.json")).default
328
+
329
+ // Step 1: Parse build.json — returns prefab collection and mount list (no I/O)
330
+ const { prefabs, mounts } = stowkit.parseBuildJson(buildJson, {
331
+ materialConverter: (mat) => mat, // optional — transform materials at load time
332
+ decoderPaths: { // optional — override decoder locations
333
+ basis: "basis/",
334
+ draco: "stowkit/draco/",
335
+ wasm: "stowkit_reader.wasm",
336
+ },
321
337
  })
322
338
 
339
+ // Step 2: Download and register each .stow pack (WASM decode, no further network)
340
+ await Promise.all(mounts.map(async (mount) => {
341
+ const blob = await fetch(mount.path).then(r => r.blob())
342
+ await stowkit.registerAssetsFromBlob(mount.alias, blob)
343
+ }))
344
+
323
345
  // Access assets
324
- const mesh = await stowkit.getMesh("name") // async
346
+ const mesh = await stowkit.getMesh("name") // async, on-demand load & cache
325
347
  const mesh = stowkit.getMeshSync("name") // sync (null if not loaded)
326
348
  const tex = await stowkit.getTexture("name")
327
349
  const clip = await stowkit.getAnimation("walk", "character_mesh")
@@ -333,6 +355,24 @@ const clone = await stowkit.cloneMesh("name", castShadow, receiveShadow)
333
355
 
334
356
  // GPU instancing
335
357
  await stowkit.registerMeshForInstancing("coin_batch", "coin_mesh", true, true, 500)
358
+ await stowkit.registerBatchFromPrefab("burger", true, true, 100) // from prefab's stow_mesh component
359
+ ```
360
+
361
+ **Preloading** — pre-decode assets during load screen to avoid pop-in:
362
+
363
+ ```typescript
364
+ await stowkit.preloadAll({
365
+ meshes: ["level_geometry", "coin_mesh"],
366
+ skinnedMeshes: { names: ["hero_model"], scale: 1.0 },
367
+ textures: ["hero_diffuse"],
368
+ audio: ["bgm_main", "sfx_click"],
369
+ animations: [{ name: "hero_idle", meshName: "hero_model" }],
370
+ })
371
+
372
+ // Or individually:
373
+ await stowkit.preloadMeshes(["level_geometry", "coin_mesh"])
374
+ await stowkit.preloadSkinnedMeshes(["hero_model"], 1.0)
375
+ await stowkit.preloadAudio(["bgm_main"])
336
376
  ```
337
377
 
338
378
  ### InputManager — Keyboard, Pointer, Touch & Custom Actions