@series-inc/rundot-3d-engine 0.6.4 → 0.6.6

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.
@@ -1589,13 +1589,27 @@ async function PopulateAudioBank3D(systemInstance, audioBank, clips) {
1589
1589
  await Promise.all(loadPromises);
1590
1590
  }
1591
1591
  function PlayAudioOneShot2D(audioBank, audioClip) {
1592
- if (!audioBank[audioClip]) {
1592
+ const audio = audioBank[audioClip];
1593
+ if (!audio) {
1593
1594
  throw new Error(`Audio clip not found in bank: ${audioClip}`);
1594
1595
  }
1595
- if (!audioBank[audioClip].buffer) {
1596
+ if (!audio.buffer) {
1596
1597
  throw new Error(`Audio clip not loaded yet: ${audioClip}`);
1597
1598
  }
1598
- audioBank[audioClip].play();
1599
+ const ctx = audio.context;
1600
+ const source = ctx.createBufferSource();
1601
+ source.buffer = audio.buffer;
1602
+ source.playbackRate.value = audio.playbackRate;
1603
+ const gain = ctx.createGain();
1604
+ gain.gain.value = audio.getVolume();
1605
+ source.connect(gain);
1606
+ const filters = audio.filters;
1607
+ if (filters && filters.length > 0) {
1608
+ gain.connect(filters[0]);
1609
+ } else {
1610
+ gain.connect(ctx.destination);
1611
+ }
1612
+ source.start(0);
1599
1613
  }
1600
1614
  function PlayAudioRandom2D(audioBank, clipNames) {
1601
1615
  if (!Array.isArray(clipNames) || clipNames.length === 0) {
@@ -2555,6 +2569,7 @@ var AnimationCullingManager = class _AnimationCullingManager {
2555
2569
  };
2556
2570
 
2557
2571
  // src/engine/core/VenusGame.ts
2572
+ import { StowKitLoader } from "@series-inc/stowkit-three-loader";
2558
2573
  var DEFAULT_CONFIG = {
2559
2574
  backgroundColor: 0,
2560
2575
  antialias: true,
@@ -2684,6 +2699,9 @@ var VenusGame = class _VenusGame {
2684
2699
  _VenusGame._scene = instance.scene;
2685
2700
  _VenusGame._renderer = instance.renderer;
2686
2701
  _VenusGame._camera = instance.camera;
2702
+ const stowkitInitPromise = StowKitLoader.preInitialize({
2703
+ renderer: instance.renderer
2704
+ }).catch((e) => console.warn("[VenusGame] StowKit pre-init failed (will retry on first load):", e));
2687
2705
  const platform = await initializePlatformAsync(platformType);
2688
2706
  const context = await platform.initializeAsync({
2689
2707
  usePreloader: true
@@ -2705,6 +2723,7 @@ var VenusGame = class _VenusGame {
2705
2723
  ComponentUpdater.initialize(instance.scene);
2706
2724
  InstancedMeshManager.getInstance().initialize(instance.scene);
2707
2725
  instance.setupAudioListener();
2726
+ await stowkitInitPromise;
2708
2727
  await instance.onStart();
2709
2728
  instance.startRenderLoop();
2710
2729
  await Platform.preloader.hideLoadScreen();
@@ -5500,7 +5519,7 @@ var PrefabLoader = class {
5500
5519
  };
5501
5520
 
5502
5521
  // src/systems/stowkit/StowKitSystem.ts
5503
- import { StowKitLoader } from "@series-inc/stowkit-three-loader";
5522
+ import { StowKitLoader as StowKitLoader2 } from "@series-inc/stowkit-three-loader";
5504
5523
  import { PerfLogger } from "@series-inc/stowkit-reader";
5505
5524
  import * as THREE13 from "three";
5506
5525
  var DEFAULT_DECODER_PATHS = {
@@ -5566,21 +5585,23 @@ var StowKitSystem = class _StowKitSystem {
5566
5585
  const mounts = prefabCollection.getMounts();
5567
5586
  console.log(`[StowKitSystem] Loading ${mounts.length} packs from mounts...`);
5568
5587
  PerfLogger.disable();
5569
- for (const mount of mounts) {
5570
- if (this.packs.has(mount.alias)) {
5571
- continue;
5572
- }
5573
- console.log(`[StowKitSystem] Loading pack "${mount.alias}" from ${mount.path}`);
5574
- const blob = await config.fetchBlob(mount.path);
5575
- const arrayBuffer = await blob.arrayBuffer();
5576
- const pack = await StowKitLoader.loadFromMemory(arrayBuffer, {
5577
- basisPath: this.decoderPaths.basis,
5578
- dracoPath: this.decoderPaths.draco,
5579
- wasmPath: this.decoderPaths.wasm
5580
- });
5581
- this.packs.set(mount.alias, pack);
5582
- }
5583
- console.log(`[StowKitSystem] All packs loaded`);
5588
+ const packLoadStart = performance.now();
5589
+ await Promise.all(
5590
+ mounts.filter((mount) => !this.packs.has(mount.alias)).map(async (mount) => {
5591
+ console.log(`[StowKitSystem] Loading pack "${mount.alias}" from ${mount.path}`);
5592
+ const blob = await config.fetchBlob(mount.path);
5593
+ const arrayBuffer = await blob.arrayBuffer();
5594
+ const pack = await StowKitLoader2.loadFromMemory(arrayBuffer, {
5595
+ basisPath: this.decoderPaths.basis,
5596
+ dracoPath: this.decoderPaths.draco,
5597
+ wasmPath: this.decoderPaths.wasm
5598
+ });
5599
+ this.packs.set(mount.alias, pack);
5600
+ })
5601
+ );
5602
+ console.log(
5603
+ `[StowKitSystem] All packs loaded in ${(performance.now() - packLoadStart).toFixed(0)}ms`
5604
+ );
5584
5605
  return prefabCollection;
5585
5606
  }
5586
5607
  /**
@@ -5601,7 +5622,7 @@ var StowKitSystem = class _StowKitSystem {
5601
5622
  console.log(`[StowKitSystem] Loading pack "${alias}" from ${path}`);
5602
5623
  const blob = await this.fetchBlob(path);
5603
5624
  const arrayBuffer = await blob.arrayBuffer();
5604
- const pack = await StowKitLoader.loadFromMemory(arrayBuffer, {
5625
+ const pack = await StowKitLoader2.loadFromMemory(arrayBuffer, {
5605
5626
  basisPath: this.decoderPaths.basis,
5606
5627
  dracoPath: this.decoderPaths.draco,
5607
5628
  wasmPath: this.decoderPaths.wasm
@@ -5634,6 +5655,52 @@ var StowKitSystem = class _StowKitSystem {
5634
5655
  }
5635
5656
  return prefab;
5636
5657
  }
5658
+ /**
5659
+ * Pre-decode meshes so they're ready before the loading screen hides.
5660
+ * Call this in onStart() after loadFromBuildJson() to avoid a visible pop-in.
5661
+ *
5662
+ * @param meshNames Array of mesh asset paths to pre-decode
5663
+ * @returns Map of mesh names to loaded groups (failed meshes are logged and skipped)
5664
+ */
5665
+ async preloadMeshes(meshNames) {
5666
+ const start = performance.now();
5667
+ const results = /* @__PURE__ */ new Map();
5668
+ await Promise.allSettled(
5669
+ meshNames.map(async (name) => {
5670
+ try {
5671
+ const mesh = await this.getMesh(name);
5672
+ results.set(name, mesh);
5673
+ } catch (e) {
5674
+ console.warn(`[StowKitSystem] Failed to preload mesh "${name}":`, e);
5675
+ }
5676
+ })
5677
+ );
5678
+ console.log(
5679
+ `[StowKitSystem] Preloaded ${results.size}/${meshNames.length} meshes in ${(performance.now() - start).toFixed(0)}ms`
5680
+ );
5681
+ return results;
5682
+ }
5683
+ /**
5684
+ * Pre-decode skinned meshes so they're ready before the loading screen hides.
5685
+ */
5686
+ async preloadSkinnedMeshes(meshNames, scale = 1) {
5687
+ const start = performance.now();
5688
+ const results = /* @__PURE__ */ new Map();
5689
+ await Promise.allSettled(
5690
+ meshNames.map(async (name) => {
5691
+ try {
5692
+ const mesh = await this.getSkinnedMesh(name, scale);
5693
+ results.set(name, mesh);
5694
+ } catch (e) {
5695
+ console.warn(`[StowKitSystem] Failed to preload skinned mesh "${name}":`, e);
5696
+ }
5697
+ })
5698
+ );
5699
+ console.log(
5700
+ `[StowKitSystem] Preloaded ${results.size}/${meshNames.length} skinned meshes in ${(performance.now() - start).toFixed(0)}ms`
5701
+ );
5702
+ return results;
5703
+ }
5637
5704
  // ============================================
5638
5705
  // Pack Access
5639
5706
  // ============================================
@@ -6153,4 +6220,4 @@ export {
6153
6220
  PrefabLoader,
6154
6221
  StowKitSystem
6155
6222
  };
6156
- //# sourceMappingURL=chunk-3YI5JLCR.js.map
6223
+ //# sourceMappingURL=chunk-SCNHMGS3.js.map