4.3 KiB
4.3 KiB
Design feature registry
Goal
Introduce a conservative Blender feature registry so generate_scene.py no
longer hard-codes every OSM feature dispatch branch, while keeping generated
.blend / .glb / scene metadata and stdout contracts unchanged.
The user value is maintainability: adding or moving a Blender feature should become a registration-level edit plus a feature module implementation, not a new branch woven through the main scene builder.
Background
- P2 module extraction is now complete for current feature assembly modules:
water.py,grass.py,scrub.py,tree.py,fountain.py,building.py, androads.pyexist underblender/osmassets/. .trellis/spec/guides/artifact-parity-guide.mdrecords the remaining P2 gap as the missingfeatures/registry.blender/generate_scene.pystill owns the orchestration sequence: material creation, OSM way dispatch, road GeoJSON/fallback dispatch, tree collection/fallback, fountain point dispatch, camera focus points, scene metadata, save/render, andSCENE_DONE.- Artifact parity is mandatory because this is intended as a pure refactor.
Requirements
- Add a new Blender-side registry module under
blender/osmassets/, expected pathblender/osmassets/features.py. - Replace the inline OSM way
if/eliffeature dispatch ingenerate_scene.pywith registry-driven dispatch while preserving exact behavior and order:- water before grass;
- grass before scrub;
- scrub before tree-row collection;
- tree-row collection before building;
- first matching handler wins, as the current
elifchain does.
- Make the current feature phases explicit in code:
- OSM way feature phase;
- road GeoJSON / OSM fallback phase;
- tree placement phase;
- point prop phase for fountains.
- Keep
generate_scene.pyresponsible for high-level scene contracts:- CLI parsing and tree-style validation;
- collection creation and collection order;
- material creation order;
counts,road_counts, tree counts, andfocus_pointsownership;catalog.check_layers()and exactLayer catalog warning:print text;- scene custom properties;
SCENE_DONEmarker and JSON shape.
- Do not change current feature module assembly signatures unless the change is a mechanical adapter around the same behavior.
- Do not reorder
catalog.MATERIALS,catalog.ROAD_LAYERS, collection creation, object creation phases, orSCENE_DONEfields. - Do not introduce a second list of osm2streets road layer ids. Road layer
iteration must still derive from
catalog.ROAD_LAYERS. - Do not fix unrelated known defects D1-D3 in this task.
Acceptance Criteria
blender/osmassets/features.pyexists and contains the registry / dispatcher contract for Blender feature phases.generate_scene.pyuses the registry for OSM way feature dispatch; the previous inlineif/elifway feature chain is removed or reduced to small handler callbacks.- Current generated object names, mesh names, material creation order,
collection order, scene properties, and
SCENE_DONEJSON remain unchanged. road_counts,counts, tree counts, andfocus_pointscontinue to be owned bygenerate_scene.pyor by explicit objects passed from it, not hidden in global module state.catalog.check_layers()warning behavior remains ingenerate_scene.pywith the exactLayer catalog warning:text.python3 -m py_compile blender/osmassets/features.pypasses.python3 -m py_compile blender/generate_scene.pypasses.python3 -m unittest blender/tests/test_pure.pypasses.- Blender/Cesium parity before/after is run for
nantaizi-lake-innovation-valleyandhanyang-block; expected compare result isidenticalfor both.
Out Of Scope
- Changing feature behavior, geometry, z values, material definitions, material order, or catalog declarations.
- Moving material creation into feature modules.
- Moving scene metadata /
SCENE_DONEconstruction out ofgenerate_scene.py. - Reworking tree model loading, procedural tree fallback, grass tuft loading, scrub bush loading, or camera focus logic beyond adapter-level plumbing.
- Adding new rendered feature types.
- Changing parity ignore lists or stdout marker parsing.
Open Questions
None.