Official Codebase of 3DCodeVerse
Python
placement: an asset that is scatter AND fog is exempt as instanced
ziyao08b400ea6685
diff --git a/harness/runtime_js/lib/host_placement.mjs b/harness/runtime_js/lib/host_placement.mjsindex 8f58088c..673a6948 100644--- a/harness/runtime_js/lib/host_placement.mjs+++ b/harness/runtime_js/lib/host_placement.mjs@@ -44,7 +44,8 @@* of which writes no depth, i.e. haze, god rays, glow (`nonSolid`) — and anything* the author tags `userData.placement = 'free'` on the asset or its zone (a bird, a* hanging lantern, a drone). A volumetric mesh is not indexed at all, so it is- * never a support, never something to sink into and never an overlap partner. First 400 assets, 4 s budget; the table says when it cut.+ * never a support, never something to sink into and never an overlap partner.+ * First 400 assets, 4 s budget; the table says when it cut.** Vertical rays only, so every mesh gets a "column index": world vertices once* and, above 1 500 triangles, a uniform XZ grid of triangle buckets. A column@@ -241,8 +242,10 @@ function collectAssets(scene, indices, volumetrics, contentBox) {if (assets.length >= MAX_ASSETS) continue;const a = { obj: child, name: child.name || `${child.type}_${total}`, zone: zone === child ? '' : (zone.name || zone.type), meshes, instanced, exempt: '' };if (isFree(zone) || isFree(child)) a.exempt = 'free';+ // instanced first: an asset that is scatter PLUS a haze shell is exempt because its+ // instances cannot be sampled at this budget, which is the more informative reason+ else if (!meshes.length && instanced) a.exempt = 'instanced';else if (!meshes.length && volumetric) a.exempt = 'volumetric';- else if (!meshes.length) a.exempt = 'instanced';else {a.min = [Infinity, Infinity, Infinity]; a.max = [-Infinity, -Infinity, -Infinity];let backdrop = 0;diff --git a/harness/tests/scene_runtime/test_placement_volumetric.py b/harness/tests/scene_runtime/test_placement_volumetric.pyindex 96f833f0..a0600c84 100644--- a/harness/tests/scene_runtime/test_placement_volumetric.py+++ b/harness/tests/scene_runtime/test_placement_volumetric.py@@ -119,3 +119,34 @@ def test_the_same_shells_WITH_depth_write_are_still_measured(solid_control):# every one of them is a solid object against fog — which is the whole pointassert all("AtmosphereHaze" in p or "MoonlightShaft" in p for p in pairs)assert ["AtmosphereHaze", "BlackPine"] in pairs+++SCATTER_JS = """+import * as THREE from 'three';+import { sceneCensus } from './lib/host_census.mjs';+const solid = new THREE.MeshStandardMaterial();+const fog = new THREE.MeshBasicMaterial({ transparent: true, opacity: 0.04, depthWrite: false });+const scene = new THREE.Scene();+const env = new THREE.Group(); env.name = 'Environment'; scene.add(env);+const ground = new THREE.Mesh(new THREE.PlaneGeometry(60, 60, 8, 8), solid);+ground.name = 'Ground'; ground.rotation.x = -Math.PI / 2; env.add(ground);+const zone = new THREE.Group(); zone.name = 'Meadow'; scene.add(zone);+// scatter AND a haze shell in one asset: both reasons apply, the instanced one is better+const mixed = new THREE.Group(); mixed.name = 'TuftsAndHaze';+mixed.add(new THREE.InstancedMesh(new THREE.BoxGeometry(0.2, 0.2, 0.2), solid, 40));+const shell = new THREE.Mesh(new THREE.BoxGeometry(20, 4, 20), fog);+shell.position.y = 2; mixed.add(shell);+zone.add(mixed);+scene.updateMatrixWorld(true);+const t = sceneCensus(scene, THREE, { placement: true }).placement;+console.log(JSON.stringify({ exempt: t.exempt,+ rows: t.assets.map((a) => ({ name: a.name, exempt: a.exempt })) }));+"""+++def test_scatter_that_also_carries_fog_is_exempt_as_instanced():+ """Both reasons are true; `instanced` says the useful thing (its instances cannot be+ sampled at this budget), so it wins."""+ out = run_node_json(SCATTER_JS.replace("'./lib/", f"'{RUNTIME_JS}/lib/"))+ row = [a for a in out["rows"] if a["name"] == "TuftsAndHaze"]+ assert row and row[0]["exempt"] == "instanced"