@series-inc/rundot-3d-engine 0.3.0 → 0.4.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.
- package/LICENSE.txt +6 -6
- package/docs/core/Component.md +321 -321
- package/docs/core/GameObject.md +204 -204
- package/docs/core/VenusGame.md +316 -316
- package/docs/patterns/ComponentCommunication.md +337 -337
- package/docs/patterns/CreatingGameObjects.md +290 -290
- package/docs/patterns/MeshColliders.md +338 -338
- package/docs/patterns/MeshLoading.md +316 -316
- package/docs/physics/Colliders.md +249 -249
- package/docs/physics/PhysicsSystem.md +151 -151
- package/docs/physics/RigidBodyComponent.md +201 -201
- package/docs/rendering/AssetManager.md +308 -308
- package/docs/rendering/InstancedRenderer.md +286 -286
- package/docs/rendering/MeshRenderer.md +286 -286
- package/docs/rendering/SkeletalRenderer.md +308 -308
- package/docs/systems/AnimationSystem.md +75 -75
- package/docs/systems/AudioSystem.md +79 -79
- package/docs/systems/InputManager.md +101 -101
- package/docs/systems/LightingSystem.md +101 -101
- package/docs/systems/ParticleSystem.md +44 -44
- package/docs/systems/PrefabSystem.md +60 -60
- package/docs/systems/StowKitSystem.md +77 -77
- package/docs/systems/TweenSystem.md +132 -132
- package/docs/systems/UISystem.md +73 -73
- package/package.json +1 -1
- package/scripts/postinstall.mjs +63 -51
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
# LightingSystem
|
|
2
|
-
|
|
3
|
-
Lighting components for Three.js scenes with directional and ambient lights.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { DirectionalLightComponentThree, AmbientLightComponentThree } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
-
import * as THREE from "three"
|
|
10
|
-
|
|
11
|
-
// Add directional light (sun)
|
|
12
|
-
const sunLight = new GameObject("Sun")
|
|
13
|
-
sunLight.addComponent(new DirectionalLightComponentThree(
|
|
14
|
-
0xffffff, // Color
|
|
15
|
-
1.0 // Intensity
|
|
16
|
-
))
|
|
17
|
-
sunLight.position.set(10, 20, 10)
|
|
18
|
-
|
|
19
|
-
// Add ambient light (fill light)
|
|
20
|
-
const ambient = new GameObject("Ambient")
|
|
21
|
-
ambient.addComponent(new AmbientLightComponentThree(
|
|
22
|
-
0x404040, // Color
|
|
23
|
-
0.5 // Intensity
|
|
24
|
-
))
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Common Use Cases
|
|
28
|
-
|
|
29
|
-
### Basic Scene Lighting
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
class MyGame extends VenusGame {
|
|
33
|
-
protected async onStart(): Promise<void> {
|
|
34
|
-
// Sun light
|
|
35
|
-
const sun = new GameObject("Sun")
|
|
36
|
-
const sunLight = new DirectionalLightComponentThree(0xffffff, 1.5)
|
|
37
|
-
sun.addComponent(sunLight)
|
|
38
|
-
sun.position.set(10, 20, 5)
|
|
39
|
-
sun.lookAt(0, 0, 0)
|
|
40
|
-
|
|
41
|
-
// Ambient fill
|
|
42
|
-
const ambient = new GameObject("Ambient")
|
|
43
|
-
ambient.addComponent(new AmbientLightComponentThree(0x404040, 0.4))
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Shadows
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
// Enable shadows in VenusGame config
|
|
52
|
-
protected getConfig(): VenusGameConfig {
|
|
53
|
-
return {
|
|
54
|
-
shadowMapEnabled: true,
|
|
55
|
-
shadowMapType: "vsm"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Directional lights cast shadows automatically
|
|
60
|
-
// Configure shadow camera for better quality
|
|
61
|
-
const sunLight = sun.getComponent(DirectionalLightComponentThree)
|
|
62
|
-
if (sunLight) {
|
|
63
|
-
const light = sunLight.getLight()
|
|
64
|
-
light.shadow.camera.left = -50
|
|
65
|
-
light.shadow.camera.right = 50
|
|
66
|
-
light.shadow.camera.top = 50
|
|
67
|
-
light.shadow.camera.bottom = -50
|
|
68
|
-
light.shadow.camera.far = 100
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## API Overview
|
|
73
|
-
|
|
74
|
-
### DirectionalLightComponentThree
|
|
75
|
-
- `new DirectionalLightComponentThree(color, intensity)` - Create directional light
|
|
76
|
-
- `getLight(): THREE.DirectionalLight` - Get Three.js light
|
|
77
|
-
- `setIntensity(intensity)` - Change brightness
|
|
78
|
-
- `setColor(color)` - Change color
|
|
79
|
-
|
|
80
|
-
### AmbientLightComponentThree
|
|
81
|
-
- `new AmbientLightComponentThree(color, intensity)` - Create ambient light
|
|
82
|
-
- `getLight(): THREE.AmbientLight` - Get Three.js light
|
|
83
|
-
|
|
84
|
-
## Light Types
|
|
85
|
-
|
|
86
|
-
### Directional Light
|
|
87
|
-
- Simulates sun/moon
|
|
88
|
-
- Parallel rays
|
|
89
|
-
- Casts shadows
|
|
90
|
-
- Position determines direction
|
|
91
|
-
|
|
92
|
-
### Ambient Light
|
|
93
|
-
- Uniform lighting from all directions
|
|
94
|
-
- No shadows
|
|
95
|
-
- Fill light to prevent pure black
|
|
96
|
-
|
|
97
|
-
## Related Systems
|
|
98
|
-
|
|
99
|
-
- [VenusGame](../core/VenusGame.md) - Shadow configuration
|
|
100
|
-
- [GameObject](../core/GameObject.md) - Attach lights to objects
|
|
101
|
-
|
|
1
|
+
# LightingSystem
|
|
2
|
+
|
|
3
|
+
Lighting components for Three.js scenes with directional and ambient lights.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { DirectionalLightComponentThree, AmbientLightComponentThree } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
+
import * as THREE from "three"
|
|
10
|
+
|
|
11
|
+
// Add directional light (sun)
|
|
12
|
+
const sunLight = new GameObject("Sun")
|
|
13
|
+
sunLight.addComponent(new DirectionalLightComponentThree(
|
|
14
|
+
0xffffff, // Color
|
|
15
|
+
1.0 // Intensity
|
|
16
|
+
))
|
|
17
|
+
sunLight.position.set(10, 20, 10)
|
|
18
|
+
|
|
19
|
+
// Add ambient light (fill light)
|
|
20
|
+
const ambient = new GameObject("Ambient")
|
|
21
|
+
ambient.addComponent(new AmbientLightComponentThree(
|
|
22
|
+
0x404040, // Color
|
|
23
|
+
0.5 // Intensity
|
|
24
|
+
))
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Common Use Cases
|
|
28
|
+
|
|
29
|
+
### Basic Scene Lighting
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
class MyGame extends VenusGame {
|
|
33
|
+
protected async onStart(): Promise<void> {
|
|
34
|
+
// Sun light
|
|
35
|
+
const sun = new GameObject("Sun")
|
|
36
|
+
const sunLight = new DirectionalLightComponentThree(0xffffff, 1.5)
|
|
37
|
+
sun.addComponent(sunLight)
|
|
38
|
+
sun.position.set(10, 20, 5)
|
|
39
|
+
sun.lookAt(0, 0, 0)
|
|
40
|
+
|
|
41
|
+
// Ambient fill
|
|
42
|
+
const ambient = new GameObject("Ambient")
|
|
43
|
+
ambient.addComponent(new AmbientLightComponentThree(0x404040, 0.4))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Shadows
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// Enable shadows in VenusGame config
|
|
52
|
+
protected getConfig(): VenusGameConfig {
|
|
53
|
+
return {
|
|
54
|
+
shadowMapEnabled: true,
|
|
55
|
+
shadowMapType: "vsm"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Directional lights cast shadows automatically
|
|
60
|
+
// Configure shadow camera for better quality
|
|
61
|
+
const sunLight = sun.getComponent(DirectionalLightComponentThree)
|
|
62
|
+
if (sunLight) {
|
|
63
|
+
const light = sunLight.getLight()
|
|
64
|
+
light.shadow.camera.left = -50
|
|
65
|
+
light.shadow.camera.right = 50
|
|
66
|
+
light.shadow.camera.top = 50
|
|
67
|
+
light.shadow.camera.bottom = -50
|
|
68
|
+
light.shadow.camera.far = 100
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## API Overview
|
|
73
|
+
|
|
74
|
+
### DirectionalLightComponentThree
|
|
75
|
+
- `new DirectionalLightComponentThree(color, intensity)` - Create directional light
|
|
76
|
+
- `getLight(): THREE.DirectionalLight` - Get Three.js light
|
|
77
|
+
- `setIntensity(intensity)` - Change brightness
|
|
78
|
+
- `setColor(color)` - Change color
|
|
79
|
+
|
|
80
|
+
### AmbientLightComponentThree
|
|
81
|
+
- `new AmbientLightComponentThree(color, intensity)` - Create ambient light
|
|
82
|
+
- `getLight(): THREE.AmbientLight` - Get Three.js light
|
|
83
|
+
|
|
84
|
+
## Light Types
|
|
85
|
+
|
|
86
|
+
### Directional Light
|
|
87
|
+
- Simulates sun/moon
|
|
88
|
+
- Parallel rays
|
|
89
|
+
- Casts shadows
|
|
90
|
+
- Position determines direction
|
|
91
|
+
|
|
92
|
+
### Ambient Light
|
|
93
|
+
- Uniform lighting from all directions
|
|
94
|
+
- No shadows
|
|
95
|
+
- Fill light to prevent pure black
|
|
96
|
+
|
|
97
|
+
## Related Systems
|
|
98
|
+
|
|
99
|
+
- [VenusGame](../core/VenusGame.md) - Shadow configuration
|
|
100
|
+
- [GameObject](../core/GameObject.md) - Attach lights to objects
|
|
101
|
+
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
# ParticleSystem
|
|
2
|
-
|
|
3
|
-
Flexible particle system for visual effects like smoke, fire, explosions, and magic.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { ParticleSystemPrefabComponent } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
-
|
|
10
|
-
// Particles are typically created from prefabs
|
|
11
|
-
// See prefab documentation for particle configuration
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Common Use Cases
|
|
15
|
-
|
|
16
|
-
### Explosion Effect
|
|
17
|
-
|
|
18
|
-
Particles are configured in prefab JSON with properties:
|
|
19
|
-
- Emission rate
|
|
20
|
-
- Particle lifetime
|
|
21
|
-
- Velocity curves
|
|
22
|
-
- Color gradients
|
|
23
|
-
- Size over time
|
|
24
|
-
- Sprite sheets
|
|
25
|
-
|
|
26
|
-
### Smoke Trail
|
|
27
|
-
|
|
28
|
-
Configure particles to:
|
|
29
|
-
- Emit continuously
|
|
30
|
-
- Move upward
|
|
31
|
-
- Fade out over time
|
|
32
|
-
- Scale up gradually
|
|
33
|
-
|
|
34
|
-
## API Overview
|
|
35
|
-
|
|
36
|
-
- `ParticleSystemPrefabComponent` - Prefab-based particle emitter
|
|
37
|
-
- Configure via prefab JSON definitions
|
|
38
|
-
- Supports sprite sheets for animated particles
|
|
39
|
-
|
|
40
|
-
## Related Systems
|
|
41
|
-
|
|
42
|
-
- [PrefabSystem](PrefabSystem.md) - Particle configuration
|
|
43
|
-
- [GameObject](../core/GameObject.md) - Attach particles to objects
|
|
44
|
-
|
|
1
|
+
# ParticleSystem
|
|
2
|
+
|
|
3
|
+
Flexible particle system for visual effects like smoke, fire, explosions, and magic.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { ParticleSystemPrefabComponent } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
+
|
|
10
|
+
// Particles are typically created from prefabs
|
|
11
|
+
// See prefab documentation for particle configuration
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Common Use Cases
|
|
15
|
+
|
|
16
|
+
### Explosion Effect
|
|
17
|
+
|
|
18
|
+
Particles are configured in prefab JSON with properties:
|
|
19
|
+
- Emission rate
|
|
20
|
+
- Particle lifetime
|
|
21
|
+
- Velocity curves
|
|
22
|
+
- Color gradients
|
|
23
|
+
- Size over time
|
|
24
|
+
- Sprite sheets
|
|
25
|
+
|
|
26
|
+
### Smoke Trail
|
|
27
|
+
|
|
28
|
+
Configure particles to:
|
|
29
|
+
- Emit continuously
|
|
30
|
+
- Move upward
|
|
31
|
+
- Fade out over time
|
|
32
|
+
- Scale up gradually
|
|
33
|
+
|
|
34
|
+
## API Overview
|
|
35
|
+
|
|
36
|
+
- `ParticleSystemPrefabComponent` - Prefab-based particle emitter
|
|
37
|
+
- Configure via prefab JSON definitions
|
|
38
|
+
- Supports sprite sheets for animated particles
|
|
39
|
+
|
|
40
|
+
## Related Systems
|
|
41
|
+
|
|
42
|
+
- [PrefabSystem](PrefabSystem.md) - Particle configuration
|
|
43
|
+
- [GameObject](../core/GameObject.md) - Attach particles to objects
|
|
44
|
+
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# PrefabSystem
|
|
2
|
-
|
|
3
|
-
Prefab system for instantiating pre-configured GameObjects with components from JSON definitions.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { PrefabLoader, PrefabCollection } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
-
|
|
10
|
-
// Load prefabs (done via StowKitSystem)
|
|
11
|
-
const prefabs = await StowKitSystem.getInstance().loadFromBuildJson(buildJson, config)
|
|
12
|
-
|
|
13
|
-
// Instantiate prefab
|
|
14
|
-
const prefab = prefabs.getPrefabByName("burger_station")
|
|
15
|
-
const instance = PrefabLoader.instantiatePrefab(prefab)
|
|
16
|
-
|
|
17
|
-
// Instance is a GameObject with all components attached
|
|
18
|
-
instance.position.set(5, 0, 5)
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Common Use Cases
|
|
22
|
-
|
|
23
|
-
### Creating from Prefab
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
class Instantiation {
|
|
27
|
-
private static prefabCollection?: PrefabCollection
|
|
28
|
-
|
|
29
|
-
public static async initialize() {
|
|
30
|
-
const stowkit = StowKitSystem.getInstance()
|
|
31
|
-
const buildJson = (await import("../prefabs/build.json")).default
|
|
32
|
-
this.prefabCollection = await stowkit.loadFromBuildJson(buildJson, {
|
|
33
|
-
fetchBlob: (path) => RundotGameAPI.cdn.fetchAsset(path)
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public static instantiate(prefabPath: string): PrefabInstance | null {
|
|
38
|
-
const prefab = this.prefabCollection?.getPrefabByName(prefabPath)
|
|
39
|
-
if (!prefab) {
|
|
40
|
-
throw new Error(`Prefab not found: ${prefabPath}`)
|
|
41
|
-
}
|
|
42
|
-
return PrefabLoader.instantiatePrefab(prefab)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Use it
|
|
47
|
-
const enemy = Instantiation.instantiate("enemy_prefab")
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## API Overview
|
|
51
|
-
|
|
52
|
-
- `PrefabLoader.instantiatePrefab(prefab, parent?, options?)` - Create instance
|
|
53
|
-
- `PrefabCollection.getPrefabByName(name)` - Get prefab by name
|
|
54
|
-
- `ComponentRegistry.register(type, class)` - Register custom components
|
|
55
|
-
|
|
56
|
-
## Related Systems
|
|
57
|
-
|
|
58
|
-
- [StowKitSystem](StowKitSystem.md) - Loads prefab definitions
|
|
59
|
-
- [GameObject](../core/GameObject.md) - Prefabs create GameObjects
|
|
60
|
-
|
|
1
|
+
# PrefabSystem
|
|
2
|
+
|
|
3
|
+
Prefab system for instantiating pre-configured GameObjects with components from JSON definitions.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { PrefabLoader, PrefabCollection } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
+
|
|
10
|
+
// Load prefabs (done via StowKitSystem)
|
|
11
|
+
const prefabs = await StowKitSystem.getInstance().loadFromBuildJson(buildJson, config)
|
|
12
|
+
|
|
13
|
+
// Instantiate prefab
|
|
14
|
+
const prefab = prefabs.getPrefabByName("burger_station")
|
|
15
|
+
const instance = PrefabLoader.instantiatePrefab(prefab)
|
|
16
|
+
|
|
17
|
+
// Instance is a GameObject with all components attached
|
|
18
|
+
instance.position.set(5, 0, 5)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Common Use Cases
|
|
22
|
+
|
|
23
|
+
### Creating from Prefab
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
class Instantiation {
|
|
27
|
+
private static prefabCollection?: PrefabCollection
|
|
28
|
+
|
|
29
|
+
public static async initialize() {
|
|
30
|
+
const stowkit = StowKitSystem.getInstance()
|
|
31
|
+
const buildJson = (await import("../prefabs/build.json")).default
|
|
32
|
+
this.prefabCollection = await stowkit.loadFromBuildJson(buildJson, {
|
|
33
|
+
fetchBlob: (path) => RundotGameAPI.cdn.fetchAsset(path)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public static instantiate(prefabPath: string): PrefabInstance | null {
|
|
38
|
+
const prefab = this.prefabCollection?.getPrefabByName(prefabPath)
|
|
39
|
+
if (!prefab) {
|
|
40
|
+
throw new Error(`Prefab not found: ${prefabPath}`)
|
|
41
|
+
}
|
|
42
|
+
return PrefabLoader.instantiatePrefab(prefab)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Use it
|
|
47
|
+
const enemy = Instantiation.instantiate("enemy_prefab")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API Overview
|
|
51
|
+
|
|
52
|
+
- `PrefabLoader.instantiatePrefab(prefab, parent?, options?)` - Create instance
|
|
53
|
+
- `PrefabCollection.getPrefabByName(name)` - Get prefab by name
|
|
54
|
+
- `ComponentRegistry.register(type, class)` - Register custom components
|
|
55
|
+
|
|
56
|
+
## Related Systems
|
|
57
|
+
|
|
58
|
+
- [StowKitSystem](StowKitSystem.md) - Loads prefab definitions
|
|
59
|
+
- [GameObject](../core/GameObject.md) - Prefabs create GameObjects
|
|
60
|
+
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
# StowKitSystem
|
|
2
|
-
|
|
3
|
-
StowKitSystem loads assets from .stow pack files with automatic caching, prefab support, and material conversion.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { StowKitSystem } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
-
import RundotGameAPI from "@series-inc/rundot-game-sdk/api"
|
|
10
|
-
|
|
11
|
-
// Load from build.json (includes all packs and prefabs)
|
|
12
|
-
const buildJson = await import("../prefabs/build.json")
|
|
13
|
-
const prefabs = await StowKitSystem.getInstance().loadFromBuildJson(buildJson.default, {
|
|
14
|
-
fetchBlob: (path) => RundotGameAPI.cdn.fetchAsset(path)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
// Access meshes synchronously after loading
|
|
18
|
-
const mesh = StowKitSystem.getInstance().getMeshSync("restaurant_display_Money")
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Common Use Cases
|
|
22
|
-
|
|
23
|
-
### Loading Assets
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
class MyGame extends VenusGame {
|
|
27
|
-
protected async onStart(): Promise<void> {
|
|
28
|
-
const stowkit = StowKitSystem.getInstance()
|
|
29
|
-
const buildJson = (await import("../prefabs/build.json")).default
|
|
30
|
-
|
|
31
|
-
// Load everything
|
|
32
|
-
await stowkit.loadFromBuildJson(buildJson, {
|
|
33
|
-
fetchBlob: (path) => RundotGameAPI.cdn.fetchAsset(path)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
// Now use meshes
|
|
37
|
-
this.createGameObjects()
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Getting Meshes
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
const stowkit = StowKitSystem.getInstance()
|
|
46
|
-
|
|
47
|
-
// Async (loads if not cached)
|
|
48
|
-
const mesh = await stowkit.getMesh("asset_name")
|
|
49
|
-
|
|
50
|
-
// Sync (returns null if not loaded)
|
|
51
|
-
const mesh = stowkit.getMeshSync("asset_name")
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Using with MeshRenderer
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
// MeshRenderer uses StowKitSystem automatically
|
|
58
|
-
const renderer = new MeshRenderer("restaurant_display_Money")
|
|
59
|
-
const obj = new GameObject("Mesh")
|
|
60
|
-
obj.addComponent(renderer)
|
|
61
|
-
// Mesh loads from StowKit automatically
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## API Overview
|
|
65
|
-
|
|
66
|
-
- `getInstance(): StowKitSystem` - Get singleton instance
|
|
67
|
-
- `loadFromBuildJson(json, config)` - Load packs and prefabs
|
|
68
|
-
- `getMesh(name): Promise<THREE.Group>` - Load mesh async
|
|
69
|
-
- `getMeshSync(name): THREE.Group | null` - Get cached mesh
|
|
70
|
-
- `cloneMeshSync(mesh, castShadow, receiveShadow)` - Clone with shadows
|
|
71
|
-
- `getBounds(mesh): THREE.Vector3` - Get mesh bounds
|
|
72
|
-
|
|
73
|
-
## Related Systems
|
|
74
|
-
|
|
75
|
-
- [MeshRenderer](../rendering/MeshRenderer.md) - Uses StowKit for loading
|
|
76
|
-
- [PrefabSystem](PrefabSystem.md) - Prefabs from StowKit
|
|
77
|
-
|
|
1
|
+
# StowKitSystem
|
|
2
|
+
|
|
3
|
+
StowKitSystem loads assets from .stow pack files with automatic caching, prefab support, and material conversion.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { StowKitSystem } from "@series-ai/rundot-3d-engine/systems"
|
|
9
|
+
import RundotGameAPI from "@series-inc/rundot-game-sdk/api"
|
|
10
|
+
|
|
11
|
+
// Load from build.json (includes all packs and prefabs)
|
|
12
|
+
const buildJson = await import("../prefabs/build.json")
|
|
13
|
+
const prefabs = await StowKitSystem.getInstance().loadFromBuildJson(buildJson.default, {
|
|
14
|
+
fetchBlob: (path) => RundotGameAPI.cdn.fetchAsset(path)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
// Access meshes synchronously after loading
|
|
18
|
+
const mesh = StowKitSystem.getInstance().getMeshSync("restaurant_display_Money")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Common Use Cases
|
|
22
|
+
|
|
23
|
+
### Loading Assets
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
class MyGame extends VenusGame {
|
|
27
|
+
protected async onStart(): Promise<void> {
|
|
28
|
+
const stowkit = StowKitSystem.getInstance()
|
|
29
|
+
const buildJson = (await import("../prefabs/build.json")).default
|
|
30
|
+
|
|
31
|
+
// Load everything
|
|
32
|
+
await stowkit.loadFromBuildJson(buildJson, {
|
|
33
|
+
fetchBlob: (path) => RundotGameAPI.cdn.fetchAsset(path)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// Now use meshes
|
|
37
|
+
this.createGameObjects()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Getting Meshes
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const stowkit = StowKitSystem.getInstance()
|
|
46
|
+
|
|
47
|
+
// Async (loads if not cached)
|
|
48
|
+
const mesh = await stowkit.getMesh("asset_name")
|
|
49
|
+
|
|
50
|
+
// Sync (returns null if not loaded)
|
|
51
|
+
const mesh = stowkit.getMeshSync("asset_name")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Using with MeshRenderer
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// MeshRenderer uses StowKitSystem automatically
|
|
58
|
+
const renderer = new MeshRenderer("restaurant_display_Money")
|
|
59
|
+
const obj = new GameObject("Mesh")
|
|
60
|
+
obj.addComponent(renderer)
|
|
61
|
+
// Mesh loads from StowKit automatically
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## API Overview
|
|
65
|
+
|
|
66
|
+
- `getInstance(): StowKitSystem` - Get singleton instance
|
|
67
|
+
- `loadFromBuildJson(json, config)` - Load packs and prefabs
|
|
68
|
+
- `getMesh(name): Promise<THREE.Group>` - Load mesh async
|
|
69
|
+
- `getMeshSync(name): THREE.Group | null` - Get cached mesh
|
|
70
|
+
- `cloneMeshSync(mesh, castShadow, receiveShadow)` - Clone with shadows
|
|
71
|
+
- `getBounds(mesh): THREE.Vector3` - Get mesh bounds
|
|
72
|
+
|
|
73
|
+
## Related Systems
|
|
74
|
+
|
|
75
|
+
- [MeshRenderer](../rendering/MeshRenderer.md) - Uses StowKit for loading
|
|
76
|
+
- [PrefabSystem](PrefabSystem.md) - Prefabs from StowKit
|
|
77
|
+
|