Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Local volumes: MCP schema field, size note, capabilities topic

Nguyen Xuan An81a116fbb973
diff --git a/changes/710-local-volumes.size.md b/changes/710-local-volumes.size.md
new file mode 100644
index 00000000..5f092886
--- /dev/null
+++ b/changes/710-local-volumes.size.md
@@ -0,0 +1,11 @@
+- entry:core: the post step list and the frame's bind call for local volumes, a few lines in the renderer (the shader and checks load with the fog addon).
+- entry:path-tracer: the local volume crossing (box and sphere intervals, nearest-first march, absorption and emission) is an agent-facing capability of the CPU tracer.
+- entry:fog-shader: the local volume shader, packing and checks load only with the fog addon, so scenes without fog or volumes do not carry them.
+- scene:lit-box: the same few core lines, counted in this scene.
+- scene:gltf-box: the same few core lines, counted in this scene.
+- scene:gltf-box+lazy: the same few core lines, counted in this scene.
+- scene:agent-scene: the recipe check and environment field for localVolumes run in the core, an agent-facing capability.
+- scene:agent-scene+lazy: the same code, counted in the lazy bundle.
+- goal:lit-box: growth is a few core lines for a new capability whose shader code lives in the fog addon.
+- goal:gltf-box: growth is a few core lines for a new capability whose shader code lives in the fog addon.
+- goal:agent-scene: the scene is already over its goal; localVolumes validation must run where the recipe is checked.
diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjs
index 06b6b7d5..de420a12 100644
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@ -278,6 +278,7 @@ const environment = z.strictObject({
fogColor: color.optional(),
fogDensity: bounded(0, 10).optional(),
volumeFog: volumeFog.optional().describe('Light-shaft fog; needs HDR.'),
+ localVolumes: z.array(z.record(z.string(), z.unknown())).max(8).optional().describe('Up to 8 absorbing and emitting volumes; fields in scene_capabilities localVolumes.'),
liquid: liquidOptics.optional().describe('Optics for materials tagged liquid or foam.'),
lines: lines.nullable().optional(),
objectReflections: z.boolean().optional().describe("false turns off reflection probes on smooth metal parts."),
diff --git a/src/fog-shader.js b/src/fog-shader.js
index fda5c96f..8701956d 100644
--- a/src/fog-shader.js
+++ b/src/fog-shader.js
@@ -78,6 +78,7 @@ function bindFieldAndLights(renderer, post, volume) {
// with the local step compiled in, and a program without it never reaches this function.
function bindLocalVolumes(renderer, post, volumes, frame) {
const context = renderer.context;
+ if (!renderer.depth || !renderer.hdr || renderer.transparent || renderer.benchmark) throw new Error('Local volumes require depth:true, active HDR and an opaque canvas');
const buffers = (renderer.localVolumeBuffers ??= createLocalVolumeBuffers());
packLocalVolumes(resolveLocalVolumes(volumes, 'environment.localVolumes'), buffers);
const locate = name => (post.uniforms[name] ??= context.getUniformLocation(post.program, name));
diff --git a/src/renderer.js b/src/renderer.js
index e3a1c89b..b5a21e59 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -2282,10 +2282,6 @@ export class Renderer67 {
const lightLength = direction?.length === 3 ? Math.hypot(...direction) : NaN;
if (!Number.isFinite(lightLength) || lightLength < 1e-6 || !Array.from(direction).every(component => typeof component === 'number' && Math.abs(component) <= 1e6)) throw new RangeError('Volume light direction must have a finite nonzero length and bounded components');
}
- if (environment.localVolumes?.length) {
- requireFeatureCode('volumeFog');
- if (!this.depth || !this.hdr || this.transparent || this.benchmark) throw new Error('Local volumes require depth:true, active HDR and an opaque canvas');
- }
updateLightingState(this.lighting, environment, { world: this.world });
this.syncViewTransform(environment);
// The shadow view follows the sun, so a moved sun redraws the map.