Merge pull request #4 from Rich43/codex/fix-missing-back-face-vertices

Fix box_with_door door mesh creation
This commit is contained in:
Richard Ward
2025-07-16 23:19:55 +01:00
committed by GitHub

View File

@@ -23,19 +23,14 @@ def create_box_with_door(box_length=30.0, box_width=20.0, box_height=15.0, door_
box_mesh = box.mesh
# Define door cutout (rectangular prism to subtract)
door_thickness = 0.1 # Thin cutout for subtraction
door_vertices = np.array([
[box_length - door_thickness, box_width / 2 - door_width / 2, 0], # Bottom-left
[box_length - door_thickness, box_width / 2 + door_width / 2, 0], # Bottom-right
[box_length - door_thickness, box_width / 2 + door_width / 2, door_height], # Top-right
[box_length - door_thickness, box_width / 2 - door_width / 2, door_height], # Top-left
])
door_faces = np.array([
[0, 1, 2], [0, 2, 3], # Front face
# Add side faces for a thin prism (simplified)
[0, 1, 4], [1, 5, 4], [1, 2, 5], [2, 6, 5], [2, 3, 6], [3, 7, 6], [3, 0, 7], [0, 4, 7]
]) # Note: 4-7 vertices would need z-offset, simplified here
door = trimesh.Trimesh(vertices=door_vertices, faces=door_faces, process=False)
door_thickness = 0.1 # Thin cutout for subtraction
# Create a small box representing the door cutout
door = trimesh.creation.box(extents=[door_thickness, door_width, door_height])
door.apply_translation([
box_length - door_thickness / 2,
box_width / 2,
door_height / 2,
])
door.apply_translation([0, 0, box_height - door_height]) # Position at top of door height
# Subtract door cutout from box