@vgai/engine 0.2.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.
Files changed (147) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +35 -0
  3. package/package.json +55 -0
  4. package/src/adapter/authoring.ts +402 -0
  5. package/src/adapter/colyseus-networking-adapter.ts +72 -0
  6. package/src/adapter/first-party-systems.ts +103 -0
  7. package/src/adapter/game-adapter.ts +151 -0
  8. package/src/adapter/host-context.ts +77 -0
  9. package/src/adapter/index.ts +85 -0
  10. package/src/adapter/ingest/game-contract.ts +59 -0
  11. package/src/adapter/ingest/overlay-applier.ts +207 -0
  12. package/src/adapter/ingest/overlay-apply.ts +124 -0
  13. package/src/adapter/ingest/overlay-file.ts +126 -0
  14. package/src/adapter/ingest/overlay-report.ts +176 -0
  15. package/src/adapter/ingest/scene-capture.ts +307 -0
  16. package/src/adapter/ingest/upstream-pin.ts +52 -0
  17. package/src/adapter/loop-gate-report.ts +54 -0
  18. package/src/adapter/rapier-physics-adapter.ts +56 -0
  19. package/src/adapter/system-adapter.ts +154 -0
  20. package/src/adapter/transform.ts +18 -0
  21. package/src/adapter/vgai-scene-game-adapter.ts +886 -0
  22. package/src/adapter/world-kind.ts +34 -0
  23. package/src/ai/navigation.ts +164 -0
  24. package/src/animation/anim-graph-types.ts +56 -0
  25. package/src/animation/anim-graph.ts +406 -0
  26. package/src/animation/anim-system.ts +28 -0
  27. package/src/animation/blend-node.ts +119 -0
  28. package/src/animation/property-track.ts +178 -0
  29. package/src/animation/schema.ts +204 -0
  30. package/src/assets.ts +80 -0
  31. package/src/audio/ambient.ts +300 -0
  32. package/src/audio/impacts.ts +212 -0
  33. package/src/audio/index.ts +7 -0
  34. package/src/audio/movement.ts +140 -0
  35. package/src/audio/musical.ts +200 -0
  36. package/src/audio/ui-sounds.ts +171 -0
  37. package/src/audio/vehicle.ts +235 -0
  38. package/src/audio/weapons.ts +152 -0
  39. package/src/core/game-loop.ts +127 -0
  40. package/src/core/system-runner.ts +298 -0
  41. package/src/core/types.ts +58 -0
  42. package/src/dev/console-bridge.ts +83 -0
  43. package/src/dev/debug-draw.ts +80 -0
  44. package/src/dev/logger.ts +119 -0
  45. package/src/ecs/component-manager.ts +748 -0
  46. package/src/ecs/game-component.ts +147 -0
  47. package/src/ecs/hmr-swap-report.ts +65 -0
  48. package/src/input/input-manager.ts +439 -0
  49. package/src/input/input-types.ts +19 -0
  50. package/src/input/schema.ts +129 -0
  51. package/src/loader.ts +70 -0
  52. package/src/manifest/index.ts +24 -0
  53. package/src/manifest/load-file.ts +16 -0
  54. package/src/manifest/load.ts +378 -0
  55. package/src/manifest/schema.ts +375 -0
  56. package/src/physics/collision-system.ts +76 -0
  57. package/src/physics/physics-registry.ts +83 -0
  58. package/src/physics/transform-writer.ts +41 -0
  59. package/src/physics/trigger-dispatch.ts +97 -0
  60. package/src/react/game-state.tsx +172 -0
  61. package/src/render/auto-batcher.ts +169 -0
  62. package/src/render/render-batch-system.ts +268 -0
  63. package/src/render/render-features.ts +146 -0
  64. package/src/render/render-settings.ts +72 -0
  65. package/src/runtime/create-runtime.ts +1152 -0
  66. package/src/runtime/frame-selector-cache.ts +81 -0
  67. package/src/runtime/game.ts +1003 -0
  68. package/src/runtime/input-router.ts +213 -0
  69. package/src/runtime/mount-game.ts +269 -0
  70. package/src/runtime/mount-manifest.ts +361 -0
  71. package/src/runtime/scene-ui-bridge.ts +86 -0
  72. package/src/runtime/scene-ui-data.ts +119 -0
  73. package/src/runtime/state-bridge.ts +79 -0
  74. package/src/runtime/types.ts +196 -0
  75. package/src/scene/asset-loaders.ts +195 -0
  76. package/src/scene/asset-paths.ts +123 -0
  77. package/src/scene/asset-registry.ts +67 -0
  78. package/src/scene/collider-dimensions.ts +125 -0
  79. package/src/scene/component-registry.ts +40 -0
  80. package/src/scene/defaults.ts +164 -0
  81. package/src/scene/geometries/index.ts +7 -0
  82. package/src/scene/geometries/terrain.ts +42 -0
  83. package/src/scene/geometry-registry.ts +42 -0
  84. package/src/scene/instance-registry.ts +84 -0
  85. package/src/scene/instancers/grid.ts +38 -0
  86. package/src/scene/instancers/index.ts +7 -0
  87. package/src/scene/light-camera-factory.ts +97 -0
  88. package/src/scene/material-factory.ts +211 -0
  89. package/src/scene/material-registry.ts +73 -0
  90. package/src/scene/materials/index.ts +7 -0
  91. package/src/scene/materials/water.ts +56 -0
  92. package/src/scene/parse.ts +71 -0
  93. package/src/scene/particles-factory.ts +383 -0
  94. package/src/scene/scene-apply.ts +356 -0
  95. package/src/scene/scene-diff-schema.ts +115 -0
  96. package/src/scene/scene-diff-types.ts +29 -0
  97. package/src/scene/scene-loader.ts +1533 -0
  98. package/src/scene/scene-query.ts +63 -0
  99. package/src/scene/scene-types.ts +34 -0
  100. package/src/scene/scene-version.ts +40 -0
  101. package/src/scene/schema/animation.ts +95 -0
  102. package/src/scene/schema/audio.ts +25 -0
  103. package/src/scene/schema/camera.ts +21 -0
  104. package/src/scene/schema/collider.ts +69 -0
  105. package/src/scene/schema/entity-ref.ts +78 -0
  106. package/src/scene/schema/entity.ts +169 -0
  107. package/src/scene/schema/environment.ts +384 -0
  108. package/src/scene/schema/index.ts +95 -0
  109. package/src/scene/schema/instances.ts +35 -0
  110. package/src/scene/schema/joint.ts +26 -0
  111. package/src/scene/schema/light.ts +38 -0
  112. package/src/scene/schema/material.ts +113 -0
  113. package/src/scene/schema/mesh.ts +108 -0
  114. package/src/scene/schema/particles.ts +398 -0
  115. package/src/scene/schema/physics.ts +49 -0
  116. package/src/scene/schema/scene-file.ts +299 -0
  117. package/src/scene/schema/shadow.ts +24 -0
  118. package/src/scene/schema/spline.ts +21 -0
  119. package/src/scene/schema/tuples.ts +21 -0
  120. package/src/scene/schema/ui.ts +602 -0
  121. package/src/scene/user-data.ts +203 -0
  122. package/src/setup/setup-audio.ts +60 -0
  123. package/src/setup/setup-particles.ts +23 -0
  124. package/src/setup/setup-physics.ts +67 -0
  125. package/src/setup/setup-renderer.ts +529 -0
  126. package/src/types-n8ao.d.ts +37 -0
  127. package/src/types-realism-effects.d.ts +61 -0
  128. package/src/world2d/authoring-2d.ts +208 -0
  129. package/src/world2d/capture-to-scene2d.ts +52 -0
  130. package/src/world2d/collision-2d.ts +106 -0
  131. package/src/world2d/components-2d.ts +86 -0
  132. package/src/world2d/index.ts +66 -0
  133. package/src/world2d/ingest-iframe-2d.ts +255 -0
  134. package/src/world2d/ingest2d.ts +131 -0
  135. package/src/world2d/physics2d-registry.ts +49 -0
  136. package/src/world2d/pixi-game-adapter.ts +325 -0
  137. package/src/world2d/pixi-surface.ts +78 -0
  138. package/src/world2d/scene-capture-2d.ts +117 -0
  139. package/src/world2d/scene2d-loader.ts +308 -0
  140. package/src/world2d/schema/entity2d.ts +145 -0
  141. package/src/world2d/schema/physics2d.ts +53 -0
  142. package/src/world2d/schema/sprite.ts +71 -0
  143. package/src/world2d/schema/tilemap.ts +22 -0
  144. package/src/world2d/schema/tuples2d.ts +25 -0
  145. package/src/world2d/system-adapters-2d.ts +49 -0
  146. package/src/world2d/transform-writer-2d.ts +24 -0
  147. package/src/world2d/types.ts +55 -0
@@ -0,0 +1,299 @@
1
+ import { z } from 'zod';
2
+ import { type SceneEntity, SceneEntitySchema } from './entity';
3
+ import { SceneEnvironmentSchema } from './environment';
4
+ import { UIRootSchema } from './ui';
5
+
6
+ export const SceneFileSchema = z
7
+ .object({
8
+ version: z.number().describe('Scene file format version'),
9
+ name: z.string().describe('Scene display name'),
10
+ environment: SceneEnvironmentSchema.optional().describe('Scene-level environment settings'),
11
+ entities: z.array(SceneEntitySchema).describe('Top-level entities in the scene'),
12
+ // UI roots (HUD/menus) attached to the scene graph as data. Optional and
13
+ // additive — pre-UI scenes (no `ui` field) load unchanged (A4 versioning).
14
+ ui: z
15
+ .array(UIRootSchema)
16
+ .optional()
17
+ .describe('React UI roots (canvases) attached to the scene graph (A1)'),
18
+ })
19
+ .describe('Scene file (.vscn.json)');
20
+
21
+ export type SceneFile = z.infer<typeof SceneFileSchema>;
22
+
23
+ export const PrefabFileSchema = z
24
+ .object({
25
+ version: z.number().describe('Prefab file format version'),
26
+ name: z.string().describe('Prefab display name'),
27
+ root: SceneEntitySchema.describe('Root entity of the prefab'),
28
+ })
29
+ .describe('Prefab file (.prefab.json)');
30
+
31
+ export type PrefabFile = z.infer<typeof PrefabFileSchema>;
32
+
33
+ /**
34
+ * Shallow-merge a section, but deep-merge specific named nested sub-objects
35
+ * within it (e.g. `physics.collider`, `material.clearcoat`). A partial
36
+ * instance override of a nested sub-object would otherwise wholesale-replace
37
+ * it and drop the prefab's other fields in that sub-object (e.g. an instance
38
+ * overriding one collider field would silently lose the prefab's `type`).
39
+ */
40
+ function mergeSectionDeepNested<T extends Record<string, unknown>>(
41
+ prefabSection: T | undefined,
42
+ instanceSection: T | undefined,
43
+ nestedKeys: readonly (keyof T)[],
44
+ ): T | undefined {
45
+ if (instanceSection === undefined) return prefabSection;
46
+ if (prefabSection === undefined) return instanceSection;
47
+ const merged: Record<string, unknown> = { ...prefabSection, ...instanceSection };
48
+ for (const key of nestedKeys) {
49
+ const p = prefabSection[key];
50
+ const i = instanceSection[key];
51
+ if (
52
+ i !== undefined &&
53
+ p !== undefined &&
54
+ typeof i === 'object' &&
55
+ typeof p === 'object' &&
56
+ !Array.isArray(i) &&
57
+ !Array.isArray(p)
58
+ ) {
59
+ merged[key as string] = { ...(p as object), ...(i as object) };
60
+ }
61
+ }
62
+ return merged as T;
63
+ }
64
+
65
+ /**
66
+ * Sections whose nested sub-object needs deep merging (T1.10) — see the
67
+ * `mergePrefabInstance` docstring for the reasoning behind each.
68
+ */
69
+ const DEEP_NESTED_SECTIONS = [
70
+ { key: 'physics', nestedKeys: ['collider'] },
71
+ { key: 'material', nestedKeys: ['clearcoat', 'transmission', 'sheen', 'iridescence'] },
72
+ { key: 'shadow', nestedKeys: ['camera'] },
73
+ ] as const;
74
+
75
+ /**
76
+ * Re-validate a merged entity through `SceneEntitySchema` (T1.10). This is
77
+ * the gate that catches a prefab's inline `material` combined with an
78
+ * instance's `materialRef` (or vice versa) — each half is individually valid,
79
+ * so only the MERGED entity can trip the material/materialRef
80
+ * mutual-exclusion refine. Throws naming the offending prefab path + instance
81
+ * so a bad scene file points straight at the offender.
82
+ */
83
+ function validateMergedEntity(merged: SceneEntity, instance: SceneEntity): SceneEntity {
84
+ const validated = SceneEntitySchema.safeParse(merged);
85
+ if (validated.success) return validated.data;
86
+ const issues = validated.error.issues.map((issue) => issue.message).join('; ');
87
+ const prefabPath = instance.prefab ?? '<unknown prefab>';
88
+ throw new Error(
89
+ `Prefab merge produced an invalid entity — prefab "${prefabPath}", instance "${instance.name}": ${issues}`,
90
+ );
91
+ }
92
+
93
+ /**
94
+ * Merge a prefab root definition with an instance's overrides.
95
+ *
96
+ * Per-field merge rules (exactly as implemented below):
97
+ *
98
+ * - transform: instance wins entirely if set, else the prefab root's transform
99
+ * (placement is per-instance; transforms are not blended field-by-field).
100
+ * - name: instance always wins.
101
+ * - id: instance wins if set (each instance has its own id); else prefab's.
102
+ * - prefab: stripped from the result so spawnEntity recursion terminates.
103
+ *
104
+ * - Sections — `mesh`, `light`, `camera`, `animation`, `audio`, `particles`,
105
+ * `spline`, `render`: SHALLOW merge per section. If the instance sets the
106
+ * section, its top-level fields override the prefab root's same-named
107
+ * fields ({ ...prefabSection, ...instanceSection }); fields the instance
108
+ * omits fall through to the prefab. Nested objects are replaced, not
109
+ * deep-merged. If only the prefab has the section it is kept as-is.
110
+ * (CB4: `spline` is included here; CB5: see metadata below; T1.10: `render`
111
+ * is now included — an instance's per-entity render overrides are honored
112
+ * and merged the same way as `mesh`/`material`.)
113
+ *
114
+ * NOTE (T1.10 audit): `mesh.instancerParams`/`mesh.generatorParams` and
115
+ * `animation.parameters`/`animation.clipAliases` are keyed dict maps nested
116
+ * one level down, and `particles` nests discriminated-union shapes/behaviors
117
+ * arrays. These have the same "shallow replace" defect as `material`/
118
+ * `physics` did, but no single well-defined field-merge semantics (dict keys
119
+ * authors may legitimately want fully replaced; discriminated unions can't
120
+ * be safely field-merged across different variants). Left as wholesale
121
+ * per-section replace; flagged here rather than silently "fixed" with a
122
+ * guess. Revisit if this causes real authoring pain.
123
+ *
124
+ * - `material`: shallow merge at the top level, PLUS deep-merge of the four
125
+ * nested physical-material feature groups (`clearcoat`, `transmission`,
126
+ * `sheen`, `iridescence`) so an instance overriding e.g. `clearcoat.clearcoat`
127
+ * preserves the prefab's `clearcoat.clearcoatRoughness` (T1.10 — previously
128
+ * these nested groups were wholesale-replaced like any other shallow field).
129
+ *
130
+ * - `physics`: shallow merge at the top level (`bodyType`, `mass`), PLUS
131
+ * deep-merge of the nested `collider` object so a partial instance collider
132
+ * override (e.g. just `isSensor`) preserves the prefab's `type` and other
133
+ * collider fields instead of dropping them (T1.10 AC).
134
+ *
135
+ * - `shadow`: shallow merge at the top level, PLUS deep-merge of the nested
136
+ * `camera` (shadow-camera frustum bounds) object, for the same reason as
137
+ * `physics.collider` (T1.10 audit — same defect, same fix).
138
+ *
139
+ * - components: DEEP merge, keyed by component name. The union of component
140
+ * names is taken; for each, instance fields override prefab fields
141
+ * ({ ...prefabComp, ...instanceComp }).
142
+ *
143
+ * - joints: REPLACE — if the instance sets joints, its array wins wholesale
144
+ * (arrays are not field-mergeable); else the prefab's joints are kept.
145
+ * - children: APPEND — prefab children first, then instance-only children.
146
+ *
147
+ * - Instance-level metadata `visible`, `materialRef`, `tags`, `locked`,
148
+ * `navigation`, `pivot`: instance wins if explicitly set, otherwise the
149
+ * prefab root's value is inherited. (CB5: spline + these metadata fields are
150
+ * now instance-wins; previously dropped.)
151
+ *
152
+ * - Re-validation (T1.10): the merged entity is re-parsed through
153
+ * `SceneEntitySchema` before being returned. This is what makes the
154
+ * material/materialRef mutual-exclusion refine fire on the MERGED result —
155
+ * previously a prefab's inline `material` plus an instance's `materialRef`
156
+ * (or vice versa) silently combined into an entity carrying both, bypassing
157
+ * the refine entirely (it only ever saw the pre-merge, individually-valid
158
+ * halves). A merge that produces an invalid entity now throws, naming the
159
+ * offending prefab path + instance name.
160
+ */
161
+ export function mergePrefabInstance(prefabRoot: SceneEntity, instance: SceneEntity): SceneEntity {
162
+ const merged: SceneEntity = {
163
+ ...prefabRoot,
164
+ name: instance.name,
165
+ };
166
+
167
+ // Handle optional fields explicitly to satisfy exactOptionalPropertyTypes
168
+ const resolvedTransform = instance.transform ?? prefabRoot.transform;
169
+ if (resolvedTransform) merged.transform = resolvedTransform;
170
+ if (instance.id) merged.id = instance.id;
171
+
172
+ // Strip prefab field so spawnEntity won't recurse infinitely
173
+ delete merged.prefab;
174
+
175
+ applyInstanceMetadata(merged, prefabRoot, instance);
176
+ applyDeepNestedSections(merged, prefabRoot, instance);
177
+ applyShallowSections(merged, prefabRoot, instance);
178
+
179
+ const components = mergeComponents(prefabRoot, instance);
180
+ if (components !== undefined) merged.components = components;
181
+
182
+ // Joints: instance wins (array, not shallow-mergeable)
183
+ if (instance.joints !== undefined) {
184
+ merged.joints = instance.joints;
185
+ }
186
+
187
+ const children = mergeChildren(prefabRoot, instance);
188
+ if (children !== undefined) merged.children = children;
189
+
190
+ // Re-validate the merged result (T1.10) — see `validateMergedEntity` above.
191
+ return validateMergedEntity(merged, instance);
192
+ }
193
+
194
+ /**
195
+ * Visibility + instance-level metadata (`materialRef`, `tags`, `locked`,
196
+ * `navigation`, `pivot`): instance wins if explicitly set, otherwise the
197
+ * prefab root's value (already present on `merged` via the initial spread in
198
+ * `mergePrefabInstance`) is kept.
199
+ */
200
+ function applyInstanceMetadata(
201
+ merged: SceneEntity,
202
+ prefabRoot: SceneEntity,
203
+ instance: SceneEntity,
204
+ ): void {
205
+ if (instance.visible !== undefined) merged.visible = instance.visible;
206
+ if (instance.materialRef !== undefined) merged.materialRef = instance.materialRef;
207
+ if (instance.tags !== undefined) merged.tags = instance.tags;
208
+ if (instance.locked !== undefined) merged.locked = instance.locked;
209
+ if (instance.navigation !== undefined) merged.navigation = instance.navigation;
210
+
211
+ if (instance.pivot !== undefined) {
212
+ merged.pivot = instance.pivot;
213
+ } else if (prefabRoot.pivot !== undefined) {
214
+ merged.pivot = prefabRoot.pivot;
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Sections whose nested sub-object needs deep (not shallow) merging — see the
220
+ * `mergePrefabInstance` docstring for the reasoning behind each.
221
+ */
222
+ function applyDeepNestedSections(
223
+ merged: SceneEntity,
224
+ prefabRoot: SceneEntity,
225
+ instance: SceneEntity,
226
+ ): void {
227
+ for (const { key, nestedKeys } of DEEP_NESTED_SECTIONS) {
228
+ const result = mergeSectionDeepNested(
229
+ // biome-ignore lint/suspicious/noExplicitAny: TS can't correlate indexed access across a union of keys
230
+ (prefabRoot as any)[key],
231
+ // biome-ignore lint/suspicious/noExplicitAny: TS can't correlate indexed access across a union of keys
232
+ (instance as any)[key],
233
+ nestedKeys,
234
+ );
235
+ // biome-ignore lint/suspicious/noExplicitAny: TS can't correlate indexed access across a union of keys
236
+ if (result !== undefined) (merged as any)[key] = result;
237
+ }
238
+ }
239
+
240
+ /** Sections shallow-merged whole (material/physics/shadow handled separately above). */
241
+ const SHALLOW_SECTIONS = [
242
+ 'mesh',
243
+ 'light',
244
+ 'camera',
245
+ 'animation',
246
+ 'audio',
247
+ 'particles',
248
+ 'spline',
249
+ 'render',
250
+ ] as const;
251
+
252
+ /**
253
+ * Shallow merge per remaining section — instance fields override within the
254
+ * section ({ ...prefabSection, ...instanceSection }); if only the prefab has
255
+ * the section it is kept as-is.
256
+ */
257
+ function applyShallowSections(
258
+ merged: SceneEntity,
259
+ prefabRoot: SceneEntity,
260
+ instance: SceneEntity,
261
+ ): void {
262
+ for (const key of SHALLOW_SECTIONS) {
263
+ if (instance[key] === undefined) continue;
264
+ // biome-ignore lint/suspicious/noExplicitAny: TS can't correlate indexed access across a union of keys
265
+ (merged as any)[key] =
266
+ prefabRoot[key] !== undefined
267
+ ? // biome-ignore lint/suspicious/noExplicitAny: TS can't correlate indexed access across a union of keys
268
+ { ...(prefabRoot as any)[key], ...(instance as any)[key] }
269
+ : instance[key];
270
+ }
271
+ }
272
+
273
+ /** Deep merge `components`, keyed by component name (instance fields win per-component). */
274
+ function mergeComponents(
275
+ prefabRoot: SceneEntity,
276
+ instance: SceneEntity,
277
+ ):
278
+ | Record<string, Record<string, number | string | boolean | number[] | string[] | boolean[]>>
279
+ | undefined {
280
+ if (!instance.components && !prefabRoot.components) return undefined;
281
+ const base = prefabRoot.components ?? {};
282
+ const over = instance.components ?? {};
283
+ const result: Record<
284
+ string,
285
+ Record<string, number | string | boolean | number[] | string[] | boolean[]>
286
+ > = {};
287
+ for (const comp of new Set([...Object.keys(base), ...Object.keys(over)])) {
288
+ result[comp] = { ...base[comp], ...over[comp] };
289
+ }
290
+ return result;
291
+ }
292
+
293
+ /** Children: prefab children first, then instance-only children appended. */
294
+ function mergeChildren(prefabRoot: SceneEntity, instance: SceneEntity): SceneEntity[] | undefined {
295
+ const prefabChildren = prefabRoot.children ?? [];
296
+ const instanceChildren = instance.children ?? [];
297
+ if (prefabChildren.length === 0 && instanceChildren.length === 0) return undefined;
298
+ return [...prefabChildren, ...instanceChildren];
299
+ }
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+
3
+ export const SceneShadowSchema = z
4
+ .object({
5
+ enabled: z.boolean().describe('Whether this light casts shadows'),
6
+ mapSize: z.number().optional().describe('Shadow map resolution in pixels (e.g. 1024, 2048)'),
7
+ camera: z
8
+ .object({
9
+ left: z.number().optional().describe('Left bound of shadow camera frustum'),
10
+ right: z.number().optional().describe('Right bound of shadow camera frustum'),
11
+ top: z.number().optional().describe('Top bound of shadow camera frustum'),
12
+ bottom: z.number().optional().describe('Bottom bound of shadow camera frustum'),
13
+ })
14
+ .optional()
15
+ .describe('Shadow camera frustum bounds (directional lights)'),
16
+ radius: z.number().optional().describe('Shadow map blur radius for soft shadows'),
17
+ bias: z.number().optional().describe('Shadow bias to reduce shadow acne artifacts'),
18
+ })
19
+ .describe('Shadow casting configuration');
20
+
21
+ /** Partial schema for prefab instance overrides (enabled not required). */
22
+ export const SceneShadowOverrideSchema = SceneShadowSchema.partial();
23
+
24
+ export type SceneShadow = z.infer<typeof SceneShadowSchema>;
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { Vec3Schema } from './tuples';
3
+
4
+ export const SceneSplineSchema = z.object({
5
+ curveType: z
6
+ .enum(['centripetal', 'chordal', 'catmullrom'])
7
+ .describe('CatmullRomCurve3 parameterization type. Matches Three.js curveType parameter'),
8
+ points: z.array(Vec3Schema).min(2).describe('Control point positions in local space'),
9
+ closed: z.boolean().optional().describe('Whether the spline forms a closed loop'),
10
+ tension: z
11
+ .number()
12
+ .optional()
13
+ .describe(
14
+ 'Curve tension (default 0.5). Only used when curveType is catmullrom; ignored for centripetal and chordal',
15
+ ),
16
+ resolution: z.number().optional().describe('Number of line segments for rendering the curve'),
17
+ });
18
+
19
+ export type SceneSpline = z.infer<typeof SceneSplineSchema>;
20
+
21
+ export const SceneSplineOverrideSchema = SceneSplineSchema.partial();
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+
3
+ export const Vec3Schema = z
4
+ .tuple([z.number(), z.number(), z.number()])
5
+ .describe('3D vector as [x, y, z]');
6
+ export const QuatSchema = z
7
+ .tuple([z.number(), z.number(), z.number(), z.number()])
8
+ .describe('Quaternion as [x, y, z, w]');
9
+
10
+ export type Vec3 = z.infer<typeof Vec3Schema>;
11
+ export type Quat = z.infer<typeof QuatSchema>;
12
+
13
+ export const TransformSchema = z
14
+ .object({
15
+ position: Vec3Schema.optional().describe('World-space position [x, y, z]'),
16
+ rotation: QuatSchema.optional().describe('Rotation quaternion [x, y, z, w]'),
17
+ scale: Vec3Schema.optional().describe('Scale factor per axis [x, y, z]. Defaults to [1, 1, 1]'),
18
+ })
19
+ .describe('Local transform relative to parent entity');
20
+
21
+ export type SceneTransform = z.infer<typeof TransformSchema>;