Fix native island material rendering

This commit is contained in:
que01 committed 2026-09-29 12:04:29 +08:00
1 parent b6d30787cd
commit c1277af16a
4 files changed
+28 -3

No files matched your search

+3 -1
View File
@@ -668,6 +668,8 @@ def build(args):
catalog.MATERIALS["native_center_line_white"])
road_mats["native_lane_separator_yellow"] = material_from_spec(
catalog.MATERIALS["native_lane_separator_yellow"])
road_mats["native_island_green"] = material_from_spec(
catalog.MATERIALS["native_island_green"])
traffic_signal_mats = {
"metal": material_from_spec(catalog.MATERIALS["traffic_signal_metal"]),
"housing": material_from_spec(catalog.MATERIALS["traffic_signal_housing"]),
@@ -800,7 +802,7 @@ def build(args):
if not os.path.isdir(native_road_dir):
raise RuntimeError("--native-road directory does not exist: " + native_road_dir)
material_layers = {layer["id"]: road_mats.get(layer["id"]) for layer in catalog.ROAD_LAYERS}
material_layers.update({"native_center_line_white": road_mats["native_center_line_white"], "native_lane_separator_yellow": road_mats["native_lane_separator_yellow"]})
material_layers.update({"native_center_line_white": road_mats["native_center_line_white"], "native_lane_separator_yellow": road_mats["native_lane_separator_yellow"], "native_island_green": road_mats["native_island_green"]})
road_counts.update(_native_roads.assemble(native_road_dir, projector, roads_c, material_layers))
elif geojson_dir and os.path.isdir(geojson_dir):
for problem in catalog.check_layers(geojson_dir):
+5
View File
@@ -194,6 +194,11 @@ MATERIALS = {
"native_lane_separator_yellow": {"kind": "solid", "name": "Native Lane Separator Yellow",
"color": (0.94, 0.58, 0.06), "roughness": 0.52,
"cesium": {"base_color": (0.94, 0.58, 0.06)}},
# Safety-island planting follows the neutral green-grey map fill and is
# intentionally opaque so it does not blend with the asphalt below.
"native_island_green": {"kind": "solid", "name": "Native Island Green",
"color": (0.0382, 0.4793, 0.1441), "roughness": 0.92,
"cesium": {"base_color": (0.0382, 0.4793, 0.1441)}},
}
+5 -1
View File
@@ -44,8 +44,12 @@ def assemble(native_road_dir, projector, collection, material_layers):
case_material_name = case.get("material", material_name)
case_material = _material(material_layers, case_material_name)
suffix = "_" + str(case["match"]) if "match" in case else ""
# Split cases may be inset overlays (for example the green
# planting inside a grey safety-island base). Keep the geometry
# unchanged, but lift matched overlays slightly to avoid z-fighting.
case_z = z_by_material_layer[material_name] + (0.001 if "match" in case else 0.0)
count += roads.assemble_geojson_layer(
source_path, source + suffix, projector, collection, case_material,
z_by_material_layer[material_name], _split_filter(split, case))
case_z, _split_filter(split, case))
counts[source] = count
return counts
+15 -1
View File
@@ -31,7 +31,7 @@ from osmassets.geom import (
sample_tree_row,
signed_polygon_area,
)
from osmassets.catalog import ROAD_LAYERS
from osmassets.catalog import MATERIALS, ROAD_LAYERS
from osmassets.native_road_manifest import CONTRACT, load as load_native_road_manifest
from osmassets.osm import Projector, parse_height, parse_osm, tags
@@ -40,6 +40,13 @@ SQUARE = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
class RoadLayerCatalogTest(unittest.TestCase):
def test_native_island_material_is_registered(self):
material = MATERIALS["native_island_green"]
self.assertEqual(material["kind"], "solid")
self.assertEqual(material["color"], (0.0382, 0.4793, 0.1441))
self.assertGreater(material["color"][1], material["color"][0])
self.assertGreater(material["color"][1], material["color"][2])
def test_intersection_and_road_asphalt_share_the_same_colour(self):
layers = {layer["id"]: layer for layer in ROAD_LAYERS}
self.assertEqual(layers["road_surface"]["color"],
@@ -105,6 +112,13 @@ class NativeRoadManifestTest(unittest.TestCase):
with self.assertRaisesRegex(RuntimeError, "semantic"):
load_native_road_manifest(self.root.name)
def test_split_overlay_has_a_separate_z_layer(self):
native_roads = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"..", "osmassets", "native_roads.py")
with open(native_roads, encoding="utf-8") as handle:
source = handle.read()
self.assertIn('0.001 if "match" in case else 0.0', source)
self.write_manifest([{"source": "center_lines", "role": "marking",
"materialLayer": "center_lines", "splitBy": {
"prop": "color", "cases": [