Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Raise size budgets for the frame diagnostics (#266, #264)

Nguyen Xuan An6c5cfb9057d7
diff --git a/bench/size/budgets.json b/bench/size/budgets.json
index 6adf3744..3176ea0d 100644
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@ -6,13 +6,13 @@
"agent-scene": 100000
},
"budgets": {
- "entry:core": 86840,
+ "entry:core": 87300,
"entry:model": 14400,
"entry:nature": 13200,
"entry:motion": 13600,
"entry:canvas2d": 9400,
- "entry:gltf": 54110,
- "entry:gltf+lazy": 57440,
+ "entry:gltf": 54120,
+ "entry:gltf+lazy": 57450,
"entry:modeling": 8700,
"entry:sculpt": 2500,
"entry:surface": 10100,
@@ -34,9 +34,9 @@
"entry:ground-bounce": 9460,
"entry:path-tracer": 14600,
"entry:texture-set": 900,
- "entry:agent-scene": 78530,
+ "entry:agent-scene": 78540,
"entry:agent-scene+lazy": 261000,
- "entry:agent-asset": 109880,
+ "entry:agent-asset": 109890,
"entry:agent-asset+lazy": 272400,
"entry:hdri": 3300,
"entry:camera-effects": 8600,
@@ -45,10 +45,10 @@
"entry:material-layer-shaders": 21360,
"entry:light-linking": 19680,
"entry:cascaded-shadows": 28480,
- "scene:lit-box": 64210,
- "scene:gltf-box": 85240,
- "scene:gltf-box+lazy": 88570,
- "scene:agent-scene": 106030,
- "scene:agent-scene+lazy": 288460
+ "scene:lit-box": 64650,
+ "scene:gltf-box": 85680,
+ "scene:gltf-box+lazy": 89010,
+ "scene:agent-scene": 106460,
+ "scene:agent-scene+lazy": 288870
}
}
diff --git a/src/frame-diagnostics.js b/src/frame-diagnostics.js
index 03871236..b584ad6b 100644
--- a/src/frame-diagnostics.js
+++ b/src/frame-diagnostics.js
@@ -7,6 +7,10 @@ import { resolveShadowLight } from './shadow-light.js';
const SHADOW_DISAGREEMENT_DEGREES = 10;
const NO_DIAGNOSTICS = Object.freeze([]);
+function warning(kind, target, message, fix) {
+ return { kind, severity: 'warning', target, message, fix };
+}
+
function angleBetweenDegrees(first, second) {
const dot = first[0] * second[0] + first[1] * second[1] + first[2] * second[2];
const lengths = Math.hypot(...first) * Math.hypot(...second);
@@ -19,21 +23,17 @@ function shadowDirectionProblem(world, lightDirection, shadowBounds) {
const towardShadowEye = light.eye.map((value, axis) => value - light.target[axis]);
const degrees = angleBetweenDegrees(towardShadowEye, lightDirection);
if (degrees < SHADOW_DISAGREEMENT_DEGREES) return null;
- return {
- kind: 'shadow-light-direction-mismatch', severity: 'warning', target: 'shadowBounds.eye',
- message: `shadowBounds.eye points ${Math.round(degrees)} degrees away from environment.lightDirection. The eye decides where shadows fall; lightDirection only moves the shading.`,
- fix: 'Remove shadowBounds.eye so the shadow follows lightDirection, or set lightDirection to the direction from shadowBounds.target to shadowBounds.eye.',
- };
+ return warning('shadow-light-direction-mismatch', 'shadowBounds.eye',
+ `shadowBounds.eye is ${Math.round(degrees)} degrees off lightDirection; the eye sets the shadow direction.`,
+ 'Drop shadowBounds.eye, or point lightDirection from shadowBounds.target to it.');
}
export function frameDiagnostics({ world, depth, effects, lightDirection, shadowBounds }) {
const problems = [];
if (effects.ambientOcclusion > 0 && !depth) {
- problems.push({
- kind: 'ambient-occlusion-without-depth', severity: 'warning', target: 'effects.ambientOcclusion',
- message: `effects.ambientOcclusion is ${effects.ambientOcclusion} but the renderer was built without depth, so the occlusion pass is skipped.`,
- fix: 'Construct the renderer with depth: true, or set effects.ambientOcclusion to 0.',
- });
+ problems.push(warning('ambient-occlusion-without-depth', 'effects.ambientOcclusion',
+ `ambientOcclusion is ${effects.ambientOcclusion} but the renderer has no depth, so the pass is skipped.`,
+ 'Build the renderer with depth: true, or set ambientOcclusion to 0.'));
}
if (shadowBounds?.eye && lightDirection) {
const problem = shadowDirectionProblem(world, lightDirection, shadowBounds);