{"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/r35-rangefinder-camera.jpg"}}, {"type": "text", "text": "create an image of an r-35 rangefinder camera"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA compact 35 mm rangefinder camera, front-left three-quarter view. Boxy body with rounded ends: brushed silver top and bottom plates, black pebble-grain leatherette around the middle, and a big black 50 mm lens sticking out left of center. Three windows across the top front, a dial cluster and cold shoe on top, a strap lug on the right end.\n\nSCALE\nAbout 16 cm wide, 94 mm tall, 74 mm deep. Build in meters, +Y up, +Z forward (lens points +Z), origin at the bottom center of the body.\n\nPARTS\n1. Body shell: rounded box split into a cast shell, a brushed top housing and a bottom plate with fine seams. Build: beveled boxes plus thin seam strips.\n2. Leatherette: the black textured band on the front and the rear door. Build: thin wrap panels sitting just proud of the shell.\n3. Finder windows: two large windows and a small illuminator, each with a raised bezel, black gasket and teal-coated glass. Build: one window helper (bezel, gasket, inset glass) reused three times.\n4. Lens: mount flange, knurled focus ring, distance scale, aperture ring, front bezel, multicoated front element, engraved \"R-OPTICAL 1:2 f=50mm\". Build: lathe every ring from a profile, knurl by radial cuts, arc text for the engraving.\n5. Top controls: shutter dial with diamond grip, cold shoe, rewind crank, film advance lever, shutter release. Build: turned rings and disks, small boxes for the shoe and lever.\n6. Small details: lens release button, strap lug, \"R-35 RANGEFINDER\" lettering, rear eyepiece. Build: disks, a bent loop, text labels.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the bottom center.\n2. Texture maps: generate brushed-aluminum and pebble-grain leatherette normal maps from height noise.\n3. Build order: body shell, leatherette, finder windows, lens, top controls, small details. Everything after the shell is placed off the shell's edges.\n4. Assemble: windows sit flush in the top housing, the lens mounts on the front below the top plate, dials sit on the top plate, the lug goes on the right end.\n5. Materials: satin-brushed aluminum, polished stainless, black anodized aluminum, gunmetal edges, graphite leatherette, black rubber seals, smoked and teal optical glass, white and dark engraving fills, a vermilion index mark.\n6. Export: camera only, no studio, one GLB with the textures embedded.\n\nCHECK\n181,928 triangles across 162 parts. Against the image: lens left of center, top plate about the upper third of the body, three windows in a row across the front.\n\n\n```python\n# build_rangefinder.py\n\"\"\"Model, texture, export and photograph the R-35 camera in Blender.\"\"\"\nimport argparse\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bmesh\nimport bpy\nimport numpy as np\nfrom mathutils import Vector\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\"--output\", type=Path, required=True)\nparser.add_argument(\"--draft\", action=\"store_true\")\nargs = parser.parse_args(sys.argv[sys.argv.index(\"--\") + 1:])\nOUT = args.output.resolve()\nOUT.mkdir(parents=True, exist_ok=True)\n\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\nPARTS = []\n\n\ndef rgba(hex_color):\n srgb = [int(hex_color[i:i + 2], 16) / 255 for i in (0, 2, 4)]\n return (*[x / 12.92 if x <= 0.04045 else ((x + 0.055) / 1.055) ** 2.4 for x in srgb], 1)\n\n\ndef material(name, color, metal=0, rough=0.45, coat=0):\n mat = bpy.data.materials.new(name)\n mat.use_nodes = True\n node = mat.node_tree.nodes.get(\"Principled BSDF\")\n node.inputs[\"Base Color\"].default_value = rgba(color)\n node.inputs[\"Metallic\"].default_value = metal\n node.inputs[\"Roughness\"].default_value = rough\n node.inputs[\"Coat Weight\"].default_value = coat\n node.inputs[\"Coat Roughness\"].default_value = 0.2\n mat.diffuse_color = rgba(color)\n return mat\n\n\ndef texture(name, data, colorspace):\n height, width, _ = data.shape\n image = bpy.data.images.new(name, width=width, height=height, alpha=False)\n image.colorspace_settings.name = colorspace\n image.pixels.foreach_set(np.ascontiguousarray(data, dtype=np.float32).ravel())\n image.file_format = \"PNG\"\n image.filepath_raw = str(OUT / (name + \".png\"))\n image.save()\n image.reload()\n image.colorspace_settings.name = colorspace\n return image\n\n\ndef channels(r, g, b):\n return np.stack((r, g, b, np.ones_like(r)), axis=-1)\n\n\ndef image_node(mat, image):\n node = mat.node_tree.nodes.new(\"ShaderNodeTexImage\")\n node.image = image\n return node\n\n\ndef apply_normal(mat, image, strength=1.0):\n tex = image_node(mat, image)\n normal = mat.node_tree.nodes.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value = strength\n mat.node_tree.links.new(tex.outputs[\"Color\"], normal.inputs[\"Color\"])\n mat.node_tree.links.new(normal.outputs[\"Normal\"], mat.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Normal\"])\n\n\ndef normal_from_height(height, strength):\n x = (np.roll(height, -1, axis=1) - np.roll(height, 1, axis=1)) * strength\n y = (np.roll(height, -1, axis=0) - np.roll(height, 1, axis=0)) * strength\n length = np.sqrt(1 + x * x + y * y)\n return channels(0.5 - 0.5 * x / length, 0.5 - 0.5 * y / length, 0.5 + 0.5 / length)\n\n\nrng = np.random.default_rng(35)\nside = 1024\ny, x = np.mgrid[:side, :side].astype(np.float32) / side\ncells = 29\ngrid_x = x * cells + 0.17 * np.sin(2 * np.pi * (7 * x + 5 * y))\ngrid_y = y * cells + 0.16 * np.cos(2 * np.pi * (4 * x - 9 * y))\nu, v = np.floor(grid_x).astype(int), np.floor(grid_y).astype(int)\njitter = rng.random((cells, cells, 2))\nfirst = np.full_like(x, np.inf)\nsecond = first.copy()\nfor j in (-1, 0, 1):\n for i in (-1, 0, 1):\n a, b = u + i, v + j\n point = jitter[b % cells, a % cells]\n dist = (grid_x - a - point[:, :, 0]) ** 2 + (grid_y - b - point[:, :, 1]) ** 2\n second = np.minimum(second, np.maximum(first, dist))\n first = np.minimum(first, dist)\ngroove = np.clip((np.sqrt(second) - np.sqrt(first)) * 7.0, 0, 1)\npores = rng.random((side, side))\ngrain = groove ** 0.48 * 0.73 + np.sin(2 * np.pi * (51 * x + 71 * y + groove)) * 0.055\ncloud = np.sin(2 * np.pi * (2 * x + 3 * y)) * np.cos(2 * np.pi * (3 * x - 1 * y))\ntint = 0.082 + 0.034 * grain + 0.018 * pores + 0.01 * cloud\nleather = material(\"Graphite pebble-grain leatherette\", \"34302C\", rough=0.67)\ncolor = texture(\"Leather_BaseColor\", channels(tint * 1.13, tint * 1.06, tint), \"sRGB\")\nnormal = texture(\"Leather_Normal\", normal_from_height(grain + 0.07 * pores, 4.0), \"Non-Color\")\nleather.node_tree.links.new(image_node(leather, color).outputs[\"Color\"],\n leather.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Base Color\"])\napply_normal(leather, normal)\n\nlines = rng.random((side, 1)) * 0.72 + 0.2 * rng.random((side, side))\nlines += 0.10 * np.sin(2 * np.pi * (43 * y + 2 * x))\naluminum = material(\"Satin-brushed anodized aluminum\", \"B9B4A9\", 0.94, 0.31)\napply_normal(aluminum, texture(\"BrushedAluminum_Normal\", normal_from_height(lines, 0.36), \"Non-Color\"), 0.65)\nsteel = material(\"Polished stainless steel\", \"BDB8AD\", 0.96, 0.21)\ndark = material(\"Black anodized aluminum\", \"292B2A\", 0.71, 0.36)\nedge = material(\"Gunmetal machined edges\", \"575852\", 0.83, 0.32)\nrubber = material(\"Black rubber and seals\", \"161616\", 0.0, 0.79)\nivory = material(\"Warm white engraved fill\", \"E2D8BD\", 0.09, 0.44)\nink = material(\"Dark graphite engraved fill\", \"24231F\", 0.14, 0.44)\nred = material(\"Vermilion index mark\", \"BF442D\", 0.1, 0.35, 0.21)\ndark_glass = material(\"Smoked optical glass\", \"111F21\", 0.44, 0.14, 0.91)\nfinder_glass = material(\"Teal-coated finder glass\", \"1B3533\", 0.44, 0.16, 0.78)\noptic = material(\"Deep teal multicoated front element\", \"102628\", 0.33, 0.125, 1.0)\noptic.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Coat Tint\"].default_value = rgba(\"95B5AF\")\niris = material(\"Inner optical barrel\", \"1B2521\", 0.38, 0.33)\n\n\ndef finish(obj, name, mat, track=True, smooth=False):\n obj.name = name\n obj.data.materials.append(mat)\n if smooth:\n for poly in obj.data.polygons:\n poly.use_smooth = True\n if track:\n PARTS.append(obj)\n return obj\n\n\ndef bevel(obj, width, segments=4):\n modifier = obj.modifiers.new(\"Machined edge radii\", \"BEVEL\")\n modifier.width = width\n modifier.segments = segments\n modifier.harden_normals = True\n normal = obj.modifiers.new(\"Weighted corner normals\", \"WEIGHTED_NORMAL\")\n normal.keep_sharp = True\n\n\ndef box(name, loc, size, mat, radius=0.04, track=True):\n bpy.ops.mesh.primitive_cube_add(size=2, location=loc)\n obj = bpy.context.object\n obj.dimensions = size\n bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)\n for polygon in obj.data.polygons:\n axis = max(range(3), key=lambda i: abs(polygon.normal[i]))\n i, j = ((1, 2), (0, 2), (0, 1))[axis]\n for index in polygon.loop_indices:\n co = obj.data.vertices[obj.data.loops[index].vertex_index].co\n obj.data.uv_layers.active.data[index].uv = (co[i] / 4.6 + 0.5, co[j] / 4.6 + 0.5)\n if radius:\n bevel(obj, radius)\n return finish(obj, name, mat, track)\n\n\ndef mesh(name, verts, faces, mat, smooth=True):\n data = bpy.data.meshes.new(name)\n data.from_pydata(verts, [], faces)\n data.update()\n bm = bmesh.new()\n bm.from_mesh(data)\n bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))\n bm.to_mesh(data)\n bm.free()\n obj = bpy.data.objects.new(name, data)\n bpy.context.collection.objects.link(obj)\n return finish(obj, name, mat, smooth=smooth)\n\n\ndef lathe(name, profile, mat, center=(0, 0), axis=\"Y\", steps=144, ridges=0, depth=0, close=True):\n vertices, faces = [], []\n for radius, axial in profile:\n for i in range(steps):\n angle = 2 * math.pi * i / steps\n wave = math.cos(ridges * angle) if ridges else 0\n offset = depth * max(0, wave) ** 1.5\n r = radius + (offset if radius > 0.05 else 0)\n a, b = center[0] + r * math.cos(angle), center[1] + r * math.sin(angle)\n vertices.append((a, -axial, b) if axis == \"Y\" else (a, b, axial))\n for row in range(len(profile) if close else len(profile) - 1):\n following = (row + 1) % len(profile)\n for i in range(steps):\n n = (i + 1) % steps\n faces.append((row * steps + i, row * steps + n, following * steps + n, following * steps + i))\n obj = mesh(name, vertices, faces, mat)\n if mat == aluminum:\n layer = obj.data.uv_layers.new()\n for polygon in obj.data.polygons:\n for idx in polygon.loop_indices:\n row, column = divmod(obj.data.loops[idx].vertex_index, steps)\n if column == 0 and polygon.index % steps == steps - 1:\n column = steps\n layer.data[idx].uv = (column / steps * 5, profile[row][1] * 0.35)\n return obj\n\n\ndef turned_ring(name, inner, outer, back, front, mat, center=(0, 0), axis=\"Y\",\n chamfer=0.065, ridges=0, depth=0):\n c = min(chamfer, (front - back) / 2.2, (outer - inner) / 2.2)\n profile = [(inner, back + c), (inner + c, back), (outer - c, back),\n (outer, back + c), (outer, front - c), (outer - c, front),\n (inner + c, front), (inner, front - c)]\n return lathe(name, profile, mat, center, axis, steps=ridges * 8 if ridges else 144,\n ridges=ridges, depth=depth)\n\n\ndef disk(name, radius, back, front, mat, center=(0, 0), axis=\"Y\"):\n return turned_ring(name, 0.001, radius, back, front, mat, center, axis)\n\n\nfront_rotation = (math.pi / 2, 0, 0)\n\n\ndef label(name, content, loc, size, mat, rotation=front_rotation, align=\"LEFT\"):\n data = bpy.data.curves.new(name, \"FONT\")\n data.body = content\n data.size = size\n data.space_character = 1.05\n data.align_x = align\n data.align_y = \"CENTER\"\n data.extrude = 0.002\n data.resolution_u = 6\n obj = bpy.data.objects.new(name, data)\n bpy.context.collection.objects.link(obj)\n obj.location, obj.rotation_euler = loc, rotation\n bpy.ops.object.select_all(action=\"DESELECT\")\n obj.select_set(True)\n bpy.context.view_layer.objects.active = obj\n bpy.ops.object.convert(target=\"MESH\")\n return finish(bpy.context.object, name, mat)\n\n\n# Chassis, precision-milled caps, and recessed grip seams.\nbox(\"Cast body shell\", (0, 0, 4.30), (14.90, 4.08, 8.05), dark, 0.30)\nbox(\"Brushed top housing\", (0, 0, 7.44), (15.02, 4.24, 2.34), aluminum, 0.21)\nbox(\"Top cap joining seam\", (0, 0, 6.28), (14.91, 4.145, 0.065), rubber, 0.03)\nbox(\"Bottom mounting plate\", (0, 0, 0.52), (14.98, 4.21, 1.04), aluminum, 0.18)\nbox(\"Bottom cap joining seam\", (0, 0, 1.04), (14.87, 4.14, 0.065), rubber, 0.03)\nbox(\"Front leather wrap\", (0, -2.056, 3.66), (14.61, 0.20, 5.14), leather, 0.085)\nbox(\"Rear door\", (0, 2.075, 3.68), (14.34, 0.21, 5.12), edge, 0.095)\nbox(\"Rear door leather wrap\", (0, 2.196, 3.68), (14.08, 0.12, 4.89), leather, 0.055)\nfor sign, side_name in ((-1, \"Left\"), (1, \"Right\")):\n box(f\"{side_name} leather wrap\", (sign * 7.438, 0, 3.65), (0.17, 3.86, 5.10), leather, 0.077)\n box(f\"{side_name} strap lug plate\", (sign * 7.551, -0.6, 6.56), (0.13, 0.90, 0.78), steel, 0.06)\n lug = turned_ring(f\"{side_name} split strap eyelet\", 0.27, 0.45, 0.52, 0.72, steel,\n (sign * 7.68, 6.57), chamfer=0.075)\n lug.rotation_euler[2] = sign * 0.08\n lug.location.x = -sign * 0.05\n box(f\"{side_name} strap lug support\", (sign * 7.54, -0.48, 6.55), (0.36, 0.30, 0.54), edge, 0.07)\n\n# Finder windows with shaped bezels, black foam gaskets and coated inset optics.\ndef window(name, x0, z0, w, h, glass):\n box(f\"{name} steel frame\", (x0, -2.118, z0), (w, 0.16, h), steel, 0.07)\n box(f\"{name} light seal\", (x0, -2.204, z0), (w - 0.15, 0.10, h - 0.15), rubber, 0.045)\n box(f\"{name} inset glass\", (x0, -2.258, z0), (w - 0.30, 0.075, h - 0.30), glass, 0.035)\n\n\nwindow(\"Rangefinder\", -5.64, 7.43, 2.25, 1.43, finder_glass)\nwindow(\"Bright-line illuminator\", -1.85, 7.43, 1.37, 1.27, dark_glass)\nfor x0 in np.linspace(-2.28, -1.42, 13):\n box(\"Illuminator Fresnel flute\", (x0, -2.298, 7.43), (0.017, 0.013, 0.74), finder_glass, 0.005)\nwindow(\"Viewfinder\", 5.21, 7.37, 2.56, 1.61, finder_glass)\nbox(\"Viewfinder framed inner reflection\", (5.19, -2.301, 6.91), (1.60, 0.006, 0.026), edge, 0.003)\nbox(\"Rear eyepiece seal\", (-4.92, 2.12, 7.38), (2.18, 0.35, 1.52), rubber, 0.15)\nbox(\"Rear eyepiece glass\", (-4.92, 2.31, 7.38), (1.53, 0.095, 0.98), finder_glass, 0.06)\nlabel(\"R-35 front mark\", \"R–35\", (0.22, -2.121, 7.46), 0.64, ink)\nlabel(\"Front camera type\", \"R A N G E F I N D E R\", (0.27, -2.121, 6.93), 0.19, ink)\nlabel(\"Rear film marking\", \"135 / 24 × 36\", (4.16, 2.267, 2.03), 0.315, ivory, (-math.pi / 2, 0, math.pi))\n\n# Detachable 50 mm lens, scaled engraving, enamel index and optical stack.\nC = (-0.48, 3.76)\nturned_ring(\"Lens mount polished flange\", 2.89, 3.31, 2.10, 2.44, steel, C, chamfer=0.135)\nturned_ring(\"Lens mount black gasket\", 2.73, 3.09, 2.36, 2.61, rubber, C)\nturned_ring(\"Focus collar rear lip\", 2.60, 2.97, 2.54, 2.71, edge, C)\nturned_ring(\"Focus ring deep knurl\", 2.61, 2.95, 2.68, 3.73, dark, C, ridges=80, depth=0.092)\nturned_ring(\"Focus collar front lip\", 2.53, 3.02, 3.71, 3.89, edge, C)\nturned_ring(\"Distance scale collar\", 2.46, 2.87, 3.88, 4.22, dark, C)\nturned_ring(\"Bright aperture ring edge\", 2.44, 2.89, 4.20, 4.31, aluminum, C, chamfer=0.04)\nturned_ring(\"Aperture adjustment knurl\", 2.45, 2.83, 4.29, 4.73, dark, C, ridges=68, depth=0.077)\nturned_ring(\"Front trim brightwork\", 2.50, 2.93, 4.70, 4.85, steel, C, chamfer=0.045)\nturned_ring(\"Front retaining bezel\", 2.39, 2.92, 4.83, 5.08, dark, C, chamfer=0.05)\nturned_ring(\"Front bevel highlight\", 2.868, 2.927, 5.01, 5.031, edge, C, chamfer=0.01)\nturned_ring(\"Filter thread support\", 2.19, 2.45, 4.35, 5.04, dark, C)\nfor j in range(10):\n start = 4.50 + j * 0.047\n turned_ring(f\"Filter thread turn {j + 1:02d}\", 2.20, 2.34, start, start + 0.027, edge, C, chamfer=0.008)\nturned_ring(\"Optical retaining ring\", 2.04, 2.22, 4.55, 4.68, iris, C)\nturned_ring(\"Olive coating at lens edge\", 1.97, 2.08, 4.57, 4.65,\n material(\"Olive optical edge\", \"27342D\", 0.45, 0.19, 0.65), C, chamfer=0.025)\nglass_profile = [(0.001, 4.41), (2.025, 4.41), (2.025, 4.605)]\nfor r in np.linspace(1.99, 0.001, 45):\n glass_profile.append((r, 4.66 + 0.27 * (1 - (r / 2.0) ** 2)))\nlathe(\"Convex multicoated front lens element\", glass_profile, optic, C)\nrelease = disk(\"Lens release button\", 0.27, 2.15, 2.43, aluminum, (3.18, 4.76))\ndisk(\"Lens mount index\", 0.072, 2.42, 2.48, red, (2.33, 5.67))\nbox(\"Focus tab\", (1.59, -3.21, 1.49), (0.75, 0.63, 0.35), dark, 0.11).rotation_euler[1] = -0.38\n\n\ndef arc_text(content, radius, center_angle, char_spacing, size, lower=False):\n for i, glyph in enumerate(content):\n angle = center_angle + (i - (len(content) - 1) / 2) * char_spacing\n if glyph != \" \":\n x0 = C[0] + radius * math.sin(angle)\n z0 = C[1] + radius * math.cos(angle)\n label(\"Front lens engraving \" + glyph, glyph, (x0, -5.08, z0), size, ivory,\n (math.pi / 2, angle + (math.pi if lower else 0), 0), \"CENTER\")\n\n\narc_text(\"R–OPTICAL 1:2 f=50mm\", 2.65, -0.08, 0.059, 0.233)\narc_text(\"No. 350147 • Ø43\", 2.65, math.pi, -0.067, 0.20, lower=True)\nfor angle in np.linspace(-0.98, 1.06, 15):\n obj = box(\"Distance scale engraved graduation\",\n (C[0] + 2.866 * math.sin(angle), -4.035, C[1] + 2.866 * math.cos(angle)),\n (0.029, 0.16, 0.014), ivory, 0.004)\n obj.rotation_euler[1] = angle\nbox(\"Focus distance index\", (C[0], -3.815, C[1] + 3.021), (0.065, 0.13, 0.018), red, 0.004)\n\n# Top controls, cold shoe, chamfered winding lever, and engraved shutter dial.\ndef top_label(name, content, x0, y0, z0, size, mat=ink, angle=0):\n return label(name, content, (x0, y0, z0), size, mat, (0, 0, angle), \"CENTER\")\n\n\ndial_center = (3.30, 0.35)\nturned_ring(\"Shutter dial base\", 0.05, 1.17, 8.60, 8.80, dark, dial_center, \"Z\")\nturned_ring(\"Shutter dial diamond grip\", 0.08, 1.14, 8.78, 9.12, aluminum,\n dial_center, \"Z\", ridges=54, depth=0.04)\ndisk(\"Shutter dial face\", 1.043, 9.115, 9.17, dark, dial_center, \"Z\")\nfor i, value in enumerate((\"B\", \"30\", \"60\", \"125\", \"250\", \"500\", \"1000\")):\n angle = math.radians(-103 + i * 48)\n top_label(f\"Shutter speed {value}\", value, 3.30 + 0.77 * math.cos(angle),\n 0.35 + 0.77 * math.sin(angle), 9.171, 0.186, ivory, angle + math.pi / 2)\ndisk(\"Shutter speed reference dot\", 0.055, 8.605, 8.63, red, (3.32, -1.03), \"Z\")\ndisk(\"Soft shutter release collar\", 0.48, 9.11, 9.285, steel, dial_center, \"Z\")\nturned_ring(\"Threaded shutter release\", 0.09, 0.31, 9.27, 9.36, aluminum, dial_center, \"Z\")\ndisk(\"Shutter release socket\", 0.084, 9.285, 9.32, dark, dial_center, \"Z\")\n\nrewind = (-5.74, 0.35)\ndisk(\"Rewind collar\", 0.96, 8.60, 8.77, dark, rewind, \"Z\")\nturned_ring(\"Rewind handle knurl\", 0.06, 0.85, 8.75, 9.064, aluminum, rewind, \"Z\", ridges=46, depth=0.046)\nbox(\"Folded rewind crank recess\", (-5.75, 0.34, 9.064), (1.36, 0.42, 0.085), dark, 0.035)\nbox(\"Folded rewind crank\", (-5.79, 0.34, 9.125), (1.14, 0.25, 0.09), steel, 0.052)\ndisk(\"Rewind crank thumb button\", 0.20, 9.14, 9.26, aluminum, (-5.33, 0.34), \"Z\")\n\ndisk(\"Film advance pivot collar\", 0.72, 8.60, 8.80, dark, (5.77, 0.43), \"Z\")\ndisk(\"Film advance pivot\", 0.60, 8.77, 8.94, aluminum, (5.77, 0.43), \"Z\")\nadvance = box(\"Film advance lever\", (6.25, -0.15, 8.96), (1.81, 0.42, 0.17), steel, 0.082)\nadvance.rotation_euler.z = -0.73\ntip = box(\"Advance lever molded tip\", (6.88, -0.72, 8.96), (0.61, 0.52, 0.28), dark, 0.13)\ntip.rotation_euler.z = -0.73\ndisk(\"Frame counter surround\", 0.39, 8.602, 8.66, steel, (5.76, 1.37), \"Z\")\ndisk(\"Frame counter acrylic cover\", 0.29, 8.65, 8.69, finder_glass, (5.76, 1.37), \"Z\")\ntop_label(\"Frame counter number\", \"12\", 5.76, 1.37, 8.694, 0.21, ivory)\nbox(\"Accessory shoe mount\", (-0.50, 0.58, 8.73), (1.98, 1.65, 0.30), dark, 0.079)\nbox(\"Accessory shoe runner left\", (-1.41, 0.58, 8.94), (0.27, 1.62, 0.20), steel, 0.035)\nbox(\"Accessory shoe runner right\", (0.41, 0.58, 8.94), (0.27, 1.62, 0.20), steel, 0.035)\nbox(\"Accessory shoe runner stop\", (-0.50, 1.32, 8.91), (1.75, 0.21, 0.16), steel, 0.035)\ndisk(\"Flash contact\", 0.16, 8.875, 8.925, aluminum, (-0.50, 0.61), \"Z\")\ntop_label(\"Top cover machine engraving\", \"MODEL R–35\", -0.52, -1.45, 8.612, 0.28)\ntop_label(\"Serial engraving\", \"35 0147\", -3.15, 1.42, 8.612, 0.193)\n\nfor i, (x0, y0) in enumerate(((-6.08, 0.80), (6.10, 0.82), (-4.95, -0.63), (4.93, -0.63))):\n disk(f\"Base plate screw {i+1}\", 0.18, -0.035, 0.03, steel, (x0, y0), \"Z\")\n slot = box(f\"Base plate screw slot {i+1}\", (x0, y0, -0.036), (0.246, 0.036, 0.007), ink, 0.002)\n slot.rotation_euler.z = i * 0.78\nturned_ring(\"Tripod socket threads\", 0.28, 0.43, -0.055, 0.07, steel, (0.21, 0.43), \"Z\")\ndisk(\"Tripod socket well\", 0.265, -0.007, 0.025, rubber, (0.21, 0.43), \"Z\")\n\n# Export only the camera, with meter-scale geometry and a bottom-center origin.\nroot = bpy.data.objects.new(\"R-35 Rangefinder\", None)\nbpy.context.collection.objects.link(root)\nroot[\"asset_id\"] = \"misc-r35-rangefinder-camera-v1\"\nroot[\"category\"] = \"misc objects\"\nroot[\"lens\"] = \"50 mm f/2\"\nroot[\"real_world_scale\"] = \"meters\"\nfor part in PARTS:\n part.parent = root\nroot.scale = (0.01,) * 3\nroot.location.z = 0.00055\nbpy.context.view_layer.update()\nif not args.draft:\n bpy.ops.object.select_all(action=\"DESELECT\")\n root.select_set(True)\n for part in PARTS:\n part.select_set(True)\n bpy.ops.export_scene.gltf(filepath=str(OUT / \"r35-rangefinder.glb\"),\n use_selection=True, export_format=\"GLB\", export_apply=True,\n export_extras=True, export_yup=True, export_image_format=\"AUTO\")\nroot.scale = (1,) * 3\nroot.location.z = 0.055\n\n\ndef aim(obj, at):\n obj.rotation_euler = (Vector(at) - obj.location).to_track_quat(\"-Z\", \"Y\").to_euler()\n\n\ndef area(name, position, target, power, color, width, height):\n data = bpy.data.lights.new(name, \"AREA\")\n data.energy = power\n data.shape = \"RECTANGLE\"\n data.size, data.size_y = width, height\n data.color = color\n light = bpy.data.objects.new(name, data)\n bpy.context.collection.objects.link(light)\n light.location = position\n aim(light, target)\n\n\nscene = bpy.context.scene\nfloor = material(\"Warm gray paper sweep\", \"706A61\", 0, 0.83)\nbox(\"Studio sweep\", (0, 0, -0.265), (1500, 1500, 0.5), floor, 0, track=False)\narea(\"Large warm key\", (-11, -12, 20), (0, 0, 3.1), 5100, (1, 0.91, 0.8), 11, 7)\narea(\"Soft cool rim\", (4, 7, 16), (0, 0, 4.0), 6400, (0.79, 0.88, 1), 12, 5.5)\narea(\"Silver bounce\", (14, -5, 9), (2, 0, 3.8), 2400, (0.91, 0.95, 1), 5, 13)\narea(\"Lower frontal fill\", (-4, -16, 5), (0, 0, 3.3), 500, (1, 0.91, 0.80), 10, 4)\narea(\"Strip reflected in front element\", (-2, -9, 12), (-0.5, -3, 3.70),\n 550, (0.69, 0.90, 0.86), 7, 0.65)\nscene.world.use_nodes = True\nscene.world.node_tree.nodes[\"Background\"].inputs[\"Color\"].default_value = (0.14, 0.16, 0.19, 1)\nscene.world.node_tree.nodes[\"Background\"].inputs[\"Strength\"].default_value = 0.32\ncamera = bpy.data.objects.new(\"Product camera\", bpy.data.cameras.new(\"Product camera\"))\nbpy.context.collection.objects.link(camera)\ncamera.location = (18, -30.5, 16.1)\ncamera.data.lens = 71\naim(camera, (0, -0.30, 4.3))\nscene.camera = camera\nscene.render.engine = \"CYCLES\"\nscene.cycles.samples = 16 if args.draft else 80\nscene.cycles.use_denoising = True\nscene.cycles.adaptive_threshold = 0.075 if args.draft else 0.025\nscene.cycles.max_bounces = 6\nscene.view_settings.view_transform = \"AgX\"\nscene.view_settings.look = \"AgX - Medium High Contrast\"\nscene.view_settings.exposure = 0.35\nscene.render.resolution_x = 1500\nscene.render.resolution_y = 1200\nscene.render.resolution_percentage = 44 if args.draft else 100\nscene.render.image_settings.file_format = \"PNG\"\nscene.render.image_settings.color_mode = \"RGB\"\nscene.render.filepath = str(OUT / (\"draft.png\" if args.draft else \"r35-rangefinder.png\"))\nbpy.ops.render.render(write_still=True)\n```\n\nrun it: `blender -b --python build_rangefinder.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[r35-rangefinder.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/r35-rangefinder-camera/r35-rangefinder.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/common-sunflower.jpg"}}, {"type": "text", "text": "create an image of a common sunflower"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA single sunflower in bloom standing upright, front view. Large dark brown disc packed with tiny florets, ringed by golden-yellow petals, with green bracts peeking out behind the head. A long, slightly curved green stalk with five serrated, veined leaves on short stalks, alternating up the stem. Cut flat at the bottom.\n\nSCALE\nAbout 42 cm wide, 75 cm tall, 17 cm deep. Build in meters, +Y up, +Z forward (flower faces +Z), origin at the center of the cut stem base.\n\nPARTS\n1. Receptacle: the rounded floret bed of the head. Build: a domed disk.\n2. Ray petals: 60 cupped yellow petals around the disc. Build: each petal shaped and curled individually so no two match.\n3. Bracts: layered green involucral bracts behind the head. Build: small pointed blades arranged radially behind the receptacle.\n4. Disc florets: 1,220 tiny five-lobed florets in a spiral. Build: phyllotactic point pattern with one small floret per point, dark in the center to ocher at the rim.\n5. Stem and petioles: the curved stalk plus five leaf stalks. Build: tubes swept along curves, petioles branching at alternating heights.\n6. Leaves: five serrated leaves with raised midribs and secondary veins, plus fine bristles on the stalk. Build: sculpted blades with toothed edges, vein ribs as raised geometry, short hair strands.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the cut base.\n2. Texture maps: run make_maps.py to generate base color, roughness and normal maps for the stem, leaves and petals.\n3. Build order: receptacle, ray petals, bracts, disc florets, stem and petioles, leaves with veins and bristles.\n4. Assemble: the head sits on the stem tip facing +Z, petioles attach along the stem, leaf blades sit on the petiole ends.\n5. Materials: fibrous green stem, olive-green leaves with yellow-green veins, golden ray florets, dark brown disc floor, chocolate to amber to bronze to ocher floret rings, golden pollen, blond trichomes.\n6. Export: one GLB with all nine textures embedded.\n\nCHECK\n297,552 triangles. Against the image: disc about half the width of the full head, petals overlap the disc edge, five leaves alternating up the stem.\n\n\n```python\n# make_maps.py\n\"\"\"Original PBR textures for the common sunflower study.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import zoom\n\nOUT=Path(__file__).resolve().parent/\"maps\"\nOUT.mkdir(exist_ok=True)\nW,H=1536,1024\nRNG=np.random.default_rng(11057)\nv,u=np.mgrid[0:1:complex(H),0:1:complex(W)]\nv=1-v\n\n\ndef noise(y,x):\n return zoom(RNG.uniform(-1,1,(y,x)),((H+.01)/y,(W+.01)/x),order=3)[:H,:W]\n\n\ndef save(name,d):\n Image.fromarray(np.clip(d*255+.5,0,255).astype(\"uint8\")).save(OUT/(name+\".png\"))\n\n\ndef normals(name,h,gain):\n dy,dx=np.gradient(h)\n p=np.dstack((-dx*gain,dy*gain,np.ones_like(h)))\n save(name,.5+.5*p/np.linalg.norm(p,axis=2,keepdims=True))\n\n\ndef petal():\n n1,n2,n3=noise(24,73),noise(106,313),noise(341,607)\n flow=(u-.5)*(1+.18*v)+.006*np.sin(11*v)+.0024*n1\n fine=np.sin(flow*2*np.pi*127)\n stripes=np.sin(flow*2*np.pi*34+n1*.57)\n groove=np.maximum(0,stripes)**6\n gold=np.clip(.92+.035*n2-.085*groove+.030*fine,0,1)\n orange=np.exp(-v*5.7)\n edge=np.abs(2*u-1)**5\n pale=.09*np.clip((v-.64)/.36,0,1)\n body=np.stack((.986-.10*orange-.017*n3,\n (.817-.340*orange+.077*edge+.035*n1+pale)*gold,\n (.012+.020*edge+.006*n2+.04*pale)*gold),axis=-1)\n save(\"Petal_Base\",body)\n save(\"Petal_Rough\",.449+.046*n1+.059*groove+.024*n3)\n normals(\"Petal_Normal\",.37*groove+.20*fine+.24*n2,1.10)\n\n\ndef foliage():\n n1,n2,n3=noise(19,30),noise(71,93),noise(399,540)\n uu=np.abs(u-.5)*2\n main=np.exp(-(uu/.016)**2)\n branch=np.zeros_like(u)\n network=np.zeros_like(u)\n for root in (.17,.29,.41,.53,.65,.76,.85):\n c=root+.15*uu+.053*uu**2\n branch=np.maximum(branch,np.exp(-((v-c)/(.0045-.0022*uu))**2)*np.clip((1.02-uu)*2.4,0,1))\n for j in (.17,.37,.57,.74):\n distance=v-(root+.150*j+.053*j*j+(.29*(uu-j)))\n network=np.maximum(network,np.exp(-(distance/.002)**2)*(uu>=j)*(uu.76+RNG.uniform(-.07,.08)\n tint=RNG.choices([0,1,2],[6,3,1])[0]\n if open_flower:\n tint=RNG.choices([2,3,4],[2,5,3])[0]\n rotation=RNG.random()*TAU\n rows=[]\n for k,(z,scale) in enumerate(((0,.64),(.46,1.),(.82,.91),(1.,.84),(.79,.39))):\n row=[]\n for j in range(10):\n t=TAU*j/10+rotation\n tooth=(1+.18*(1 if j%2==0 else -1)) if k==3 else 1\n height=z+(.16 if k==3 and j%2==0 else 0)\n row.append(origin+axis*(h*height)+px*(math.cos(t)*dr*scale*tooth+bend*z)+\n py*(math.sin(t)*dr*scale*tooth))\n rows.append(row)\n from_index=len(surface.faces)\n rings(surface,rows,tint)\n surface.slots[-1]=0\n if open_flower and i%3!=1:\n pts=[origin+axis*h*t+px*(bend*t+.00048*t*t) for t in (.76,1.04,1.28,1.42)]\n surface.tube(pts,[.00022,.00024,.00019,.00013],3,n=6)\n surface.build(\"Phyllotactic disc with 1,220 individual five-lobed florets\",mats)\n\n\ndef stem_at(t):\n # A gently leaning stem, bent just below the heavy flower head.\n return Vector((.017*math.sin(t*4.62)+.031*t**3,.033*t-.055*t**7,.613*t))\n\n\ndef foliage(stem_mat,leaf_mat,vein_mat,hair):\n stalks,blades,veins,hairlines=Surface(),Surface(),Surface(),Surface()\n p=[stem_at(i/115) for i in range(116)]\n p.append(C-N*.017-V*.008)\n stalks.tube(p,[.0082-.0026*(i/(len(p)-1)) for i in range(len(p))],n=28)\n for i in range(132):\n t=.07+.88*(i+.2)/132\n p=stem_at(t)\n angle=i*2.399963\n outward=Vector((math.cos(angle),math.sin(angle),.09))\n offset=outward*(.0082-.0026*t)\n hairlines.tube([p+offset,p+offset+outward*.00085+Vector((0,0,.00072))],\n [.00014,.000054],n=5)\n leaves=[\n (.26,(-.94,-.21,-.23),.189,.069,.037,.014),\n (.40,( .96,-.16,-.24),.171,.063,.037,.018),\n (.54,(-.94, .16, .20),.140,.053,.032,.012),\n (.69,( .92, .02, .32),.126,.047,.026,.013),\n (.79,(-.86, .34, .41),.101,.033,.020,.013),\n ]\n for index,(level,d,length,width,petiole,roll) in enumerate(leaves):\n A=Vector(d).normalized()\n side=Vector((0,-1,0)).cross(A).normalized()\n to_camera=A.cross(side).normalized()\n # Rotate around each leaf's own axis so profiles vary.\n angle=roll*25*(-1 if index%2 else 1)\n S=side*math.cos(angle)+to_camera*math.sin(angle)\n B=A.cross(S).normalized()\n base=stem_at(level)\n root=base+A*petiole+B*.008\n stalks.tube([base.lerp(root,i/16)+B*.0055*math.sin(math.pi*i/16) for i in range(17)],\n [.0032-.0015*i/16 for i in range(17)],n=14)\n def shape(u,t):\n q=2*u-1\n w=(.012+.988*math.sin(math.pi*(.034+.963*t)**.70)**.84)*width\n teeth=(.5+.5*math.sin(TAU*(17*t+ .31*(q>0))))**6\n w*=1+.108*teeth*abs(q)**5-.024*math.sin(28*t+index)*q\n longitudinal=t*length-.018*abs(q)**2*math.sin(math.pi*t)**.74*(1-t)**2\n lateral=q*w+.010*math.sin(math.pi*t)*math.sin(index+2.1)*t\n warp=.016*math.sin(math.pi*t)-(.019+roll)*t*t\n warp+=.008*q*q*math.sin(math.pi*t)+.006*q*math.sin(3.8*t+index)*t\n warp+=.0024*math.sin(23*t+4*q+index)*abs(q)**2.5\n return root+A*longitudinal+S*lateral+B*warp\n blades.patch(shape,110,46)\n pts=[shape(.5,i/57)+B*.00018 for i in range(58)]\n veins.tube(pts,[.00138*(1-i/59)**1.16+.000058 for i in range(58)],n=8)\n for order,t0 in enumerate((.17,.29,.41,.53,.65,.76,.85)):\n for s in (-1,1):\n pts=[]\n for j in range(25):\n t=j/24\n u=.5+s*.47*t\n v=t0+.15*t+.053*t*t\n if v>.994:\n break\n pts.append(shape(u,v)+B*.00016)\n if len(pts)>2:\n veins.tube(pts,[.00051*(1-j/len(pts))**1.3+.000033 for j in range(len(pts))],n=7)\n stalks.build(\"Curved sunflower stem and five petioles\",[stem_mat])\n blades.build(\"Five serrated, sculpted sunflower leaves\",[leaf_mat])\n veins.build(\"Raised midribs and branching secondary leaf veins\",[vein_mat])\n hairlines.build(\"Fine bristles on the stalk\",[hair])\n\n\ndef make_plant():\n gold=material(\"Golden yellow ray florets with longitudinal silk fibers\",(.69,.37,.013),.43,\"Petal\",.40)\n gold.node_tree.nodes[\"Principled BSDF\"].inputs[\"Specular IOR Level\"].default_value=.25\n foliage_mat=material(\"Olive green veined sunflower leaves\",(.07,.15,.032),.52,\"Leaf\",.69)\n foliage_mat.node_tree.nodes[\"Principled BSDF\"].inputs[\"Specular IOR Level\"].default_value=.36\n stem_mat=material(\"Fibrous sunflower stem, petioles, and involucre\",(.09,.15,.029),.56,\"Stem\",.59)\n vein=material(\"Yellow-green raised leaf veins\",(.134,.215,.047),.61)\n stem_hairs=material(\"Fine blond plant trichomes\",(.28,.24,.104),.64)\n bed=material(\"Dark brown disc floor\",(.056,.023,.007),.74)\n closed=material(\"Dark chocolate tips of immature disc florets\",(.071,.027,.008),.54)\n closed2=material(\"Warm oxidized amber-brown disc florets\",(.136,.059,.014),.52)\n amber=material(\"Bronze-tipped transition florets\",(.205,.089,.019),.55)\n pollen=material(\"Golden pollen and flower anthers\",(.61,.291,.016),.54)\n copper=material(\"Ocher outer disc florets\",(.344,.152,.017),.58)\n foliage(stem_mat,foliage_mat,vein,stem_hairs)\n disk_base([bed,stem_mat])\n bracts(stem_mat)\n petals([gold])\n florets([closed,closed2,amber,pollen,copper])\n\n\ndef point_at(ob, xyz):\n ob.rotation_euler=(Vector(xyz)-ob.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef area(name, location, target, energy, color, width, height):\n light=bpy.data.lights.new(name,\"AREA\")\n light.energy=energy\n light.color=color\n light.shape=\"RECTANGLE\"\n light.size=width\n light.size_y=height\n ob=bpy.data.objects.new(name,light)\n bpy.context.collection.objects.link(ob)\n ob.location=location\n point_at(ob,target)\n\n\ndef studio(output, mode):\n scene=bpy.context.scene\n world=scene.world=bpy.data.worlds.new(\"Neutral studio ambient\")\n world.use_nodes=True\n bg=world.node_tree.nodes[\"Background\"]\n bg.inputs[\"Color\"].default_value=(.55,.62,.70,1)\n bg.inputs[\"Strength\"].default_value=.24\n # A seamless photographic sweep, excluded from the exported geometry.\n sweep=[(-5,-.0008),(.33,-.0008)]\n for i in range(1,44):\n theta=math.pi*.5*i/43\n sweep.append((.33+.85*math.sin(theta),.85*(1-math.cos(theta))-.0008))\n sweep.append((1.18,5))\n mesh=bpy.data.meshes.new(\"Continuous olive-gray studio sweep\")\n vertices=[(x,y,z) for y,z in sweep for x in (-6,6)]\n faces=[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(sweep)-1)]\n mesh.from_pydata(vertices,[],faces)\n mesh.update()\n backdrop=bpy.data.objects.new(mesh.name,mesh)\n bpy.context.collection.objects.link(backdrop)\n mesh.materials.append(material(\"Studio backdrop\",(.070,.081,.063),.87))\n for face in mesh.polygons:\n face.use_smooth=True\n area(\"Large warm diagonal window\",(-.56,-.72,1.12),(0,0,.46),34,(1,.975,.908),.57,.64)\n area(\"Backlit edge of petals\",(.32,.31,.90),(0,0,.57),21,(.93,.97,1),.32,.59)\n area(\"Front white bounce\",(.53,-.48,.49),(0,0,.35),9,(.95,.97,1),.31,.54)\n camdata=bpy.data.cameras.new(\"Botanical portrait\")\n camera=bpy.data.objects.new(\"Botanical portrait\",camdata)\n bpy.context.collection.objects.link(camera)\n camera.location=(.176,-1.34,.64)\n point_at(camera,(0,0,.383))\n camdata.lens=58\n scene.camera=camera\n scene.render.engine=\"CYCLES\"\n scene.cycles.samples=192 if mode==\"final\" else 24\n scene.cycles.adaptive_threshold=.015 if mode==\"final\" else .065\n scene.cycles.use_denoising=mode==\"final\"\n scene.cycles.max_bounces=7\n scene.render.resolution_x=1640\n scene.render.resolution_y=2000\n scene.render.resolution_percentage=100 if mode==\"final\" else 42\n scene.view_settings.view_transform=\"Khronos PBR Neutral\"\n scene.view_settings.look=\"None\"\n scene.view_settings.exposure=-.56\n scene.render.image_settings.file_format=\"PNG\"\n scene.render.image_settings.color_mode=\"RGB\"\n scene.render.filepath=str(output/(STEM+\".png\"))\n bpy.ops.render.render(write_still=True)\n\n\ndef main():\n parser=argparse.ArgumentParser()\n parser.add_argument(\"--out\",type=Path,required=True)\n parser.add_argument(\"--mode\",choices=(\"draft\",\"final\"),required=True)\n argv=sys.argv[sys.argv.index(\"--\")+1:]\n args=parser.parse_args(argv)\n output=args.out.resolve()\n output.mkdir(exist_ok=True,parents=True)\n bpy.ops.wm.read_factory_settings(use_empty=True)\n bpy.context.scene.unit_settings.system=\"METRIC\"\n make_plant()\n if args.mode==\"final\":\n bpy.ops.file.pack_all()\n bpy.ops.wm.save_as_mainfile(filepath=str(output/\"sunflower.blend\"),compress=True)\n target=output/(STEM+\".glb\")\n bpy.ops.export_scene.gltf(filepath=str(target),export_format=\"GLB\",\n export_apply=True,export_cameras=False,export_lights=False)\n bpy.ops.wm.read_factory_settings(use_empty=True)\n bpy.ops.import_scene.gltf(filepath=str(target))\n obs=list(bpy.context.scene.objects)\n assert len(obs)==8 and all(ob.type==\"MESH\" for ob in obs)\n bounds=[ob.matrix_world@Vector(v) for ob in obs for v in ob.bound_box]\n measures=[max(p[i] for p in bounds)-min(p[i] for p in bounds) for i in range(3)]\n tri=0\n verts=0\n for ob in obs:\n ob.data.calc_loop_triangles()\n tri+=len(ob.data.loop_triangles)\n verts+=len(ob.data.vertices)\n maps={img.name:list(img.size) for img in bpy.data.images if img.source==\"FILE\" and img.size[0]}\n assert len(maps)==9 and all(dims==[1536,1024] for dims in maps.values())\n stats={\"blender_version\":bpy.app.version_string,\"objects\":len(obs),\"triangles\":tri,\"vertices\":verts,\"image_sizes\":maps,\n \"dimensions_m\":dict(zip((\"width\",\"depth\",\"height\"),measures))}\n (output/\"reimport.json\").write_text(json.dumps(stats,indent=2)+\"\\n\")\n studio(output,args.mode)\n\n\nif __name__==\"__main__\":\n main()\n```\n\nrun it: `python3 make_maps.py` then `blender -b --python sunflower.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[common-sunflower.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/common-sunflower/common-sunflower.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/nova-foam-prop-loop.jpg"}}, {"type": "text", "text": "create an image of a nova foam prop loop"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA stylized adult character on a round stage, seen from behind at a three-quarter angle. Blue technical jacket with a padded back yoke and \"NOVA\" patch, indigo trousers with cargo pockets and lime accents, dark gloves and high-top boots, dark hair in a short tied-back knot. A coral, lilac and lime foam prop is locked in a catch at the right hip. It's one frame of an animation loop.\n\nSCALE\nLife-size adult figure. Build in meters, +Y up, character faces -Z, so this view of the rear catch is the +Z side.\n\nPARTS\n1. Trousers: tailored hips, wide violet waistband, back pockets, cargo pockets, shin seams and reinforcement panels. Build: lofted leg shells with detail passes for thighs and shins.\n2. Costume catch: soft catch plate with a bright flex jaw on the back of the waist. Build: rounded boxes.\n3. Jacket: padded torso, back yoke with a stitch line, team patch with \"N O V A\" lettering, zipper, ribbed collar, sleeves with piping. Build: lofted shells over the body, pipes for piping, text for the lettering.\n4. Head and face: amber eyes, brows, small nose, mouth, ears with a pale green stud, warm skin. Build: ellipsoids and lofts.\n5. Hair: dark fitted crown, side-swept lock, short ponytail knot. Build: ellipsoids and lofts.\n6. Hands, boots and foam prop: graphite gloves and high-tops with heavy rubber soles, and a rounded solid foam prop with a sealed oval nose, lilac insert, lime bumper, plum grip and an engraved label. Build: rounded boxes, ellipsoids and lofts.\n\nPLAN\n1. Setup: clear the scene, meters, +Y up. Create an empty for each control (pelvis, chest, head, arm and leg links).\n2. Texture maps: none. Every surface is a procedural material.\n3. Build order: trousers, costume catch, jacket, head and face, hair, hands and boots, foam prop.\n4. Assemble: parent each piece to its control so it follows the rig, then keyframe 41 channels over a 10-second, 240-frame loop at 24 fps: draw the prop, display it, seat it back in the catch.\n5. Materials: indigo trousers, ink-blue jacket, lilac piping, chartreuse trim, graphite gloves and boots, mauve rubber soles, warm sienna skin, plum-brown hair, coral EVA foam, lilac insert, lime bumper.\n6. Export: actor and prop only, no stage, then pack the animated GLB with pack_glb.py.\n\nCHECK\nAgainst the image: stylized adult proportions, prop at the right hip, lime accents on the shoulders and boots, one continuous loop with no pop at the seam.\n\n\n```python\n# stunt_loop.py\n\"\"\"Ten-second original Blender stunt-prop loop. Blender 4.3+.\"\"\"\nfrom pathlib import Path\nimport argparse\nimport math\nimport sys\n\nimport bpy\nfrom mathutils import Matrix, Quaternion, Vector\n\nHERE=Path(__file__).resolve().parent\nFPS=24\nLAST=240\nTWO_PI=math.tau\n\np=argparse.ArgumentParser()\np.add_argument(\"--mode\",choices=(\"setup\",\"preview\"),required=True)\np.add_argument(\"--out\",type=Path,required=True)\nargs=p.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\ndest=args.out.resolve()\ndest.mkdir(exist_ok=True,parents=True)\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\n\n\ndef mat(name,rgba,rough=.45,metal=0,power=0):\n m=bpy.data.materials.new(name)\n color=(*rgba,1)\n m.diffuse_color=color\n m.use_nodes=True\n bsdf=m.node_tree.nodes.get(\"Principled BSDF\")\n bsdf.inputs[\"Base Color\"].default_value=color\n bsdf.inputs[\"Metallic\"].default_value=metal\n bsdf.inputs[\"Roughness\"].default_value=rough\n if power:\n bsdf.inputs[\"Emission Color\"].default_value=color\n bsdf.inputs[\"Emission Strength\"].default_value=power\n return m\n\n\nnavy=mat(\"Indigo stretch-woven utility trousers\",(.037,.043,.092),.67)\ndark=mat(\"Deep violet fabric in seams and cuffs\",(.018,.019,.040),.60)\nsuit=mat(\"Ink blue technical cotton jacket\",(.064,.082,.183),.63)\nlight=mat(\"Icy pale lilac piping\",(.345,.403,.624),.54)\nblue=mat(\"Dusty ultramarine stitched panels\",(.128,.169,.352),.61)\nmint=mat(\"Chartreuse costume trim\",(.44,.65,.096),.45)\nleather=mat(\"Graphite gloves and high-top boots\",(.028,.027,.043),.48)\nrubber=mat(\"Heavy mauve vulcanized rubber\",(.122,.087,.153),.7)\nskin=mat(\"Warm sienna skin\",(.417,.201,.128),.54)\nskin2=mat(\"Warm skin near folds\",(.33,.132,.105),.55)\nhair=mat(\"Deep plum-brown hair\",(.039,.019,.033),.48)\nhairlight=mat(\"Chestnut sheen on sculpted locks\",(.084,.039,.056),.53)\neye_white=mat(\"Warm whites of the eyes\",(.73,.63,.55),.37)\neye_color=mat(\"Deep amber iris\",(.17,.079,.032),.31)\neye_black=mat(\"Eyelashes and pupils\",(.016,.009,.014),.48)\nlip=mat(\"Warm rose lips\",(.294,.075,.071),.53)\nprop_shell=mat(\"Coral EVA foam stunt prop\",(.663,.033,.169),.52)\nprop_white=mat(\"Soft pale lilac foam insert\",(.66,.50,.76),.58)\nprop_purple=mat(\"Plum rubber on the stunt prop\",(.164,.044,.24),.58)\nprop_mint=mat(\"Bright lime foam bumper\",(.487,.69,.068),.55)\nsignal=mat(\"Visible costume catch inlay\",(.19,.61,.30),.44,0,.45)\nbadge=mat(\"Pale gray engraved stunt label\",(.83,.76,.77),.59)\n\n\ndef empty(name,parent=None):\n o=bpy.data.objects.new(name,None)\n bpy.context.collection.objects.link(o)\n o.parent=parent\n o.empty_display_size=.036\n return o\n\n\ndef mesh(name,vertices,faces,material,parent=None,smooth=True):\n d=bpy.data.meshes.new(name)\n d.from_pydata(vertices,[],faces)\n d.update()\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.parent=parent\n d.materials.append(material)\n for f in d.polygons:\n f.use_smooth=smooth\n return o\n\n\ndef box(name,loc,size,material,parent=None,radius=.007,rotation=None):\n bpy.ops.mesh.primitive_cube_add(size=1,location=loc)\n o=bpy.context.object\n o.parent=parent\n o.name=name\n o.dimensions=size\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n if rotation:\n o.rotation_euler=rotation\n o.data.materials.append(material)\n if radius:\n bevel=o.modifiers.new(\"Rounded edges\",\"BEVEL\")\n bevel.width=min(radius,min(size)*.45)\n bevel.segments=4\n weighted=o.modifiers.new(\"Face normals\",\"WEIGHTED_NORMAL\")\n weighted.keep_sharp=True\n return o\n\n\ndef ellipsoid(name,loc,scales,material,parent=None,rot=None):\n bpy.ops.mesh.primitive_uv_sphere_add(segments=26,ring_count=18,location=loc)\n o=bpy.context.object\n o.parent=parent\n o.name=name\n o.scale=scales\n if rot:\n o.rotation_euler=rot\n o.data.materials.append(material)\n for f in o.data.polygons:\n f.use_smooth=True\n return o\n\n\ndef text(name,body,loc,size,material,parent=None,rotation=(math.pi/2,0,0)):\n d=bpy.data.curves.new(name,\"FONT\")\n d.body=body\n d.align_x=d.align_y=\"CENTER\"\n d.size=size\n d.extrude=.00028\n d.resolution_u=4\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.parent=parent\n o.location=loc\n o.rotation_euler=rotation\n o.data.materials.append(material)\n return o\n\n\ndef loft(name,profile,material,parent=None,power=.77,res=40,softness=0):\n vertices=[]\n for i,row in enumerate(profile):\n z,wx,wy,cy=row\n for j in range(res):\n a=TWO_PI*j/res\n x,y=math.cos(a),math.sin(a)\n wrinkle=1+softness*(.43*math.sin(i*1.71+2*a)+.57*math.sin(i*.91+4*a))\n xx=wx*math.copysign(abs(x)**power,x)*wrinkle\n yy=cy+wy*math.copysign(abs(y)**power,y)*wrinkle\n vertices.append((xx,yy,z))\n faces=[]\n for i in range(len(profile)-1):\n for j in range(res):\n k=(j+1)%res\n faces.append((i*res+j,i*res+k,(i+1)*res+k,(i+1)*res+j))\n faces.append(tuple(range(res-1,-1,-1)))\n faces.append(tuple((len(profile)-1)*res+j for j in range(res)))\n ob=mesh(name,vertices,faces,material,parent)\n for f in list(ob.data.polygons)[-2:]:\n f.use_smooth=False\n return ob\n\n\ndef pipe(name,coordinates,diameter,material,parent=None,cyclic=False):\n d=bpy.data.curves.new(name,\"CURVE\")\n d.dimensions=\"3D\"\n d.resolution_u=2\n d.bevel_depth=diameter\n d.bevel_resolution=3\n d.use_fill_caps=True\n s=d.splines.new(\"POLY\")\n s.use_cyclic_u=cyclic\n s.points.add(len(coordinates)-1)\n for p,c in zip(s.points,coordinates):\n p.co=(*c,1)\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.parent=parent\n o.data.materials.append(material)\n return o\n\n\ndef pos(x,y,z):\n return Vector((x,y,z))\n\n\nactor=empty(\"NOVA / original adult stunt performer\")\npelvis=empty(\"Pelvis control\",actor)\nchest=empty(\"Chest control\",actor)\nhead=empty(\"Head control\",chest)\n\nhip=[(-.119,.104,.082,-.020),(-.092,.146,.104,-.018),(-.056,.177,.116,-.012),\n (-.012,.183,.121,-.010),(.041,.172,.111,-.006),(.089,.152,.085,.003),(.110,.144,.079,.003)]\nloft(\"Tailored utility trousers at the hips\",hip,navy,pelvis,softness=.014)\n# The seat is cloth-covered. The exterior costume catch keeps the foam prop on screen.\npipe(\"Rear center trouser seam\",[(0,-.134,-.097),(0,-.139,-.050),(0,-.140,.003),(0,-.124,.065)],.0022,dark,pelvis)\nfor side in (-1,1):\n x=side*.099\n box(\"Reinforced back pocket\",(x,-.105,.014),(.084,.014,.078),blue,pelvis,.013,(0,side*.17,0))\n pipe(\"Back pocket contrast piping\",[(x-.035,-.115,.039),(x+.034,-.115,.039)],.0018,light,pelvis)\nloft(\"Wide violet waistband\",[(.062,.165,.104,-.002),(.068,.169,.104,-.002),(.094,.155,.087,.002),\n (.100,.151,.085,.002)],dark,pelvis)\nfor x in (-.106,-.053,.055,.106):\n box(\"Utility waist loop\",(x,-.093,.084),(.016,.018,.036),blue,pelvis,.004)\nbox(\"Lime back-waist seam accent\",(0,-.111,.083),(.062,.011,.009),mint,pelvis,.003)\n# Exterior, oversized costume pad designed for the foam prop's locking animation.\nbox(\"Soft costume catch plate\",(0,-.142,-.022),(.132,.020,.061),dark,pelvis,.012)\nfor side in (-1,1):\n box(\"Bright flex jaw of costume catch\",(side*.039,-.160,-.021),(.029,.018,.041),mint,pelvis,.007)\n\nloft(\"Gently sculpted jacket torso\",[(-.059,.148,.079,0),(-.028,.145,.082,0),(.022,.152,.087,0),\n (.081,.174,.097,.011),(.139,.195,.106,.015),(.183,.206,.088,.008),(.216,.172,.067,-.002),\n (.240,.087,.052,.001),(.244,.062,.049,.003)],suit,chest,softness=.014)\nloft(\"Jacket hem and stretch binding\",[(-.061,.149,.081,0),(-.052,.150,.082,0),(-.031,.149,.084,0),\n (-.027,.148,.084,0)],dark,chest)\nbox(\"Technical padded upper back yoke\",(0,-.074,.153),(.303,.042,.081),blue,chest,.014)\npipe(\"Angled yoke stitch across shoulders\",[(x,-.094,.185-.055*abs(x)) for x in (-.144,-.105,0,.105,.144)],.0020,light,chest)\nbox(\"Back yoke team patch\",(0,-.096,.145),(.100,.013,.037),dark,chest,.006)\ntext(\"Back yoke lettering\",\"N O V A\",(0,-.105,.145),.015,light,chest)\npipe(\"Front jacket zipper\",[(0,.081,-.026),(0,.090,.030),(0,.119,.132),(0,.084,.193)],.0026,light,chest)\nfor side in (-1,1):\n box(\"Front welt pocket\",(side*.088,.087,.045),(.080,.020,.021),blue,chest,.004,(0,.13*side,0))\nloft(\"Ribbed mock neck collar\",[(.219,.065,.051,0),(.238,.065,.051,0),(.259,.056,.049,0),\n (.269,.054,.048,0)],dark,chest)\nellipsoid(\"Neck\",(0,0,.275),(.051,.047,.068),skin,chest)\n\nhead.location=(0,.008,.303)\nheadprofile=[(-.012,.036,.032,.025),(-.003,.050,.042,.023),(.015,.064,.049,.018),\n (.036,.072,.055,.013),(.060,.076,.062,.009),(.085,.077,.066,.006),(.111,.073,.062,.002),\n (.133,.061,.055,-.004),(.149,.042,.043,-.010),(.158,.007,.008,-.011)]\nloft(\"Layered stylized facial silhouette\",headprofile,skin,head,.91,48)\nfor side in (-1,1):\n ellipsoid(\"Ear auricle\",(side*.073,.004,.056),(.012,.014,.024),skin,head)\n ellipsoid(\"Ear depression\",(side*.081,.010,.057),(.005,.010,.015),skin2,head)\n ellipsoid(\"Pale green ear stud\",(side*.082,.008,.042),(.0050,.0060,.0050),mint,head)\n x=side*.031\n ellipsoid(\"Warm sclera\",(x,.067,.067),(.020,.007,.0099),eye_white,head,(0,-side*.06,0))\n ellipsoid(\"Amber iris\",(x+.002,.0731,.067),(.0084,.0032,.0087),eye_color,head)\n ellipsoid(\"Small black pupil\",(x+.003,.0756,.067),(.0048,.0018,.0060),eye_black,head)\n pipe(\"Upper eye contour\",[(x-.018,.068,.068),(x-.009,.074,.075),(x+.010,.075,.075),(x+.018,.069,.070)],\n .0019,eye_black,head)\n pipe(\"Arched brow\",[(x-.018,.065,.088),(x-.006,.071,.093),(x+.010,.070,.093),(x+.018,.066,.090)],\n .0031,hair,head)\nellipsoid(\"Small defined nose\",(0,.070,.051),(.014,.014,.020),skin,head,(-.20,0,0))\nellipsoid(\"Nose tip\",(0,.079,.043),(.012,.0083,.009),skin,head)\npout=[(-.015,.064,.023),(-.009,.069,.022),(0,.073,.021),(.008,.069,.022),(.015,.064,.024)]\npipe(\"Slightly curved mouth\",pout,.0024,lip,head)\nellipsoid(\"Short asymmetric bob behind the head\",(0,-.032,.096),(.083,.050,.070),hair,head)\nellipsoid(\"Dark fitted crown\",(0,-.003,.129),(.079,.063,.043),hair,head)\nhairlines=[(-.069,.020,.112,-.033),(-.054,.043,.125,-.023),(-.029,.055,.138,-.016),\n (.001,.051,.142,-.001),(.041,.041,.139,.016),(.062,.022,.124,.018)]\nfor i,(x,y,z,s) in enumerate(hairlines):\n ellipsoid(\"Sculpted side-swept hair lock\",(x,y,z),(.024,.027,.019),hairlight if i%2 else hair,head,(0,-.21+i*.105,.24))\nellipsoid(\"Gathered short ponytail knot\",(.023,-.077,.109),(.025,.025,.028),hair,head)\nellipsoid(\"Tied-back short ponytail\",(.025,-.093,.081),(.026,.039,.055),hair,head,(.42,0,-.2))\nellipsoid(\"Scrunchie\",(.024,-.085,.109),(.024,.011,.019),mint,head,(.20,0,0))\n\ndef link(name,widths,material,detail=None):\n node=empty(name+\" control\",actor)\n loft(name,[(t,wx,wy,0) for t,wx,wy in widths],material,node,.81,32,.035)\n if detail:\n detail(node)\n return node\n\n\ndef shin_details(node):\n box(\"Reinforced material on shin\", (0,-.050,.49),(.081,.015,.38),blue,node,.020)\n pipe(\"Shin seam detail\",[(.053,-.020,.20),(.055,-.024,.46),(.054,-.033,.85)],.0028,light,node)\n\n\ndef thigh_details(node):\n box(\"Paneled cargo pocket\",(.051,-.035,.47),(.032,.080,.36),blue,node,.013)\n box(\"Cargo pocket flap\",(.064,-.035,.62),(.018,.083,.099),dark,node,.008)\n pipe(\"Cargo topstitch\",[(.055,.027,.17),(.066,.020,.46),(.060,.017,.87)],.0018,light,node)\n\n\ndef sleeve_details(node):\n box(\"Sleeve stripe tab\",(.054,-.029,.30),(.018,.047,.12),mint,node,.006)\n pipe(\"Outer sleeve decorative stitching\",[(.047,-.015,.20),(.054,-.015,.50),(.046,-.014,.92)],.0022,light,node)\n\n\nlimbs={}\nfor side in (-1,1):\n tag=\"Right\" if side>0 else \"Left\"\n limbs[side]={}\n l=limbs[side]\n l[\"thigh\"]=link(tag+\" upper pant leg\",[(0,.081,.086),(.09,.089,.097),(.22,.089,.093),\n (.46,.082,.081),(.71,.066,.068),(.87,.058,.062),(1.01,.057,.057)],navy,thigh_details)\n l[\"shin\"]=link(tag+\" lower pant leg\",[(-.055,.055,.058),(.09,.061,.062),(.28,.064,.065),\n (.59,.054,.056),(.79,.047,.047),(.97,.048,.054),(1.03,.046,.048)],navy,shin_details)\n feet=(side*.117,side*.054)\n root=empty(tag+\" boot\",actor)\n l[\"boot\"]=root\n root.location=(*feet,.006)\n root.rotation_euler.z=side*-.14\n box(\"Dark traction tread\",(0,.055,.020),(.124,.257,.038),leather,root,.013)\n box(\"Thick mauve sole band\",(0,.059,.034),(.128,.254,.037),rubber,root,.014)\n box(\"Cream sidewall welt\",(0,.062,.048),(.130,.245,.013),light,root,.005)\n ellipsoid(\"Rounded leather toe and vamp\",(0,.098,.075),(.063,.097,.036),leather,root)\n loft(\"Laced high top boot collar\",[(.046,.058,.061,-.014),(.085,.055,.059,-.015),\n (.125,.052,.051,-.015),(.164,.050,.044,-.012)],leather,root,.77,28)\n for j in range(4):\n z=.089+j*.014\n y=.056-j*.004\n pipe(\"Blunt heel topstitch\", [(-.037,y,z),(.000,y+.002,z+.002),(.037,y,z)],.0031,light,root)\n box(\"Heel boot ribbon\",(0,-.060,.112),(.024,.011,.066),mint,root,.005)\n\n l[\"upper\"]=link(tag+\" articulated shaped upper sleeve\",[(0,.058,.062),(.09,.063,.065),(.21,.060,.058),\n (.48,.051,.052),(.76,.046,.046),(.99,.042,.042)],suit,sleeve_details)\n ellipsoid(\"Rounded cloth at jacket elbow\",(0,0,.974),(.044,.045,.104),suit,l[\"upper\"])\n l[\"fore\"]=link(tag+\" articulated fore sleeve\",[(-.055,.041,.043),(.09,.049,.049),(.25,.050,.048),\n (.47,.044,.044),(.71,.038,.037),(.88,.033,.032),(1.03,.031,.032)],suit)\n loft(\"Fitted dark sleeve cuff\",[(.850,.033,.033,0),(.877,.037,.036,0),(.960,.035,.035,0),\n (1.036,.031,.031,0)],dark,l[\"fore\"],.80,28)\n box(\"Forearm jacket piping\",(.032,-.025,.64),(.013,.015,.24),light,l[\"fore\"],.003)\n\n hand=empty(tag+\" glove grip control\",actor)\n l[\"hand\"]=hand\n ellipsoid(\"Glove palm\",(-.026,.023,-.008),(.034,.016,.025),leather,hand)\n box(\"Lilac glove panel\",(-.031,.035,-.007),(.035,.008,.030),blue,hand,.007)\n l[\"digits\"]=[]\n for i,z in enumerate((.008,-.005,-.017,-.028)):\n pivot=empty(\"Finger flex\",hand)\n pivot.location=(-.009,.022,z)\n l[\"digits\"].append(pivot)\n ln=(.035,.041,.039,.031)[i]\n ellipsoid(\"Gloved finger proximal\",(ln*.36,-.003,0),(ln*.55,.0063,.006),leather,pivot)\n ellipsoid(\"Gloved folded fingertip\",(ln*.77,-.010,-.0005),(ln*.32,.0063,.0058),leather,pivot,(0,0,-.48))\n thumb=empty(\"Thumb flex\",hand)\n thumb.location=(-.024,.017,.017)\n ellipsoid(\"Gloved thumb\",(.011,-.004,.005),(.017,.009,.008),leather,thumb,(0,-.39,-.38))\n l[\"thumb\"]=thumb\n\nstunt=empty(\"Fictional foam stunt prop\",actor)\n# Rounded solid foam, with a sealed oval nose and oversized toy markings.\nellipsoid(\"Sealed soft foam core\",(.059,0,.058),(.098,.035,.039),prop_shell,stunt)\nbox(\"Foam toy's beveled side enclosure\",(.040,0,.052),(.168,.060,.056),prop_shell,stunt,.025)\nellipsoid(\"Oversized closed-cell foam nose\",(.149,0,.056),(.037,.041,.034),prop_mint,stunt)\nellipsoid(\"Circular violet cushion on the solid nose\",(.171,0,.056),(.018,.031,.029),prop_purple,stunt)\nellipsoid(\"Bright flat center of solid bumper\",(.183,0,.056),(.012,.020,.019),prop_white,stunt)\nbox(\"Closed toy handhold\",(-.006,0,-.013),(.041,.047,.086),prop_purple,stunt,.014,(0,-.24,0))\nbox(\"Foam grip's end pad\",(-.017,.000,-.052),(.045,.050,.019),prop_white,stunt,.008,(0,-.15,0))\nellipsoid(\"Purple raised foam top crest\",(.031,0,.088),(.068,.025,.019),prop_purple,stunt)\nfor side in (-1,1):\n ellipsoid(\"Lilac embossed oval on the foam shell\",(.053,side*.031,.060),(.064,.007,.023),prop_white,stunt)\n text(\"Die-cut foam identification\",\"F O A M / 0 3\",(.053,side*.0387,.059),.0117,prop_purple,stunt,\n ((math.pi/2,0,0) if side<0 else (math.pi/2,0,math.pi)))\n for i in range(3):\n box(\"Molded violet pop-color bar\",(.002+i*.014,side*.032,.035),(.007,.007,.010),prop_purple,stunt,.003)\nstunt[\"description\"]=\"Original nonfunctional closed-cell foam science-fiction stage accessory.\"\nactor[\"description\"]=\"Original stylized adult character. All parts modeled for this ten-second animation.\"\n\n\ndef ease(t):\n t=max(0,min(1,t))\n return t*t*(3-2*t)\n\n\ndef eval_track(track,t):\n if t<=track[0][0]:\n return track[0][1]\n for (a,x),(b,y) in zip(track,track[1:]):\n if a<=t<=b:\n return x.lerp(y,ease((t-a)/(b-a))) if isinstance(x,Vector) else x+(y-x)*ease((t-a)/(b-a))\n return track[-1][1]\n\n\ndef key(t,values):\n return eval_track([(a,pos(*xyz)) for a,xyz in values],t)\n\n\ndef orientation(yaw,pitch=0,roll=0):\n return (Quaternion((0,0,1),yaw)@Quaternion((0,1,0),pitch)@Quaternion((1,0,0),roll)).normalized()\n\n\ndef set_link(node,a,b,x_hint):\n z=(b-a).normalized()\n x=(x_hint-z*x_hint.dot(z)).normalized()\n y=z.cross(x).normalized()\n node.location=a\n node.rotation_mode=\"QUATERNION\"\n node.rotation_quaternion=Matrix((x,y,z)).transposed().to_quaternion()\n node.scale=(1,1,(b-a).length)\n\n\ndef get_elbow(a,b,plus,side):\n d=(b-a).length\n uv=(b-a).normalized()\n u=.276\n v=.254\n d2=min(d,u+v-.007)\n at=(u*u-v*v+d2*d2)/(2*d2)\n rise=math.sqrt(max(.00003,u*u-at*at))\n bend=plus-plus.dot(uv)*uv\n return a+uv*at+bend.normalized()*rise\n\n\nRIGHT=[\n (0,(.259,-.061,.913)),(.83,(.255,-.074,.919)),(1.54,(.249,-.219,1.005)),(2.04,(.147,-.259,.971)),\n (2.27,(.069,-.195,.934)),(2.57,(.132,-.324,.956)),(3.02,(.310,-.295,1.047)),\n (3.65,(.417,-.230,1.150)),(4.35,(.406,-.244,1.184)),(5.40,(.411,-.229,1.156)),\n (5.91,(.248,-.307,1.075)),(6.36,(.143,-.320,.988)),(6.85,(.069,-.195,.934)),\n (7.13,(.069,-.195,.934)),(7.55,(.196,-.266,.994)),(8.25,(.370,-.122,1.284)),\n (8.64,(.354,-.109,1.242)),(9.47,(.263,-.061,.915)),(10,(.259,-.061,.913))\n]\nTURN=[\n (0,2.84),(1.28,2.91),(2.27,math.pi),(2.53,3.10),(3.00,1.79),(3.68,.61),\n (4.52,.68),(5.40,.59),(5.97,1.66),(6.47,2.75),(6.85,math.pi),(7.13,math.pi),\n (7.51,3.35),(8.22,4.52),(8.62,4.43),(9.45,2.85),(10,2.84)\n]\nLEFT=[\n (0,(-.242,.017,.907)),(1.30,(-.248,.025,.919)),(2.27,(-.261,.079,.998)),\n (3.39,(-.203,.112,1.116)),(4.58,(-.188,.126,1.073)),(5.68,(-.213,.108,1.027)),\n (6.87,(-.245,.055,.953)),(7.31,(-.255,.038,.939)),(8.22,(-.282,-.011,.990)),\n (8.66,(-.279,-.004,.983)),(9.48,(-.249,.022,.910)),(10,(-.242,.017,.907))\n]\nCHEST_YAW=[(0,-.25),(1,-.29),(2.25,-.43),(3.68,-.81),(4.65,-.89),\n (5.4,-.75),(6.85,-.39),(7.4,-.31),(8.35,-.56),(9.54,-.25),(10,-.25)]\nARM_GRIP=[(0,.43),(1,.30),(2.14,.18),(2.29,1.),(6.96,1.),(7.20,.11),\n (8.25,.07),(8.65,.08),(9.72,.43),(10,.43)]\n\n\ndef animation_pose(t):\n breathe=math.sin(t*math.pi*2/2.5)\n lean=math.exp(-((t-2.29)/.52)**2)+.85*math.exp(-((t-6.88)/.46)**2)\n hero=math.exp(-((t-4.45)/1.10)**4)\n flourish=math.exp(-((t-8.28)/.64)**4)\n qp=orientation(-.115-.115*lean-.039*hero,0,.023*hero)\n pp=pos(-.011*lean+.014*hero,-.005-.008*lean,1.001-.020*lean+.006*breathe)\n qc=orientation(eval_track(CHEST_YAW,t),.035*hero+.071*lean,-.026-.12*lean+.055*flourish)\n pc=pp+pos(.007+.007*hero,-.001,.154)\n pelvis.location=pp\n chest.location=pc\n for obj,q in ((pelvis,qp),(chest,qc)):\n obj.rotation_mode=\"QUATERNION\"\n obj.rotation_quaternion=q\n head.rotation_mode=\"QUATERNION\"\n head.rotation_quaternion=orientation(-.05-.42*hero-.20*flourish-.16*lean,-.04-.10*lean,.065*hero)\n dock=pp+qp@pos(.057,-.190,-.060)\n dock_rotation=(qp@orientation(math.pi,.115,0)).normalized()\n r=key(t,RIGHT)\n is_contact = ease((t-1.75)/.51)*(1-ease((t-2.33)/.35))\n return_contact = ease((t-6.32)/.50)*(1-ease((t-7.16)/.38))\n contact=max(is_contact,return_contact)\n r=r.lerp(dock,contact)\n rh=orientation(eval_track(TURN,t),eval_track([(0,0),(2.25,.115),(3.60,-.53),(4.90,-.65),\n (5.45,-.51),(6.82,.11),(7.14,.11),(8.10,-.84),(10,0)],t),.09*hero)\n rh=rh.slerp(dock_rotation,contact)\n held=2.30<=t<6.86\n stunt.location=r if held else dock\n stunt.rotation_mode=\"QUATERNION\"\n stunt.rotation_quaternion=rh if held else dock_rotation\n\n for side in (-1,1):\n l=limbs[side]\n hip_joint=pp+qp@pos(side*.096,.006,-.072)\n knee=pos(side*(.111+.006*flourish),.053+side*.040+.020*lean,.533-.013*lean)\n ankle=pos(side*.117,side*.054-.013,.132)\n set_link(l[\"thigh\"],hip_joint,knee,pos(side*.82,-.1,-.05))\n set_link(l[\"shin\"],knee,ankle,pos(side*.88,-.06,0))\n hand=l[\"hand\"]\n h=r if side>0 else key(t,LEFT)\n hq=rh if side>0 else orientation(.15+.70*flourish+.17*hero,-.16+.41*flourish,-.19)\n hand.location=h\n hand.rotation_mode=\"QUATERNION\"\n hand.rotation_quaternion=hq\n opening=eval_track(ARM_GRIP,t) if side>0 else .21+.36*hero-.18*flourish\n for i,pivot in enumerate(l[\"digits\"]):\n pivot.rotation_euler=(0,.028*(i-1.5)*(1-opening),-.04-.93*opening+.101*(i-1.5)*(1-opening))\n l[\"thumb\"].rotation_euler=(0,-.22-.15*opening,-.47*opening)\n wrist=h+hq@pos(-.051,.022,-.005)\n shoulder=pc+qc@pos(side*.177,.002,.179)\n bend=pos(side*(1-.37*lean),-.30-.40*lean,-.19+.21*flourish)\n elbow=get_elbow(shoulder,wrist,bend,side)\n set_link(l[\"upper\"],shoulder,elbow,pos(side*.85,-.49,.14))\n set_link(l[\"fore\"],elbow,wrist,pos(side*.89,-.39,.04))\n\n\ndef all_controls():\n out=[pelvis,chest,head,stunt]\n for item in limbs.values():\n out.extend(item[n] for n in (\"thigh\",\"shin\",\"upper\",\"fore\",\"hand\",\"thumb\"))\n out.extend(item[\"digits\"])\n return out\n\n\nprevious={}\nfor frame in range(1,LAST+2):\n t=(frame-1)/FPS\n animation_pose(t)\n for o in all_controls():\n if o.rotation_mode==\"QUATERNION\":\n q=o.rotation_quaternion.copy()\n if o.name in previous and previous[o.name].dot(q)<0:\n o.rotation_quaternion=-q\n previous[o.name]=o.rotation_quaternion.copy()\n o.keyframe_insert(data_path=\"rotation_quaternion\",frame=frame,group=\"Pose\")\n else:\n o.keyframe_insert(data_path=\"rotation_euler\",frame=frame,group=\"Pose\")\n o.keyframe_insert(data_path=\"location\",frame=frame,group=\"Pose\")\n if \" control\" in o.name:\n o.keyframe_insert(data_path=\"scale\",frame=frame,group=\"Pose\")\n\n\nscene.frame_start=1\nscene.frame_end=LAST\nscene.render.fps=FPS\nfor f,name in ((1,\"VISIBLE AT REAR\"),(28,\"REACH\"),(55,\"CONTACT\"),(78,\"DRAW\"),(105,\"DISPLAY\"),\n (142,\"RETURN\"),(166,\"RESEAT\"),(176,\"RELEASE\"),(198,\"HANDS CLEAR\")):\n scene.timeline_markers.new(name,frame=f)\n\ndef point_camera(o,target):\n o.rotation_euler=(Vector(target)-o.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef lamp(name,location,target,power,size,color,second=None):\n d=bpy.data.lights.new(name,\"AREA\")\n d.energy=power\n d.color=color\n d.shape=\"RECTANGLE\" if second else \"DISK\"\n d.size=size\n if second:\n d.size_y=second\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.location=location\n point_camera(o,target)\n\n\ndef decorate_stage():\n deck=mat(\"Neutral graphite cyclorama\",(.062,.058,.084),.82)\n verts=[]\n samples=[(-14.,0.),(2.8,0.)]\n for k in range(1,33):\n a=math.pi/2*k/32\n samples.append((2.8+2.0*math.sin(a),2.0*(1-math.cos(a))))\n samples.append((4.8,9.))\n for y,z in samples:\n verts.extend(((-12,y,z),(12,y,z)))\n mesh(\"Studio cyclorama\",verts,[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(samples)-1)],deck)\n bpy.ops.mesh.primitive_cylinder_add(vertices=120,radius=1.21,depth=.021,location=(0,0,-.007))\n stage=bpy.context.object\n stage.name=\"Quiet circular practice stage\"\n stage.data.materials.append(mat(\"Satin graphite stage surface\",(.083,.074,.105),.69))\n ring=mat(\"Subtle mint stage reveal\",(.12,.27,.23),.48,0,.18)\n pipe(\"Wide circle in the stage texture\",[(1.113*math.cos(TWO_PI*j/160),1.113*math.sin(TWO_PI*j/160),\n .0041) for j in range(160)],.0040,ring,cyclic=True)\n for i in range(12):\n a=TWO_PI*i/12\n ob=box(\"Painted rehearsal-stage tick\",(1.027*math.cos(a),1.027*math.sin(a),.0051),\n (.059,.006,.002),ring,None,.001)\n ob.rotation_euler.z=a\n world=scene.world=bpy.data.worlds.new(\"Warm studio ambience\")\n world.use_nodes=True\n bg=world.node_tree.nodes.get(\"Background\")\n bg.inputs[\"Color\"].default_value=(.36,.38,.50,1)\n bg.inputs[\"Strength\"].default_value=.19\n lamp(\"Warm late-afternoon softbox\",(-2.1,-3.7,4.0),(0,0,.94),345,3.0,(1,.909,.806),2.3)\n lamp(\"Long blue steel edge strip\",(2.4,.9,3.05),(0,0,1.0),420,1.3,(.68,.79,1),2.8)\n lamp(\"Soft violet shadow fill\",(1.4,-2.7,1.72),(0,0,.98),89,1.25,(.90,.84,1),1.7)\n lamp(\"Quiet studio background light\",(-1.2,1.8,1.6),(0,3.5,2.5),100,1.9,(.53,.66,.92))\n data=bpy.data.cameras.new(\"Continuous three-quarter camera\")\n cam=bpy.data.objects.new(data.name,data)\n bpy.context.collection.objects.link(cam)\n scene.camera=cam\n for f,xyz,lens in (\n (1,(2.43,-3.12,1.76),66),(51,(2.60,-3.12,1.75),68),\n (94,(2.82,-2.99,1.77),68),(133,(2.82,-2.99,1.77),68),\n (171,(2.48,-3.15,1.75),69),(207,(2.45,-3.14,1.75),67),\n (241,(2.43,-3.12,1.76),66)):\n cam.location=xyz\n point_camera(cam,(.028,-.035,.856))\n data.lens=lens\n cam.keyframe_insert(data_path=\"location\",frame=f)\n cam.keyframe_insert(data_path=\"rotation_euler\",frame=f)\n data.keyframe_insert(data_path=\"lens\",frame=f)\n\n\ndef actor_only():\n selected=set()\n stack=[actor]\n while stack:\n o=stack.pop()\n selected.add(o)\n stack.extend(o.children)\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in selected:\n ob.select_set(True)\n bpy.context.view_layer.objects.active=actor\n\n\ndef options(res):\n scene.render.engine=\"CYCLES\"\n scene.cycles.samples=16\n scene.cycles.use_denoising=True\n scene.cycles.adaptive_threshold=.08\n scene.cycles.max_bounces=5\n scene.cycles.diffuse_bounces=2\n scene.cycles.glossy_bounces=2\n scene.render.resolution_x=res\n scene.render.resolution_y=res\n scene.render.resolution_percentage=100\n scene.render.image_settings.file_format=\"PNG\"\n scene.render.image_settings.color_mode=\"RGB\"\n scene.view_settings.view_transform=\"AgX\"\n scene.view_settings.look=\"AgX - Medium High Contrast\"\n scene.view_settings.exposure=.28\n\n\ndecorate_stage()\noptions(1080)\nscene.frame_set(1)\nif args.mode==\"setup\":\n frames=dest/\"frames\"\n frames.mkdir(exist_ok=True)\n scene.render.filepath=str(frames/\"frame-\")\n bpy.ops.wm.save_as_mainfile(filepath=str(dest/\"nova-stunt-loop.blend\"),compress=True)\n actor_only()\n scene.frame_end=LAST+1\n bpy.ops.export_scene.gltf(filepath=str(dest/\"nova-stunt-loop.glb\"),export_format=\"GLB\",\n use_selection=True,export_animations=True,export_animation_mode=\"SCENE\",\n export_frame_range=True,export_frame_step=1,export_lights=False,export_cameras=False)\nelse:\n options(480)\n scene.cycles.samples=12\n for f in (1,55,94,165,200):\n scene.frame_set(f)\n scene.render.filepath=str(dest/f\"preview-{f:03}.png\")\n bpy.ops.render.render(write_still=True)\n```\n\n```python\n# pack_glb.py\n\"\"\"Combine Blender's per-object animation tracks into one ten-second glTF clip.\"\"\"\nimport json\nfrom pathlib import Path\nimport struct\nimport sys\n\nsource, target = [Path(p) for p in sys.argv[1:]]\ndata=source.read_bytes()\nassert struct.unpack_from(\"<4sII\",data) == (b\"glTF\",2,len(data))\nlength,typ=struct.unpack_from(\"\nLOOK\nA metallic jewel beetle resting flat, seen from above at an angle. Long pointed wing cases with fine lengthwise ridges, emerald green with burgundy stripes running down each side. Rounded copper-green shield behind the head, big dark compound eyes, serrated antennae, and six segmented legs splayed low with tiny claws and hairs.\n\nSCALE\nAbout 30 mm wide, 8 mm tall, 38 mm deep, life size. Build in meters, +Y up, +Z forward, origin at surface level under the body centerline.\n\nPARTS\n1. Wing cases: two long tapered shells meeting at a center seam, ridged, with burgundy bands. Build: parametric surface running from the dorsal seam to the rolled outer flank, with real shell thickness.\n2. Abdomen: overlapping ventral segments under the wing cases. Build: parametric surface.\n3. Pronotum: rounded dorsal shield with a lateral ridge. Build: parametric surface with its own pit spacing.\n4. Scutellum: a small raised triangle at the wing hinge. Build: small mesh.\n5. Head: head capsule, compound eyes, mandibles, collar membrane. Build: parametric face surface, spheres for the eyes.\n6. Antennae and legs: serrated antennae, plus front, middle and hind legs with femora, tibiae, spinules, setae and paired claws. Build: tapered spindles and tubes along bent paths, with joint rims between segments.\n\nPLAN\n1. Setup: clear the scene, meters, origin at surface level.\n2. Texture maps: generated inside beetle.py. Wing-case color with the burgundy band and bronze border, cuticle pit and stria normals, a different pit spacing for the head and pronotum, and a fine ommatidia pattern for the eyes.\n3. Build order: wing cases, abdomen, pronotum, scutellum, head and eyes, antennae, legs.\n4. Assemble: wing cases meet on the center seam behind the pronotum, scutellum at the hinge, legs in a low asymmetric resting pose with the lowest claw tips just above the floor. Join repeated small pieces into one group per joint.\n5. Materials: metallic wing-case cuticle with burgundy bands, emerald-copper pronotum, bottle-green sclerites, waxy copper-green legs, deep green eyes, dark chitin claws and mandibles, golden setae.\n6. Export: beetle only, one GLB with the textures embedded.\n\nCHECK\n429,228 triangles across 122 parts. Against the image: wing cases about two-thirds of the body length, a burgundy band on each side, legs spread wider than the body.\n\n\n```python\n# beetle.py\n\"\"\"Original procedural Japanese jewel beetle with UV-painted PBR wing cases.\"\"\"\nimport argparse\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bpy\nimport bmesh\nfrom mathutils import Vector\nimport numpy as np\n\nparser=argparse.ArgumentParser()\nparser.add_argument(\"--output\",type=Path,required=True)\nparser.add_argument(\"--draft\",action=\"store_true\")\nargs=parser.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261126T2000Z-animals-japanese-jewel-beetle\"\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\nparts=[]\nrng=np.random.default_rng(4993)\ntau=math.tau\n\n\ndef rgb(s):\n v=[int(s[i:i+2],16)/255 for i in (0,2,4)]\n return tuple(c/12.92 if c<=.04045 else ((c+.055)/1.055)**2.4 for c in v)\n\n\ndef mat(name,color,metal,rough,coat=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*rgb(color),1)\n m.use_nodes=True\n bs=m.node_tree.nodes.get(\"Principled BSDF\")\n bs.inputs[\"Base Color\"].default_value=m.diffuse_color\n bs.inputs[\"Metallic\"].default_value=metal\n bs.inputs[\"Roughness\"].default_value=rough\n bs.inputs[\"Coat Weight\"].default_value=coat\n bs.inputs[\"Coat Roughness\"].default_value=.19\n return m\n\n\ndef png(name,r,g,b,space):\n h,w=r.shape\n pixels=np.stack((r,g,b,np.ones_like(r)),axis=-1).astype(np.float32)\n im=bpy.data.images.new(name,width=w,height=h,alpha=False)\n im.colorspace_settings.name=space\n im.pixels.foreach_set(pixels.ravel())\n im.file_format=\"PNG\"\n im.filepath_raw=str(out/(name+\".png\"))\n im.save()\n im.reload()\n im.colorspace_settings.name=space\n return im\n\n\ndef node(m,image):\n n=m.node_tree.nodes.new(\"ShaderNodeTexImage\")\n n.image=image\n return n\n\n\ndef color_map(m,image):\n m.node_tree.links.new(node(m,image).outputs[\"Color\"],m.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Base Color\"])\n\n\ndef roughness_map(m,image):\n m.node_tree.links.new(node(m,image).outputs[\"Color\"],m.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Roughness\"])\n\n\ndef normal_map(m,image,strength):\n nt=m.node_tree\n n=nt.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=strength\n nt.links.new(node(m,image).outputs[\"Color\"],n.inputs[\"Color\"])\n nt.links.new(n.outputs[\"Normal\"],nt.nodes.get(\"Principled BSDF\").inputs[\"Normal\"])\n\n\ndef norm_img(name,height,amp_u,amp_v):\n dx=(np.roll(height,-1,axis=1)-np.roll(height,1,axis=1))*amp_u\n dy=(np.roll(height,-1,axis=0)-np.roll(height,1,axis=0))*amp_v\n den=np.sqrt(1+dx*dx+dy*dy)\n return png(name,.5-.5*dx/den,.5-.5*dy/den,.5+.5/den,\"Non-Color\")\n\n\nres=1536\nv,u=np.mgrid[:res,:res].astype(np.float32)/res\n\n\ndef noise(nx,ny):\n x,y=u*nx,v*ny\n ix,iy=np.floor(x).astype(int),np.floor(y).astype(int)\n fx,fy=x-ix,y-iy\n sx=fx*fx*(3-2*fx)\n sy=fy*fy*(3-2*fy)\n r=rng.uniform(-1,1,(ny,nx)).astype(np.float32)\n a=r[iy%ny,ix%nx]*(1-sx)+r[iy%ny,(ix+1)%nx]*sx\n b=r[(iy+1)%ny,ix%nx]*(1-sx)+r[(iy+1)%ny,(ix+1)%nx]*sx\n return a*(1-sy)+b*sy\n\n\ndef ease(x,a,b):\n s=np.clip((x-a)/(b-a),0,1)\n return s*s*(3-2*s)\n\n\n# Elytron U runs from the dorsal seam to the rolled outer flank.\n# Sepia-red band has its own bronze border and tiny irregularities.\nwarp=.007*noise(7,20)+.004*noise(30,80)\ncenter=.410+.030*np.sin(v*math.pi)-.019*v+warp\nhalf=(.133-.050*v)*ease(v,-.04,.10)*(1-ease(v,.86,1.02))\nedge_dist=np.abs(u-center)-half\nstripe=(1-ease(edge_dist,-.007,.003))*ease(v,.000,.060)*(1-ease(v,.94,.997))\nbronze=(1-ease(edge_dist,.001,.052))*(1-stripe)*ease(v,.004,.060)*(1-ease(v,.91,.998))\ntoward_flank=ease(u,.58,1)\ngrain=noise(20,60)*.018+noise(122,295)*.022\ngreen=np.stack((.136+.128*ease(u,.04,.32)-.113*toward_flank+grain,\n .545+.112*ease(u,.05,.35)-.280*toward_flank+grain,\n .332-.190*ease(u,.08,.34)+.197*toward_flank+grain),axis=-1)\nred=np.stack((.595-.139*ease(v,.10,.94)+grain,\n .205+.12*ease(edge_dist,-.076,-.01)+grain,\n .306-.106*ease(edge_dist,-.066,-.006)+grain),axis=-1)\nedge_color=np.stack((.51+grain,.462+grain,.159+grain),axis=-1)\ncolor=green*(1-bronze[...,None])+edge_color*bronze[...,None]\ncolor=color*(1-stripe[...,None])+red*stripe[...,None]\nc=ease(u,0,.025)*.20+.80\ncolor=np.clip(color*c[...,None],0,1)\nelytra_color=png(\"Elytra_BaseColor\",color[:,:,0],color[:,:,1],color[:,:,2],\"sRGB\")\n\n# Array of softly beveled, jittered cuticle pits and faint wing-case striae.\ndent=np.zeros_like(u)\nfor ny,nx,amplitude in [(166,73,.52),(251,117,.25)]:\n gu,gv=u*nx,v*ny\n i,j=np.floor(gu).astype(int),np.floor(gv).astype(int)\n jitter=rng.random((ny,nx,3))\n off=jitter[j%ny,i%nx]\n px=gu-i-(.23+.55*off[:,:,0])\n py=gv-j-(.22+.57*off[:,:,1])\n d=np.exp(-(px*px+py*py)*33)*off[:,:,2]\n dent+=amplitude*d.astype(np.float32)\nlongitudinal=(.5+.5*np.cos(tau*(11.6*u+.07*np.sin(v*8)+.047*noise(9,19))))**12\nheight=-dent-.22*longitudinal+.058*noise(178,421)\nelytra_normal=norm_img(\"Elytra_Normal\",height,2.15,1.80)\nr=.29+.079*dent+.015*longitudinal+.046*noise(72,110)+.035*toward_flank\nr=np.clip(r,.23,.41)\nelytra_rough=png(\"Elytra_Roughness\",r,r,r,\"Non-Color\")\nelytron=mat(\"Wing cases | metallic cuticle with burgundy bands\",\"52975E\",.87,.32,.26)\ncolor_map(elytron,elytra_color)\nroughness_map(elytron,elytra_rough)\nnormal_map(elytron,elytra_normal,.64)\n\n# Head and pronotum have a different pit spacing and a green-copper transition.\nsh=.48+.12*noise(14,10)+.052*noise(107,82)\npollen=noise(164,148)\nveins=(.5+.5*np.cos(tau*(u+.081*np.sin(v*6.22))))\naround=np.minimum(u,1-u)\nstripe_pro = 1-ease(np.abs(around-(.153+.012*np.sin(v*3.7))),.023,.049)\ncrimson=(ease(veins,.72,.92)-ease(veins,.95,.989))*.27 + stripe_pro*.64\nshieldcolor=png(\"HeadThorax_BaseColor\",\n .175+.24*crimson+.102*sh+.035*pollen,\n .462-.20*crimson+.15*sh+.027*pollen,\n .233+.037*crimson+.074*sh+.02*pollen,\"sRGB\")\nshield_norm=norm_img(\"HeadThorax_Normal\",-.70*dent+.18*pollen,2.0,2.00)\nshield=mat(\"Pronotum | emerald copper cuticle\",\"438649\",.83,.33,.21)\ncolor_map(shield,shieldcolor)\nnormal_map(shield,shield_norm,.59)\nunder=mat(\"Thoracic and abdominal sclerites | dark bottle green\",\"224336\",.78,.38,.17)\ngreen_joint=mat(\"Femora and tibiae | waxy copper-green cuticle\",\"366A51\",.69,.365,.20)\nnormal_map(green_joint,shield_norm,.25)\ngold_joint=mat(\"Articulation rims | bronze-green\",\"71733F\",.77,.36,.15)\nmembrane=mat(\"Articulating membrane | dark umber\",\"212620\",.28,.47)\nantenna=mat(\"Antennae | green umber\",\"2A5445\",.55,.42,.14)\nmouth=mat(\"Mandibles and tarsal claws | dark chitin\",\"262F29\",.38,.37,.16)\nhair=mat(\"Short golden sensory setae\",\"735D32\",.24,.48)\nscutellum=mat(\"Waxed triangular scutellum\",\"28624A\",.81,.31,.20)\n\n# Fine ommatidia pattern. Scale differently from the cuticle maps so it remains\n# visible on a two-millimeter eye without separate draw calls for every facet.\nfx,fy=u*79,v*49\nrow=np.floor(fy).astype(int)\ndx=fx+.5*(row%2)-np.floor(fx+.5*(row%2))-.5\ndy=fy-row-.5\nd=np.sqrt(dx*dx+dy*dy)\neyes_norm=norm_img(\"Ommatidia_Normal\",.18*(1-ease(d,.08,.59)),1.05,1.02)\neye=mat(\"Compound eyes | deep green ommatidia\",\"142C28\",.31,.25,.30)\nnormal_map(eye,eyes_norm,.49)\n\n\ndef register(ob,name,material,smooth=True,export=True):\n ob.name=name\n ob.data.materials.append(material)\n if smooth:\n for f in ob.data.polygons:\n f.use_smooth=True\n if export:\n parts.append(ob)\n return ob\n\n\ndef mesh(name,verts,faces,material,uvs=None,flip=False,closed=False,export=True):\n m=bpy.data.meshes.new(name)\n m.from_pydata(verts,[],[tuple(reversed(f)) for f in faces] if flip else faces)\n m.update()\n if uvs is not None:\n uv=m.uv_layers.new(name=\"UVMap\")\n for f in m.polygons:\n seam=max(uvs[i][0] for i in f.vertices)-min(uvs[i][0] for i in f.vertices)>.92 and len(f.vertices)<5\n for index in f.loop_indices:\n x,y=uvs[m.loops[index].vertex_index]\n uv.data[index].uv=(x+int(seam and x<.1),y)\n if closed:\n bm=bmesh.new()\n bm.from_mesh(m)\n bmesh.ops.recalc_face_normals(bm,faces=bm.faces[:])\n bm.to_mesh(m)\n bm.free()\n o=bpy.data.objects.new(name,m)\n bpy.context.collection.objects.link(o)\n return register(o,name,material,export=export)\n\n\ndef surface(name,fn,mat,rows,cols,wrap=False,caps=False,flip=False):\n count=cols if wrap else cols+1\n verts,faces,uv=[],[],[]\n for j in range(rows+1):\n for i in range(count):\n u0,v0=i/cols,j/rows\n verts.append(fn(u0,v0))\n uv.append((u0,v0))\n for j in range(rows):\n for i in range(cols):\n a,b=j*count+i,j*count+(i+1)%count\n faces.append((a,b,b+count,a+count))\n if caps:\n faces.extend([tuple(reversed(range(count))),tuple(range(rows*count,(rows+1)*count))])\n return mesh(name,verts,faces,mat,uv,flip,caps)\n\n\ndef sphere(name,loc,scales,m,seg=36,rings=24,rot=None):\n bpy.ops.mesh.primitive_uv_sphere_add(segments=seg,ring_count=rings,location=loc)\n ob=bpy.context.object\n ob.scale=scales\n if rot:\n ob.rotation_euler=rot\n return register(ob,name,m)\n\n\ndef point(p,z):\n i=next((n for n in range(len(p)-1) if z<=p[n+1][0]),len(p)-2)\n prev,a,b,nxt=p[max(0,i-1)],p[i],p[i+1],p[min(i+2,len(p)-1)]\n span=b[0]-a[0]\n t=max(0,min(1,(z-a[0])/span))\n return tuple((2*t**3-3*t*t+1)*a[k]+(t**3-2*t*t+t)*span*(b[k]-prev[k])/(b[0]-prev[0])+\n (-2*t**3+3*t*t)*b[k]+(t**3-t*t)*span*(nxt[k]-a[k])/(nxt[0]-a[0]) for k in range(1,len(a)))\n\n\ndef tube(name,points,radii,mat,sides=12,squash=1):\n pts=list(map(Vector,points))\n verts,faces,uv=[],[],[]\n frames=[]\n for i,pt in enumerate(pts):\n direction=(pts[min(len(pts)-1,i+1)]-pts[max(0,i-1)]).normalized()\n ref=Vector((0,0,1)) if abs(direction.z)<.92 else Vector((0,1,0))\n sideways=direction.cross(ref).normalized()\n up=sideways.cross(direction).normalized()\n frames.append((sideways,up))\n r=radii(i/(len(pts)-1)) if callable(radii) else radii\n for j in range(sides):\n a=tau*j/sides\n verts.append(pt+r*(math.cos(a)*sideways+squash*math.sin(a)*up))\n uv.append((j/sides,i/(len(pts)-1)))\n for i in range(len(pts)-1):\n for j in range(sides):\n k=(j+1)%sides\n faces.append((i*sides+j,i*sides+k,(i+1)*sides+k,(i+1)*sides+j))\n faces.extend([tuple(reversed(range(sides))),tuple(range(len(verts)-sides,len(verts)))])\n return mesh(name,verts,faces,mat,uv,closed=True)\n\n\ndef bent_points(a,b,bow,n):\n a,b,offset=Vector(a),Vector(b),Vector(bow)\n return [a.lerp(b,t)+math.sin(math.pi*t)*offset for t in np.linspace(0,1,n)]\n\n\ndef spindle(name,a,b,width,m,bow=(0,0,0),power=.72,tip=.24,squash=.87,n=20,sides=16):\n def contour(t):\n return width*(tip+(1-tip)*math.sin(math.pi*t)**power)\n return tube(name,bent_points(a,b,bow,n),contour,m,sides,squash)\n\n\ndef span(p,a,b,m,r=.06):\n return tube(p,[a,(Vector(a)+Vector(b))*.5,b],lambda t:r*(1-.88*t),m,8,.93)\n\n\nely_profile=[\n (-5.34,3.90,6.53,2.36),(-4.88,4.72,7.19,2.66),(-3.76,5.33,7.78,2.92),\n (-1.85,5.50,8.08,3.04),(.50,5.46,8.00,3.12),(3.4,5.24,7.67,3.13),\n (6.4,4.70,7.19,2.97),(9.6,3.85,6.66,2.61),(12.5,2.67,6.06,2.04),\n (14.7,1.72,5.44,1.55),(16.37,.91,4.84,1.03),(17.54,.22,4.20,.42),\n (17.81,.025,3.99,.17)\n]\n\n\ndef wing(s,u,t):\n y=-5.34+23.15*t\n w,z,bend=point(ely_profile,y)\n a=u*1.97\n ridge=.044*(.5+.5*math.cos(tau*(11.6*u+.074*math.sin(t*8))))**8\n jitter=.025*math.sin(22*y+s*2)*math.sin(17*a)\n x=(.061+w*math.sin(a)+.018*math.sin(y*.9))*s\n y-=.66*math.sin(math.pi*u)**1.1*(1-t)**5\n z-=bend*(1-math.cos(a)) + ridge*math.sin(math.pi*t)**.43\n z+=jitter+.029*s*math.sin(y*.66)\n return x,y,z\n\n\nabd=[(-5.8,3.92,3.72,1.44),(-3.0,4.82,3.81,1.65),(1.8,5.03,3.84,1.89),\n (6.4,4.42,3.72,1.75),(10.9,3.31,3.63,1.39),(14.5,1.64,3.63,.96),(17.71,.15,3.90,.16)]\ndef body(u,v):\n y=-5.80+23.51*v\n w,c,h=point(abd,y)\n a=u*tau\n band=.095*math.cos((y-1.55)*3.02+.25*math.sin(a)) * math.sin(math.pi*v)\n return (w*math.sin(a),y,c+(h+band)*math.cos(a))\nsurface(\"Abdomen | overlapping ventral segments\",body,under,136,86,True,True)\nfor s,name in [(-1,\"Right\"),(1,\"Left\")]:\n el=surface(name+\" elytron\",lambda u,v,s=s:wing(s,u,v),elytron,240,112,flip=s<0)\n mod=el.modifiers.new(\"Real shell section\",\"SOLIDIFY\")\n mod.thickness=.103\n mod.offset=-1\n pts=[]\n for t in np.linspace(.018,.976,110):\n x,y,z=wing(s,.981,float(t))\n pts.append((x*.998,y,z+.025))\n tube(name+\" fine lateral elytral lip\",pts,lambda t:.026+.046*math.sin(math.pi*t)**.48,green_joint,10)\n pts=[wing(s,.005,float(t)) for t in np.linspace(.035,.956,100)]\n tube(name+\" sutural ridge\",pts,lambda t:.018+.038*math.sin(math.pi*t)**.58,green_joint,9,.78)\n\nthorax=[(-12.95,2.48,5.18,1.21),(-12.38,3.25,5.44,1.65),(-11.11,3.92,5.54,1.83),\n (-9.11,4.79,5.51,2.00),(-7.11,5.11,5.47,2.08),(-5.22,4.89,5.29,1.88),(-4.76,3.93,5.1,1.54)]\ndef pro(u,v):\n a=tau*u\n y=-12.95+8.19*v\n w,c,h=point(thorax,y)\n x=w*math.sin(a)\n z=c+h*math.cos(a)-.24*(math.cos(a)**6)*math.sin(math.pi*v)**2\n y+=.59*math.cos(a)**2*math.sin(a)**2*(2*v-1)\n return x,y,z\nsurface(\"Pronotum | rounded dorsal shield\",pro,shield,125,168,True,True)\nfor s in (-1,1):\n points=[]\n for v0 in np.linspace(.045,.99,75):\n x,y,z=pro(.244 if s>0 else .756,float(v0))\n points.append((x*1.007,y,z+.024))\n tube(\"Pronotal lateral carina\",points,lambda t:.043+.077*math.sin(math.pi*t),gold_joint,10)\n\n# Small raised triangular scutellum at the wing hinge.\nverts=[(-.63,-5.50,7.17),(.64,-5.49,7.18),(.28,-4.68,7.42),(0,-4.05,7.60),\n (-.28,-4.66,7.42),(0,-5.20,7.63),(-.43,-5.23,7.27),(.43,-5.23,7.27)]\nob=mesh(\"Scutellum at elytral hinge\",verts,[(0,6,5),(0,5,1),(1,5,7),(7,5,2),(2,5,3),(3,5,4),(4,5,6)],scutellum)\nm=ob.modifiers.new(\"Cuticle thickness\",\"SOLIDIFY\")\nm.thickness=.13\n\nhead=[(-17.41,.68,3.82,.45),(-17.06,1.63,4.09,.93),(-16.25,2.55,4.45,1.32),\n (-15.30,3.01,4.74,1.31),(-14.18,3.18,4.88,1.34),(-13.15,2.87,4.90,1.33),(-12.17,2.29,4.97,1.25)]\ndef face(u,v):\n a=tau*u\n y=-17.41+5.24*v\n w,c,h=point(head,y)\n x=w*math.sin(a)\n z=c+h*math.cos(a)-.18*max(0,math.cos(a))**5 * (.6+.4*math.sin(math.pi*v))\n return x,y,z\nsurface(\"Head capsule | frons and clypeus\",face,shield,102,126,True,True)\nsphere(\"Collar membrane\",(0,-12.80,4.45),(2.71,1.36,1.48),membrane)\n\nfor s in (-1,1):\n side=\"Left\" if s>0 else \"Right\"\n sphere(side+\" compound eye\",(s*2.68,-14.39,4.76),(.91,1.62,1.32),eye,96,66,(.10,s*.17,s*.13))\n sphere(side+\" basal antennal socket\",(s*1.92,-16.39,4.32),(.45,.45,.37),gold_joint)\n spindle(side+\" incurved mandible\",(s*1.14,-16.92,3.92),(s*.17,-18.01,3.56),.46,mouth,(s*.29,-.10,-.03),tip=.10,n=28,sides=18)\n spindle(side+\" maxillary palp base\",(s*1.55,-16.35,3.55),(s*1.27,-17.60,3.08),.21,green_joint,(s*.13,0,-.02))\n spindle(side+\" maxillary palp tip\",(s*1.27,-17.60,3.08),(s*.74,-18.18,3.11),.138,mouth,(s*.04,0,-.02))\n outer=.17 if s>0 else -.19\n stations=[(s*1.95,-16.45,4.33),(s*2.85,-17.45,4.20),(s*3.24,-17.84,4.31),\n (s*3.98,-18.58,4.24),(s*4.62,-19.13,4.19),(s*5.26,-19.66,4.20+outer),\n (s*5.99,-20.04,4.24+outer),(s*6.69,-20.33,4.35+outer),(s*7.36,-20.44,4.38+outer),\n (s*8.03,-20.45,4.45+outer),(s*8.63,-20.39,4.40+outer),(s*9.24,-20.29,4.28+outer)]\n for i,(a,b) in enumerate(zip(stations,stations[1:])):\n dir=(Vector(b)-Vector(a)).normalized()\n spanvec=Vector((-dir.y,dir.x,0))*s\n start=Vector(a)+dir*.037\n end=Vector(b)-dir*.041\n if i<3:\n spindle(side+\" antenna basal segment \"+str(i+1),start,end,.24-.027*i,antenna,tip=.49,n=12,sides=14)\n else:\n def blade(t):\n return .101+(.125 if i<10 else .078)*math.sin(math.pi*t)**.65\n pts=[start.lerp(end,t)+spanvec*.13*math.sin(math.pi*t)**2*t for t in np.linspace(0,1,16)]\n tube(side+\" serrated flagellum \"+str(i+1),pts,blade,antenna,14,.62)\n if i<10:\n q=start.lerp(end,.67)\n span(side+\" flagellar tooth\",q,q+spanvec*.39+dir*.08,antenna,.16)\n if i:\n sphere(side+\" antenna joint\",a,(.104,.122,.095),membrane,16,10)\n\n# Front, middle and hind legs in a low, asymmetrical resting posture.\nlegs=[\n ((3.22,-10.96,3.64),(6.82,-12.4,3.12),(9.61,-15.07,1.17),(12.21,-16.24,.31)),\n ((3.83,-7.19,3.62),(7.67,-7.66,3.13),(11.07,-7.45,.97),(14.13,-7.78,.29)),\n ((3.88,-3.43,3.15),(7.64,1.07,3.05),(10.55,4.32,1.06),(13.27,6.10,.25))\n]\nfor s in (-1,1):\n side=\"Left\" if s>0 else \"Right\"\n for i,(ha,kn,an,to) in enumerate(legs):\n name=side+\" \"+(\"fore\",\"mid\",\"hind\")[i]+\" leg\"\n asym=(.37,.51,-.94)[i] if s<0 else 0\n hip,knee,ankle,toe=[Vector((s*(pt[0]+(.38 if s<0 and 1\nLOOK\nA potted prayer plant seen from slightly above. Broad round leaves with bold silver-white stripes across green, on long thin upright stems from the center. One pale new leaf is still rolled up in the middle. Tapered, unglazed terracotta pot with dark soil, bark chips and perlite on top.\n\nSCALE\nAbout 80 cm wide, 75 cm tall, 82 cm deep. Build in meters, +Y up, +Z forward, origin at the base center of the pot.\n\nPARTS\n1. Pot: tapered terracotta vessel with a rounded rim bead, inner wall, hollow interior and a perforated foot. Build: lathe a profile.\n2. Potting mix: uneven recessed soil with bark chips and perlite grit. Build: a displaced disk plus scattered debris pieces.\n3. Petioles: long thin stems from the crown. The young ones stand upright and the outer ones arch outward. Build: tubes along bezier paths.\n4. Leaves: each mature leaf has its own direction, reach, attachment height, length, width, raise, twist and tip droop. Silver-striped on top, sage underneath. Build: one leaf builder driven by those parameters, plus raised midrib and vein relief.\n5. Unfurling leaf: one pale leaf still rolled into a soft tube at the crown. Build: leaf mesh rolled around its own axis.\n6. Basal sheaths: new-leaf and dry outer sheaths where the stems leave the soil. Build: short wrapped tubes.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the pot base.\n2. Texture maps: generated inside orbifolia.py. Silver stripe pattern for the upper leaf, muted underside, bark, soil and terracotta textures.\n3. Build order: pot, soil with bark and perlite, leaves with their petioles, unfurling leaf, sheaths, rib and vein relief.\n4. Assemble: every petiole starts at the crown in the soil, blades attach at the petiole tips with independent orientation. Batch each leaf's rib relief into that leaf.\n5. Materials: silver-green upper lamina, sage lower lamina, sap-green and olive petioles, yellow-green midribs, pale new leaf, dry sheath, soil, bark, perlite, unglazed terracotta.\n6. Export: plant and pot only, one GLB with the textures embedded.\n\nCHECK\n561,200 triangles across 128 parts. Against the image: the leaf spread is several times the pot width, inner leaves stand taller than outer ones, the rolled leaf sits dead center.\n\n\n```python\n# orbifolia.py\n\"\"\"Original life-size procedural Goeppertia orbifolia in a thrown clay pot.\"\"\"\nimport argparse\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Vector\nimport numpy as np\n\nap=argparse.ArgumentParser()\nap.add_argument(\"--output\",type=Path,required=True)\nap.add_argument(\"--draft\",action=\"store_true\")\nargs=ap.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261126T2100Z-plants-silver-striped-prayer-plant\"\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\nrng=np.random.default_rng(6871)\nparts=[]\ntau=math.tau\n\n\ndef srgb(h):\n values=[int(h[i:i+2],16)/255 for i in (0,2,4)]\n return tuple(c/12.92 if c<=.04045 else ((c+.055)/1.055)**2.4 for c in values)\n\n\ndef material(name,h,rough,coat=0):\n mat=bpy.data.materials.new(name)\n mat.diffuse_color=(*srgb(h),1)\n mat.use_nodes=True\n bs=mat.node_tree.nodes.get(\"Principled BSDF\")\n bs.inputs[\"Base Color\"].default_value=mat.diffuse_color\n bs.inputs[\"Roughness\"].default_value=rough\n bs.inputs[\"Coat Weight\"].default_value=coat\n bs.inputs[\"Coat Roughness\"].default_value=.35\n return mat\n\n\ndef image(name,rgb,space):\n h,w=rgb.shape[:2]\n a=np.concatenate((rgb,np.ones((h,w,1),dtype=np.float32)),axis=-1)\n im=bpy.data.images.new(name,width=w,height=h,alpha=False)\n im.colorspace_settings.name=space\n im.pixels.foreach_set(np.ascontiguousarray(a,dtype=np.float32).ravel())\n im.file_format=\"PNG\"\n im.filepath_raw=str(out/(name+\".png\"))\n im.save()\n im.reload()\n im.colorspace_settings.name=space\n return im\n\n\ndef gray(a):\n return np.repeat(a[:,:,None],3,axis=2)\n\n\ndef map_to(mat,img,socket,normal=None):\n nt=mat.node_tree\n img_node=nt.nodes.new(\"ShaderNodeTexImage\")\n img_node.image=img\n target=nt.nodes.get(\"Principled BSDF\").inputs[socket]\n if normal is None:\n nt.links.new(img_node.outputs[\"Color\"],target)\n else:\n node=nt.nodes.new(\"ShaderNodeNormalMap\")\n node.inputs[\"Strength\"].default_value=normal\n nt.links.new(img_node.outputs[\"Color\"],node.inputs[\"Color\"])\n nt.links.new(node.outputs[\"Normal\"],target)\n\n\ndef noise(u,v,cols,rows):\n x,y=u*cols,v*rows\n i,j=np.floor(x).astype(int),np.floor(y).astype(int)\n fracx,fracy=x-i,y-j\n mx=fracx*fracx*(3-2*fracx)\n my=fracy*fracy*(3-2*fracy)\n sample=rng.uniform(-1,1,(rows,cols)).astype(np.float32)\n a=sample[j%rows,i%cols]*(1-mx)+sample[j%rows,(i+1)%cols]*mx\n b=sample[(j+1)%rows,i%cols]*(1-mx)+sample[(j+1)%rows,(i+1)%cols]*mx\n return a*(1-my)+b*my\n\n\ndef smooth(x,a,b):\n s=np.clip((x-a)/(b-a),0,1)\n return s*s*(3-2*s)\n\n\ndef normal_rgb(z,ax,ay):\n dx=(np.roll(z,-1,axis=1)-np.roll(z,1,axis=1))*ax\n dy=(np.roll(z,-1,axis=0)-np.roll(z,1,axis=0))*ay\n w=np.sqrt(1+dx*dx+dy*dy)\n return np.stack((.5-.5*dx/w,.5-.5*dy/w,.5+.5/w),axis=-1)\n\n\ndef rgb_blend(a,b,t):\n return np.array(a)*(1-t[:,:,None])+np.array(b)*t[:,:,None]\n\n\ndef leaf_texture(k,N=1024):\n v,u=np.mgrid[:N,:N].astype(np.float32)/(N-1)\n p=np.abs(2*u-1)\n jitter=noise(u,v,16,20)*.006+noise(u,v,82,94)*.002\n sweep=(.034+.106*np.sin(math.pi*(.15+.89*v)))*p**1.46\n asym=.018*np.sin(v*11+k)*np.sign(u-.5)*p\n phase=(v-sweep+asym+jitter)*10.65+.13*np.sin(tau*v+.7*k)+.067*k\n wave=np.cos(tau*(phase+.058))\n silver=smooth(wave,-.42,.79)*(.91-.079*np.cos(12*v+k))\n silver*=smooth(p,.013,.071)\n silver*=1-smooth(p,.944,.987)*.94\n modulation=.031*noise(u,v,27,20)+.019*noise(u,v,106,131)+.017*noise(u,v,359,339)\n vein=np.exp(-(np.sin(math.pi*phase)/.095)**2)*smooth(p,.014,.09)\n sub=np.exp(-(np.sin(math.pi*(phase*2.93+p*.59))/.152)**2)\n cross=1-(.33+.13*np.cos(p*24-v*37))*sub\n top=rgb_blend([.207+.012*k,.354+.009*k,.184+.005*k],\n [.515+.012*k,.625+.008*k,.439+.014*k],silver)\n top+=modulation[:,:,None]*np.array([.85,1,.65])\n top-=((vein*.054+sub*.009)*cross)[:,:,None]*np.array([.54,1,.65])\n # A narrow pale midrib and scattered age spots near a few margins.\n mid=np.exp(-(p/(.018-.010*v))**2)\n top=top*(1-mid[:,:,None]*.7)+np.array([.51,.59,.344])*mid[:,:,None]*.7\n vein_green=smooth(np.exp(-(np.sin(math.pi*(phase-.018))/.119)**2),.28,.9)\n top+=vein_green[:,:,None]*np.array([.020,.025,.014])\n edge=smooth(p+.018*noise(u,v,87,43),.982,.998)\n top=top*(1-edge[:,:,None]*.55)+np.array([.26,.35,.15])*edge[:,:,None]*.55\n if k in (1,3):\n spot=np.zeros_like(u)\n for side,center,height in [(1,.20,.068),(-1,.51,.015),(1,.84,.026),(-1,.76,.020)]:\n side_mask=(u>.5) if side==1 else (u<.5)\n mark=np.clip((p-.88+.017*noise(u,v,40,75))*14,0,1)*np.exp(-((v-center)/height)**2)\n spot=np.maximum(spot,mark*side_mask)\n tip=smooth(v+.018*noise(u,v,35,68),.968,.998)*(.6 if k==3 else .3)\n spot=np.maximum(spot,tip)\n top=top*(1-spot[:,:,None]*.75)+np.array([.38,.245,.114])*spot[:,:,None]*.75\n else:\n spot=np.zeros_like(u)\n underside=rgb_blend([.276,.392,.244],[.453,.544,.377],silver*.69)\n underside+=modulation[:,:,None]*.77+(vein*.039+mid*.11)[:,:,None]\n cellular=noise(u,v,120,163)*.016+noise(u,v,502,437)*.016\n bump=mid*.10+vein*.052+sub*.014+cellular-.050*spot\n rough=.43-.046*silver+.035*noise(u,v,36,26)+.13*spot+.043*sub\n return np.clip(top,0,1),np.clip(underside,0,1),gray(rough),normal_rgb(bump,9.1,7.0)\n\n\ntiles=[leaf_texture(i) for i in range(4)]\npacks=[]\nfor m in range(4):\n rows=[np.concatenate([np.pad(tiles[k][m],((12,12),(12,12),(0,0)),mode=\"edge\")\n for k in (2*j,2*j+1)],axis=1) for j in range(2)]\n packs.append(np.concatenate(rows,axis=0))\ntops=image(\"Leaf_Upper_BaseColor\",packs[0],\"sRGB\")\nbacks=image(\"Leaf_Lower_BaseColor\",packs[1],\"sRGB\")\nrough=image(\"Leaf_Roughness\",packs[2],\"Non-Color\")\nnormal=image(\"Leaf_Normal\",packs[3],\"Non-Color\")\nadax=material(\"Upper leaf | silver-green lamina\",\"70915A\",.43,.15)\nabax=material(\"Lower leaf | muted sage lamina\",\"657F58\",.56,.05)\nmap_to(adax,tops,\"Base Color\")\nmap_to(abax,backs,\"Base Color\")\nmap_to(adax,rough,\"Roughness\")\nmap_to(adax,normal,\"Normal\",.59)\nmap_to(abax,normal,\"Normal\",.32)\nfor plant_mat in (adax,abax):\n bs=plant_mat.node_tree.nodes.get(\"Principled BSDF\")\n bs.inputs[\"Subsurface Weight\"].default_value=.028\n bs.inputs[\"Subsurface Radius\"].default_value=(.32,.57,.25)\n\npetiole=material(\"Petiole | young sap green\",\"789856\",.49,.11)\npetiole_deep=material(\"Petiole | mature olive green\",\"527437\",.51,.10)\nvein_col=material(\"Leaf raised midrib | yellow-green\",\"8EA35E\",.48,.10)\npale=material(\"New leaf and basal sheath\",\"ADBF76\",.53,.08)\npapery=material(\"Dry outer sheath\",\"9B7751\",.69)\nloam=material(\"Potting soil\",\"46382B\",.91)\nbark=[material(\"Bark | \"+str(k),h,.83) for k,h in enumerate((\"4D3423\",\"654731\",\"775038\",\"352620\"))]\nperlite=material(\"Perlite granules\",\"C9C8B6\",.83)\n\nN=1024\ny,x=np.mgrid[:N,:N].astype(np.float32)/(N-1)\ndiv=noise(x,y,75,80)*.041+noise(x,y,185,191)*.023+noise(x,y,490,501)*.019\nlarge=noise(x,y,13,8)+noise(x,y,23,20)*.55\nband=.61+.147*np.sin(tau*(14*y+.28*noise(x,y,18,17)))+.053*np.sin(tau*123*y)\nbloom=np.clip((large-.24)*.44,0,.5)*(.72-.66*np.sin(math.pi*y)**3)+.064*smooth(band,.65,.98)\nclay=rgb_blend([.544,.260,.148],[.76,.55,.395],bloom)+div[:,:,None]\nclay+=(band-.55)[:,:,None]*np.array([.122,.102,.074])\nclay_rough=.728+.17*bloom+.051*noise(x,y,155,163)\nclay_normal=normal_rgb(.145*band+.45*div+.051*noise(x,y,301,351),5.4,3.5)\npotmat=material(\"Unglazed terracotta | fired clay and mineral bloom\",\"A55E41\",.72,.025)\nmap_to(potmat,image(\"Terracotta_BaseColor\",np.clip(clay,0,1),\"sRGB\"),\"Base Color\")\nmap_to(potmat,image(\"Terracotta_Roughness\",gray(clay_rough),\"Non-Color\"),\"Roughness\")\nmap_to(potmat,image(\"Terracotta_Normal\",clay_normal,\"Non-Color\"),\"Normal\",.58)\nearth=noise(x,y,57,61)*.49+noise(x,y,149,158)*.25+noise(x,y,422,387)*.17\nsoil=rgb_blend([.208,.145,.099],[.405,.338,.260],smooth(earth,-.46,.56))\nmap_to(loam,image(\"Loam_BaseColor\",soil,\"sRGB\"),\"Base Color\")\nmap_to(loam,image(\"Loam_Normal\",normal_rgb(earth*.24,5,5),\"Non-Color\"),\"Normal\",.83)\n\n\ndef register(obj,name,m,smooth=True,keep=True):\n obj.name=name\n obj.data.materials.append(m)\n if smooth:\n for f in obj.data.polygons:\n f.use_smooth=True\n if keep:\n parts.append(obj)\n return obj\n\n\ndef mesh(name,vertices,faces,m,uvs=None,wrap=False,cap=False,smooth=True):\n d=bpy.data.meshes.new(name)\n d.from_pydata(vertices,[],faces)\n d.update()\n if uvs is not None:\n layer=d.uv_layers.new(name=\"UVMap\")\n for f in d.polygons:\n seam=wrap and len(f.vertices)<5 and max(uvs[i][0] for i in f.vertices)-min(uvs[i][0] for i in f.vertices)>.85\n for li in f.loop_indices:\n x,y=uvs[d.loops[li].vertex_index]\n layer.data[li].uv=(x+int(seam and x<.1),y)\n if cap:\n bm=bmesh.new()\n bm.from_mesh(d)\n bmesh.ops.recalc_face_normals(bm,faces=bm.faces[:])\n bm.to_mesh(d)\n bm.free()\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n return register(ob,name,m,smooth)\n\n\ndef grid(name,fn,m,rows,cols,wrap=False,uvfn=None):\n verts,faces,uv=[],[],[]\n count=cols if wrap else cols+1\n for j in range(rows+1):\n for i in range(count):\n uu,vv=i/cols,j/rows\n verts.append(fn(uu,vv))\n uv.append(uvfn(uu,vv) if uvfn else (uu,vv))\n for j in range(rows):\n for i in range(cols):\n a,b=j*count+i,j*count+(i+1)%count\n faces.append((a,b,b+count,a+count))\n return mesh(name,verts,faces,m,uv,wrap)\n\n\ndef polyline(name,pts,r,m,n=10,squash=1):\n ps=list(map(Vector,pts))\n vertices,faces=[],[]\n for i,p in enumerate(ps):\n t=i/(len(ps)-1)\n tangent=(ps[min(i+1,len(ps)-1)]-ps[max(i-1,0)]).normalized()\n ref=Vector((0,0,1)) if abs(tangent.z)<.92 else Vector((0,1,0))\n across=tangent.cross(ref).normalized()\n up=across.cross(tangent).normalized()\n rad=r(t) if callable(r) else r\n for j in range(n):\n a=tau*j/n\n vertices.append(p+rad*(across*math.cos(a)+squash*up*math.sin(a)))\n for i in range(len(ps)-1):\n for j in range(n):\n q=(j+1)%n\n faces.append((i*n+j,i*n+q,(i+1)*n+q,(i+1)*n+j))\n faces.extend([tuple(reversed(range(n))),tuple(range(len(vertices)-n,len(vertices)))])\n return mesh(name,vertices,faces,m,cap=True)\n\n\ndef bezier(a,b,c,d,t):\n t=float(t)\n return (1-t)**3*a+3*(1-t)**2*t*b+3*(1-t)*t*t*c+t**3*d\n\n\ndef lathe(profile,n=188):\n vertices,faces,uv=[],[],[]\n for r,z in profile:\n for i in range(n):\n a=tau*i/n\n slop=(.060*math.cos(3*a+z*.19)+.021*math.sin(13*a+.38*z))*min(r/4,1)\n vertices.append(((r+slop)*math.cos(a),(r+slop)*math.sin(a),z))\n uv.append((i/n,z/23.2))\n for j in range(len(profile)):\n k=(j+1)%len(profile)\n for i in range(n):\n h=(i+1)%n\n faces.append((j*n+i,j*n+h,k*n+h,k*n+i))\n return mesh(\"Wheel-thrown tapered terracotta vessel\",vertices,faces,potmat,uv,True,True)\n\n\n# True hollow planter, rounded throwing bead, inner wall and perforated foot.\nprofile=[(1.03,0),(8.75,0),(9.15,.045),(9.35,.16),(9.42,.45),(9.43,.83),\n (9.57,1.00),(10.03,1.03),(10.20,1.22),(10.38,2.0)]\nfor z in np.linspace(2.2,20.35,46):\n r=10.35+(z-2)*.161+.95*math.sin((z-2)/18.35*math.pi*.49)\n r+=.028*math.sin(z*16.0)+.023*math.sin(z*33.7)\n profile.append((float(r),float(z)))\nprofile += [(14.35,20.61),(14.48,20.75),(14.85,20.82),(15.06,20.99),\n (15.14,21.22),(15.13,22.63),(15.02,22.94),(14.87,23.16),\n (14.55,23.22),(14.14,23.18),(13.93,23.01),(13.87,22.83),\n (13.78,21.14),(13.60,20.66),(13.42,20.32),(13.20,19.67),\n (12.34,16.70),(11.61,13.19),(10.92,9.92),(10.22,6.57),\n (9.63,3.47),(9.21,2.40),(8.84,1.92),(7.41,1.63),(3.30,1.44),\n (1.07,1.35),(.96,1.19),(.96,.18)]\nlathe(profile)\n\n\ndef ground(u,v):\n a=tau*u\n r=.003+13.57*v\n x,y=r*math.cos(a),r*math.sin(a)\n z=20.48+.19*math.sin(3*a+v*6.4)*v+.115*math.sin(x*.67+y*.89)+.13*math.cos(y*.61-x*1.21)-.12*v*v\n return x,y,z\nsoil_disc=grid(\"Uneven recessed potting mix\",lambda u,v:ground(1-u,v),loam,44,125,True)\nsoil_disc.modifiers.new(\"Soil backing\",\"SOLIDIFY\").thickness=.25\n\n\ndef debris(name,positions,m):\n vertices,faces=[],[]\n for x,y,z,r,k in positions:\n a=rng.uniform(0,tau)\n dx,dy=math.cos(a),math.sin(a)\n # Six-sided irregular chips with fractured profiles across both surfaces.\n n=len(vertices)\n for layer in (0,1):\n for i in range(6):\n t=tau*i/6\n rr=rng.uniform(.72,1.21)*r\n xx=rr*math.cos(t)\n yy=k*rr*math.sin(t)\n vertices.append((x+dx*xx-dy*yy,y+dy*xx+dx*yy,z+r*(.27 if layer else -.18)+r*.2*rng.uniform(-1,1)))\n for i in range(6):\n j=(i+1)%6\n faces.append((n+i,n+j,n+6+j,n+6+i))\n faces += [tuple(n+j for j in range(5,-1,-1)),tuple(n+6+j for j in range(6))]\n return mesh(name,vertices,faces,m,cap=True,smooth=False)\n\n\nfor k in range(5):\n arr=[]\n for j in range(130 if k<4 else 74):\n r=12.9*math.sqrt(rng.uniform(0,1))\n a=rng.uniform(0,tau)\n x,y,z=ground(a/tau,r/13.57)\n width=rng.uniform(.09,.72) if k<4 else rng.uniform(.086,.28)\n arr.append((x,y,z+.065,width,rng.uniform(.38,.82)))\n debris(\"Perlite grit\" if k==4 else \"Fractured bark batch \"+str(k+1),arr,perlite if k==4 else bark[k])\n\n# Direction, base reach, attachment height, length, full width, raise, twist,\n# tip drop, UV variant. Blade orientations are independent of the petioles.\n# The more upright center leaves are younger and the lower pair arch outward.\nleaves=[\n (-102,13.3,41.2,30.7,26.2,5.6,-.21,6.2,0),\n (-43,14.6,38.0,28.0,24.2,4.9,.17,7.8,1),\n (-161,13.9,45.5,30.2,26.8,4.5,.18,5.1,2),\n (20,11.4,48.6,28.1,22.7,9.5,-.21,6.1,0),\n (99,11.0,53.5,28.3,22.6,10.6,.25,4.2,1),\n (163,12.6,57.8,28.0,24.0,10.2,-.17,3.6,3),\n (-71,10.4,57.2,29.7,24.3,7.7,.18,5.8,2),\n (-9,8.4,61.1,28.3,21.0,9.0,-.22,5.7,3),\n (60,6.3,58.6,25.2,19.6,14.2,.12,4.1,2),\n (137,5.3,63.0,23.9,17.6,13.5,.24,3.4,0),\n (-140,7.8,64.8,26.0,20.7,10.4,-.20,5.0,1),\n (-107,9.4,32.0,22.3,18.4,3.2,-.11,7.4,3),\n (4,13.3,34.8,24.6,21.1,4.4,.26,4.9,2),\n (64,14.1,42.6,24.9,21.9,5.7,-.16,5.7,1),\n (-123,8.4,43.2,23.9,19.4,9.2,.12,4.1,3),\n (-17,5.5,43.9,20.8,18.1,11.3,-.24,3.2,0),\n]\n\n\ndef uv_atlas(u,v,k):\n tile=1048\n scale=2096\n return ((12.5+(k%2)*tile+1023*u)/scale,(12.5+(k//2)*tile+1023*v)/scale)\n\n\ndef build_leaf(i,spec):\n adeg,reach,h,length,width,raise_,twist,drop,k=spec\n az=math.radians(adeg)\n forward=Vector((math.cos(az),math.sin(az),0))\n across=Vector((-forward.y,forward.x,0))\n lateral=.97*math.sin(2.1*i)\n anchor=forward*reach+across*lateral+Vector((0,0,h))\n base=forward*rng.uniform(1.2,4.5)+across*rng.uniform(-1.1,1.1)+Vector((0,0,20.35))\n start=base+forward*1.6+Vector((0,0,(h-20)*.28))\n end=anchor-forward*(reach*.31)-Vector((0,0,(h-20)*.26))\n pts=[bezier(base,start,end,anchor,t) for t in np.linspace(0,1,53)]\n n=\"Leaf %02d\"%(i+1)\n polyline(n+\" petiole\",pts,lambda t:.135+.21*(1-t)**.60+.086*math.sin(math.pi*min(1,t/.17))*(t<.17),\n petiole_deep if i in (1,5,11,12,13) else petiole,14,.93)\n pt=pts[-5]\n polyline(n+\" pulvinus\",[pt.lerp(anchor,t)+Vector((0,0,.20*math.sin(math.pi*t))) for t in np.linspace(0,1,17)],\n lambda t:.147+.16*math.sin(math.pi*t)**.53,pale,14)\n for dry in (True,False) if i%3==0 else (False,):\n offset=-.19 if dry else .15\n def sheath(u,v):\n dist=3.7 if dry else 6.8+math.sin(i)*.9\n t=v*dist/max(10,h-20)\n p=bezier(base,start,end,anchor,t)\n a=(u-.5)*(4.75-2.8*v)\n r=.39+.16*math.sin(math.pi*v)-.17*v\n return p+forward*(r*math.cos(a)+offset)+across*(r*math.sin(a))+Vector((0,0,.10+.17*math.sin(3*u)))\n grid(n+(\" dry basal sheath\" if dry else \" inner basal sheath\"),sheath,papery if dry else pale,21,24)\n phase=.90*i\n def pos(u,v):\n q=2*u-1\n p=abs(q)\n # Broad ovate shape, near-round shoulder, slightly unequal margins.\n s=max(.001,math.sin(math.pi*v**.83))\n span=(width*.5)*(s**(.73+.035*math.sin(i)))*(.992+.054*math.sin(2.17*i+v*7.8)*q)\n uneven=(.13*math.sin(v*36.9+phase)+.059*math.sin(v*81.1+q+phase))*p**4*s\n flank=span*q + uneven\n length_z=raise_*v+(.9+1.27*math.sin(i+1))*math.sin(math.pi*v)-drop*v**3.9\n fold=span*(twist*q*(.41+.69*v)+(.15+.059*math.sin(phase+v*6))*p**1.38)\n effective=(v-(.034+.106*math.sin(math.pi*(.15+.89*v)))*p**1.46+\n .018*math.sin(v*11+k)*math.copysign(p,q))*10.65+.13*math.sin(tau*v+.7*k)+.067*k\n single=(.081+.006*i)*math.cos(tau*effective)*s*p**.79\n recurved=(.116+.178*math.sin(19*v+phase+1.4*q))*p**6*s\n minor=.051*math.cos(143*v+4*q+phase)*math.sin(q*16+v*33)\n z=length_z+fold+single+recurved+minor\n if i in (0,11):\n z-=.91*p**3*s**.8\n xy=anchor+forward*(length*v)+across*(flank+.96*math.sin(v*math.pi)*math.sin(i*1.44))\n return xy+Vector((0,0,z))\n\n lamina=grid(n+\" orbicular lamina\",lambda u,v:pos(1-u,v),adax,88,62,uvfn=lambda u,v:uv_atlas(1-u,v,k))\n lamina.data.materials.append(abax)\n sh=lamina.modifiers.new(\"Thin lower lamina\",\"SOLIDIFY\")\n sh.thickness=.041\n sh.offset=-1\n sh.material_offset=1\n sh.material_offset_rim=1\n pts=[pos(.5002,t)+Vector((0,0,.034)) for t in np.linspace(.012,.971,62)]\n polyline(n+\" upper midrib\",pts,lambda t:.104*(1-t)**.90+.013,vein_col,9,.64)\n pts_under=[pos(.5002,t)+Vector((0,0,-.047)) for t in np.linspace(.020,.955,55)]\n polyline(n+\" lower midrib\",pts_under,lambda t:.15*(1-t)**1.01+.016,pale,9,.69)\n # Several short low-relief secondary veins near petiole attachment.\n for j in range(2,6):\n t0=(j-.10*k)/10.65\n for side in (-1,1):\n pts=[]\n for s in np.linspace(.045,.87,21):\n t=t0+(.034+.106*math.sin(math.pi*(.15+.89*t0)))*s**1.46-.007\n point=pos(.5+.5*side*s,t)+Vector((0,0,.024))\n pts.append(point)\n polyline(n+\" rib relief \"+str(j),pts,lambda t:.023*(1-t)**.65+.007,vein_col,6,.49)\n\n\nfor i,spec in enumerate(leaves):\n build_leaf(i,spec)\n\n# One pale leaf is still unrolling from a soft tube on the crown.\nbase=Vector((1.7,-1.2,20.1))\nanchor=Vector((2.4,3.0,55.8))\npts=[bezier(base,Vector((.9,-2.7,39)),Vector((4,2.5,48)),anchor,t) for t in np.linspace(0,1,54)]\npolyline(\"Emerging leaf petiole\",pts,lambda t:.237-.068*t,pale,14)\ndef roll(u,v):\n a=(u-.5)*(tau+.8-1.8*v)+.64*v\n r=(.68+.86*math.sin(math.pi*v))*(1-.982*v**2.8)\n return anchor+Vector((r*math.cos(a)+.70*v*v, r*math.sin(a)+1.8*v*v,13.65*v+.36*math.sin(a)))\nroll_obj=grid(\"Pale unfurling leaf\",roll,pale,76,48)\nroll_obj.modifiers.new(\"Leaf membrane\",\"SOLIDIFY\").thickness=.037\npolyline(\"Unfurling seam\",[roll(.015,t)+Vector((.025,0,0)) for t in np.linspace(.01,.99,57)],\n lambda t:.074*(1-t)+.018,vein_col,10,.71)\n\n# Each mature leaf remains independently editable. Batch the short rib relief\n# within each leaf to avoid eight small additional draw calls.\nfor i in range(len(leaves)):\n prefix=\"Leaf %02d rib relief\"%(i+1)\n group=[p for p in parts if p.name.startswith(prefix)]\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in group:\n ob.select_set(True)\n parts.remove(ob)\n bpy.context.view_layer.objects.active=group[0]\n bpy.ops.object.join()\n bpy.context.object.name=\"Leaf %02d secondary vein relief\"%(i+1)\n parts.append(bpy.context.object)\n\nroot=bpy.data.objects.new(\"Silver-striped prayer plant | Goeppertia orbifolia\",None)\nbpy.context.collection.objects.link(root)\nroot[\"asset_id\"]=\"plants-goeppertia-orbifolia-terracotta-v1\"\nroot[\"scientific_name\"]=\"Goeppertia orbifolia\"\nroot[\"category\"]=\"plants\"\nroot[\"units\"]=\"meters in GLB\"\nfor ob in parts:\n ob.parent=root\nif not args.draft:\n root.scale=(.01,)*3\n bpy.context.view_layer.update()\n bpy.ops.object.select_all(action=\"DESELECT\")\n root.select_set(True)\n for ob in parts:\n ob.select_set(True)\n bpy.ops.export_scene.gltf(filepath=str(out/(stem+\".glb\")),export_format=\"GLB\",use_selection=True,\n export_apply=True,export_yup=True,export_extras=True)\n root.scale=(1,)*3\n\n# Continuous warm-gray paper sweep for the rendered product photograph.\nstage=material(\"Warm gray studio paper\",\"555550\",.87)\nstations=[(-450,-.035),(67,-.035)]\nfor i in range(1,45):\n a=math.pi/2*i/44\n stations.append((67+103*math.sin(a),103*(1-math.cos(a))-.035))\nstations += [(170,440)]\nvertices=[(x,y,z) for y,z in stations for x in (-360,360)]\nfaces=[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(stations)-1)]\nmesh(\"Studio sweep\",vertices,faces,stage)\n\n\ndef aim(ob,at):\n ob.rotation_euler=(Vector(at)-ob.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef area(name,p,focus,power,clr,w,h):\n d=bpy.data.lights.new(name,\"AREA\")\n d.energy=power\n d.color=clr\n d.shape=\"RECTANGLE\"\n d.size=w\n d.size_y=h\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n ob.location=p\n aim(ob,focus)\n\narea(\"Large neutral window key\",(-75,-70,113),(0,0,45),132000,(1,.96,.88),79,92)\narea(\"Cool backlit upper leaves\",(35,54,107),(0,0,45),94000,(.84,.93,1),67,48)\narea(\"Broad shadow fill\",(66,-60,65),(0,0,39),36500,(.91,.97,1),69,81)\narea(\"Soft pot bounce\",(-27,-45,26),(0,0,18),7100,(1,.92,.81),31,46)\nscene=bpy.context.scene\nscene.world.use_nodes=True\nworld=scene.world.node_tree.nodes[\"Background\"]\nworld.inputs[\"Color\"].default_value=(.16,.18,.22,1)\nworld.inputs[\"Strength\"].default_value=.38\nd=bpy.data.cameras.new(\"Plant portrait camera\")\ncamera=bpy.data.objects.new(d.name,d)\nbpy.context.collection.objects.link(camera)\ncamera.location=(36,-173,109)\nd.lens=58\naim(camera,(0,0,39.4))\nscene.camera=camera\nscene.render.engine=\"CYCLES\"\nscene.cycles.samples=20 if args.draft else 115\nscene.cycles.use_denoising=False\nscene.cycles.adaptive_threshold=.071 if args.draft else .015\nscene.cycles.max_bounces=6\nscene.view_settings.view_transform=\"AgX\"\nscene.view_settings.look=\"AgX - Medium High Contrast\"\nscene.view_settings.exposure=.22\nscene.render.resolution_x=1460\nscene.render.resolution_y=1800\nscene.render.resolution_percentage=44 if args.draft else 100\nscene.render.image_settings.file_format=\"PNG\"\nscene.render.image_settings.color_mode=\"RGB\"\nscene.render.filepath=str(out/(\"draft.png\" if args.draft else stem+\".png\"))\nbpy.ops.render.render(write_still=True)\n```\n\nrun it: `blender -b --python orbifolia.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261126T2100Z-plants-silver-striped-prayer-plant.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/silver-striped-prayer-plant/3d-dataset-20261126T2100Z-plants-silver-striped-prayer-plant.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/north-quay-signal-cabin.jpg"}}, {"type": "text", "text": "create an image of a north quay railway signal cabin"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA two-story railway signal cabin, three-quarter view from above. Red brick ground floor with a plank door and a small barred window, sage weatherboard upper story with a long band of cream-framed windows around the control room, a green \"NORTH QUAY\" sign, a hipped slate roof with ridge caps, a brick chimney with a round cowl, and an exterior timber stair with green iron railings up to a side landing.\n\nSCALE\nAbout 8.6 m wide, 7.2 m tall, 5.7 m deep. Build in meters, +Y up, +Z forward, origin at ground level under the center of the main structure.\n\nPARTS\n1. Base and ground floor: stone foundation, chamfered plinth, lime mortar wall cores, individually laid red brickwork, stone lintels and sills. Build: merged boxes per course, one box per brick.\n2. Doors and lower windows: grooved plank doors with cross battens, locks and handles, frames and thresholds, barred window. Build: door and window helpers from small boxes.\n3. Upper story: overlapping sage weatherboards, corner pilasters, sill band, nameplate with lettering. Build: lapped board strips, a label for the sign.\n4. Control room windows: long run of shallow-reveal casements with sash rails, head trim and catches, plus the lever frame and interior visible through the glass. Build: sash helper repeated along each wall, simple interior boxes.\n5. Stair and landing: straight timber stair from grade to the rear landing, iron stringers, posts and rails. Build: boxes for treads, pipes for the rails.\n6. Roof and chimney: low hipped slate roof with individually lapped tabs, ridge caps, gutter and downpipe, brick chimney with copper flashing and a round cowl. Build: shingle helper per tab, cylinder for the cowl.\n\nPLAN\n1. Setup: clear the scene, meters, origin at grade under the center.\n2. Texture maps: generated inside signal.py. Brick, slate, weatherboard paint, mortar and stone maps packed into an atlas.\n3. Build order: foundation and brick ground floor, doors and lower windows, upper weatherboard story, control room casements and interior, stair, roof, chimney.\n4. Assemble: upper story sits on the sill band, casements wrap the corners, stair lands on the side landing, roof overhangs the walls on all four sides. Merge repeated roof caps into one piece.\n5. Materials: red stock brick, lime mortar, gritstone plinth and lintels, sage weatherboards, ivory window paint, blue-green iron, oiled stair boards, blue-black slate, copper flashing, gray glazing, green enamel sign with ivory letters.\n6. Export: building only, no studio, one GLB with the textures embedded.\n\nCHECK\n411,024 triangles across 130 parts. Against the image: brick ground floor about half the wall height, windows cover most of the upper story, roof slopes on all four sides, stair rises along the right wall.\n\n\n```python\n# signal.py\n\"\"\"Model the original North Quay railway signal cabin and render its exterior.\"\"\"\nimport argparse\nfrom collections import defaultdict\nimport math\nfrom pathlib import Path\nimport random\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Quaternion, Vector\nimport numpy as np\n\np=argparse.ArgumentParser()\np.add_argument(\"--output\",type=Path,required=True)\np.add_argument(\"--draft\",action=\"store_true\")\nargs=p.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261126T2200Z-buildings-north-quay-signal-cabin\"\nrng=np.random.default_rng(6485)\nseed=random.Random(904)\ntau=math.tau\nparts=[]\nbatch=defaultdict(list)\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\n\n\ndef lin(s):\n return [c/12.92 if c<=.04045 else ((c+.055)/1.055)**2.4\n for c in [int(s[i:i+2],16)/255 for i in (0,2,4)]]\n\n\ndef mat(name,color,rough=.53,metal=0,coat=0):\n m=bpy.data.materials.new(name)\n m.use_nodes=True\n bs=m.node_tree.nodes.get(\"Principled BSDF\")\n m.diffuse_color=(*lin(color),1)\n bs.inputs[\"Base Color\"].default_value=m.diffuse_color\n bs.inputs[\"Roughness\"].default_value=rough\n bs.inputs[\"Metallic\"].default_value=metal\n bs.inputs[\"Coat Weight\"].default_value=coat\n bs.inputs[\"Coat Roughness\"].default_value=.35\n return m\n\n\ndef image(name,data,space):\n h,w=data.shape[:2]\n arr=np.concatenate((data,np.ones((h,w,1),np.float32)),axis=-1)\n im=bpy.data.images.new(name,width=w,height=h,alpha=False)\n im.colorspace_settings.name=space\n im.pixels.foreach_set(np.ascontiguousarray(arr,dtype=np.float32).ravel())\n im.file_format=\"PNG\"\n im.filepath_raw=str(out/(name+\".png\"))\n im.save()\n im.reload()\n im.colorspace_settings.name=space\n return im\n\n\ndef connect(m,im,to,strength=None):\n nt=m.node_tree\n t=nt.nodes.new(\"ShaderNodeTexImage\")\n t.image=im\n bs=nt.nodes.get(\"Principled BSDF\")\n if strength is None:\n nt.links.new(t.outputs[\"Color\"],bs.inputs[to])\n else:\n n=nt.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=strength\n nt.links.new(t.outputs[\"Color\"],n.inputs[\"Color\"])\n nt.links.new(n.outputs[\"Normal\"],bs.inputs[to])\n\n\nN=1024\nv,u=np.mgrid[:N,:N].astype(np.float32)/N\n\n\ndef noise(nx,ny):\n x,y=u*nx,v*ny\n i,j=np.floor(x).astype(int),np.floor(y).astype(int)\n fx,fy=x-i,y-j\n qx=fx*fx*(3-2*fx)\n qy=fy*fy*(3-2*fy)\n table=rng.uniform(-1,1,(ny,nx))\n ax=table[j%ny,i%nx]*(1-qx)+table[j%ny,(i+1)%nx]*qx\n bx=table[(j+1)%ny,i%nx]*(1-qx)+table[(j+1)%ny,(i+1)%nx]*qx\n return ax*(1-qy)+bx*qy\n\n\ndef normal(z,ax=4,ay=4):\n dx=(np.roll(z,-1,axis=1)-np.roll(z,1,axis=1))*ax\n dy=(np.roll(z,-1,axis=0)-np.roll(z,1,axis=0))*ay\n l=np.sqrt(1+dx*dx+dy*dy)\n return np.stack((.5-.5*dx/l,.5-.5*dy/l,.5+.5/l),axis=-1)\n\n\ndef atlas(name,colors,kind):\n # Left-to-right bands are different stock materials. Sample the central\n # portion of each band so all UV islands remain safe at their borders.\n coarse=noise(44,18)\n fine=noise(323,236)\n tiny=noise(507,438)\n color=np.empty((N,N,3),np.float64)\n height=np.empty((N,N),np.float64)\n for i,c in enumerate(colors):\n start=i*N//len(colors)\n stop=(i+1)*N//len(colors)\n slip=np.s_[:,start:stop]\n if kind==\"brick\":\n worn=np.clip(noise(50,27)[slip]-.21,0,1)*.04\n f=.08*coarse[slip]+.045*fine[slip]+.024*tiny[slip]+worn\n h=.21*coarse[slip]+.19*fine[slip]+.11*tiny[slip]-.25*np.maximum(0,-tiny[slip]-.58)\n color[slip]=np.array(c)+f[:,:,None]*np.array([.97,.79,.70])\n elif kind==\"slate\":\n grain=noise(155,9)[slip]\n speck=np.maximum(0,noise(170,158)[slip]-.51)\n f=.053*coarse[slip]+.032*grain+.035*fine[slip]+.055*speck\n color[slip]=np.array(c)+f[:,:,None]*np.array([.93,.98,1.19])\n h=.125*grain+.19*fine[slip]+.133*tiny[slip]\n else:\n grain=noise(24,194)[slip]\n torn=np.maximum(0,noise(42,164)[slip]-.60)\n f=.048*coarse[slip]+.041*grain+.016*fine[slip]\n color[slip]=np.array(c)+f[:,:,None]-torn[:,:,None]*np.array([.112,.14,.144])\n h=.135*grain+.13*fine[slip]-.13*torn\n height[slip]=h\n base=image(name+\"_BaseColor\",np.clip(color,.025,.97),\"sRGB\")\n norm=image(name+\"_Normal\",normal(height,5,4),\"Non-Color\")\n return base,norm\n\n\nbrick=mat(\"Hand-fired red stock bricks\",\"835242\",.82)\nmaps=atlas(\"BrickStock\",[(.570,.341,.265),(.522,.303,.235),(.605,.378,.286),(.465,.265,.226),(.640,.414,.331),(.518,.370,.311)],\"brick\")\nconnect(brick,maps[0],\"Base Color\")\nconnect(brick,maps[1],\"Normal\",.60)\nslate=mat(\"Weathered blue-black roof slate\",\"3D4950\",.76)\nmaps=atlas(\"RoofSlate\",[(.282,.314,.326),(.248,.282,.300),(.320,.344,.350),(.273,.301,.313),(.354,.369,.369),(.238,.268,.282)],\"slate\")\nconnect(slate,maps[0],\"Base Color\")\nconnect(slate,maps[1],\"Normal\",.61)\npaint=mat(\"Weathered sage-painted timber cladding\",\"627768\",.65,.0,.06)\nmaps=atlas(\"SageCladding\",[(.415,.505,.445),(.362,.454,.407),(.436,.524,.461),(.371,.479,.422)],\"paint\")\nconnect(paint,maps[0],\"Base Color\")\nconnect(paint,maps[1],\"Normal\",.37)\nmortar=mat(\"Weathered gray-tan lime mortar\",\"958577\",.90)\nstone=mat(\"Gritstone sill and plinth\",\"76746B\",.80)\nstone_light=mat(\"Pale gritstone lintel\",\"969087\",.76)\ncream=mat(\"Aged warm ivory window paint\",\"D2CBB2\",.61)\ncream_shadow=mat(\"Weathered cream infill boards\",\"ACA98F\",.76)\ndark=mat(\"Deep blue-green painted iron\",\"303E3D\",.57,.32,.09)\nedge=mat(\"Burnished iron hardware\",\"666A65\",.43,.68)\nwood=mat(\"Aged oiled stair and floor boards\",\"69513B\",.73)\nwood_light=mat(\"Weathered inner woodwork\",\"9B7655\",.75)\nwood_shade=mat(\"Tobacco-stained inner trim\",\"3D342A\",.74)\nenamel=mat(\"Deep forest sign enamel\",\"263F36\",.39,.09,.24)\noffwhite=mat(\"Ivory hand-painted sign lettering\",\"DED2AA\",.56)\nglass=mat(\"Clear slightly gray historic glazing\",\"E4F0E8\",.091,.0,0)\ng=glass.node_tree.nodes.get(\"Principled BSDF\")\ng.inputs[\"Transmission Weight\"].default_value=1.0\ng.inputs[\"IOR\"].default_value=1.46\ncopper=mat(\"Oxidized copper flashing\",\"52665C\",.52,.48)\nred=mat(\"Oxide red signal lever handles\",\"784232\",.46,.29,.07)\nyellow=mat(\"Ochre signal lever handles\",\"AA8640\",.46,.20,.08)\nfloorwall=mat(\"Interior aged limewash\",\"B5AF97\",.82)\n\n\ndef register(ob,name,m,smooth=False,export=True):\n ob.name=name\n ob.data.materials.append(m)\n if smooth:\n for f in ob.data.polygons:\n f.use_smooth=True\n if export:\n parts.append(ob)\n return ob\n\n\ndef small_box(name,loc,dims,m,b=.012,group=None):\n if group is not None:\n batch[group,m].append((loc,dims,b,None,None))\n return\n bpy.ops.mesh.primitive_cube_add(size=2,location=loc)\n ob=bpy.context.object\n ob.dimensions=dims\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n if b:\n bevel=ob.modifiers.new(\"Eased edges\",\"BEVEL\")\n bevel.width=b\n bevel.segments=2\n ob.modifiers.new(\"Weighted corner normals\",\"WEIGHTED_NORMAL\")\n return register(ob,name,m)\n\n\ndef mesh(name,verts,faces,m,uvs=None,smooth=False,export=True,norm=False):\n d=bpy.data.meshes.new(name)\n d.from_pydata(verts,[],faces)\n d.update()\n if uvs is not None:\n layer=d.uv_layers.new(name=\"UVMap\")\n for f,coords in zip(d.polygons,uvs):\n for j,li in enumerate(f.loop_indices):\n layer.data[li].uv=coords[j]\n if norm:\n bm=bmesh.new()\n bm.from_mesh(d)\n bmesh.ops.recalc_face_normals(bm,faces=bm.faces[:])\n bm.to_mesh(d)\n bm.free()\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n return register(ob,name,m,smooth,export)\n\n\ndef uv_rect(k=0,count=1):\n if count==1:\n return [(0,0),(1,0),(1,1),(0,1)]\n start=k/count\n du=.82/count\n u=start+.048/count+seed.random()*.07/count\n v=.018+seed.random()*.14\n return [(u,v),(u+du,v),(u+du,v+.8),(u,v+.8)]\n\n\ndef merge_boxes(group,entries,m):\n corners=[(-1,-1,-1),(1,-1,-1),(1,1,-1),(-1,1,-1),(-1,-1,1),(1,-1,1),(1,1,1),(-1,1,1)]\n quad=[(3,2,1,0),(4,5,6,7),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7)]\n verts,faces,uv=[],[],[]\n for loc,dims,bevel,tr,texture in entries:\n base=len(verts)\n for xyz in corners:\n p=Vector([xyz[i]*dims[i]/2 for i in range(3)])\n p=tr@p if tr is not None else p\n verts.append(Vector(loc)+p)\n for f in quad:\n faces.append(tuple(base+i for i in f))\n uv.append(uv_rect(*texture) if texture else uv_rect())\n ob=mesh(group,verts,faces,m,uv)\n b=entries[0][2]\n if b:\n bevel=ob.modifiers.new(\"Eased stock edges\",\"BEVEL\")\n bevel.width=b\n bevel.segments=2\n ob.modifiers.new(\"Weighted face normals\",\"WEIGHTED_NORMAL\")\n return ob\n\n\ndef cylinder(name,a,b,r,m,segs=20):\n a,b=Vector(a),Vector(b)\n d=b-a\n bpy.ops.mesh.primitive_cylinder_add(vertices=segs,radius=r,depth=d.length,location=(a+b)/2)\n ob=bpy.context.object\n ob.rotation_euler=d.to_track_quat(\"Z\",\"Y\").to_euler()\n return register(ob,name,m,True)\n\n\ndef barn(name,a,b,width,height,m,group):\n a,b=Vector(a),Vector(b)\n d=b-a\n rot=d.to_track_quat(\"Z\",\"Y\")\n batch[group,m].append(((a+b)/2,(width,height,d.length),.008,rot,None))\n\n\ndef pipe(name,points,r,m,steps=16):\n ps=list(map(Vector,points))\n verts,faces=[],[]\n for i,p in enumerate(ps):\n direction=(ps[min(len(ps)-1,i+1)]-ps[max(0,i-1)]).normalized()\n ref=Vector((0,0,1)) if abs(direction.z)<.94 else Vector((0,1,0))\n x=direction.cross(ref).normalized()\n y=x.cross(direction).normalized()\n for j in range(steps):\n t=tau*j/steps\n verts.append(p+r*(x*math.cos(t)+y*math.sin(t)))\n for i in range(len(ps)-1):\n for j in range(steps):\n k=(j+1)%steps\n faces.append((i*steps+j,i*steps+k,(i+1)*steps+k,(i+1)*steps+j))\n faces.append(tuple(range(steps-1,-1,-1)))\n faces.append(tuple(range(len(verts)-steps,len(verts))))\n return mesh(name,verts,faces,m,smooth=True,norm=True)\n\n\ndef label(name,s,loc,sz,m):\n d=bpy.data.curves.new(name,\"FONT\")\n d.body=s\n d.size=sz\n d.align_x=\"CENTER\"\n d.align_y=\"CENTER\"\n d.space_character=1.17\n d.extrude=.0023\n d.bevel_depth=.00075\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n ob.location=loc\n ob.rotation_euler.x=math.pi/2\n bpy.ops.object.select_all(action=\"DESELECT\")\n ob.select_set(True)\n bpy.context.view_layer.objects.active=ob\n bpy.ops.object.convert(target=\"MESH\")\n register(bpy.context.object,name,m)\n return ob\n\n\nW,D=6.80,3.94\nhx,hy=W/2,D/2\nbrick_top=2.47\nsmall_box(\"Flush stone foundation and foot\", (0,0,.084),(W+.16,D+.15,.168),stone,.020)\nsmall_box(\"Chamfered outer plinth course\", (0,0,.188),(W+.085,D+.085,.120),stone,.017)\nsmall_box(\"Upper floor exposed sill band\",(0,0,2.478),(W+.12,D+.12,.156),stone,.013)\nsmall_box(\"Lower interior slab\",(0,0,.183),(6.52,3.72,.107),wood_shade,.009)\nsmall_box(\"Upper signal room floor\",(0,0,2.571),(6.58,3.75,.143),wood,.009)\n\n\ndef wallbox(side,s,z,span,h,depth,m,group,offset=0,b=.003):\n if side==0:\n loc=(s,-hy-offset,z)\n dims=(span,depth,h)\n elif side==1:\n loc=(s,hy+offset,z)\n dims=(span,depth,h)\n elif side==2:\n loc=(hx+offset,s,z)\n dims=(depth,span,h)\n else:\n loc=(-hx-offset,s,z)\n dims=(depth,span,h)\n small_box(group,loc,dims,m,b,group)\n\n\nfront_open=[(-2.64,-1.47,.244,2.165),(.79,2.10,1.06,1.94)]\nback_open=[(-.71,.62,1.02,1.94)]\nright_open=[(-.86,.18,1.02,1.89)]\nleft_open=[(-.99,.30,1.02,1.96)]\nlower_open=[front_open,back_open,right_open,left_open]\nfor side,openings in enumerate(lower_open):\n half=hx if side<2 else hy-.079\n breaks=sorted({.232,2.41,*[a for op in openings for a in op[2:]]})\n for zlo,zhi in zip(breaks,breaks[1:]):\n mid=(zlo+zhi)/2\n limits=[(-half,half)]\n for a,b,c,d in openings:\n if cl]\n for a,b in limits:\n wallbox(side,(a+b)/2,mid,b-a,zhi-zlo,.188,mortar,\"Lime mortar wall cores\",offset=-.064,b=.002)\n for row in range(32):\n z=.235+row*.068\n top=min(z+.062,2.411)\n if top<=z:\n continue\n limits=[(-half,half)]\n for a,b,c,d in openings:\n if not z>=d and not top<=c:\n limits=[(l,t) for x,y in limits for l,t in [(x,min(y,a)),(max(x,b),y)] if t-l>.025]\n for a,b in limits:\n t=-half-(row%2)*.111\n while t.025:\n u0=(left+right)/2\n d=.126+seed.uniform(-.010,.009)\n fz=(z+top)/2+seed.uniform(-.0011,.0011)\n if side<2:\n loc=(u0,(-1 if side==0 else 1)*(hy-.028),fz)\n dim=(right-left,d,top-z)\n else:\n loc=((1 if side==2 else -1)*(hx-.027),u0,fz)\n dim=(d,right-left,top-z)\n k=seed.choices(range(6),[9,7,7,3,4,4])[0]\n batch[\"Individually laid red stock brickwork\",brick].append((loc,dim,.004,None,(k,6)))\n t+=.223\n for a,b,zlo,zhi in openings:\n wid=b-a\n wallbox(side,(a+b)/2,zhi+.043,wid+.225,.138,.246,stone_light,\"Gritstone window lintels\",offset=.012,b=.016)\n if zlo>.7:\n wallbox(side,(a+b)/2,zlo+.001,wid+.22,.108,.329,stone_light,\"Weathered stone window sills\",offset=.043,b=.018)\n\n# Upper weatherboard sections and the long band of shallow-reveal casements.\nupper_front=[(-3.16,-1.69),(-1.60,-.069),(.011,1.57),(1.65,3.17)]\nupper_back=[(-2.75,-1.43),(-.97,.29),(.72,2.06)]\nupper_right=[(-1.74,-.33),(-.21,.89),(.995,1.87)]\nupper_left=[(-1.71,-.45),(-.34,.87)]\nfor side,opens in enumerate((upper_front,upper_back,upper_right,upper_left)):\n half=hx-.065 if side<2 else hy-.065\n lows,highs=3.167,4.567\n cuts=sorted({2.555,4.962,lows,highs,*([2.613] if side==2 else [])})\n for za,zb in zip(cuts,cuts[1:]):\n spans=[(-half,half)]\n for j,(a,b) in enumerate(opens):\n lo=2.613 if side==2 and j==2 else lows\n if lo<.5*(za+zb)l]\n for a,b in spans:\n wallbox(side,(a+b)/2,(za+zb)/2,b-a,zb-za,.188,floorwall,\"Plastered backing to weatherboards\",offset=-.113,b=.004)\n for row in range(21):\n z=2.565+row*.1146\n top=z+.1112\n spans=[(-half,half)]\n for j,(a,b) in enumerate(opens):\n lo=2.613 if side==2 and j==2 else lows\n if zlo:\n spans=[(l,t) for x,y in spans for l,t in [(x,min(y,a)),(max(x,b),y)] if t-l>.016]\n for a,b in spans:\n if side<2:\n loc=((a+b)/2,(-1 if side==0 else 1)*(hy-.034),(z+top)/2)\n dim=(b-a,.104,top-z)\n quat=Quaternion((1,0,0),math.radians(7 if side==0 else -7))\n else:\n loc=((1 if side==2 else -1)*(hx-.034),(a+b)/2,(z+top)/2)\n dim=(.104,b-a,top-z)\n quat=Quaternion((0,1,0),math.radians(-7 if side==2 else 7))\n batch[\"Overlapping sage-painted weatherboards\",paint].append((loc,dim,.002,quat,(seed.randrange(4),4)))\n for a in (-half,half):\n wallbox(side,a,3.742,.113,2.38,.136,cream_shadow,\"Upper story corner pilasters\",offset=.016,b=.006)\n sill_min,sill_max=-half,(.983 if side==2 else half)\n wallbox(side,(sill_min+sill_max)/2,3.084,sill_max-sill_min,.091,.185,cream_shadow,\n \"Horizontal sash sill rail\",offset=.020,b=.010)\n wallbox(side,0,4.662,half*2,.115,.132,cream,\"Window head trim\",offset=.018,b=.009)\n\n\ndef sash(side,a,b,lo,hi,upper=True):\n sq=\"Upper\" if upper else \"Lower\"\n w=b-a\n h=hi-lo\n m=cream if upper else dark\n rail=.050 if upper else .065\n foffset=.027 if upper else -.031\n for s in (a+rail/2,b-rail/2):\n wallbox(side,s,(lo+hi)/2,rail,h+.059,.106,m,sq+\" casement outer jambs\",offset=foffset,b=.004)\n for z in (lo+rail/2,hi-rail/2):\n wallbox(side,(a+b)/2,z,w,rail,.105,m,sq+\" casement head and bottom rails\",offset=foffset,b=.004)\n mid=lo+h*.681 if upper else lo+h*.515\n wallbox(side,(a+b)/2,mid,w,.044,.085,m,sq+\" sash transoms\",offset=foffset+.018,b=.004)\n for t in ([.50] if not upper else [.333,.666]):\n wallbox(side,a+w*t,(lo+hi)/2,.043,h,.076,m,sq+\" divided-light glazing bars\",offset=foffset+.016,b=.004)\n wallbox(side,(a+b)/2,(lo+hi)/2,w-.049,h-.059,.014,glass,sq+\" clear window glass\",offset=foffset-.029,b=0)\n wallbox(side,(a+b)/2,lo+.004,w+.112,.058,.229,cream_shadow if upper else stone_light,sq+\" exterior window sill\",offset=foffset+.043,b=.012)\n if upper:\n # Weather strip and dark visible handle on selected lower lights.\n wallbox(side,(a+b)/2+.051,mid-.066,.073,.018,.063,edge,\"Sash catches\",offset=foffset+.060,b=.004)\n\n\nfor side,opens in enumerate((upper_front,upper_back,upper_right,upper_left)):\n for j,(a,b) in enumerate(opens):\n if side!=2 or j!=2:\n sash(side,a,b,3.167,4.567)\nfor side,opens in enumerate(lower_open):\n for a,b,lo,hi in opens:\n if lo>.7:\n sash(side,a,b,lo+.07,hi-.035,False)\n\n\ndef door(side,a,b,z0,z1,painted):\n wide=b-a\n for s in (a+.035,b-.035):\n wallbox(side,s,(z0+z1)/2,.084,z1-z0,.184,cream_shadow,\"Door jambs\",offset=.015,b=.007)\n wallbox(side,(a+b)/2,z1-.036,wide,.072,.160,cream_shadow,\"Door frame heads\",offset=.017,b=.009)\n wallbox(side,(a+b)/2,z0+.019,wide+.22,.091,.319,stone_light,\"Threshold blocks\",offset=.042,b=.014)\n n=7\n for j in range(n):\n width=(wide-.135)/n\n center=a+.0675+width*(j+.5)\n wallbox(side,center,(z0+z1)/2,width-.005,z1-z0-.102,.107,painted,\"Vertically grooved plank doors\",offset=-.016,b=.003)\n for z in (z0+.337,z1-.378):\n wallbox(side,(a+b)/2,z,wide-.159,.062,.051,painted,\"Door exterior cross battens\",offset=.044,b=.003)\n wallbox(side,a+wide*.76,z0+.94,.054,.127,.061,edge,\"Door locks\",offset=.056,b=.007)\n wallbox(side,a+wide*.77,z0+.972,.119,.027,.063,dark,\"Door pull handles\",offset=.095,b=.006)\n\n\ndoor(0,-2.64,-1.47,.237,2.164,dark)\ndoor(2,.995,1.87,2.613,4.566,dark)\nsmall_box(\"Evocative North Quay vitreous enamel placard\",(0,-2.052,2.902),(1.99,.085,.370),enamel,.021)\nsmall_box(\"Placard projecting edge trim\",(0,-2.094,2.902),(1.928,.023,.302),enamel,.009)\nlabel(\"North Quay hand-painted lettering\",\"NORTH QUAY\",(0,-2.107,2.898),.223,offwhite)\nfor x in (-.908,.908):\n cylinder(\"Placard fixing bolt\",(x,-2.112,2.902),(x,-2.126,2.902),.014,edge,12)\nsmall_box(\"Service number enamel plate\",(-1.268,-2.020,1.752),(.181,.027,.114),enamel,.008)\nlabel(\"Service number\",\"27\",(-1.268,-2.037,1.751),.083,offwhite)\n\n# Interior silhouette visible through the sash. The instrument furnishings are\n# fixed building details. Studio illumination is added only after export.\nfor i in range(30):\n y=-1.77+i*.119\n small_box(\"Signal floorboards\",(0,y,2.627),(6.46,.116,.038),wood_light,.002,\"Signal floorboards\")\nfor side in (0,1):\n wallbox(side,0,3.02,6.47,.081,.085,wood_shade,\"Interior dado rails\",offset=-.197,b=.006)\nfor i in range(3):\n x=-2.25+i*1.33\n small_box(\"Block shelf bracket\",(x,-1.54,3.525),(.099,.365,.293),wood_shade,.016,\"Interior block shelf\")\nsmall_box(\"Long illuminated-room block shelf\",(-.93,-1.49,3.617),(3.34,.426,.094),wood_light,.011)\nfor i in range(5):\n x=-2.27+i*.58\n small_box(\"Period block instrument housings\",(x,-1.46,3.795),(.38,.245,.281),wood_shade,.019,\"Interior block instrument boxes\")\n small_box(\"Small instrument face panels\",(x,-1.595,3.813),(.231,.033,.132),cream_shadow,.009,\"Instrument face panels\")\n for j in range(2):\n cylinder(\"Dark instrument disc rim\",(x+(.068 if j else -.068),-1.616,3.813),(x+(.068 if j else -.068),-1.628,3.813),.037,dark,18)\nsmall_box(\"Control frame iron base\",(-.6,-.27,2.716),(3.24,.67,.177),dark,.021)\nfor i in range(14):\n x=-2.014+i*.216\n y=-.247+(.21 if i%4==1 else 0)\n barn(\"Signal control levers\",(x,-.28,2.76),(x,y,3.442+(i%2)*.081),.042,.038,\n [dark,red,red,yellow][i%4],\"Signal control lever silhouettes\")\n cylinder(\"Signal lever handle\",(x,y,3.408+(i%2)*.081),(x,y,3.544+(i%2)*.081),.033,edge,12)\nsmall_box(\"Rear rail chart board\",(-.38,1.693,4.012),(3.91,.081,.570),wood_shade,.018)\nsmall_box(\"Rail chart paper\",(-.38,1.645,4.012),(3.74,.019,.447),cream_shadow,.004)\nfor i in range(4):\n small_box(\"Linework on rail chart\",(-.38,1.633,3.877+i*.091),(3.41,.011,.012),dark,.001,\"Rail chart linework\")\nsmall_box(\"Side desk top\",(2.42,.638,3.396),(1.28,.65,.086),wood_light,.009)\nfor x in (1.92,2.91):\n for y in (.41,.87):\n small_box(\"Side desk legs\",(x,y,3.02),(.10,.10,.78),wood_shade,.007,\"Interior furniture silhouettes\")\n\n# Straight exterior stair from grade to the rear landing.\nxs=(3.50,4.66)\nstair_center=sum(xs)/2\nfoot=-3.11\ntop=1.055\nsmall_box(\"Stone pad below stair foot\",(stair_center,foot+.075,.042),(1.41,.514,.084),stone,.016)\nheight=2.614\nn=15\nrun=(top-foot)/n\nrise=height/n\nfor j in range(n):\n y=foot+(j+.5)*run\n z=(j+1)*rise\n small_box(\"Weathered timber stair treads\",(stair_center,y,z-.047),(1.225,run+.027,.095),wood,.012,\"Timber stair treads\")\n small_box(\"Stair nosing wear strip\",(stair_center,y-run*.433,z-.017),(1.172,.032,.024),wood_light,.005,\"Worn tread noses\")\n for x in xs:\n small_box(\"Iron tread angle support\",(x,y,z-.108),(.105,.204,.109),dark,.008,\"Tread brackets\")\nfor x in xs:\n barn(\"Stair stringer\",(x,foot-.06,.038),(x,top+.063,height-.143),.154,.242,dark,\"Cut timber stair stringers\")\n for j in (0,4,8,12,15):\n y=foot+j*run\n z=j*rise+.119\n barn(\"Rake baluster structural post\",(x,y,z-.043),(x,y,z+.999),.079,.079,dark,\"Iron stair uprights\")\n for j in range(1,n):\n if j%4:\n y=foot+j*run\n z=j*rise+.130\n barn(\"Intermediate stair rail upright\",(x,y,z),(x,y,z+.864),.042,.042,dark,\"Stair balusters\")\n for railz,w in ((1.024,.086),(.527,.056)):\n barn(\"Sloped railing\",(x,foot-.079,railz+.099),(x,top+.049,height+railz+.100),w,w,dark,\"Continuous raked handrails\")\n for j in (2,8,14):\n y=foot+j*run\n z=j*rise-.017\n cylinder(\"Exposed stringer washer\",(x+(.074 if x>4 else -.074),y,z),\n (x+(.090 if x>4 else -.090),y,z),.034,edge,14)\nsmall_box(\"Landing stone support slab\",(4.087,1.566,.061),(1.266,1.288,.122),stone,.019)\nfor x in xs:\n for y in (1.21,1.986):\n barn(\"Landing support post\",(x,y,.126),(x,y,2.505),.149,.148,dark,\"Landing support frame\")\n barn(\"Landing margin newel\",(x,y,2.609),(x,y,3.718),.092,.089,dark,\"Landing newel posts\")\nfor j in range(11):\n x=3.443+j*.122\n small_box(\"Landing decking boards\",(x,1.543,2.568),(.118,1.143,.092),wood,.012,\"External landing boards\")\nfor z,w in [(3.711,.085),(3.16,.053)]:\n barn(\"Landing side rail\",(4.68,1.054,z),(4.68,2.061,z),w,w,dark,\"Landing rails\")\n barn(\"Landing return rail\",(3.465,2.061,z),(4.68,2.061,z),w,w,dark,\"Landing rails\")\nfor y in np.linspace(1.237,1.915,4):\n barn(\"Landing side baluster\",(4.68,y,2.612),(4.68,y,3.711),.043,.043,dark,\"Landing balusters\")\nfor x in (3.697,3.92,4.15,4.385):\n barn(\"Landing return baluster\",(x,2.058,2.612),(x,2.058,3.711),.043,.043,dark,\"Landing balusters\")\nbarn(\"Post cross stiffener\",(4.60,1.25,.473),(4.60,2.039,2.423),.054,.091,dark,\"Landing support frame\")\n\n# A low overhung hipped slate roof with individually lapped tabs.\nRX,RY=3.799,2.38\neave=4.988\npitch=.604\nridge=eave+pitch*RY\nsmall_box(\"Continuous projecting eave soffit\",(0,0,4.958),(7.57,4.714,.105),cream_shadow,.015)\nvertices=[(-RX,-RY,eave),(RX,-RY,eave),(RX,RY,eave),(-RX,RY,eave),\n (-RX+RY,0,ridge),(RX-RY,0,ridge)]\nmesh(\"Hipped roof felt underlay\",vertices,[(0,1,5,4),(1,2,5),(2,3,4,5),(3,0,4),(3,2,1,0)],dark)\nverts,faces,uvs=[],[],[]\ndef shingle(side,a,b,d0,d1,row):\n if b-a<.027:\n return\n pts=[]\n lift=.026+.006*(row%2)+seed.uniform(-.0035,.004)\n for k,(s,d) in enumerate(((a,d0),(b,d0),(b,d1),(a,d1))):\n max_s=(RX if side<2 else RY)-d-.014\n s=min(max(-max_s,s),max_s)\n z=eave+d*pitch+lift+seed.uniform(-.0025,.0025)\n pts.append((s,(-1 if side==0 else 1)*(RY-d),z) if side<2 else ((1 if side==2 else -1)*(RX-d),s,z))\n ix=len(verts)\n verts.extend(pts+[(x,y,z-.017) for x,y,z in pts])\n for f in [(0,1,2,3),(7,6,5,4),(0,4,5,1),(1,5,6,2),(2,6,7,3),(3,7,4,0)]:\n faces.append(tuple(ix+j for j in f))\n uvs.append(uv_rect(seed.choices(range(6),[8,7,8,7,3,5])[0],6))\nfor side in range(4):\n for row in range(14):\n d0=row*.174\n d1=min(RY-.006,d0+.211)\n if d1\nLOOK\nA washed indigo denim chore jacket, posed on an invisible form, front three-quarter view. Pointed folded collar on a stand, a straight button placket with six copper buttons, one breast pocket and two large hip patch pockets with double topstitching, long sleeves with buttoned cuffs, and a small woven \"LOOM / 07\" label inside the neck.\n\nSCALE\nAbout 90 cm wide, 68 cm tall, 27 cm deep. Build in meters, +Y up, +Z forward, origin centered below the garment on the symmetry plane.\n\nPARTS\n1. Torso shell: cut denim body with two armholes and a deeply folded bottom hem. Build: a parametric shell with real cloth thickness.\n2. Sleeves and cuffs: long sleeves set into the armholes, cuffs with a button. Build: tubes shaped along the arm path.\n3. Placket: front button band with twin topstitching and a broken-in fold. Build: strip following the front opening.\n4. Collar: curved stand plus two independently shaped folded collar leaves with rounded points. Build: lofted sections.\n5. Back yoke and pockets: two rear yoke seams with a felled ridge, a left breast pocket, left and right hip pockets, each following the body curve. Build: patch panels projected onto the shell, dashed topstitch lines.\n6. Buttons and label: copper tack buttons with spun rims, holes and thread, plus a woven neck label with lettering. Build: lathed buttons, a thin box with text.\n\nPLAN\n1. Setup: clear the scene, meters, origin below the garment.\n2. Texture maps: generated inside chore.py. Twill weave color and normal maps for the face and the undyed reverse.\n3. Build order: torso shell, sleeves, hem, placket, collar, back yoke, pockets, buttons, label.\n4. Assemble: sleeves meet the armholes, collar sits on the neck stand, pockets follow the local chest and hip curvature, buttons run down the placket with matching holes.\n5. Materials: washed indigo twill face, undyed weft reverse, faded indigo seams, sand cotton topstitch, dark blue overlock, aged copper buttons, cream label with madder lettering.\n6. Export: jacket only, one GLB with the textures embedded.\n\nCHECK\n738,402 triangles across 63 parts. Against the image: three pockets (one breast, two hip), six buttons in a straight line, collar points spread outward, sleeves hang slightly forward.\n\n\n```python\n# chore.py\n\"\"\"Original washed-indigo chore jacket, at adult garment scale.\"\"\"\nimport argparse\nfrom collections import defaultdict\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Vector, Quaternion\nimport numpy as np\n\np=argparse.ArgumentParser()\np.add_argument(\"--output\",type=Path,required=True)\np.add_argument(\"--draft\",action=\"store_true\")\np.add_argument(\"--preview-only\",action=\"store_true\")\nargs=p.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261126T2300Z-clothes-washed-indigo-chore-jacket\"\nrng=np.random.default_rng(7107)\ntau=math.tau\nparts=[]\ntrim=defaultdict(lambda: ([],[],[]))\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\n\n\ndef srgb(c):\n v=[int(c[i:i+2],16)/255 for i in (0,2,4)]\n return tuple(i/12.92 if i<=.04045 else ((i+.055)/1.055)**2.4 for i in v)\n\n\ndef mat(name,c,rough,metal=0,coat=0,sheen=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*srgb(c),1)\n m.use_nodes=True\n bs=m.node_tree.nodes.get(\"Principled BSDF\")\n bs.inputs[\"Base Color\"].default_value=m.diffuse_color\n bs.inputs[\"Roughness\"].default_value=rough\n bs.inputs[\"Metallic\"].default_value=metal\n bs.inputs[\"Coat Weight\"].default_value=coat\n bs.inputs[\"Sheen Weight\"].default_value=sheen\n bs.inputs[\"Sheen Roughness\"].default_value=.57\n return m\n\n\ndef img(name,d,space):\n h,w=d.shape[:2]\n a=np.concatenate((d,np.ones((h,w,1),np.float32)),axis=-1)\n im=bpy.data.images.new(name,width=w,height=h,alpha=False)\n im.colorspace_settings.name=space\n im.pixels.foreach_set(np.ascontiguousarray(a,dtype=np.float32).ravel())\n im.file_format=\"PNG\"\n im.filepath_raw=str(out/(name+\".png\"))\n im.save()\n im.reload()\n im.colorspace_settings.name=space\n return im\n\n\ndef connect(m,i,socket,strength=None):\n nt=m.node_tree\n tex=nt.nodes.new(\"ShaderNodeTexImage\")\n tex.image=i\n to=nt.nodes.get(\"Principled BSDF\").inputs[socket]\n if strength is None:\n nt.links.new(tex.outputs[\"Color\"],to)\n else:\n n=nt.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=strength\n nt.links.new(tex.outputs[\"Color\"],n.inputs[\"Color\"])\n nt.links.new(n.outputs[\"Normal\"],to)\n\n\nN=1536\ny,x=np.mgrid[:N,:N].astype(np.float32)/N\n\ndef noise(nx,ny):\n u,v=x*nx,y*ny\n ix,iy=np.floor(u).astype(int),np.floor(v).astype(int)\n fx,fy=u-ix,v-iy\n qx=fx*fx*(3-2*fx)\n qy=fy*fy*(3-2*fy)\n r=rng.uniform(-1,1,(ny,nx))\n a=r[iy%ny,ix%nx]*(1-qx)+r[iy%ny,(ix+1)%nx]*qx\n b=r[(iy+1)%ny,ix%nx]*(1-qx)+r[(iy+1)%ny,(ix+1)%nx]*qx\n return a*(1-qy)+b*qy\n\n\ndef normal(z,ax=2.9,ay=2.9):\n dx=(np.roll(z,-1,axis=1)-np.roll(z,1,axis=1))*ax\n dy=(np.roll(z,-1,axis=0)-np.roll(z,1,axis=0))*ay\n d=np.sqrt(1+dx*dx+dy*dy)\n return np.stack((.5-.5*dx/d,.5-.5*dy/d,.5+.5/d),axis=-1)\n\n\nwarp=.5+.5*np.cos(tau*(227*x+.14*noise(38,38)))\nweft=.5+.5*np.cos(tau*(237*y+.17*noise(36,38)))\nphase=(.5+.5*np.cos(tau*(113*x-78*y+.22*noise(35,41))))**1.8\ncross=warp**1.7*(.65+.35*phase)+weft**2*(.33+.30*(1-phase))\nwash=.031*noise(6,6)+.018*noise(24,29)+.013*noise(121,117)+.014*noise(571,472)\nwash+=.018*(.5+.5*np.sin(tau*(48*x+.25*noise(17,19))))**3\nsmall=.045*cross+.062*phase+.035*noise(391,510)\nbase=np.stack((.119+wash*.79+small*.50,.187+wash*.85+small*.63,.267+wash*.92+small*.78),axis=-1)\ninside=np.stack((.330+wash*.65+small*.96,.369+wash*.73+small*.98,.393+wash*.77+small*1.02),axis=-1)\nedge=np.stack((.162+wash*.78+small*.60,.227+wash*.83+small*.69,.310+wash*.93+small*.83),axis=-1)\nz=(cross-.31)*.176 + .077*phase+.046*noise(553,477)\nr=.758-.066*phase+.046*noise(43,53)+.035*cross\nbase_im=img(\"Indigo_Denim_BaseColor\",np.clip(base,0,1),\"sRGB\")\ninside_im=img(\"Weft_Side_BaseColor\",np.clip(inside,0,1),\"sRGB\")\nedge_im=img(\"Washed_Seam_BaseColor\",np.clip(edge,0,1),\"sRGB\")\nnormal_im=img(\"Denim_Twill_Normal\",normal(z,2.45,2.32),\"Non-Color\")\nrough_im=img(\"Denim_Roughness\",np.repeat(r[:,:,None],3,axis=2),\"Non-Color\")\nfabric=mat(\"Washed indigo cotton twill, face\",\"3C5267\",.76,sheen=.29)\nlining=mat(\"Undyed weft, reverse side of denim\",\"636D73\",.84,sheen=.24)\nfaded=mat(\"Faded indigo in binding and raised seams\",\"495B72\",.77,sheen=.29)\nfor m,c in [(fabric,base_im),(lining,inside_im),(faded,edge_im)]:\n connect(m,c,\"Base Color\")\n connect(m,normal_im,\"Normal\",.37 if m==lining else .57)\n connect(m,rough_im,\"Roughness\")\nstitch=mat(\"Quiet sand-colored cotton topstitch\",\"A38D6B\",.87,sheen=.15)\nblue_stitch=mat(\"Darker blue overlock stitching\",\"586F85\",.86,sheen=.19)\ncopper=mat(\"Aged copper-alloy tack buttons\",\"937352\",.33,.82,.16)\nox=mat(\"Dark oxidized copper in button recesses\",\"4D3E34\",.48,.62)\nfelt=mat(\"Faded cotton label substrate\",\"C0AA85\",.87)\nink=mat(\"Madder-brown woven label lettering\",\"593E31\",.88)\ndark=mat(\"Seam shadow, deep indigo\",\"273543\",.85)\n\n\ndef register(ob,name,m,smooth=True,use=True):\n ob.name=name\n ob.data.materials.append(m)\n if smooth:\n for f in ob.data.polygons:\n f.use_smooth=True\n if use:\n parts.append(ob)\n return ob\n\n\ndef mesh(name,V,F,m,uvs=None,flip=False,closed=False):\n data=bpy.data.meshes.new(name)\n data.from_pydata(V,[],[tuple(reversed(f)) for f in F] if flip else F)\n data.update()\n if uvs is not None:\n layer=data.uv_layers.new(name=\"UVMap\")\n for f in data.polygons:\n us=[uvs[j][0] for j in f.vertices]\n for l in f.loop_indices:\n q=uvs[data.loops[l].vertex_index]\n layer.data[l].uv=q\n if closed:\n b=bmesh.new()\n b.from_mesh(data)\n bmesh.ops.recalc_face_normals(b,faces=b.faces[:])\n b.to_mesh(data)\n b.free()\n ob=bpy.data.objects.new(name,data)\n bpy.context.collection.objects.link(ob)\n return register(ob,name,m)\n\n\ndef grid(name,fn,m,rows,cols,uv=None,wrap=False,flip=False,omit=None):\n V,F,UV=[],[],[]\n n=cols if wrap else cols+1\n for j in range(rows+1):\n for i in range(n):\n u,v=i/cols,j/rows\n V.append(fn(u,v))\n UV.append(uv(u,v) if uv else (u,v))\n for j in range(rows):\n for i in range(cols):\n if omit and omit((i+.5)/cols,(j+.5)/rows):\n continue\n a=j*n+i\n b=j*n+(i+1)%n\n F.append((a,b,b+n,a+n))\n return mesh(name,V,F,m,UV,flip)\n\n\ndef make_shell(ob,thickness=.095):\n ob.data.materials.append(lining)\n mod=ob.modifiers.new(\"Two-sided denim fabric\",\"SOLIDIFY\")\n mod.thickness=thickness\n mod.offset=-1\n mod.material_offset=1\n mod.material_offset_rim=1\n\n\ndef add_tube(bag,pts,r,n=8,flat=1):\n vs,fs,tex=bag\n P=list(map(Vector,pts))\n at=len(vs)\n for i,pt in enumerate(P):\n tangent=(P[min(len(P)-1,i+1)]-P[max(0,i-1)]).normalized()\n ref=Vector((0,0,1)) if abs(tangent.z)<.90 else Vector((0,1,0))\n x0=tangent.cross(ref).normalized()\n y0=x0.cross(tangent).normalized()\n rad=r(i/(len(P)-1)) if callable(r) else r\n for j in range(n):\n a=tau*j/n\n vs.append(pt+rad*(x0*math.cos(a)+flat*y0*math.sin(a)))\n tex.append((j/n,i/(len(P)-1)*2.1))\n for i in range(len(P)-1):\n for j in range(n):\n k=(j+1)%n\n fs.append((at+i*n+j,at+i*n+k,at+(i+1)*n+k,at+(i+1)*n+j))\n fs.extend([tuple(at+j for j in reversed(range(n))),tuple(at+(len(P)-1)*n+j for j in range(n))])\n\n\ndef pipe(name,pts,r,m,flat=1,steps=9):\n bag=trim[(name,m)]\n add_tube(bag,pts,r,steps,flat)\n\n\ndef dashed(name,path,m,pitch=.40,r=.023):\n nodes=[Vector(path(float(t))) for t in np.linspace(0,1,361)]\n length=[0.]\n for a,b in zip(nodes,nodes[1:]):\n length.append(length[-1]+(b-a).length)\n import bisect\n def sample(d):\n i=max(0,min(len(nodes)-2,bisect.bisect_right(length,d)-1))\n delta=max(.00001,length[i+1]-length[i])\n return nodes[i].lerp(nodes[i+1],max(0,min(1,(d-length[i])/delta)))\n n=max(2,int(length[-1]/pitch))\n length_actual=(length[-1]/n)\n for j in range(n):\n a,b=sample((j+.10)*length_actual),sample((j+.77)*length_actual)\n mid=a.lerp(b,.5)\n pipe(name,[a,mid,b],r,m,flat=.82,steps=6)\n\n\ndef section(profile,t):\n i=next((k for k in range(len(profile)-1) if t<=profile[k+1][0]),len(profile)-2)\n a,b=profile[i],profile[i+1]\n prev,nxt=profile[max(0,i-1)],profile[min(i+2,len(profile)-1)]\n delta=b[0]-a[0]\n u=max(0,min(1,(t-a[0])/delta))\n return tuple((2*u**3-3*u*u+1)*a[j]+(u**3-2*u*u+u)*delta*(b[j]-prev[j])/(b[0]-prev[0])+\n (-2*u**3+3*u*u)*b[j]+(u**3-u*u)*delta*(nxt[j]-a[j])/(nxt[0]-a[0])\n for j in range(1,len(a)))\n\n\ndef gaussian(t,center,width):\n return math.exp(-((t-center)/width)**2)\n\n\nbody_profile=[\n (0,9.0,25.4,10.9,9.4),(.15,17.9,25.8,10.6,9.8),\n (.35,30.2,26.7,11.,10.5),(.55,43.0,28.1,12.5,11.1),\n (.68,51.3,28.7,13.0,11.35),(.77,56.7,28.5,13.3,11.07),\n (.85,62.0,27.8,12.9,9.85),(.90,65.5,24.4,12.0,8.60),\n (.955,68.0,16.2,8.4,7.39),(1,69.01,8.78,5.43,6.86)\n]\n\n\ndef gap(t):\n return .017+.793*max(0,(t-.786)/.214)**1.63\n\n\ndef torso(a,t):\n z,w,f,b=section(body_profile,t)\n c,s=math.cos(a),math.sin(a)\n x0=w*s\n side=-1 if s<0 else 1\n front=max(0,c)**.31\n rear=max(0,-c)\n y0=-(f if c>=0 else b)*math.copysign(abs(c)**(.63 if c>0 else .74),c)\n drape=(.59*math.sin(a*13+.7+t*8.4)+.32*math.sin(a*23-1.19+t*14))*gaussian(t,.16,.22)\n drape+=.21*math.sin(7*a+7.5*t)+.09*math.sin(14*a-11*t)\n drape+=.36*gaussian(abs(x0),18.6,5.4)*gaussian(t,.48,.18)*math.cos(t*39+side*.55)\n drape+=.61*gaussian(abs(x0),23.0,9.2)*gaussian(t,.67,.092)*math.cos(74*t+abs(x0)*.38)\n y0-=drape*front\n y0+=rear*(.52*math.sin(9*a-10*t)*gaussian(t,.69,.33)+.63*gaussian(t,.67,.14)*math.sin(abs(x0)*.35))\n x0+=s*.62*math.sin(10*t+a*7)*gaussian(t,.4,.4)\n z+=.39*math.cos(6*a+.8)*(1-t)**1.4+.28*math.sin(4*a)*math.sin(math.pi*t)\n z-=2.19*front*max(0,(t-.835)/.165)**1.82\n return Vector((x0,y0,z))\n\n\ndef theta(u,t):\n g=gap(t)\n return g+(tau-2*g)*u\n\n\ndef armhole(u,t):\n a=theta(u,t)\n center=math.pi/2 if a0)\n make_shell(o,.143)\n for tt in (.85,.947):\n dashed(\"Double topstitch around collar\",lambda u,tt=tt:collar(u,tt)+Vector((0,-.02,.045)),\n stitch,.345,.024)\n pipe(\"Gently rounded collar point\", [collar(t,.995)+Vector((0,-.034,.015)) for t in np.linspace(0,1,104)],.073,faded,.67)\n\n# The back yoke seam is visible at an angle and uses its own construction line.\nfor z0 in (.791,.808):\n dashed(\"Two rear yoke seams\",lambda u,z0=z0:torso(math.pi*.55+u*math.pi*.90,z0)+Vector((0,.080,0)),blue_stitch,.40,.027)\npipe(\"Back yoke felled ridge\",[torso(math.pi*.55+u*math.pi*.9,.800)+Vector((0,.046,0)) for u in np.linspace(0,1,131)],\n .067,faded,.82)\n\nfor s in (-1,1):\n half=math.pi/2 if s>0 else 3*math.pi/2\n def arm_ring(a,s=s,half=half):\n t=.754+.123*math.sin(a)\n th=half-s*.447*math.cos(a)\n return torso(th,t)+Vector((s*.092,0,0))\n\n profile=[\n (0,28.1,0.,55.4,8.0,8.43),(.14,31.64,-.34,51.4,7.74,7.61),\n (.31,34.81,-.82,42.5,7.12,6.83),(.53,37.07,-1.55,31.56,6.37,6.27),\n (.74,38.73,-3.53,20.34,5.77,5.32),(.91,39.56,-4.71,10.52,5.2,4.71),\n (1,39.99,-4.90,5.10,4.99,4.48)\n ]\n def sleeve(a,t):\n x,y,z,wy,wx=section(profile,t)\n phase=t*34+1.37*math.sin(a*2+.39*s)\n crease=(.52+.08*s)*gaussian(t,.55,.17)*math.sin(phase)+.21*gaussian(t,.17,.16)*math.cos(t*46-a*4)\n crease+=.44*gaussian(t,.83,.105)*math.sin(t*59+math.cos(a*2)*2.1)\n crease+=.25*math.cos(a*8+12*t)*gaussian(t,.42,.52)\n w=(1-t)*.204*math.sin(4*a+.37*s)+crease\n xx=s*(x+math.sin(a)*(wx+w)) + .61*math.sin(t*3.1+s)*math.sin(math.pi*t)\n yy=y-math.cos(a)*(wy+w)+1.3*s*math.sin(math.pi*t)-.51*s*t**3\n zz=z+(7.7*math.exp(-5.2*t)+2.02)*math.sin(a)*(.5+.51*(1-t))+.30*math.cos(a+t*9)+.86*s*t*t\n target=Vector((xx,yy,zz))\n blend=min(1,t/.242)\n blend=blend*blend*(3-2*blend)\n start=arm_ring(a)\n start+=Vector((s*5.5*t,-.2*t,-8.05*t))\n return start.lerp(target,blend)\n\n label0=\"Left\" if s>0 else \"Right\"\n # Reverse U for the mirrored sleeve so its outward surface remains the face.\n def sleeve_fn(u,t,s=s):\n a=tau*(1-u if s>0 else u)\n return sleeve(a,t)\n o=grid(label0+\" anatomically curved sleeve\",sleeve_fn,fabric,129,132,\n uv=lambda u,v:(u*2.44+.14,v*2.39+.085),wrap=False)\n make_shell(o,.106)\n for v in (.010,.023):\n dashed(label0+\" rounded armhole topstitch\", lambda u,v=v:sleeve(tau*u,v)+Vector((s*.069,0,.034)),\n stitch,.379,.024)\n pipe(label0+\" armhole felled seam\", [sleeve(tau*u,.006)+Vector((s*.068,0,.029)) for u in np.linspace(0,1,162)],\n .083,faded,.76)\n c_a=.52 if s>0 else -.63\n for shift in (-.023,.029):\n dashed(label0+\" outer sleeve seam stitch\",lambda t,shift=shift:sleeve(c_a+shift,t)+Vector((s*.063,-.062,0)),blue_stitch,.395,.025)\n\n def cuff(u,v,s=s):\n t=.902+.095*v\n a=tau*(1-u if s>0 else u)\n return sleeve(a,t)+Vector((s*.156*math.sin(a),-.156*math.cos(a),-.037*v))\n o=grid(label0+\" sturdy denim cuff band\",cuff,faded,33,125,\n uv=lambda u,v:(u*2.41+.19,v*.26+.16))\n make_shell(o,.153)\n for v0 in (.15,.847):\n dashed(label0+\" cuff twin topstitch\",lambda u,v0=v0:cuff(u,v0)+Vector((0,-.054,-.034)),stitch,.31,.022)\n pipe(label0+\" cuff roll at open end\",[cuff(u,.998) for u in np.linspace(0,1,146)],.116,faded,.65)\n points=[]\n for a in np.linspace(.06,.37,63):\n start=cuff(a,.92)\n end=cuff(a,.40)\n points.append(start.lerp(end,float(.72-.12*math.sin(a*14))))\n pipe(label0+\" cuff clasp overlap\",points,.082,faded,.62)\n\n# Shaped patch pockets, each following its local bodice curvature.\npockets=[(\"Left breast\", -14.9,39.5,12.25,14.41,.86),\n (\"Left hip\",-14.25,15.4,17.4,16.63,.91),\n (\"Right hip\",14.54,15.5,17.15,16.83,1.12)]\nfor nm,c,z,w,h,drop in pockets:\n def pocket(u,v,c=c,z=z,w=w,h=h,drop=drop):\n q=2*u-1\n breadth=w*(.416+.081*math.sin(.5*math.pi*v)**.52)\n wav=.30*math.sin(8.1*v+c*.51)*q+.14*math.sin(18*v)\n x=c+q*breadth + .16*math.sin(math.pi*v) + wav\n zz=z+h*v+drop*q*q*(1-v)**2+.370*q*(.23+.77*v**3)\n bulge=(.27+.47*math.sin(math.pi*v)**.68)*math.sin(math.pi*u)**.59\n lip=.70*v**9*(.53+.47*math.sin(math.pi*u))\n y=front_y(x,zz)-.204-bulge-lip-.09*math.cos(16*v+q*3)\n return Vector((x,y,zz))\n pa=grid(nm+\" patch pocket\",pocket,fabric,76,65,\n uv=lambda u,v:(u*w/27.5+.19,v*h/27.5+.35))\n make_shell(pa,.124)\n lip=grid(nm+\" rolled pocket welt\",lambda u,v:pocket(u,.892+.105*v)+Vector((0,-.084,-.027)),\n faded,21,65,uv=lambda u,v:(u*w/27.5+.19,v*.16+.31))\n make_shell(lip,.115)\n pipe(nm+\" fabric roll at pocket mouth\",[pocket(t,.995)+Vector((0,-.077,.016)) for t in np.linspace(0,1,110)],.102,faded,.73)\n for u0 in (.038,.093,.905,.96):\n dashed(nm+\" side attachment stitches\",lambda v,u0=u0:pocket(u0,.051+.890*v)+Vector((0,-.072,0)),stitch,.35,.027)\n for v0 in (.040,.083,.913,.950):\n dashed(nm+\" top and hem lines\",lambda u,v0=v0:pocket(.043+.916*u,v0)+Vector((0,-.112,0)),stitch,.345,.026)\n for x in (.052,.949):\n for v in (.895,.911,.925):\n a=pocket(x-.019,v)+Vector((0,-.09,0))\n b=pocket(x+.022,v)+Vector((0,-.09,.016))\n pipe(nm+\" pocket bartacks\",[a,a.lerp(b,.5),b],.040,blue_stitch,.83,7)\n\n# Buttons have spun rims, raised collars and incised thread holes.\ndef button(name,center,radius,m,forward=(0,-1,0)):\n direction=Vector(forward).normalized()\n q=Vector((0,0,1)).rotation_difference(direction)\n c=Vector(center)\n # Radial profile from underside to rolled rim and recessed engraved face.\n profile=[(.02,0),(.64,0),(.80,.074),(.91,.149),(1,.241),(.988,.32),(.912,.393),\n (.808,.418),(.729,.383),(.636,.321),(.06,.298),(.02,.298)]\n V,F=[],[]\n n=72\n for factor,z in profile:\n for j in range(n):\n th=tau*j/n\n V.append(c+q@Vector((radius*factor*math.cos(th),radius*factor*math.sin(th),radius*z)))\n for i in range(len(profile)):\n k=(i+1)%len(profile)\n for j in range(n):\n a=(j+1)%n\n F.append((i*n+j,i*n+a,k*n+a,k*n+j))\n o=mesh(name,V,F,m,closed=True)\n for j in range(24):\n t=tau*j/24\n a=c+q@Vector((.790*radius*math.cos(t),.790*radius*math.sin(t),.400*radius))\n b=c+q@Vector((.847*radius*math.cos(t),.847*radius*math.sin(t),.404*radius))\n pipe(\"Button rim tooling\",[a,a.lerp(b,.5),b],radius*.024,ox,.73,6)\n # Tiny oxidized depressions and stitches are modeled on the face.\n for side in (-1,1):\n vside=.216*side\n pts=[c+q@Vector((radius*(vside+.086*math.cos(t)),radius*.074*math.sin(t),radius*.310))\n for t in np.linspace(0,tau,42)]\n pipe(\"Paired recessed button holes\",pts,.077*radius,ox,.56,8)\n a=c+q@Vector((-.225*radius,0,.343*radius))\n b=c+q@Vector((.225*radius,0,.343*radius))\n mid=c+q@Vector((0,.018*radius,.386*radius))\n pipe(\"Visible button thread\",[a,mid,b],.065*radius,blue_stitch,.80,10)\n\nfor i,z in enumerate((14.83,24.19,33.86,43.42,52.64,60.12)):\n t=(z-9.3)/53.6\n x=placket(-1,.37,t).x if i==5 else (-.21-.61*max(0,(t-.82)/.18))\n y=min(placket(-1,.24,t).y,front_y(x,z)-.79)-.10\n button(\"Copper front closure button %02d\"%(i+1),(x,y,z),.86,copper)\nfor s in (-1,1):\n x=s*41.45\n y=-8.89-(s*.35)\n button(\"Copper cuff button\",(x,y,7.78+.45*s),.68,copper,forward=(s*.54,-.84,.05))\n\n# A small interior woven maker label on the weft side.\ndef box(name,loc,dims,m,b=.01,use=True):\n bpy.ops.mesh.primitive_cube_add(size=2,location=loc)\n ob=bpy.context.object\n ob.dimensions=dims\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n if b:\n bevel=ob.modifiers.new(\"Soft corner radius\",\"BEVEL\")\n bevel.width=b\n bevel.segments=3\n return register(ob,name,m,False,use)\n\n\ndef lettering(name,s,c,size,m):\n d=bpy.data.curves.new(name,\"FONT\")\n d.body=s\n d.align_x=\"CENTER\"\n d.align_y=\"CENTER\"\n d.size=size\n d.space_character=1.15\n d.extrude=.004\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n ob.location=c\n ob.rotation_euler.x=math.pi/2\n bpy.ops.object.select_all(action=\"DESELECT\")\n ob.select_set(True)\n bpy.context.view_layer.objects.active=ob\n bpy.ops.object.convert(target=\"MESH\")\n register(bpy.context.object,name,m)\n\n\nbox(\"Interior woven neck label\",(0,5.632,69.26),(5.27,.126,1.63),felt,.089)\nlettering(\"Woven neck label text\",\"LOOM / 07\",(0,5.559,69.43),.623,ink)\nlettering(\"Woven label fiber caption\",\"INDIGO TWILL\",(0,5.556,68.945),.267,ink)\n\nfor (name,m),(vertices,faces,uv) in trim.items():\n mesh(name,vertices,faces,m,uv,closed=True)\n\nroot=bpy.data.objects.new(\"Loom 07 washed indigo chore jacket\",None)\nbpy.context.collection.objects.link(root)\nroot[\"asset_id\"]=\"clothes-loom-07-indigo-chore-jacket-v1\"\nroot[\"category\"]=\"clothes\"\nroot[\"fit\"]=\"adult jacket, relaxed fit, static hanging shape\"\nroot[\"units\"]=\"meters in glTF\"\nfor ob in parts:\n ob.parent=root\nroot.location.z=-2.\nif not args.draft and not args.preview_only:\n root.scale=(.01,)*3\n root.location.z=-.02\n bpy.context.view_layer.update()\n bpy.ops.object.select_all(action=\"DESELECT\")\n root.select_set(True)\n for ob in parts:\n ob.select_set(True)\n bpy.ops.export_scene.gltf(filepath=str(out/(stem+\".glb\")),export_format=\"GLB\",use_selection=True,\n export_apply=True,export_yup=True,export_extras=True)\n root.scale=(1,)*3\n root.location.z=-2.\n\n# Studio clothing photograph, using the same geometry and material settings.\nstage=mat(\"Warm stone-gray photographic sweep\",\"57544F\",.91)\nstations=[(-550,-.08),(47,-.08)]\nfor i in range(1,50):\n a=(math.pi/2)*i/49\n stations.append((47+88*math.sin(a),88*(1-math.cos(a))-.08))\nstations += [(135,360)]\nvertices=[(x,y,z) for y,z in stations for x in (-320,320)]\nfaces=[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(stations)-1)]\nob=mesh(\"Photographic cove\",vertices,faces,stage)\nparts.remove(ob)\nob.data.polygons[0].use_smooth=False\n\n\ndef aim(ob,at):\n ob.rotation_euler=(Vector(at)-ob.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef area(name,loc,at,power,c,w,h):\n d=bpy.data.lights.new(name,\"AREA\")\n d.energy=power\n d.color=c\n d.shape=\"RECTANGLE\"\n d.size=w\n d.size_y=h\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n ob.location=loc\n aim(ob,at)\n\n\narea(\"Large angled fabric softbox\",(-66,-81,108),(0,0,43),175000,(1,.935,.846),69,78)\narea(\"Cool rim from camera right\",(59,24,81),(0,0,41),141000,(.76,.86,1),43,85)\narea(\"Soft front right bounce\",(51,-63,44),(0,0,38),43200,(.90,.94,1),57,73)\narea(\"Warm lower bounce\",(-32,-43,30),(0,0,33),5900,(1,.90,.77),33,21)\nscene=bpy.context.scene\nscene.world.use_nodes=True\nw=scene.world.node_tree.nodes[\"Background\"]\nw.inputs[\"Color\"].default_value=(.17,.19,.22,1)\nw.inputs[\"Strength\"].default_value=.34\nd=bpy.data.cameras.new(\"Apparel portrait camera\")\ncamera=bpy.data.objects.new(d.name,d)\nbpy.context.collection.objects.link(camera)\ncamera.location=(38,-173,106)\nd.lens=59\nd.clip_end=6000\naim(camera,(0,-.53,36.7))\nscene.camera=camera\nscene.render.engine=\"CYCLES\"\nscene.cycles.samples=18 if args.draft else 119\nscene.cycles.use_denoising=False\nscene.cycles.adaptive_threshold=.076 if args.draft else .015\nscene.cycles.max_bounces=7\nscene.view_settings.view_transform=\"AgX\"\nscene.view_settings.look=\"AgX - Medium High Contrast\"\nscene.view_settings.exposure=.20\nscene.render.resolution_x=1640\nscene.render.resolution_y=1800\nscene.render.resolution_percentage=43 if args.draft else 100\nscene.render.image_settings.file_format=\"PNG\"\nscene.render.image_settings.color_mode=\"RGB\"\nscene.render.filepath=str(out/(\"draft.png\" if args.draft else stem+\".png\"))\nbpy.ops.render.render(write_still=True)\n```\n\nrun it: `blender -b --python chore.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261126T2300Z-clothes-washed-indigo-chore-jacket.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/washed-indigo-chore-jacket/3d-dataset-20261126T2300Z-clothes-washed-indigo-chore-jacket.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/cedarline-parlor-guitar.jpg"}}, {"type": "text", "text": "create an image of a cedarline p-12 parlor guitar"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA small-bodied acoustic parlor guitar standing upright, front view. Bookmatched cedar top with cream binding, round soundhole with a fine inlaid rosette, dark moustache bridge with bone saddle and pins, long dark fretboard with pearl dots joining the body at the 12th fret, and a slotted headstock with three brass tuners per side and a \"CEDARLINE\" logo. Mahogany sides show at the edge.\n\nSCALE\nAbout 37 cm wide, 94 cm tall, 11 cm deep. Build in meters, +Y up, +Z forward (top faces +Z), origin on the support plane under the center of the lower bout.\n\nPARTS\n1. Body: right-side outline from shaped bout and waist segments, mirrored. Bookmatched cedar top with an open soundhole, carved mahogany back, bent sides. Build: outline curve, front and back panels with thickness, a rim for the sides.\n2. Rosette and binding: maple lines, rosewood marquetry ring, maple and cinnamon diamonds, cream body binding. Build: concentric annuli plus small inlaid lozenges.\n3. Inside: spruce braces, kerfed lining and a kraft label visible through the soundhole. Build: boxes and a text label.\n4. Bridge: low moustache-shaped ebony bridge, compensated bone saddle, ebony pins with bone dots. Build: carved profile mesh, small cylinders for pins.\n5. Neck and fretboard: 12-fret neck at real scale length, slightly radiused ebony fretboard, nickel frets, pearl markers, bone nut. Build: neck profile lofted along its length, frets as thin bars.\n6. Headstock and strings: slotted headstock with two milled openings, brass tuner plates with rollers, six strings (three wound, three plain) with coils at the rollers. Build: rounded cutter subtraction for the slots, tubes for the strings.\n\nPLAN\n1. Setup: clear the scene, meters, origin under the lower bout.\n2. Texture maps: generated inside cedarline.py. Cedar grain, figured mahogany, ebony streaks and maple figure.\n3. Build order: body outline and panels, rosette and binding, inner bracing and label, bridge, neck and fretboard, headstock and slots, strings.\n4. Assemble: neck joins the body at the 12th fret, saddle-to-nut distance matches the scale length, strings run from bridge pins over the saddle and nut to the rollers.\n5. Materials: cedar top, satin mahogany, ebony, cream maple binding, bone, brass tuners, nickel frets, pearl markers, phosphor bronze and steel strings.\n6. Export: guitar only, standing exactly upright, one GLB with the textures embedded.\n\nCHECK\n588,040 triangles across 218 parts. Against the image: soundhole centered between the waist and the fretboard end, bridge in the lower bout, neck about as long as the body, slots visible in the headstock.\n\n\n```python\n# cedarline.py\n\"\"\"Build the original Cedarline 12-fret acoustic parlor guitar in centimeters.\"\"\"\nimport argparse\nfrom collections import defaultdict\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Vector\nimport numpy as np\n\nap=argparse.ArgumentParser()\nap.add_argument(\"--output\",type=Path,required=True)\nap.add_argument(\"--draft\",action=\"store_true\")\nap.add_argument(\"--preview-only\",action=\"store_true\")\nargs=ap.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261127T0100Z-musical-instruments-cedarline-parlor-guitar\"\nrng=np.random.default_rng(7749)\ntau=math.tau\nparts=[]\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\n\n\ndef rgb(c):\n values=[int(c[i:i+2],16)/255 for i in (0,2,4)]\n return tuple(c/12.92 if c<=.04045 else ((c+.055)/1.055)**2.4 for c in values)\n\n\ndef mat(name,c,rough,metal=0,coat=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*rgb(c),1)\n m.use_nodes=True\n bs=m.node_tree.nodes.get(\"Principled BSDF\")\n bs.inputs[\"Base Color\"].default_value=m.diffuse_color\n bs.inputs[\"Roughness\"].default_value=rough\n bs.inputs[\"Metallic\"].default_value=metal\n bs.inputs[\"Coat Weight\"].default_value=coat\n bs.inputs[\"Coat Roughness\"].default_value=.21\n return m\n\n\ndef img(name,d,colorspace):\n h,w=d.shape[:2]\n a=np.concatenate((d,np.ones((h,w,1),np.float32)),axis=-1)\n im=bpy.data.images.new(name,width=w,height=h,alpha=False)\n im.colorspace_settings.name=colorspace\n im.pixels.foreach_set(np.ascontiguousarray(a,dtype=np.float32).ravel())\n im.file_format=\"PNG\"\n im.filepath_raw=str(out/(name+\".png\"))\n im.save()\n im.reload()\n im.colorspace_settings.name=colorspace\n return im\n\n\ndef texture(m,i,socket,strength=None):\n nt=m.node_tree\n t=nt.nodes.new(\"ShaderNodeTexImage\")\n t.image=i\n dst=nt.nodes.get(\"Principled BSDF\").inputs[socket]\n if strength is None:\n nt.links.new(t.outputs[\"Color\"],dst)\n else:\n n=nt.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=strength\n nt.links.new(t.outputs[\"Color\"],n.inputs[\"Color\"])\n nt.links.new(n.outputs[\"Normal\"],dst)\n\n\nN=1536\nv,u=np.mgrid[:N,:N].astype(np.float32)/N\ndef noise(nx,ny,X=u,Y=v):\n xx,yy=X*nx,Y*ny\n i,j=np.floor(xx).astype(int),np.floor(yy).astype(int)\n x,y=xx-i,yy-j\n x=x*x*(3-2*x)\n y=y*y*(3-2*y)\n q=rng.uniform(-1,1,(ny,nx)).astype(np.float32)\n a=q[j%ny,i%nx]*(1-x)+q[j%ny,(i+1)%nx]*x\n b=q[(j+1)%ny,i%nx]*(1-x)+q[(j+1)%ny,(i+1)%nx]*x\n return a*(1-y)+b*y\n\n\ndef normal(z,ax,ay):\n dx=(np.roll(z,-1,axis=1)-np.roll(z,1,axis=1))*ax\n dy=(np.roll(z,-1,axis=0)-np.roll(z,1,axis=0))*ay\n q=np.sqrt(1+dx*dx+dy*dy)\n return np.stack((.5-.5*dx/q,.5-.5*dy/q,.5+.5/q),axis=-1)\n\n\ndef gray(z):\n return np.repeat(z[:,:,None],3,axis=2)\n\n\num=.5+np.abs(u-.5)\nwarp=um+.0025*noise(19,6,um,v)+.0014*np.sin(tau*(2.8*v+1.3*um))\nphase=warp*153+.49*noise(57,3,um,v)+.32*noise(21,2,um,v)\ndark_line=(.5+.5*np.cos(tau*phase))**11\nfiber=noise(283,13,um,v)*.034+noise(590,49,um,v)*.020\ngrowth=.039*noise(103,4,um,v)+.034*noise(47,3,um,v)+.025*noise(7,2,um,v)\ncross=.017*np.sin(tau*(v*31+um*2.6+.50*noise(9,17,um,v)))\nwood=np.stack((.705+growth*.79+fiber*.60-dark_line*.081+cross*.67,\n .455+growth*.95+fiber*.74-dark_line*.079+cross*.79,\n .238+growth*.83+fiber*.75-dark_line*.062+cross*.44),axis=-1)\nedge=np.clip((np.abs(u-.5)*2)**5*.065,0,.065)\nwood-=edge[:,:,None]*np.array([.57,.57,.67])\nwood=np.clip(wood,.035,.95)\ncem=mat(\"Bookmatched western red cedar soundboard\",\"B5784A\",.33,0,.285)\ntexture(cem,img(\"Cedar_Bookmatched_BaseColor\",wood,\"sRGB\"),\"Base Color\")\nheight=-dark_line*.096+fiber*.711+growth*.24+cross*.14\ntexture(cem,img(\"Cedar_Grain_Normal\",normal(height,3.61,2.15),\"Non-Color\"),\"Normal\",.46)\nrc=.354+.055*dark_line+.019*noise(41,17)+.016*noise(83,19)\ntexture(cem,img(\"Cedar_Satin_Roughness\",gray(rc),\"Non-Color\"),\"Roughness\")\n\nskew=u+.013*np.sin(tau*(v*2.11+u*.51))+.022*noise(17,4)\nphase2=skew*91+.33*noise(29,6)\ngrain2=(.5+.5*np.cos(tau*phase2))**9\nflame=(.5+.5*np.sin(tau*(v*12.2+u*.71+.64*noise(7,6))))**3.5\npore=(.5+.5*np.cos(tau*(194*u+1.31*v+.43*noise(15,72))))**18\nbrown=.052*noise(54,8)+.057*noise(14,6)+.022*noise(400,25)\nmah=np.stack((.429+brown-.055*grain2-.061*pore+.065*flame,\n .247+brown*.77-.040*grain2-.046*pore+.041*flame,\n .170+brown*.71-.036*grain2-.029*pore+.028*flame),axis=-1)\nmahogany=mat(\"Satin finished figured mahogany\",\"775040\",.35,.0,.31)\ntexture(mahogany,img(\"Mahogany_Figure_BaseColor\",np.clip(mah,.04,.88),\"sRGB\"),\"Base Color\")\nmah_norm=img(\"Mahogany_Pores_Normal\",normal(-.115*grain2-.118*pore+.46*brown+.024*flame,3.0,1.8),\"Non-Color\")\ntexture(mahogany,mah_norm,\"Normal\",.48)\neb=.037*noise(52,5)+.053*noise(14,3)+.013*noise(344,34)\nebcolor=np.stack((.157+eb-.027*grain2,.111+eb*.69-.021*grain2,.085+eb*.57-.015*grain2),axis=-1)\nebony=mat(\"Oiled streaked ebony, bridge and fretboard\",\"30271F\",.46,.0,.12)\ntexture(ebony,img(\"Ebony_Streak_BaseColor\",np.clip(ebcolor,.03,.26),\"sRGB\"),\"Base Color\")\ntexture(ebony,mah_norm,\"Normal\",.29)\nbinding=mat(\"Aged cream maple body binding\",\"DABB87\",.42,0,.20)\nivory=mat(\"Unbleached bone, nut and saddle\",\"D8CEAE\",.39,0,.16)\nrose=mat(\"Rosewood rosette inlays\",\"653A2B\",.42,0,.22)\nmidwood=mat(\"Cinnamon and maple marquetry\",\"A56843\",.42,0,.19)\nlam=mat(\"Interior pale spruce and kerf lining\",\"9B754F\",.82)\nins=mat(\"Unfinished mahogany interior\",\"644737\",.77)\ndark=mat(\"Ebony-black purfling and pin heads\",\"28211E\",.45)\nsteel=mat(\"Nickel silver fret wire\",\"A4ADB0\",.28,.90,.08)\nbrass=mat(\"Patinated vintage brass tuner plates\",\"8E7548\",.31,.79,.09)\nbronze=mat(\"Phosphor bronze wound strings\",\"AD8A52\",.34,.79,.10)\nwire=mat(\"Plain bright steel treble strings\",\"B6BABB\",.31,.86)\npearl=mat(\"Warm mother-of-pearl markers\",\"D5D5BE\",.33,.11,.28)\npaper=mat(\"Kraft instrument label\",\"C5A77B\",.86)\nink=mat(\"Dark letterpress ink\",\"493125\",.78)\nclear_wood=mat(\"Maple geometric rosette inlay\",\"BE8C51\",.45,.0,.17)\n\n\ndef mesh(name,V,F,m,uv=None,idx=None,closed=False,smooth=True):\n d=bpy.data.meshes.new(name)\n d.from_pydata(V,[],F)\n d.update()\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n for mat0 in m if isinstance(m,list) else [m]:\n d.materials.append(mat0)\n if uv is not None:\n layer=d.uv_layers.new(name=\"UVMap\")\n for poly,c in zip(d.polygons,uv):\n for j,li in enumerate(poly.loop_indices):\n layer.data[li].uv=c[j]\n for j,poly in enumerate(d.polygons):\n poly.use_smooth=smooth\n if idx is not None:\n poly.material_index=idx[j]\n if closed:\n bm=bmesh.new()\n bm.from_mesh(d)\n bmesh.ops.recalc_face_normals(bm,faces=bm.faces[:])\n bm.to_mesh(d)\n bm.free()\n parts.append(ob)\n return ob\n\n\ndef register(ob,name,m,smooth=False):\n ob.name=name\n ob.data.materials.append(m)\n if smooth:\n for f in ob.data.polygons:\n f.use_smooth=True\n parts.append(ob)\n return ob\n\n\ndef smooth_bevel(ob,width,segments=3):\n if not width:\n return\n b=ob.modifiers.new(\"Hand-softened component radius\",\"BEVEL\")\n b.width=width\n b.segments=segments\n b.harden_normals=True\n ob.modifiers.new(\"Weighted normals\",\"WEIGHTED_NORMAL\")\n\n\ndef capsule(name,c,dims,m,b=0.04,rot=None):\n bpy.ops.mesh.primitive_cube_add(size=2,location=c)\n ob=bpy.context.object\n ob.dimensions=dims\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n if rot:\n ob.rotation_euler=rot\n register(ob,name,m)\n smooth_bevel(ob,b)\n return ob\n\n\ndef bez(a,b,c,d,t):\n s=1-t\n return tuple(s**3*a[i]+3*s*s*t*b[i]+3*s*t*t*c[i]+t**3*d[i] for i in range(len(a)))\n\n\ndef sample_path(segments,ns=29):\n p=[]\n for q in segments:\n p.extend(bez(*q,i/ns) for i in range(ns))\n p.append(segments[-1][-1])\n return p\n\n\n# Right body outline built from shaped bout and waist segments.\noutline_right=sample_path([\n [(0,0),(9.8,-.21),(16.59,3.85),(17.55,9.80)],\n [(17.55,9.80),(19.15,16.02),(17.39,20.88),(13.92,24.04)],\n [(13.92,24.04),(10.71,26.51),(10.11,28.43),(11.04,30.92)],\n [(11.04,30.92),(12.08,33.65),(14.02,35.05),(13.46,38.99)],\n [(13.46,38.99),(12.91,43.12),(10.24,44.82),(6.61,45.81)],\n [(6.61,45.81),(4.19,46.61),(2.39,46.65),(0,46.62)]\n],36)\noutline=outline_right+[(-x,z) for x,z in reversed(outline_right[1:-1])]\nSOUND_Z=31.22\nHOLE=4.14\n\n\ndef top_y(x,z):\n return -4.735+.0122*z+.0021*x*x+.00048*(z-24)**2\n\n\ndef back_y(x,z):\n return 4.906-.0208*z-.0028*x*x-.00077*(z-22)**2\n\n\ndef front_uv(x,z):\n return .5+x/39.,.044+z/50.\n\n\ndef front_panel():\n V,F,UV=[],[],[]\n n=len(outline)\n rings=86\n for j in range(rings+1):\n v=j/rings\n for x,z in outline:\n a=math.atan2(z-SOUND_Z,x)\n ix,iz=HOLE*math.cos(a),SOUND_Z+HOLE*math.sin(a)\n px,pz=(1-v)*ix+v*x,(1-v)*iz+v*z\n V.append((px,top_y(px,pz),pz))\n for j in range(rings):\n for i in range(n):\n a,b=j*n+i,j*n+(i+1)%n\n q=(a,b,b+n,a+n)\n q=tuple(reversed(q))\n F.append(q)\n UV.append([front_uv(V[k][0],V[k][2]) for k in q])\n ob=mesh(\"Bookmatched cedar soundboard with open soundhole\",V,F,[cem,lam],UV)\n # Enforce the shell direction toward the instrument cavity.\n f=next(poly for poly in ob.data.polygons if abs(poly.normal.y)>.80)\n if f.normal.y>0:\n bm=bmesh.new()\n bm.from_mesh(ob.data)\n bmesh.ops.reverse_faces(bm,faces=bm.faces[:])\n bm.to_mesh(ob.data)\n bm.free()\n p=ob.modifiers.new(\"Soundboard thickness and soundhole wall\",\"SOLIDIFY\")\n p.thickness=.286\n p.offset=-1\n p.material_offset=1\n p.material_offset_rim=1\nfront_panel()\n\n\ndef back_panel():\n V,F,UV=[],[],[]\n n=len(outline)\n c=23.1\n for j in range(65):\n r=.00034+(1-.00034)*j/64\n for x,z in outline:\n xx,zz=r*x,c+r*(z-c)\n V.append((xx,back_y(xx,zz),zz))\n for j in range(64):\n for i in range(n):\n a,b=j*n+i,j*n+(i+1)%n\n q=(a,b,b+n,a+n)\n F.append(q)\n UV.append([front_uv(V[k][0],V[k][2]) for k in q])\n ob=mesh(\"Bookmatched carved mahogany back plate\",V,F,[mahogany,ins],UV)\n f=next(poly for poly in ob.data.polygons if abs(poly.normal.y)>.80)\n if f.normal.y<0:\n bm=bmesh.new()\n bm.from_mesh(ob.data)\n bmesh.ops.reverse_faces(bm,faces=bm.faces[:])\n bm.to_mesh(ob.data)\n bm.free()\n p=ob.modifiers.new(\"Shaped back plate thickness\",\"SOLIDIFY\")\n p.thickness=.322\n p.offset=-1\n p.material_offset=1\n p.material_offset_rim=1\nback_panel()\n\n\ndef rim(name,profile,material,closed=True):\n V,F,UV=[],[],[]\n n=len(outline)\n total=[0.]\n for i,(p0,q0) in enumerate(outline):\n j=(i+1)%n\n total.append(total[-1]+math.hypot(p0-outline[j][0],q0-outline[j][1]))\n for thunk in profile:\n for x,z in outline:\n V.append(thunk(x,z))\n for j in range(len(profile) if closed else len(profile)-1):\n k=(j+1)%len(profile)\n for i in range(n):\n l=(i+1)%n\n F.append((j*n+i,j*n+l,k*n+l,k*n+i))\n a,b=total[i]/total[-1]*2,total[i+1]/total[-1]*2\n v,w=j/len(profile),(j+1)/len(profile)\n UV.append([(a,v),(b,v),(b,w),(a,w)])\n return mesh(name,V,F,material,UV,closed=closed)\n\n\ndef sidefun(r,t):\n def f(x,z):\n xp,zp=r*x,23.1+r*(z-23.1)\n yf,yb=top_y(x,z)+.057,back_y(x,z)-.074\n return xp,yf*(1-t)+yb*t,zp\n return f\n\n\nrim(\"Bent mahogany sides with continuous interior wall\",\n [sidefun(1.001,.021),sidefun(1.009,.089),sidefun(1.011,.36),\n sidefun(1.011,.64),sidefun(1.009,.925),sidefun(1.002,.984),\n sidefun(.989,.990),sidefun(.984,.913),sidefun(.984,.106),sidefun(.989,.011)],mahogany)\nfor name,get_y,sign in ((\"Front\",top_y,-1),(\"Rear\",back_y,1)):\n def stripef(s,d):\n def f(x,z):\n return (x*s,get_y(x,z)+sign*d,23.1+(z-23.1)*s)\n return f\n rim(name+\" figured maple bound edge\",[stripef(1.001,-.259),stripef(1.010,-.163),\n stripef(1.010,-.065),stripef(1.005,.022),\n stripef(.995,.051),stripef(.988,.039),stripef(.987,-.014),\n stripef(.992,-.242)],binding)\n rim(name+\" double black purfling\",[stripef(.985,.016),stripef(.986,.034),\n stripef(.982,.039),stripef(.981,.024),\n stripef(.976,.024),stripef(.975,.038),\n stripef(.971,.034),stripef(.970,.013)],dark)\n rim(name+\" cinnamon separator line\",[stripef(.979,.024),stripef(.978,.035),\n stripef(.976,.038),stripef(.975,.021)],midwood)\n\n# Flat, true inlaid rosette band with individual maple lozenges.\ndef annulus(name,r0,r1,offset,m,center=SOUND_Z,count=242):\n V,F=[],[]\n for r in (r0,r1):\n for i in range(count):\n a=tau*i/count\n x,z=r*math.cos(a),center+r*math.sin(a)\n V.append((x,top_y(x,z)-offset,z))\n for i in range(count):\n k=(i+1)%count\n F.append((i,i+count,k+count,k))\n return mesh(name,V,F,m,closed=False)\n\nannulus(\"Black border to soundhole inlay\",4.227,4.355,.018,dark)\nannulus(\"Inner pale maple rosette line\",4.355,4.445,.022,binding)\nannulus(\"Rosewood marquetry rosette bed\",4.445,4.960,.024,rose)\nannulus(\"Outer pale maple rosette line\",4.970,5.067,.021,binding)\nannulus(\"Outer dark rosette edging\",5.071,5.146,.021,dark)\nannulus(\"Secondary slim rosewood rosette\",5.224,5.265,.016,rose)\nV,F,I=[],[],[]\nfor i in range(116):\n t=tau*(i+.0)/116\n profile=[(.0,4.485),(.35,4.711),(.0,4.913),(-.35,4.711)]\n f=[]\n for angle,r in profile:\n a=t+angle*tau/116\n x,z=r*math.cos(a),SOUND_Z+r*math.sin(a)\n f.append(len(V))\n V.append((x,top_y(x,z)-.044,z))\n F.append(f)\n I.append(1 if i%6==0 else 0)\nmesh(\"Individual maple and cinnamon rosette diamonds\",V,F,[clear_wood,midwood],idx=I,smooth=False)\n\n# A bass and treble brace, kerfed lining and label are visible through the aperture.\nfor y,z,width,depth in [(3.16,31.05,19.68,.52),(-3.29,36.80,24.08,.58),(-3.51,25.99,20.26,.59)]:\n capsule(\"Pale spruce transverse inner bracing\",(0,y,z),(width,depth,.54),lam,.205)\ncapsule(\"Kraft text label on the inner back\",(0,back_y(0,29.2)-.167,29.2),(7.5,.055,4.27),paper,.19)\n\n\ndef text(name,s,loc,size,m):\n d=bpy.data.curves.new(name,\"FONT\")\n d.body=s\n d.align_x=\"CENTER\"\n d.align_y=\"CENTER\"\n d.size=size\n d.space_character=1.14\n d.extrude=.009\n d.bevel_depth=.0026\n d.resolution_u=7\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n ob.location=loc\n ob.rotation_euler.x=math.pi/2\n bpy.ops.object.select_all(action=\"DESELECT\")\n ob.select_set(True)\n bpy.context.view_layer.objects.active=ob\n bpy.ops.object.convert(target=\"MESH\")\n return register(bpy.context.object,name,m)\ntext(\"Interior label maker\",\"CEDARLINE\",(0,back_y(0,29.2)-.213,29.48),.73,ink)\ntext(\"Interior label model\",\"P-12 • No. 027\",(0,back_y(0,29.2)-.211,28.55),.42,ink)\n\n# Low moustache bridge carved into a shallow asymmetric wing shape.\nbridge_b=[(-7.24,13.03),(-5.89,12.78),(-2.65,12.65),(0,12.40),(2.65,12.65),\n (5.89,12.78),(7.24,13.03),(7.42,14.67),(6.31,15.38),(4.39,15.83),\n (2.60,16.43),(-2.60,16.43),(-4.39,15.83),(-6.31,15.38),(-7.42,14.67)]\nV=[]\nfor t in (0,1):\n for x,z in bridge_b:\n bump=.47+.28*math.exp(-((x)/3.5)**4)\n V.append((x,top_y(x,z)-bump*t,z))\nn=len(bridge_b)\nF=[tuple(reversed(range(n))),tuple(range(n,n*2))]+[(i,(i+1)%n,(i+1)%n+n,i+n) for i in range(n)]\nB=mesh(\"Hand-carved streaked ebony pin bridge\",V,F,ebony,\n [[(.5+V[i][0]/16,.4+(V[i][2]-13)/4.7) for i in f] for f in F],closed=True,smooth=False)\nsmooth_bevel(B,.133)\nsaddle=capsule(\"Compensated unbleached bone saddle\",(0,-5.52,14.919),(6.88,.79,.265),ivory,.105)\nsaddle.rotation_euler.y=-.024\n\n\ndef tube(name,points,r,m,segs=16,flat=1,uv_scale=(1,1)):\n pts=list(map(Vector,points))\n V,F,UV=[],[],[]\n for i,p in enumerate(pts):\n d=(pts[min(i+1,len(pts)-1)]-pts[max(0,i-1)]).normalized()\n ref=Vector((0,0,1)) if abs(d.z)<.89 else Vector((0,1,0))\n u=d.cross(ref).normalized()\n v=u.cross(d).normalized()\n w=r(i/(len(pts)-1)) if callable(r) else r\n for j in range(segs):\n a=tau*j/segs\n V.append(p+w*(u*math.cos(a)+v*flat*math.sin(a)))\n for i in range(len(pts)-1):\n for j in range(segs):\n k=(j+1)%segs\n F.append((i*segs+j,i*segs+k,(i+1)*segs+k,(i+1)*segs+j))\n UV.append([(uv_scale[0]*j/segs,uv_scale[1]*i/len(pts)),(uv_scale[0]*(j+1)/segs,uv_scale[1]*i/len(pts)),\n (uv_scale[0]*(j+1)/segs,uv_scale[1]*(i+1)/len(pts)),(uv_scale[0]*j/segs,uv_scale[1]*(i+1)/len(pts))])\n F.extend([tuple(reversed(range(segs))),tuple(range(len(V)-segs,len(V)))])\n UV.extend([[(0,0)]*segs,[(1,1)]*segs])\n return mesh(name,V,F,m,UV,closed=True)\n\n\ndef cylinder(name,a,b,r,m,vertices=26,bevel=0):\n a,b=Vector(a),Vector(b)\n d=b-a\n bpy.ops.mesh.primitive_cylinder_add(vertices=vertices,radius=r,depth=d.length,location=(a+b)/2)\n ob=bpy.context.object\n ob.rotation_euler=d.to_track_quat(\"Z\",\"Y\").to_euler()\n register(ob,name,m,True)\n if bevel:\n smooth_bevel(ob,bevel,2)\n return ob\n\n\ndef sphere(name,loc,r,m,rotate=None):\n bpy.ops.mesh.primitive_uv_sphere_add(segments=32,ring_count=20,location=loc)\n ob=bpy.context.object\n ob.scale=r\n if rotate:\n ob.rotation_euler=rotate\n return register(ob,name,m,True)\n\n\nfor j in range(6):\n x=(j-2.5)*1.087\n z=13.44+.104*abs(j-2.5)**1.13\n sphere(\"Ebony bridge pin \"+str(j+1),(x,-5.426,z),(.277,.195,.293),dark)\n sphere(\"Bone pin dot \"+str(j+1),(x,-5.608,z),(.105,.038,.105),ivory)\n\n# Playable dimensions measured from the nominal saddle to the nut.\nNUT=77.80\nSCALE=62.80\nJOIN=46.4\nF_END=36.58\ndef board_width(z):\n return 2.263+(NUT-z)*.0163\n\n\ndef board_y(x,z):\n return -4.998-(NUT-z)*.00631+x*x*.0106\n\n\nzc=[36.58,36.62,38.0,41.5,46.62,59.9,73.7,77.65,77.8]\ndef fretboard():\n V,F,UV=[],[],[]\n for j in range(128):\n z=F_END+(NUT-F_END)*j/127\n width=board_width(z)\n width*=1-.040*math.exp(-((z-F_END)/.23)**2)\n for i in range(46):\n s=2*i/45-1\n x=width*s\n V.append((x,board_y(x,z),z))\n for j in range(127):\n for i in range(45):\n f=(j*46+i,j*46+i+1,(j+1)*46+i+1,(j+1)*46+i)\n F.append(f)\n UV.append([(.5+V[i][0]/12,.14+(V[i][2]-37)/49) for i in f])\n o=mesh(\"Slightly radiused ebony fingerboard\",V,F,ebony,UV)\n mod=o.modifiers.new(\"Ebony fingerboard thickness\",\"SOLIDIFY\")\n mod.thickness=.617\n mod.offset=-1\nfretboard()\n\n\ndef neck_profile(p):\n a,t=p\n z=45.7+32.1*t\n w=board_width(z)\n # The soft V becomes rounder toward the nut. Let the heel flare\n # toward the heel block below the twelfth fret.\n heel=math.exp(-((z-46.03)/2.19)**2)\n r=w*(.959+.076*heel)\n x=math.sin(a)*r\n back=max(0,math.cos(a))\n y=board_y(x,z)+.53+1.89*back**.79+heel*2.27*back**.89\n return x,y,z\n\n\nn=96\nverts,faces,uv=[],[],[]\nfor j in range(108):\n t=j/107\n for i in range(n):\n a=tau*i/n\n z=45.7+32.1*t\n w=board_width(z)\n if i>n//4 and i<3*n//4:\n # Flatten the embedded face of the neck under the fingerboard.\n x=math.sin(a)*w\n verts.append((x,board_y(x,z)+.457,z))\n else:\n verts.append(neck_profile((a,t)))\nfor j in range(107):\n for i in range(n):\n k=(i+1)%n\n faces.append((j*n+i,j*n+k,(j+1)*n+k,(j+1)*n+i))\n uv.append([(i/n,j/107),((i+1)/n,j/107),((i+1)/n,(j+1)/107),(i/n,(j+1)/107)])\nfaces.extend([tuple(reversed(range(n))),tuple(range(len(verts)-n,len(verts)))])\nuv.extend([[(.5,.2)]*n,[(.5,.8)]*n])\nmesh(\"Carved mahogany neck with rolled shoulders\",verts,faces,mahogany,uv,closed=True)\nheel_points=[(0,-.12,41.93),(0,-.54,43.41),(0,-1.19,44.7),(0,-1.51,46.47),(0,-1.61,48.58)]\ntube(\"Hand-shaped mahogany neck heel\",heel_points,\n lambda t:1.00+1.72*math.sin(math.pi*(.069+.839*t))**.88,mahogany,36,.74)\ncapsule(\"Small ebony heel cap\",(0,2.45,43.04),(3.18,.316,1.47),ebony,.29)\n\nfor s in (-1,1):\n pts=[]\n for z in np.linspace(F_END+.071,NUT-.018,161):\n w=board_width(z)*s\n pts.append((w,board_y(w,z)+.238,z))\n tube(\"Bound fingerboard edge \"+str(s),pts,.091,binding,13,.95)\n\nfor n0 in range(1,19):\n z=NUT-SCALE*(1-2**(-n0/12))\n w=board_width(z)-.045\n pts=[(x,board_y(x,z)-.090,z) for x in np.linspace(-w,w,41)]\n tube(\"Crowned nickel silver fret %02d\"%n0,pts,.075,steel,16,.77)\n if n0 in (3,5,7,9,12,15,17):\n prev=NUT-SCALE*(1-2**(-(n0-1)/12))\n zi=(prev+z)/2\n for xx in ((-.69,.69) if n0==12 else (0,)):\n y=board_y(xx,zi)-.014\n cylinder(\"Flush pearl position marker\",(xx,y+.016,zi),(xx,y-.026,zi),.163 if n0==12 else .137,pearl,30)\ncapsule(\"Unbleached bone nut\",(0,-5.038,NUT),(4.622,.689,.326),ivory,.081)\n\n\ndef head_y(z):\n return -4.947+(z-NUT)*.159\n\n\nheadedge=[(-2.27,77.79),(-2.43,79.45),(-2.81,81.05),(-3.15,82.86),(-3.37,86.38),\n (-3.44,90.17),(-3.19,92.42),(-2.42,93.38),(-1.06,93.78),(0,94.07),(1.06,93.78),\n (2.42,93.38),(3.19,92.42),(3.44,90.17),(3.37,86.38),(3.15,82.86),(2.81,81.05),\n (2.43,79.45),(2.27,77.79)]\nV=[(x,head_y(z)+y,z) for y in (0,1.63) for x,z in headedge]\nn=len(headedge)\nF=[tuple(range(n)),tuple(reversed(range(n,n*2)))]+[(i,(i+1)%n,(i+1)%n+n,i+n) for i in range(n)]\nuv=[[(.5+V[i][0]/9,.1+(V[i][2]-77.7)/19) for i in f] for f in F]\nH=mesh(\"Slotted mahogany headstock with streaked ebony face\",V,F,[mahogany,ebony],uv,\n [1,0]+[0]*n,True,False)\n# Mill two true slotted openings using rounded cutters through the headstock.\nfor s in (-1,1):\n cutter=capsule(\"Temporary tuner slot cutter\",(s*1.388,-3.44,86.51),(1.272,8.77,9.946),dark,.429)\n bpy.ops.object.select_all(action=\"DESELECT\")\n cutter.select_set(True)\n bpy.context.view_layer.objects.active=cutter\n if cutter.modifiers.get(\"Hand-softened component radius\"):\n bpy.ops.object.modifier_apply(modifier=\"Hand-softened component radius\")\n bpy.context.view_layer.objects.active=H\n H.select_set(True)\n c=H.modifiers.new(\"True open slotted headstock\",\"BOOLEAN\")\n c.operation=\"DIFFERENCE\"\n c.solver=\"EXACT\"\n c.object=cutter\n bpy.ops.object.modifier_apply(modifier=c.name)\n parts.remove(cutter)\n bpy.data.objects.remove(cutter,do_unlink=True)\nsmooth_bevel(H,.141,4)\n\nTUNER_Z=(82.82,86.49,90.16)\nfor s in (-1,1):\n for j,z in enumerate(TUNER_Z):\n yf=head_y(z)+.72\n ax=abs(np.interp(z,[77.8,82.8,86.4,90.2],[2.28,3.14,3.375,3.445]))\n cylinder(\"Polished slotted string roller\",(s*.70,yf,z),(s*2.22,yf,z),.228,steel,36,.034)\n cylinder(\"Roller brass bushing\",(s*2.02,yf,z),(s*2.32,yf,z),.322,brass,32,.028)\n cylinder(\"Tuner mounting sleeve\",(s*(ax-.23),yf+.724,z),(s*(ax+.45),yf+.724,z),.255,brass,30,.033)\n plate=capsule(\"Open gear tuner plate\",(s*(ax-.121),yf+1.09,z),(.226,.27,1.63),brass,.088)\n rod0=(s*(ax+.24),yf+.78,z+.087)\n rod1=(s*(ax+1.008),yf+.786,z+.087)\n cylinder(\"Tuning key stem\",rod0,rod1,.117,steel,22,.022)\n sphere(\"Ivoroid butterbean tuner key\",(s*(ax+1.16),yf+.812,z+.09),(.343,.223,.512),ivory,(0,s*.21,.06))\n cylinder(\"Open brass gear bed\",(s*(ax-.212),yf+1.43,z+.105),(s*(ax+.061),yf+1.53,z+.11),.35,brass,30,.027)\n for k in range(14):\n a=tau*k/14\n sphere(\"Bronze worm gear tooth\",(s*(ax+.05),yf+1.49+.331*math.cos(a),z+.109+.331*math.sin(a)),\n (.069,.046,.046),brass)\n for dz in (-.54,.56):\n cylinder(\"Slotted tuner plate screw\",(s*(ax-.06),yf+1.24,z+dz),(s*(ax-.06),yf+1.31,z+dz),.099,steel,18)\n\nmer=text(\"Inlaid headstock maker name\",\"CEDARLINE\",(0,head_y(92.49)-.036,92.53),.552,pearl)\nmer.rotation_euler.x-=math.atan(.159)\ntext(\"Small model mark on headstock\",\"P-12\",(0,head_y(80.44)-.031,80.46),.454,pearl)\nfor z,x0,side in [(93.30,0,0),(92.93,-.061,0)]:\n q=[(x0-.22,head_y(z)-.044,z),(x0,head_y(z-.16)-.042,z-.16),\n (x0+.22,head_y(z)-.044,z),(x0,head_y(z+.16)-.044,z+.16)]\n mesh(\"Pearl diamond logo inlay\",q,[(0,1,2,3)],pearl,smooth=False)\n\n# Six gauge-correct strings, including short coils on the individual rollers.\nfor j,r in enumerate((.065,.054,.041,.030,.022,.0165)):\n s=-1 if j<3 else 1\n xpin=(j-2.5)*1.087\n zpin=13.44+.104*abs(j-2.5)**1.13\n zs=14.929-.024*xpin\n zn=NUT\n xn=(j-2.5)*.737\n tz=TUNER_Z[j if j<3 else 5-j]\n xx=s*(1.21+(.163 if abs(j-2.5)>1.7 else .0))\n yf=head_y(tz)+.72\n pts=[(xpin,-5.529,zpin+.17),(xpin,-5.844,zpin+.43),(xpin,-5.936,zs)]\n for t in np.linspace(.008,1,119):\n pts.append(((1-t)*xpin+t*xn,-5.936*(1-t)-5.408*t,zs*(1-t)+zn*t))\n pts += [(xn*.981,-5.372,78.06),((xn+xx)*.50,(yf-5.4)/2,zn+.56*(tz-zn)),(xx,yf-.232,tz)]\n rwind=.233+r*.87\n for t in np.linspace(0,1,136):\n a=t*tau*3.75\n pts.append((xx+s*.266*t,yf-rwind*math.cos(a),tz+rwind*math.sin(a)))\n tube(\"Steel string %d with tuner windings\"%(j+1),pts,r,bronze if j<4 else wire,13)\n\n# The studio shot does not export its stage or light rig. Keep the instrument\n# exactly upright, with its lower bout as the model origin datum.\nroot=bpy.data.objects.new(\"Cedarline P-12 acoustic parlor guitar\",None)\nbpy.context.collection.objects.link(root)\nroot[\"asset_id\"]=\"musical-instruments-cedarline-p12-parlor-guitar-v1\"\nroot[\"category\"]=\"musical instruments\"\nroot[\"scale_length_cm\"]=62.8\nroot[\"strings\"]=6\nroot[\"units\"]=\"meters in glTF\"\nfor ob in parts:\n ob.parent=root\nroot.location.z=.079\nif not args.draft and not args.preview_only:\n root.scale=(.01,)*3\n root.location.z=.00079\n bpy.context.view_layer.update()\n bpy.ops.object.select_all(action=\"DESELECT\")\n root.select_set(True)\n for ob in parts:\n ob.select_set(True)\n bpy.ops.export_scene.gltf(filepath=str(out/(stem+\".glb\")),export_format=\"GLB\",use_selection=True,\n export_apply=True,export_yup=True,export_extras=True)\n root.scale=(1,)*3\n root.location.z=.079\n\nstage=mat(\"Dark gray-brown presentation sweep\",\"4A4641\",.90)\nstation=[(-560,-.011),(68,-.011)]\nfor i in range(1,44):\n a=math.pi/2*i/43\n station.append((68+105*math.sin(a),105*(1-math.cos(a))-.011))\nstation.append((173,435))\nV=[(x,y,z) for y,z in station for x in (-320,320)]\nF=[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(station)-1)]\no=mesh(\"Temporary music-product sweep\",V,F,stage)\no.data.polygons[0].use_smooth=False\nparts.remove(o)\n\n\ndef aim(ob,at):\n ob.rotation_euler=(Vector(at)-ob.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef area(name,pos,at,power,c,w,h):\n d=bpy.data.lights.new(name,\"AREA\")\n d.energy=power\n d.color=c\n d.shape=\"RECTANGLE\"\n d.size=w\n d.size_y=h\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n ob.location=pos\n aim(ob,at)\n\n\narea(\"Soft warm full-height key\",(-61,-82,119),(0,0,46),196000,(1,.941,.830),65,108)\narea(\"Cool rim on mahogany sides\",(55,48,109),(0,0,45),174000,(.81,.91,1),55,108)\narea(\"Neutral front-right fill\",(58,-82,63),(0,0,47),44500,(.92,.965,1),49,99)\narea(\"Gentle floor bounce\",(-36,-57,31),(0,0,42),8350,(1,.9,.77),40,31)\nscene=bpy.context.scene\nscene.world.use_nodes=True\nw=scene.world.node_tree.nodes[\"Background\"]\nw.inputs[\"Color\"].default_value=(.152,.171,.21,1)\nw.inputs[\"Strength\"].default_value=.32\nd=bpy.data.cameras.new(\"Full instrument portrait camera\")\ncamera=bpy.data.objects.new(d.name,d)\nbpy.context.collection.objects.link(camera)\ncamera.location=(62,-193,91)\nd.lens=63\nd.clip_end=6000\naim(camera,(0,-.16,47.1))\nscene.camera=camera\nscene.render.engine=\"CYCLES\"\nscene.cycles.samples=19 if args.draft else 117\nscene.cycles.use_denoising=False\nscene.cycles.adaptive_threshold=.074 if args.draft else .015\nscene.cycles.max_bounces=7\nscene.view_settings.view_transform=\"AgX\"\nscene.view_settings.look=\"AgX - Medium High Contrast\"\nscene.view_settings.exposure=.15\nscene.render.resolution_x=1460\nscene.render.resolution_y=1920\nscene.render.resolution_percentage=43 if args.draft else 100\nscene.render.image_settings.file_format=\"PNG\"\nscene.render.image_settings.color_mode=\"RGB\"\nscene.render.filepath=str(out/(\"draft.png\" if args.draft else stem+\".png\"))\nbpy.ops.render.render(write_still=True)\n```\n\nrun it: `blender -b --python cedarline.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T0100Z-musical-instruments-cedarline-parlor-guitar.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/cedarline-parlor-guitar/3d-dataset-20261127T0100Z-musical-instruments-cedarline-parlor-guitar.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/vesper-eclipse-display-shield.jpg"}}, {"type": "text", "text": "create an image of a vesper eclipse display shield"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA decorative bronze and enamel wall plaque in a rounded shield shape, front three-quarter view. Thick rolled bronze rim, a copper-orange border with a pattern of leaf motifs, and a teal enamel field with sunburst rays around a central dark blue glass disc. A hammered bronze crescent moon and a four-point star sit on the disc, with a small star and teal bead at the top and bottom of the field.\n\nSCALE\nAbout 50 cm wide, 61 cm tall, 83 mm deep. Build in meters, +Y up, +Z forward (face points +Z), origin on the support plane under the center of the outline.\n\nPARTS\n1. Plaque body: solid convex casting with a rounded profile and a convex enamel field. Build: outline curve extruded and domed.\n2. Rims: three rounded perimeter moldings (outer cordon, inner rolled bead, back lip) separated by dark tooling lines. Build: ring grids following the outline.\n3. Central medallion: recessed bezel with a domed midnight-blue glass disc and a triple inscribed groove. Build: a lathed bezel and a domed disk.\n4. Crescent and stars: hammered low-relief crescent with rounded tips, a central four-point ornament with a teal teardrop, constellation roundels, top and bottom heraldic stars with teal beads. Build: a crescent surface, small domed bosses.\n5. Field decoration: 36 flattened sunburst rays following the curved field, punched dotwork, a scroll line above and below the medallion. Build: thin relief strips projected onto the field.\n6. Border frieze and back: nested leaf motifs between the rims, rosettes and turquoise dots, rolled pearls, plus a maker stamp on the reverse. Build: repeated relief motifs around the outline, a text stamp on the back.\n\nPLAN\n1. Setup: clear the scene, meters, origin under the outline.\n2. Texture maps: generated inside vesper.py. Burnished bronze with brown oxidation and turquoise salts, subtle cast pits, and dark vitreous enamel with firing clouds.\n3. Build order: plaque body, rims, central medallion and glass disc, crescent, raised marks and stars, roundels, sunburst rays, leaf border, pearls, scroll panel, reverse stamp.\n4. Assemble: all relief sits on the curved field surface, the medallion is recessed into the center, the border sits between the outer and inner rims. Batch repeated small marks into one piece each.\n5. Materials: patinated cast bronze, worn burnished edges, brown oxidation in recesses, indigo-teal enamel field, midnight-blue glass disc, green enamel inserts, copper-ochre enamel details.\n6. Export: plaque only, solid with no straps or moving parts, one GLB with the textures embedded.\n\nCHECK\n443,092 triangles across 35 parts. Against the image: medallion about one-third of the plaque width, crescent opening to the right, rays evenly spaced all the way around.\n\n\n```python\n# vesper.py\n\"\"\"Vesper Eclipse, an original solid relief plaque with a ceremonial shield silhouette.\"\"\"\nimport argparse\nfrom collections import defaultdict\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bpy\nimport bmesh\nimport numpy as np\nfrom mathutils import Vector\n\nparser=argparse.ArgumentParser()\nparser.add_argument(\"--output\",type=Path,required=True)\nparser.add_argument(\"--draft\",action=\"store_true\")\nparser.add_argument(\"--preview-only\",action=\"store_true\")\nargs=parser.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261127T0200Z-weapons-vesper-eclipse-display-shield\"\nrng=np.random.default_rng(8173)\ntau=math.tau\nparts=[]\njobs=defaultdict(lambda:([],[],[]))\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\n\n\ndef srgb(code):\n vals=[int(code[i:i+2],16)/255 for i in (0,2,4)]\n return tuple(c/12.92 if c<=.04045 else ((c+.055)/1.055)**2.4 for c in vals)\n\n\ndef mat(name,code,rough,metal=0,coat=0):\n m=bpy.data.materials.new(name)\n m.use_nodes=True\n bs=m.node_tree.nodes.get(\"Principled BSDF\")\n m.diffuse_color=(*srgb(code),1)\n bs.inputs[\"Base Color\"].default_value=m.diffuse_color\n bs.inputs[\"Roughness\"].default_value=rough\n bs.inputs[\"Metallic\"].default_value=metal\n bs.inputs[\"Coat Weight\"].default_value=coat\n bs.inputs[\"Coat Roughness\"].default_value=.23\n return m\n\n\ndef png(name,data,space):\n h,w=data.shape[:2]\n a=np.concatenate((data,np.ones((h,w,1),np.float32)),axis=-1)\n im=bpy.data.images.new(name,width=w,height=h,alpha=False)\n im.colorspace_settings.name=space\n im.pixels.foreach_set(np.ascontiguousarray(a,dtype=np.float32).ravel())\n im.file_format=\"PNG\"\n im.filepath_raw=str(out/(name+\".png\"))\n im.save()\n im.reload()\n im.colorspace_settings.name=space\n return im\n\n\ndef texture(m,i,socket,strength=None):\n nt=m.node_tree\n t=nt.nodes.new(\"ShaderNodeTexImage\")\n t.image=i\n spot=nt.nodes.get(\"Principled BSDF\").inputs[socket]\n if strength is None:\n nt.links.new(t.outputs[\"Color\"],spot)\n else:\n n=nt.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=strength\n nt.links.new(t.outputs[\"Color\"],n.inputs[\"Color\"])\n nt.links.new(n.outputs[\"Normal\"],spot)\n\n\nN=1536\ny,x=np.mgrid[:N,:N].astype(np.float32)/N\n\n\ndef noise(nx,ny,X=x,Y=y):\n xx,yy=X*nx,Y*ny\n i,j=np.floor(xx).astype(int),np.floor(yy).astype(int)\n dx,dy=xx-i,yy-j\n fx=dx*dx*(3-2*dx)\n fy=dy*dy*(3-2*dy)\n t=rng.uniform(-1,1,(ny,nx)).astype(np.float32)\n a=t[j%ny,i%nx]*(1-fx)+t[j%ny,(i+1)%nx]*fx\n b=t[(j+1)%ny,i%nx]*(1-fx)+t[(j+1)%ny,(i+1)%nx]*fx\n return a*(1-fy)+b*fy\n\n\ndef blend(a,b,t):\n return np.array(a)*(1-t[:,:,None])+np.array(b)*t[:,:,None]\n\n\ndef smooth(z,a,b):\n s=np.clip((z-a)/(b-a),0,1)\n return s*s*(3-2*s)\n\n\ndef gray(z):\n return np.repeat(z[:,:,None],3,axis=2)\n\n\ndef norm(z,ax,ay):\n dx=(np.roll(z,-1,axis=1)-np.roll(z,1,axis=1))*ax\n dy=(np.roll(z,-1,axis=0)-np.roll(z,1,axis=0))*ay\n r=np.sqrt(1+dx*dx+dy*dy)\n return np.stack((.5-.5*dx/r,.5-.5*dy/r,.5+.5/r),axis=-1)\n\n\n# Bronze relief: bright burnished islands, brown oxidation and patchy turquoise salts.\nlarge=.55*noise(10,12)+.32*noise(29,32)+.13*noise(69,83)\nsmall=.52*noise(77,81)+.33*noise(214,233)+.15*noise(433,459)\nbloom=smooth(large+.21*small,.03,.52)*.57\nbrown=smooth(-large+.16*small,.01,.61)*.43\nsalt=smooth(noise(119,129)+.77*noise(41,42)+.38*large,.46,1.21)\ntiny=noise(512,563)\nbase=blend([.597,.382,.213],[.275,.396,.318],bloom)\nbase=base*(1-brown[:,:,None])+np.array([.342,.213,.140])*brown[:,:,None]\nbase=base*(1-salt[:,:,None]*.27)+np.array([.275,.385,.319])*salt[:,:,None]*.27\nbase+=(.036*small+.048*large+.022*tiny)[:,:,None]\npit=smooth(-tiny+.42*small,.47,1.08)\ncastheight=.27*large+.12*small+.022*tiny-.29*pit\n# Cast surface pits are subtle while the hammered shape comes from geometry.\nrough=.399+.155*bloom+.097*brown+.036*small+.048*pit\nbronze=mat(\"Patinated cast bronze | relief and outer frieze\",\"9D6C47\",.43,.84,.052)\npolish=mat(\"Worn burnished bronze | raised edges\",\"B29056\",.31,.90,.12)\ndark_bronze=mat(\"Deep brown oxidation in cut relief\",\"443A2D\",.59,.69)\nbronze_base=png(\"AgedBronze_BaseColor\",np.clip(base,.034,.96),\"sRGB\")\nbronze_norm=png(\"AgedBronze_Normal\",norm(castheight,2.93,2.77),\"Non-Color\")\nbronze_r=png(\"AgedBronze_Roughness\",gray(np.clip(rough,.31,.68)),\"Non-Color\")\ntexture(bronze,bronze_base,\"Base Color\")\ntexture(bronze,bronze_r,\"Roughness\")\ntexture(bronze,bronze_norm,\"Normal\",.57)\ntexture(polish,bronze_norm,\"Normal\",.22)\n\n# Cool dark vitreous enamel, slight firing clouds and tiny pits under polish.\nbluefield=.54*noise(6,8)+.29*noise(24,28)+.17*noise(72,89)\ngrain=.51*noise(98,113)+.36*noise(201,226)+.13*noise(524,525)\nmicro=smooth(noise(477,509),.52,1.0)\nglaze=blend([.082,.200,.220],[.166,.348,.321],smooth(bluefield,-.54,.53))\nglaze+=.029*grain[:,:,None]\nglaze-=micro[:,:,None]*np.array([.033,.060,.052])\nwear=smooth(grain+bluefield,.62,1.07)\nglaze=glaze*(1-.32*wear[:,:,None])+np.array([.255,.225,.147])*.32*wear[:,:,None]\nenamel=mat(\"Fired indigo-teal glass enamel | main field\",\"265257\",.36,.24,.26)\ntexture(enamel,png(\"BlueEnamel_BaseColor\",np.clip(glaze,.035,.63),\"sRGB\"),\"Base Color\")\ntexture(enamel,png(\"BlueEnamel_Roughness\",gray(.345+.085*grain+.069*micro+.04*wear),\"Non-Color\"),\"Roughness\")\ntexture(enamel,png(\"BlueEnamel_Normal\",norm(.115*grain-.20*micro,2.5,2.71),\"Non-Color\"),\"Normal\",.34)\ndark_navy=mat(\"Midnight blue opaque glass | central eclipse disk\",\"101D28\",.28,.16,.48)\nteal=mat(\"Deep green translucent-style enamel inserts\",\"224E49\",.32,.24,.29)\nochre=mat(\"Copper-ochre vitreous enamel details\",\"8B5536\",.41,.34,.19)\nblack=mat(\"Blue-black fired recesses\",\"17272B\",.49,.34,.12)\nlight=mat(\"Bright handled bronze along central crescent\",\"B59962\",.32,.82,.11)\ntexture(light,bronze_norm,\"Normal\",.25)\n\nCX,CZ=0,30.14\ndef outline(a):\n c,s=math.cos(a),math.sin(a)\n upper=1+.11*c-.078*c*c\n pleat=1+.012*math.cos(8*a)+.018*math.cos(4*a+.12)\n return 24.2*s*upper*pleat,29.96*c+.42*math.cos(3*a)\n\ndef field_y(u,v):\n r2=(u/25.4)**2+(v/30.9)**2\n return -4.86+3.72*r2+.075*math.sin(.46*u+.18*v)*math.sin(.44*v-.22*u)\n\ndef profile(a,r,d,back=False):\n x0,z0=outline(a)\n z0*=r\n x0*=r\n if back:\n yy=1.31+.42*((x0/25.4)**2+(z0/31.0)**2)+d\n else:\n yy=field_y(x0,z0)+d\n return x0,yy,z0+CZ\n\ndef flat_uv(p):\n return (.5+p[0]/53.6,.5+(p[2]-CZ)/63.5)\n\n\ndef mesh(name,V,F,m,uv=None,idx=None,closed=False,smooth=True):\n d=bpy.data.meshes.new(name)\n d.from_pydata(V,[],F)\n d.update()\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n for material in m if isinstance(m,list) else [m]:\n d.materials.append(material)\n if uv is not None:\n l=d.uv_layers.new(name=\"UVMap\")\n for f,coords in zip(d.polygons,uv):\n for i,q in zip(f.loop_indices,coords):\n l.data[i].uv=q\n for j,p in enumerate(d.polygons):\n p.use_smooth=smooth\n if idx is not None:\n p.material_index=idx[j]\n if closed:\n bm=bmesh.new()\n bm.from_mesh(d)\n bmesh.ops.recalc_face_normals(bm,faces=bm.faces[:])\n bm.to_mesh(d)\n bm.free()\n parts.append(ob)\n return ob\n\n\ndef ring_grid(name,fn,n,sections,m,section_mats=None):\n V,F,UV,I=[],[],[],[]\n for j in range(sections):\n for i in range(n):\n V.append(fn(tau*i/n,j))\n for j in range(sections):\n k=(j+1)%sections\n for i in range(n):\n q=(i+1)%n\n f=(j*n+i,j*n+q,k*n+q,k*n+i)\n F.append(f)\n UV.append([flat_uv(V[k]) for k in f])\n I.append(section_mats[j] if section_mats else 0)\n return mesh(name,V,F,m,UV,I,closed=True)\n\n# A solid wall-display plaque with rounded profile, no straps or moving parts.\nshell=[(.00019,-.006,False),(.08,0,False),(.17,0,False),(.28,0,False),\n (.40,0,False),(.51,0,False),(.62,0,False),(.71,0,False),(.79,0,False),\n (.86,0,False),(.92,.012,False),(.974,.075,False),(.996,.178,False),\n (1.004,.388,False),(1.006,.70,False),(1.003,1.09,False),\n (.993,1.37,False),(.971,-.27,True),(.91,-.16,True),(.77,-.08,True),\n (.59,-.031,True),(.36,0,True),(.15,0,True),(.00014,0,True)]\nring_grid(\"Solid convex decorative plaque casting\",lambda a,j:profile(a,*shell[j]),396,len(shell),bronze)\nrelief=[(.00015,-.155),(.08,-.155),(.18,-.16),(.29,-.162),(.39,-.165),\n (.50,-.17),(.59,-.18),(.68,-.18),(.735,-.182),(.778,-.18),(.799,-.165),\n (.806,-.09),(.806,-.02),(.794,.015),(.100,.013),(.00015,.015)]\nring_grid(\"Convex vitreous enamel field\",lambda a,j:profile(a,*relief[j]),374,len(relief),enamel)\n\n# Three rounded perimeter moldings, separated by deliberately dark tooling lines.\nbands=[\n (\"Rounded outer bronze cordon\",[(.971,-.479),(.984,-.445),(.995,-.308),(1.001,-.106),\n (.997,.037),(.987,.114),(.975,.075),(.962,-.113),(.961,-.316),(.964,-.448)],[polish,bronze],[0,0,0,0,1,1,1,1,0,0]),\n (\"Patina trough at outer rim\",[(.948,-.142),(.955,-.124),(.955,-.038),(.950,-.014),(.943,-.018),(.942,-.074),(.945,-.146)],\n [dark_bronze],None),\n (\"Fine inner rolled bronze bead\",[(.802,-.294),(.809,-.358),(.822,-.368),(.831,-.294),\n (.834,-.212),(.833,-.121),(.820,-.078),(.806,-.115),(.801,-.198)],[polish,bronze],[1,0,0,1,1,1,1,1,1]),\n (\"Recessed bronze valley under rose bead\",[(.789,-.206),(.799,-.219),(.804,-.197),(.803,-.148),(.792,-.155),(.786,-.172)],\n [dark_bronze],None),\n (\"Outer convex back lip\",[(.965,-.086),(.973,-.056),(.978,.034),(.974,.110),\n (.958,.148),(.951,.090),(.954,-.022)],[bronze],None)\n]\nfor name,prof,materials,idx in bands:\n ring_grid(name,lambda a,j,prof=prof,bk=(\"back lip\" in name):profile(a,*prof[j],back=bk),\n 384,len(prof),materials,idx)\n\n# Central recessed bezel with circular thermally-fused glass disc.\nCCZ=31.54\ndef central(a,r,h):\n x0=r*math.cos(a)\n z0=CCZ+r*math.sin(a)\n return x0,field_y(x0,z0-CZ)+h,z0\n\n\nbez=[(10.52,-.83),(10.64,-1.03),(10.82,-1.12),(11.03,-1.14),(11.23,-1.04),\n (11.33,-.89),(11.42,-.60),(11.57,-.49),(11.60,-.39),(11.54,-.30),\n (11.36,-.27),(10.56,-.28)]\nring_grid(\"Burnished central medallion bezel\",lambda a,j:central(a,*bez[j]),244,len(bez),\n [polish,bronze,dark_bronze],[1,1,0,0,1,1,2,2,2,2,1,1])\naperture=[(.0001,-1.14),(.46,-1.139),(2.8,-1.118),(4.82,-1.102),(6.88,-1.062),\n (8.58,-1.024),(9.86,-.982),(10.54,-.947),(10.70,-.90),\n (10.73,-.71),(10.60,-.63),(.00010,-.63)]\ndef enamel_disk(profile_rows):\n # True poles preserve the clean highlight at the center of the glass.\n n=228\n levels=profile_rows[1:-1]\n vertices=[central(tau*i/n,*p) for p in levels for i in range(n)]\n front=len(vertices)\n vertices.append(central(0,0,profile_rows[0][1]))\n rear=len(vertices)\n vertices.append(central(0,0,profile_rows[-1][1]))\n faces=[]\n for j in range(len(levels)-1):\n for i in range(n):\n k=(i+1)%n\n faces.append((j*n+i,j*n+k,(j+1)*n+k,(j+1)*n+i))\n end=(len(levels)-1)*n\n for i in range(n):\n k=(i+1)%n\n faces.append((front,k,i))\n faces.append((rear,end+i,end+k))\n mesh(\"Dark blue domed enamel eclipse ground\",vertices,faces,dark_navy,\n [[flat_uv(vertices[i]) for i in f] for f in faces],closed=True)\n\nenamel_disk(aperture)\nfor i,(rad,off,color) in enumerate(((12.17,-.386,polish),(12.68,-.342,bronze),(13.04,-.269,dark_bronze))):\n p=[(rad-.088,-.002+off),(rad-.057,off-.060),(rad+.056,off-.047),(rad+.093,off+.02),\n (rad+.063,off+.081),(rad-.04,off+.068)]\n ring_grid(\"Eclipse triple surrounding inscribed groove \"+str(i+1),lambda a,j,p=p:central(a,*p[j]),\n 213,len(p),color)\n\n\ndef batchline(group,pts,r,m,flat=.85,n=10):\n P=list(map(Vector,pts))\n V,F,UV=jobs[(group,m)]\n index=len(V)\n for i,pt in enumerate(P):\n d=(P[min(i+1,len(P)-1)]-P[max(i-1,0)]).normalized()\n ref=Vector((0,-1,0))\n side=d.cross(ref).normalized()\n face=side.cross(d).normalized()\n w=r(i/(len(P)-1)) if callable(r) else r\n for j in range(n):\n a=tau*j/n\n V.append(pt+side*(w*math.cos(a))+face*(flat*w*math.sin(a)))\n def push(f):\n F.append(f)\n UV.append([flat_uv(V[k]) for k in f])\n for i in range(len(P)-1):\n for j in range(n):\n k=(j+1)%n\n push((index+i*n+j,index+i*n+k,index+(i+1)*n+k,index+(i+1)*n+j))\n push(tuple(index+k for k in reversed(range(n))))\n push(tuple(index+(len(P)-1)*n+k for k in range(n)))\n\n\n# Bronze crescent cast in low relief. The two tips are softened and rounded.\nR=8.29\np=3.42\nr=7.61\nb=(R*R-r*r+p*p)/(2*p)\nat=math.acos(b/R)\nbt=math.atan2(R*math.sin(at),b-p)\ndef moon_edge(t,s):\n if s==0:\n a=at+(tau-2*at)*t\n return R*math.cos(a),R*math.sin(a)+CCZ\n a=bt+(tau-2*bt)*t\n return p+r*math.cos(a),r*math.sin(a)+CCZ\n\n\ndef crescent_surface(u,v):\n ax,az=moon_edge(u,0)\n bx,bz=moon_edge(u,1)\n x=ax+(bx-ax)*v\n z=az+(bz-az)*v\n lip=math.sin(math.pi*v)**.61 * math.sin(math.pi*u)**.45\n hammer=(.034*math.sin(.98*x+1.07*z)+.040*math.sin(2.94*x-2.63*z))*lip\n return (x,field_y(x,z-CZ)-1.061-.355*lip-hammer,z)\n\n\nV,F,UV=[],[],[]\nn=43\nM=144\nfor j in range(M+1):\n u=.004+.992*j/M\n for i in range(n+1):\n V.append(crescent_surface(u,i/n))\nfor j in range(M):\n for i in range(n):\n a=j*(n+1)+i\n f=(a,a+1,a+n+2,a+n+1)\n F.append(f)\n UV.append([flat_uv(V[i]) for i in f])\no=mesh(\"Hammered rounded bronze eclipse crescent\",V,F,[light,bronze],UV)\nth=o.modifiers.new(\"Rounded cast relief depth\",\"SOLIDIFY\")\nth.thickness=.216\nth.offset=-1\nth.material_offset=1\nth.material_offset_rim=1\nm=o.modifiers.new(\"Soft cast edge radius\",\"BEVEL\")\nm.width=.061\nm.segments=3\nfor s in (0,1):\n pts=[]\n for u in np.linspace(.011,.989,145):\n x0,z0=moon_edge(float(u),s)\n pts.append((x0,field_y(x0,z0-CZ)-1.074,z0))\n batchline(\"Fine hammered crescent edge\",pts,lambda t:.035+.071*math.sin(math.pi*t)**.77,polish)\n\n# Batch domed inlaid raised marks and low relief stars on the original field.\ndef boss(group,x,z,ra,height,offset,m,points=0,rot=0,squash=1.0):\n V,F,UV=jobs[(group,m)]\n index=len(V)\n n=32 if not points else 48\n levels=[(.0011,height),(.27,height*.93),(.531,height*.78),(.79,height*.52),(.947,height*.235),(1,.002),(.947,-.058),(.0011,-.058)]\n for r,d in levels:\n for i in range(n):\n a=tau*i/n\n wave=1 if not points else .75+.25*(.5+.5*math.cos(points*a))**1.30\n ax=math.cos(a+rot)*ra*r*wave\n az=math.sin(a+rot)*ra*r*wave*squash\n X,Z=x+ax,z+az\n V.append((X,field_y(X,Z-CZ)-offset-d,Z))\n for j in range(len(levels)):\n k=(j+1)%len(levels)\n for i in range(n):\n l=(i+1)%n\n f=(index+j*n+i,index+j*n+l,index+k*n+l,index+k*n+i)\n F.append(f)\n UV.append([flat_uv(V[j]) for j in f])\n\n\n# Unfilled crescent area studded with separate celestial roundel relief.\nboss(\"Central four-point ornament\",3.20,CCZ+.83,2.11,.316,1.175,polish,points=4,rot=.16,squash=1.11)\nboss(\"Central teardrop enamel setting\",3.2,CCZ+.83,.561,.210,1.463,teal)\nfor x0,z,s,r0 in [(6.67,CCZ+3.7,1,.731),(4.97,CCZ-3.96,0,.650),\n (1.31,CCZ+4.85,0,.47),(.88,CCZ-4.60,1,.352),\n (8.74,CCZ-.78,0,.328),(5.92,CCZ+5.95,0,.271)]:\n boss(\"Constellation roundels on eclipse glass\",x0,z,r0,.192,1.131,polish if not s else light,\n points=4 if s else 0,rot=.28)\nboss(\"Top heraldic star\",0,54.35,2.22,.422,.234,light,points=8,rot=0)\nboss(\"Top teal enamel bead\",0,54.35,.755,.278,.596,teal)\nboss(\"Bottom heraldic star\",0,6.80,2.14,.343,.261,light,points=8,rot=0)\nboss(\"Bottom teal enamel bead\",0,6.80,.68,.195,.590,teal)\n\n# Thirty-six stylized solar rays follow the curved field as flattened relief.\nfor i in range(36):\n a=tau*(i+.118)/36\n p=15.46 + (.95 if i%3==0 else 0)+.55*abs(math.sin(a))\n start=13.28+.311*abs(math.sin(a+.28))\n for side in (0,1):\n pts=[]\n for j in range(31):\n t=j/30\n # A gentle curve rather than a pointed edge.\n angle=a+.026*math.sin(math.pi*t)+side*.011\n radial=start+(p-start+(1.18 if i%3==0 else .0))*t\n X,Z=radial*math.cos(angle),CCZ+radial*math.sin(angle)\n pts.append((X,field_y(X,Z-CZ)-(.277 if side else .320),Z))\n batchline(\"Low-relief sunburst rays\",pts,\n lambda t,side=side:.029+(.169 if not side else .043)*math.sin(math.pi*t)**.72,\n bronze if not side else polish,flat=.57,n=10)\n\nfor i in range(72):\n b=tau*i/72\n r=12.40+.026*math.sin(i)\n boss(\"Punched dotwork orbit\",r*math.cos(b),CCZ+r*math.sin(b),.095,.070,.354,polish)\n\n# Nested leaf motifs are set into a broad border between the two rolled rims.\nfor j in range(38):\n a0=tau*j/38\n da=tau/38\n for s in (-1,1):\n P=[]\n for t in np.linspace(0,1,38):\n a=a0+s*da*(.009+.372*t+.067*math.sin(math.pi*t))\n r=.844+.089*t+.009*math.sin(math.pi*t)\n x0,y0,z0=profile(a,float(r),-.119)\n P.append((x0,y0-.023*math.sin(math.pi*t),z0))\n batchline(\"Cast acanthus threadwork around frieze\",P,lambda t:.041+.139*math.sin(math.pi*t)**.75,\n polish if j%3 else bronze,.48,n=10)\n Q=[]\n for t in np.linspace(0,1,29):\n a=a0+s*da*(.008+.215*t+.27*math.sin(math.pi*t))\n r=.844+.081*t\n Q.append(profile(a,float(r),-.095))\n batchline(\"Shaded outlines below chased leaves\",Q,lambda t:.033+.062*math.sin(math.pi*t),\n dark_bronze,.47,n=9)\n px,yy,pz=profile(a0,.927,-.241)\n boss(\"Oxidized bronze rosettes at rim\",px,pz,.335,.202,.238,bronze,points=5,rot=a0)\n boss(\"Turquoise glass dots at rim\",px,pz,.175,.109,.402,teal if j%3 else ochre)\n qx,qy,qz=profile(a0+da*.5,.864,-.089)\n boss(\"Small surrounding punched beads\",qx,qz,.107,.113,.088,polish)\n\n# Multiple rolled pearls under the inlay line, proportioned as cast decoration.\nfor i in range(136):\n a=tau*(i+.45)/136\n x0,y0,z0=profile(a,.816,-.294)\n boss(\"Beaded inner circlet\",x0,z0,.099+(i%2)*.014,.101,.305,polish)\n\n# Quiet scroll panel on the exposed enamel above and below the central field.\nfor sign in (-1,1):\n z0=54.29 if sign>0 else 7.56\n for direction in (-1,1):\n pts=[]\n for t in np.linspace(0,1,53):\n x0=direction*(2.04+7.56*t)\n z=z0-sign*(.25+3.1*t-1.86*t*t+.55*math.sin(t*4.7))\n pts.append((x0,field_y(x0,z-CZ)-.264,z))\n batchline(\"Fine scroll line above and below the medallion\",pts,lambda t:.028+.084*math.sin(math.pi*t),polish,.48,9)\n\n# Reverse shows the shallow center stamp within its plain curved display surface.\ndef back_stencil(name,label,z,y):\n d=bpy.data.curves.new(name,\"FONT\")\n d.body=label\n d.align_x=\"CENTER\"\n d.align_y=\"CENTER\"\n d.size=.72\n d.space_character=1.13\n d.extrude=.012\n d.resolution_u=6\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.location=(0,y,z)\n o.rotation_euler=(math.pi/2,0,math.pi)\n bpy.ops.object.select_all(action=\"DESELECT\")\n o.select_set(True)\n bpy.context.view_layer.objects.active=o\n bpy.ops.object.convert(target=\"MESH\")\n o=bpy.context.object\n o.data.materials.append(dark_bronze)\n parts.append(o)\n\nback_stencil(\"Recess-tone reverse Vesper maker stamp\",\"VESPER / 09\",CZ,1.332)\nfor (name,m),(V,F,UV) in jobs.items():\n mesh(name,V,F,m,UV,closed=True)\n\nroot=bpy.data.objects.new(\"Vesper Eclipse display shield\",None)\nbpy.context.collection.objects.link(root)\nroot[\"asset_id\"]=\"weapons-vesper-eclipse-display-shield-v1\"\nroot[\"category\"]=\"weapons\"\nroot[\"subject\"]=\"fictional decorative wall plaque with shield silhouette\"\nroot[\"function\"]=\"display prop\"\nroot[\"units\"]=\"meters in glTF\"\nfor o in parts:\n o.parent=root\nroot.location.z=.423\nif not args.draft and not args.preview_only:\n root.scale=(.01,)*3\n root.location.z=.00423\n bpy.context.view_layer.update()\n bpy.ops.object.select_all(action=\"DESELECT\")\n root.select_set(True)\n for o in parts:\n o.select_set(True)\n bpy.ops.export_scene.gltf(filepath=str(out/(stem+\".glb\")),export_format=\"GLB\",use_selection=True,\n export_apply=True,export_yup=True,export_extras=True)\n root.scale=(1,)*3\n root.location.z=.423\n\nstage=mat(\"Slate-gray seamless gallery sweep\",\"454649\",.88)\nstations=[(-520,-.035),(44,-.035)]\nfor i in range(1,46):\n a=math.pi/2*i/45\n stations.append((44+87*math.sin(a),87*(1-math.cos(a))-.035))\nstations.append((131,320))\nV=[(x,y,z) for y,z in stations for x in (-300,300)]\nF=[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(stations)-1)]\no=mesh(\"Photographic gallery cove\",V,F,stage)\no.data.polygons[0].use_smooth=False\nparts.remove(o)\n\n\ndef aim(o,at):\n o.rotation_euler=(Vector(at)-o.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef area(name,pos,at,power,c,w,h):\n d=bpy.data.lights.new(name,\"AREA\")\n d.energy=power\n d.color=c\n d.shape=\"RECTANGLE\"\n d.size=w\n d.size_y=h\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.location=pos\n aim(o,at)\n\n\narea(\"Warm broad oblique key\",(-59,-72,77),(0,0,33),121000,(1,.917,.773),59,62)\narea(\"Cool metal edge from far right\",(48,29,74),(0,0,32),131000,(.76,.861,1),38,67)\narea(\"Low saturated front fill\",(40,-61,46),(0,0,28),31200,(.95,.967,1),58,45)\narea(\"Gentle lower artifact bounce\",(-21,-43,21),(0,0,25),5900,(1,.864,.688),32,34)\nscene=bpy.context.scene\nscene.world.use_nodes=True\nw=scene.world.node_tree.nodes[\"Background\"]\nw.inputs[\"Color\"].default_value=(.128,.145,.201,1)\nw.inputs[\"Strength\"].default_value=.33\nd=bpy.data.cameras.new(\"Decorative relief portrait camera\")\ncamera=bpy.data.objects.new(d.name,d)\nbpy.context.collection.objects.link(camera)\ncamera.location=(31,-133,57)\nd.lens=63\nd.clip_end=6000\naim(camera,(0,0,30.51))\nscene.camera=camera\nscene.render.engine=\"CYCLES\"\nscene.cycles.samples=20 if args.draft else 126\nscene.cycles.use_denoising=False\nscene.cycles.adaptive_threshold=.070 if args.draft else .014\nscene.cycles.max_bounces=7\nscene.view_settings.view_transform=\"AgX\"\nscene.view_settings.look=\"AgX - Medium High Contrast\"\nscene.view_settings.exposure=.20\nscene.render.resolution_x=1500\nscene.render.resolution_y=1800\nscene.render.resolution_percentage=44 if args.draft else 100\nscene.render.image_settings.file_format=\"PNG\"\nscene.render.image_settings.color_mode=\"RGB\"\nscene.render.filepath=str(out/(\"draft.png\" if args.draft else stem+\".png\"))\nbpy.ops.render.render(write_still=True)\n```\n\nrun it: `blender -b --python vesper.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T0200Z-weapons-vesper-eclipse-display-shield.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/vesper-eclipse-display-shield/3d-dataset-20261127T0200Z-weapons-vesper-eclipse-display-shield.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/breakwater-125-scooter.jpg"}}, {"type": "text", "text": "create an image of a breakwater 125 step-through scooter"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA retro step-through city scooter, front-left three-quarter view. Two-tone sea-glass blue and bone coachwork, a curved front leg shield, a front mudguard over a small wheel with a disc brake and fork dampers, a round chrome headlamp in the handlebar nacelle with orange indicators, tall round mirrors, a ribbed dark floor mat, a rounded rear body with a side vent, a cognac two-place saddle, a chrome exhaust and a kickstand.\n\nSCALE\nAbout 84 cm wide, 123 cm tall, 170 cm deep. Build in meters, +Y up, +Z forward, origin at ground level on the centerline between the wheels.\n\nPARTS\n1. Front end: cast fork sliders, polished stanchions, gaiters, wheel with tire and cast rim, brake disc and caliper. Build: lathed wheel and tire, cylinders for the fork.\n2. Front mudguard: curved sea-glass shell with a bright edge, ivory pinstripes and a crest. Build: fender sweep with thickness.\n3. Rear body: strongly curved pressed side panels with a wraparound lower trim and beltline, an inset vent, and the cognac saddle with piping and stitching. Build: lofted rear shell, a seat pan with a padded top.\n4. Floor deck: dark running mat with ribs and a deck bridge joining the front and rear sections. Build: boxes with raised ribs.\n5. Leg shield: swept front fairing with side brows and a separate shaded rear face. Build: shaped shield panel with thickness.\n6. Underbody, handlebar and dash: shock spring, exhaust, kickstand, handlebar nacelle with the oval headlamp lens, indicators, grips, mirrors, and a small dashboard with a gauge. Build: helix for the spring, lathed exhaust, lathed headlamp, curved rods for the mirrors.\n\nPLAN\n1. Setup: clear the scene, meters, origin on the ground between the wheels.\n2. Texture maps: generated inside breakwater.py. Enamel paint, leatherette grain, tire rubber and cast aluminum.\n3. Build order: front fork and wheel, front mudguard, rear body and saddle, floor deck, leg shield, underbody, handlebar nacelle, dashboard.\n4. Assemble: front wheel under the leg shield on the fork, deck bridges the shield to the rear body, saddle on top of the rear body, exhaust and shock on the right side, both tires touching the ground plane.\n5. Materials: sea-glass blue and bone enamel, teal lower trim, charcoal ABS seals, graphite tires, plated trim and mirrors, cast aluminum, cognac saddle with wheat thread, clear headlamp, orange and ruby lenses.\n6. Export: scooter only, one GLB with the textures embedded.\n\nCHECK\n684,096 triangles across 212 parts. Against the image: two-tone split along the lower body, saddle at about leg-shield height, wheels small relative to the body, mirrors on tall stalks.\n\n\n```python\n# breakwater.py\n\"\"\"Original Breakwater 125 step-through scooter. Working units are centimeters.\"\"\"\nimport argparse\nfrom collections import defaultdict\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Vector\nimport numpy as np\n\np=argparse.ArgumentParser()\np.add_argument(\"--output\",type=Path,required=True)\np.add_argument(\"--draft\",action=\"store_true\")\np.add_argument(\"--preview-only\",action=\"store_true\")\nargs=p.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261127T0300Z-vehicles-breakwater-125-scooter\"\nrng=np.random.default_rng(7332)\ntau=math.tau\nparts=[]\njobs=defaultdict(lambda:([],[],[]))\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\n\n\ndef srgb(h):\n vals=[int(h[i:i+2],16)/255 for i in (0,2,4)]\n return tuple(v/12.92 if v<=.04045 else ((v+.055)/1.055)**2.4 for v in vals)\n\n\ndef material(name,h,rough,metal=0,coat=0,coatrough=.17):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*srgb(h),1)\n m.use_nodes=True\n n=m.node_tree.nodes.get(\"Principled BSDF\")\n n.inputs[\"Base Color\"].default_value=m.diffuse_color\n n.inputs[\"Roughness\"].default_value=rough\n n.inputs[\"Metallic\"].default_value=metal\n n.inputs[\"Coat Weight\"].default_value=coat\n n.inputs[\"Coat Roughness\"].default_value=coatrough\n return m\n\n\ndef img(name,a,space):\n h,w=a.shape[:2]\n p=np.concatenate((a,np.ones((h,w,1),dtype=np.float32)),axis=-1)\n im=bpy.data.images.new(name,width=w,height=h,alpha=False)\n im.colorspace_settings.name=space\n im.pixels.foreach_set(np.ascontiguousarray(p,dtype=np.float32).ravel())\n im.file_format=\"PNG\"\n im.filepath_raw=str(out/(name+\".png\"))\n im.save()\n im.reload()\n im.colorspace_settings.name=space\n return im\n\n\ndef tex(m,i,to,strength=None):\n n=m.node_tree\n im=n.nodes.new(\"ShaderNodeTexImage\")\n im.image=i\n dst=n.nodes.get(\"Principled BSDF\").inputs[to]\n if strength is None:\n n.links.new(im.outputs[\"Color\"],dst)\n else:\n normal=n.nodes.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value=strength\n n.links.new(im.outputs[\"Color\"],normal.inputs[\"Color\"])\n n.links.new(normal.outputs[\"Normal\"],dst)\n\n\nN=1024\nv,u=np.mgrid[:N,:N].astype(np.float32)/N\n\ndef noise(nx,ny,X=u,Y=v):\n xx,yy=X*nx,Y*ny\n i,j=np.floor(xx).astype(int),np.floor(yy).astype(int)\n x,y=xx-i,yy-j\n x=x*x*(3-2*x)\n y=y*y*(3-2*y)\n t=rng.uniform(-1,1,(ny,nx))\n a=t[j%ny,i%nx]*(1-x)+t[j%ny,(i+1)%nx]*x\n b=t[(j+1)%ny,i%nx]*(1-x)+t[(j+1)%ny,(i+1)%nx]*x\n return a*(1-y)+b*y\n\n\ndef norm(z,x,y):\n dx=(np.roll(z,-1,axis=1)-np.roll(z,1,axis=1))*x\n dy=(np.roll(z,-1,axis=0)-np.roll(z,1,axis=0))*y\n n=np.sqrt(1+dx*dx+dy*dy)\n return np.stack((.5-.5*dx/n,.5-.5*dy/n,.5+.5/n),axis=-1)\n\n\ndef gray(z):\n return np.repeat(z[:,:,None],3,axis=2)\n\n\ndef ease(z,a,b):\n s=np.clip((z-a)/(b-a),0,1)\n return s*s*(3-2*s)\n\n\npearl=.057*noise(208,297)+.127*noise(441,398)+.041*noise(37,43)\npaint_norm=img(\"Enamel_Microtexture_Normal\",norm(pearl,3.02,3.08),\"Non-Color\")\npaint=material(\"Deep sea-glass blue enamel | main coachwork\",\"39777D\",.32,.28,.59)\nsand=material(\"Warm bone enamel | secondary coachwork\",\"D9C5A3\",.33,.18,.55)\npaint_dark=material(\"Deep teal lower coach trim\",\"25515A\",.44,.24,.23)\nfor m in (paint,sand):\n tex(m,paint_norm,\"Normal\",.22)\ndark=material(\"Charcoal molded ABS and weather seals\",\"25282A\",.54)\nboot=material(\"Black polyurethane bellows\",\"242729\",.69)\ntire=material(\"Graphite tire compound\",\"292B2C\",.72)\nrubber_noise=noise(113,127)*.131+noise(401,407)*.084\ntex(tire,img(\"Tire_Rubber_Normal\",norm(rubber_noise,3.36,3.11),\"Non-Color\"),\"Normal\",.46)\nchrome=material(\"Polished plated trim and mirror metal\",\"B9BFC1\",.196,.98,.13)\nalum=material(\"Satin-cast aluminum wheel and powertrain\",\"9EA6A4\",.40,.89,.07)\nsteel=material(\"Oxidized brake disc and hardware\",\"5F6261\",.46,.78)\nbolt=material(\"Bright zinc fasteners\",\"B2AC9D\",.32,.90)\nink=material(\"Deep charcoal instrument face\",\"21282A\",.56)\nivory=material(\"Cream markings and pinstripe\",\"D8D0B7\",.52,0,.11)\nglass=material(\"Clear headlamp front shell\",\"A8C3C6\",.163,.06,.36)\nglass.node_tree.nodes[\"Principled BSDF\"].inputs[\"Transmission Weight\"].default_value=.54\nglass.node_tree.nodes[\"Principled BSDF\"].inputs[\"IOR\"].default_value=1.46\ntail=material(\"Transparent ruby-red tail lens\",\"991C22\",.23,.19,.32)\ntail.node_tree.nodes[\"Principled BSDF\"].inputs[\"Transmission Weight\"].default_value=.14\namber=material(\"Orange turn indicator lens\",\"D08F36\",.27,.23,.32)\namber.node_tree.nodes[\"Principled BSDF\"].inputs[\"Transmission Weight\"].default_value=.14\nopal=material(\"Satin etched headlamp reflector\",\"B4B4A9\",.26,.62,.13)\nlight=material(\"Pale ivory front diffuser ribs\",\"D9D9C7\",.35,.20,.19)\nred=material(\"Gauge needle and tiny trim marker\",\"C74C3A\",.43,.10)\nleather=material(\"Cognac pebbled saddle leatherette\",\"997453\",.56,0,.09,.28)\ntan_noise=noise(88,103)*.33+noise(187,173)*.28+noise(399,407)*.17\ngrain=noise(22,25)*.037+noise(410,420)*.039\nc=np.stack((.510+grain+.073*tan_noise,.321+grain*.86+.068*tan_noise,.194+grain*.76+.056*tan_noise),axis=-1)\ntex(leather,img(\"Cognac_Saddle_BaseColor\",np.clip(c,.05,.85),\"sRGB\"),\"Base Color\")\ntex(leather,img(\"Cognac_Saddle_Normal\",norm(.25*tan_noise,4.9,4.21),\"Non-Color\"),\"Normal\",.65)\ntex(leather,img(\"Cognac_Saddle_Roughness\",gray(.54+.081*tan_noise+.057*grain),\"Non-Color\"),\"Roughness\")\nseam=material(\"Darker saddle piping\",\"48372C\",.63)\nstitch=material(\"Wheat-colored saddle thread\",\"B89364\",.74)\n\n\ndef mesh(name,V,F,m,UV=None,idx=None,close=False,smooth=True,keep=True):\n d=bpy.data.meshes.new(name)\n d.from_pydata(V,[],F)\n d.update()\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n for q in m if isinstance(m,list) else [m]:\n d.materials.append(q)\n if UV is not None:\n l=d.uv_layers.new(name=\"UVMap\")\n for f,coords in zip(d.polygons,UV):\n for i,uv in zip(f.loop_indices,coords):\n l.data[i].uv=uv\n for j,f in enumerate(d.polygons):\n f.use_smooth=smooth\n if idx:\n f.material_index=idx[j]\n if close:\n bm=bmesh.new()\n bm.from_mesh(d)\n bmesh.ops.recalc_face_normals(bm,faces=bm.faces[:])\n bm.to_mesh(d)\n bm.free()\n if keep:\n parts.append(o)\n return o\n\n\ndef add(o,name,m,smooth=False):\n o.name=name\n o.data.materials.append(m)\n if smooth:\n for f in o.data.polygons:\n f.use_smooth=True\n parts.append(o)\n return o\n\n\ndef bevel(o,w,segments=3):\n if w:\n b=o.modifiers.new(\"Rounded production edges\",\"BEVEL\")\n b.width=w\n b.segments=segments\n b.harden_normals=True\n o.modifiers.new(\"Weighted panel normals\",\"WEIGHTED_NORMAL\")\n\n\ndef box(name,loc,dims,m,b=.20,rot=None):\n bpy.ops.mesh.primitive_cube_add(size=2,location=loc)\n o=bpy.context.object\n o.dimensions=dims\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n if rot:\n o.rotation_euler=rot\n add(o,name,m)\n bevel(o,b)\n return o\n\n\ndef ball(name,loc,scales,m,rot=None,res=38):\n bpy.ops.mesh.primitive_uv_sphere_add(segments=res,ring_count=max(16,int(res*.62)),location=loc)\n o=bpy.context.object\n o.scale=scales\n if rot:\n o.rotation_euler=rot\n return add(o,name,m,True)\n\n\ndef cylinder(name,a,b,r,m,segments=28,edge=.09):\n a,b=Vector(a),Vector(b)\n vec=b-a\n bpy.ops.mesh.primitive_cylinder_add(vertices=segments,radius=r,depth=vec.length,location=(a+b)/2)\n o=bpy.context.object\n o.rotation_euler=vec.to_track_quat(\"Z\",\"Y\").to_euler()\n add(o,name,m,True)\n bevel(o,edge,2)\n return o\n\n\ndef hermite(rows,t):\n k=next((i for i in range(len(rows)-1) if t<=rows[i+1][0]),len(rows)-2)\n a,b=rows[k:k+2]\n p,q=rows[max(0,k-1)],rows[min(k+2,len(rows)-1)]\n d=b[0]-a[0]\n u=max(0,min(1,(t-a[0])/d))\n return tuple((2*u**3-3*u*u+1)*a[i]+(u**3-2*u*u+u)*d*(b[i]-p[i])/(b[0]-p[0])+\n (-2*u**3+3*u*u)*b[i]+(u**3-u*u)*d*(q[i]-a[i])/(q[0]-a[0])\n for i in range(1,len(a)))\n\n\ndef grid(name,fn,m,rows,cols,wrap=False,caps=False,flip=False,idx=None):\n n=cols if wrap else cols+1\n V=[fn(i/cols,j/rows) for j in range(rows+1) for i in range(n)]\n F,UV,I=[],[],[]\n for j in range(rows):\n for i in range(cols):\n a,b=j*n+i,j*n+(i+1)%n\n f=(a,b,b+n,a+n)\n uv=((i/cols,j/rows),((i+1)/cols,j/rows),((i+1)/cols,(j+1)/rows),(i/cols,(j+1)/rows))\n F.append(f[::-1] if flip else f)\n UV.append(uv[::-1] if flip else uv)\n I.append(idx((i+.5)/cols,(j+.5)/rows) if idx else 0)\n if caps:\n F.extend([tuple(reversed(range(n))),tuple(range(rows*n,(rows+1)*n))])\n UV.extend([[(.5,.5)]*n,[(.5,.5)]*n])\n I.extend([0,0])\n return mesh(name,V,F,m,UV,I,close=caps)\n\n\ndef path(name,P,r,m,faces=15,flat=1,batch=False):\n P=list(map(Vector,P))\n V,F,UV=jobs[(name,m)] if batch else ([],[],[])\n start=len(V)\n for i,p in enumerate(P):\n tangent=(P[min(len(P)-1,i+1)]-P[max(0,i-1)]).normalized()\n ref=Vector((0,0,1)) if abs(tangent.z)<.92 else Vector((0,1,0))\n x=tangent.cross(ref).normalized()\n y=x.cross(tangent).normalized()\n d=r(i/(len(P)-1)) if callable(r) else r\n for j in range(faces):\n a=tau*j/faces\n V.append(p+d*(x*math.cos(a)+flat*y*math.sin(a)))\n def push(f,uv):\n F.append(f)\n UV.append(uv)\n for i in range(len(P)-1):\n for j in range(faces):\n n=(j+1)%faces\n push((start+i*faces+j,start+i*faces+n,start+(i+1)*faces+n,start+(i+1)*faces+j),\n [(j/faces,i/len(P)),((j+1)/faces,i/len(P)),((j+1)/faces,(i+1)/len(P)),(j/faces,(i+1)/len(P))])\n push(tuple(start+i for i in reversed(range(faces))),[(.5,0)]*faces)\n push(tuple(start+(len(P)-1)*faces+i for i in range(faces)),[(.5,1)]*faces)\n if not batch:\n return mesh(name,V,F,m,UV,close=True)\n\n\ndef curve(a,b,c,d,n=45):\n a,b,c,d=map(Vector,(a,b,c,d))\n pts=[]\n for i in range(n):\n t=i/(n-1)\n s=1-t\n pts.append(s**3*a+3*s*s*t*b+3*s*t*t*c+t**3*d)\n return pts\n\n\ndef xlathe(name,y,z,prof,m,n=152,radial=None):\n V,F,UV=[],[],[]\n for j,(x,r) in enumerate(prof):\n for i in range(n):\n a=tau*i/n\n rr=r+(radial(a,j,x,r) if radial else 0)\n V.append((x,y+rr*math.sin(a),z+rr*math.cos(a)))\n L=len(prof)\n for j in range(L):\n k=(j+1)%L\n for i in range(n):\n l=(i+1)%n\n F.append((j*n+i,j*n+l,k*n+l,k*n+i))\n UV.append([(i/n,j/L),((i+1)/n,j/L),((i+1)/n,(j+1)/L),(i/n,(j+1)/L)])\n return mesh(name,V,F,m,UV,close=True)\n\n\ndef ylathe(name,x,z,prof,m,n=116,tilt=1):\n # Radii are specified independently in X and Z for painted bezels and glass.\n V,F,UV=[],[],[]\n for a,b,y in prof:\n for i in range(n):\n t=tau*i/n\n V.append((x+a*math.cos(t),y,z+b*math.sin(t)))\n for j in range(len(prof)):\n k=(j+1)%len(prof)\n for i in range(n):\n q=(i+1)%n\n F.append((j*n+i,j*n+q,k*n+q,k*n+i))\n UV.append([(i/n,j/len(prof)),((i+1)/n,j/len(prof)),((i+1)/n,(j+1)/len(prof)),(i/n,(j+1)/len(prof))])\n return mesh(name,V,F,m,UV,close=True)\n\n\ndef label(name,s,loc,size,m,rotation=(math.pi/2,0,0)):\n d=bpy.data.curves.new(name,\"FONT\")\n d.body=s\n d.size=size\n d.align_x=\"CENTER\"\n d.align_y=\"CENTER\"\n d.space_character=1.13\n d.extrude=.034\n d.bevel_depth=.010\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.location=loc\n o.rotation_euler=rotation\n bpy.ops.object.select_all(action=\"DESELECT\")\n o.select_set(True)\n bpy.context.view_layer.objects.active=o\n bpy.ops.object.convert(target=\"MESH\")\n return add(bpy.context.object,name,m)\n\n\nFR=-60.5\nRE=61.1\nZ=22.8\nfor y,title,sizing in [(FR,\"Front\",1.0),(RE,\"Rear\",1.12)]:\n # Angular tread grooves are carved directly into the tire mesh.\n roundprof=[(-4.42,15.1),(-4.91,15.9),(-5.01,17),(-5.45,18.25),(-5.54,19.50),\n (-5.39,20.54),(-4.91,21.52),(-4.3,22.02),(-3.52,22.41),\n (-2.65,22.65),(-1.77,22.80),(-.87,22.90),(0,22.91),\n (.87,22.90),(1.77,22.80),(2.65,22.65),(3.52,22.41),\n (4.30,22.02),(4.91,21.52),(5.39,20.54),(5.54,19.50),(5.45,18.25),\n (5.01,17),(4.91,15.90),(4.42,15.1),(3.8,14.85),(-3.8,14.85)]\n prof=[]\n for i in range(len(roundprof)):\n a,b=roundprof[i],roundprof[(i+1)%len(roundprof)]\n for k in range(5):\n t=k/5\n prof.append(((a[0]*(1-t)+b[0]*t)*sizing,a[1]*(1-t)+b[1]*t))\n def tread(a,j,x,r):\n p=abs(x/sizing)\n phase=(a/tau)*62.0+abs(x)*.145+(.28 if x>0 else 0)\n groove=(.5+.5*math.cos(tau*phase))**13\n wide=(.5+.5*math.cos(tau*((a/tau)*62.0+.73+x*.21)))**14\n braid=(.5+.5*math.cos(tau*((a/tau)*31.0+.315*abs(x))))**17\n shoulder=0 if p>5.19 else (.72+.28*math.cos(p*.37))\n return -(.216*groove+.072*wide+.095*braid)*shoulder if r>21.38 else 0\n xlathe(title+\" treaded tire with swept grooves\",y,Z,prof,tire,366,tread)\n ring=[(-4.50,14.62),(-4.64,15.0),(-4.64,15.35),(-4.49,15.67),\n (-4.22,15.77),(-3.99,15.6),(3.99,15.6),(4.22,15.77),\n (4.49,15.67),(4.64,15.35),(4.64,15.0),(4.50,14.62),\n (4.20,14.32),(-4.20,14.32)]\n xlathe(title+\" cast alloy wheel and flange\",y,Z,[(x*sizing,r) for x,r in ring],alum)\n for s in (-1,1):\n r=[(s*4.65*sizing,14.69),(s*4.825*sizing,14.93),(s*4.817*sizing,15.29),\n (s*4.68*sizing,15.46),(s*4.58*sizing,15.12)]\n xlathe(title+\" turned bright rim \"+str(s),y,Z,r,chrome,158)\n p=[(s*4.62*sizing,16.31),(s*4.74*sizing,16.37),(s*4.75*sizing,16.49),(s*4.63*sizing,16.47)]\n xlathe(title+\" molded tire bead \"+str(s),y,Z,p,boot,144)\n cylinder(title+\" central alloy hub\",(-5.31*sizing,y,Z),(5.31*sizing,y,Z),4.72,alum,54,.38)\n for j in range(7):\n a=tau*(j+.07)/7\n pts=[]\n for k in range(35):\n t=k/34\n r=4.15+10.86*t\n angle=a+.183*math.sin(t*1.44)\n pts.append((.62*sizing*math.sin(math.pi*t),y+r*math.sin(angle),Z+r*math.cos(angle)))\n path(title+\" seven swept rim spokes\",pts,lambda t:1.33+.41*math.sin(math.pi*t),alum,17,1.42,True)\n plate=[(sizing*4.93,5.25),(sizing*5.29,5.57),(sizing*5.39,6.04),\n (sizing*5.39,10.41),(sizing*5.21,10.82),(sizing*4.87,10.39)]\n xlathe(title+\" circular machined brake rotor\",y,Z,plate,steel,148)\n xlathe(title+\" outer disc wear track\",y,Z,[(sizing*5.39,9.82),(sizing*5.43,9.81),\n (sizing*5.45,10.09),(sizing*5.39,10.12)],alum,138)\n for k in range(6):\n a=tau*k/6\n py,pz=y+3.11*math.sin(a),Z+3.11*math.cos(a)\n cylinder(title+\" hub nut\",(sizing*5.29,py,pz),(sizing*5.97,py,pz),.365,bolt,10,.074)\n for k in range(18):\n a=tau*k/18\n for r in (6.56,8.83):\n py,pz=y+r*math.sin(a+.29*r),Z+r*math.cos(a+.29*r)\n path(title+\" blackened brake drill details\",[(sizing*5.37,py,pz),(sizing*5.42,py,pz)],\n .373 if r<8 else .345,dark,12,1,True)\n\n# Front fork dampers are visible either side of the separate wheel.\nfor s in (-1,1):\n x=s*7.88\n cylinder(\"Lower fork cast slider\",(x,FR+2.43,21.7),(x,FR+7.24,44.21),2.05,alum,40,.42)\n cylinder(\"Polished fork stanchion\",(x,FR+6.79,40.3),(x,FR+13.37,68.81),1.34,chrome,37,.19)\n for j in range(7):\n y0=FR+7.5+j*.394\n z0=43.2+j*1.35\n cylinder(\"Fork gaiter raised rubber ring\",(x,y0,z0),(x,y0+.17,z0+.62),1.63-j*.043,boot,28,.12)\n cylinder(\"Short front visible wheel axle\",(x-s*1.8,FR,Z),(x+s*1.39,FR,Z),1.13,bolt,26,.23)\nbox(\"Brake caliper cast pod\",(8.06,FR+6.31,29.43),(4.0,5.79,5.0),dark,1.26,(.23,0,0))\npath(\"Front brake flexible conduit\",curve((8.22,FR+7.2,31),(9,FR+14,38),(8,FR+15,52),(8,FR+10,62)),\n .32,boot,12)\n\ndef fender(u,v,ext=0):\n t=-1.18+2.45*v\n w=7.19*(.78+.22*math.sin(math.pi*v)**.63)\n a=2*u-1\n x=(w+ext)*a\n edge=1.67*abs(a)**2.27\n r=25.29+2.75*math.sin(math.pi*v)**.61-edge\n return (x,FR+r*math.sin(t),Z+r*math.cos(t))\n\nfd=grid(\"Curved sea-glass front mudguard\",fender,paint,100,91)\nmd=fd.modifiers.new(\"Rounded mudguard shell\",\"SOLIDIFY\")\nmd.thickness=.60\nmd.offset=-1\nbevel(fd,.12,3)\nfor s,u0 in [(-1,.01),(1,.99)]:\n pts=[Vector(fender(u0,t))+Vector((s*.12,0,.045)) for t in np.linspace(.026,.978,103)]\n path(\"Thin front mudguard bright edge\",pts,.16,chrome,12)\nfor x in (-.29,.29):\n pts=[Vector(fender(.50+x*.19,t))+Vector((0,-.024,.067)) for t in np.linspace(.18,.78,81)]\n path(\"Front fender ivory pinstripes\",pts,.101,ivory,10,.71)\nball(\"Front fender crown crest\",(0,FR-12.3,46.63),(1.22,2.13,.41),chrome,(.34,0,0))\n\n# Rear body shape with strongly curved pressed panels and wraparound lower trim.\ntailbody=[(6.5,.42,32.1,35.6),(10,10.63,25.91,50.8),(18,17.6,24.7,63.29),\n (29,20.8,25.91,67.2),(43,23.15,26.37,68.9),\n (58,23.53,25.75,67.47),(69,20.92,28.13,63.7),\n (77.4,15.81,32.76,58.87),(81.87,8.43,37.41,53.97),(83.42,.41,43.75,48.16)]\ndef rear(a,y):\n w,lo,hi=hermite(tailbody,y)\n c,s=math.cos(a),math.sin(a)\n zz=(hi+lo)*.5+(hi-lo)*.5*math.copysign(abs(c)**.77,c)\n xx=w*math.copysign(abs(s)**.765,s)\n wavy=(.094*math.cos(6*a+y*.21)+.129*math.sin(y*.28+a*2))*math.sin(math.pi*(y-6.5)/76.92)\n return xx,y,zz+wavy\n\ngrid(\"Sculpted rear coachwork and lower fairings\",lambda u,v:rear(tau*u,6.5+76.92*v),\n [paint,sand],134,164,True,True,idx=lambda u,v:int(abs(u-.5)<.216))\nfor s in (-1,1):\n for ang,h in [(1.79,0),(1.91,-.541)]:\n pts=[]\n for y in np.linspace(13.01,79.77,138):\n xx,yy,zz=rear(s*(ang+.14*math.sin((y-15)*.044)),float(y))\n pts.append((xx+s*.18,yy,zz+h))\n path(\"Contrasting rear body side reveal and beltline\",pts,.208 if h else .118,\n chrome if h else dark,13,.91)\nfor s in (-1,1):\n yt,zt=42.07,50.825\n xx,_,_=rear(s*1.30,yt)\n V=[]\n for i in range(56):\n a=tau*i/56\n y,z=yt+6.66*math.cos(a),zt+2.80*math.sin(a)+.09*math.cos(a)\n w,lo,hi=hermite(tailbody,y)\n xn=w*(1-min(1,abs((z-(lo+hi)/2)/((hi-lo)*.5))**(2/.77)))**(.765/2)\n V.append((s*(xn+.16),y,z))\n vent=mesh(\"Inset deep-teal rear cowl vent\",V,[tuple(range(56))],dark,close=False)\n solid=vent.modifiers.new(\"Pressed vent plate\",\"SOLIDIFY\")\n solid.thickness=.19\n for k in range(6):\n y=yt-4.28+k*1.71\n w,lo,hi=hermite(tailbody,y)\n z=zt+.19+.117*k\n x=w*(1-min(1,abs((z-(lo+hi)*.5)/((hi-lo)*.5))**(2/.77)))**(.765/2)\n o=box(\"Bright vent grille louvre\",(s*(x+.301),y,z),(.32,.34,3.26 if k in (2,3) else 2.67),\n alum,.14,(.264,0,0))\n for k in (-1,1):\n y=yt+5.39*k\n cylinder(\"Cowl vent retaining screw\",(s*(xx+.08),y,zt),(s*(xx+.46),y,zt),.211,bolt,16,.026)\n\nseat=[(12.8,.31,64.1,65.01),(14.2,6.13,64.5,70.18),(18.0,11.75,65.6,74.62),\n (29.0,14.38,66.1,77.15),(41,16.67,67.0,77.63),(48.5,18.36,67.84,79.42),\n (57,18.87,67.26,80.35),(66,17.48,66.17,79.54),\n (73.3,13.17,63.99,76.99),(77.29,6.1,62.25,71.41),(78.22,.394,62.3,68.29)]\ndef seatp(a,y):\n w,lo,hi=hermite(seat,y)\n s,c=math.sin(a),math.cos(a)\n x=w*math.copysign(abs(s)**.746,s)\n z=(hi+lo)*.5+(hi-lo)*.5*math.copysign(abs(c)**.544,c)\n z-=.31*math.exp(-((y-43.7)/2.18)**2)*max(0,c)\n return x,y,z\ndef seat_pan(a,y):\n w,lo,hi=hermite(seat,y)\n si,co=math.sin(a),math.cos(a)\n x=w*.918*math.copysign(abs(si)**.771,si)\n yy=y+.105*(y-45)/32\n top=lo+1.349\n bottom=lo-3.95-.74*math.sin((y-12.8)/65.42*math.pi)\n z=(top+bottom)*.5+(top-bottom)*.5*math.copysign(abs(co)**.68,co)\n return x,yy,z\ngrid(\"Molded dark foundation under saddle\",lambda u,v:seat_pan(tau*u,13.19+64.27*v),dark,101,101,True,True)\n\ngrid(\"Cognac sculpted two-place saddle\",lambda u,v:seatp(tau*u,12.8+65.42*v),\n leather,128,132,True,True)\nfor s in (-1,1):\n pts=[Vector(seatp(s*1.78,t))+Vector((s*.21,0,.054)) for t in np.linspace(13.31,77.76,148)]\n path(\"Piped lower saddle perimeter\",pts,.266,seam,14,.83)\n for j in range(1,97):\n a=13.66+j*.644\n pp=[Vector(seatp(s*1.49,a+.22*t))+Vector((s*.127,0,.161)) for t in (0,.5,1)]\n path(\"Individually stitched saddle perimeter\",pp,.055,stitch,7,.67,True)\nfor j in range(78):\n a=(j/78)*math.pi*1.46-math.pi*.73\n P=[Vector(seatp(a+.019*t,44.44+.12*math.sin(a)))+Vector((.07*math.sin(a),0,.19)) for t in (0,.5,1)]\n path(\"Double saddle section seam stitches\",P,.055,stitch,7,.67,True)\n\n# Dark running mat and separate deck bridge between the two body sections.\nbox(\"Rounded step-through floor casting\",(0,-15.6,28.43),(31.2,49.1,7.43),sand,3.17)\nbox(\"Recessed grippy footwell rubber mat\",(0,-15.7,32.08),(29.04,44.09,1.22),dark,2.38)\nfor s in (-1,1):\n for j in range(4):\n x=s*(4.18+j*2.89)\n box(\"Raised foot mat rib\",(x,-15.89,32.75),(.844,36.1-(j%2)*.95,.477),boot,.221)\n pts=[(s*13.5,-37.7,30.75),(s*15.17,-31.1,31.40),(s*15.7,-10.1,31.52),(s*14.1,5.47,31.41)]\n path(\"Continuous stainless footwell edging\",pts,.26,chrome,12)\n\n# Swept front fairing and side brows. The rear face is a separate shaded panel.\nlegprof=[(31.18,14.83,-39.1),(38.28,17.46,-43.22),(48.08,19.8,-48.8),\n (59.2,22.36,-51.67),(70.61,23.31,-50.77),(79.83,21.91,-47.46),\n (85.91,17.89,-44.84),(89.58,11.02,-43.14),(91.06,.071,-42.7)]\ndef shield(u,v):\n z=31.18+59.88*v\n w,y=hermite(legprof,z)\n a=2*u-1\n x=w*a\n yy=y+(2.17+.89*math.sin(math.pi*v))*abs(a)**2.25+.475*abs(a)**7\n zz=z-(.815+.97*v**3)*abs(a)**4.2*math.sin(math.pi*v)**1.15\n return x,yy,zz\nsh=grid(\"Pressed sea-glass front leg fairing\",shield,[paint,sand],164,154,\n idx=lambda u,v:int(abs(u-.5)>.410 and v>.082 and v<.855))\nth=sh.modifiers.new(\"Padded fairing panel backing\",\"SOLIDIFY\")\nth.thickness=1.62\nth.offset=-1\nth.material_offset=0\nth.material_offset_rim=1\nbevel(sh,.31,4)\nfor s in (-1,1):\n U=.003 if s<0 else .997\n pts=[Vector(shield(U,t))+Vector((s*.13,.056,.02)) for t in np.linspace(.036,.969,98)]\n path(\"Chrome front leg-shield border\",pts,.272,chrome,15)\nfor z,ra in [(77.1,2.02),(68.2,1.14)]:\n T=(z-31.18)/59.88\n _,y0,z0=shield(.5,T)\n ball(\"Central brightwork button\",(0,y0-.355,z0),(ra,.42,ra*.638),chrome)\nfor s in (-1,1):\n pts=[]\n for j in range(52):\n t=.175+.48*j/51\n b=.5+s*(.074+.033*math.sin(math.pi*t))\n x,y,z=shield(b,t)\n pts.append((x,y-.153,z))\n path(\"Thin upright fairing coach stripes\",pts,.168,ivory,12,.83)\ndef point_badge(z):\n x,y,_=shield(.5,(z-31.18)/59.88)\n return x,y,z\n_,y,z=point_badge(71.8)\nbox(\"Original recessed front model badge\",(0,y-.33,z),(11.62,.633,2.45),paint_dark,.62)\nlabel(\"Breakwater main badge\",\"BREAKWATER\",(0,y-.687,z-.038),.997,ivory)\n_,y,z=point_badge(79.64)\nlabel(\"Front capacity emblem\",\"125\",(0,y-.229,z),1.67,chrome)\n\n# Shadowed underbody, shock spring and exhaust on the presentation side.\nbox(\"Dark central underbody casting\",(0,29.1,25.41),(24.27,58.9,12.4),dark,4.65)\nfor s in (-1,1):\n x=s*11.70\n a=Vector((x,52.95,29.2))\n b=Vector((x,63.1,48.95))\n d=(b-a).normalized()\n p0=Vector((1,0,0))\n p1=d.cross(p0)\n cylinder(\"Rear damper internal cylinder\",a,b,1.47,steel,30,.24)\n P=[]\n for j in range(258):\n t=j/257\n angle=tau*6.71*t\n P.append(a.lerp(b,t)+1.911*(p0*math.cos(angle)+p1*math.sin(angle)))\n path(\"Exposed rear suspension spring\",P,.299,chrome,12)\n for q in (a,b):\n cylinder(\"Rear shock spherical-headed bolt\",q-Vector((1.47,0,0)),q+Vector((1.47,0,0)),.87,bolt,20,.14)\npath(\"Swept lower exhaust header\",curve((14.6,25.5,26.8),(23.2,29.2,14.6),\n (21.9,46.2,15.5),(21.1,48.4,21.38)),1.78,steel,24)\nbox(\"Rounded longitudinal rear muffler\",(21.6,61.5,21.08),(8.1,30.1,9.16),alum,3.55,(.10,0,0))\nbox(\"Polished muffler heat guard\",(25.04,61.0,22.19),(1.51,25.11,7.15),chrome,2.5,(.10,0,0))\nfor y,z in ((52.2,21.2),(68.95,23.2)):\n cylinder(\"Visible muffler guard screw\",(25.1,y,z),(26.02,y,z),.58,steel,17,.10)\ncylinder(\"Muffler outlet dark opening\",(21.72,74.31,21.96),(21.72,77.21,22.21),1.97,dark,38,.28)\npath(\"Center stand display foot\",[(5.03,7.92,26.15),(7.1,15.0,15.2),(9.8,19.0,3.0),(14.1,20.21,.54)],\n .683,steel,14)\nbox(\"Center stand rubber ground shoe\",(14.0,20.24,.47),(5.16,2.84,1.03),dark,.26)\npath(\"Rear chrome hand rail\",curve((-16.1,56.9,68.0),(-16.7,82.0,72.0),\n (16.7,82.0,72.0),(16.1,56.9,68.0)),.957,chrome,20)\nbox(\"Rounded central red tail lamp base\",(0,82.0,52.2),(18.43,4.33,6.16),chrome,2.04,(.14,0,0))\nbox(\"Ruby tail lens\",(0,84.04,52.03),(17.23,3.11,5.43),tail,2.21,(.14,0,0))\nfor x in np.linspace(-6.7,6.7,17):\n box(\"Tail lamp internal narrow ridge\",(x,85.13,52.03),(.145,.208,3.33),tail,.062)\nbox(\"Rear registration plate recess\",(0,83.51,42.10),(15.39,2.4,6.37),dark,1.16,(-.16,0,0))\nbox(\"Small ivory rear display plate\",(0,84.86,42.10),(14.52,.602,5.63),ivory,.54,(-.16,0,0))\nlabel(\"Rear display plate line\",\"BW 125\",(0,85.30,42.12),2.12,ink,(math.pi/2,0,math.pi))\n\n# Handlebar nacelle with the oval lens embedded in the fascia.\ncylinder(\"Painted steering neck\",(0,-42.69,84.0),(0,-43.69,98.4),3.78,paint,48,.82)\nbox(\"Rounded handlebar nacelle\",(0,-45.36,97.75),(26.1,13.8,15.03),paint,5.34,(.11,0,0))\nfor s in (-1,1):\n path(\"Curved handlebar tube\",curve((s*10.0,-44.0,98.00),(s*17.0,-43.8,99.31),\n (s*24,-41.2,96.91),(s*33.1,-32.5,95.68),52),\n 1.21,chrome,21)\n a=(s*24.21,-38.2,96.6)\n b=(s*35.91,-30.16,95.31)\n cylinder(\"Fluted black handlebar grip\",a,b,1.65,boot,40,.24)\n a,b=Vector(a),Vector(b)\n d=(b-a).normalized()\n for j in range(10):\n q=a.lerp(b,.115+.081*j)\n cylinder(\"Grip annular rubber rib\",q-d*.100,q+d*.100,1.71,boot,24,.042)\n cylinder(\"Polished bar-end plug\",b-d*.09,b+d*.443,1.61,chrome,28,.16)\n ball(\"Handlebar control switch pod\",(s*23.2,-38.0,96.82),(2.3,2.12,2.20),dark)\n path(\"Curved hand brake lever\",curve((s*22.8,-40.3,96.41),(s*26,-45.9,95.85),\n (s*34.2,-41.7,95.03),(s*36.04,-38.4,95.23)),\n lambda t:.48-.152*t,chrome,13)\n ball(\"Blunt lever end\",(s*36.04,-38.4,95.23),(.428,.412,.44),chrome)\n path(\"Small angled turn signal mount\",curve((s*10.5,-45.7,94.7),(s*14.0,-44.4,93.5),\n (s*18.3,-44.6,92.4),(s*19.78,-46.13,91.23)),\n .56,chrome,16)\n ball(\"Front turn signal black socket\",(s*19.9,-46.38,91.18),(3.33,1.82,2.29),dark)\n ball(\"Front amber signal lens\",(s*19.9,-47.37,91.21),(2.94,1.51,1.92),amber)\n for i in range(5):\n x=s*19.9+(i-2)*.63\n y=-48.66+.12*(i-2)**2\n path(\"Amber lens micro fluting\",[(x,y,90.48),(x,y-.12,91.17),(x,y,91.98)],\n .095,amber,9,1,True)\n k=1.31 if s<0 else -.8\n path(\"Tall curved chromed mirror stalk\",curve((s*18.30,-42.42,98.74),(s*21.29,-39.12,104.7),\n (s*31.19,-35.0,113.4+k),(s*35.62,-33.4,115.14+k)),\n .53,chrome,21)\n ball(\"Mirror stalk saddle clamp\",(s*18.30,-42.42,98.62),(1.12,.93,.65),chrome)\n o=ball(\"Rounded rear-view mirror black shell\",(s*36.3,-33.23,117.12+k),\n (6.13,1.76,3.93),paint_dark,(0,s*.184,s*.32),44)\n ball(\"Rear-view mirror glass\",(s*36.35,-31.84,117.12+k),(5.69,.63,3.53),chrome,(0,s*.184,s*.32),44)\n\nprof=[(9.1,4.65,-51),(9.78,5.22,-51.3),(10.29,5.59,-51.95),(10.35,5.65,-52.98),\n (10.14,5.50,-53.72),(9.68,5.16,-54.1),(9.16,4.67,-54.1),(8.80,4.40,-53.70),\n (8.72,4.31,-52.88),(8.98,4.50,-51.47)]\nylathe(\"Continuous polished oval headlamp bezel\",0,98.3,prof,chrome)\nball(\"Oval headlight optical cup\",(0,-52.08,98.31),(9.27,1.65,4.76),opal)\nfor j in range(19):\n x=(j-9)*.835\n h=4.10*math.sqrt(max(.03,1-(x/8.31)**2))\n P=[(x,-53.52-.10*(1-(k/20)**2),98.30+h*(2*k/20-1)) for k in range(21)]\n path(\"Fluted period headlamp reflector ribs\",P,.175,light,11,.79,True)\np=[(.001,.001,-55.15),(1.77,.92,-55.12),(4.75,2.48,-54.99),(7.39,3.83,-54.74),\n (8.92,4.57,-54.30),(9.36,4.77,-53.95),(9.22,4.62,-53.65),(7.88,4.15,-53.86),\n (.001,.001,-54.57)]\nylathe(\"Convex transparent front headlight lens\",0,98.31,p,glass,147)\n\n# Simple dashboard hardware and stamped marks on the rider-facing side.\ndash=ball(\"Rider-facing instrument face\",(0,-42.12,104.68),(7.13,5.61,.693),ink,(-.25,0,0))\no=ball(\"Instrument binnacle alloy lip\",(0,-42.11,104.26),(7.57,5.95,.747),chrome,(-.25,0,0))\nfor j in range(13):\n a=math.radians(-18+18*j)\n P=[(q*math.cos(a),-42.1+q*.712*math.sin(a),105.16-.27*q*.712*math.sin(a)) for q in (4.41,4.86,5.10)]\n path(\"Instrument dial markings\",P,.072,ivory,8,.77,True)\npath(\"Analog red speed indicator needle\",[(0,-42.12,105.36),(-1.69,-42.62,105.48),(-3.78,-43.34,105.53)],\n .132,red,10,.61)\nball(\"Dial center hub\",(0,-42.13,105.37),(.34,.34,.16),chrome)\nlabel(\"Tiny rider-side speed scale title\",\"KM/H\",(0,-42.98,105.47),.655,ivory,(.17,0,0))\n\nfor (name,m),(V,F,UV) in jobs.items():\n mesh(name,V,F,m,UV,close=True)\n\nroot=bpy.data.objects.new(\"Breakwater 125 vintage step-through scooter\",None)\nbpy.context.collection.objects.link(root)\nroot[\"asset_id\"]=\"vehicles-breakwater-125-city-scooter-v1\"\nroot[\"category\"]=\"vehicles\"\nroot[\"fictional_design\"]=True\nroot[\"units\"]=\"meters in glTF\"\nroot[\"wheelbase_m\"]=1.216\nfor ob in parts:\n ob.parent=root\nroot.location.z=.124\nif not args.draft and not args.preview_only:\n root.scale=(.01,)*3\n root.location.z=.00124\n bpy.context.view_layer.update()\n bpy.ops.object.select_all(action=\"DESELECT\")\n root.select_set(True)\n for ob in parts:\n ob.select_set(True)\n bpy.ops.export_scene.gltf(filepath=str(out/(stem+\".glb\")),export_format=\"GLB\",use_selection=True,\n export_apply=True,export_yup=True,export_extras=True)\n root.scale=(1,)*3\n root.location.z=.124\n\n# Seamless photographic cove, lights and camera are created after export.\nstage=material(\"Dark neutral automotive studio cove\",\"535654\",.88)\nstations=[(-880,-.019),(138,-.019)]\nfor i in range(1,52):\n a=math.pi/2*i/51\n stations.append((138+165*math.sin(a),165*(1-math.cos(a))-.019))\nstations.append((303,1500))\nV=[(x,y,z) for y,z in stations for x in (-2200,2200)]\nF=[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(stations)-1)]\nstudio=mesh(\"Temporary photographic sweep\",V,F,stage,keep=False)\nstudio.data.polygons[0].use_smooth=False\n\n\ndef aim(o,at):\n o.rotation_euler=(Vector(at)-o.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef area(name,loc,at,power,c,w,h):\n d=bpy.data.lights.new(name,\"AREA\")\n d.energy=power\n d.color=c\n d.shape=\"RECTANGLE\"\n d.size=w\n d.size_y=h\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.location=loc\n aim(o,at)\n\n\narea(\"Huge warm key over front end\",(-146,-179,227),(0,-10,55),612000,(1,.956,.87),163,172)\narea(\"Cool rim across saddle and rear\",(-35,142,194),(0,16,64),621000,(.80,.91,1),147,138)\narea(\"Broad camera-right fill\",(139,-113,154),(0,2,55),247000,(.91,.959,1),104,117)\narea(\"Narrow chrome cabinet reflection\",(-103,-73,57),(0,0,52),54700,(1,.90,.72),43,80)\nscene=bpy.context.scene\nscene.world.use_nodes=True\nw=scene.world.node_tree.nodes[\"Background\"]\nw.inputs[\"Color\"].default_value=(.155,.178,.197,1)\nw.inputs[\"Strength\"].default_value=.36\nd=bpy.data.cameras.new(\"Automotive three-quarter camera\")\ncamera=bpy.data.objects.new(d.name,d)\nbpy.context.collection.objects.link(camera)\ncamera.location=(327,-288,190)\naim(camera,(0,2,55.3))\nd.lens=73\nd.clip_end=6500\nscene.camera=camera\nscene.render.engine=\"CYCLES\"\nscene.cycles.samples=19 if args.draft else 128\nscene.cycles.use_denoising=False\nscene.cycles.adaptive_threshold=.075 if args.draft else .014\nscene.cycles.max_bounces=8\nscene.view_settings.view_transform=\"AgX\"\nscene.view_settings.look=\"AgX - Medium High Contrast\"\nscene.view_settings.exposure=.14\nscene.render.resolution_x=1920\nscene.render.resolution_y=1500\nscene.render.resolution_percentage=44 if args.draft else 100\nscene.render.image_settings.file_format=\"PNG\"\nscene.render.image_settings.color_mode=\"RGB\"\nscene.render.filepath=str(out/(\"draft.png\" if args.draft else stem+\".png\"))\nbpy.ops.render.render(write_still=True)\n```\n\nrun it: `blender -b --python breakwater.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T0300Z-vehicles-breakwater-125-scooter.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/breakwater-125-scooter/3d-dataset-20261127T0300Z-vehicles-breakwater-125-scooter.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/bracken-head-basalt-coast.jpg"}}, {"type": "text", "text": "create an image of a bracken head basalt coast"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nAn aerial view of a rugged coastline. Rolling green grassland on top ends at a long, layered basalt cliff with brown iron staining and horizontal bedding. The cliff line juts out into a headland. Two tall grooved sea stacks with green caps stand offshore, there's a small rock in open water, and turquoise sea with white surf breaks along the foot of the cliff and around the stacks.\n\nSCALE\nAbout 3.2 km wide, 128.3 m tall, 3.4 km deep. Real-scale landscape in meters, +Y up, +Z forward, origin at nominal sea level near the main headland.\n\nPARTS\n1. Upland: rolling maritime grassland with inland ridges, denser near the cliff rim and lighter toward the far corners. Build: a height-field grid with more tessellation at the rim.\n2. Cliff wall: stacked, fractured basalt following the irregular headland outline, with layering that follows the rim and undercut sea caves. Build: a wall mesh swept along the coast curve with layered relief.\n3. Intertidal shelf: eroded basalt platforms and shoal strips at the cliff foot, showing through breaks in the surf. Build: ridges carved into the terrain at the base of the wall.\n4. Sea stacks: offshore columns with tapered, grooved sides and irregular turf caps. Build: tapered extrusions with vertical grooves and a separate green cap.\n5. Boulders and talus: angular talus at the outcrops and wave-polished blocks on the tidal shelf. Build: scattered irregular rock meshes.\n6. Water: one continuous sea surface with directional swells, turquoise shallows and white surf around the base of the cliff and the stacks. Build: a displaced water plane with a world-space seabed and foam texture.\n\nPLAN\n1. Setup: clear the scene, meters, origin at sea level near the headland.\n2. Texture maps: generated inside bracken.py. Weathered basalt with iron staining and fractures, a grass and heather map with exposed soil, and a seabed and surf map sharing the same world UVs as the normals.\n3. Build order: coast outline and stack positions, upland terrain, cliff wall, intertidal shelf, sea stacks, talus and boulders, water.\n4. Assemble: upland meets the cliff rim along one shared outline, cliff foot meets the shelf at sea level, stacks rise from the water offshore, water surrounds everything and wraps foam around the stacks.\n5. Materials: weathered basalt, wet polished basalt blocks, salt-swept grass and earth, tidal water with turquoise shallows and white surf.\n6. Export: landscape only, lighting and camera excluded, one GLB with the textures embedded.\n\nCHECK\n923,944 triangles across 15 parts. Against the image: cliff height small compared to the width of the land, headland juts toward the stacks, stacks taller than they are wide, surf visible all along the cliff base.\n\n\n```python\n# bracken.py\n\"\"\"Original Bracken Head coastal landscape. Working and exported units are meters.\"\"\"\nimport argparse\nimport math\nfrom pathlib import Path\nimport sys\n\nimport bpy\nimport numpy as np\nfrom mathutils import Vector\n\nap=argparse.ArgumentParser()\nap.add_argument(\"--output\",type=Path,required=True)\nap.add_argument(\"--draft\",action=\"store_true\")\nap.add_argument(\"--preview-only\",action=\"store_true\")\nargs=ap.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\nout=args.output.resolve()\nout.mkdir(parents=True,exist_ok=True)\nstem=\"3d-dataset-20261127T0400Z-landscape-bracken-head-basalt-coast\"\nseed=np.random.default_rng(47513)\ntau=math.tau\nparts=[]\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.object.delete(use_global=False)\n\n\ndef rgb(h):\n q=[int(h[i:i+2],16)/255 for i in (0,2,4)]\n return tuple(x/12.92 if x<=.04045 else ((x+.055)/1.055)**2.4 for x in q)\n\n\ndef material(name,h,rough,metal=0,coat=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*rgb(h),1)\n m.use_nodes=True\n p=m.node_tree.nodes.get(\"Principled BSDF\")\n p.inputs[\"Base Color\"].default_value=m.diffuse_color\n p.inputs[\"Roughness\"].default_value=rough\n p.inputs[\"Metallic\"].default_value=metal\n p.inputs[\"Coat Weight\"].default_value=coat\n p.inputs[\"Coat Roughness\"].default_value=.27\n return m\n\n\ndef put(name,a,space):\n h,w=a.shape[:2]\n rgba=np.concatenate((a,np.ones((h,w,1),np.float32)),axis=-1)\n img=bpy.data.images.new(name,width=w,height=h,alpha=False)\n img.colorspace_settings.name=space\n img.pixels.foreach_set(np.ascontiguousarray(rgba,dtype=np.float32).ravel())\n img.file_format=\"PNG\"\n img.filepath_raw=str(out/(name+\".png\"))\n img.save()\n img.reload()\n img.colorspace_settings.name=space\n return img\n\n\ndef attach(m,im,destination,strength=None):\n nt=m.node_tree\n t=nt.nodes.new(\"ShaderNodeTexImage\")\n t.image=im\n target=nt.nodes.get(\"Principled BSDF\").inputs[destination]\n if strength is None:\n nt.links.new(t.outputs[\"Color\"],target)\n else:\n normal=nt.nodes.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value=strength\n nt.links.new(t.outputs[\"Color\"],normal.inputs[\"Color\"])\n nt.links.new(normal.outputs[\"Normal\"],target)\n\n\ndef ease(z,a,b):\n t=np.clip((z-a)/(b-a),0,1)\n return t*t*(3-2*t)\n\n\nclass Field:\n def __init__(self,k):\n self.rng=np.random.default_rng(k)\n self.tables={}\n\n def n(self,x,y,key=0):\n if key not in self.tables:\n self.tables[key]=self.rng.uniform(-1,1,(278,281)).astype(np.float32)\n t=self.tables[key]\n a,b=np.floor(x).astype(np.int32),np.floor(y).astype(np.int32)\n u,v=x-a,y-b\n u=u*u*(3-2*u)\n v=v*v*(3-2*v)\n p=t[b%278,a%281]*(1-u)+t[b%278,(a+1)%281]*u\n q=t[(b+1)%278,a%281]*(1-u)+t[(b+1)%278,(a+1)%281]*u\n return p*(1-v)+q*v\n\n\nfield=Field(571)\ndef dims(s):\n y,x=np.mgrid[:s,:s].astype(np.float32)/(s-1)\n return x,y\n\nU,V=dims(1536)\n\ndef norm(z,sx,sy):\n dx=(np.roll(z,-1,axis=1)-np.roll(z,1,axis=1))*sx\n dy=(np.roll(z,-1,axis=0)-np.roll(z,1,axis=0))*sy\n k=np.sqrt(1+dx*dx+dy*dy)\n return np.stack((.5-.5*dx/k,.5-.5*dy/k,.5+.5/k),axis=-1)\n\n\ndef seamless(data,overlap=98):\n \"\"\"Reconcile both pairs of boundaries while preserving the interior grains.\"\"\"\n tiled=np.array(data,copy=True)\n for axis in (0,1):\n r=np.moveaxis(tiled,axis,0)\n f=.25*(1+np.cos(np.linspace(0,math.pi,overlap)))\n f=f.reshape((overlap,)+(1,)*(r.ndim-1))\n first=r[:overlap].copy()\n last=r[-overlap:][::-1].copy()\n r[:overlap]=first*(1-f)+last*f\n r[-overlap:]=(last*(1-f)+first*f)[::-1]\n return tiled\n\n\ndef rgb_mix(a,b,t):\n return np.asarray(a)*(1-t[:,:,None])+np.asarray(b)*t[:,:,None]\n\n\n# Broad shadowed gray ledges, fractures and irregular oxidized stone grains.\nxx=U+.011*field.n(U*9,V*14,1)\nyy=V+.006*field.n(U*13,V*10,2)+.0018*np.sin(U*62)\ncolumn=(.5+.5*np.cos(tau*(xx*31+.28*field.n(U*29,V*7,3))))**14\nband=(.5+.5*np.cos(tau*(yy*16+.17*field.n(U*9,V*29,4))))**6\ncrack_sig=np.sin(tau*(yy*29+xx*1.5+.31*field.n(U*14,V*25,5)))\nline=(.5+.5*crack_sig)**22\nstone_grit=.46*field.n(U*73,V*79,6)+.30*field.n(U*176,V*163,7)+.24*field.n(U*411,V*377,8)\nwash=field.n(U*15,V*17,9)+.30*field.n(U*40,V*49,10)\niron=ease(wash,.26,.87)*.54\nbasalt_color=rgb_mix([.376,.365,.350],[.495,.390,.291],iron)\nbasalt_color+=((.031*stone_grit+.043*wash-.040*line-.026*column+.020*band))[:,:,None]\nbasalt=material(\"Weathered basalt | iron staining and bedding fractures\",\"59554E\",.86)\nattach(basalt,put(\"Basalt_BaseColor\",np.clip(seamless(basalt_color),.10,.80),\"sRGB\"),\"Base Color\")\nattach(basalt,put(\"Basalt_Normal\",norm(seamless(-.095*column-.123*line+.18*stone_grit+.139*band),6.2,6.9),\"Non-Color\"),\"Normal\",.66)\nboulder=material(\"Wave-polished wet basalt blocks\",\"383A36\",.59,.015,.07)\nattach(boulder,bpy.data.images[\"Basalt_BaseColor\"],\"Base Color\")\nattach(boulder,bpy.data.images[\"Basalt_Normal\"],\"Normal\",.43)\n\n# Higher level turf has heather, coarse blades and exposed soil within one map.\nwr=.226*field.n(U*14,V*15,11)+.317*field.n(U*37,V*35,12)+.17*field.n(U*103,V*92,13)\ngrassfine=.036*field.n(U*457,V*443,14)+.057*field.n(U*281,V*247,15)+.10*field.n(U*132,V*143,16)\ng=ease(wr,-.22,.29)\ngrasscolor=rgb_mix([.293,.326,.194],[.410,.448,.245],g)\nt=ease(field.n(U*17,V*14,17)+.62*wr,.10,.81)*.56\ngrasscolor=grasscolor*(1-t[:,:,None])+np.array([.498,.461,.347])*t[:,:,None]\ngrasscolor+=(grassfine*.34+wr*.019)[:,:,None]\ngrass=material(\"Salt-swept maritime grass and exposed earth\",\"6A6E40\",.93)\nattach(grass,put(\"MaritimeTurf_BaseColor\",np.clip(seamless(grasscolor),.037,.94),\"sRGB\"),\"Base Color\")\nattach(grass,put(\"MaritimeTurf_Normal\",norm(seamless(grassfine*.92+.27*wr),5.0,4.9),\"Non-Color\"),\"Normal\",.31)\n\n# Irregular headland plan, coastal contour and offshore sea stacks.\n# Coast positions are deliberately fictional.\nyks=np.array([-1200,-900,-741,-625,-495,-407,-330,-263,-198,-155,-124,-81,-44,0,\n 42,78,122,173,214,259,307,362,432,511,611,743,895,1090,1330])\nxks=np.array([-235,-214,-221,-191,-163,-158,-139,-105,-79,-69,-52,8,53,87,\n 109,103,71,42,80,151,183,172,119,75,45,38,118,126,108],dtype=float)\nx_slope=np.gradient(xks,yks)\nymin,ymax=-1200.,1330.\nxmin=-1240.\nwxlo,wxhi=-1610.,1620.\nwylo,wyhi=-1610.,1820.\n\n\ndef coast(y):\n y=np.asarray(y)\n i=np.clip(np.searchsorted(yks,y,side=\"right\")-1,0,len(yks)-2)\n s=yks[i+1]-yks[i]\n t=np.clip((y-yks[i])/s,0,1)\n x0=(2*t**3-3*t*t+1)*xks[i]+(t**3-2*t*t+t)*s*x_slope[i]+(-2*t**3+3*t*t)*xks[i+1]+(t**3-t*t)*s*x_slope[i+1]\n x0+=4.4*field.n(y*.075,0.,18)+2.0*field.n(y*.201,0.,19)+.94*field.n(y*.455,0.,20)\n x0+=3.1*np.sin(y*.048+1.71)\n return x0\n\n\ndef cliff_height(y):\n return (68.4+10.6*np.sin(y*.013+.80)+5.7*np.sin(y*.021+.42)+4.9*field.n(y*.040,0.,21)+3.93*np.cos(y*.007+.94)\n -16.3*np.exp(-((y+144)/57.5)**2)+12.7*np.exp(-((y-69)/47.5)**2)-8.8*np.exp(-((y-184)/36.0)**2))\n\n\ndef shore_x(y):\n return coast(y)+12.65+3.2*field.n(y*.038,0.,22)+2.9*np.sin(y*.038+.20)\n\n\n# Standalone water plane with an authored seabed/foam texture in world space.\nS=2048\nuw,vw=dims(S)\nX=wxlo+(wxhi-wxlo)*uw\nY=wylo+(wyhi-wylo)*vw\nstacks=[(192.5,47.7,18.2,17.0,57.5,-.92),(241.2,97.0,14.1,12.1,42.6,.91),\n (209.7,126.7,7.35,10.11,12.84,.11),(294.5,276.0,15.86,8.94,10.77,.44),\n (142.5,-150.4,11.16,6.38,5.42,1.20)]\ndst=(X-shore_x(Y))*(1/(1+np.square((coast(Y+1)-coast(Y-1))*.5))**.5)\nfor x,y,rx,ry,h,a in stacks:\n dx,dy=X-x,Y-y\n u=dx*np.cos(a)+dy*np.sin(a)\n v=-dx*np.sin(a)+dy*np.cos(a)\n d=(np.sqrt((u/rx)**2+(v/ry)**2)-1)*min(rx,ry)-2.0\n dst=np.minimum(dst,d)\nwash=field.n(X*.019,Y*.019,23)+.41*field.n(X*.049,Y*.044,24)+.15*field.n(X*.121,Y*.131,25)\nshallow=(1-ease(dst+8*wash,3.4,86.0))*.91\nmottle=field.n(X*.0017,Y*.0019,26)*.08+field.n(X*.013,Y*.008,27)*.028\nseacolor=rgb_mix([.079,.255,.321],[.174,.453,.411],shallow)\nseacolor+=mottle[:,:,None]*np.array([.49,.9,1.21])\nfoam_noise=.53*field.n(X*.205,Y*.179,28)+.33*field.n(X*.51,Y*.51,29)+.14*field.n(X*1.23,Y*1.38,30)\nfilament=.5+.5*np.sin(dst*.65+wash*3.6+.39*np.sin(Y*.145+X*.22))\nsponge=ease(foam_noise+.26*filament,-.033,.605)\nwetfoam=(1-ease(dst+1.9*wash,1.7,9.2))*ease(dst,-1.5,1.8)\nwetfoam*=.22+.78*sponge\nbreaks=ease(wash,.15,.83)*(.5+.5*np.sin(dst*.43+wash*2.99+.39*np.sin(Y*.19)))**13\nbreaks*=ease(dst,4,10)*(1-ease(dst,22,59))\ncrest_noise=.73*field.n(X*.027,Y*.110,31)+.22*field.n(X*.075,Y*.220,32)\ncrest=ease(crest_noise,.52,1.045)*.22*ease(dst,24,96)\nfoam=np.clip(wetfoam+.54*breaks+crest,0,.93)\nseacolor=seacolor*(1-foam[:,:,None])+np.array([.795,.877,.853])*foam[:,:,None]\nsea=material(\"Tidal water | turquoise shallows and white surf\",\"24576A\",.30,.085,.36)\nattach(sea,put(\"CoastalWater_ColorAndSurf\",np.clip(seacolor,.02,.97),\"sRGB\"),\"Base Color\")\nsea_rough=.295+.125*foam+.02*wash\nattach(sea,put(\"CoastalWater_Roughness\",np.repeat(sea_rough[:,:,None],3,axis=2),\"Non-Color\"),\"Roughness\")\n# This normal is sampled using the same world UV as the color atlas.\nsmallwaves=(np.sin(X*.534+Y*.227+5.6*field.n(X*.051,Y*.044,33))*.090+\n np.sin(X*.783-Y*.120+5.27*field.n(X*.065,Y*.054,34))*.059+\n .126*field.n(X*.243,Y*.261,35))\nattach(sea,put(\"CoastalWater_RippleNormal\",norm(smallwaves,1.21,1.37),\"Non-Color\"),\"Normal\",.38)\n\n\ndef geom(name,V,F,m,U=None,ids=None,smooth=True):\n d=bpy.data.meshes.new(name)\n d.from_pydata(V,[],F)\n d.update()\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n for mat0 in m if isinstance(m,list) else [m]:\n d.materials.append(mat0)\n if U is not None:\n layer=d.uv_layers.new(name=\"UVMap\")\n for f,coords in zip(d.polygons,U):\n for l,q in zip(f.loop_indices,coords):\n layer.data[l].uv=q\n for i,f in enumerate(d.polygons):\n f.use_smooth=smooth\n if ids is not None:\n f.material_index=int(ids[i])\n parts.append(o)\n return o\n\n\ndef regular(name,xyz,uv,m,reverse=False):\n rows,cols,_=xyz.shape\n V=xyz.reshape(-1,3).tolist()\n data_uv=uv.reshape(-1,2).tolist()\n F=[]\n UV=[]\n for j in range(rows-1):\n for i in range(cols-1):\n a=j*cols+i\n f=(a,a+1,a+1+cols,a+cols)\n if reverse:\n f=f[::-1]\n F.append(f)\n UV.append([data_uv[i] for i in f])\n return geom(name,V,F,m,UV)\n\n\ndef top_height(X,Y):\n # Ridge inland of the headland, drained gullies and rolling wind-cut grass.\n broad=(25.7*np.exp(-((X+320+.13*(Y-80))/220)**2-((Y-174)/840)**2)+\n 31.4*np.exp(-((X+560)/381)**2-((Y-390)/603)**2)+\n 22.3*np.exp(-((X+440)/213)**2-((Y+391)/251)**2))\n rug=7.7*field.n(X*.0094,Y*.0081,36)+4.4*field.n(X*.021,Y*.019,37)+1.6*field.n(X*.049,Y*.049,38)\n fine=.63*field.n(X*.112,Y*.101,39)+.28*field.n(X*.282,Y*.221,40)\n groove=.9+np.sin((Y+22)*.030+.81*np.sin(X*.009))\n cut=7.4*ease(groove,1.43,1.92)*np.exp(-((X+211)/432)**2)\n return 70+broad+rug+fine-cut\n\n# Inland ground tessellation concentrates at the rim and keeps the far corners light.\nY=np.unique(np.concatenate((np.linspace(ymin,ymax,482),np.linspace(-315,430,176))))\nn=len(Y)\ns=np.linspace(0,1,177)\nC=coast(Y)\nH=cliff_height(Y)\nxx=C[:,None]-(C[:,None]-xmin)*(s[None,:]**1.77)\nyy=np.broadcast_to(Y[:,None],xx.shape)\ndistance=C[:,None]-xx\nbase=top_height(xx,yy)\nmix=ease(distance,2.2,72.0)\nzz=H[:,None]*(1-mix)+base*mix\nzz+=(.50*field.n(xx*.12,yy*.14,41)+.22*field.n(xx*.43,yy*.48,42))*ease(distance,.5,10)\nregular(\"Maritime grass upland and rolling inland ridges\",np.stack((xx,yy,zz),axis=-1),\n np.stack((xx/246+2.2,yy/279+4.2),axis=-1),grass,reverse=True)\n\n# Coastal rock wall. Layering follows the rim, with sea caves suggested by undercut relief.\nrow=np.linspace(0,1,90)[None,:]\nY0=Y[:,None]\nYb=np.broadcast_to(Y0,(n,row.shape[1]))\nsea_bottom=-4.06\nzz=sea_bottom+(H[:,None]-sea_bottom)*row\ncoast_edge=C[:,None]\nbeach=(1-row)**2.42*(10.2+3.3*field.n(Y0*.029,0,43))\nquant=np.sin((zz+3.2*np.sin(Y0*.011)+1.08*np.sin(Y0*.029)+2.19*field.n(Y0*.018,zz*.012,53))*.342)\nshelf=(.5+.5*quant)**6.5\nstep=(2.48*shelf-.64*(1-shelf)**5)*np.sin(math.pi*row)**.52*(.88+.43*field.n(Y0*.044,zz*.053,54))\ncolumns=(np.sin(Yb*.632+.93*field.n(Yb*.053,zz*.024,45))+\n .53*np.sin(Yb*1.196+1.17*field.n(Yb*.084,zz*.018,46)))\ncolumns*=1.02*np.sin(math.pi*row)**.62\nfault=3.61*field.n(Yb*.047,zz*.074,47)+1.76*field.n(Yb*.15,zz*.138,48)+.88*field.n(Yb*.42,zz*.448,49)\nfault*=np.sin(math.pi*row)**.72\ncave=9.21*np.exp(-((Yb+144)/14.1)**2-((zz-8.6)/6.4)**2)+6.8*np.exp(-((Yb-161.1)/11.2)**2-((zz-5.8)/6.3)**2)\nledge=(3.94*np.exp(-((Yb-82.0)/45.2)**2-((row-.39)/.064)**2)+\n 4.10*np.exp(-((Yb-235)/37.7)**2-((row-.54)/.062)**2)+\n 2.8*np.exp(-((Yb+103)/38)**2-((row-.252)/.071)**2))\nxx=coast_edge+beach+step+columns+fault+ledge-cave\nuv=np.stack((Yb/96.5+10.6,zz/78.8+.094),axis=-1)\nregular(\"Stacked fractured basalt cliff and intertidal ledges\",np.stack((xx,Yb,zz),axis=-1),uv,basalt,reverse=True)\n\n# Exposed shoal strips at the bottom of the wall. Their ridges are carved\n# into the terrain and read as uneven beds through breaks in the surf.\nts=np.linspace(0,1,49)[None,:]\nys=np.linspace(ymin,ymax,571)[:,None]\nband=np.broadcast_to(ys,(len(ys),49))\nshore=shore_x(ys)\nwidth=11.7+5.1*np.sin(ys*.023)+4.8*field.n(ys*.026,0,58)\nedge=shore-6.4+width*ts\ncoarse=field.n(edge*.094,band*.088,59)\ndetail=field.n(edge*.39,band*.41,60)\nridge=(.5+.5*np.cos(edge*.49+band*.19+.62*coarse))**6\nzl=(1-ts)*(.64+1.14*coarse)-ts*(1.85+.71*detail)+.72*ridge+.61*detail\nrough_uv=np.stack((band/96.5+.14,edge/78.8+.17),axis=-1)\nregular(\"Eroded intertidal basalt platforms\",np.stack((edge,band,zl),axis=-1),rough_uv,boulder)\n\n# Offshore stacks have tapered, grooved sides and irregular closed, turfed tops.\ndef stack_top(index,rad,a,r,h,x,y,rx,ry,rot):\n c,s=np.cos(a),np.sin(a)\n wob=1+.096*np.sin(a*3.0+index*1.5)+.082*np.cos(a*5.0-.49*index)+.025*np.sin(a*13+.54*index)\n ex,ey=rx*rad*c*wob,ry*rad*s*wob\n X=x+ex*math.cos(rot)-ey*math.sin(rot)+2.05*min(h/45,1)*rad\n Y=y+ex*math.sin(rot)+ey*math.cos(rot)+.65*rad\n Z=h+(3.78*np.cos(a+.92+index*.8)+1.91*np.cos(a*2+.28)+1.13*np.sin(a*3.1))*rad*min(h/30,1)+r\n return X,Y,Z\n\n\nfor j,(x,y,rx,ry,h,rot) in enumerate(stacks):\n n,m=140,73\n V0,F,UV=[],[],[]\n t0=np.linspace(0,1,m)\n for iy,t in enumerate(t0):\n for i in range(n):\n a=tau*i/n\n front=1.08-.28*t-.13*t**3\n foot=.07*np.exp(-((t-.14)/.08)**2)\n lateral=(.041*np.sin(a*25+.37*np.sin(t*11))+.027*np.cos(a*39+.48*math.sin(t*5.4))) * math.sin(math.pi*t)**.56\n erosion=.057*np.sin(a*12+t*4.3)+.033*np.sin(a*7-t*8)\n erosion*=math.sin(math.pi*t)**.65\n strat=.048*(.5+.5*np.cos(tau*(t*5.1+.046*np.sin(a*2))))**5*math.sin(math.pi*t)**.64\n ex,ey,zt=stack_top(j,front+lateral+erosion+strat+foot,a,0,h,x,y,rx,ry,rot)\n zg=-4.3+(zt+4.3)*t+(.50*np.sin(a*8+t*13)) * math.sin(math.pi*t)\n V0.append((ex,ey,zg))\n for iy in range(m-1):\n for i in range(n):\n b=(i+1)%n\n f=(iy*n+i,iy*n+b,(iy+1)*n+b,(iy+1)*n+i)\n F.append(f)\n UV.append([(i/n*1.93, V0[f[0]][2]/78.8),((i+1)/n*1.93,V0[f[1]][2]/78.8),\n ((i+1)/n*1.93,V0[f[2]][2]/78.8),(i/n*1.93,V0[f[3]][2]/78.8)])\n geom(\"Offshore basalt sea stack \"+str(j+1),V0,F,basalt,UV)\n V,F,UV=[],[],[]\n rings=21\n for iy in range(rings+1):\n v=iy/rings\n rad=.00011+.66989*v\n for i in range(n):\n a=tau*i/n\n top=stack_top(j,rad,a,max(h*.034,1.1)*(1-v*v),h,x,y,rx,ry,rot)\n V.append(top)\n for iy in range(rings):\n for i in range(n):\n b=(i+1)%n\n f=(iy*n+i,iy*n+b,(iy+1)*n+b,(iy+1)*n+i)[::-1]\n F.append(f)\n UV.append([(V[k][0]/102.5+.16,V[k][1]/106.5+.12) for k in f])\n geom(\"Weathered green cap on stack \"+str(j+1),V,F,grass if j<2 else basalt,UV)\n\n# Angular talus at outcrops and wave-polished blocks on the tidal shelf.\nrpos=[]\nfor i in range(920):\n y=seed.uniform(-847,1060)\n x=float(shore_x(y))+seed.uniform(-10,17)\n b=seed.uniform(.23,1.0)**3*2.95+.45\n p=seed.uniform(.48,1.18)\n rpos.append((x,y,seed.uniform(-1.48,.89),b,seed.uniform(.64,1.26),p,seed.uniform(0,tau)))\nfor i in range(155):\n j=int(seed.integers(5))\n x,y,rx,ry,h,rot=stacks[j]\n a=seed.uniform(0,tau)\n k=seed.uniform(.94,1.59)\n px,py=x+rx*k*math.cos(a),y+ry*k*math.sin(a)\n rpos.append((px,py,seed.uniform(-1.2,1.10),seed.uniform(.52,3.25),.63,.83,seed.uniform(0,tau)))\nfor i in range(105):\n y=seed.uniform(-380,640)\n x=float(coast(y))-seed.uniform(1.4,40)\n z=float(cliff_height(y))-.68\n rpos.append((x,y,z,seed.uniform(.34,1.85),.80,.56,seed.uniform(0,tau)))\nV,F,UV=[],[],[]\nfor x,y,z,r,q,w,a in rpos:\n index=len(V)\n n=7 if r<1 else 9\n for hz,scale in [(-.49,.66),(-.22,1.0),(.29,.917),(.57,.48)]:\n for i in range(n):\n t=tau*i/n\n rad=seed.uniform(.75,1.19)*r*scale\n u,v=rad*math.cos(t),q*rad*math.sin(t)\n V.append((x+u*math.cos(a)-v*math.sin(a),y+u*math.sin(a)+v*math.cos(a),z+r*w*(hz+seed.uniform(-.11,.10))))\n for j in range(3):\n for i in range(n):\n k=(i+1)%n\n f=(index+j*n+i,index+j*n+k,index+(j+1)*n+k,index+(j+1)*n+i)\n F.append(f)\n UV.append([(V[k][0]*.11+.21*V[k][2],V[k][1]*.11-.27*V[k][2]) for k in f])\n f=tuple(index+3*n+i for i in range(n))\n F.append(f)\n UV.append([(V[k][0]*.12,V[k][1]*.12) for k in f])\ngeom(\"Wave-polished boulder field and rounded cliff debris\",V,F,boulder,UV,smooth=False)\n\n# Water elevation uses continuous directional swells and scatter at the sea stacks.\ns=np.linspace(-1,1,259)\ntx=np.sort(np.unique(np.concatenate((np.clip(240*s+1380*s**3+3,wxlo,wxhi), np.linspace(-95,480,131),\n [wxlo,wxhi]))))\nty=np.sort(np.unique(np.concatenate((266*s+1420*s**3+102, np.linspace(-345,680,158),\n [wylo,wyhi]))))\nX,Y=np.meshgrid(tx,ty)\nu=(X-wxlo)/(wxhi-wxlo)\nv=(Y-wylo)/(wyhi-wylo)\nphase=X*.152+Y*.032+field.n(X*.009,Y*.015,50)*2.3\nphase2=X*.071-Y*.107+field.n(X*.012,Y*.012,51)*2.2\nphase+=5.42*field.n(X*.021,Y*.024,55)\nphase2+=5.25*field.n(X*.022,Y*.028,56)\namp=.62+.51*field.n(X*.017,Y*.017,57)\nz=amp*(.205*np.sin(phase)+.154*np.sin(phase2)+.075*np.sin(phase*2.71+.57*phase2))\nz+=.124*field.n(X*.084,Y*.087,52)\nregular(\"Continuous coastal water mesh with visible shallow surf\",np.stack((X,Y,z),axis=-1),\n np.stack((u,v),axis=-1),sea)\n\nroot=bpy.data.objects.new(\"Bracken Head coastal landscape\",None)\nbpy.context.collection.objects.link(root)\nroot[\"asset_id\"]=\"landscape-bracken-head-basalt-coast-v1\"\nroot[\"category\"]=\"landscape\"\nroot[\"fictional_location\"]=True\nroot[\"units\"]=\"meters in glTF\"\nfor ob in parts:\n ob.parent=root\nif not args.draft and not args.preview_only:\n bpy.ops.object.select_all(action=\"DESELECT\")\n root.select_set(True)\n for ob in parts:\n ob.select_set(True)\n bpy.ops.export_scene.gltf(filepath=str(out/(stem+\".glb\")),export_format=\"GLB\",use_selection=True,\n export_apply=True,export_extras=True,export_yup=True)\n\n# Environmental photograph. Lighting and camera are separate from the GLB.\ndef aim(ob,at):\n ob.rotation_euler=(Vector(at)-ob.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef sun(name,position,target,energy,color,angle):\n d=bpy.data.lights.new(name,\"SUN\")\n d.energy=energy\n d.angle=angle\n d.color=color\n ob=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(ob)\n ob.location=position\n aim(ob,target)\n\n\nsun(\"Warm late-afternoon directional sun\",(590,-330,355),(0,55,0),2.57,(1,.916,.797),.061)\nsun(\"Broad blue sky fill\",(-45,249,337),(0,0,12),.50,(.744,.865,1),.67)\nscene=bpy.context.scene\nscene.world.use_nodes=True\nworld=scene.world.node_tree\nb=world.nodes[\"Background\"]\nb.inputs[\"Color\"].default_value=(.270,.414,.557,1)\nb.inputs[\"Strength\"].default_value=.54\n\nd=bpy.data.cameras.new(\"Aerial coastal landscape camera\")\ncamera=bpy.data.objects.new(d.name,d)\nbpy.context.collection.objects.link(camera)\ncamera.location=(451,-565,377)\naim(camera,(73,63,35))\nd.lens=58\nd.clip_end=17000\nscene.camera=camera\nscene.render.engine=\"CYCLES\"\nscene.cycles.samples=16 if args.draft else 96\nscene.cycles.use_denoising=False\nscene.cycles.adaptive_threshold=.081 if args.draft else .026\nscene.cycles.max_bounces=6\nscene.view_settings.view_transform=\"AgX\"\nscene.view_settings.look=\"AgX - Medium High Contrast\"\nscene.view_settings.exposure=.14\nscene.render.resolution_x=1900\nscene.render.resolution_y=1430\nscene.render.resolution_percentage=45 if args.draft else 100\nscene.render.image_settings.file_format=\"PNG\"\nscene.render.image_settings.color_mode=\"RGB\"\nscene.render.filepath=str(out/(\"draft.png\" if args.draft else stem+\".png\"))\nbpy.ops.render.render(write_still=True)\n```\n\nrun it: `blender -b --python bracken.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T0400Z-landscape-bracken-head-basalt-coast.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/bracken-head-basalt-coast/3d-dataset-20261127T0400Z-landscape-bracken-head-basalt-coast.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/greywake-point-lighthouse.jpg"}}, {"type": "text", "text": "create an image of a greywake point lighthouse"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA coastal lighthouse, front three-quarter view. Tall tapered round tower of pale limewashed stone blocks on a tiered granite base, an arched red plank door with stone steps and a small black plaque above it, three arched windows with red frames climbing the tower, a corbelled ledge holding a dark iron gallery with a round railing, a glazed lantern room with a glowing lamp inside, and a green oxidized copper dome topped with a gold finial.\n\nSCALE\nAbout 5.1 m wide, 15.3 m tall, 5.7 m deep. Build in meters, +Y up, +Z forward, origin at the center of the tower foundation at grade.\n\nPARTS\n1. Base: tiered granite foundation and plinth. Build: lathe a stepped profile.\n2. Tower: tapered limewashed masonry shaft with real arched openings cut through it. Build: lathe a tapering profile, then cut openings.\n3. Doorway: arched stone jambs, voussoirs and keystone, recessed oxblood plank door with battens, hinges and a brass handle, granite step, black station plaque reading \"LIGHT STATION 1894\". Build: arch trim blocks, boxes for the boards, label for the plaque.\n4. Windows: arched openings with ashlar surrounds, stone sills, dark reveals, gray-green glazing, oxblood mullions and crossbars. Build: one window routine placed at three heights around the tower.\n5. Gallery: two-stage corbel band under a cantilevered iron platform, cast uprights on foot plates, continuous circular safety rail. Build: arc panels for the corbels, tubes for the railing.\n6. Lantern and roof: polygonal glazed lantern room with posts, glazing bars, cross braces and a warm lamp with pale prisms, then an oxidized copper dome with standing seams, iron eaves and a cast finial. Build: polygon frame, thin glass panes, lathe for the dome, ribs for the seams.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the tower base center.\n2. Texture maps: run make_maps.py first for the tower masonry, granite and copper patina maps.\n3. Build order: base, tower, doorway, windows, gallery, lantern, roof.\n4. Assemble: tower sits on the base, openings are cut into the tower wall before trim goes in, gallery sits on the corbels at the tower top, lantern stands inside the railing, dome caps the lantern.\n5. Materials: limewashed masonry, salt-worn granite, lighter ashlar trim, oxblood joinery, dark recesses, painted iron, brass plaque and finial, gray-green glazing, clear lantern glass, warm lamp, pale lime prisms, green-black copper.\n6. Export: lighthouse only, no studio, one GLB with the textures embedded.\n\nCHECK\n108,992 triangles across 83 parts. Against the image: tower about three times as tall as it is wide, gallery overhangs the tower top, windows step up the tower, finial points straight up.\n\n\n```python\n# make_maps.py\n\"\"\"Generate original weathered masonry, copper, and granite PBR maps.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import zoom, gaussian_filter\n\nDEST=Path(__file__).resolve().parent/\"maps\"\nDEST.mkdir(exist_ok=True)\nW,H=1536,1024\nRNG=np.random.default_rng(103786)\nv,u=np.mgrid[1:0:complex(H),0:1:complex(W)]\n\n\ndef noise(y,x):\n values=RNG.uniform(-1,1,(y,x))\n values[:,-1]=values[:,0]\n return zoom(values,((H+.01)/y,(W+.01)/x),order=3,mode=\"wrap\")[:H,:W]\n\n\ndef save(name,d):\n Image.fromarray(np.clip(d*255+.5,0,255).astype(\"uint8\")).save(DEST/(name+\".png\"))\n\n\ndef maps(name,c,r,h,gain):\n save(name+\"_Base\",c)\n save(name+\"_Rough\",r)\n dy,dx=np.gradient(h)\n normals=np.dstack((-dx*gain,dy*gain,np.ones_like(dx)))\n save(name+\"_Normal\",.5+.5*normals/np.linalg.norm(normals,axis=-1,keepdims=True))\n\n\nlow,cloud,medium,grain,fine=(noise(9,41),noise(32,72),noise(112,195),noise(249,348),noise(601,817))\ncourse=v*35 + .039*medium + .023*np.sin(u*93+v*22)\nrow=np.floor(course).astype(int)\nalong=62*u + (row%2)*.5 + .127*np.sin(row*13.12)+.035*medium\ndx=np.minimum(along%1,1-along%1)\ndy=np.minimum(course%1,1-course%1)\nmortar=np.maximum(np.clip((.034-dx)/.025,0,1),np.clip((.043-dy)/.030,0,1))\nblock_id=np.floor(along)\nblock=(np.sin(block_id*17.043+row*65.011)+.39*np.sin(block_id*48.203-row*10.33))*.026\nsalt=np.maximum(0,.44*low+.38*cloud+.18*medium-.14)**1.4\nrun=np.maximum(0,.66*noise(12,240)+.21*cloud+.12*grain-.32)**.81\nchips=np.maximum(0,.64*grain+.31*fine+.12*medium-.43)\nd=.044*low+.051*cloud+.027*medium+.039*grain+.021*fine+block-.125*run-.099*chips\ncolor=np.array([.729,.703,.623])+d[...,None]*np.array([.95,1.,1.08])\ncolor+=salt[...,None]*np.array([.095,.105,.13])\ncolor-=((1-v)**8*(.15+.085*cloud))[...,None]*np.array([.43,.37,.65])\ng=np.array([.449,.419,.361])+(.035*medium+.036*grain)[...,None]\ncolor=color*(1-mortar[...,None]*.79)+g*(mortar[...,None]*.79)\nmaps(\"Tower\",color,.717+.077*cloud+.043*grain+.065*mortar,\n .21*medium+.34*grain+.14*fine+.65*block-.99*mortar-.45*chips,1.38)\n\nbroad,cloud,middle,grain,fine=(noise(14,22),noise(46,71),noise(93,248),noise(284,410),noise(720,810))\nmineral=np.sin(u*63+v*15+.8*cloud)*.014\npoints=np.maximum(0,.59*grain+.42*fine-.30)**1.4\nvariation=.074*broad+.064*cloud+.043*middle+.053*grain+.032*fine+mineral\ngranite=np.array([.413,.408,.361])+variation[...,None]*np.array([.91,.94,.86])\ngranite+=points[...,None]*np.array([.13,.12,.099])\nmaps(\"Granite\",granite,.757+.095*cloud+.062*grain,.36*middle+.35*grain+.18*fine,1.21)\n\nbroad,mid,grain,fine=(noise(20,26),noise(48,67),noise(347,414),noise(601,713))\noxide=np.clip(.56+.28*broad+.26*mid+.12*grain,0,1)\nrun=np.maximum(0,.68*noise(17,192)+.27*mid-.17)\nd=.033*mid+.019*grain+.019*fine-.046*run\ncopper=np.array([.246,.277,.235])+(oxide[...,None]-.4)*np.array([-.077,.182,.136])\ncopper+=d[...,None]*np.array([1.,1.,.9])\nmaps(\"Copper\",copper,.474+.15*oxide+.10*mid+.074*grain,\n .38*mid+.21*grain+.11*fine-.46*run,1.21)\n```\n\n```python\n# lighthouse.py\n\"\"\"Greywake Point, an original coastal lighthouse in weathered masonry.\"\"\"\nimport argparse\nimport json\nimport math\nfrom pathlib import Path\nimport sys\nimport random\n\nimport bmesh\nimport bmesh\nimport bpy\nfrom mathutils import Vector\n\nDIR = Path(__file__).resolve().parent\nSTEM = \"3d-dataset-20261127T1600Z-buildings-greywake-point-lighthouse\"\nTAU = math.tau\ndef material(name, color, roughness, maps=None, bump=.6, metallic=0., transmission=0., ior=1.45):\n m = bpy.data.materials.new(name)\n m.diffuse_color = (*color, 1)\n m.use_nodes = True\n tree = m.node_tree\n p = tree.nodes.get(\"Principled BSDF\")\n p.inputs[\"Base Color\"].default_value = (*color, 1)\n p.inputs[\"Roughness\"].default_value = roughness\n p.inputs[\"Metallic\"].default_value = metallic\n p.inputs[\"IOR\"].default_value = ior\n p.inputs[\"Transmission Weight\"].default_value = transmission\n if maps:\n for index, (tag, colorspace) in enumerate(\n ((\"Base\", \"sRGB\"), (\"Rough\", \"Non-Color\"), (\"Normal\", \"Non-Color\"))\n ):\n path = DIR/\"maps\"/f\"{maps}_{tag}.png\"\n if not path.exists():\n continue\n tex = tree.nodes.new(\"ShaderNodeTexImage\")\n tex.image = bpy.data.images.load(str(path),check_existing=True)\n tex.image.colorspace_settings.name = colorspace\n tex.location = (-620,250-index*220)\n if tag == \"Base\":\n tree.links.new(tex.outputs[\"Color\"],p.inputs[\"Base Color\"])\n elif tag == \"Rough\":\n packed = tree.nodes.new(\"ShaderNodeSeparateColor\")\n packed.location = (-310,30)\n tree.links.new(tex.outputs[\"Color\"],packed.inputs[\"Color\"])\n tree.links.new(packed.outputs[\"Green\"],p.inputs[\"Roughness\"])\n else:\n normal = tree.nodes.new(\"ShaderNodeNormalMap\")\n normal.location = (-300,-215)\n normal.inputs[\"Strength\"].default_value = bump\n tree.links.new(tex.outputs[\"Color\"],normal.inputs[\"Color\"])\n tree.links.new(normal.outputs[\"Normal\"],p.inputs[\"Normal\"])\n return m\n\n\ndef mesh(name, vertices, faces, materials, assignments, uv_coords, smooth):\n data = bpy.data.meshes.new(name)\n data.from_pydata(vertices, [], faces)\n data.update()\n uv = data.uv_layers.new(name=\"Surface maps\")\n for item in materials:\n data.materials.append(item)\n for f in data.polygons:\n f.use_smooth = smooth[f.index] if isinstance(smooth,list) else smooth\n f.material_index = assignments[f.index]\n for loop, coord in zip(f.loop_indices, uv_coords[f.index]):\n uv.data[loop].uv = coord\n obj = bpy.data.objects.new(name,data)\n bpy.context.collection.objects.link(obj)\n return obj\n\n\n\n\n\nRNG=random.Random(27119)\n\ndef catmull(keys,steps=14):\n interp=[]\n for i in range(len(keys)-1):\n a,b,c,d=[keys[max(0,min(len(keys)-1,j))] for j in (i-1,i,i+1,i+2)]\n for j in range(steps):\n t=j/steps\n interp.append(tuple(.5*(2*q+(-p+r)*t+(2*p-5*q+4*r-s)*t*t+\n (-p+3*q-3*r+s)*t*t*t) for p,q,r,s in zip(a,b,c,d)))\n return interp+[keys[-1]]\n\n\ndef profile_mesh(name,rings,mats,n=32,slot_for=None, planar_uv=None,ends=True):\n coords=[v for row in rings for v in row]\n faces,uv,slots,smooth=[],[],[],[]\n for i in range(len(rings)-1):\n for j in range(n):\n k=(j+1)%n\n f=(i*n+j,i*n+k,(i+1)*n+k,(i+1)*n+j)\n faces.append(f)\n uv.append(tuple(planar_uv(coords[v]) for v in f) if planar_uv else\n ((j/n,i/(len(rings)-1)),((j+1)/n,i/(len(rings)-1)),\n ((j+1)/n,(i+1)/(len(rings)-1)),(j/n,(i+1)/(len(rings)-1))))\n slots.append(slot_for(i/(len(rings)-1),j/n) if slot_for else 0)\n smooth.append(True)\n if ends:\n for index,order in ((0,range(n-1,-1,-1)),(len(rings)-1,range(n))):\n face=tuple(index*n+j for j in order)\n faces.append(face)\n uv.append(tuple(planar_uv(coords[v]) for v in face) if planar_uv else tuple(\n (.5+.31*math.cos(TAU*i/n),.5+.31*math.sin(TAU*i/n)) for i in order))\n slots.append(slot_for(index/(len(rings)-1),0) if slot_for else 0)\n smooth.append(False)\n return mesh(name,coords,faces,mats,slots,uv,smooth)\n\n\ndef tube(name,knots,mats,n=22,steps=11,slot_for=None):\n path=catmull(knots,steps)\n rings=[]\n for i,(x,y,z,w,h) in enumerate(path):\n before=Vector(path[max(0,i-1)][:3])\n after=Vector(path[min(len(path)-1,i+1)][:3])\n tang=(after-before).normalized()\n up=Vector((0,0,1)) if abs(tang.z)<.92 else Vector((0,1,0))\n p=tang.cross(up).normalized()\n q=tang.cross(p).normalized()\n rings.append([Vector((x,y,z))+p*w*math.cos(TAU*j/n)+q*h*math.sin(TAU*j/n)\n for j in range(n)])\n return profile_mesh(name,rings,mats,n,slot_for)\n\n\ndef ellipsoid(name,p,scale,mat,n=64,levels=29):\n xyz=Vector(p)\n rings=[]\n for i in range(levels):\n a=math.pi*(.003+.994*i/(levels-1))\n rings.append([xyz+Vector((scale[0]*math.sin(a)*math.cos(TAU*j/n),\n scale[1]*math.sin(a)*math.sin(TAU*j/n),\n -scale[2]*math.cos(a))) for j in range(n)])\n return profile_mesh(name,rings,[mat],n)\n\n\n\n\ndef lathe(name,profile,mats,n=144,slot=None):\n rings=[[Vector((r*math.cos(TAU*i/n),r*math.sin(TAU*i/n),z)) for i in range(n)] for r,z in profile]\n return profile_mesh(name,rings,mats,n,slot_for=slot)\n\n\ndef box(name,loc,dim,m,bevel=.027,yaw=0):\n bpy.ops.mesh.primitive_cube_add(size=1,location=loc)\n o=bpy.context.object\n o.name=o.data.name=name\n o.dimensions=dim\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n o.rotation_euler.z=yaw\n o.data.materials.append(m)\n d=o.data\n uv=d.uv_layers.active.data\n for p in d.polygons:\n for i in p.loop_indices:\n x,y,z=d.vertices[d.loops[i].vertex_index].co\n if abs(p.normal.x)>.5:\n uv[i].uv=(.5+y/max(dim),.5+z/max(dim))\n elif abs(p.normal.y)>.5:\n uv[i].uv=(.5+x/max(dim),.5+z/max(dim))\n else:\n uv[i].uv=(.5+x/max(dim),.5+y/max(dim))\n b=o.modifiers.new(\"Light-catching bevel\",\"BEVEL\")\n b.width=min(bevel,min(dim)*.38)\n b.segments=3\n normal=o.modifiers.new(\"Weighted surface normals\",\"WEIGHTED_NORMAL\")\n normal.keep_sharp=True\n return o\n\n\ndef world(a,x,d,z):\n return (x*math.cos(a)+d*math.sin(a),x*math.sin(a)-d*math.cos(a),z)\n\n\ndef arc_panel(name,a,width,bottom,arc_base,back,front,mat):\n half=width/2\n section=[(-half,bottom),(half,bottom)]\n for i in range(29):\n p=math.pi*i/28\n section.append((half*math.cos(p),arc_base+half*math.sin(p)))\n n=len(section)\n vertices=[world(a,x,d,z) for d in (back,front) for x,z in section]\n faces=[tuple(range(n-1,-1,-1)),tuple(range(n,2*n))]\n faces.extend((i,(i+1)%n,n+(i+1)%n,n+i) for i in range(n))\n uv=[tuple((.5+section[j%n][0]/(width*1.04),(section[j%n][1]-bottom)/(arc_base+half-bottom))\n for j in f) for f in faces]\n return mesh(name,vertices,faces,[mat],[0]*len(faces),uv,False)\n\n\ndef cut_opening(tower,cutter):\n bpy.context.view_layer.objects.active=tower\n b=tower.modifiers.new(\"Real opening in the masonry\",\"BOOLEAN\")\n b.operation=\"DIFFERENCE\"\n b.solver=\"EXACT\"\n b.object=cutter\n bpy.ops.object.modifier_apply(modifier=b.name)\n bpy.data.objects.remove(cutter,do_unlink=True)\n\n\ndef downpipe(name,points,r,mat):\n pipe=bpy.data.curves.new(name,\"CURVE\")\n pipe.dimensions=\"3D\"\n pipe.bevel_depth=r\n pipe.bevel_resolution=3\n pipe.resolution_u=2\n pipe.use_fill_caps=True\n s=pipe.splines.new(\"POLY\")\n s.points.add(len(points)-1)\n for p,xyz in zip(s.points,points):\n p.co=(*xyz,1)\n o=bpy.data.objects.new(name,pipe)\n bpy.context.collection.objects.link(o)\n o.data.materials.append(mat)\n return o\n\n\ndef trim_arch(a,r,bottom,arch,w,stone,m,sill=True):\n half=w/2\n for side in (-1,1):\n height=arch-bottom\n for k in range(5):\n z=bottom+(k+.5)*height/5\n d=r -.038*(z-bottom)+.066\n box(\"Individual ashlar jamb block\",world(a,side*(half+.078),d,z),\n (.165,.212,height/5-.011),stone,.014,a)\n for k in range(11):\n t0=math.pi*k/11+.014\n t1=math.pi*(k+1)/11-.014\n inner=half+.003\n ext=half+(.191 if k==5 else .155)\n verts=[]\n for d in (r-.045,r+.171):\n for t,rr in ((t0,inner),(t0,ext),(t1,ext),(t1,inner)):\n verts.append(world(a,rr*math.cos(t),d,arch+rr*math.sin(t)))\n faces=[(0,3,2,1),(4,5,6,7),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7)]\n uv=[((0,0),(1,0),(1,1),(0,1))]*6\n mesh(\"Modeled arch voussoir\" if k!=5 else \"Proud central keystone\",\n verts,faces,[stone if k%2 else m],[0]*6,uv,False)\n if sill:\n box(\"Outward weathered stone sill\",world(a,0,r+.089,bottom-.057),\n (w+.334,.335,.137),stone,.027,a)\n\n\ndef doorway(tower,masonry,stone,red,deep,brass,glass,iron):\n a=0\n r=2.19\n base=.54\n spring=2.14\n w=1.05\n cut_opening(tower,arc_panel(\"Door masonry cutter\",a,w,base,spring,1.50,2.58,stone))\n arc_panel(\"Recessed oxblood-painted entrance door\",a,w-.064,base+.042,spring,2.041,2.111,red)\n trim_arch(a,r,base,spring,w,stone,masonry,False)\n for x in (-.38,-.19,0,.19,.38):\n z1=spring+math.sqrt((w*.46)**2-x*x)-.085\n box(\"Recess joint between vertical door boards\",world(a,x,2.114,(.63+z1)/2),(.010,.013,z1-.63),deep,.003,a)\n for z in (1.02,1.97):\n box(\"Aged painted timber door batten\",world(a,0,2.128,z),(.92,.042,.093),red,.010,a)\n for x in (-.39,.39):\n box(\"Blackened hinge strap\",world(a,x,2.148,z),(.15,.023,.050),iron,.004,a)\n box(\"Brass door knob backplate\",world(a,.309,2.151,1.43),(.101,.029,.165),brass,.014)\n bpy.ops.mesh.primitive_uv_sphere_add(segments=32,ring_count=16,radius=.038,location=world(a,.309,2.188,1.451))\n o=bpy.context.object\n o.name=\"Round antique brass door handle\"\n o.scale.y=.69\n o.data.materials.append(brass)\n for f in o.data.polygons:\n f.use_smooth=True\n for i in range(3):\n dep=2.30+.18*i\n box(\"Granite entrance step\",world(a,0,dep,.435-.129*i),\n (1.49+.107*i,.62+.122*i,.143),stone,.036)\n box(\"Black enamel station plaque\",world(a,0,2.203,3.02),(.96,.064,.37),iron,.025)\n label(\"Greywake Station plaque text\",\"GREYWAKE\",world(a,0,2.240,3.067),.108,brass)\n label(\"Greywake Station founding year\",\"LIGHT STATION • 1894\",world(a,0,2.243,2.960),.063,brass)\n\n\ndef label(name,value,where,size,mat):\n data=bpy.data.curves.new(name,\"FONT\")\n data.body=value\n data.size=size\n data.align_x=data.align_y=\"CENTER\"\n data.extrude=.00055\n data.resolution_u=4\n o=bpy.data.objects.new(name,data)\n bpy.context.collection.objects.link(o)\n o.location=where\n o.rotation_euler.x=math.pi/2\n o.data.materials.append(mat)\n\n\ndef windows(tower,stone,trim,deep,red,glass,iron):\n for angle,base,r in ((.74,4.05,2.02),(-.43,6.74,1.91),(.64,8.99,1.80),(-2.7,5.66,1.95)):\n w=.59\n spring=base+.94\n cut_opening(tower,arc_panel(\"Window masonry cutter\",angle,w,base,spring,r-.51,r+.55,stone))\n arc_panel(\"Dark recessed window reveal\",angle,w,base+.012,spring,r-.216,r-.203,deep)\n arc_panel(\"Inset grey-green window glazing\",angle,w-.057,base+.028,spring-.006,r-.127,r-.112,glass)\n trim_arch(angle,r,base,spring,w,stone,trim,True)\n for x in (-.265,0,.265):\n zmax=spring+(.265 if x==0 else .092)\n box(\"Oxblood-painted window mullion\",world(angle,x,r-.061,(base+zmax)/2),\n (.042,.047,zmax-base),red,.006,angle)\n for z in (base+.049,base+.428,spring+.003):\n box(\"Oxblood-painted window crossbar\",world(angle,0,r-.056,z),(.550,.042,.039),red,.007,angle)\n\n\ndef roof(iron,copper,dark,brass):\n footprint=[\n (2.094,12.950),(2.115,13.045),(2.040,13.133),(1.915,13.198),(1.742,13.273),\n (1.565,13.400),(1.39,13.532),(1.21,13.662),(.99,13.802),(.786,13.913),\n (.572,14.028),(.393,14.126),(.238,14.213),(.174,14.259)]\n lathe(\"Oxidized copper lantern dome\",footprint,[copper],n=216)\n lathe(\"Turned dark iron eaves and flashing\",[(2.115,12.931),(2.136,12.971),\n (2.137,13.050),(2.113,13.110),(2.044,13.144)], [iron],n=192)\n for i in range(18):\n a=TAU*i/18\n downpipe(\"Raised standing seam on the copper dome\",[(r*math.cos(a),r*math.sin(a),z+.012)\n for r,z in footprint[2:]],.024, dark)\n lathe(\"Finial socket at the roof crown\",[(.192,14.155),(.23,14.183),(.231,14.229),\n (.207,14.274),(.151,14.294),(.136,14.341)], [iron],n=96)\n lathe(\"Sculpted lightning finial\",[(.088,14.29),(.103,14.39),(.093,14.49),\n (.066,14.58),(.056,14.72),(.035,14.95),(.016,15.17),(.007,15.30)], [brass],n=96)\n bpy.ops.mesh.primitive_uv_sphere_add(segments=32,ring_count=16,radius=.119,location=(0,0,14.477))\n o=bpy.context.object\n o.name=\"Cast finial sphere\"\n o.scale.z=.88\n o.data.materials.append(copper)\n for f in o.data.polygons:\n f.use_smooth=True\n\n\ndef gallery(iron,dark,stone,brass,slip):\n lathe(\"Two-stage masonry corbel below gallery\",[(1.667,10.178),(1.707,10.27),(1.838,10.324),\n (1.869,10.420),(1.897,10.519),(2.219,10.597),(2.229,10.682),\n (2.398,10.729),(2.448,10.866),(2.448,10.992),(2.393,11.013)], [stone,dark],\n slot=lambda t,u: 1 if t>.66 else 0)\n for i in range(16):\n a=TAU*i/16\n for k in range(3):\n rr=1.768+.130*k\n z=10.30+.175*k\n box(\"Carved cantilevered gallery corbel\",world(a,0,rr,z),(.213,.313,.157),stone,.023,a)\n r=2.338\n for i in range(36):\n a=TAU*i/36\n x,y=r*math.cos(a),r*math.sin(a)\n downpipe(\"Cast gallery railing upright\",[(x,y,10.99),(x,y,11.980)],.027 if i%3 else .043,iron)\n if i%3==0:\n box(\"Steel gallery post foot plate\",(x,y,11.017),(.177,.166,.046),dark,.012,a)\n for z,th in ((11.288,.026),(11.624,.026),(11.986,.046)):\n ring=[(r*math.cos(TAU*j/145),r*math.sin(TAU*j/145),z) for j in range(146)]\n downpipe(\"Continuous circular gallery safety rail\",ring,th,iron)\n lathe(\"Lantern service room skirt\",[(1.597,11.001),(1.647,11.051),(1.654,11.160),(1.654,11.234),\n (1.694,11.276),(1.699,11.379),(1.687,11.402)], [iron,slip],slot=lambda t,u: 1 if .18\nLOOK\nA burnt-orange quilted down vest, front three-quarter view, standing on its own. Horizontal puffed baffles with fine stitching, a stand-up collar lined in slate blue, a center front zipper with dark teeth and a brass slider, dark brown binding around the armholes, collar and hem, two vertical zip pockets with brass pulls, and a small black \"KILNLINE / FIELD DOWN\" chest label.\n\nSCALE\nAbout 55 cm wide, 62 cm tall, 31 cm deep. Build in meters, +Y up, +Z forward, origin at the center of the hem on the resting plane.\n\nPARTS\n1. Outer shell: continuous puffed burnt-sienna ripstop body. Build: a cloth shell with baffle puffing and real thickness.\n2. Lining: slate-blue interior with its own seam relief. Build: an inner shell offset inside the outer one.\n3. Armholes and hem: real arm openings carved through both layers, tubular binding around each armhole and along the hem, plus topstitching. Build: cutter meshes to carve, then cords swept along the edges.\n4. Collar: padded stand collar with lining and a folded binding along its crest, continuing into the zipper edge. Build: a lofted collar band.\n5. Quilting and front: baffle stitch dashes across the body, center zipper tape with individual teeth, slider, pull tab and bottom box, two inset slash-pocket welts with zippers and pulls. Build: dashed stitch lines, repeated tooth meshes, small rounded hardware pieces.\n6. Chest label: small woven label with \"KILNLINE\" and \"FIELD DOWN\". Build: a thin box with text.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the hem center.\n2. Texture maps: run make_maps.py first for the ripstop shell, lining and binding weave maps.\n3. Build order: outer shell and lining, armhole carve and binding, hem binding, collar, baffle stitching, zipper and pockets, chest label.\n4. Assemble: lining sits inside the shell and both are carved together at the armholes, binding wraps every open edge, zipper runs from the hem to the collar crest, pockets sit on the lower front panels.\n5. Materials: burnt-sienna ripstop, slate-blue lining, umber binding and zipper tape, saddle quilting thread, dark brown zipper teeth, aged brass hardware, near-black label with cream lettering.\n6. Export: vest only, one GLB with the textures embedded.\n\nCHECK\n292,726 triangles across 35 parts. Against the image: about six baffles from hem to chest, zipper dead center, collar stands up above the shoulders, armholes show the blue lining.\n\n\n```python\n# make_maps.py\n\"\"\"Generate original ripstop, lining and woven binding PBR maps.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import zoom\n\nOUT=Path(__file__).resolve().parent/\"maps\"\nOUT.mkdir(exist_ok=True)\nW,H=1536,1024\nRNG=np.random.default_rng(18524)\nv,u=np.mgrid[0:1:complex(H),0:1:complex(W)]\n\n\ndef noise(y,x):\n grid=RNG.uniform(-1,1,(y,x))\n grid[-1]=grid[0]\n grid[:,-1]=grid[:,0]\n return zoom(grid,((H+.01)/y,(W+.01)/x),order=3,mode=\"wrap\")[:H,:W]\n\n\ndef save(name,data):\n Image.fromarray(np.clip(data*255+.5,0,255).astype(\"uint8\")).save(OUT/(name+\".png\"))\n\n\ndef maps(name,c,r,h,gain):\n save(name+\"_Base\",c)\n save(name+\"_Rough\",r)\n dy,dx=np.gradient(h)\n vec=np.dstack((-dx*gain,dy*gain,np.ones_like(dx)))\n save(name+\"_Normal\",.5+.5*vec/np.linalg.norm(vec,axis=2,keepdims=True))\n\n\ndef textiles(name,color,grid_rate,coarse):\n broad,mid,fine=noise(29,36),noise(149,277),noise(489,698)\n wx=(.5+.5*np.sin((u*grid_rate)*np.pi*2))**11\n wy=(.5+.5*np.sin((v*grid_rate*.69)*np.pi*2))**11\n rip=np.maximum(wx,wy)\n loops=.5+.5*np.sin(2*np.pi*(u*263+v*3))*np.sin(2*np.pi*(v*283-u*7))\n signal=.035*broad+.022*mid+.016*fine-.035*rip+.025*loops\n tint=np.array(color)+signal[...,None]*np.array([.87,.79,.70])\n maps(name,tint,coarse+.051*mid+.068*fine+.064*rip,.21*mid+.18*fine+.32*rip+.21*loops,1.15)\n\n\ntextiles(\"Shell\",(.511,.221,.111),112,.502)\ntextiles(\"Lining\",(.220,.259,.297),66,.501)\ntextiles(\"Binding\",(.216,.141,.115),86,.635)\n```\n\n```python\n# vest.py\n\"\"\"Kilnline, an original insulated ripstop vest.\"\"\"\nimport argparse\nimport json\nimport math\nfrom pathlib import Path\nimport sys\nimport random\n\nimport bmesh\nimport bmesh\nimport bpy\nfrom mathutils import Vector\n\nDIR = Path(__file__).resolve().parent\nSTEM = \"3d-dataset-20261127T1700Z-clothes-kilnline-quilted-vest\"\nTAU = math.tau\ndef material(name, color, roughness, maps=None, bump=.6, metallic=0., transmission=0., ior=1.45):\n m = bpy.data.materials.new(name)\n m.diffuse_color = (*color, 1)\n m.use_nodes = True\n tree = m.node_tree\n p = tree.nodes.get(\"Principled BSDF\")\n p.inputs[\"Base Color\"].default_value = (*color, 1)\n p.inputs[\"Roughness\"].default_value = roughness\n p.inputs[\"Metallic\"].default_value = metallic\n p.inputs[\"IOR\"].default_value = ior\n p.inputs[\"Transmission Weight\"].default_value = transmission\n if maps:\n for index, (tag, colorspace) in enumerate(\n ((\"Base\", \"sRGB\"), (\"Rough\", \"Non-Color\"), (\"Normal\", \"Non-Color\"))\n ):\n path = DIR/\"maps\"/f\"{maps}_{tag}.png\"\n if not path.exists():\n continue\n tex = tree.nodes.new(\"ShaderNodeTexImage\")\n tex.image = bpy.data.images.load(str(path),check_existing=True)\n tex.image.colorspace_settings.name = colorspace\n tex.location = (-620,250-index*220)\n if tag == \"Base\":\n tree.links.new(tex.outputs[\"Color\"],p.inputs[\"Base Color\"])\n elif tag == \"Rough\":\n packed = tree.nodes.new(\"ShaderNodeSeparateColor\")\n packed.location = (-310,30)\n tree.links.new(tex.outputs[\"Color\"],packed.inputs[\"Color\"])\n tree.links.new(packed.outputs[\"Green\"],p.inputs[\"Roughness\"])\n else:\n normal = tree.nodes.new(\"ShaderNodeNormalMap\")\n normal.location = (-300,-215)\n normal.inputs[\"Strength\"].default_value = bump\n tree.links.new(tex.outputs[\"Color\"],normal.inputs[\"Color\"])\n tree.links.new(normal.outputs[\"Normal\"],p.inputs[\"Normal\"])\n return m\n\n\ndef mesh(name, vertices, faces, materials, assignments, uv_coords, smooth):\n data = bpy.data.meshes.new(name)\n data.from_pydata(vertices, [], faces)\n data.update()\n uv = data.uv_layers.new(name=\"Surface maps\")\n for item in materials:\n data.materials.append(item)\n for f in data.polygons:\n f.use_smooth = smooth[f.index] if isinstance(smooth,list) else smooth\n f.material_index = assignments[f.index]\n for loop, coord in zip(f.loop_indices, uv_coords[f.index] if uv_coords else ()):\n uv.data[loop].uv = coord\n obj = bpy.data.objects.new(name,data)\n bpy.context.collection.objects.link(obj)\n return obj\n\n\n\n\n\nRNG=random.Random(27119)\n\ndef catmull(keys,steps=14):\n interp=[]\n for i in range(len(keys)-1):\n a,b,c,d=[keys[max(0,min(len(keys)-1,j))] for j in (i-1,i,i+1,i+2)]\n for j in range(steps):\n t=j/steps\n interp.append(tuple(.5*(2*q+(-p+r)*t+(2*p-5*q+4*r-s)*t*t+\n (-p+3*q-3*r+s)*t*t*t) for p,q,r,s in zip(a,b,c,d)))\n return interp+[keys[-1]]\n\n\ndef profile_mesh(name,rings,mats,n=32,slot_for=None, planar_uv=None,ends=True):\n coords=[v for row in rings for v in row]\n faces,uv,slots,smooth=[],[],[],[]\n for i in range(len(rings)-1):\n for j in range(n):\n k=(j+1)%n\n f=(i*n+j,i*n+k,(i+1)*n+k,(i+1)*n+j)\n faces.append(f)\n uv.append(tuple(planar_uv(coords[v]) for v in f) if planar_uv else\n ((j/n,i/(len(rings)-1)),((j+1)/n,i/(len(rings)-1)),\n ((j+1)/n,(i+1)/(len(rings)-1)),(j/n,(i+1)/(len(rings)-1))))\n slots.append(slot_for(i/(len(rings)-1),j/n) if slot_for else 0)\n smooth.append(True)\n if ends:\n for index,order in ((0,range(n-1,-1,-1)),(len(rings)-1,range(n))):\n face=tuple(index*n+j for j in order)\n faces.append(face)\n uv.append(tuple(planar_uv(coords[v]) for v in face) if planar_uv else tuple(\n (.5+.31*math.cos(TAU*i/n),.5+.31*math.sin(TAU*i/n)) for i in order))\n slots.append(slot_for(index/(len(rings)-1),0) if slot_for else 0)\n smooth.append(False)\n return mesh(name,coords,faces,mats,slots,uv,smooth)\n\n\ndef tube(name,knots,mats,n=22,steps=11,slot_for=None):\n path=catmull(knots,steps)\n rings=[]\n for i,(x,y,z,w,h) in enumerate(path):\n before=Vector(path[max(0,i-1)][:3])\n after=Vector(path[min(len(path)-1,i+1)][:3])\n tang=(after-before).normalized()\n up=Vector((0,0,1)) if abs(tang.z)<.92 else Vector((0,1,0))\n p=tang.cross(up).normalized()\n q=tang.cross(p).normalized()\n rings.append([Vector((x,y,z))+p*w*math.cos(TAU*j/n)+q*h*math.sin(TAU*j/n)\n for j in range(n)])\n return profile_mesh(name,rings,mats,n,slot_for)\n\n\ndef ellipsoid(name,p,scale,mat,n=64,levels=29):\n xyz=Vector(p)\n rings=[]\n for i in range(levels):\n a=math.pi*(.003+.994*i/(levels-1))\n rings.append([xyz+Vector((scale[0]*math.sin(a)*math.cos(TAU*j/n),\n scale[1]*math.sin(a)*math.sin(TAU*j/n),\n -scale[2]*math.cos(a))) for j in range(n)])\n return profile_mesh(name,rings,[mat],n)\n\n\n\n\n\nSEAMS=(.011,.091,.175,.256,.338,.414,.480,.536)\nTORSO=[\n (0,.236,.116,.105),(.032,.248,.122,.115),(.087,.250,.121,.115),\n (.153,.245,.121,.117),(.220,.248,.127,.121),(.288,.257,.137,.128),\n (.354,.268,.142,.131),(.419,.269,.140,.126),(.470,.256,.125,.111),\n (.496,.231,.115,.098),(.518,.186,.102,.093),(.539,.119,.095,.088),\n (.548,.096,.092,.087),\n]\n\n\ndef smooth_profile(z):\n k=0\n while kTORSO[k+1][0]:\n k+=1\n p,x,y,q=TORSO[max(0,k-1)],TORSO[k],TORSO[k+1],TORSO[min(len(TORSO)-1,k+2)]\n span=y[0]-x[0]\n t=max(0,min(1,(z-x[0])/span))\n c=(2*t**3-3*t*t+1,t**3-2*t*t+t,-2*t**3+3*t*t,t**3-t*t)\n return tuple(c[0]*x[i]+c[1]*span*(y[i]-p[i])/(y[0]-p[0])+\n c[2]*y[i]+c[3]*span*(q[i]-x[i])/(q[0]-x[0]) for i in (1,2,3))\n\n\ndef angular_gap(z):\n t=max(0,min(1,(z-.428)/.132))\n return .021+.43*t**1.16\n\n\ndef cloth(a,z,lining=False):\n w,front,back=smooth_profile(z)\n s,c=math.sin(a),math.cos(a)\n frontness=max(0,c)\n softness=(1-abs(s)**4)\n zm=z+.011*math.sin(a)**2+.005*math.sin(2*a+z*6)*z\n for p,q in zip(SEAMS,SEAMS[1:]):\n if p<=zm<=q:\n t=(zm-p)/(q-p)\n inflation=math.sin(math.pi*t)**.77\n break\n else:\n inflation=0\n breathing=.93+.062*math.sin(3*a+z*18)+.031*math.cos(7*a-z*26)\n angle=abs(math.remainder(a,TAU))\n zip_clear=1-.87*math.exp(-(angle/.135)**2)\n arm_clear=1-.69*math.exp(-((angle-math.pi/2)/.63)**4)*max(0,min(1,(z-.29)/.11))\n clearance=zip_clear*arm_clear\n adjustment=inflation*.0146*breathing*(.32+.68*softness)*clearance if not lining else .0018*inflation\n # Uneven folds bunch near stitch lines and drape vertically across a baffle.\n ripple=(.00275*math.sin(a*18+z*47)+.00175*math.sin(a*31-z*83))*(.30+.70*inflation)\n ripple*=(math.cos(2*a+z*5)*.6+.4)*(.25+.75*clearance)\n fold=.0023*math.cos(a*25+z*34)*max(0,.54-inflation)*abs(c)*clearance\n if lining:\n w-=.012\n front-=.013\n back-=.013\n ripple*=.33\n x=(w+adjustment*.59+ripple)*math.copysign(abs(s)**.79,s)\n if c>=0:\n depth=(front+adjustment*.91+ripple+fold)\n else:\n depth=(back+adjustment*.83+ripple)\n y=-math.copysign(abs(c)**.69,c)*depth + .007*math.sin(z*16.1)\n # Gentle lean through the chest, with the lower hem and centerline as the pivot.\n x+=.005*zip_clear*math.sin(z*9.7)*math.sin(math.pi*min(1,z/.55)) + .004*s*z\n y+=.007*z*frontness\n return Vector((x,y,z))\n\n\ndef panel_shell(name,material,inner=False):\n rows=112 if inner else 159\n n=150 if inner else 216\n verts,faces,uv=[],[],[]\n for j in range(rows+1):\n z=.548*j/rows\n angle=angular_gap(z)\n verts.extend(cloth(angle+(TAU-2*angle)*i/n,z,inner) for i in range(n+1))\n for j in range(rows):\n for i in range(n):\n k=j*(n+1)+i\n f=(k,k+1,k+n+2,k+n+1)\n faces.append(f if not inner else tuple(reversed(f)))\n tex=[(2.5*i/n,j/rows),(2.5*(i+1)/n,j/rows),\n (2.5*(i+1)/n,(j+1)/rows),(2.5*i/n,(j+1)/rows)]\n uv.append(tuple(tex if not inner else reversed(tex)))\n return mesh(name,verts,faces,[material],[0]*len(faces),uv,True)\n\n\ndef arm_shape(theta):\n si,co=math.sin(theta),math.cos(theta)\n z=.430+.103*si\n y=.004+.117*co*(.84+.16*(si+1)/2)+.023*si\n return y,z\n\n\ndef make_cutter(side,material):\n n=160\n vertices=[(side*x,*arm_shape(TAU*i/n)) for x in (.096,.352) for i in range(n)]\n faces=[tuple(range(n-1,-1,-1)),tuple(range(n,2*n))]\n faces.extend((j,(j+1)%n,n+(j+1)%n,n+j) for j in range(n))\n if side<0:\n faces=[tuple(reversed(f)) for f in faces]\n return mesh(\"Armhole cutter\",vertices,faces,[material],[0]*len(faces),None,False)\n\n\ndef carve(ob,material):\n bpy.context.view_layer.objects.active=ob\n shell=ob.modifiers.new(\"Cloth shell thickness\",\"SOLIDIFY\")\n shell.thickness=.00125\n shell.offset=-.35\n bpy.ops.object.modifier_apply(modifier=shell.name)\n for side in (-1,1):\n cutter=make_cutter(side,material)\n bpy.context.view_layer.objects.active=ob\n cut=ob.modifiers.new(\"Real arm opening\",\"BOOLEAN\")\n cut.operation=\"DIFFERENCE\"\n cut.solver=\"EXACT\"\n cut.object=cutter\n bpy.ops.object.modifier_apply(modifier=cut.name)\n bpy.data.objects.remove(cutter,do_unlink=True)\n bm=bmesh.new()\n bm.from_mesh(ob.data)\n bmesh.ops.remove_doubles(bm,verts=list(bm.verts),dist=.000007)\n bmesh.ops.dissolve_degenerate(bm,edges=list(bm.edges),dist=.000007)\n bm.to_mesh(ob.data)\n bm.free()\n\n\ndef cord(name,pts,r,mat,cycle=False):\n d=bpy.data.curves.new(name,\"CURVE\")\n d.dimensions=\"3D\"\n d.bevel_depth=r\n d.bevel_resolution=3\n d.use_fill_caps=True\n s=d.splines.new(\"POLY\")\n s.use_cyclic_u=cycle\n s.points.add(len(pts)-1)\n for p,x in zip(s.points,pts):\n p.co=(*x,1)\n o=bpy.data.objects.new(name,d)\n bpy.context.collection.objects.link(o)\n o.data.materials.append(mat)\n return o\n\n\ndef arm_edge(side,u):\n y,z=arm_shape(u)\n lo,hi=0,math.pi\n for _ in range(29):\n c=(lo+hi)/2\n p=cloth(c*side,z)\n if p.y.094 and arm<1.085:\n continue\n def stitch_pos(a,z):\n work=cloth(a,z-.005*math.sin(2*a+z*6)*z)\n return work+Vector((math.sin(a)*.00069,-math.cos(a)*.00069,0))\n p=stitch_pos(a,z)\n q=stitch_pos(a2,z)\n s=curve.splines.new(\"POLY\")\n s.points.add(1)\n s.points[0].co=(*p,1)\n s.points[1].co=(*q,1)\n total+=1\n ob=bpy.data.objects.new(curve.name,curve)\n bpy.context.collection.objects.link(ob)\n ob.data.materials.append(stitch)\n\n\ndef trim_front(tape,tooth,hardware,stitch):\n for side in (-1,1):\n path=[]\n for i in range(130):\n z=.005+.543*i/129\n q=cloth(side*angular_gap(z),z)\n x=side*max(abs(q.x),.005)\n path.append(Vector((x,q.y-.0025,z)))\n cord(\"Woven central zipper tape\",path,.0043,tape)\n verts,faces,uv=[],[],[]\n for i in range(116):\n z=.014+i*.00458\n q=cloth(side*angular_gap(z),z)\n if z<.426:\n x=side*.0024*(1 if z<.417 else 1.25)\n else:\n x=q.x-side*.001\n y=q.y-.006\n zz=z+.0005*side\n base=len(verts)\n verts.extend((x+sx*.0022,y+sy*.00175,zz+sz*.00178)\n for sz in (-1,1) for sy in (-1,1) for sx in (-1,1))\n for f in ((0,2,3,1),(4,5,7,6),(0,1,5,4),(1,3,7,5),(3,2,6,7),(2,0,4,6)):\n faces.append(tuple(base+j for j in f))\n uv.append(((0,0),(1,0),(1,1),(0,1)))\n o=mesh(\"Fine individual interlocking zipper teeth\",verts,faces,[tooth],[0]*len(faces),uv,False)\n m=o.modifiers.new(\"Tooth edge roundover\",\"BEVEL\")\n m.width=.00044\n m.segments=2\n\n level=.427\n depth=cloth(0,level).y-.008\n box(\"Rounded antique zipper slider\",(0,depth,level),(.028,.012,.029),hardware,.0036)\n box(\"High relief slider bridge\",(0,depth-.005,level-.006),(.015,.012,.013),hardware,.0022)\n pull=[(-.005,depth-.011,.426),(.005,depth-.011,.426),(.008,depth-.016,.414),\n (.008,depth-.022,.392),(.005,depth-.024,.386),(-.005,depth-.024,.386),\n (-.008,depth-.022,.392),(-.008,depth-.016,.414)]\n cord(\"Hollow rounded zipper pull tab\",pull,.0027,hardware,True)\n box(\"Lower zipper insertion box\",(0,cloth(0,.010).y-.002,.013),(.020,.012,.019),hardware,.0028)\n\n for side in (-1,1):\n pts=[]\n for i in range(43):\n t=i/42\n z=.135+.161*t\n a=side*(.61+.167*t)\n p=cloth(a,z)\n pts.append(p+Vector((.003*side,-.004,0)))\n cord(\"Inset slash-pocket welt\",pts,.0062,tape)\n cord(\"Opening in pocket welt\",[p+Vector((.0011*side,-.0051,0)) for p in pts[1:-1]],.0027,tooth)\n for off in (-.0062,.0062):\n cord(\"Pocket stitching along bound edge\",[p+Vector((off,-.0007,-.003)) for p in pts],.00064,stitch)\n p=pts[-2]\n box(\"Pocket zipper pull and slider\",(p.x,p.y-.006,p.z),(.013,.009,.019),hardware,.0023,side*.34)\n\n\ndef label(text_value,loc,size,mat):\n d=bpy.data.curves.new(text_value,\"FONT\")\n d.body=text_value\n d.size=size\n d.align_x=d.align_y=\"CENTER\"\n d.extrude=.00004\n d.resolution_u=4\n o=bpy.data.objects.new(text_value,d)\n bpy.context.collection.objects.link(o)\n o.location=loc\n o.rotation_euler.x=math.pi/2\n o.data.materials.append(mat)\n\n\ndef build():\n shell=material(\"Burnt-sienna nylon ripstop shell\",(.28,.074,.034),.47,\"Shell\",.44)\n lining=material(\"Slate-blue nylon lining\",(.066,.081,.100),.53,\"Lining\",.35)\n binding=material(\"Woven umber binding and zipper tape\",(.061,.028,.021),.61,\"Binding\",.44)\n stitch=material(\"Fine saddle-colored quilting thread\",(.332,.153,.074),.68)\n tooth=material(\"Dark brown interlocked zipper teeth\",(.073,.044,.034),.51)\n hardware=material(\"Aged brass zipper hardware\",(.38,.241,.102),.41,metallic=.64)\n tag=material(\"Near-black woven jacket-label backing\",(.033,.035,.037),.73)\n ink=material(\"Cream jacquard label lettering\",(.64,.55,.39),.60)\n for part,mat in ((panel_shell(\"Continuous puffed outer vest shell\",shell),shell),\n (panel_shell(\"Interior lining with separate seam relief\",lining,True),lining)):\n carve(part,mat)\n for side in (-1,1):\n pts=[arm_edge(side,TAU*i/224) for i in range(224)]\n cord(\"Tubular binding around real armhole\",pts,.0062,binding,True)\n cord(\"Topstitched inner edge of armhole binding\",[p+Vector((.0047*side,0,0)) for p in pts],\n .00071,stitch,True)\n gap=angular_gap(.006)\n hem=[cloth(gap+(TAU-2*gap)*i/235,.007) for i in range(236)]\n cord(\"Rounded lower hem binding\",hem,.0068,binding)\n cord(\"Fine lower-hem topstitch\",[p+Vector((.0004,0,.0068)) for p in hem],.00064,stitch)\n collar(shell,lining,binding,stitch)\n baffle_stitch(stitch,binding)\n trim_front(binding,tooth,hardware,stitch)\n q=cloth(-.40,.398)\n box(\"Small woven chest brand label\",(q.x,q.y-.008,.398),(.048,.005,.023),tag,.0016,-.022)\n label(\"KILNLINE\",(q.x,q.y-.011,.400),.0065,ink)\n label(\"FIELD DOWN\",(q.x,q.y-.011,.392),.0038,ink)\n\n\ndef prepare_export():\n for obj in list(bpy.context.scene.objects):\n if obj.type!=\"FONT\":\n continue\n bpy.ops.object.select_all(action=\"DESELECT\")\n obj.select_set(True)\n bpy.context.view_layer.objects.active=obj\n bpy.ops.object.convert(target=\"MESH\")\n out=bpy.context.object\n bm=bmesh.new()\n bm.from_mesh(out.data)\n bmesh.ops.triangulate(bm,faces=list(bm.faces))\n remove=[f for f in bm.faces if f.calc_area()<1e-11]\n bmesh.ops.delete(bm,geom=remove,context=\"FACES_ONLY\")\n bm.to_mesh(out.data)\n bm.free()\n\n\ndef point_at(obj, target):\n obj.rotation_euler = (Vector(target)-obj.location).to_track_quat(\"-Z\",\"Y\").to_euler()\n\n\ndef panel(name,location,target,power,color,size,minor):\n data = bpy.data.lights.new(name,\"AREA\")\n data.energy = power\n data.color = color\n data.shape = \"RECTANGLE\"\n data.size = size\n data.size_y = minor\n obj = bpy.data.objects.new(name,data)\n bpy.context.collection.objects.link(obj)\n obj.location = location\n point_at(obj,target)\n\n\ndef studio(output,mode):\n scene = bpy.context.scene\n profile=[(-10,-.0005),(.42,-.0005)]\n for j in range(1,48):\n t=(math.pi/2)*j/47\n profile.append((.42+1.37*math.sin(t),1.37*(1-math.cos(t))-.0005))\n profile.append((1.79,12))\n verts=[(x,y,z) for y,z in profile for x in (-8,8)]\n faces=[(2*i,2*i+1,2*i+3,2*i+2) for i in range(len(profile)-1)]\n grey=material(\"Charcoal-olive studio sweep\",(.092,.093,.081),.77)\n mesh(\"Seamless studio backdrop\",verts,faces,[grey],[0]*len(faces),\n [((0,0),(1,0),(1,1),(0,1))]*len(faces),True)\n scene.world = bpy.data.worlds.new(\"Soft slate studio\")\n scene.world.use_nodes = True\n bg = scene.world.node_tree.nodes.get(\"Background\")\n bg.inputs[\"Color\"].default_value = (.53,.59,.69,1)\n bg.inputs[\"Strength\"].default_value = .15\n panel(\"Cross-light for the quilted fabric\",(-.67,-.77,1.09),(0,0,.30),61,(1,.941,.852),.52,.84)\n panel(\"Soft blue rim along shoulders\",(.39,.57,.92),(0,0,.34),49,(.81,.918,1),.44,.64)\n panel(\"Faint fill on zip hardware\",(.62,-.72,.37),(0,0,.28),19,(.95,.97,1),.37,.56)\n cdata = bpy.data.cameras.new(\"Vest portrait\")\n cam = bpy.data.objects.new(\"Vest portrait\",cdata)\n bpy.context.collection.objects.link(cam)\n cam.location = (.767,-1.395,.634)\n point_at(cam,(0,0,.290))\n cdata.lens = 76\n scene.camera = cam\n scene.render.engine = \"CYCLES\"\n scene.cycles.samples = 232 if mode==\"final\" else 24\n scene.cycles.use_denoising = False\n scene.cycles.adaptive_threshold = .011 if mode==\"final\" else .086\n scene.cycles.max_bounces = 7\n scene.cycles.transmission_bounces = 4\n scene.render.resolution_x = 1660\n scene.render.resolution_y = 1900\n scene.render.resolution_percentage = 100 if mode==\"final\" else 44\n scene.view_settings.view_transform = \"AgX\"\n scene.view_settings.exposure = -.39\n scene.view_settings.look = \"AgX - Medium High Contrast\"\n scene.render.image_settings.file_format = \"PNG\"\n scene.render.image_settings.color_mode = \"RGB\"\n scene.render.filepath = str(output/(STEM+\".png\"))\n bpy.ops.render.render(write_still=True)\n\n\ndef reimport(path,output):\n bpy.ops.wm.read_factory_settings(use_empty=True)\n bpy.ops.import_scene.gltf(filepath=str(path))\n objs = list(bpy.context.scene.objects)\n meshes = [o for o in objs if o.type==\"MESH\"]\n assert meshes and all(o.type in {\"MESH\",\"EMPTY\"} for o in objs)\n corners = [o.matrix_world@Vector(x) for o in meshes for x in o.bound_box]\n dims = [max(p[i] for p in corners)-min(p[i] for p in corners) for i in range(3)]\n tris = 0\n for o in meshes:\n o.data.calc_loop_triangles()\n tris += len(o.data.loop_triangles)\n stats = {\"objects\":len(meshes),\"triangles\":tris,\n \"dimensions_m\":dict(zip((\"width\",\"depth\",\"height\"),dims)),\n \"image_sizes\":{i.name:list(i.size) for i in bpy.data.images if i.source==\"FILE\" and i.size[0]}}\n (output/\"reimport.json\").write_text(json.dumps(stats,indent=2)+\"\\n\")\n\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"--out\",type=Path,required=True)\n parser.add_argument(\"--mode\",choices=(\"draft\",\"final\"),required=True)\n args = parser.parse_args(sys.argv[sys.argv.index(\"--\")+1:])\n output = args.out.resolve()\n output.mkdir(exist_ok=True,parents=True)\n bpy.ops.wm.read_factory_settings(use_empty=True)\n bpy.context.scene.unit_settings.system = \"METRIC\"\n build()\n if args.mode==\"final\":\n bpy.ops.file.pack_all()\n bpy.ops.wm.save_as_mainfile(filepath=str(output/\"kilnline-vest.blend\"),compress=True)\n prepare_export()\n path = output/(STEM+\".glb\")\n bpy.ops.export_scene.gltf(filepath=str(path),export_format=\"GLB\",export_apply=True,\n export_cameras=False,export_lights=False)\n reimport(path,output)\n studio(output,args.mode)\n\n\nif __name__==\"__main__\":\n main()\n```\n\nrun it: `python3 make_maps.py` then `blender -b --python vest.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T1700Z-clothes-kilnline-quilted-vest.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/kilnline-quilted-vest/3d-dataset-20261127T1700Z-clothes-kilnline-quilted-vest.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/meridian-enamel-signet.jpg"}}, {"type": "text", "text": "create an image of a meridian enamel signet"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nAn Art Deco gold signet ring, three-quarter view from above. Polished yellow gold band with a stepped octagonal head, filled with teal-petrol enamel. On the face, a satin gold sun rises over stepped horizon lines, with rays in alternating blue and turquoise enamel, all outlined in gold wire. Three blue enamel bars sit on the side of the shank, and \"MERIDIAN / 750\" is engraved inside.\n\nSCALE\nAbout 22 mm wide, 25 mm tall, 13 mm deep. Build in meters, +Y up, +Z forward, origin on the ground plane under the ring, centered across the shank.\n\nPARTS\n1. Shank: continuous comfort-fit band. Build: a cross-section profile swept around the ring path.\n2. Shoulders: sculpted crown shoulders rising from the band to the head. Build: lofted sections blending band to bezel.\n3. Bezel: stepped octagonal head with a first step, a dark perimeter fillet and a bright-cut enamel lip. Build: stacked clipped octagons with bevels.\n4. Enamel face: kiln-set petrol enamel field with hand-filled ray cells. Build: a recessed field mesh plus separate ray cells.\n5. Cloisonne: gold dividing wires, stepped horizon lines, compass accents, and a raised sun with a polished rim and satin face. Build: wires swept along paths, a domed disk for the sun.\n6. Shank details: stepped black enamel tablets on each shoulder and a hallmark inside the shank. Build: small tiles following the shank curvature, glyphs mapped onto the inner surface.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the tabletop contact.\n2. Texture maps: run make_maps.py first for polished and satin gold and enamel variation.\n3. Build order: shank, shoulders, bezel steps, enamel field, sunrise and horizon cloisons, shank tablets, inner hallmark.\n4. Assemble: shoulders join the shank to the bezel, enamel sits recessed inside the bezel lip, wires and sun sit on top of the enamel, tablets follow the shank curve. Stand the ring upright with the pivot at the contact point.\n5. Materials: softly polished 18k gold, polished edges, champagne satin sun, recessed maker's marks, midnight petrol, blue-black, blue slate and oxidized turquoise enamels.\n6. Export: ring only, one GLB with the textures embedded.\n\nCHECK\n33,180 triangles across 39 parts. Against the image: bezel wider than the band, sun near the top of the face with rays fanning upward, horizon lines below it, enamel bars on the shank side.\n\n\n```python\n# make_maps.py\n\"\"\"Rebuild the original PBR texture maps with NumPy, SciPy, and Pillow.\"\"\"\nfrom pathlib import Path\n\nimport numpy as np\nfrom PIL import Image, ImageDraw\nfrom scipy.ndimage import gaussian_filter\n\nOUTPUT = Path(__file__).resolve().parent / \"maps\"\nOUTPUT.mkdir(exist_ok=True)\nSIZE = 1024\nrng = np.random.default_rng(250618)\n\n\ndef noise(sigma):\n result = gaussian_filter(rng.standard_normal((SIZE, SIZE)), sigma, mode=\"wrap\")\n return result / result.std()\n\n\ndef save(name, values):\n Image.fromarray(np.clip(np.round(values * 255), 0, 255).astype(\"uint8\")).save(OUTPUT / (name + \".png\"))\n\n\nweather = noise(15)\ngrain = noise((0.75, 5.3))\nscratch_image = Image.new(\"L\", (SIZE, SIZE))\ndraw = ImageDraw.Draw(scratch_image)\nfor _ in range(1150):\n x, y = rng.integers(0, SIZE, 2)\n length = rng.integers(6, 83)\n fall = rng.normal(0, 1.65)\n strength = rng.integers(16, 88)\n for shift_x in (-SIZE, 0):\n for shift_y in (-SIZE, 0, SIZE):\n draw.line((x + shift_x, y + shift_y, x + length + shift_x, y + fall + shift_y), fill=int(strength), width=1)\nscratch = gaussian_filter(np.asarray(scratch_image, dtype=float) / 255, 0.5, mode=\"wrap\")\nmetal_roughness = .205 + .014 * weather + .016 * grain + .25 * scratch\nsave(\"metal-roughness\", metal_roughness)\nmetallic_tint = 1 - .014 * np.clip(weather + .4 * grain, -1, 2) - .12 * scratch\nsave(\"metal-color\", metallic_tint[:, :, None] * np.array([.958, .740, .410]))\nheight = .005 * grain - .08 * scratch + .0012 * noise(.45)\ngy, gx = np.gradient(height)\nnormal = np.stack([-gx * 5, -gy * 5, np.ones_like(height)], axis=2)\nnormal /= np.linalg.norm(normal, axis=2)[:, :, None]\nsave(\"metal-normal\", .5 + .5 * normal)\n\nenamel_clouds = noise(20) * .030 + noise(6) * .021 + noise(1.2) * .013\nsave(\"enamel-color\", np.array([.052, .185, .209]) * (1 + enamel_clouds[:, :, None]))\nsave(\"enamel-roughness\", .143 + .012 * noise(12) + .006 * noise(.86) + .05 * scratch)\nsave(\"champagne-roughness\", .32 + .025 * noise((1.4, 3.4)) + .014 * noise(18))\n```\n\n```python\n# meridian.py\n\"\"\"Parametric Blender model for the Meridian enamel signet, in millimeters.\"\"\"\nfrom math import atan2, cos, pi, sin, sqrt, copysign\nfrom pathlib import Path\nimport sys\n\nimport bpy\nfrom mathutils import Matrix, Vector\n\nHERE = Path(__file__).resolve().parent\nOUT = Path(sys.argv[sys.argv.index(\"--\") + 1]) if \"--\" in sys.argv else HERE\nSTEM = \"3d-dataset-20261127T1800Z-jewelry-meridian-enamel-signet\"\nOUT.mkdir(parents=True, exist_ok=True)\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene = bpy.context.scene\nscene.unit_settings.system = \"METRIC\"\n\n\ndef make_material(name, color, metal, rough, maps=None, coat=0):\n mat = bpy.data.materials.new(name)\n mat.diffuse_color = (*color, 1)\n mat.use_nodes = True\n tree = mat.node_tree\n bsdf = tree.nodes.get(\"Principled BSDF\")\n bsdf.inputs[\"Base Color\"].default_value = (*color, 1)\n bsdf.inputs[\"Metallic\"].default_value = metal\n bsdf.inputs[\"Roughness\"].default_value = rough\n bsdf.inputs[\"Coat Weight\"].default_value = coat\n bsdf.inputs[\"Coat Roughness\"].default_value = .13\n for key, texture in (maps or {}).items():\n path = HERE / \"maps\" / (texture + \".png\")\n image = bpy.data.images.load(str(path), check_existing=True)\n image.colorspace_settings.name = \"sRGB\" if key == \"Base Color\" else \"Non-Color\"\n node = tree.nodes.new(\"ShaderNodeTexImage\")\n node.image = image\n node.label = texture\n if key == \"Normal\":\n normal = tree.nodes.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value = .45\n tree.links.new(node.outputs[\"Color\"], normal.inputs[\"Color\"])\n tree.links.new(normal.outputs[\"Normal\"], bsdf.inputs[key])\n else:\n tree.links.new(node.outputs[\"Color\"], bsdf.inputs[key])\n return mat\n\n\ngold = make_material(\"18k gold · softly polished\", (.91,.63,.30), 1, .21, {\n \"Base Color\":\"metal-color\", \"Roughness\":\"metal-roughness\", \"Normal\":\"metal-normal\"})\nedge = make_material(\"18k gold · polished edges\", (.93,.62,.29), 1, .155)\nbright = make_material(\"18k gold · champagne satin sun\", (.94,.72,.46), 1, .34, {\n \"Roughness\":\"champagne-roughness\"})\nenamel = make_material(\"Vitreous enamel · midnight petrol\", (.008,.029,.036), 0, .145,\n {\"Base Color\":\"enamel-color\", \"Roughness\":\"enamel-roughness\"}, .24)\ndeep = make_material(\"Vitreous enamel · blue-black accents\", (.004,.012,.019), 0, .18, coat=.22)\nteal = make_material(\"Vitreous enamel · oxidized turquoise\", (.015,.097,.105), 0, .21, coat=.18)\nmuted = make_material(\"Vitreous enamel · blue slate\", (.015,.046,.065), 0, .2, coat=.17)\nstamp = make_material(\"18k gold · recessed maker's marks\", (.27,.137,.044), 1, .38)\n\n\ndef mesh(name, verts, faces, mat, uv=None, smooth=False):\n geo = bpy.data.meshes.new(name)\n geo.from_pydata([Vector(v) * .001 for v in verts], [], faces)\n geo.update()\n ob = bpy.data.objects.new(name, geo)\n scene.collection.objects.link(ob)\n geo.materials.append(mat)\n tex = geo.uv_layers.new(name=\"Surface\")\n for face in geo.polygons:\n face.use_smooth = smooth\n for loop in face.loop_indices:\n j = geo.loops[loop].vertex_index\n tex.data[loop].uv = uv[j] if uv else (verts[j][0]/16+.5, verts[j][1]/14+.5)\n return ob\n\n\ndef band_point(a, b, offset=0):\n rise = ((1+cos(a))*.5)**4.7\n inner = 9.16 + .03*cos(a)\n outer = 10.78 + 2.17 * rise\n width = 4.05 + 6.65 * rise\n def softened(v):\n return copysign(abs(v)**.45, v)\n radius = (inner + outer)*.5 + (outer - inner)*.5*softened(cos(b)) + offset\n return (radius*sin(a), width*.5*softened(sin(b)), radius*cos(a))\n\n\ndef make_band():\n n, m = 216, 48\n verts = [band_point(i*2*pi/n, j*2*pi/m) for i in range(n) for j in range(m)]\n faces = [(i*m+j, ((i+1)%n)*m+j, ((i+1)%n)*m+(j+1)%m, i*m+(j+1)%m)\n for i in range(n) for j in range(m)]\n ob = mesh(\"Continuous comfort-fit shank\", verts, faces, gold, smooth=True)\n layer = ob.data.uv_layers.active\n for poly in ob.data.polygons:\n i,j = divmod(poly.index,m)\n for loop,uv in zip(poly.loop_indices, [(i,j),(i+1,j),(i+1,j+1),(i,j+1)]):\n layer.data[loop].uv = (uv[0]/n*2,uv[1]/m)\n return ob\n\n\ndef loft(name, perimeter, levels, material, bevel_mat=None):\n \"\"\"Stepped solid with a closed, flat display face.\"\"\"\n verts = [(x*s,y*s, z(x*s,y*s) if callable(z) else z)\n for s,z in levels for x,y in perimeter]\n num = len(perimeter)\n faces = [tuple(reversed(range(num)))]\n for k in range(len(levels)-1):\n for i in range(num):\n nxt = (i+1)%num\n faces.append((k*num+i,k*num+nxt,(k+1)*num+nxt,(k+1)*num+i))\n faces.append(tuple(range(len(verts)-num,len(verts))))\n obj = mesh(name,verts,faces,material)\n if material == gold:\n layer = obj.data.uv_layers.active\n distances = [0.]\n for (x1,y1),(x2,y2) in zip(perimeter,perimeter[1:]+perimeter[:1]):\n distances.append(distances[-1]+sqrt((x2-x1)**2+(y2-y1)**2))\n for poly in list(obj.data.polygons)[1:-1]:\n index = (poly.index-1) % num\n for loop,column in zip(poly.loop_indices,(index,index+1,index+1,index)):\n vertex = obj.data.loops[loop].vertex_index\n layer.data[loop].uv = (distances[column]/24,verts[vertex][2]/5)\n if bevel_mat:\n obj.data.materials.append(bevel_mat)\n for p in list(obj.data.polygons)[1:-1]:\n if (p.index-1)//num in (0,len(levels)-2):\n p.material_index = 1\n return obj\n\n\ndef solid(name, points, z, material, bevel=.012, thickness=.054):\n if sum(x1*y2-x2*y1 for (x1,y1),(x2,y2) in zip(points,points[1:]+points[:1])) < 0:\n points = list(reversed(points))\n obj = loft(name,points,[(1,z-thickness),(1,z)],material)\n if bevel:\n modifier = obj.modifiers.new(\"Rounded jewelry edges\", \"BEVEL\")\n modifier.width = bevel*.001\n modifier.segments = 3\n modifier.affect = \"EDGES\"\n return obj\n\n\ndef foil_line(name, a, b, width, z, mat=edge):\n ax,ay = a\n bx,by = b\n theta = atan2(by-ay,bx-ax)\n pts = [(bx+width*.5*cos(theta-pi/2+i*pi/8),by+width*.5*sin(theta-pi/2+i*pi/8))\n for i in range(9)]\n pts += [(ax+width*.5*cos(theta+pi/2+i*pi/8),ay+width*.5*sin(theta+pi/2+i*pi/8))\n for i in range(9)]\n return solid(name,pts,z,mat,min(.013,width*.14))\n\n\ndef foil_path(name, points, width, z):\n directions=[Vector((bx-ax,by-ay)).normalized() for (ax,ay),(bx,by) in zip(points,points[1:])]\n normals=[Vector((-d.y,d.x)) for d in directions]\n offsets=[normals[0]]\n for a,b in zip(normals,normals[1:]):\n n=(a+b).normalized()\n offsets.append(n/n.dot(a))\n offsets.append(normals[-1])\n left=[tuple(Vector(p)+n*width/2) for p,n in zip(points,offsets)]\n right=[tuple(Vector(p)-n*width/2) for p,n in zip(points,offsets)]\n return solid(name,left+right[::-1],z,edge,.014)\n\n\ndef clip(poly, border):\n for a,b in zip(border,border[1:]+border[:1]):\n def side(p):\n return (b[0]-a[0])*(p[1]-a[1])-(b[1]-a[1])*(p[0]-a[0])\n output = []\n for p,q in zip(poly,poly[1:]+poly[:1]):\n dp,dq = side(p),side(q)\n if dp >= 0:\n output.append(p)\n if (dp>=0) != (dq>=0):\n t = dp/(dp-dq)\n output.append((p[0]+t*(q[0]-p[0]),p[1]+t*(q[1]-p[1])))\n poly = output\n return poly\n\n\nmake_band()\noctagon = [(-5.64,-6.17),(5.64,-6.17),(7.6,-4.16),(7.6,4.16),\n (5.64,6.17),(-5.64,6.17),(-7.6,4.16),(-7.6,-4.16)]\nloft(\"Sculpted crown shoulders\", octagon,\n [(.91,lambda x,y:sqrt(12.2**2-x*x)-.95),\n (.995,lambda x,y:sqrt(12.9**2-x*x)-.36),(1,12.18),(.988,12.55),\n (.954,12.92)],gold,edge)\nloft(\"First bezel step\",octagon,[(.952,12.85),(.957,12.94),(.957,13.09),(.932,13.29)],gold,edge)\nloft(\"Obsidian perimeter fillet\",octagon,[(.925,13.23),(.925,13.31),(.908,13.39)],deep)\nloft(\"Bright-cut enamel lip\",octagon,[(.905,13.34),(.916,13.44),(.916,13.53),(.898,13.68)],edge)\nloft(\"Kiln-set petrol enamel\",octagon,[(.873,13.59),(.873,13.66),(.857,13.706)],enamel)\nborder = [(x*.829,y*.829) for x,y in octagon]\n\n# A sunrise and terraces laid into the enamel, with actual beveled cloison edges.\nsource = (0,.52)\nfor degrees, tint in [(25,muted),(51,teal),(78,muted),(102,muted),(129,teal),(155,muted)]:\n a = (degrees-3.4)*pi/180\n b = (degrees+3.4)*pi/180\n wedge = clip([source,(15*cos(a),source[1]+15*sin(a)),(15*cos(b),source[1]+15*sin(b))],border)\n solid(\"Hand-filled enamel ray\",wedge,13.717,tint,.007)\n for i in [1,2]:\n endpoint=max(wedge,key=lambda p: (p[0]-source[0])*cos([a,b][i-1])+(p[1]-source[1])*sin([a,b][i-1])-\n 20*abs((p[1]-source[1])*cos([a,b][i-1])-(p[0]-source[0])*sin([a,b][i-1])))\n foil_line(\"Gold dividing wire\",source,endpoint,.082,13.754)\nfor y,w in [(-.79,5.78),(-1.83,4.92),(-2.86,4.05),(-3.89,3.17)]:\n points = [(-w,y),(-w*.56,y),(-w*.41,y+.44),(w*.41,y+.44),(w*.56,y),(w,y)]\n foil_path(\"Stepped horizon cloison\",points,.128,13.771)\n\nfor side in [-1,1]:\n x=side*5.17\n solid(\"Compass accent\",[ (x-.32,-2.21),(x,-1.80),(x+.32,-2.21),(x,-2.62)],13.752,bright)\n\ndef circle(cx,cy,r,n=112):\n return [(cx+r*cos(i*2*pi/n),cy+r*sin(i*2*pi/n)) for i in range(n)]\n\nsolid(\"Raised sun · polished rim\",circle(0,.56,1.73),13.80,edge,.039,.14)\nloft(\"Raised sun · satin face\",circle(0,.56,1.515),[(1,13.788),(1,13.811),(.971,13.840)],bright,edge)\n\n# Small geometric reliefs follow the real shank curvature below either shoulder.\ndef shoulder_tile(name, angle, center_b, span_a, span_b, mat):\n p=[(-1,-.61),(-.66,-1),(.66,-1),(1,-.61),(1,.61),(.66,1),(-.66,1),(-1,.61)]\n # Subdivide each perimeter edge and fill in concentric rings.\n outline = []\n for a,b in zip(p,p[1:]+p[:1]):\n outline.extend((a[0]+(b[0]-a[0])*i/6,a[1]+(b[1]-a[1])*i/6) for i in range(6))\n count=len(outline)\n verts=[]\n for radius in [.18,.42,.67,.86,1.]:\n verts.extend(band_point(angle+u*span_a*radius,center_b+v*span_b*radius,.018+.011*(1-radius))\n for u,v in outline)\n faces=[tuple(range(count))]\n for j in range(4):\n faces.extend((j*count+i,(j+1)*count+i,(j+1)*count+(i+1)%count,j*count+(i+1)%count)\n for i in range(count))\n return mesh(name,verts,faces,mat,smooth=True)\n\nfor side in (-1,1):\n for n in range(3):\n a=side*(.88+n*.116)\n shoulder_tile(\"Shank · stepped black enamel tablet\",a,0,.044,.28-.054*n,deep)\n\n# A laser-darkened hallmarked area on the inside of the shank.\n# Map converted glyph coordinates onto the measured inner surface.\nfont_curve=bpy.data.curves.new(\"Original registered-style maker's mark\",\"FONT\")\nfont_curve.body=\"MERIDIAN / 750\"\nfont_curve.align_x=\"CENTER\"\nfont_curve.align_y=\"CENTER\"\nfont_curve.size=.64\nfont_curve.space_character=1.1\nfont_obj=bpy.data.objects.new(\"Inner shank · MERIDIAN / 750\",font_curve)\nscene.collection.objects.link(font_obj)\nbpy.context.view_layer.objects.active=font_obj\nfont_obj.select_set(True)\nbpy.ops.object.convert(target=\"MESH\")\nfont_obj.data.materials.append(stamp)\nfor v in font_obj.data.vertices:\n x,y,_=v.co\n a = pi - x/9.13\n v.co=Vector((9.118*sin(a),y,9.118*cos(a)))*.001\nfont_obj.select_set(False)\n\n# Display orientation, with the pivot centered at the tabletop contact.\ntilt = Matrix.Rotation(.23,4,\"X\")\nfor ob in scene.objects:\n if ob.type == \"MESH\":\n ob.data.transform(tilt)\nmin_z=min(v.co.z for ob in scene.objects if ob.type==\"MESH\" for v in ob.data.vertices)\nlift=Matrix.Translation((0,0,-min_z))\nfor ob in scene.objects:\n if ob.type==\"MESH\":\n ob.data.transform(lift)\n ob.select_set(True)\nbpy.context.view_layer.objects.active=bpy.data.objects[\"Continuous comfort-fit shank\"]\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(OUT/\"meridian-signet.blend\"),compress=True)\nbpy.ops.export_scene.gltf(filepath=str(OUT / (STEM+\".glb\")),export_format=\"GLB\",\n use_selection=True,export_apply=True,export_yup=True)\n```\n\nrun it: `python3 make_maps.py` then `blender -b --python meridian.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T1800Z-jewelry-meridian-enamel-signet.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/meridian-enamel-signet/3d-dataset-20261127T1800Z-jewelry-meridian-enamel-signet.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/marlowe-maple-snare.jpg"}}, {"type": "text", "text": "create an image of a marlowe 14 maple snare"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA 14-inch snare drum, three-quarter view from above. Honeyburst figured maple shell, chrome triple-flange hoops top and bottom, an ivory coated batter head with \"MARLOWE\" printed on it, chrome tube lugs with tension rods spaced evenly around the shell, a teal enamel \"MARLOWE\" badge on the front, and a throw-off lever on the right.\n\nSCALE\nAbout 39 cm wide, 17 cm tall, 37 cm deep. Build in meters, +Y up, +Z forward (badge faces +Z), origin at the center of the drum on the resting plane.\n\nPARTS\n1. Shell: bent laminated maple with a lacquered outer face, natural inner plies and stepped bearing edges. Build: lathe the shell wall with its edge profile, ply rings at the bearing edges.\n2. Heads: ivory coated batter on top, smoky pearl resonant head below, dark compressed edges under the hoops. Build: thin disks with collar rings.\n3. Hoops: top and bottom triple-flange nickel hoops with a drawn seam and ears. Build: lathe the hoop profile.\n4. Tension hardware: lugs with gaskets, insets, spines and bushings, tension rods with threads, washers and square key heads. The same set repeats around the shell. Build: one lug and rod set, placed at even angles.\n5. Badge and print: brushed brass badge with teal enamel inset and \"MARLOWE / MAPLE / 14\", plus the logo on the batter head. Build: pill-shaped plate, text.\n6. Snare mechanism: throw-off faceplate, pad, slide, lever, tension adjuster with knurl, strap butt plate, webbing tabs and helical snare wires under the bottom head. Build: blocks, cylinders, and helical cables for the wires.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the drum center on the resting plane.\n2. Texture maps: run maps.py first for the maple figure, lacquer and coated-head maps.\n3. Build order: shell, heads, hoops, tension hardware, badge and print, snare mechanism.\n4. Assemble: heads seat on the bearing edges, hoops clamp over the heads, rods run from each hoop ear into its lug, badge faces front, throw-off and butt plate sit opposite each other with the wires stretched under the bottom head. Merge by material.\n5. Materials: honeyburst satin maple, natural inner plies, polished and satin nickel, blackened steel, black rubber gaskets, ivory batter, smoky pearl resonant head, slate ink, brass badge with teal enamel, spring steel wires.\n6. Export: drum only, one GLB with the textures embedded.\n\nCHECK\n278,359 triangles across 17 parts. Against the image: shell depth about 40 percent of the diameter, lugs evenly spaced, badge centered between two lugs, throw-off on the side.\n\n\n```python\n# maps.py\n\"\"\"Generate the original maple, coated drumhead and metal textures.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image, ImageDraw\nfrom scipy.ndimage import gaussian_filter\n\nOUT = Path(__file__).resolve().parent / \"maps\"\nOUT.mkdir(exist_ok=True)\nW, H = 2048, 1024\nrng = np.random.default_rng(271900)\ny, x = np.mgrid[0:H,0:W]\nu,v=x/W,y/H\n\n\ndef field(sig):\n a=gaussian_filter(rng.standard_normal((H,W)),sig,mode=\"wrap\")\n return a/max(a.std(),1e-6)\n\n\ndef save(name,a):\n Image.fromarray(np.clip(np.round(a*255),0,255).astype(\"uint8\")).save(OUT/(name+\".png\"),optimize=True)\n\n\n# Vertical quarter-sawn figure with fine pores, mild flame and shaded lacquer at the shell edges.\nwave = .27*np.sin(2*np.pi*(2*u+.32*np.sin(2*np.pi*v)))+.10*field((38,26))\nwood = 0\nfor f,amp in [(17,.19),(38,.18),(79,.14),(153,.1),(321,.06)]:\n wood += np.sin(2*np.pi*(u*f+wave*(1+f/300)+rng.random()))*amp\ngrain = field((23,.7))\npores = np.maximum(field((3.5,.53))-1.1,0)**1.35\nflame = np.sin(2*np.pi*(v*10+.42*np.sin(2*np.pi*(5*u+v*.22))+.16*field((44,50))))\nbands = .86+.12*wood+.026*grain-.018*pores+.045*flame\nedges = (np.abs(v-.5)*2)**3.2\ncolor = np.clip(bands,.45,1.)[:,:,None]*np.array([.76,.425,.193])\ncolor *= (1-edges[:,:,None]*np.array([.24,.39,.46]))\nsave(\"maple-color\",color)\nsave(\"maple-roughness\",.29+.017*grain+.032*pores+.018*field((14,20)))\n\n# Coated head. Stick wear is concentrated where a player would strike, with softer irregular marks toward the rim.\ndx,dy=u-.49,v-.49\nr=np.sqrt((dx*1.12)**2+(dy*.89)**2)\ncenter=np.exp(-(r/.20)**2)\nsmall=field((1.4,1.4))\nbroad=field((24,30))\ndust=np.maximum(field((2.8,3.8))-1.3,0)\nmark=Image.new(\"L\",(W,H))\nd=ImageDraw.Draw(mark)\nfor n in range(215):\n xx,yy=rng.normal([W*.49,H*.49],[W*.125,H*.155])\n width=rng.uniform(2,24)\n height=rng.uniform(1.7,9)\n d.ellipse((xx-width,yy-height,xx+width,yy+height),fill=int(rng.uniform(7,48)))\nwear=gaussian_filter(np.asarray(mark)/255.,(1.05,2.05))\nlighting_free=.955-.066*center-.17*center*wear-.044*center*dust-.012*small-.009*broad\nlighting_free-=.045*np.clip((r-.425)*11,0,1)\nsave(\"head-color\",lighting_free[:,:,None]*np.array([1,.977,.923]))\nsave(\"head-roughness\",.63-.11*center-.10*wear+.055*small)\nh=(.0017*small+.0008*field((.46,.65))) / (1+.8*center)\ngy,gx=np.gradient(h)\nnormal=np.stack([-gx*15,-gy*15,np.ones_like(h)],2)\nnormal/=np.linalg.norm(normal,axis=2,keepdims=True)\nsave(\"head-normal\",.5+.5*normal)\n\n# Lightly streaked nickel, retained as a roughness-only map.\nsave(\"nickel-roughness\",.235+.012*field((.60,10))+.015*field((16,35))+.025*dust)\n```\n\n```python\n# marlowe.py\n\"\"\"Original Marlowe 14 maple snare in Blender, with dimensions specified in mm.\"\"\"\nfrom math import cos, pi, sin, sqrt\nfrom pathlib import Path\nimport sys\n\nimport bpy\nimport bmesh\nfrom mathutils import Matrix, Vector\n\nROOT=Path(__file__).resolve().parent\nSTEM=\"3d-dataset-20261127T1900Z-musical-instruments-marlowe-maple-snare\"\nDEST=Path(sys.argv[sys.argv.index(\"--\")+1]) if \"--\" in sys.argv else ROOT\nDEST.mkdir(parents=True,exist_ok=True)\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\n\n\ndef material(name,color,metal,roughness,maps=None,coat=0):\n mat=bpy.data.materials.new(name)\n mat.diffuse_color=(*color,1)\n mat.use_nodes=True\n nt=mat.node_tree\n shader=nt.nodes.get(\"Principled BSDF\")\n for key,val in {\"Base Color\":(*color,1),\"Metallic\":metal,\"Roughness\":roughness,\n \"Coat Weight\":coat,\"Coat Roughness\":.28}.items():\n shader.inputs[key].default_value=val\n for prop, image_name in (maps or {}).items():\n src=nt.nodes.new(\"ShaderNodeTexImage\")\n src.image=bpy.data.images.load(str(ROOT/\"maps\"/(image_name+\".png\")),check_existing=True)\n src.image.colorspace_settings.name=\"sRGB\" if prop==\"Base Color\" else \"Non-Color\"\n if prop==\"Normal\":\n normal=nt.nodes.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value=.55\n nt.links.new(src.outputs[\"Color\"],normal.inputs[\"Color\"])\n nt.links.new(normal.outputs[\"Normal\"],shader.inputs[prop])\n else:\n nt.links.new(src.outputs[\"Color\"],shader.inputs[prop])\n return mat\n\n\nmaple=material(\"Honeyburst maple · satin lacquer\",(.38,.16,.045),0,.3,\n {\"Base Color\":\"maple-color\",\"Roughness\":\"maple-roughness\"},.32)\ninner=material(\"Natural maple · inner plies\",(.43,.27,.125),0,.47)\nply=[material(\"Bearing edge · ply \"+str(i),(.32+i*.041,.156+i*.028,.058+i*.012),0,.45)\n for i in range(5)]\nnickel=material(\"Satin nickel · brushed hardware\",(.66,.69,.69),1,.23,{\"Roughness\":\"nickel-roughness\"})\nchrome=material(\"Polished nickel · rolled hoops\",(.73,.77,.81),1,.145)\ncarbon=material(\"Blackened steel · seams and rests\",(.016,.018,.020),.69,.33)\nrubber=material(\"Black rubber · lug gaskets\",(.013,.016,.016),0,.55)\nhead=material(\"Ivory coated batter head · played-in\",(.84,.80,.71),0,.61,\n {\"Base Color\":\"head-color\",\"Roughness\":\"head-roughness\",\"Normal\":\"head-normal\"})\nresonant=material(\"Smoky pearl resonant head\",(.37,.41,.43),.05,.34,coat=.18)\nink=material(\"Slate drumhead ink\",(.046,.053,.052),0,.72)\nbrass=material(\"Fine brushed brass · maker's badge\",(.62,.40,.17),.88,.31)\nbadge_base=material(\"Badge · dark teal enamel\",(.021,.088,.083),.2,.31,coat=.2)\nwire=material(\"Spring steel · snare wires\",(.30,.32,.34),1,.22)\n\n\ndef obj(name,verts,faces,mat,smooth=False,coords=None):\n me=bpy.data.meshes.new(name)\n me.from_pydata([tuple(Vector(v)*.001) for v in verts],[],faces)\n me.update()\n ob=bpy.data.objects.new(name,me)\n scene.collection.objects.link(ob)\n me.materials.append(mat)\n uv=me.uv_layers.new(name=\"Surface\")\n for face in me.polygons:\n face.use_smooth=smooth\n for i in face.loop_indices:\n n=me.loops[i].vertex_index\n uv.data[i].uv=coords[n] if coords else (verts[n][0]/44+.5,verts[n][2]/105+.5)\n return ob\n\n\ndef lathe(name,profile,mat,n=192,loop=True,uv_range=None,smooth=True):\n verts=[(r*cos(2*pi*i/n),r*sin(2*pi*i/n),z) for r,z in profile for i in range(n)]\n faces=[]\n for j in range(len(profile) if loop else len(profile)-1):\n k=(j+1)%len(profile)\n for i in range(n):\n nxt=(i+1)%n\n faces.append((j*n+i,j*n+nxt,k*n+nxt,k*n+i))\n ob=obj(name,verts,faces,mat,smooth)\n uv=ob.data.uv_layers.active\n if uv_range:\n zmin,zmax=uv_range\n for p in ob.data.polygons:\n j,i=divmod(p.index,n)\n k=(j+1)%len(profile)\n for loop_id,(col,row) in zip(p.loop_indices,[(i,j),(i+1,j),(i+1,k),(i,k)]):\n uv.data[loop_id].uv=(col/n,(profile[row][1]-zmin)/(zmax-zmin))\n return ob\n\n\ndef disk(name,r,center,rim,mat,down=False):\n n,steps=144,26\n verts=[(0,0,center)]\n for j in range(1,steps+1):\n t=j/steps\n z=center+(rim-center)*t**2\n verts.extend((r*t*cos(2*pi*i/n),r*t*sin(2*pi*i/n),z) for i in range(n))\n faces=[(0,i+1,(i+1)%n+1) for i in range(n)]\n for j in range(steps-1):\n start=1+j*n\n for i in range(n):\n nxt=(i+1)%n\n faces.append((start+i,start+n+i,start+n+nxt,start+nxt))\n if down:\n faces=[tuple(reversed(f)) for f in faces]\n return obj(name,verts,faces,mat,True,[(x/(r*2)+.5,y/(r*2)+.5) for x,y,_ in verts])\n\n\ndef bevel(ob,mm,segments=3):\n b=ob.modifiers.new(\"Machined edge radius\",\"BEVEL\")\n b.width=mm*.001\n b.segments=segments\n norm=ob.modifiers.new(\"Face-weighted normals\",\"WEIGHTED_NORMAL\")\n norm.keep_sharp=True\n return ob\n\n\ndef block(name,dim,mat,rounding,location=(0,0,0)):\n a,b,c=(d/2 for d in dim)\n o=obj(name,[(-a,-b,-c),(a,-b,-c),(a,b,-c),(-a,b,-c),(-a,-b,c),(a,-b,c),(a,b,c),(-a,b,c)],\n [(3,2,1,0),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7),(4,5,6,7)],mat)\n bevel(o,rounding)\n o.location=Vector(location)*.001\n return o\n\n\ndef pill(name,path,depth,mat,rad):\n n=len(path)\n verts=[(x,y,z) for y in [-depth/2,depth/2] for x,z in path]\n faces=[tuple(range(n)),tuple(range(n,2*n))[::-1]]\n for i in range(n):\n j=(i+1)%n\n faces.append((j,i,i+n,j+n))\n return bevel(obj(name,verts,faces,mat),rad)\n\n\ndef cylinder(name,r,depth,mat,loc=(0,0,0),n=40,rad=.3):\n bpy.ops.mesh.primitive_cylinder_add(vertices=n,radius=r*.001,depth=depth*.001,\n location=Vector(loc)*.001)\n ob=bpy.context.object\n ob.name=name\n ob.data.materials.append(mat)\n for p in ob.data.polygons:\n if len(p.vertices)==4:\n p.use_smooth=True\n return bevel(ob,rad) if rad else ob\n\n\ndef place(ob,angle,radius,z):\n twist=angle+pi/2\n ob.location=Vector((radius*cos(angle),radius*sin(angle),z))*.001\n ob.rotation_euler.z=twist\n return ob\n\n\n# Bent laminated shell: lacquered outer face, inner maple, and exposed stepped bearing edges.\nlathe(\"Lacquered maple shell\",[(174.4,19),(175.5,20.7),(175.5,169.1),(174.6,171.4)],\n maple,256,False,(18,172))\nlathe(\"Shell interior and cut bearing edges\",[(174.4,19),(173,17.5),(169.1,17.5),(167.4,21.8),\n (167.4,167.4),(169.1,172.4),(173,172.4),(174.6,171.4)][::-1],inner,192,False)\nfor i,m in enumerate(ply):\n r=169.35+i*.81\n for z in [17.52,172.38]:\n lathe(\"Exposed maple ply\",[(r,z-.1),(r+.25,z-.09),(r+.25,z+.09),(r,z+.10)],m,128)\n# Membranes and dark compressed edges under the hoops.\ndisk(\"Ivory batter membrane\",179.8,176.6,177.25,head)\ndisk(\"Pearl snare-side membrane\",179.1,13.1,12.55,resonant,True)\nlathe(\"Top bearing shadow\",[(174.2,167.1),(179.8,167.1),(181.1,168.5),(181.1,172.0),(175.4,172.1)],carbon)\nlathe(\"Lower bearing shadow\",[(174.2,17.2),(179.7,17.2),(181.3,18.8),(181.3,21.8),(175.4,22.2)],carbon)\nfor z,sgn in [(171,1),(19,-1)]:\n section=[(175.8,-5.5),(183.7,-5.5),(186,-4.5),(187,-3.0),(187,-.6),\n (185.4,1.7),(183.6,2.4),(183.2,6.8),(184.2,8.6),(184.15,9.7),\n (183.1,10.8),(181.3,10.8),(180.2,9.6),(180.2,4.7),(180.1,1.4),\n (179.5,-.15),(175.8,-2.4)]\n poly=[(r,z+sgn*d) for r,d in section]\n lathe(\"Top triple-flange nickel hoop\" if sgn==1 else \"Bottom triple-flange nickel hoop\",\n poly if sgn==1 else poly[::-1],chrome,256)\n trace=[(180.55,z+sgn*4.1),(181.04,z+sgn*4.1),(181.04,z+sgn*5.4),(180.55,z+sgn*5.4)]\n lathe(\"Dark drawn hoop seam\",trace if sgn==1 else trace[::-1],carbon,192)\n\n# Tension hardware. The same components repeat around the shell; each has true depth.\nangles=[-pi/2+pi/10+i*2*pi/10 for i in range(10)]\nlug_path=[(-7.9,-33),(7.9,-33),(10.6,-25),(11.3,-11),(10.5,0),(11.3,11),\n (10.6,25),(7.9,33),(-7.9,33),(-10.6,25),(-11.3,11),(-10.5,0),(-11.3,-11),(-10.6,-25)]\nfor i,a in enumerate(angles,1):\n place(pill(f\"Lug {i:02d} · die-cast housing\",lug_path,15,nickel,2.1),a,182,95)\n place(block(\"Compression gasket\",(20.6,3.5,62),rubber,2),a,175.4,95)\n place(block(\"Lug central inset\",(10.8,1.6,32),carbon,1.15),a,189.65,95)\n place(block(\"Raised lug spine\",(4.7,1.45,29),chrome,.67),a,190.4,95)\n for sign in (-1,1):\n z=95+sign*49\n place(cylinder(\"Threaded insert collar\",5.2,12.2,nickel,rad=.57),a,188.25,95+sign*30)\n place(cylinder(\"Dark lug bushing\",4.5,2.6,carbon,rad=.2),a,188.255,95+sign*36)\n place(cylinder(\"Tension rod · exposed shank\",2.55,42.5,chrome,rad=.24),a,188.25,z+sign*4.5)\n for k in range(5):\n place(cylinder(\"Rolled thread crest\",2.73,.43,nickel,n=24,rad=.09),a,188.25,95+sign*(37.9+k*1.15))\n place(block(\"Hoop ear reinforcement\",(18,14.0,4.6),chrome,1.8),a,186.4,95+sign*74)\n place(cylinder(\"Tension washer\",5.3,1.35,nickel,rad=.17),a,188.25,95+sign*77.5)\n place(block(\"Square tuning key head\",(6.6,6.6,4.7),chrome,.44),a,188.25,95+sign*80.0)\n\n\ndef label(name,body,size,mat,x=0,y=0,z=0,vertical=False,space=1.05):\n c=bpy.data.curves.new(name,\"FONT\")\n c.body=body\n c.size=size*.001\n c.align_x=\"CENTER\"\n c.align_y=\"CENTER\"\n c.space_character=space\n c.resolution_u=8\n o=bpy.data.objects.new(name,c)\n scene.collection.objects.link(o)\n o.location=Vector((x,y,z))*.001\n if vertical:\n o.rotation_euler.x=pi/2\n c.materials.append(mat)\n return o\n\n# Branded hardware and original identity face the nominal front.\nbadge=[(-30,-8),(-24,-13),(24,-13),(30,-8),(30,8),(24,13),(-24,13),(-30,8)]\nplace(pill(\"Numbered brass badge\",badge,2.5,brass,.7),-pi/2,175.55,99)\nplace(pill(\"Teal enamel inset\",[(x*.925,z*.795) for x,z in badge],.75,badge_base,.34),-pi/2,177.13,99)\nlabel(\"Marlowe badge lettering\",\"M A R L O W E\",5.0,brass,0,-177.55,101.8,True)\nlabel(\"Marlowe badge specification\",\"MAPLE / 14\",2.65,brass,0,-177.55,95.1,True)\nfor x in [-25,25]:\n b=cylinder(\"Badge pin\",1.35,1.3,chrome,(x,-177.5,99),24,.28)\n b.rotation_euler.x=pi/2\n\nlabel(\"Drumhead logo\",\"M A R L O W E\",9.8,ink,0,132,177.02,False,1.12)\nlabel(\"Drumhead model line\",\"COATED / SERIES 14\",3.3,ink,0,121,177.01,False,1.1)\n# Raised but low profile underside mechanism and actual helical snare wires.\nrelease_angle=-.31\nplace(block(\"Throw-off faceplate\",(36,7.8,64),nickel,3.4),release_angle,178.3,65)\nplace(block(\"Throw-off insulation pad\",(31.5,2.3,58),rubber,2),release_angle,175.3,65)\nplace(block(\"Throw-off slide\",(16.8,10,37),chrome,2.4),release_angle,185,59)\nplace(block(\"Throw-off lever\",(12,11.7,43.0),carbon,2.8),release_angle,196,87).rotation_euler.y=.22\nplace(cylinder(\"Tension adjuster\",8.6,9.0,nickel,rad=1.05),release_angle,190,112)\nfor k in range(20):\n a=k*2*pi/20\n p=release_angle+pi/2\n center=Vector((190*cos(release_angle),190*sin(release_angle),112))\n ob=block(\"Adjuster knurl\",(.95,1.05,6.3),chrome,.22,\n tuple(center+Vector((8.52*cos(a+p),8.52*sin(a+p),0))))\n ob.rotation_euler.z=a+p\nplace(block(\"Opposite strap butt plate\",(37,7.2,31),nickel,2.7),release_angle+pi,178.6,40)\nfor k in range(2):\n place(block(\"Snare webbing tab\",(33,50,1.55),rubber,.44),release_angle+k*pi,150,10.8)\n place(block(\"Crimped snare wire end plate\",(42,16,1.9),brass,.62),release_angle+k*pi,128,10.55)\n\ndef cable(name,path,radius,material):\n c=bpy.data.curves.new(name,\"CURVE\")\n c.dimensions=\"3D\"\n c.bevel_depth=radius*.001\n c.bevel_resolution=1\n c.use_fill_caps=True\n spl=c.splines.new(\"POLY\")\n spl.points.add(len(path)-1)\n for point,v in zip(spl.points,path):\n point.co=(*[k*.001 for k in v],1)\n o=bpy.data.objects.new(name,c)\n scene.collection.objects.link(o)\n c.materials.append(material)\n return o\n\nfor i in range(20):\n points=[]\n for n in range(465):\n t=n/464\n a=t*2*pi*58\n d=-123+246*t\n lateral=(i-9.5)*1.96+.51*cos(a)\n z=10.75+.48*sin(a)\n points.append((d*cos(release_angle)-lateral*sin(release_angle),\n d*sin(release_angle)+lateral*cos(release_angle),z))\n cable(\"Helical snare strand\",points,.174,wire)\n\n# Source retains editable text and curves. The GLB tessellates those objects on export.\nfor o in scene.objects:\n o.location.z -= .0082\n o.select_set(True)\nbpy.context.view_layer.objects.active=bpy.data.objects[\"Lacquered maple shell\"]\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(DEST/\"marlowe-maple-snare.blend\"),compress=True)\n# Merge the delivery by material to keep the Three.js draw-call count low.\nbpy.ops.object.convert(target=\"MESH\")\nby_material={}\nfor ob in scene.objects:\n mat=ob.data.materials[0]\n by_material.setdefault(mat.name,[]).append(ob)\n\nfor name, parts in by_material.items():\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in parts:\n ob.select_set(True)\n bpy.context.view_layer.objects.active=parts[0]\n if len(parts)>1:\n bpy.ops.object.join()\n bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\n ob=bpy.context.object\n ob.name=name\n if name in (carbon.name,rubber.name,brass.name,ink.name):\n mesh=bmesh.new()\n mesh.from_mesh(ob.data)\n bmesh.ops.triangulate(mesh,faces=list(mesh.faces))\n cutoff=1e-10 if name==ink.name else 1e-13\n tiny=[face for face in mesh.faces if face.calc_area() < cutoff]\n bmesh.ops.delete(mesh,geom=tiny,context=\"FACES_ONLY\")\n mesh.to_mesh(ob.data)\n mesh.free()\n\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.export_scene.gltf(filepath=str(DEST/(STEM+\".glb\")),export_format=\"GLB\",\n use_selection=True,export_apply=True,export_yup=True)\n```\n\nrun it: `python3 maps.py` then `blender -b --python marlowe.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T1900Z-musical-instruments-marlowe-maple-snare.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/marlowe-maple-snare/3d-dataset-20261127T1900Z-musical-instruments-marlowe-maple-snare.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/moonwake-crescent-stage-scepter.jpg"}}, {"type": "text", "text": "create an image of a moonwake crescent stage scepter"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA theatrical display scepter lying at an angle. The top is a large rounded crescent in gold with blue enamel panel cells, fine gilt lines and small studs. A pale glazed porcelain orb sits inside the crescent, held by two curved gold ribbons and wrapped in gold orbit strips. Below, a gold collar with grooves and a blue sleeve, a slate-blue woven grip with a stitched seam, and a gold pommel with a blue bead at the end.\n\nSCALE\nAbout 19 cm wide, 59 cm tall, 65 mm deep. Build in meters, +Y up, +Z forward, origin at the bottom center of the upright prop.\n\nPARTS\n1. Crescent: solid rounded crescent casting with a panel surround, dark gasket, indigo enamel cells, a continuous gilt hairline, embossed comets and small brass seeds. Build: crescent surface from two arcs with thickness, enamel cells inset along its length.\n2. Orb mount: two rounded ribbons with fine gilt edges and a sculpted pearl seat. Build: tubes swept along curves.\n3. Orb: glazed porcelain sphere with brass orbit filigree on its lower half. Build: UV sphere plus thin strips that follow the sphere surface.\n4. Crown saddle: broad rounded saddle joining the casting to the top collar, with a gilt rivet. Build: lathed flare with a small cylinder for the rivet.\n5. Shaft and collar: upper shaft, blue collar sleeve, turned gold collar with a patina groove. Build: lathe profiles.\n6. Grip and pommel: woven midnight grip with a raised seam, sage whip stitch and a bound braid, then a rounded pommel with a blue bead and a bright edge. Build: milled cylinder for the weave, a stitch path, lathe for the pommel.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the bottom center with the scepter upright.\n2. Texture maps: run maps.py first for the patinated brass, clouded enamel, porcelain glaze and woven grip maps.\n3. Build order: crescent casting and enamel, orb ribbons and seat, orb and orbit strips, pommel, grip, shaft and collar, crown saddle.\n4. Assemble: shaft runs straight up the Y axis, the collar sits on top of the grip, the saddle joins the collar to the crescent base, the ribbons hold the orb inside the crescent opening. Batch it into a small set of display meshes.\n5. Materials: aged brass effect, hand-burnished brass, oxidized brown grooves, clouded indigo enamel, pale blue enamel, moon porcelain glaze, midnight indigo woven grip, deep blue resin, sage thread.\n6. Export: scepter only, one GLB with the textures embedded.\n\nCHECK\n119,696 triangles across 9 parts. Against the image: crescent about a third of the total length, orb sits inside the crescent's curve, grip longer than the collar section.\n\n\n```python\n# maps.py\n\"\"\"Generate the original faux-brass, enamel, grip and porcelain maps.\"\"\"\nfrom pathlib import Path\n\nimport numpy as np\nfrom PIL import Image, ImageDraw\nfrom scipy.ndimage import gaussian_filter\n\nOUT=Path(__file__).resolve().parent / \"maps\"\nOUT.mkdir(exist_ok=True)\nW,H=1536,1024\nY,X=np.mgrid[0:H,0:W]\nu,v=X/W,Y/H\nrng=np.random.default_rng(272000)\n\n\ndef noise(sig):\n a=gaussian_filter(rng.standard_normal((H,W)),sig,mode=\"wrap\")\n return a/a.std()\n\n\ndef save(name,a):\n Image.fromarray(np.clip(np.round(a*255),0,255).astype(\"uint8\")).save(OUT/(name+\".png\"))\n\n\nscratches_image=Image.new(\"L\",(W,H))\npen=ImageDraw.Draw(scratches_image)\nfor i in range(1150):\n x,y=rng.uniform(0,[W,H])\n length=rng.uniform(4,68)\n slope=rng.normal(0,.17)\n w=int(rng.uniform(12,155))\n pen.line((x,y,x+length,y+length*slope),fill=w,width=1)\nscratches=gaussian_filter(np.asarray(scratches_image)/255.,.5)\nbrass_noise=.029*noise((.55,5.7))+.029*noise((23,25))-.14*scratches\noxidation=np.maximum(noise((3,7))-.58,0)*.04\nsave(\"brass-color\",np.array([.80,.572,.27])*(1+brass_noise[:,:,None]-oxidation[:,:,None]))\nsave(\"brass-roughness\",.29+.021*noise((.8,7.2))+.026*noise((9,11))+.31*scratches)\nenamel_clouds=.105*noise((27,24))+.056*noise((7,8))+.023*noise((1.5,1.6))\nsave(\"indigo-color\",np.array([.085,.213,.348])*(1+enamel_clouds[:,:,None]))\nsave(\"indigo-roughness\",.202+.032*noise((12,16))+.021*noise((1,2))+.12*scratches)\n\n# Woven, indigo-dyed fabric on the short grip.\nwarp=np.cos(u*2*np.pi*237)\nweft=np.cos(v*2*np.pi*113)\nweave=.55*warp*weft+.23*warp+.22*weft\nbase=.9+.095*weave+.038*noise((2,2))\nsave(\"cloth-color\", np.array([.104,.142,.172])*base[:,:,None])\nhh=.016*weave+.002*noise((.52,.51))\ngy,gx=np.gradient(hh)\nnormal=np.stack([-gx*9,-gy*9,np.ones_like(hh)],2)\nnormal/=np.linalg.norm(normal,axis=2,keepdims=True)\nsave(\"cloth-normal\",.5+.5*normal)\n\n# Directional layers in the decorative glazed porcelain orb.\nflow=v*13+.41*np.sin(2*np.pi*(u*3+v*.28))+.24*noise((31,57))\nstriations=.5+.5*np.sin(2*np.pi*flow)\ncloud=.04*noise((19,32))+.024*noise((5,9))\nblue=np.array([.35,.65,.72])\ncream=np.array([.89,.84,.69])\ncolor=cream*(.45+.45*striations[:,:,None])+blue*(.55-.45*striations[:,:,None])\nsave(\"porcelain-color\", color+cloud[:,:,None])\n```\n\n```python\n# moonwake.py\n\"\"\"Original Moonwake theatrical scepter. All internal design dimensions are in mm.\"\"\"\nfrom math import cos, pi, sin, sqrt\nfrom pathlib import Path\nimport sys\n\nimport bpy\nfrom mathutils import Vector\n\nHERE=Path(__file__).resolve().parent\nOUT=Path(sys.argv[sys.argv.index(\"--\")+1]) if \"--\" in sys.argv else HERE\nSTEM=\"3d-dataset-20261127T2000Z-weapons-moonwake-crescent-stage-scepter\"\nOUT.mkdir(parents=True,exist_ok=True)\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\n\n\ndef material(name,color,metal,rough,images=None,coat=0):\n mat=bpy.data.materials.new(name)\n mat.diffuse_color=(*color,1)\n mat.use_nodes=True\n nodes=mat.node_tree\n p=nodes.nodes.get(\"Principled BSDF\")\n for key,val in {\"Base Color\":(*color,1),\"Metallic\":metal,\"Roughness\":rough,\n \"Coat Weight\":coat,\"Coat Roughness\":.2}.items():\n p.inputs[key].default_value=val\n for key,name in (images or {}).items():\n t=nodes.nodes.new(\"ShaderNodeTexImage\")\n t.image=bpy.data.images.load(str(HERE/\"maps\"/(name+\".png\")),check_existing=True)\n t.image.colorspace_settings.name=\"sRGB\" if key==\"Base Color\" else \"Non-Color\"\n if key==\"Normal\":\n n=nodes.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=.65\n nodes.links.new(t.outputs[\"Color\"],n.inputs[\"Color\"])\n nodes.links.new(n.outputs[\"Normal\"],p.inputs[key])\n else:\n nodes.links.new(t.outputs[\"Color\"],p.inputs[key])\n return mat\n\n\nbrass=material(\"Aged brass effect · patinated resin\",(.52,.32,.106),1,.29,\n {\"Base Color\":\"brass-color\",\"Roughness\":\"brass-roughness\"})\ngold=material(\"Hand-burnished brass effect\",(.68,.45,.177),1,.245)\ndark=material(\"Oxidized brown effect\",(.113,.062,.031),.75,.43)\nenamel=material(\"Indigo enamel effect · clouded\",(.035,.081,.141),0,.26,\n {\"Base Color\":\"indigo-color\",\"Roughness\":\"indigo-roughness\"},.3)\nceladon=material(\"Pale blue enamel effect\",(.055,.165,.20),0,.25,coat=.27)\ndeep=material(\"Deep blue molded resin\",(.018,.035,.062),0,.31,coat=.17)\ncloth=material(\"Midnight indigo woven grip\",(.041,.055,.064),0,.63,\n {\"Base Color\":\"cloth-color\",\"Normal\":\"cloth-normal\"})\nthread=material(\"Sage trim thread\",(.16,.184,.169),0,.69)\npearl=material(\"Moon porcelain · glaze effect\",(.58,.68,.67),0,.225,{\"Base Color\":\"porcelain-color\"},.29)\n\n\ndef mesh(name,verts,faces,mat,uvs=None,smooth=False):\n me=bpy.data.meshes.new(name)\n me.from_pydata([Vector(v)*.001 for v in verts],[],faces)\n me.update()\n ob=bpy.data.objects.new(name,me)\n scene.collection.objects.link(ob)\n me.materials.append(mat)\n uv=me.uv_layers.new(name=\"Surface\")\n for p in me.polygons:\n p.use_smooth=smooth\n for ln in p.loop_indices:\n i=me.loops[ln].vertex_index\n uv.data[ln].uv=uvs[i] if uvs else (verts[i][0]/220+.5,verts[i][2]/225)\n return ob\n\n\ndef cubic(points,t):\n return sum((v*k for v,k in zip(points,[(1-t)**3,3*(1-t)**2*t,3*(1-t)*t*t,t**3])),points[0]*0)\n\n\nouter=[[ (66,570), (6,610),(-97,585),(-102,505)],\n [(-102,505),(-108,419),(9,358),(91,393)]]\ninner=[[(62,564),(8,572),(-39,548),(-43,505)],\n [(-43,505),(-47,452),(10,404),(87,398)]]\nouter=[[Vector(v) for v in pts] for pts in outer]\ninner=[[Vector(v) for v in pts] for pts in inner]\n\n\ndef crescent_point(t,w,y):\n k=0 if t<=.5 else 1\n local=2*t-k\n outside=cubic(outer[k],local)\n inside=cubic(inner[k],local)\n x,z=outside.lerp(inside,w)\n taper=.34+.66*sin(pi*t)**.29\n return (x,y*taper,z)\n\n\ndef crescent(name,t0,t1,section,mat,steps=140):\n n=len(section)\n coords=[]\n verts=[]\n for i in range(steps+1):\n t=t0+(t1-t0)*i/steps\n for j,(w,y) in enumerate(section):\n verts.append(crescent_point(t,w,y))\n coords.append((t,w+(y/32 if j>=n//2 else -y/32)))\n faces=[]\n for i in range(steps):\n for j in range(n):\n k=(j+1)%n\n faces.append((i*n+j,i*n+k,(i+1)*n+k,(i+1)*n+j))\n # Winding corrected by pointing each cap away from the center.\n faces.append(tuple(reversed(range(n))))\n faces.append(tuple(range(steps*n,(steps+1)*n)))\n return mesh(name,verts,faces,mat,coords,True)\n\n\ncrescent(\"Solid rounded crescent casting\",0,1,[(0,0),(.019,5),(.058,9.4),(.115,11.3),(.18,12.1),\n (.82,12.1),(.90,10.9),(.953,8.9),(.988,4.1),(1,0),(.988,-4.1),(.953,-8.9),\n (.90,-10.9),(.82,-12.1),(.18,-12.1),(.115,-11.3),(.058,-9.4),(.019,-5)],brass)\nfor side in (-1,1):\n def signed(section):\n a=[(w,side*y) for w,y in section]\n return a if side==1 else a[::-1]\n crescent(\"Crescent panel surround\",.032,.969,signed([\n (.112,10.8),(.13,12.5),(.16,13.6),(.841,13.6),(.873,12.55),(.893,10.8)\n ]),gold)\n crescent(\"Dark panel gasket\",.052,.95,signed([\n (.161,13.3),(.176,13.84),(.823,13.84),(.842,13.34)\n ]),dark)\n for i in range(9):\n t0=.057+i*.0984\n t1=t0+.0919\n crescent(\"Indigo enamel cell\",t0,t1,signed([\n (.189,13.75),(.20,14.32),(.23,14.8),(.77,14.8),(.80,14.28),(.813,13.75)\n ]),enamel,25)\n\n\ndef tube(name, path, radius, mat, sides=8):\n coords=[]\n verts=[]\n for i,p in enumerate(path):\n p=Vector(p)\n before=Vector(path[max(0,i-1)])\n after=Vector(path[min(len(path)-1,i+1)])\n axis=(after-before).normalized()\n reference=Vector((0,1,0)) if abs(axis.y)<.90 else Vector((1,0,0))\n a=axis.cross(reference).normalized()\n b=axis.cross(a).normalized()\n for j in range(sides):\n ph=2*pi*j/sides\n verts.append(p+radius*(cos(ph)*a+sin(ph)*b))\n coords.append((i/max(len(path)-1,1),j/sides))\n f=[]\n for i in range(len(path)-1):\n n=i*sides\n for j in range(sides):\n k=(j+1)%sides\n f.append((n+j,n+k,n+sides+k,n+sides+j))\n f += [tuple(reversed(range(sides))), tuple(range(len(verts)-sides,len(verts)))]\n return mesh(name,verts,f,mat,coords,smooth=True)\n\n\ndef mill(name,r,x,y,z,mat,scales=(1,1,1),segments=36,rings=18):\n bpy.ops.mesh.primitive_uv_sphere_add(segments=segments,ring_count=rings,radius=r*.001,\n location=Vector((x,y,z))*.001)\n ob=bpy.context.object\n ob.name=name\n for axis,s in enumerate(scales):\n ob.scale[axis]=s\n ob.data.materials.append(mat)\n for face in ob.data.polygons:\n face.use_smooth=True\n return ob\n\n\nfor side in (-1,1):\n for w in (.171,.828):\n tube(\"Continuous gilt hairline\",[\n crescent_point(.055+.89*i/177,w,side*14.35) for i in range(178)],.38,gold)\n for i in range(9):\n center=.101+i*.0984\n for j in [-1,1]:\n p=[crescent_point(center+.036*t,.31+j*.078*(1-abs(t)),side*15.04)\n for t in [-1,-.75,-.5,-.25,0,.25,.5,.75,1]]\n tube(\"Embossed enamel comet\",p,.46,celadon,8)\n x,y,z=crescent_point(center,.634,side*15.1)\n mill(\"Brass enamel seed\",1.27,x,y,z,gold,(1,.47,1),16,8)\n\n# The glazed orb is held visibly by two rounded sculptural ribbons.\nfor side in (-1,1):\n start=Vector((-54,0,449))\n path=[]\n for i in range(70):\n t=i/69\n p=(1-t)**3*start+3*t*(1-t)**2*Vector((-17,side*17,431))+3*(1-t)*t*t*Vector((60,side*30,441))+t**3*Vector((55,side*17,475))\n path.append(p)\n tube(\"Rounded crescent-to-orb ribbon\",path,4.05,brass,16)\n tube(\"Fine gilt ribbon edge\",[v+Vector((0,side*3.51,.28)) for v in path],.65,gold,8)\n x,y,z=path[-1]\n mill(\"Sculpted pearl seat\",4.63,x,y,z,dark,(1.05,1,1.2),24,12)\nmill(\"Glazed Moonwake orb\",32.2,27,0,482.4,pearl,(1,1,1.008),128,64)\n# Embossed orbit strips follow the lower part of the sphere and are inert decoration.\nfor phase in (-.16,.16):\n a0,a1=-2.83,.51\n pts=[]\n for i in range(126):\n a=a0+(a1-a0)*i/125\n r=32.5\n pts.append((27+r*cos(a)*cos(phase),r*sin(a)*cos(phase),482.4+r*sin(phase)+r*cos(a)*.095))\n tube(\"Brass orbit filigree\",pts,.63,gold,8)\n\n\ndef lathe(name, profile,mat, center=-27,n=96,cap=False):\n verts=[(center+r*cos(2*pi*i/n),r*sin(2*pi*i/n),z) for r,z in profile for i in range(n)]\n m=len(profile)\n faces=[]\n for j in range(m-1):\n for i in range(n):\n k=(i+1)%n\n faces.append((j*n+i,j*n+k,(j+1)*n+k,(j+1)*n+i))\n if cap:\n faces.extend([tuple(reversed(range(n))),tuple(range((m-1)*n,m*n))])\n ob=mesh(name,verts,faces,mat,smooth=True)\n for p in ob.data.polygons[:(m-1)*n]:\n j,i=divmod(p.index,n)\n for loop,uv in zip(p.loop_indices,[(i,j),(i+1,j),(i+1,j+1),(i,j+1)]):\n lo=profile[0][1]\n hi=profile[-1][1]\n ob.data.uv_layers.active.data[loop].uv=(uv[0]/n,(profile[uv[1]][1]-lo)/(hi-lo))\n return ob\n\n\nlathe(\"Rounded pommel\",[(13,0),(16,1.1),(18.6,4.8),(19.6,8),(19,12),(17.3,15),\n (17.3,26),(18.6,30),(18.5,36),(16.5,41),(15.4,43)],brass,cap=True)\nlathe(\"Pommel blue montage bead\",[(17.3,16),(18.5,17),(18.75,20),(18.5,23),(17.3,24)],enamel)\nlathe(\"Pommel bright edge\",[(18.95,8),(19.74,8.8),(19.82,9.4),(19.4,10.4)],gold)\n\ngrip_profile=[]\nfor j in range(121):\n t=j/120\n r=15.5+1.3*sin(pi*t)+.18*sin(t*2*pi*11)\n grip_profile.append((r,42+t*250))\nlathe(\"Woven midnight grip\",grip_profile,cloth)\nfor side in (-1,1):\n path=[]\n for j in range(258):\n t=j/257\n z=50+232*t\n angle=side*1.27+.29*sin(2*pi*t)\n r=15.9+1.3*sin(pi*t)+.18*sin(t*2*pi*10.4)\n path.append((-27+r*cos(angle),r*sin(angle),z))\n tube(\"Raised woven grip seam\",path,.48,deep)\n for j in range(37):\n t=.022+.955*j/36\n z=50+232*t\n angle=side*1.27+.29*sin(2*pi*t)\n r=16.0+1.3*sin(pi*t)+.18*sin(t*2*pi*10.4)\n marks=[(-27+r*cos(angle+d),r*sin(angle+d),z+4*d) for d in [-.085,0,.085]]\n tube(\"Sage whip stitch\",marks,.34,thread,6)\nfor z in [42.4,46,284,287.6]:\n lathe(\"Bound grip braid\",[(15.55,z-.8),(16.25,z-.55),(16.44,z),(16.25,z+.48),(15.52,z+.79)],thread)\n\nlathe(\"Upper shaft body\",[(15.1,290),(17.7,293),(18.9,301),(18.8,304),(16.8,309),\n (15.5,316),(14.6,338),(15.3,362),(17.7,379),(18.7,388),(18.0,394),\n (14.6,398),(13.8,403),(11.6,415),(10.8,426)],brass,cap=True)\nlathe(\"Blue collar sleeve\",[(15.84,316),(16.35,317.4),(16.55,320),(15.8,333),\n (15.45,337),(14.7,338)],enamel)\nfor z,r in [(296.1,18.37),(301,18.88),(310.3,16.5),(338,15.26),(370.2,16.95),(383.2,18.65),(389,18.76)]:\n lathe(\"Turned gold collar\",[(r-.1,z-1.2),(r+.5,z-.61),(r+.64,z),(r+.43,z+.65),(r-.13,z+1.2)],gold)\nfor z,r in [(313.0,16.24),(343.4,15.06),(364.0,15.97),(377.12,17.6)]:\n lathe(\"Bronze patina groove\",[(r-.2,z-.52),(r+.10,z-.51),(r+.10,z+.5),(r-.2,z+.52)],dark)\n\n# A broad rounded saddle visibly joins the sculptural casting to the top collar.\nfor side in [-1,1]:\n v=[Vector((-25,side*9,382)),Vector((-28,side*13,389)),\n Vector((-34,side*13,413)),Vector((-43,side*8,431))]\n tube(\"Splayed crown saddle\", [cubic(v,i/40) for i in range(41)],4.3,brass,12)\n for x,z in [(-25,389),(-43,423)]:\n mill(\"Crown saddle gilt rivet\",2,x,side*13.9,z,gold,(1,.44,1),20,10)\n\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(OUT/\"moonwake-crescent.blend\"),compress=True)\n\n# Deliver a small set of batched display meshes and a centered base pivot.\nby_material={}\nfor ob in scene.objects:\n by_material.setdefault(ob.data.materials[0].name,[]).append(ob)\nfor mat,objects in by_material.items():\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in objects:\n ob.select_set(True)\n bpy.context.view_layer.objects.active=objects[0]\n if len(objects)>1:\n bpy.ops.object.join()\n bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\n ob=bpy.context.object\n ob.name=mat\n for v in ob.data.vertices:\n v.co.x+=.027\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.export_scene.gltf(filepath=str(OUT/(STEM+\".glb\")),export_format=\"GLB\",export_apply=True,\n use_selection=True,export_yup=True)\n```\n\nrun it: `python3 maps.py` then `blender -b --python moonwake.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T2000Z-weapons-moonwake-crescent-stage-scepter.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/moonwake-crescent-stage-scepter/3d-dataset-20261127T2000Z-weapons-moonwake-crescent-stage-scepter.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/saltline-e4-yard-tug.jpg"}}, {"type": "text", "text": "create an image of a saltline e4 electric yard tug"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA compact electric yard tug, front-left three-quarter view. Marine-teal steel body with rounded pressed panels, a tall glazed cab with an ivory roof and an amber beacon, an ochre grille surround between two square headlamps, a black front bumper with a plate, an \"E4\" decal with a \"SALTLINE / YARD DUTY\" stripe on the door, a seat and steering wheel visible through the glass, chunky industrial tires on ivory wheels, and a short rear deck with a tow hitch.\n\nSCALE\nAbout 145 cm wide, 197 cm tall, 2.8 m deep. Build in meters, +Y up, +Z forward, origin on the ground plane under the center of the chassis.\n\nPARTS\n1. Chassis and nose: welded drop-center frame, central battery enclosure, painted rockers, side steps with anti-slip ribs, axle spindles, pressed steel hood, grille pocket with rubber surround and ochre carrier. Build: beveled blocks and lofted sections.\n2. Cab shell: rear body, cowl, cream fascia strip, sloped A pillars, rear pillars, stamped doors with the cream ID stripe, ivory roof with a rolled lip and rain channel. Build: lofted panels and beams.\n3. Glazing: fitted clear windows with perimeter weather seals. Build: pane helper with thickness and an outline seal.\n4. Interior: instrument panel and binnacle with a digital display, dash buttons, isolation pedestal, molded seat with center pads, steering column and wheel, pedals. Build: blocks, rods and a lathed wheel.\n5. Wheels and mudguards: molded industrial tires with tread blocks and sidewall marks, ivory pressed wheel dishes, hubs and lugs, gently rolled steel mudguards. Build: lathe the tire and wheel profiles, repeat tread blocks around the circumference.\n6. Rear deck and lights: deck frame with a diamond-relief pad and rub rail, grab handle, bumper, hitch receiver and tow coupling, rear lamp carrier with red tail lenses, headlamps, beacon and graphics. Build: blocks, rods and text.\n\nPLAN\n1. Setup: clear the scene, meters, origin on the ground under the chassis center.\n2. Texture maps: run maps.py first for the teal paint, powder coat and their roughness maps.\n3. Build order: chassis and nose, cab shell, glazing, interior, wheels and mudguards, rear deck and lights.\n4. Assemble: cab sits on the chassis behind the hood, windows fit inside the pillar openings, the seat and wheel sit inside the cab, wheels sit on the axle spindles with the tires on the ground, deck bolts to the back of the frame. Batch the delivery to one draw primitive per material.\n5. Materials: marine-teal paint, charcoal powder coat, brushed zinc, deep teal seams, safety-ochre enamel, ivory graphics and roof, black EPDM gaskets, oil-resistant rubber, warm white reflectors, reeded lamp glass, amber beacon, red tail lens, safety glazing, graphite seat vinyl.\n6. Export: tug only, one GLB with the textures embedded.\n\nCHECK\n163,118 triangles across 17 parts. Against the image: cab is taller than the hood is long, the roof overhangs the cab slightly, wheels are big relative to the body, deck sits low at the back.\n\n\n```python\n# maps.py\n\"\"\"Procedural PBR maps for the Saltline E4 without external texture assets.\"\"\"\nfrom pathlib import Path\n\nimport numpy as np\nfrom PIL import Image, ImageDraw\nfrom scipy.ndimage import gaussian_filter\n\nOUT=Path(__file__).resolve().parent/\"maps\"\nOUT.mkdir(exist_ok=True)\nW=H=1024\ny,x=np.mgrid[0:H,0:W]\nu,v=x/W,y/H\nrng=np.random.default_rng(272100)\n\n\ndef noise(sigma):\n a=gaussian_filter(rng.standard_normal((H,W)),sigma,mode=\"wrap\")\n return a/a.std()\n\n\ndef save(name,a):\n Image.fromarray(np.clip(np.round(a*255),0,255).astype(\"uint8\")).save(OUT/(name+\".png\"))\n\n\nmist=noise(24)\norange_peel=noise(1.3)\npaint_scratches=Image.new(\"L\",(W,H))\nline=ImageDraw.Draw(paint_scratches)\nfor i in range(650):\n px,py=rng.uniform(0,W,2)\n length=rng.uniform(3,34)\n line.line((px,py,px+length,py+rng.uniform(-3,3)),fill=int(rng.uniform(8,92)),width=1)\nscratch=gaussian_filter(np.asarray(paint_scratches)/255,.55)\npaint_tone=1+.031*mist+.008*orange_peel\npaint_rgb=np.array([.117,.455,.466])*paint_tone[:,:,None]\npaint_rgb+=scratch[:,:,None]*np.array([.17,.10,.08])\nsave(\"teal-paint\",paint_rgb)\nsave(\"paint-roughness\",.29+.027*mist+.025*orange_peel+.21*scratch)\nsave(\"rubber-color\",np.stack([.112+.014*mist+.007*noise(.9)]*3,2))\nsave(\"rubber-roughness\",.72+.048*noise(5)+.033*noise(.75))\nweave=np.cos(u*2*np.pi*188)*np.cos(v*2*np.pi*153)\nh=.013*weave+.005*noise(.51)\ngy,gx=np.gradient(h)\nnormal=np.stack([-gx*8,-gy*8,np.ones_like(h)],2)\nnormal/=np.linalg.norm(normal,axis=2,keepdims=True)\nsave(\"seat-normal\",.5+.5*normal)\n# Powder coat mottling is visible in angled highlights on the kick plates.\nsave(\"powder-roughness\",.46+.035*noise((4.4,9))+.035*noise(.8)+.11*scratch)\n```\n\n```python\n# saltline.py\n\"\"\"Original Saltline E4 electric yard tug. Dimensions are specified in meters.\"\"\"\nfrom math import atan2, cos, pi, sin\nfrom pathlib import Path\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Matrix, Vector\n\nROOT=Path(__file__).resolve().parent\nOUT=Path(sys.argv[sys.argv.index(\"--\")+1]) if \"--\" in sys.argv else ROOT\nSTEM=\"3d-dataset-20261127T2100Z-vehicles-saltline-e4-yard-tug\"\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\n\n\ndef material(name,color,metal,rough,imgs=None,coat=0,trans=0,ior=1.46,emission=0):\n mat=bpy.data.materials.new(name)\n mat.diffuse_color=(*color,1)\n mat.use_nodes=True\n nt=mat.node_tree\n p=nt.nodes.get(\"Principled BSDF\")\n props={\"Base Color\":(*color,1),\"Metallic\":metal,\"Roughness\":rough,\"Coat Weight\":coat,\n \"Coat Roughness\":.16,\"Transmission Weight\":trans,\"IOR\":ior,\n \"Emission Color\":(*color,1),\"Emission Strength\":emission}\n for k,val in props.items():\n p.inputs[k].default_value=val\n for key,name in (imgs or {}).items():\n tex=nt.nodes.new(\"ShaderNodeTexImage\")\n tex.image=bpy.data.images.load(str(ROOT/\"maps\"/(name+\".png\")),check_existing=True)\n tex.image.colorspace_settings.name=\"sRGB\" if key==\"Base Color\" else \"Non-Color\"\n if key==\"Normal\":\n n=nt.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=.63\n nt.links.new(tex.outputs[\"Color\"],n.inputs[\"Color\"])\n nt.links.new(n.outputs[\"Normal\"],p.inputs[\"Normal\"])\n else:\n nt.links.new(tex.outputs[\"Color\"],p.inputs[key])\n return mat\n\n\nteal=material(\"Saltline marine teal · painted steel\",(.04,.24,.25),.33,.26,\n {\"Base Color\":\"teal-paint\",\"Roughness\":\"paint-roughness\"},.39)\nteal_dark=material(\"Deep teal seam enamel\",(.021,.113,.120),.39,.35,coat=.27)\ncream=material(\"Shell ivory · cab roof and wheel enamel\",(.74,.67,.51),.29,.31,coat=.27)\nochre=material(\"Safety ochre · baked enamel\",(.67,.31,.043),.23,.28,coat=.24)\nteal.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Coat Roughness\"].default_value=.25\ncream.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Coat Roughness\"].default_value=.25\nrubber=material(\"Oil-resistant rubber · tires and stops\",(.012,.014,.016),0,.72,\n {\"Base Color\":\"rubber-color\",\"Roughness\":\"rubber-roughness\"})\ntread=material(\"Raised tire lettering and siping\",(.033,.037,.039),0,.74)\npowder=material(\"Charcoal powder-coated steel\",(.034,.046,.052),.45,.48,{\"Roughness\":\"powder-roughness\"})\ngasket=material(\"Black EPDM gasket\",(.012,.017,.019),0,.58)\nzinc=material(\"Brushed zinc hardware\",(.48,.51,.51),.9,.32)\ncloth=material(\"Graphite woven seat vinyl\",(.067,.079,.079),0,.65,{\"Normal\":\"seat-normal\"})\nglass=material(\"Cab safety glazing\",(.837,.944,.953),0,.082,coat=.10,trans=1,ior=1.43)\nlens=material(\"Reeded lamp glass\",(.92,.94,.83),0,.15,coat=.25,trans=.83)\nlamp=material(\"Warm white lamp reflector\",(.94,.858,.56),.32,.25,emission=.17)\norange=material(\"Amber safety beacon lens\",(.93,.28,.018),.025,.23,coat=.43,emission=.09)\nred=material(\"Red tail-light lens\",(.36,.022,.037),.04,.25,coat=.45,emission=.05)\nink=material(\"Ivory block vinyl graphics\",(.89,.83,.62),0,.45)\ndarkink=material(\"Indigo-dark transfer and lettering\",(.017,.042,.057),0,.49)\nreflector=material(\"White safety reflector\",(.89,.79,.60),.22,.31)\n\n\ndef obj(name,verts,faces,mat,rounding=0,smooth=False,uv=None):\n me=bpy.data.meshes.new(name)\n me.from_pydata(verts,[],faces)\n me.update()\n ob=bpy.data.objects.new(name,me)\n scene.collection.objects.link(ob)\n me.materials.append(mat)\n tex=me.uv_layers.new(name=\"Surface\")\n for p in me.polygons:\n p.use_smooth=smooth\n for loop in p.loop_indices:\n i=me.loops[loop].vertex_index\n x,y,z=me.vertices[i].co\n tex.data[loop].uv=uv[i] if uv else (x*.91+y*.56+.5,z*.83+y*.73+.5)\n if rounding:\n bevel(ob,rounding)\n return ob\n\n\ndef bevel(ob,r,n=3):\n b=ob.modifiers.new(\"Rounded stamped edges\",\"BEVEL\")\n b.width=r\n b.segments=n\n nrm=ob.modifiers.new(\"Weighted corner normals\",\"WEIGHTED_NORMAL\")\n nrm.keep_sharp=True\n\n\ndef block(name,loc,dim,mat,r=.009):\n x,y,z=(t*.5 for t in dim)\n ob=obj(name,[(-x,-y,-z),(x,-y,-z),(x,y,-z),(-x,y,-z),(-x,-y,z),(x,-y,z),(x,y,z),(-x,y,z)],\n [(3,2,1,0),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7),(4,5,6,7)],mat,r)\n ob.location=loc\n return ob\n\n\ndef rod(name,a,b,r,mat,num=24,rounding=.0013):\n a,b=Vector(a),Vector(b)\n delta=b-a\n bpy.ops.mesh.primitive_cylinder_add(vertices=num,radius=r,depth=delta.length,location=(a+b)*.5)\n ob=bpy.context.object\n ob.name=name\n ob.rotation_mode=\"QUATERNION\"\n ob.rotation_quaternion=delta.to_track_quat(\"Z\",\"Y\")\n ob.data.materials.append(mat)\n for p in ob.data.polygons:\n if len(p.vertices)==4:\n p.use_smooth=True\n if rounding:\n bevel(ob,rounding)\n return ob\n\n\ndef beam(name,a,b,xw,yw,mat,r=.007):\n a,b=Vector(a),Vector(b)\n d=b-a\n ob=block(name,(a+b)*.5,(xw,yw,d.length),mat,r)\n ob.rotation_mode=\"QUATERNION\"\n ob.rotation_quaternion=d.to_track_quat(\"Z\",\"Y\")\n return ob\n\n\ndef pane(name,corners,mat,thickness=.006,r=.001):\n vectors=[Vector(p) for p in corners]\n normal=(vectors[1]-vectors[0]).cross(vectors[-1]-vectors[0]).normalized()\n n=len(corners)\n verts=[p+side*normal*thickness*.5 for side in [-1,1] for p in vectors]\n faces=[tuple(reversed(range(n))),tuple(range(n,n*2))]\n faces.extend((i,(i+1)%n,(i+1)%n+n,i+n) for i in range(n))\n return obj(name,verts,faces,mat,r)\n\n\ndef outline(corners,mat,r,name=\"Perimeter weather seal\"):\n for a,b in zip(corners,corners[1:]+corners[:1]):\n rod(name,a,b,r,mat,num=14,rounding=0)\n\n\ndef text(name,body,size,loc,mat,rotation=(pi/2,0,0),spacing=1.10):\n c=bpy.data.curves.new(name,\"FONT\")\n c.body=body\n c.size=size\n c.space_character=spacing\n c.align_x=c.align_y=\"CENTER\"\n c.resolution_u=8\n ob=bpy.data.objects.new(name,c)\n scene.collection.objects.link(ob)\n ob.location=loc\n ob.rotation_euler=rotation\n c.materials.append(mat)\n return ob\n\n\ndef yloft(name, sections, mat, r=.009):\n verts=[]\n for y,w,lo,hi in sections:\n verts.extend([(-w*.86,y,lo),(w*.86,y,lo),(w,y,lo+.045),(w,y,hi-.052),\n (w*.91,y,hi-.018),(w*.78,y,hi),(-w*.78,y,hi),\n (-w*.91,y,hi-.018),(-w,y,hi-.052),(-w,y,lo+.045)])\n n=10\n faces=[tuple(range(n))]\n for j in range(len(sections)-1):\n for i in range(n):\n k=(i+1)%n\n faces.append((j*n+k,j*n+i,(j+1)*n+i,(j+1)*n+k))\n faces.append(tuple(reversed(range(len(verts)-n,len(verts)))))\n return obj(name,verts,faces,mat,r)\n\n\n# Chassis, running boards and the pressed nose tank.\nblock(\"Welded drop-center frame\",(0,.02,.351),(.81,2.13,.29),powder,.039)\nblock(\"Central battery enclosure\",(0,.017,.286),(.80,.91,.20),powder,.020)\nblock(\"Lower battery pan\",(0,.015,.195),(.73,.88,.04),zinc,.011)\nfor x in [-.433,.433]:\n block(\"Painted lower rocker\",(x,.10,.51),(.123,1.52,.245),teal_dark,.019)\n block(\"Side step mounting plate\",(x*1.19,.047,.462),(.21,.70,.049),powder,.015)\n for j in range(13):\n block(\"Raised anti-slip step rib\",(x*1.28,-.252+j*.047,.490),(.14,.010,.006),zinc,.002)\n block(\"Rocker top rolled rail\",(x*1.17,.046,.566),(.12,.66,.039),teal,.012)\n for y in [-.79,.773]:\n rod(\"Axle spindle\",(0,y,.278),(x*1.32,y,.278),.068,zinc,num=36)\n\nhood_sections=[(-1.245,.475,.508,.863),(-1.217,.501,.500,.894),(-1.10,.507,.50,.925),\n (-.71,.512,.50,.969),(-.45,.516,.50,.998),(-.342,.501,.505,1.005)]\nyloft(\"Pressed steel hood shell\",hood_sections,teal,.015)\nyloft(\"Front grille pocket\",[(-1.262,.422,.571,.842),(-1.244,.441,.568,.850)],teal_dark,.007)\nblock(\"Front grille rubber surround\",(0,-1.267,.707),(.67,.032,.198),gasket,.019)\nblock(\"Safety ochre grille carrier\",(0,-1.284,.707),(.625,.018,.174),ochre,.017)\nblock(\"Radiator intake cavity\",(0,-1.296,.703),(.524,.014,.120),gasket,.009)\nfor i in range(14):\n block(\"Radiator cast slat\",(-.234+i*.036,-1.305,.703),(.020,.013,.105),powder,.0035)\nblock(\"Radiator center bridge\",(0,-1.315,.718),(.54,.011,.018),zinc,.0035)\nblock(\"Saltline nose emblem plate\",(0,-1.323,.758),(.214,.014,.041),powder,.007)\ntext(\"Nose script\",\"S A L T L I N E\",.023,(0,-1.331,.758),ink,spacing=.92)\nfor side in [-1,1]:\n x=side*.400\n block(\"Recessed headlamp socket\",(x,-1.251,.765),(.162,.044,.136),gasket,.018)\n block(\"Headlamp chrome bowl\",(x,-1.273,.765),(.140,.031,.116),zinc,.018)\n block(\"Headlamp pale reflector\",(x,-1.290,.765),(.112,.007,.088),lamp,.014)\n block(\"Reeded safety lens\",(x,-1.299,.765),(.117,.011,.093),lens,.012)\n for j in range(7):\n rod(\"Prismatic lamp flute\",(x-.041+j*.0135,-1.305,.732),(x-.041+j*.0135,-1.306,.793),\n .00155,lens,12,0)\n block(\"Marker beneath headlight\",(x,-1.268,.619),(.090,.017,.027),orange,.006)\n block(\"Nose bumper stop\",(side*.322,-1.337,.449),(.221,.085,.109),rubber,.015)\n for j in range(3):\n block(\"Bumper molded rib\",(side*.322,-1.384,.424+j*.024),(.191,.012,.009),tread,.003)\nblock(\"Front heavy box bumper\",(0,-1.252,.448),(1.107,.154,.136),powder,.023)\nblock(\"Front access plate\",(0,-1.337,.455),(.253,.024,.083),zinc,.007)\ntext(\"Axle plate embossed\",\"E4 / 027\",.036,(0,-1.350,.455),darkink)\n\n\n# Cab skins and a roof with an actual roof lip, above fitted clear windows.\nblock(\"Cab floor pan\",(0,.106,.647),(1.015,1.010,.105),powder,.021)\nblock(\"Cab rear body\",(0,.622,.713),(1.05,.127,.34),teal,.026)\nblock(\"Cowl base\",(0,-.349,.899),(1.007,.15,.282),teal,.025)\nblock(\"Cream painted fascia strip\",(0,-.434,.995),(.96,.021,.055),cream,.007)\nblock(\"Fascia seal ridge\",(0,-.456,1.028),(.905,.022,.013),gasket,.004)\nblock(\"Deep rolled roof edge\",(0,.166,1.776),(1.115,1.222,.078),teal_dark,.043)\nblock(\"Ivory steel roof\",(0,.156,1.823),(1.151,1.256,.112),cream,.048)\nfor x in [-.345,.345]:\n block(\"Roof rain channel rib\",(x,.173,1.878),(.025,1.034,.012),cream,.005)\nfor side in [-1,1]:\n x=side*.503\n beam(\"Sloped A pillar\",(x,-.406,1.018),(x,-.259,1.76),.064,.061,teal,.012)\n beam(\"Straight rear roof pillar\",(x,.617,.959),(x,.654,1.76),.063,.070,teal,.011)\n beam(\"Side window top rail\",(x,-.259,1.748),(x,.652,1.748),.067,.072,teal,.011)\n x1=side*.493\n plate=[(x1,-.417,.689),(x1,.613,.689),(x1,.613,1.074),(x1,-.400,1.074)]\n pane(\"Stamped cab door\",plate,teal,.065,.018)\n plate=[(side*.531,-.372,.707),(side*.531,.573,.707),(side*.531,.573,1.053),(side*.531,-.373,1.053)]\n outline(plate,teal_dark,.004,\"Door panel shadow seam\")\n stripe=[(side*.535,-.375,.778),(side*.535,.565,.778),(side*.535,.565,.833),(side*.535,-.375,.833)]\n pane(\"Cab side cream identification stripe\",stripe,cream,.004,.004)\n side_window=[(side*.514,-.367,1.100),(side*.514,.607,1.100),\n (side*.514,.627,1.708),(side*.514,-.242,1.708)]\n pane(\"Side window safety glass\",side_window,glass,.008,.001)\n outline(side_window,gasket,.014)\n beam(\"Sliding glass division\",(side*.527,.282,1.112),(side*.527,.300,1.710),.027,.025,teal_dark,.006)\n block(\"Side body upper bead\",(side*.527,.116,1.077),(.05,1.016,.038),teal,.010)\n block(\"Door handle base\",(side*.547,.459,1.014),(.026,.135,.052),gasket,.009)\n block(\"Brushed drop handle\",(side*.562,.450,1.020),(.022,.103,.028),zinc,.010)\n for y in [-.334,-.241]:\n block(\"Door hinge cover\",(side*.566,y,.925),(.039,.028,.064),teal_dark,.006)\n rotation=(pi/2,0,side*pi/2)\n text(\"Door livery number\",\"E4\",.129,(side*.535,.065,.928),ink,rotation,1.02)\n text(\"Cream stripe typography\",\"S A L T L I N E / Y A R D D U T Y\",.030,\n (side*.539,.092,.804),darkink,rotation,.98)\n block(\"Service socket surround\",(side*.544,.510,.728),(.022,.086,.052),teal_dark,.010)\n rod(\"Mirror arm\",(side*.538,-.339,1.520),(side*.671,-.368,1.539),.013,gasket)\n block(\"Side mirror housing\",(side*.680,-.374,1.560),(.089,.047,.116),powder,.018)\n block(\"Side mirror\",(side*.681,-.348,1.563),(.068,.009,.085),zinc,.013)\n for j in range(8):\n block(\"Hood side cooling louver\",(side*.515,-1.040+j*.071,.814),(.015,.041,.115),\n teal_dark,.006).rotation_euler.x=-.20\n block(\"Hood side amber cover\",(side*.516,-.644,.620),(.013,.255,.066),ochre,.008)\n text(\"Battery livery\",\"48 V\",.040,(side*.525,-.644,.620),darkink,rotation)\n rod(\"Hood pin socket\",(side*.330,-.524,.980),(side*.330,-.524,1.006),.022,zinc,20)\n rod(\"Hood pin grip\",(side*.330,-.532,1.013),(side*.330,-.484,1.013),.008,gasket,16)\n\nf=[(-.460,-.408,1.078),(.460,-.408,1.078),(.461,-.268,1.713),(-.461,-.268,1.713)]\npane(\"Front windshield\",f,glass,.009,.001)\noutline(f,gasket,.016)\nbeam(\"Windshield center structural spine\",(0,-.408,1.071),(0,-.268,1.717),.025,.038,teal,.005)\nrr=[(.459,.632,1.034),(-.459,.632,1.034),(-.459,.658,1.700),(.459,.658,1.700)]\npane(\"Rear cab glass\",rr,glass,.009,.001)\noutline(rr,gasket,.015)\nbeam(\"Rear window protective middle bar\",(0,.647,1.04),(0,.667,1.698),.029,.040,teal,.006)\nfor x in [-.302,.302]:\n rod(\"Windshield wiper pivot\",(x,-.420,1.129),(x,-.439,1.124),.012,gasket,18)\n p=(x+.141,-.390,1.239)\n rod(\"Stamped windshield wiper arm\",(x,-.439,1.124),p,.007,powder,16,.001)\n rod(\"Windshield wiper blade\",(p[0]-.084,-.407,1.211),(p[0]+.040,-.391,1.271),.009,gasket,12,.001)\n\n# A working-looking interior with a molded seat, steering wheel, pedals and a dash display.\nblock(\"Cab instrument panel\",(0,-.277,1.017),(.885,.217,.143),powder,.034)\nblock(\"Instrument binnacle\",(0,-.236,1.112),(.304,.142,.075),gasket,.017)\nblock(\"Digital instrument glass\",(0,-.194,1.153),(.246,.083,.012),teal_dark,.010)\ntext(\"Dashboard readout\",\"E4 • 88\",.025,(0,-.191,1.161),ink,(0,0,0))\nfor j in range(5):\n rod(\"Colored dash buttons\",(.251+j*.033,-.199,1.098),(.251+j*.033,-.189,1.105),.009,\n orange if j==0 else gasket,16,.001)\nblock(\"Driver isolation pedestal\",(0,.316,.754),(.374,.335,.195),powder,.022)\nblock(\"Molded seat cushion\",(0,.303,.888),(.463,.429,.130),cloth,.053)\nblock(\"Seat cushion center pad\",(0,.303,.943),(.329,.315,.034),cloth,.019)\nblock(\"Molded seat back\",(0,.522,1.130),(.443,.130,.439),cloth,.047).rotation_euler.x=.13\nblock(\"Seat back center insert\",(0,.464,1.137),(.323,.028,.325),cloth,.014).rotation_euler.x=.13\nfor x in [-.205,.205]:\n rod(\"Seat back pivot\",(x,.457,.856),(x,.518,1.031),.016,zinc,20)\nfor x in [-.130,.124]:\n plate=block(\"Floor pedal\",(x,-.175,.733),(.077,.114,.019),rubber,.008)\n plate.rotation_euler.x=.36\nrod(\"Steering column\",(0,-.224,.789),(0,-.038,1.192),.028,powder,32)\ncenter=Vector((0,-.027,1.222))\nnormal=Vector((0,-.571,.821))\nforward=Vector((0,.821,.571))\nbasis=Vector((1,0,0))\nbpy.ops.mesh.primitive_torus_add(major_segments=64,minor_segments=12,major_radius=.164,\n minor_radius=.014,location=center)\nwheel=bpy.context.object\nwheel.name=\"Driver steering wheel grip\"\nwheel.rotation_mode=\"QUATERNION\"\nwheel.rotation_quaternion=normal.to_track_quat(\"Z\",\"Y\")\nwheel.data.materials.append(gasket)\nfor p in wheel.data.polygons:\n p.use_smooth=True\nfor a in [pi/2,pi/2+2*pi/3,pi/2+4*pi/3]:\n rod(\"Steering wheel spoke\",center,center+.152*(basis*cos(a)+forward*sin(a)),.012,powder,20)\nrod(\"Steering wheel hub\",center-.018*normal,center+.022*normal,.050,powder,44)\n\n\n# Mudguards, wheels and separate exterior mechanical body details.\ndef wheel_lathe(name,y,z,profile,mat,n=96,caps=False):\n verts=[(x,y+r*cos(2*pi*i/n),z+r*sin(2*pi*i/n)) for x,r in profile for i in range(n)]\n faces=[]\n for j in range(len(profile)-1):\n for i in range(n):\n k=(i+1)%n\n faces.append((j*n+i,j*n+k,(j+1)*n+k,(j+1)*n+i))\n if caps:\n faces += [tuple(reversed(range(n))),tuple(range(len(verts)-n,len(verts)))]\n ob=obj(name,verts,faces,mat,smooth=True)\n tex=ob.data.uv_layers.active\n for face in ob.data.polygons[:(len(profile)-1)*n]:\n j,i=divmod(face.index,n)\n for loop,(col,row) in zip(face.loop_indices,[(i,j),(i+1,j),(i+1,j+1),(i,j+1)]):\n tex.data[loop].uv=(col/n*2,row/(len(profile)-1))\n return ob\n\n\nsweep=[(-.113,.161),(-.111,.190),(-.103,.222),(-.093,.248),(-.077,.264),(-.061,.268),\n (.061,.268),(.077,.264),(.093,.248),(.103,.222),(.111,.190),(.113,.161)]\nfor side in [-1,1]:\n for y in [-.790,.773]:\n x=side*.505\n z=.277\n wheel_lathe(\"Molded industrial tire\",y,z,[(x+a,r) for a,r in sweep],rubber,n=100)\n rim=[(x+side*a,r) for a,r in [(-.084,.156),(.094,.156),(.103,.161),(.114,.161),\n (.122,.151),(.121,.141),(.109,.135),(.096,.118),(.087,.100)]]\n if side==-1:\n rim.reverse()\n wheel_lathe(\"Pressed ivory wheel dish\",y,z,rim,cream,96,True)\n rod(\"Inset wheel hub\",(x+side*.075,y,z),(x+side*.108,y,z),.085,teal_dark,64,.005)\n rod(\"Wheel hub cap\",(x+side*.102,y,z),(x+side*.135,y,z),.046,zinc,40,.004)\n for j in range(6):\n a=j*2*pi/6\n yy,zz=y+.064*cos(a),z+.064*sin(a)\n rod(\"Six-sided wheel lug\",(x+side*.098,yy,zz),(x+side*.120,yy,zz),.011,zinc,6,.0014)\n outer=x+side*.115\n for offset in [.177,.217,.233]:\n p=sorted([(outer-side*.010,offset-.0022),(outer,offset),(outer-side*.010,offset+.0024)])\n wheel_lathe(\"Raised tire sidewall mold ring\",y,z,p,tread,100)\n for row in [-1,1]:\n for j in range(34):\n a=2*pi*j/34+row*.055\n r=.270\n loc=(x+row*.038,y+r*cos(a),z+r*sin(a))\n o=block(\"Traction tire tread block\",loc,(.066,.014,.038),rubber,.0045)\n o.rotation_euler=(a,row*.27,0)\n for j in range(9):\n a=.46+j*.24\n r=.218\n o=block(\"Sidewall industrial hash mark\",(x+side*.114,y+r*cos(a),z+r*sin(a)),\n (.004,.018,.0034),tread,.0010)\n o.rotation_euler.x=a+.20\n for index,(material_,left,right) in enumerate([(teal,.393,.619),(gasket,.611,.628)]):\n profile=[]\n for t in range(33):\n a=.055+(pi-.11)*t/32\n rr=.319 if index==0 else .322\n profile.extend([(side*left,y+rr*cos(a),z+rr*sin(a)),\n (side*right,y+rr*cos(a),z+rr*sin(a))])\n faces=[(2*t,2*t+1,2*t+3,2*t+2) for t in range(32)]\n o=obj(\"Gently rolled steel mudguard\",profile,faces,material_,smooth=True)\n solid=o.modifiers.new(\"Mudguard edge roll\",\"SOLIDIFY\")\n solid.thickness=.014 if index==0 else .008\n bevel(o,.0035)\n\n# Rear work deck and tow interface.\nblock(\"Rear deck frame\",(0,.910,.578),(1.051,.636,.131),teal_dark,.025)\nblock(\"Rear deck top and rail\",(0,.949,.654),(1.104,.586,.052),teal,.019)\nblock(\"Rear deck powder-coated pad\",(0,.960,.686),(.903,.487,.028),powder,.012)\nfor col in range(10):\n for row in range(6):\n x=-.394+col*.0876\n y=.768+row*.073\n tread_plate=block(\"Pressed diamond deck relief\",(x,y,.705),(.029,.012,.009),zinc,.003)\n tread_plate.rotation_euler.z=pi/4 if (col+row)%2==0 else -pi/4\nfor side in [-1,1]:\n block(\"Rear raised rub rail\",(side*.504,1.013,.716),(.061,.414,.079),teal,.020)\n block(\"Rear lamp carrier\",(side*.369,1.221,.563),(.219,.042,.110),gasket,.013)\n block(\"Rear tail lamp red lens\",(side*.406,1.248,.562),(.104,.017,.075),red,.009)\n block(\"Rear tail indicator\",(side*.324,1.248,.563),(.062,.014,.073),orange,.008)\n rod(\"Rear deck grab handle\",(side*.357,.788,.698),(side*.357,.788,.786),.013,zinc)\n rod(\"Rear deck grab handle\",(side*.357,.789,.785),(side*.357,1.105,.785),.013,zinc)\n rod(\"Rear deck grab handle\",(side*.357,1.104,.784),(side*.357,1.104,.698),.013,zinc)\nblock(\"Rear bumper\",(0,1.224,.425),(1.104,.154,.119),powder,.018)\nblock(\"Rear hitch receiver\",(0,1.303,.390),(.200,.120,.100),powder,.014)\nblock(\"Tow coupling recess\",(0,1.365,.390),(.084,.020,.065),gasket,.009)\nrod(\"Industrial tow eye pin\",(-.077,1.400,.396),(.077,1.400,.396),.016,zinc,28)\nfor x in [-.169,.169]:\n block(\"Rear reflective marking\",(x,1.307,.464),(.144,.012,.036),ochre,.006)\n\nrod(\"Beacon mount\",(.334,.496,1.849),(.334,.496,1.910),.046,powder,48,.006)\nrod(\"Amber safety beacon\",(.334,.496,1.898),(.334,.496,1.962),.041,orange,56,.008)\nfor j in range(16):\n a=j*2*pi/16\n x,y=.334+.040*cos(a),.496+.040*sin(a)\n rod(\"Beacon lens flutes\",(x,y,1.916),(x,y,1.949),.0027,orange,10,0)\nblock(\"Roof work light mount\",(-.305,-.415,1.762),(.196,.101,.069),powder,.012)\nblock(\"White roof work light\",(-.305,-.470,1.768),(.154,.022,.043),lamp,.008)\n\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(OUT/\"saltline-e4.blend\"),compress=True)\n\n# Preserve all editable source objects. Batch the deliverable to one draw primitive per material.\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.context.view_layer.objects.active=bpy.data.objects[\"Welded drop-center frame\"]\nbpy.ops.object.convert(target=\"MESH\")\ngroups={}\nfor ob in scene.objects:\n groups.setdefault(ob.data.materials[0].name,[]).append(ob)\nfor mat,items in groups.items():\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in items:\n ob.select_set(True)\n bpy.context.view_layer.objects.active=items[0]\n if len(items)>1:\n bpy.ops.object.join()\n bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\n ob=bpy.context.object\n ob.name=mat\n me=bmesh.new()\n me.from_mesh(ob.data)\n bmesh.ops.triangulate(me,faces=list(me.faces))\n cutoff=1.8e-9 if mat in {ink.name,darkink.name} else 2e-12\n tiny=[f for f in me.faces if f.calc_area()\nLOOK\nA ground-level view up a narrow desert canyon. Steep layered red-orange sandstone walls on both sides with deep horizontal ledges and overhangs, rising to rounded mesa tops. A pale sandy dry wash runs down the middle, lined with rounded boulders and cobbles in ochre, russet, bleached and gray-brown, and a few small scrub plants and grass tufts. Clear pale blue sky.\n\nSCALE\nAbout 158.4 m wide, 48.2 m tall, 241.8 m deep. Real-scale terrain in meters, +Y up, +Z forward, origin on the dry-wash surface near the middle of the canyon.\n\nPARTS\n1. West wall: bedded iron-rich sandstone face with ledges, scars and spalling, following the canyon's bend. Build: a dense grid shaped by a shared wall field function, displaced at meter and decimeter scales.\n2. East wall: the same construction mirrored to the other side, with its own rock material.\n3. Plateaus: rolling oxidized-sandstone outcrops on top of each wall. Build: a grid that starts where the wall top ends.\n4. Dry wash: continuous quartz sand and gravel floor with sediment banks rising to the wall bases. Build: a grid across the canyon width following the bed height function.\n5. Talus and cobbles: hundreds of boulders along the wall feet and thousands of small cobbles scattered on the wash. Build: one boulder generator in five rock tones, batched into a few meshes.\n6. Vegetation: branching creosote scrub and scattered dry bunchgrass. Build: stalks for the branches and leaf clusters, thin blades for the grass.\n\nPLAN\n1. Setup: clear the scene, meters, origin on the wash surface.\n2. Texture maps: run maps.py first. It uses the same terrain_field.py functions as the geometry, so the sandstone bedding, mesa cap and wash maps line up with the shapes.\n3. Build order: west and east walls with their plateaus, dry wash, talus and cobbles, scrub, bunchgrass.\n4. Assemble: walls and wash share their edge rows so there are no gaps, plateaus continue off the wall tops, boulders sit on the bed surface, plants root in the wash and the sediment banks.\n5. Materials: west and east bedded sandstone, oxidized mesa cap, quartz sand and gravel, five talus tones, gray scrub bark, olive, sage and dusty leaves, straw grass.\n6. Export: terrain only, one GLB with the textures embedded.\n\nCHECK\n920,856 triangles across 15 parts. Against the image: walls much taller than the wash is wide, horizontal bedding on both sides, boulders cluster at the wall feet, the canyon bends out of view in the distance.\n\n\n```python\n# maps.py\n\"\"\"Produce continuous procedural strata and dry-wash PBR maps.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import gaussian_filter\nfrom terrain_field import YMIN,YMAX,ledges,smooth,wash\n\nDIR=Path(__file__).resolve().parent/\"maps\"\nDIR.mkdir(exist_ok=True)\nW,H=2048,1536\nv,u=np.meshgrid(np.linspace(1,0,H),np.linspace(0,1,W),indexing=\"ij\")\ny=YMIN+(YMAX-YMIN)*u\nrng=np.random.default_rng(272200)\n\n\ndef field(sigma):\n n=gaussian_filter(rng.standard_normal((H,W)),sigma,mode=\"reflect\")\n return n/max(1e-8,n.std())\n\n\ndef save(name,values):\n im=Image.fromarray(np.clip(np.round(values*255),0,255).astype(np.uint8))\n if name.endswith(\"roughness\"):\n im=im.resize((1024,768),Image.Resampling.LANCZOS)\n if any(k in name for k in (\"-rock\",\"-color\")):\n im.save(DIR/(name+\".jpg\"),quality=95,subsampling=0,optimize=True)\n else:\n im.save(DIR/(name+\".png\"))\n\n\ndef normals(heights,r=1):\n gy,gx=np.gradient(heights)\n n=np.stack([-gx*r,gy*r,np.ones_like(gx)],axis=2)\n n/=np.linalg.norm(n,axis=2,keepdims=True)\n return .5+.5*n\n\n\ndef color_ramp(value, positions, colors):\n return np.stack([np.interp(value,positions,np.asarray(colors)[:,i]) for i in range(3)],2)\n\n\n# Main mineral bands with streaks of desert varnish and particulate detail.\nfor side,name in [(-1,\"west\"),(1,\"east\")]:\n z=ledges(y,side,v)\n drift=.22*field((17,26))+.12*field((5,14))\n finer=field((1.3,1.5))\n lime=.48+.205*np.sin(z*.83 + .7*np.sin(y*.078))+ .115*np.cos(z*1.75+drift)+.09*np.sin(z*3.61+.65*drift)\n lime+=.039*field((34,39))+.03*field((4,9))+.015*finer\n colors=[(.29,.135,.090),(.43,.226,.135),(.57,.330,.203),(.68,.447,.304),(.79,.602,.433)]\n rgb=color_ramp(lime,[0,.26,.46,.69,1],colors)\n stripes=(.55+.45*np.sin(z*5.3+drift))**11\n varnish=smooth((field((40,2.2))-.9)/2.2)*smooth((field((34,18))+.05)/1.7)\n cap=smooth((v-.89)/.11)*.06\n rgb*= (1-.093*stripes-.20*varnish-cap)[:,:,None]\n rgb+=.011*field((.7,1.2))[:,:,None]\n save(name+\"-rock\",rgb)\n if side==-1:\n save(\"stone-roughness\",.77+.055*stripes+.042*field((5,8))+.025*finer)\n\na=(v-.5)*2\ndistance=np.abs(a-wash(y))\nlarge=field((39,8))\nlittle=field((9,1.35))\ngranular=field((5.5,.57))\nrim=smooth((distance-.16+large*.04)/.55)\nwash_core=.55+.115*large+.080*little+.082*granular\ngravel=color_ramp(wash_core,[0,.26,.55,.76,1],\n [(.42,.30,.20),(.56,.43,.31),(.66,.52,.39),(.74,.61,.47),(.82,.68,.53)])\nsand=color_ramp(.54+.11*large+.11*little+.065*granular,[0,.29,.53,.75,1],\n [(.46,.285,.178),(.60,.421,.286),(.70,.523,.365),(.78,.594,.425),(.87,.70,.531)])\nrgb=gravel*(1-rim[:,:,None])+sand*rim[:,:,None]\ncrescent=np.sin(8*np.pi*(v+.015*np.sin(y*.77))+.91*np.sin(y*.26))*.006\nsave(\"wash-color\",rgb+crescent[:,:,None])\nsave(\"sand-roughness\",.81+.043*little+.032*granular)\n\ncap_field=.49+.105*field((23,11))+.078*field((9,3.2))+.036*field((3,1.3))\ncap_field+=.085*np.sin(10*np.pi*v+.7*np.sin(y*.115))+.05*np.sin(33*np.pi*v+.42*np.sin(y*.23))\ncap_colors=[(.36,.185,.103),(.49,.28,.163),(.61,.376,.235),(.68,.444,.281),(.75,.501,.325)]\nsave(\"cap-color\",color_ramp(cap_field,[0,.30,.51,.72,1],cap_colors))\n\n# Tileable higher-frequency relief restores mineral texture at ground-level views.\nS=768\ndef tile_noise(sig):\n a=gaussian_filter(rng.standard_normal((S,S)),sig,mode=\"wrap\")\n return a/a.std()\n\nrock=.057*tile_noise((1.,1.1))+.085*tile_noise((2.6,3.1))+.095*tile_noise((5.5,7.2))\nrock-=.071*np.maximum(tile_noise((2.7,2.4))-.55,0)**1.6\nsand=.038*tile_noise((.72,.78))+.062*tile_noise((1.8,2.1))\nsand+=.073*np.maximum(tile_noise((4.8,4.4))-.78,0)**1.75\nfor name,values in [(\"rock-micro-normal\",rock),(\"sand-micro-normal\",sand)]:\n Image.fromarray(np.clip(np.round(normals(values,7)*255),0,255).astype(\"uint8\")).save(DIR/(name+\".png\"))\n```\n\n```python\n# terrain_field.py\n\"\"\"Field functions shared by geometry and PBR map generation.\"\"\"\nimport numpy as np\n\nYMIN=-84.\nYMAX=156.\n\n\ndef sat(a):\n return np.clip(a,0,1)\n\n\ndef smooth(a):\n a=sat(a)\n return a*a*(3-2*a)\n\n\ndef bend(y):\n return 8.1*np.sin((y+10)*.034)+8.3*np.sin((y+32)*.018)+3.0*np.sin((y-11)*.080)\n\n\ndef base(y):\n return .013*(y+70)+.49*np.sin(y*.052)+.23*np.cos(y*.101)\n\n\ndef width(y,s):\n return 6.7+1.55*np.sin((y+14)*.055+s*.94)+1.5*np.cos(y*.027+s*.8)+.66*np.sin(y*.121-s)\n\n\ndef wall_height(y,s):\n return 26.3 + 4.6*np.sin(y*.036+s*.92)+2.82*np.cos(y*.086-s*.51)+1.85*np.cos(y*.145+s*1.1)\n\n\ndef wash(y):\n return .23*np.sin(y*.094)+.10*np.sin(y*.22+1.0)\n\n\ndef bed_z(y,a):\n d=np.abs(a-wash(y))\n erosion=.42*smooth((d-.11)/.55)+.93*smooth((np.abs(a)-.43)/.57)\n ripple=.033*np.sin(y*.72+a*13)+.024*np.cos(y*1.16-a*42)+.015*np.sin(y*2.9-a*31)\n bank=(.20*np.cos(y*.342+a*4.1)+.18*np.sin(y*.147-a*2.7))*np.abs(a)**1.7\n return base(y)+erosion+ripple+bank\n\n\ndef ledges(y,s,f):\n z=wall_height(y,s)*f\n # Corresponding rock beds twist gradually with the bend in the canyon.\n bedding=z + 1.16*np.sin(y*.039+s*.25)+.53*np.sin(y*.101-s*1.4)+.009*y*s\n return bedding\n\n\ndef wall_xyz(y,f,s):\n h=wall_height(y,s)\n strat=ledges(y,s,f)\n # Bell-shaped alcoves, rounded buttresses, and steps cut into harder beds.\n alcoves=(1.00*np.sin(.21*y+s*.6)+.72*np.sin(.37*y-s*.5)+.31*np.cos(.91*y+s*1.3))\n fins=2.15*np.sin(.106*y+s*.8)+1.12*np.sin(.193*y+3.25*f+s)\n transition=np.sin(np.pi*f)**.9\n strata=.46*np.sin(strat*1.56)+.206*np.sin(strat*3.15)+.108*np.sin(strat*8.7)\n ribs=(.72*np.cos(y*.58+1.1*f)+.26*np.sin(y*1.65-f*3.8))*smooth((f-.26)/.4)\n cut=width(y,s) + 8.5*smooth(f/.29)+1.2*f+5.1*smooth((f-.55)/.45)\n cut+=transition*(fins+(1.16-f)*alcoves+ribs)+strata*smooth(f/.14)\n chips=(.11*np.sin(2.09*y+f*171)+.075*np.sin(4.31*y-f*248)+\n .075*np.sin(6.13*y+f*391)*np.cos(f*214-y*.95))\n cut+=chips*smooth(f/.19)\n z=bed_z(y,s)+h*f+.13*np.sin(y*.38+f*42)*transition\n yy=y + .94*transition*np.sin(y*.19+f*5.9+s)\n return bend(y)+s*cut,yy,z\n\n\ndef plateau_xyz(y,a,s):\n x,yy,z=wall_xyz(y,1.,s)\n ridges=(3.4*np.sin(y*.054+a*5.3+s)+2.6*np.sin(y*.106-a*4.0)\n +1.45*np.sin(y*.173+a*12.0+s)+.33*np.sin(y*.69+a*37.7))\n x=x+s*(41*a+1.2*np.sin(a*9.0)*np.sin(y*.13))\n z=z+smooth(a/.17)*ridges+7.3*sinwarp(a,y,s)\n return x,yy,z\n\n\ndef sinwarp(a,y,s):\n return np.sin(a*np.pi*.77)*(.44+.44*np.sin(y*.045+s))\n```\n\n```python\n# canyon.py\n\"\"\"Original full-scale sandstone canyon terrain for Blender and glTF.\"\"\"\nfrom math import atan2, cos, pi, sin, sqrt\nfrom pathlib import Path\nfrom random import Random\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Euler, Vector, noise\nimport numpy as np\n\nROOT=Path(__file__).resolve().parent\nsys.path.insert(0,str(ROOT))\nfrom terrain_field import YMIN,YMAX,bend,bed_z,width,wall_xyz,plateau_xyz\n\nOUT=Path(sys.argv[sys.argv.index(\"--\")+1]) if \"--\" in sys.argv else ROOT\nSTEM=\"3d-dataset-20261127T2200Z-landscape-copper-narrows-sandstone-canyon\"\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\nrng=Random(272200)\n\n\ndef mat(name,color,rough,images=None,normal_scale=1):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*color,1)\n m.use_nodes=True\n nt=m.node_tree\n p=nt.nodes.get(\"Principled BSDF\")\n p.inputs[\"Base Color\"].default_value=(*color,1)\n p.inputs[\"Roughness\"].default_value=rough\n for key,img in (images or {}).items():\n n=nt.nodes.new(\"ShaderNodeTexImage\")\n n.image=bpy.data.images.load(str(ROOT/\"maps\"/(img+(\".jpg\" if \"-color\" in img or \"-rock\" in img else \".png\"))),check_existing=True)\n n.image.colorspace_settings.name=\"sRGB\" if key==\"Base Color\" else \"Non-Color\"\n if key==\"Normal\":\n texcoord=nt.nodes.new(\"ShaderNodeUVMap\")\n texcoord.uv_map=\"Detail\"\n nt.links.new(texcoord.outputs[\"UV\"],n.inputs[\"Vector\"])\n normal=nt.nodes.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value=normal_scale\n nt.links.new(n.outputs[\"Color\"],normal.inputs[\"Color\"])\n nt.links.new(normal.outputs[\"Normal\"],p.inputs[key])\n else:\n nt.links.new(n.outputs[\"Color\"],p.inputs[key])\n return m\n\n\nrock_materials={}\nfor side,name in [(-1,\"west\"),(1,\"east\")]:\n rock_materials[side]=mat(name.title()+\" · bedded iron-rich sandstone\",(.43,.21,.11),.84,\n {\"Base Color\":name+\"-rock\",\"Normal\":\"rock-micro-normal\",\"Roughness\":\"stone-roughness\"},.56)\nwash=mat(\"Dry wash · quartz sand and gravel\",(.51,.33,.18),.83,\n {\"Base Color\":\"wash-color\",\"Normal\":\"sand-micro-normal\",\"Roughness\":\"sand-roughness\"},.48)\ncap=mat(\"Mesa cap · oxidized sandstone\",(.41,.239,.124),.86,{\"Roughness\":\"stone-roughness\",\"Base Color\":\"cap-color\"})\ntalus=[\n mat(\"Talus · ochre\",(.35,.183,.085),.87),\n mat(\"Talus · bleached sandstone\",(.54,.34,.199),.85),\n mat(\"Talus · russet\",(.31,.114,.063),.9),\n mat(\"Talus · grey-brown\",(.20,.152,.112),.88),\n mat(\"Talus · weathered orange\",(.42,.20,.103),.86),\n]\nbranch=mat(\"Scrub · grey bark\",(.133,.089,.050),.92)\nleaves=[mat(\"Scrub · leaf \"+name,c,.80) for name,c in\n [(\"olive\",(.10,.114,.054)),(\"sage\",(.17,.182,.084)),(\"dusty\",(.22,.223,.117))]]\ngrass=mat(\"Desert grass · straw blades\",(.33,.255,.126),.89)\n\n\ndef mesh(name,verts,faces,material,uv=None,smooth=True,detail=None):\n geo=bpy.data.meshes.new(name)\n geo.from_pydata(verts,[],faces)\n geo.update()\n ob=bpy.data.objects.new(name,geo)\n scene.collection.objects.link(ob)\n geo.materials.append(material)\n coords=geo.uv_layers.new(name=\"UVMap\") if uv is not None else None\n detail_coords=geo.uv_layers.new(name=\"Detail\") if detail is not None else None\n for polygon in geo.polygons:\n polygon.use_smooth=smooth\n if coords is not None:\n for j in polygon.loop_indices:\n coords.data[j].uv=uv[geo.loops[j].vertex_index]\n if detail_coords is not None:\n for j in polygon.loop_indices:\n detail_coords.data[j].uv=detail[geo.loops[j].vertex_index]\n return ob\n\n\ny_axis=np.linspace(YMIN,YMAX,481)\nSIDE_HEIGHT=151\nfor side,name in [(-1,\"West\"),(1,\"East\")]:\n v,u=np.meshgrid(np.linspace(0,1,SIDE_HEIGHT),np.linspace(0,1,len(y_axis)))\n y=YMIN+(YMAX-YMIN)*u\n xx,yy,zz=wall_xyz(y,v,side)\n # The geology is displaced at meter and decimeter scales. End bands match adjacent grids.\n ramp=np.sin(v*pi)**.7\n scars=.15*np.cos(9.05*y+57*v)+.11*np.sin(8.82*y-87*v)+.068*np.cos(y*12.52+146*v)\n spall=.26*np.cos(y*1.32+v*3.2)*np.sin(47*v+y*.28)\n xx+=side*(scars+spall)*ramp\n zz+=.048*np.sin(5.71*y+213*v)*ramp\n verts=list(zip(xx.ravel(),yy.ravel(),zz.ravel()))\n faces=[]\n for j in range(len(y_axis)-1):\n for k in range(SIDE_HEIGHT-1):\n n=j*SIDE_HEIGHT+k\n face=(n,n+SIDE_HEIGHT,n+SIDE_HEIGHT+1,n+1)\n faces.append(face[::-1] if side==1 else face)\n mesh(name+\" wall · bedded face and ledges\",verts,faces,rock_materials[side],\n list(zip(u.ravel(),v.ravel())),detail=list(zip((yy/2.65).ravel(),(zz/2.65).ravel())))\n m=45\n v,u=np.meshgrid(np.linspace(0,1,m),np.linspace(0,1,len(y_axis)))\n y=YMIN+(YMAX-YMIN)*u\n xx,yy,zz=plateau_xyz(y,v,side)\n faces=[]\n for j in range(len(y_axis)-1):\n for k in range(m-1):\n n=j*m+k\n f=(n,n+1,n+m+1,n+m)\n faces.append(f if side==1 else f[::-1])\n mesh(name+\" plateau · rolling outcrops\",list(zip(xx.ravel(),yy.ravel(),zz.ravel())),faces,cap,\n list(zip(u.ravel(),v.ravel())))\n\nB=105\nv,u=np.meshgrid(np.linspace(0,1,B),np.linspace(0,1,len(y_axis)))\ny=YMIN+(YMAX-YMIN)*u\na=2*v-1\nside=np.where(a<0,-1,1)\nx=bend(y)+a*width(y,side)\nz=bed_z(y,a)\nz+=np.sin(pi*v)**1.5*(.015*np.cos(7.3*y+23*a)+.009*np.sin(12*y+47*a))\nfaces=[]\nfor j in range(len(y_axis)-1):\n for k in range(B-1):\n n=j*B+k\n faces.append((n,n+1,n+B+1,n+B))\nmesh(\"Continuous dry wash and sediment banks\",list(zip(x.ravel(),y.ravel(),z.ravel())),faces,wash,\n list(zip(u.ravel(),v.ravel())),detail=list(zip((y/2.45).ravel(),(x/2.45).ravel())))\n\n\ndef append(group,verts,faces):\n gverts,gfaces=group\n offset=len(gverts)\n gverts.extend(verts)\n gfaces.extend(tuple(offset+i for i in f) for f in faces)\n\n\nico=bmesh.new()\nbmesh.ops.create_icosphere(ico,subdivisions=2,radius=1)\nico.verts.index_update()\nrock_base=[v.co.copy() for v in ico.verts]\nrock_faces=[tuple(v.index for v in f.verts) for f in ico.faces]\nico.free()\nmicro=bmesh.new()\nbmesh.ops.create_icosphere(micro,subdivisions=1,radius=1)\nmicro.verts.index_update()\ngrit_base=[v.co.copy() for v in micro.verts]\ngrit_faces=[tuple(v.index for v in f.verts) for f in micro.faces]\nmicro.free()\ndense=bmesh.new()\nbmesh.ops.create_icosphere(dense,subdivisions=3,radius=1)\ndense.verts.index_update()\ndense_base=[v.co.copy() for v in dense.verts]\ndense_faces=[tuple(v.index for v in f.verts) for f in dense.faces]\ndense.free()\nbatches=[([],[]) for _ in talus]\n\n\ndef boulder(loc,scale,kind):\n q=Euler((rng.uniform(-.30,.30),rng.uniform(-.25,.25),rng.uniform(-pi,pi))).to_matrix()\n layers=rng.uniform(1.7,5.2)\n seed=rng.uniform(1.,75.)\n verts=[]\n largest=max(scale)\n if largest>.74:\n geom,faces=dense_base,dense_faces\n elif largest>.16:\n geom,faces=rock_base,rock_faces\n else:\n geom,faces=grit_base,grit_faces\n for v in geom:\n w=v.copy()\n strength=.18*noise.noise(w*2.67+Vector((seed,-seed,seed*.6)))\n strength+=.10*noise.noise(w*5.42+Vector((seed,seed,-seed*.5)))\n strength+=.042*cos(w.z*layers*5)\n w*=1+strength\n # Some weathered fragments preserve roughly planar bedding surfaces.\n if w.z>.62:\n w.z=.62+(w.z-.62)*.44\n w=Vector((w.x*scale[0],w.y*scale[1],w.z*scale[2]))\n verts.append(Vector(loc)+q@w)\n append(batches[kind],verts,faces)\n\n\nfor j in range(565):\n s=rng.choice([-1,1])\n y=rng.uniform(YMIN+1,YMAX-2)\n a=s*rng.triangular(.37,1,.93)\n loc=(bend(y)+a*width(y,s),y,bed_z(y,a))\n size=rng.uniform(.14,.56)*(.75+abs(a)) if j<500 else rng.uniform(.42,1.15)\n scale=(size*rng.uniform(.77,1.63),size*rng.uniform(.52,1.30),size*rng.uniform(.35,.79))\n boulder(loc,scale,rng.randrange(len(talus)))\nfor s in [-1,1]:\n for y in [-55,-44,-26,-12,21,49,70,103,127]:\n yy=y+rng.uniform(-2.2,2.2)\n a=s*rng.uniform(.82,.97)\n loc=(bend(yy)+a*width(yy,s),yy,bed_z(yy,a)-.12)\n size=rng.uniform(.7,1.72)\n boulder(loc,(size,size*.81,size*.62),rng.choice([0,1,2,4]))\n for j in range(34):\n yy=rng.uniform(YMIN+2,YMAX-2)\n f=rng.uniform(.035,.145)\n x0,y0,z0=wall_xyz(yy,f,s)\n loc=(x0-s*.14,y0,z0-.13)\n size=rng.uniform(.35,1.25)\n boulder(loc,(size*.92,size*1.21,size*.54),rng.randrange(len(talus)))\nfor yy,a,size in [(-47,-.89,1.97),(-42,.94,1.58),(-35,-.96,1.71),(-24,.92,1.77)]:\n s=1 if a>0 else -1\n x=bend(yy)+a*width(yy,s)\n z=bed_z(yy,a)-.31\n boulder((x,yy,z),(size,1.2*size,.62*size),4 if a>0 else 2)\nfor _ in range(2000):\n yy=rng.uniform(-70,24)\n side=rng.choice([-1,1])\n a=side*rng.triangular(.04,.72,.43)\n size=rng.uniform(.025,.117)\n x=bend(yy)+a*width(yy,side)\n boulder((x,yy,bed_z(yy,a)-.008),(size,size*.87,size*.59),rng.choices(range(5),[2,4,1,3,2])[0])\nfor i,(vertices,faces) in enumerate(batches):\n m=talus[i]\n coords=[((v.x+.40*v.y)/1.62,(v.z+.48*v.y)/1.62) for v in vertices]\n ob=mesh(\"Eroded talus and cobbles \"+str(i+1),vertices,faces,m,smooth=True,detail=coords)\n shader=m.node_tree.nodes.get(\"Principled BSDF\")\n n=m.node_tree.nodes.new(\"ShaderNodeTexImage\")\n n.image=bpy.data.images.load(str(ROOT/\"maps\"/\"rock-micro-normal.png\"),check_existing=True)\n uv=m.node_tree.nodes.new(\"ShaderNodeUVMap\")\n uv.uv_map=\"Detail\"\n m.node_tree.links.new(uv.outputs[\"UV\"],n.inputs[\"Vector\"])\n normal=m.node_tree.nodes.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value=.62\n m.node_tree.links.new(n.outputs[\"Color\"],normal.inputs[\"Color\"])\n m.node_tree.links.new(normal.outputs[\"Normal\"],shader.inputs[\"Normal\"])\n vcolor=m.node_tree.nodes.new(\"ShaderNodeVertexColor\")\n vcolor.layer_name=\"Mineral stain\"\n m.node_tree.links.new(vcolor.outputs[\"Color\"],shader.inputs[\"Base Color\"])\n base=m.diffuse_color\n color=ob.data.color_attributes.new(name=\"Mineral stain\",type=\"FLOAT_COLOR\",domain=\"POINT\")\n for vertex,sample in zip(ob.data.vertices,color.data):\n p=vertex.co\n q=Vector((p.x*.83,p.y*.91,p.z*3.1))\n grain=noise.noise(q*4.72)\n patch=noise.noise(q*1.84)\n bedding=.08*sin(p.z*19+p.y*.13)\n tone=max(.47,min(1.39,.92+.22*grain+.27*patch+bedding))\n sample.color=(base[0]*tone,base[1]*tone,base[2]*tone,1)\n\n\n\ndef stalk(group,points,radius):\n verts=[]\n sides=5\n for i,p in enumerate(points):\n axis=(points[min(i+1,len(points)-1)]-points[max(i-1,0)]).normalized()\n co=axis.cross(Vector((1,0,0))).normalized()\n si=axis.cross(co).normalized()\n r=radius*(1-.75*i/(len(points)-1))\n for j in range(sides):\n t=2*pi*j/sides\n verts.append(p+r*(co*cos(t)+si*sin(t)))\n faces=[]\n for i in range(len(points)-1):\n for j in range(sides):\n k=(j+1)%sides\n faces.append((i*sides+j,i*sides+k,(i+1)*sides+k,(i+1)*sides+j))\n append(group,verts,faces)\n\n\ndef foliage(group,a,d,length,span):\n d=d.normalized()\n cross=d.cross(Vector((0,0,1))).normalized()\n lift=d.cross(cross).normalized()\n p=a+d*length*.50\n tip=a+d*length+lift*(length*.21)\n append(group,[a,p-cross*span,p+lift*(span*.46),p+cross*span,tip],\n [(0,1,2),(0,2,3),(1,4,2),(2,4,3)])\n\n\nwood=([],[])\nfoliage_groups=[([],[]) for _ in leaves]\ngrass_geo=([],[])\nfor i in range(135):\n side=rng.choice([-1,1])\n yy=rng.uniform(-70,133)\n a=side*rng.uniform(.63,1)\n x0=bend(yy)+a*width(yy,side)\n root=Vector((x0,yy,bed_z(yy,a)-.01))\n if i%6==0:\n p=wall_xyz(yy,rng.uniform(.10,.26),side)\n root=Vector((p[0]-side*.06,p[1],p[2]))\n h=rng.uniform(.19,.65)\n if i%4==0:\n for j in range(rng.randint(8,18)):\n phi=rng.uniform(0,2*pi)\n b=root+Vector((rng.uniform(-.07,.07),rng.uniform(-.07,.07),0))\n d=Vector((cos(phi)*rng.uniform(.10,.7),sin(phi)*rng.uniform(.10,.7),1))\n foliage(grass_geo,b,d,h*rng.uniform(.48,1.02),rng.uniform(.011,.021))\n continue\n for j in range(rng.randint(6,12)):\n phi=rng.uniform(0,2*pi)\n d=Vector((cos(phi)*rng.uniform(.23,.98),sin(phi)*rng.uniform(.24,.93),1))\n d*=h*rng.uniform(.52,.96)\n mid=root+d*.57+Vector((0,0,.04*h))\n tip=root+d\n stalk(wood,[root,mid,tip],.024*h)\n for k in range(8):\n frac=.50+.51*k/7\n a0=root+frac*d\n ph=phi+k*2.394+rng.uniform(-.25,.25)\n direction=Vector((cos(ph),sin(ph),rng.uniform(.31,1)))\n end=a0+direction*(.20*h)\n stalk(wood,[a0,(a0+end)*.5,end],.009*h)\n for leaf in range(4):\n leafdir=direction+Vector((rng.uniform(-.8,.8),rng.uniform(-.8,.8),rng.uniform(-.54,.48)))\n foliage(foliage_groups[rng.randrange(3)],a0.lerp(end,(leaf+1)/5),leafdir,\n h*rng.uniform(.12,.30),h*rng.uniform(.026,.060))\nmesh(\"Branching desert scrub\",*wood,branch)\nfor i,g in enumerate(foliage_groups):\n mesh(\"Creosote scrub leaf geometry \"+str(i+1),*g,leaves[i])\nmesh(\"Scattered dry bunchgrass\",*grass_geo,grass)\n\n# Place the origin on the dry-wash surface near the middle of the terrain.\norigin_z=float(bed_z(0,0))\nfor ob in scene.objects:\n for vert in ob.data.vertices:\n vert.co.z-=origin_z\nscene[\"terrain_anchor_z\"]=origin_z\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(OUT/\"copper-narrows.blend\"),compress=True)\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.ops.export_scene.gltf(filepath=str(OUT/(STEM+\".glb\")),export_format=\"GLB\",\n export_yup=True,use_selection=True,export_apply=True)\n```\n\nrun it: `python3 maps.py` then `blender -b --python canyon.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261127T2200Z-landscape-copper-narrows-sandstone-canyon.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/copper-narrows-sandstone-canyon/3d-dataset-20261127T2200Z-landscape-copper-narrows-sandstone-canyon.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/wren-court-rain-passage.jpg"}}, {"type": "text", "text": "create an image of a wren court rain passage"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA rainy enclosed stone courtyard, front view. Honey limestone block walls on three sides, a dressed stone archway in the middle with individually cut voussoirs and jambs, and through it a sage-green double timber gate with black iron straps on a stone step. Wet blue-gray granite setts on the ground with shallow puddles, a black iron lantern on the wall plus a smaller one inside the arch, a black \"WREN COURT No. 7\" plaque, a copper downpipe, a drain grate, and terracotta pots of ferns.\n\nSCALE\nAbout 6.1 m wide, 4.4 m tall, 9.1 m deep. Build in meters, +Y up, +Z forward, origin at the center of the main arch wall at paving level.\n\nPARTS\n1. Main wall: limestone blocks with individually relieved faces and recessed lime mortar, cut to the curved arch surround. Build: masonry quads per block, trimmed against the arch curve.\n2. Arch: dressed jambs and individually cut voussoirs. Build: prisms turned around the arch center.\n3. Side walls: two mews walls framing the foreground and a smaller second court. Build: the same block masonry on the side planes.\n4. Back court: back wall and a shallow step visible through the arch, with the sage double gate and iron hardware. Build: blocks for the wall and step, plank boxes for the gate, rods for the straps.\n5. Paving: granite setts with physically recessed joints, a darker curb, a drain grate and shallow reflective rain puddles. Build: one block per sett, water patches as thin surfaces.\n6. Details: hanging iron lanterns with mottled glass and a flame-shaped bulb, the enameled court plaque, the downpipe, and terracotta planters with custom fern fronds. Build: lathe for the pots and lantern parts, label for the plaque, tubes for the pipe, frond strips for the ferns.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the arch wall center on the paving.\n2. Texture maps: run maps.py first for the limestone, wet granite, mortar, timber and terracotta maps.\n3. Build order: main wall masonry, arch jambs and voussoirs, side walls, back wall and step with the gate, paving and puddles, lanterns and plaque, planters and ferns.\n4. Assemble: arch sits in the main wall opening, side walls meet the main wall at the corners, the gate is centered in the back wall behind the arch, setts fill the ground between the walls, the lantern and plaque hang on the main wall to the right of the arch, pots stand against the walls.\n5. Materials: honey limestone, sand lime mortar, wet blue-gray granite, rain-darkened curb, reflective rainwater, sage gate timber, black lacquered iron, oxidized bronze, mottled lantern glass, warm filament, ivory plaque lettering, terracotta, damp soil, three fern greens.\n6. Export: court only, no studio, one GLB with the textures embedded.\n\nCHECK\n154,245 triangles across 17 parts. Against the image: arch about half the wall width, gate fills most of the arch view, blocks shrink in perspective toward the back, puddles darken the setts in patches.\n\n\n```python\n# maps.py\n\"\"\"Original wet stone, mortar, painted wood, copper and leaf PBR maps.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import gaussian_filter\n\nROOT=Path(__file__).resolve().parent/\"maps\"\nROOT.mkdir(exist_ok=True)\nS=1024\nv,u=np.mgrid[0:S,0:S]/S\nrng=np.random.default_rng(272300)\n\n\ndef field(sig):\n a=gaussian_filter(rng.standard_normal((S,S)),sig,mode=\"wrap\")\n return a/a.std()\n\n\ndef save(name,a,normal=False):\n img=Image.fromarray(np.clip(np.round(a*255),0,255).astype(\"uint8\"))\n if not normal and a.ndim==3:\n img.save(ROOT/(name+\".jpg\"),quality=95,subsampling=0,optimize=True)\n else:\n img.save(ROOT/(name+\".png\"))\n\n\ndef normal(h,strength):\n gy,gx=np.gradient(h)\n vec=np.stack([-gx*strength,gy*strength,np.ones_like(h)],2)\n vec/=np.linalg.norm(vec,axis=2,keepdims=True)\n return .5+.5*vec\n\n\ncloud=field((18,23))\nspots=field((3.1,4.7))\ngrain=field((.53,.63))\npore=np.maximum(field((1.07,1.1))-.67,0)**1.4\nwhite=np.maximum(field((1.55,1.9))-1.26,0)**1.4\nsulfate=np.clip((field((52,21))+.32*spots-.7)*.32,0,.85)\nstone_shading=1+.046*cloud+.05*spots-.041*pore+.016*grain+.020*white\nivory=np.array([.75,.657,.509])[None,None,:]\ngreen=np.array([.293,.358,.233])[None,None,:]\nstone=stone_shading[:,:,None]*ivory*(1-.61*sulfate[:,:,None])+green*sulfate[:,:,None]*.32\nsave(\"limestone-color\",stone)\nsave(\"limestone-normal\",normal(.021*spots+.013*grain-.027*pore+.023*white,7.6),True)\nsave(\"limestone-roughness\",.71+.054*cloud+.042*spots+.046*pore)\n\nweather=field(18)\nstone_grain=field((1.9,2.3))\nfine=field(.64)\npits=np.maximum(field((3.5,4.2))-.55,0)**1.45\nstone_tone=(1+.087*weather+.061*stone_grain+.019*fine-.048*pits)\nsave(\"sett-color\",stone_tone[:,:,None]*np.array([.52,.518,.465]))\nsave(\"sett-roughness\",.53+.15*np.clip(weather*.28,-1,1)+.06*stone_grain+.046*fine)\nsave(\"sett-normal\",normal(.018*weather+.032*stone_grain+.025*fine-.029*pits,8),True)\nwood_grain=field((22,.65))\nwood_wear=np.maximum(field((37,6.5))-.7,0)**1.45\nwood_rgb=np.array([.239,.394,.356])*(1+.063*wood_grain[:,:,None]-.094*wood_wear[:,:,None])\nsave(\"sage-paint\",wood_rgb)\nsave(\"painted-wood-normal\",normal(.038*wood_grain+.016*field((16,2.4))-.061*wood_wear,7),True)\npatina=np.maximum(field((11,9))+.45*field((3,3))-.12,0)\ncopper_rgb=np.array([.30,.222,.155])*(1+.10*cloud[:,:,None])+np.array([-.05,.095,.070])*patina[:,:,None]\nsave(\"bronze-color\",copper_rgb)\nsave(\"bronze-roughness\",.44+.089*patina+.04*grain)\n```\n\n```python\n# wren.py\n\"\"\"Original Wren Court scenery. Coordinate dimensions are in meters.\"\"\"\nfrom math import cos, pi, sin, sqrt\nfrom pathlib import Path\nfrom random import Random\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Vector\n\nROOT=Path(__file__).resolve().parent\nOUT=Path(sys.argv[sys.argv.index(\"--\")+1]) if \"--\" in sys.argv else ROOT\nSTEM=\"3d-dataset-20261127T2300Z-scenery-wren-court-rain-passage\"\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\nrng=Random(272300)\n\n\ndef mat(name,color,rough=.65,metal=0,imgs=None,coat=0,trans=0,ior=1.46,emit=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*color,1)\n m.use_nodes=True\n nt=m.node_tree\n p=nt.nodes.get(\"Principled BSDF\")\n for key,value in {\"Base Color\":(*color,1),\"Roughness\":rough,\"Metallic\":metal,\n \"Coat Weight\":coat,\"Coat Roughness\":.18,\"IOR\":ior,\n \"Transmission Weight\":trans,\"Emission Color\":(*color,1),\n \"Emission Strength\":emit}.items():\n p.inputs[key].default_value=value\n for key,path in (imgs or {}).items():\n tx=nt.nodes.new(\"ShaderNodeTexImage\")\n tx.image=bpy.data.images.load(str(ROOT/\"maps\"/path),check_existing=True)\n tx.image.colorspace_settings.name=\"sRGB\" if key==\"Base Color\" else \"Non-Color\"\n if key==\"Normal\":\n n=nt.nodes.new(\"ShaderNodeNormalMap\")\n n.inputs[\"Strength\"].default_value=.77\n nt.links.new(tx.outputs[\"Color\"],n.inputs[\"Color\"])\n nt.links.new(n.outputs[\"Normal\"],p.inputs[key])\n else:\n nt.links.new(tx.outputs[\"Color\"],p.inputs[key])\n return m\n\n\nlimestone=mat(\"Wren Court · weathered honey limestone\",(.53,.43,.28),.74,imgs={\n \"Base Color\":\"limestone-color.jpg\",\"Roughness\":\"limestone-roughness.png\",\"Normal\":\"limestone-normal.png\"})\nmortar=mat(\"Sand-colored recessed lime mortar\",(.268,.239,.186),.88)\npave=mat(\"Wet granite setts · blue-grey mix\",(.263,.251,.22),.53,imgs={\n \"Base Color\":\"sett-color.jpg\",\"Roughness\":\"sett-roughness.png\",\"Normal\":\"sett-normal.png\"},coat=.29)\nsteps=mat(\"Rain-darkened curb and joints\",(.152,.163,.149),.65,imgs={\n \"Roughness\":\"sett-roughness.png\",\"Normal\":\"sett-normal.png\"},coat=.15)\nwood=mat(\"Sage painted gate · aged timber\",(.085,.14,.109),.52,imgs={\n \"Base Color\":\"sage-paint.jpg\",\"Normal\":\"painted-wood-normal.png\"},coat=.10)\nbronze=mat(\"Oxidized bronze hardware\",(.16,.108,.067),.45,.78,imgs={\n \"Base Color\":\"bronze-color.jpg\",\"Roughness\":\"bronze-roughness.png\"})\niron=mat(\"Black lacquered iron\",(.035,.043,.036),.45,.65,coat=.15)\npaper=mat(\"Hand-painted ivory plaque lettering\",(.63,.552,.354),.58)\nlampglass=mat(\"Warm mottled lantern glass\",(.93,.67,.35),.22,trans=.80,ior=1.42)\nbulb=mat(\"Warm lantern filament\",(.99,.46,.11),.23,emit=3.0)\nterracotta=mat(\"Weathered fired terracotta\",(.32,.138,.068),.77,imgs={\n \"Normal\":\"limestone-normal.png\",\"Roughness\":\"limestone-roughness.png\"})\nsoil=mat(\"Damp potting soil\",(.063,.049,.035),.89)\nleaf1=mat(\"Fern · mature deep green\",(.046,.106,.042),.58,coat=.08)\nleaf2=mat(\"Fern · new sage frond\",(.092,.164,.068),.55,coat=.09)\nleaf3=mat(\"Fern · shaded lower frond\",(.039,.083,.040),.67,coat=.05)\nstalkmat=mat(\"Fern stems\",(.108,.123,.045),.78)\npuddle=mat(\"Rainwater · shallow reflective surface\",(.79,.88,.91),.102,trans=.94,ior=1.333)\n\n\ndef obj(name,verts,faces,material,uv=None,smooth=False,ids=None):\n g=bpy.data.meshes.new(name)\n g.from_pydata(verts,[],faces)\n g.update()\n ob=bpy.data.objects.new(name,g)\n scene.collection.objects.link(ob)\n g.materials.append(material)\n coords=g.uv_layers.new(name=\"UVMap\")\n for p in g.polygons:\n p.use_smooth=smooth\n for ln in p.loop_indices:\n i=g.loops[ln].vertex_index\n x,y,z=g.vertices[i].co\n coords.data[ln].uv=uv[i] if uv is not None else (x*1.8+y*.56,z*2.2+y*1.3)\n if ids is not None:\n set_tones(ob,ids)\n return ob\n\n\ndef set_tones(ob,tones):\n color=ob.data.color_attributes.new(name=\"Mineral variation\",type=\"FLOAT_COLOR\",domain=\"POINT\")\n for v,t in zip(color.data,tones):\n v.color=(*t,1)\n\n\ndef mod_edges(ob,r):\n b=ob.modifiers.new(\"Worn corner radius\",\"BEVEL\")\n b.width=r\n b.segments=3\n n=ob.modifiers.new(\"Weighted face normals\",\"WEIGHTED_NORMAL\")\n n.keep_sharp=True\n return ob\n\n\ndef prism(name,verts,faces,material,r):\n ob=obj(name,verts,faces,material)\n return mod_edges(ob,r) if r else ob\n\n\ndef block(name,location,dim,material,r=.01):\n a,b,c=(d/2 for d in dim)\n ob=prism(name,[(-a,-b,-c),(a,-b,-c),(a,b,-c),(-a,b,-c),(-a,-b,c),(a,-b,c),(a,b,c),(-a,b,c)],\n [(3,2,1,0),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7),(4,5,6,7)],material,r)\n ob.location=location\n return ob\n\n\ndef rod(name,a,b,r,material,n=20,bevel=.003):\n a,b=Vector(a),Vector(b)\n d=b-a\n bpy.ops.mesh.primitive_cylinder_add(vertices=n,radius=r,depth=d.length,location=(a+b)*.5)\n ob=bpy.context.object\n ob.name=name\n ob.rotation_mode=\"QUATERNION\"\n ob.rotation_quaternion=d.to_track_quat(\"Z\",\"Y\")\n ob.data.materials.append(material)\n for p in ob.data.polygons:\n if len(p.vertices)==4:\n p.use_smooth=True\n return mod_edges(ob,bevel) if bevel else ob\n\n\ndef label(name,body,size,pos,material,spacing=1.12):\n c=bpy.data.curves.new(name,\"FONT\")\n c.body=body\n c.size=size\n c.space_character=spacing\n c.resolution_u=12\n c.align_x=c.align_y=\"CENTER\"\n o=bpy.data.objects.new(name,c)\n scene.collection.objects.link(o)\n o.rotation_euler.x=pi/2\n o.location=pos\n c.materials.append(material)\n return o\n\n\ndef append(group,verts,faces,uv=None,tone=(1,1,1)):\n gv,gf,gu,gt=group\n off=len(gv)\n gv.extend(verts)\n gf.extend(tuple(i+off for i in f) for f in faces)\n gu.extend(uv if uv is not None else [(x*1.9+y*.28,z*1.85+y*.31) for x,y,z in verts])\n gt.extend([tone]*len(verts))\n\n\ndef connection(name,points,r,material,sides=8):\n vs=[]\n for i,p in enumerate(points):\n p=Vector(p)\n d=(Vector(points[min(i+1,len(points)-1)])-Vector(points[max(0,i-1)])).normalized()\n axis=Vector((0,0,1)) if abs(d.z)<.92 else Vector((1,0,0))\n a=d.cross(axis).normalized()\n b=d.cross(a)\n vs.extend(p+r*(cos(j*2*pi/sides)*a+sin(j*2*pi/sides)*b) for j in range(sides))\n fs=[]\n for i in range(len(points)-1):\n for j in range(sides):\n k=(j+1)%sides\n fs.append((i*sides+j,i*sides+k,(i+1)*sides+k,(i+1)*sides+j))\n fs.extend([tuple(reversed(range(sides))),tuple(range(len(vs)-sides,len(vs)))])\n return obj(name,vs,fs,material,smooth=True)\n\n\n# Masonry. A stack of irregular, individually relieved bed faces is cut to the curved surround.\nA=-.38\nR=1.028\nS=2.040\nOUTER=1.283\nMINX=-2.80\nMAXX=2.80\n\n\ndef outside(z,radius):\n return sqrt(max(0.,radius*radius-max(0,z-S)**2)) if z=0:\n outline.append(a)\n if (da>=0)!=(db>=0):\n t=da/(da-db)\n outline.append((a[0]+t*(b[0]-a[0]),a[1]+t*(b[1]-a[1])))\n return outline\n\n\nlevels=[.09,.40,.718,1.053,1.378,1.714,2.040,2.307,2.577,2.810,3.078,3.323,3.609,3.907,4.14]\nfor row,(lo,hi) in enumerate(zip(levels,levels[1:])):\n low,high=outside(lo,OUTER),outside(hi,OUTER)\n n=max(7,round((MAXX-MINX)/(.61 if row%3 else .72)))\n edges=[MINX]+[MINX+(MAXX-MINX)*j/n+rng.uniform(-.079,.079)+.15*(row%2)\n for j in range(1,n)]+[MAXX]\n for a,b in zip(edges,edges[1:]):\n corners=[(a+.009,lo+.009),(b-.009,lo+.008),(b-.010,hi-.008),(a+.011,hi-.011)]\n segments=[corners] if lo>=S+OUTER else [trim_to_arch(corners,side,lo,hi,low,high) for side in [-1,1]]\n for segment in segments:\n if len(segment)>=3 and max(p[0] for p in segment)-min(p[0] for p in segment)>.055:\n masonry_quad(segment,-.333+rng.uniform(-.014,.017),.36,chroma(),rng.uniform(.009,.025))\n # A recessed continuous wall behind the real stone joints.\n innerLo,innerHi=outside(lo,R+.025),outside(hi,R+.025)\n if lo>=S+R+.025:\n chunks=[(MINX,MAXX,MINX,MAXX)]\n else:\n chunks=[(MINX,A-innerLo,MINX,A-innerHi),(A+innerLo,MAXX,A+innerHi,MAXX)]\n for a,b,c,d in chunks:\n v=[(a,-.306,lo),(b,-.306,lo),(d,-.306,hi),(c,-.306,hi),\n (a,.39,lo),(b,.39,lo),(d,.39,hi),(c,.39,hi)]\n prism(\"Lime mortar between wall courses\",v,[(0,1,2,3),(7,6,5,4),(0,4,5,1),(1,5,6,2),\n (2,6,7,3),(3,7,4,0)],mortar,0)\n\n# Dressed jambs and individual cut voussoirs.\nfor side in [-1,1]:\n x=A+side*(R+.122)\n for j in range(7):\n lo=j*.2875+.04\n hi=lo+.273\n w=.236 if j%2 else .261\n masonry_quad([(x-w/2,lo),(x+w/2,lo),(x+w/2,hi),(x-w/2,hi)],\n -.418+rng.uniform(-.009,.009),.73,chroma(),.016)\n block(\"Foot of dressed jamb\",(x,-.03,.101),(.35,.923,.16),limestone,.032)\n block(\"Springer impost stone\",(x,-.040,S-.022),(.35,.920,.108),limestone,.016)\nfor i in range(15):\n lo=(i+.044)*pi/15\n hi=(i+.951)*pi/15\n outer=OUTER+.075 if i==7 else OUTER\n inner=R-.016 if i==7 else R\n na=6\n profile=[(A+radius*cos(a),S+radius*sin(a))\n for radius,theta in [(outer,[lo+(hi-lo)*j/na for j in range(na+1)]),\n (inner,[hi-(hi-lo)*j/na for j in range(na+1)])] for a in theta]\n m=len(profile)\n layers=[(-.469,.969),(-.438,1.0),(.684,1.0),(.717,.985)]\n center=sum((Vector(p) for p in profile),Vector((0,0)))/m\n vv=[(x,y,z) for y,k in layers for x,z in (center.lerp(Vector(p),k) for p in profile)]\n ff=[tuple(range(m))]\n for k in range(len(layers)-1):\n for j in range(m):\n nxt=(j+1)%m\n ff.append((k*m+nxt,k*m+j,(k+1)*m+j,(k+1)*m+nxt))\n ff.append(tuple(reversed(range((len(layers)-1)*m,len(layers)*m))))\n append(stonework,vv,ff,[(x*1.3+y*.8,z*1.8) for x,y,z in vv],chroma())\n\ndef turn_group(orig,angle,dx,dy):\n verts,faces,uvs,tones=orig\n n=len(stonework[0])\n stonework[0].extend((x*cos(angle)-y*sin(angle)+dx,x*sin(angle)+y*cos(angle)+dy,z) for x,y,z in verts)\n stonework[1].extend(tuple(n+i for i in f) for f in faces)\n stonework[2].extend(uvs)\n stonework[3].extend(tones)\n\n\n# The two mews walls frame an enclosed foreground and a smaller second court.\nhero_stones=stonework\nfor side in [-1,1]:\n stonework=([],[],[],[])\n for row in range(11):\n z=.10+row*.322\n start=-2.92+.13*(row%2)\n for j in range(9):\n a=start+j*.707\n b=min(a+.686,3.86)\n if b>a:\n masonry_quad([(a,z),(b,z+.009),(b-.002,z+.307),(a+.013,z+.311)],-.25,.28,chroma(),.015)\n local=stonework\n stonework=hero_stones\n turn_group(local,-side*pi/2,side*2.71,.30)\n block(\"Shadow backing of side wall\",(side*2.68,.67,1.88),(.38,6.62,3.54),mortar,.027)\n block(\"Rounded wall coping\",(side*2.74,.69,3.76),(.47,6.77,.137),limestone,.038)\n\n# The back wall and shallow step, visible inside the arch.\nstonework=hero_stones\nfor row in range(12):\n h=.28+row*.304\n for j in range(9):\n x=-2.86+j*.649+(.17 if row%2 else 0)\n if x>.70 or x+.63<-1.13 or h>2.65:\n masonry_quad([(x,h),(x+.631,h),(x+.625,h+.289),(x+.01,h+.292)],\n 3.64+rng.uniform(-.008,.008),3.88,chroma(),.016)\nblock(\"Back lime mortar wall\",(0,3.836,2.05),(5.51,.21,3.81),mortar,.024)\nblock(\"Back door recess\",(-.25,3.578,1.435),(1.89,.14,2.54),iron,.051)\nfor side in [-1,1]:\n x=-.25+side*.962\n block(\"Rear limestone door surround\",(x,3.547,1.435),(.159,.34,2.65),limestone,.020)\nblock(\"Rear lintel\",(-.25,3.493,2.77),(2.064,.46,.19),limestone,.026)\nfor i in range(14):\n x=-1.107+i*.134\n o=block(\"Sage gate board\",(x,3.485,1.426),(.127,.069,2.43),wood,.011)\n o.rotation_euler.y=rng.uniform(-.004,.004)\nfor x in [-.70,.20]:\n for z in [.47,2.33]:\n block(\"Timber gate black strap hinge\",(x,3.434,z),(.82,.036,.082),iron,.009)\n for j in range(5):\n xx=x-.30+j*.15\n rod(\"Gate hinge rivet\",(xx,3.41,z),(xx,3.397,z),.015,bronze,14,.002)\nfor x in [-.327,-.173]:\n block(\"Gate latch plate\",(x,3.425,1.293),(.086,.029,.145),iron,.007)\n pts=[(x+.041*cos(j*2*pi/32),3.362,1.293+.044*sin(j*2*pi/32)) for j in range(33)]\n connection(\"Gate pull ring\",pts,.0075,bronze)\nblock(\"Rear worn entrance step\",(-.25,3.13,.137),(2.18,.65,.235),limestone,.045)\nblock(\"Front arch coping course\",(0,-.054,4.159),(5.65,.877,.174),limestone,.029)\nblock(\"Coping drip edge\",(0,-.372,4.030),(5.63,.119,.068),limestone,.016)\nblock(\"Copper downspout top collector\",(-2.209,-.471,3.965),(.245,.237,.24),bronze,.045)\npath=[(-2.216,-.486,3.96),(-2.213,-.511,3.514),(-2.19,-.520,3.461),(-2.19,-.510,.30),\n (-2.18,-.555,.223),(-2.14,-.642,.191)]\nconnection(\"Aged copper rainwater pipe\",path,.047,bronze,20)\nfor z in [.58,1.53,2.62,3.38]:\n rod(\"Downspout wall clamp\",(-2.19,-.509,z-.026),(-2.19,-.509,z+.026),.054,iron,24,.003)\n block(\"Downspout fastening plate\",(-2.19,-.367,z),(.122,.091,.078),bronze,.009)\n\nweathered=[]\nfor (x,y,z),tone in zip(stonework[0],stonework[3]):\n lower=max(0,1-z/(.97+.15*sin(y*2.2+x*2.9)))**1.2\n drain=max(0,1-abs(x+2.18)/.27)*max(0,1-z/3.65)\n damp=min(.42,.34*lower+.14*drain)\n mottled=.963+.024*sin(x*7.8+z*1.3)+.015*cos(x*13.5+y*1.7+z*5.)\n weathered.append(tuple(t*mottled*(1-damp*c) for t,c in zip(tone,(1.05,.88,1.04))))\nstones=obj(\"Individual chipped limestone courses and arch stones\",*stonework[:2],limestone,\n uv=stonework[2],ids=weathered)\nnt=limestone.node_tree\np=nt.nodes.get(\"Principled BSDF\")\ntex=next(n for n in nt.nodes if n.type==\"TEX_IMAGE\" and n.image.name.startswith(\"limestone-color\"))\nmix=nt.nodes.new(\"ShaderNodeMixRGB\")\nmix.blend_type=\"MULTIPLY\"\nmix.inputs[0].default_value=1\nshade=nt.nodes.new(\"ShaderNodeVertexColor\")\nshade.layer_name=\"Mineral variation\"\nnt.links.new(tex.outputs[\"Color\"],mix.inputs[1])\nnt.links.new(shade.outputs[\"Color\"],mix.inputs[2])\nnt.links.new(mix.outputs[\"Color\"],p.inputs[\"Base Color\"])\n# Continuous-sized dressing stones have white multiplicative color.\nfor ob in scene.objects:\n if ob.type==\"MESH\" and ob.data.materials and ob.data.materials[0]==limestone and ob!=stones:\n set_tones(ob,[(1,1,1)]*len(ob.data.vertices))\n\n\n# Stone-paved courtyard with physically recessed joints.\ndef floor_z(x,y):\n return .018*sin(x*1.26+y*.39)+.008*cos(x*3.34-y*1.31)+.018+max(y,0)*.012\n\n\npavers=([],[],[],[])\nfor row in range(39):\n yc=-4.93+row*.229\n for col in range(29):\n xc=-2.75+col*.194 + (.090 if row%2 else 0)\n if xc>2.76:\n continue\n dx=rng.uniform(.084,.095)\n dy=rng.uniform(.097,.110)\n q=rng.uniform(.16,.30)\n z=floor_z(xc,yc)+rng.uniform(-.008,.010)\n rot=rng.uniform(-.124,.124)\n contour=[(-1,-1+q),(-1+q,-1),(1-q,-1),(1,-1+q),(1,1-q),(1-q,1),(-1+q,1),(-1,1-q)]\n verts=[]\n for level,scale in [(-.065,.94),(-.015,1),(.012,.96),(.022,.83)]:\n for k,(x,y) in enumerate(contour):\n xx,yy=x*dx*scale,y*dy*scale\n verts.append((xc+cos(rot)*xx-sin(rot)*yy,yc+sin(rot)*xx+cos(rot)*yy,\n z+level+(rng.uniform(-.003,.003) if level>=.012 else 0)))\n faces=[tuple(reversed(range(8)))]\n for k in range(3):\n for j in range(8):\n n=(j+1)%8\n faces.append((k*8+j,k*8+n,(k+1)*8+n,(k+1)*8+j))\n faces.append(tuple(range(24,32)))\n tone=rng.uniform(.51,1.11)\n uv=[(x*2.46+z*.55+col*.131,y*2.62+z*.2+row*.131) for x,y,z in verts]\n append(pavers,verts,faces,uv,(tone,tone*rng.uniform(.96,1.05),tone*rng.uniform(.93,1.04)))\ntiles=obj(\"Wet hand-set courtyard granite setts\",*pavers[:2],pave,uv=pavers[2],ids=pavers[3],smooth=True)\nnt=pave.node_tree\np=nt.nodes.get(\"Principled BSDF\")\ntx=next(n for n in nt.nodes if n.type==\"TEX_IMAGE\" and n.image.name.startswith(\"sett-color\"))\nm=nt.nodes.new(\"ShaderNodeMixRGB\")\nm.blend_type=\"MULTIPLY\"\nm.inputs[0].default_value=1\nv=nt.nodes.new(\"ShaderNodeVertexColor\")\nv.layer_name=\"Mineral variation\"\nnt.links.new(tx.outputs[\"Color\"],m.inputs[1])\nnt.links.new(v.outputs[\"Color\"],m.inputs[2])\nnt.links.new(m.outputs[\"Color\"],p.inputs[\"Base Color\"])\nblock(\"Bed of the courtyard tile\",(0,-.50,-.107),(5.72,8.99,.12),steps,.012)\n\n\ndef water_patch(cx,cy,rx,ry,z,seed):\n verts=[(cx,cy,z)]\n for i in range(106):\n a=i*2*pi/106\n n=1+.106*sin(3*a+seed)+.038*cos(8*a+seed)+.029*sin(13*a)\n verts.append((cx+rx*n*cos(a),cy+ry*n*sin(a),z))\n faces=[(0,i+1,(i+1)%106+1) for i in range(106)]\n obj(\"Irregular shallow pool of rainwater\",verts,faces,puddle)\n\n\nfor x,y,rx,ry in [(.40,-2.56,.79,.68),(-1.24,-2.97,.56,.80),(.97,-1.62,.50,.52),\n (-.16,.9,.53,.36),(-1.95,-.96,.33,.42)]:\n water_patch(x,y,rx,ry,floor_z(x,y)+.022,rng.random()*9)\nblock(\"Small heel-proof drain frame\",(-1.95,-1.70,.046),(.364,.272,.04),bronze,.012)\nblock(\"Shadow below grate\",(-1.95,-1.70,.064),(.310,.207,.009),iron,.005)\nfor k in range(9):\n block(\"Cast drain slot bridge\",(-2.08+k*.033,-1.70,.075),(.015,.214,.014),bronze,.003)\nfor y in [-1.778,-1.622]:\n block(\"Grate maintenance bridge\",(-1.95,y,.075),(.300,.017,.015),bronze,.004)\n\n\n# Hanging iron lantern, flame-shaped bulb and enameled court plaque.\ndef lamp(cx,cy,bottom,scale):\n base=bottom\n w=.145*scale\n top=base+.412*scale\n bx=[(-1,-1),(1,-1),(1,1),(-1,1)]\n section=[(.59,base-.020*scale),(.72,base+.016*scale),(1.0,base+.050*scale),\n (.91,base+.070*scale)]\n vv=[(cx+a*w*k,cy+b*w*k,z) for k,z in section for a,b in bx]\n ff=[(3,2,1,0),(12,13,14,15)]\n for j in range(len(section)-1):\n for i in range(4):\n n=(i+1)%4\n ff.append((j*4+i,j*4+n,(j+1)*4+n,(j+1)*4+i))\n prism(\"Cast iron lantern base\",vv,ff,iron,.007*scale)\n for i,(a,b) in enumerate(bx):\n c,d=bx[(i+1)%4]\n low=base+.061*scale\n high=top-.031*scale\n p0=(cx+a*w*.85,cy+b*w*.85,low)\n p1=(cx+c*w*.85,cy+d*w*.85,low)\n p2=(cx+c*w*1.02,cy+d*w*1.02,high)\n p3=(cx+a*w*1.02,cy+b*w*1.02,high)\n obj(\"Thin lantern glass panel\",[p0,p1,p2,p3],[(0,1,2,3)],lampglass)\n rod(\"Tapered lantern corner iron\",p0,p3,.0115*scale,iron,n=16,bevel=.001)\n rod(\"Lamp top frame rail\",p2,p3,.013*scale,iron,n=16,bevel=.001)\n rod(\"Lamp lower frame rail\",p0,p1,.013*scale,iron,n=16,bevel=.001)\n lid=[(1.17,top-.037*scale),(1.16,top+.006*scale),(.84,top+.028*scale),\n (.44,top+.100*scale),(.21,top+.124*scale)]\n vv=[(cx+a*w*k,cy+b*w*k,z) for k,z in lid for a,b in bx]\n ff=[(3,2,1,0),(16,17,18,19)]\n for j in range(len(lid)-1):\n for i in range(4):\n n=(i+1)%4\n ff.append((j*4+i,j*4+n,(j+1)*4+n,(j+1)*4+i))\n prism(\"Pressed peaked lantern cap\",vv,ff,bronze,.006*scale)\n rod(\"Lantern top finial\",(cx,cy,top+.109*scale),(cx,cy,top+.171*scale),.028*scale,bronze,24,.009)\n rod(\"Bronze lamp burner\",(cx,cy,base+.071*scale),(cx,cy,base+.151*scale),.032*scale,bronze,24,.005)\n bpy.ops.mesh.primitive_uv_sphere_add(segments=32,ring_count=16,radius=.039*scale,\n location=(cx,cy,base+.204*scale))\n ob=bpy.context.object\n ob.name=\"Soft glowing filament envelope\"\n ob.scale.z=1.52\n ob.data.materials.append(bulb)\n for p in ob.data.polygons:\n p.use_smooth=True\n\nlamp(1.48,-.729,2.075,1.06)\nblock(\"Iron hanging bracket flange\",(1.48,-.372,2.709),(.191,.076,.311),iron,.020)\npoints=[(1.48,-.403,2.745),(1.48,-.475,2.803),(1.48,-.572,2.846),\n (1.48,-.672,2.844),(1.48,-.728,2.809),(1.48,-.729,2.687)]\nconnection(\"Curled wall lantern bracket\",points,.023,iron,12)\nlamp(-1.46,3.23,2.18,.68)\nrod(\"Inner court lantern bracket\",(-1.46,3.24,2.56),(-1.46,3.59,2.62),.014,iron)\nblock(\"Court sign chamfered bronze frame\",(1.51,-.364,1.613),(.792,.087,.371),bronze,.036)\nblock(\"Weathered black sign enamel\",(1.51,-.415,1.613),(.729,.026,.313),iron,.021)\nlabel(\"Raised Wren Court plaque\",\"W R E N C O U R T\",.079,(1.51,-.431,1.666),paper,.99)\nlabel(\"Raised number on plaque\",\"N o . 7\",.063,(1.51,-.432,1.548),paper,1.02)\nfor x in [1.177,1.843]:\n rod(\"Weathered bronze plaque screws\",(x,-.427,1.615),(x,-.442,1.615),.014,bronze,20,.002)\n\n\n# Terracotta planters and custom fern fronds.\ndef lathe(name,cx,cy,profile,m,n=64):\n verts=[(cx+r*cos(2*pi*i/n),cy+r*sin(2*pi*i/n),z) for r,z in profile for i in range(n)]\n faces=[]\n for j in range(len(profile)-1):\n for i in range(n):\n k=(i+1)%n\n faces.append((j*n+i,j*n+k,(j+1)*n+k,(j+1)*n+i))\n return obj(name,verts,faces,m,smooth=True)\n\n\nfoliage=[([],[],[],[]) for _ in range(3)]\nplants=[(1.85,-.741,1.05),(2.14,-1.26,.67),(1.43,-.83,.56),(-2.15,-.80,.50),\n (-1.70,2.50,.78),(1.38,2.51,.90)]\nmain_stems=[]\nfor index,(x,y,k) in enumerate(plants):\n ground=floor_z(x,y)+.036\n profile=[(.16,0),(.165,.032),(.197,.13),(.225,.26),(.256,.383),(.279,.406),\n (.283,.439),(.270,.452),(.241,.448),(.236,.413),(.216,.383),(.19,.259),(.155,.09)]\n lathe(\"Hand-thrown clay pot\",x,y,[(r*k,ground+z*k) for r,z in profile],terracotta)\n rod(\"Rain-darkened terracotta soil plug\",(x,y,ground+.327*k),(x,y,ground+.401*k),.232*k,soil,48,.006)\n for j in range(15):\n a=j*2.399+rng.uniform(-.31,.31)\n L=rng.uniform(.39,.86)*k\n height=rng.uniform(.33,.73)*k\n dz=ground+.407*k\n orient=Vector((cos(a),sin(a),0))\n lateral=Vector((-sin(a),cos(a),0))\n origin=Vector((x+rng.uniform(-.055,.055)*k,y+rng.uniform(-.055,.055)*k,dz))\n def frond(t):\n return origin+orient*(L*t**1.27)+Vector((0,0,height*sin(1.95*t)+.10*t*k))\n main_stems.append(([frond(t/19) for t in range(20)],.0037*k))\n for row in range(12):\n t=.25+row*.062\n node=frond(t)\n for side in [-1,1]:\n length=k*(.101+.068*sin(pi*t))*(1-.60*t)\n length*=rng.uniform(.88,1.19)\n direction=(lateral*side*.85+orient*.49+Vector((0,0,.078))).normalized()\n mid=node+direction*(length*.50)+Vector((0,0,length*.10))\n tip=node+direction*length+Vector((0,0,length*.056))\n across=direction.cross(Vector((0,0,1))).normalized()\n span=length*.228\n verts=[node,mid+across*span,mid+Vector((0,0,span*.28)),\n mid-across*span,tip]\n append(foliage[(j+row)%3],verts,[(0,1,2),(0,2,3),(1,4,2),(2,4,3)])\nfor i,(vs,fs,uvs,tones) in enumerate(foliage):\n obj(\"Fern leaflets \"+str(i+1),vs,fs,[leaf1,leaf2,leaf3][i],smooth=True)\nfor path,r in main_stems:\n connection(\"Arching fern rachis\",path,r,stalkmat,6)\n\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(OUT/\"wren-court.blend\"),compress=True)\n\n# Trim Blender-only drawing overhead while retaining the component-level source.\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.context.view_layer.objects.active=bpy.data.objects[\"Bed of the courtyard tile\"]\nbpy.ops.object.convert(target=\"MESH\")\ngroups={}\nfor ob in scene.objects:\n groups.setdefault(ob.data.materials[0].name,[]).append(ob)\nfor material,parts in groups.items():\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in parts:\n ob.select_set(True)\n bpy.context.view_layer.objects.active=parts[0]\n if len(parts)>1:\n bpy.ops.object.join()\n bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\n ob=bpy.context.object\n ob.name=material\n ob.data.name=material\n bm=bmesh.new()\n bm.from_mesh(ob.data)\n bmesh.ops.triangulate(bm,faces=list(bm.faces))\n cutoff=1e-9 if material==paper.name else 1e-11\n unused=[f for f in bm.faces if f.calc_area()\nLOOK\nA low mid-century style sideboard, front three-quarter view. Long walnut cabinet with rounded ends, two tambour doors made of thin vertical rounded slats that curve around the corners, a thick cream travertine top with rounded corners, an open center compartment with a shelf and a small \"ASTER / 04\" brass label, slim brass pulls on the door edges, and four splayed tapered walnut legs with brass foot caps.\n\nSCALE\nAbout 169 cm wide, 79 cm tall, 52 cm deep. Build in meters, +Y up, +Z forward, origin at the center of the cabinet at floor contact height.\n\nPARTS\n1. Top: honed travertine slab with a subtle rolled chamfer, a narrow reveal underneath, and a mitered plinth band at the base of the case. Build: a softened outline slab with thickness.\n2. Case: walnut carcass with rounded ends, inner lining running around the back and behind both tambour panels, an interior shelf. Build: outline-based slabs and jambs.\n3. Tambour tracks: continuous rounded races that guide each set of slats around the corners. Build: track curves following the case outline.\n4. Tambour slats: individually rounded walnut slats placed along each track, left and right sets, curling around the ends. Build: one slat mesh placed and rotated along the track.\n5. Pulls: small offset machined brass handles on the door edges with a finger gap. Build: rounded boxes.\n6. Legs and label: four splayed tapered legs with brass foot caps and graphite glides, plus the ivory \"ASTER / 04\" transfer. Build: tapered cylinders, short brass sleeves, text.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the cabinet center on the floor.\n2. Texture maps: run maps.py first for the walnut grain, travertine and brushed brass maps.\n3. Build order: top slab and plinth, case and lining, tambour tracks, slats, pulls, legs and label.\n4. Assemble: the top sits on the case with a narrow reveal, slats run in the tracks with the center left open, pulls mount on the inner edge of each door, legs splay out from under the plinth.\n5. Materials: cream travertine, satin walnut, oiled walnut interior, blackened bronze trims, warm brushed brass, cocoa laminate back, graphite glides, ivory transfer.\n6. Export: sideboard only, one GLB with the textures embedded.\n\nCHECK\n37,098 triangles across 8 parts. Against the image: about twice as wide as it is tall, top overhangs the case slightly, center opening about a fifth of the width, legs angled outward.\n\n\n```python\n# maps.py\n\"\"\"Original PBR texture maps for walnut, honed travertine and satin brass.\"\"\"\nfrom pathlib import Path\nfrom math import pi\n\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import gaussian_filter\n\nOUT=Path(__file__).resolve().parent/\"maps\"\nOUT.mkdir(exist_ok=True)\nW,H=2048,1024\ny,x=np.mgrid[0:H,0:W]\nu,v=x/W,y/H\nrng=np.random.default_rng(280000)\n\n\ndef field(sig):\n a=gaussian_filter(rng.standard_normal((H,W)),sig,mode=\"wrap\")\n return a/a.std()\n\n\ndef write(name,a,kind=\"png\"):\n img=Image.fromarray(np.clip(np.round(a*255),0,255).astype(\"uint8\"))\n if kind==\"jpg\":\n img.save(OUT/(name+\".jpg\"),quality=95,subsampling=0,optimize=True)\n else:\n img.save(OUT/(name+\".png\"))\n\n\ndef normal(h,strength):\n gy,gx=np.gradient(h)\n a=np.stack([-gx*strength,gy*strength,np.ones_like(h)],2)\n a/=np.linalg.norm(a,axis=2,keepdims=True)\n return .5+.5*a\n\n\n# Closely spaced quarter-cut fibers, long pores and occasional broad figure.\nwarp=.60*np.sin(2*pi*(.99*v+2*u))+.22*np.sin(2*pi*(2.1*v+5*u))+.22*field((42,20))\nknot=np.exp(-((u-.79)/.078)**2-((v-.42)/.42)**2)\nwarp+=.98*knot*np.arctan2((v-.42)*.38,u-.79)\nraw=.16*field((23,1.05))+.095*field((13,4.6))+.058*field((3,.65))\nfor i,amp in [(12,.23),(28,.125),(47,.078),(78,.06),(153,.04),(291,.026)]:\n raw+=amp*np.sin(2*pi*(u*i+warp*(1+i/240)+rng.random()))\npore=np.maximum(field((7.7,.42))-.68,0)**1.9\nfigure=1+raw*.29+.061*field((37,19))-.054*pore\nwood=np.array([.462,.311,.214])[None,None,:]*figure[:,:,None]\nwrite(\"walnut-color\",wood,\"jpg\")\nwrite(\"walnut-roughness\",.358+.032*field((22,6))+.035*raw+.079*np.minimum(pore,1.8))\nwrite(\"walnut-normal\",normal(.033*raw-.020*pore+.008*field((.51,.54)),6.8))\n\nmarbling=field((6,39))\nsand=field((1.0,2.2))\ncloud=field((19,37))\nbedded=.43*np.sin(2*pi*(v*5.9+.16*np.sin(2*pi*u*1.28)))+.16*np.sin(2*pi*v*21.3+.32*cloud)\npores=np.maximum(field((1.03,4.28))-.88,0)**1.77*(.67+.33*np.sin(pi*(v*9+u*.98))**2)\nlimestone=np.array([.86,.789,.658])*(1+.038*cloud[:,:,None]+.028*marbling[:,:,None]+\n .043*bedded[:,:,None]+.017*sand[:,:,None]-.096*pores[:,:,None])\nwrite(\"travertine-color\",limestone,\"jpg\")\nwrite(\"travertine-roughness\",.46+.038*cloud+.038*sand+.11*pores+.031*bedded)\nwrite(\"travertine-normal\",normal(.014*sand+.025*marbling-.031*pores,8.4))\nwrite(\"brass-roughness\",.29+.022*field((.58,8.1))+.017*field((10,45)))\n```\n\n```python\n# aster.py\n\"\"\"Parametric open/closed details for the original Aster tambour sideboard.\"\"\"\nfrom math import cos, pi, sin, sqrt\nfrom pathlib import Path\nfrom random import Random\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Vector\n\nROOT=Path(__file__).resolve().parent\nOUT=Path(sys.argv[sys.argv.index(\"--\")+1]) if \"--\" in sys.argv else ROOT\nSTEM=\"3d-dataset-20261128T0000Z-furniture-aster-tambour-sideboard\"\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\nrng=Random(280000)\n\n\ndef material(name,base,metal,rough,tex=None,coat=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*base,1)\n m.use_nodes=True\n nt=m.node_tree\n p=nt.nodes.get(\"Principled BSDF\")\n for k,val in {\"Base Color\":(*base,1),\"Metallic\":metal,\"Roughness\":rough,\n \"Coat Weight\":coat,\"Coat Roughness\":.23}.items():\n p.inputs[k].default_value=val\n for k,n in (tex or {}).items():\n img=nt.nodes.new(\"ShaderNodeTexImage\")\n img.image=bpy.data.images.load(str(ROOT/\"maps\"/n),check_existing=True)\n img.image.colorspace_settings.name=\"sRGB\" if k==\"Base Color\" else \"Non-Color\"\n if k==\"Normal\":\n bump=nt.nodes.new(\"ShaderNodeNormalMap\")\n bump.inputs[\"Strength\"].default_value=.59\n nt.links.new(img.outputs[\"Color\"],bump.inputs[\"Color\"])\n nt.links.new(bump.outputs[\"Normal\"],p.inputs[k])\n else:\n nt.links.new(img.outputs[\"Color\"],p.inputs[k])\n return m\n\n\nwalnut=material(\"Aster · satin walnut\",(.27,.139,.065),0,.38,{\n \"Base Color\":\"walnut-color.jpg\",\"Roughness\":\"walnut-roughness.png\",\"Normal\":\"walnut-normal.png\"},.24)\nshelf=material(\"Aster · clear oiled walnut interior\",(.25,.119,.060),0,.50,{\n \"Base Color\":\"walnut-color.jpg\",\"Roughness\":\"walnut-roughness.png\"},.13)\nstone=material(\"Honed cream travertine\",(.76,.63,.46),0,.48,{\n \"Base Color\":\"travertine-color.jpg\",\"Roughness\":\"travertine-roughness.png\",\n \"Normal\":\"travertine-normal.png\"},.12)\nbrass=material(\"Hand-brushed warm brass\",(.61,.365,.125),.89,.31,\n {\"Roughness\":\"brass-roughness.png\"})\ndark=material(\"Blackened bronze and shadow trims\",(.039,.030,.020),.68,.44)\nliner=material(\"Rear inset cocoa laminate\",(.108,.052,.029),0,.64)\nrubber=material(\"Graphite leveling glides\",(.027,.029,.029),0,.66)\nink=material(\"Ivory transfer graphics\",(.79,.70,.49),0,.5)\n\n\ndef mesh(name,verts,faces,mat,uvs=None,smooth=False):\n geo=bpy.data.meshes.new(name)\n geo.from_pydata(verts,[],faces)\n geo.update()\n ob=bpy.data.objects.new(name,geo)\n scene.collection.objects.link(ob)\n geo.materials.append(mat)\n coords=geo.uv_layers.new(name=\"UVMap\")\n for p in geo.polygons:\n p.use_smooth=smooth\n for loop in p.loop_indices:\n i=geo.loops[loop].vertex_index\n x,y,z=geo.vertices[i].co\n coords.data[loop].uv=uvs[i] if uvs else (x*.96+y*.74+.5,z*1.15+y*.29)\n return ob\n\n\ndef softened(ob,rad,segments=3):\n m=ob.modifiers.new(\"Soft, finished edges\",\"BEVEL\")\n m.width=rad\n m.segments=segments\n w=ob.modifiers.new(\"Weighted surface normals\",\"WEIGHTED_NORMAL\")\n w.keep_sharp=True\n return ob\n\n\ndef box(name,pos,dim,m,r=.006):\n x,y,z=(i*.5 for i in dim)\n verts=[(-x,-y,-z),(x,-y,-z),(x,y,-z),(-x,y,-z),(-x,-y,z),(x,-y,z),(x,y,z),(-x,y,z)]\n fs=[(3,2,1,0),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7),(4,5,6,7)]\n ob=mesh(name,verts,fs,m)\n ob.location=pos\n if r:\n softened(ob,r)\n return ob\n\n\ndef outline(w,d,rx,ry,segments=20):\n points=[]\n for i,(sx,sy) in enumerate([(1,1),(-1,1),(-1,-1),(1,-1)]):\n for j in range(segments+1):\n a=i*pi/2+j*pi/(2*segments)\n points.append((sx*(w-rx)+rx*cos(a),sy*(d-ry)+ry*sin(a)))\n return points\n\n\ndef horizontal_uv(o,points,direction):\n coords=o.data.uv_layers.active\n n=len(points)\n across=[0.]\n for i,(a,b) in enumerate(zip(points,points[1:]+points[:1])):\n across.append(across[-1]+sqrt((b[0]-a[0])**2+(b[1]-a[1])**2))\n for p in o.data.polygons:\n m=(p.index-1)%n\n for k,loop in enumerate(p.loop_indices):\n v=o.data.vertices[o.data.loops[loop].vertex_index].co\n x,y,z=v\n if p.index in (0,len(o.data.polygons)-1):\n coords.data[loop].uv=(x*.54+.5,y*1.84+.5) if direction==\"stone\" else (y*1.13+.5,x*.53+.5)\n else:\n a=across[m+(k in (1,2))]\n if direction==\"stone\":\n coords.data[loop].uv=(a*.544,.47+z*1.25)\n else:\n coords.data[loop].uv=(z*2.8,a*.57)\n\n\ndef slab(name,curves,mat,pattern):\n # Each curve is (half width, half depth, corner radii, elevation).\n rows=[outline(w,d,rx,ry) for w,d,rx,ry,z in curves]\n n=len(rows[0])\n verts=[(x,y,curves[i][4]) for i,r in enumerate(rows) for x,y in r]\n faces=[tuple(reversed(range(n)))]\n for row in range(len(rows)-1):\n for i in range(n):\n j=(i+1)%n\n faces.append((row*n+i,row*n+j,(row+1)*n+j,(row+1)*n+i))\n faces.append(tuple(range(len(verts)-n,len(verts))))\n ob=mesh(name,verts,faces,mat,smooth=True)\n ob.data.polygons[0].use_smooth=False\n ob.data.polygons[-1].use_smooth=False\n horizontal_uv(ob,rows[0],pattern)\n return ob\n\n\n# Subtle rolled chamfer around the honed slab, a narrow reveal and mitered plinth.\nslab(\"Honed travertine top\",[\n (.831,.252,.165,.149,.742),\n (.842,.259,.171,.156,.746),\n (.844,.260,.172,.157,.750),\n (.844,.260,.172,.157,.779),\n (.843,.259,.171,.156,.783),\n (.838,.254,.168,.152,.789),\n (.834,.251,.165,.149,.791)],stone,\"stone\")\nslab(\"Shadow reveal beneath travertine\",[\n (.811,.233,.150,.133,.735),(.819,.241,.154,.140,.737),(.819,.241,.154,.140,.745)\n],dark,\"wood\")\nslab(\"Walnut upper apron\",[\n (.810,.230,.151,.132,.693),(.818,.237,.155,.137,.698),(.826,.243,.161,.142,.704),\n (.826,.243,.161,.142,.728),(.821,.239,.157,.139,.735),(.814,.234,.151,.133,.737)\n],walnut,\"wood\")\nslab(\"Solid walnut lower plinth\",[\n (.794,.225,.145,.132,.209),(.802,.229,.148,.134,.215),(.817,.239,.154,.140,.226),\n (.825,.243,.160,.141,.237),(.825,.243,.160,.141,.253),(.816,.238,.155,.137,.262),\n (.805,.229,.150,.132,.267)\n],walnut,\"wood\")\nslab(\"Thin brass recessed inlay\",[\n (.824,.242,.159,.140,.240),(.826,.244,.160,.142,.242),(.826,.244,.160,.142,.245),\n (.824,.242,.159,.141,.247)\n],brass,\"wood\")\nslab(\"Recessed lower tambour track\",[\n (.798,.219,.145,.127,.264),(.806,.225,.151,.134,.267),\n (.807,.226,.152,.135,.274),(.803,.222,.147,.131,.278)\n],dark,\"wood\")\nslab(\"Recessed upper tambour track\",[\n (.803,.221,.150,.129,.685),(.807,.224,.151,.133,.688),\n (.807,.224,.151,.133,.698),(.803,.221,.149,.130,.702)\n],dark,\"wood\")\n\n\ndef jamb(name,profile,m):\n verts=[]\n uvs=[]\n for j,(x,y) in enumerate(profile):\n for z in [.267,.694]:\n verts.append((x,y,z))\n uvs.append((j/(len(profile)-1)*1.8,z/.65))\n faces=[]\n for j in range(len(profile)-1):\n i=j*2\n faces.append((i+2,i,i+1,i+3))\n ob=mesh(name,verts,faces,m,uvs,smooth=True)\n s=ob.modifiers.new(\"Laminated timber thickness\",\"SOLIDIFY\")\n s.thickness=.014\n s.offset=-.25\n softened(ob,.0018)\n return ob\n\n\n# The cabinet lining runs around the rear and behind both curled tambour panels.\npts=outline(.784,.200,.141,.133,28)\njamb(\"Rounded interior shell and backing\",pts[87:]+pts[:87],walnut)\nback_points=[(-.635,.182),(.635,.182)]\njamb(\"Inset back lining behind shelves\",back_points,liner)\nfor y in [.172,.176]:\n box(\"Rear liner narrow trim\",(0,y,.676),(1.24,.012,.022),walnut,.005)\nbox(\"Center divider\",(-.069,-.023,.480),(.025,.379,.422),shelf,.008)\nfor x,w in [(-.393,.618),(.286,.676)]:\n box(\"Floating adjustable walnut shelf\",(x,-.016,.475),(w,.380,.034),shelf,.008)\n box(\"Rounded shelf edge nosing\",(x,-.204,.476),(w,.026,.034),walnut,.010)\n box(\"Shelf bottom support cleat\",(x,.132,.451),(w*.83,.027,.021),dark,.006)\nfor x in [-.726,-.087,-.042,.727]:\n for y in [-.141,.137]:\n for j in range(5):\n box(\"Small shelf support pin\",(x,y,.403+j*.029),(.014,.012,.012),brass,.003)\n\n\n# Both sets of individual tambour slats travel along a continuous rounded race.\nXEND=.663\nFRONT=-.2188\nRADIUS=.135\nSTRAIGHT_SIDE=.172\nSLAT=.0166\nARC=RADIUS*pi/2\n\n\ndef track(side,start,d):\n straight=XEND-side*start\n if d<=straight:\n return Vector((start+side*d,FRONT,0)),Vector((side,0,0)),Vector((0,-1,0))\n d-=straight\n if d<=ARC:\n a=d/RADIUS\n return (Vector((side*(XEND+RADIUS*sin(a)),FRONT+RADIUS*(1-cos(a)),0)),\n Vector((side*cos(a),sin(a),0)),Vector((side*sin(a),-cos(a),0)))\n d-=ARC\n if d<=STRAIGHT_SIDE:\n return Vector((side*(XEND+RADIUS),FRONT+RADIUS+d,0)),Vector((0,1,0)),Vector((side,0,0))\n d-=STRAIGHT_SIDE\n if d<=ARC:\n a=d/RADIUS\n return (Vector((side*(XEND+RADIUS*cos(a)),FRONT+RADIUS+STRAIGHT_SIDE+RADIUS*sin(a),0)),\n Vector((-side*sin(a),cos(a),0)),Vector((side*cos(a),sin(a),0)))\n d-=ARC\n return (Vector((side*(XEND-d),FRONT+2*RADIUS+STRAIGHT_SIDE,0)),\n Vector((-side,0,0)),Vector((0,1,0)))\n\n\ndef make_slat(name,side,start,d,number):\n p,t,n=track(side,start,d)\n half=SLAT*.444\n profile=[(-half,-.0061),(half,-.0061),(half,.0009),(half*.90,.0041),\n (half*.62,.0061),(half*.26,.0069),(-half*.26,.0069),\n (-half*.62,.0061),(-half*.90,.0041),(-half,.0009)]\n vv=[]\n for z,f in [(.273,.951),(.279,1),(.682,1),(.689,.951)]:\n for x,y in profile:\n v=p+t*x*f+n*y*f\n vv.append((v.x,v.y,z))\n count=len(profile)\n fs=[tuple(range(count))]\n for j in range(3):\n for k in range(count):\n n1=(k+1)%count\n fs.append((j*count+n1,j*count+k,(j+1)*count+k,(j+1)*count+n1))\n fs.append(tuple(reversed(range(30,40))))\n if side==-1:\n fs=[tuple(reversed(f)) for f in fs]\n x0=rng.random()\n v0=rng.random()*.62\n uv=[(x0+profile[i%count][0]*4+profile[i%count][1]*2,v0+(v[2]-.273)*.91) for i,v in enumerate(vv)]\n ob=mesh(name,vv,fs,walnut,uv,True)\n ob.data.polygons[0].use_smooth=False\n ob.data.polygons[-1].use_smooth=False\n\n\nfor side,start,count in [(-1,.143,65),(1,.503,49)]:\n for j in range(count):\n make_slat((\"Left\" if side<0 else \"Right\")+\" individually rounded tambour slat \"+str(j+1),\n side,start,(j+.42)*SLAT,j)\n\n\ndef pin(name,a,b,r,mat,count=24,rad=.0008):\n a,b=Vector(a),Vector(b)\n d=b-a\n bpy.ops.mesh.primitive_cylinder_add(vertices=count,radius=r,depth=d.length,location=(a+b)*.5)\n ob=bpy.context.object\n ob.name=name\n ob.rotation_mode=\"QUATERNION\"\n ob.rotation_quaternion=d.to_track_quat(\"Z\",\"Y\")\n ob.data.materials.append(mat)\n for p in ob.data.polygons:\n if len(p.vertices)==4:\n p.use_smooth=True\n if rad:\n softened(ob,rad)\n return ob\n\n\n# Small offset machined handles give a readable brass accent and a finger gap.\nfor x in [.128,.519]:\n box(\"Recessed pull plate\",(x,-.2258,.483),(.025,.008,.133),dark,.006)\n box(\"Pull bracket bottom\",(x,-.233,.435),(.016,.018,.018),brass,.004)\n box(\"Pull bracket top\",(x,-.233,.530),(.016,.018,.018),brass,.004)\n box(\"Hollow brass pull grip\",(x,-.250,.4825),(.013,.017,.113),brass,.006)\n for z in [.426,.540]:\n pin(\"Recessed pull fastener\",(x,-.230,z),(x,-.233,z),.0027,brass,20,.0004)\n\n\ndef leg(name,bottom,top,m,profile,n=52):\n a=Vector(bottom)\n b=Vector(top)\n direction=(b-a).normalized()\n s=direction.cross(Vector((0,1,0))).normalized()\n t=direction.cross(s).normalized()\n vv=[]\n for level,r in profile:\n p=a.lerp(b,level)\n for i in range(n):\n angle=i*2*pi/n\n vv.append(p+r*cos(angle)*s+r*sin(angle)*t)\n ff=[tuple(reversed(range(n)))]\n for j in range(len(profile)-1):\n for i in range(n):\n k=(i+1)%n\n ff.append((j*n+i,j*n+k,(j+1)*n+k,(j+1)*n+i))\n ff.append(tuple(range(len(vv)-n,len(vv))))\n uv=[(i/n,level) for level,r in profile for i in range(n)]\n return mesh(name,vv,ff,m,uv,smooth=True)\n\n\nfor side in [-1,1]:\n for front in [-1,1]:\n b=(side*.666,front*.178,.008)\n t=(side*.597,front*.145,.244)\n leg(\"Tapered splayed solid walnut leg\",b,t,walnut,\n [(0,.020),(.08,.022),(.25,.023),(.48,.026),(.73,.032),(.94,.039),(1,.038)])\n leg(\"Satin brass sabot\",b,t,brass,\n [(0,.022),(.024,.023),(.173,.025),(.188,.024)])\n box(\"Small rubber floor glide\",(b[0],b[1],.006),(.032,.033,.012),rubber,.004)\n box(\"Hidden secondary leg mount\",(t[0],t[1],.222),(.148,.098,.049),dark,.016)\nbox(\"Underframe cross rail\",(0,0,.218),(1.225,.140,.042),liner,.012)\n\n\ndef text(name,string,size,loc,m):\n c=bpy.data.curves.new(name,\"FONT\")\n c.body=string\n c.size=size\n c.space_character=1.12\n c.align_x=c.align_y=\"CENTER\"\n c.resolution_u=8\n ob=bpy.data.objects.new(name,c)\n scene.collection.objects.link(ob)\n ob.location=loc\n ob.rotation_euler.x=pi/2\n c.materials.append(m)\n\n\nbox(\"Maker's solid brass interior tablet\",(.291,-.219,.474),(.154,.006,.026),brass,.005)\ntext(\"Aster interior maker's mark\",\"A S T E R / 0 4\",.0132,(.291,-.2227,.474),ink)\n\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(OUT/\"aster-tambour.blend\"),compress=True)\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.context.view_layer.objects.active=bpy.data.objects[\"Walnut upper apron\"]\nbpy.ops.object.convert(target=\"MESH\")\ngroups={}\nfor ob in scene.objects:\n groups.setdefault(ob.data.materials[0].name,[]).append(ob)\nfor name,objects in groups.items():\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in objects:\n ob.select_set(True)\n bpy.context.view_layer.objects.active=objects[0]\n if len(objects)>1:\n bpy.ops.object.join()\n bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\n ob=bpy.context.object\n ob.name=name\n b=bmesh.new()\n b.from_mesh(ob.data)\n bmesh.ops.triangulate(b,faces=list(b.faces))\n cutoff=3e-10 if name==ink.name else 2e-12\n small=[face for face in b.faces if face.calc_area()\nLOOK\nA metric dial caliper lying flat, top view. Satin stainless beam with an engraved millimeter scale \"0-150\" and \"STRATA / D150\" marking, a fixed jaw on the left and a sliding jaw opened a little, a round ivory dial reading \"STRATA\" with a red needle under a clear crystal, a knurled thumb wheel below the dial, and a thin depth rod sticking out of the right end.\n\nSCALE\nAbout 26 cm wide, 18 mm tall, 99 mm deep. Build in meters, +Y up, +Z forward, origin at the center of the tool footprint on the resting plane, jaws posed at 32.40 mm.\n\nPARTS\n1. Beam and fixed jaw: ground stainless beam with the fixed measuring jaw and an extension depth rod. Build: beveled plates.\n2. Slider: movable jaw and carriage that wraps around the rail and exposes the beam scale from the zero index. Build: plates and rectangles around the beam profile.\n3. Graduations: laser-darkened millimeter lines and numbers as real thin geometry on the satin beam. Build: thin rectangles and labels.\n4. Dial: dial housing, ivory enamel face with readable marks and numbers, red needle pointing at 0.40 mm on the two-millimeter dial. Build: lathe for the housing, labels for the marks, a thin needle mesh.\n5. Crystal: one optical surface with two real thickness rings and a clear center window. Build: a lathed lens profile.\n6. Controls and underside: knurled thumb wheel, lock screw with machined shoulders, smooth pinion cover underneath, small copper foil serial plaque. Build: lathe with knurled rims, plates.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the footprint center.\n2. Texture maps: run maps.py first for the satin-ground stainless and steel normal maps.\n3. Build order: beam, fixed jaw and depth rod, slider, graduations, dial, crystal, thumb wheel and lock screw, pinion cover and plaque.\n4. Assemble: slider placed 32.40 mm from the fixed jaw, the depth rod extends by the same amount, the dial sits on the slider with the needle at 0.40, the thumb wheel is under the dial against the beam edge.\n5. Materials: satin stainless, polished stainless edges, blackened steel details, blue-black engraved fill, parkerized carriage, ivory stencil, warm ivory dial, optical crystal, oxide red needle, red copper foil.\n6. Export: caliper only, in resting orientation, one GLB with the textures embedded.\n\nCHECK\n113,378 triangles across 10 parts. Against the image: beam about two and a half times as long as the jaws, dial diameter about half the jaw length, needle pointing at about 20 on the dial face, depth rod sticking out of the right end.\n\n\n```python\n# maps.py\n\"\"\"Generate directional steel wear and aged enamel roughness.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image, ImageDraw\nfrom scipy.ndimage import gaussian_filter\n\nOUT=Path(__file__).resolve().parent/\"maps\"\nOUT.mkdir(exist_ok=True)\nW,H=1536,768\nrng=np.random.default_rng(280300)\n\n\ndef noise(sigma):\n a=gaussian_filter(rng.standard_normal((H,W)),sigma,mode=\"wrap\")\n return a/a.std()\n\n\ndef save(name,values):\n Image.fromarray(np.uint8(np.clip(np.round(values*255),0,255))).save(OUT/(name+\".png\"))\n\n\nbrush=noise((.7,8.8))\nfog=noise((18,30))\nscar=Image.new(\"L\",(W,H))\nd=ImageDraw.Draw(scar)\nfor _ in range(1150):\n x,y=rng.uniform(0,[W,H])\n span=rng.uniform(4,65)\n d.line((x,y,x+span,y+rng.normal(0,.9)),fill=int(rng.uniform(12,110)),width=1)\nwear=gaussian_filter(np.asarray(scar)/255,.46)\nsave(\"steel-color\",np.array([.735,.754,.756])*(1+(.017*fog+.014*brush-.22*wear)[:,:,None]))\nsave(\"steel-roughness\",.27+.029*brush+.020*fog+.29*wear)\nh=.011*brush-.057*wear+.0017*noise(.53)\ngy,gx=np.gradient(h)\nn=np.stack([-gx*5,gy*5,np.ones_like(h)],2)\nn/=np.linalg.norm(n,axis=2,keepdims=True)\nsave(\"steel-normal\",.5+.5*n)\nsave(\"ivory-roughness\",.48+.035*noise(3.4)+.035*noise(.78))\nsave(\"coating-roughness\",.42+.061*noise((2.7,4))+.035*noise(.67)+.08*wear)\n```\n\n```python\n# strata.py\n\"\"\"Parametric original Strata 150 metrology caliper in millimeter design units.\"\"\"\nfrom math import cos, pi, sin\nfrom pathlib import Path\nimport sys\n\nimport bmesh\nimport bpy\nfrom mathutils import Vector\n\nROOT=Path(__file__).resolve().parent\nOUT=Path(sys.argv[sys.argv.index(\"--\")+1]) if \"--\" in sys.argv else ROOT\nSTEM=\"3d-dataset-20261128T0300Z-tools-strata-150-dial-caliper\"\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\n\n\ndef material(name,color,metal,rough,images=None,trans=0,coat=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*color,1)\n m.use_nodes=True\n nt=m.node_tree\n s=nt.nodes.get(\"Principled BSDF\")\n for key,value in {\"Base Color\":(*color,1),\"Metallic\":metal,\"Roughness\":rough,\n \"Transmission Weight\":trans,\"IOR\":1.44,\"Coat Weight\":coat,\n \"Coat Roughness\":.18}.items():\n s.inputs[key].default_value=value\n for key,name in (images or {}).items():\n n=nt.nodes.new(\"ShaderNodeTexImage\")\n n.image=bpy.data.images.load(str(ROOT/\"maps\"/(name+\".png\")),check_existing=True)\n n.image.colorspace_settings.name=\"sRGB\" if key==\"Base Color\" else \"Non-Color\"\n if key==\"Normal\":\n bump=nt.nodes.new(\"ShaderNodeNormalMap\")\n bump.inputs[\"Strength\"].default_value=.60\n nt.links.new(n.outputs[\"Color\"],bump.inputs[\"Color\"])\n nt.links.new(bump.outputs[\"Normal\"],s.inputs[key])\n else:\n nt.links.new(n.outputs[\"Color\"],s.inputs[key])\n return m\n\n\nsteel=material(\"Satin-ground stainless steel\",(.56,.60,.61),.96,.27,{\n \"Base Color\":\"steel-color\",\"Roughness\":\"steel-roughness\",\"Normal\":\"steel-normal\"})\nbright=material(\"Polished stainless edges\",(.69,.72,.73),.99,.18)\ncast=material(\"Parkerized charcoal carriage\",(.042,.055,.064),.72,.39,\n {\"Roughness\":\"coating-roughness\"})\nrack=material(\"Blackened steel details\",(.026,.030,.029),.74,.42)\nivory=material(\"Warm ivory enamel dial\",(.79,.752,.628),0,.49,{\"Roughness\":\"ivory-roughness\"})\nink=material(\"Blue-black engraved scale fill\",(.014,.022,.026),.08,.46)\nred=material(\"Oxide red dial needle\",(.47,.020,.014),.26,.32,coat=.25)\nglass=material(\"Optical dial crystal\",(.978,.989,1),0,.057,trans=1)\ncopper=material(\"Red copper crest foil\",(.68,.33,.128),.84,.28)\npale=material(\"Ivory carriage stencil\",(.86,.826,.72),0,.45)\n\n\ndef mesh(name,verts,faces,mat,uv=None,smooth=False):\n me=bpy.data.meshes.new(name)\n me.from_pydata([Vector(v)*.001 for v in verts],[],faces)\n me.update()\n ob=bpy.data.objects.new(name,me)\n scene.collection.objects.link(ob)\n me.materials.append(mat)\n coords=me.uv_layers.new(name=\"UVMap\")\n for p in me.polygons:\n p.use_smooth=smooth\n for loop in p.loop_indices:\n i=me.loops[loop].vertex_index\n x,y,z=verts[i]\n coords.data[loop].uv=uv[i] if uv else (x*.009+y*.013+.5,z*.035+y*.022+.5)\n return ob\n\n\ndef bevel(ob,r):\n b=ob.modifiers.new(\"Broken machined edges\",\"BEVEL\")\n b.width=r*.001\n b.segments=3\n n=ob.modifiers.new(\"Weighted edge normals\",\"WEIGHTED_NORMAL\")\n n.keep_sharp=True\n return ob\n\n\ndef plate(name,outline,y0,y1,mat,r=.20):\n n=len(outline)\n if sum(x*z2-x2*z for (x,z),(x2,z2) in zip(outline,outline[1:]+outline[:1]))<0:\n outline=outline[::-1]\n verts=[(x,y,z) for y in [y0,y1] for x,z in outline]\n faces=[tuple(range(n)),tuple(reversed(range(n,2*n)))]\n faces.extend(((j+1)%n,j,j+n,(j+1)%n+n) for j in range(n))\n ob=mesh(name,verts,faces,mat)\n if r:\n bevel(ob,r)\n return ob\n\n\ndef rect(name,x,z,w,h,y0,y1,mat,r=.14):\n return plate(name,[(x-w*.5,z-h*.5),(x+w*.5,z-h*.5),(x+w*.5,z+h*.5),(x-w*.5,z+h*.5)],y0,y1,mat,r)\n\n\ndef lathe(name,cx,cz,profile,mat,cap=True,n=128):\n \"\"\"The dial axis points forward (negative Y).\"\"\"\n verts=[(cx+r*cos(2*pi*i/n),y,cz+r*sin(2*pi*i/n)) for r,y in profile for i in range(n)]\n faces=[]\n for j in range(len(profile)-1):\n for i in range(n):\n nxt=(i+1)%n\n faces.append((j*n+i,j*n+nxt,(j+1)*n+nxt,(j+1)*n+i))\n if cap:\n faces.extend([tuple(reversed(range(n))),tuple(range(len(verts)-n,len(verts)))])\n uvs=[(i/n,j/(len(profile)-1)) for j in range(len(profile)) for i in range(n)]\n ob=mesh(name,verts,faces,mat,uvs,smooth=True)\n if cap:\n ob.data.polygons[-1].use_smooth=False\n ob.data.polygons[-2].use_smooth=False\n return ob\n\n\ndef label(name,string,size,x,z,y,mat,spacing=1.0,angle=0):\n c=bpy.data.curves.new(name,\"FONT\")\n c.body=string\n c.size=size*.001\n c.space_character=spacing\n c.resolution_u=10\n c.align_x=c.align_y=\"CENTER\"\n ob=bpy.data.objects.new(name,c)\n scene.collection.objects.link(ob)\n ob.location=(x*.001,y*.001,z*.001)\n ob.rotation_euler=(pi/2,angle,0)\n c.materials.append(mat)\n return ob\n\n\n# Ground beam, fixed measuring jaw, movable slide, and extension depth rod.\nplate(\"Ground stainless measuring beam\",[(-110,-.5),(105,-.5),(109,1.4),(109,15.4),\n (107,17.2),(-101,17.2),(-108,14.3)],-1.55,1.55,steel,.31)\nrect(\"Recessed full-length rack channel\",1,3.05,208,3.12,-1.61,-1.50,rack,.25)\nfor i in range(219):\n x=-101.9+i*.927\n rect(\"Individual machined rack tooth\",x,3.08,.49,2.63,-1.77,-1.54,bright,.057)\nrect(\"Lower bar glide trim\",2,.04,210,.90,-1.66,-1.32,bright,.19)\nrect(\"Depth rod shoulder cap\",107,7.7,4.0,17.0,-2.27,2.39,steel,.35)\nplate(\"Ground extending depth rod\",[(104.2,5.59),(138.63,5.59),(141.23,6.57),(141.40,8.89),\n (138.60,9.72),(104.2,9.72)],-1.12,1.13,bright,.16)\nrect(\"Depth rod indexing band\",119.68,7.62,2.85,2.91,-1.132,-1.105,ink,.04)\n\nfixed=[(-115,9.5),(-110.2,15.5),(-100,17.1),(-96.0,13.6),(-96.0,1.4),\n (-96.0,-53.6),(-97.4,-57.7),(-101.7,-56.7),(-105.6,-44.8),(-108.8,-30.1),(-114.8,-13.6)]\nplate(\"Fixed outer measurement jaw\",fixed,-2.16,2.40,steel,.75)\nplate(\"Fixed inner measurement nib\",[(-112.7,12.6),(-109.7,18.7),(-109.65,33.3),\n (-108.0,40.2),(-104.4,41.8),(-103.15,39.7),(-102.1,26.7),(-96.7,14.0)],-1.68,1.87,steel,.50)\nrect(\"Lapped fixed measuring face\",-96.315,-30.4,.63,43.0,-2.16,2.39,bright,.15)\nplate(\"Moving outer measurement jaw\",[(-63.60,5),(-53.1,5),(-44.7,-5.2),(-45.8,-12.3),\n (-52.5,-28.8),(-56.8,-48.5),(-59.3,-56.6),(-62.2,-58.0),(-63.60,-54.5)],-2.08,2.39,steel,.72)\nplate(\"Moving inner measurement nib\",[(-62.8,14.7),(-67.2,23.3),(-66.94,37.1),\n (-64.42,41.3),(-60.91,39.7),(-59.3,27.2),(-51.2,14.6)],-1.68,1.87,steel,.52)\nrect(\"Lapped moving measuring face\",-63.315,-31.0,.57,42.8,-2.05,2.35,bright,.15)\n\n# Slider wraps around the rail and exposes the beam scale from the zero index.\nslider=[(-65.1,-9.4),(-61.6,-12.0),(-24.2,-12.0),(-18.3,-7.8),(-18.3,18.3),\n (-22.1,22.4),(-59.8,22.5),(-65.1,18.1)]\nplate(\"Cast slider front carriage\",slider,-4.70,-1.76,cast,.82)\nplate(\"Cast slider rear carriage\",slider,1.56,5.52,cast,.79)\nrect(\"Bridge above caliper beam\",-42,19.73,41.4,4.31,-4.5,5.53,cast,.82)\nrect(\"Bridge beneath caliper beam\",-42,-5.4,41.1,7.2,-4.55,5.45,cast,.90)\nrect(\"Brushed index cap\",-63.60,11.0,1.3,11.09,-4.93,-4.62,bright,.25)\nrect(\"Black rubber thumb rest\",-19.49,9,2.6,16.2,-4.86,-2.05,rack,.31)\nlabel(\"Carriage engraving\",\"S T R A T A\",2.08,-42.00,-8.52,-4.86,pale,1.06)\nfor x,z in [(-60.6,-7.7),(-22.4,-7.2),(-60.5,18.1),(-22.1,18.2)]:\n lathe(\"Cross-head socket screw\",x,z,[(1.84,-4.43),(1.87,-4.76),(1.69,-4.96)],bright,n=28)\n rect(\"Slot in screw face\",x,z,2.31,.34,-4.986,-4.948,rack,.04)\n\n# Laser-darkened graduations are true thin geometry over the satin beam.\nfor i in range(151):\n x=-96+i\n height=3.66 if i%10==0 else 2.46 if i%5==0 else 1.47\n rect(\"Millimeter graduation\",x,16.1-height*.5,.177 if i%5 else .241,height,-1.568,-1.548,ink,.020)\n if i%10==0:\n label(\"Metric beam numeral\",str(i),2.78,x,10.79,-1.590,ink,1.05)\nfor i in range(61):\n x=-95.5+i*2.5\n height=1.30 if i%4==0 else .60\n rect(\"Lower alternating scale mark\",x,6.10+height*.5,.172,height,-1.565,-1.546,ink,.016)\nlabel(\"Beam lower range label\",\"M M · 0—150\",2.77,82,11.85,-1.607,ink,1.12)\nlabel(\"Beam lower serial code\",\"S T R A T A / D 1 5 0\",2.00,82,7.29,-1.607,ink,1.10)\n\n# Dial assembly, crystal, readable marks, and red hand at 0.40 mm on the two-millimeter dial.\ncx,cz=-41.8,8.0\nlathe(\"Charcoal dial back housing\",cx,cz,[(18.12,-4.48),(19.19,-5.04),(19.69,-5.63),(19.74,-6.98)],cast)\nlathe(\"Rolled and turned stainless bezel\",cx,cz,[(19.42,-6.74),(20.18,-7.00),(20.61,-7.76),\n (20.59,-9.82),(20.29,-10.28),(19.72,-10.56),(19.02,-10.61),(18.59,-10.25),\n (18.42,-9.75),(18.31,-8.96),(18.06,-8.59),(18.00,-7.54)],bright,False,160)\nlathe(\"Thin dark gasket ring\",cx,cz,[(18.53,-10.06),(18.71,-10.24),(18.55,-10.43),\n (18.25,-10.43),(18.17,-10.24),(18.02,-10.03)],rack,False,144)\nfor i in range(94):\n a=i*2*pi/94\n r=20.60\n xx,zz=cx+r*cos(a),cz+r*sin(a)\n o=rect(\"Fine fluted grip on dial bezel\",0,0,.52,.57,-10.05,-7.94,bright,.11)\n o.rotation_euler.y=-a\n o.location.x=xx*.001\n o.location.z=zz*.001\nlathe(\"Ivory enamel dial face\",cx,cz,[(17.88,-8.28),(17.94,-8.51),(17.80,-8.59)],ivory)\n# A single optical surface with two real thickness rings and a clear central window.\nlathe(\"Clear dial crystal\",cx,cz,[(18.04,-10.04),(18.10,-10.17),(17.93,-10.31)],glass,True,160)\nfor i in range(100):\n t=pi/2-i*2*pi/100\n axis=Vector((cos(t),sin(t)))\n tangent=Vector((-sin(t),cos(t)))\n center=Vector((cx,cz))\n r0=14.83 if i%10==0 else 15.66 if i%5==0 else 16.27\n half=.155 if i%10==0 else .118\n vv=[center+axis*r+tangent*w for r,w in [(r0,-half),(17.27,-half),(17.27,half),(r0,half)]]\n plate(\"Printed dial graduation\",[(v.x,v.y) for v in vv],-8.625,-8.574,ink,.010)\n if i%10==0:\n p=center+12.08*axis\n label(\"Dial numeral\",str(i),2.75,p.x,p.y,-8.637,ink,1.02)\nlabel(\"Makers mark on dial\",\"S T R A T A\",2.27,cx,cz+5.80,-8.645,ink,1.07)\nlabel(\"Dial resolution text\",\"0.02 mm\",2.09,cx,cz-4.20,-8.648,ink,1.06)\nlabel(\"Dial lower calibration\",\"2 mm / rev\",1.53,cx,cz-6.54,-8.647,ink,1.01)\nt=pi/2-2*pi*.20\np=Vector((cx,cz))\naxis=Vector((cos(t),sin(t)))\ns=Vector((-sin(t),cos(t)))\nneedle=[p+axis*l+s*w for l,w in [(-5.65,-.74),(-5.63,.66),(-1.20,.80),(0,.48),\n (16.17,.095),(16.44,0),(16.12,-.113),(.05,-.47),(-1.23,-.84)]]\nplate(\"Aged red indicator hand\",[(v.x,v.y) for v in needle],-9.19,-8.93,red,.033)\nlathe(\"Needle pinion cap\",cx,cz,[(2.14,-8.85),(2.28,-9.03),(2.25,-9.31),(1.93,-9.45)],rack,n=60)\nlathe(\"Polished indicator hub pin\",cx,cz,[(.66,-9.42),(.73,-9.52),(.62,-9.59)],bright,n=32)\n\n# Thumb wheel and lock screw have distinct knurled rims and machined shoulders.\nlathe(\"Feed wheel supporting axle\",-27.7,-13.7,[(4.7,3.43),(4.7,-2.84),(4.3,-3.12)],rack,n=72)\nlathe(\"Thumb roller machined wheel\",-27.7,-13.7,[(5.97,2.42),(6.66,2.04),(6.68,-2.78),\n (6.35,-3.34),(5.3,-3.55)],steel,n=96)\nfor i in range(35):\n a=2*pi*i/35\n o=rect(\"Knurled thumb wheel tooth\",0,0,.67,.546,-2.58,1.86,bright,.14)\n o.rotation_euler.y=-a\n o.location.x=(-27.7+6.67*cos(a))*.001\n o.location.z=(-13.7+6.67*sin(a))*.001\nlathe(\"Feed roller polished front retaining washer\",-27.7,-13.7,[(1.99,-3.35),(2.29,-3.64),(2.18,-3.91)],bright,n=48)\nfor r,zz,length,mat in [(2.02,23.7,3.57,bright),(3.90,26.92,3.92,cast),(3.24,29.03,.59,bright)]:\n bpy.ops.mesh.primitive_cylinder_add(vertices=56,radius=r*.001,depth=length*.001,\n location=(-52.8*.001,.37*.001,zz*.001))\n o=bpy.context.object\n o.name=\"Lock screw collar and shoulder\"\n o.data.materials.append(mat)\n for f in o.data.polygons:\n if len(f.vertices)==4:\n f.use_smooth=True\n bevel(o,.28)\nfor i in range(30):\n a=i*2*pi/30\n o=rect(\"Lock screw grip flute\",0,26.99,.54,2.73,-.31,.28,bright,.10)\n o.rotation_euler.z=a\n o.location.x=(-52.8+3.79*sin(a))*.001\n o.location.y=(.37-3.79*cos(a))*.001\n\n# Smooth underside pinion cover and small copper foil serial plaque.\nlathe(\"Rear pinion cover\",cx,cz,[(13.4,5.38),(13.83,5.77),(14.01,6.23),(13.42,6.64),(12.86,6.74)],\n cast,n=96)\nrect(\"Rear copper foil serial label\",-41.3,7.8,16.4,6.03,6.72,6.86,copper,.18)\nfor x in [-50.4,-33.60]:\n lathe(\"Rear rivet head\",x,7.6,[(1.44,6.65),(1.53,6.79),(1.45,6.92)],bright,n=24)\n\n# Geometry uses the resting orientation so Three.js contact and pivot are predictable.\nfrom mathutils import Matrix\npose=Matrix.Rotation(-pi/2,4,\"X\")\nbpy.context.view_layer.update()\nfor ob in scene.objects:\n ob.matrix_world=pose @ ob.matrix_world\nbpy.context.view_layer.update()\ncoords=[ob.matrix_world @ v.co for ob in scene.objects if ob.type==\"MESH\" for v in ob.data.vertices]\nxmin,xmax=min(p.x for p in coords),max(p.x for p in coords)\nymin,ymax=min(p.y for p in coords),max(p.y for p in coords)\nbase=min(p.z for p in coords)\nfor ob in scene.objects:\n ob.location+=Vector((-(xmin+xmax)*.5,-(ymin+ymax)*.5,-base))\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(OUT/\"strata-150.blend\"),compress=True)\n\nbpy.ops.object.select_all(action=\"SELECT\")\nbpy.context.view_layer.objects.active=bpy.data.objects[\"Ground stainless measuring beam\"]\nbpy.ops.object.convert(target=\"MESH\")\ngroups={}\nfor ob in scene.objects:\n groups.setdefault(ob.data.materials[0].name,[]).append(ob)\nfor name,parts in groups.items():\n bpy.ops.object.select_all(action=\"DESELECT\")\n for ob in parts:\n ob.select_set(True)\n bpy.context.view_layer.objects.active=parts[0]\n if len(parts)>1:\n bpy.ops.object.join()\n bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\n ob=bpy.context.object\n ob.name=name\n bm=bmesh.new()\n bm.from_mesh(ob.data)\n bmesh.ops.triangulate(bm,faces=list(bm.faces))\n cutoff=2e-10 if name in {ink.name,pale.name} else 1e-12\n small=[f for f in bm.faces if f.calc_area()\nLOOK\nA single ripe Comice pear standing upright, front three-quarter view. A wide rounded bottom tapering into a short, slightly lopsided neck. Yellow-green skin with an orange-red blush across the lower front, fine brown speckles and patches of russet, and a thin woody stem curving up and to the right out of a shallow dip at the top.\n\nSCALE\nAbout 80 mm wide, 12 cm tall, 76 mm deep. Build in meters, +Y up, +Z forward, origin at the center of the lower fruit on the resting plane.\n\nPARTS\n1. Fruit body: the pear silhouette with its full base, narrowing neck and slightly off-center axis. Build: a ring mesh swept around a curved axis, with the radius at each height read from a smooth profile curve.\n2. Skin: blush, russeting and lenticel speckles over a waxy peel. Build: one UV texture set (color, roughness, normal) wrapped around the fruit.\n3. Poles: the shallow recess at the top where the stem leaves and the one underneath where the calyx sits. Build: near each pole the profile switches to latitude, so the skin curves smoothly inward.\n4. Stalk: a thin curved woody stem with a lighter cut end. Build: a ring mesh swept along a curve that leans away from the axis, with a separate pith material on the end cap.\n5. Calyx lobes: five narrow dried sepals in the bottom recess. Build: five thin tapered strips with random length and angle, given thickness with a solidify modifier.\n6. Calyx core: the dark dried center the lobes grow from. Build: a small squashed UV sphere.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the center of the lower fruit on the resting plane.\n2. Texture maps: run maps.py first for the pear skin and stem color, roughness and normal maps.\n3. Build order: fruit body, stalk, calyx lobes, calyx core.\n4. Assemble: the stalk rises from the top tip of the fruit, the lobes and core sit in the bottom recess, then everything moves down so the lowest point of the fruit rests at zero.\n5. Materials: waxy peel with orchard blush, russet and lenticels, dried bark on the stalk, exposed pith at the stem scar, dark umber calyx.\n6. Export: pear only, one GLB with the textures embedded.\n\nCHECK\n105,048 triangles across 4 parts. Against the image: height about one and a half times the width, widest point in the lower third, stem about a sixth of the total height and leaning to one side.\n\n\n```python\n# maps.py\n\"\"\"Create the original UV textures for the pear and its stem.\"\"\"\nfrom pathlib import Path\n\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import map_coordinates, gaussian_filter\n\nROOT = Path(__file__).resolve().parent\nMAPS = ROOT / \"maps\"\nMAPS.mkdir(exist_ok=True)\nrng = np.random.default_rng(324091)\n\n\ndef noise(width, height, columns, rows):\n cell = rng.random((rows, columns), dtype=np.float32)\n cell = np.pad(cell, ((1, 1), (2, 2)), mode=\"wrap\")\n x = 2 + np.arange(width, dtype=np.float32) * columns / width\n y = 1 + np.linspace(0, rows - 1, height, dtype=np.float32)\n xx, yy = np.meshgrid(x, y)\n return map_coordinates(cell, [yy, xx], order=3, mode=\"nearest\") - .5\n\n\ndef mix(a, b, w):\n weight = np.asarray(w)[..., None]\n return np.float32(a) * (1 - weight) + np.float32(b) * weight\n\n\ndef save_rgb(name, array):\n Image.fromarray(np.rint(np.clip(array, 0, 255)).astype(\"uint8\")).save(MAPS / name)\n\n\ndef normal(name, relief, width_m, height_m):\n h, w = relief.shape\n dx = (np.roll(relief, -1, axis=1) - np.roll(relief, 1, axis=1)) / (2 * width_m / w)\n dy = np.gradient(relief, axis=0) / (height_m / h)\n xyz = np.stack((-dx, dy, np.ones_like(dx)), axis=-1)\n xyz /= np.linalg.norm(xyz, axis=-1, keepdims=True)\n save_rgb(name, (xyz * .5 + .5) * 255)\n\n\nw, h = 2048, 1536\nu, v = np.meshgrid(np.arange(w, dtype=np.float32) / w, np.linspace(1, 0, h, dtype=np.float32))\nn0 = noise(w, h, 9, 5)\nn1 = noise(w, h, 23, 15)\nn2 = noise(w, h, 69, 45)\nn3 = noise(w, h, 180, 110)\nn4 = noise(w, h, 425, 340)\nmicro = rng.normal(0, 1, (h, w)).astype(\"float32\")\nlight = np.clip(.55 + n0 * .48 + n1 * .19 - v * .10, 0, 1)\nskin = mix([104, 111, 34], [213, 179, 83], light)\nsun_side = (.5 + .5 * np.cos((u - .805) * 2 * np.pi)) ** 4\nblush = np.clip((sun_side * np.exp(-((v - .48) / .36) ** 2) + n0 * .4 +\n n1 * .26 - .25) * .97, 0, .83)\nskin = mix(skin, mix([156, 47, 27], [211, 98, 41], np.clip(.51 + n1 + .3*n3, 0, 1)), blush)\nrusset_field = (.37 * (.5 + .5 * np.cos((u - .615) * 2 * np.pi)) ** 3\n * np.exp(-((v - .20) / .23)**2) + .54 * np.exp(-(1-v)*18)\n + .24 * np.exp(-((v-.33)/.15)**2) * (.5+.5*np.cos((u-.905)*2*np.pi))**17\n + .31 * np.exp(-v*18) + n0*.39 + n1*.24 + n2*.21 + n3*.1)\nrusset = np.clip((russet_field - .198) * 5.1, 0, 1)\nrusset_color = mix([109, 66, 36], [169, 119, 61],\n np.clip(.54 + .47*n1 + .54*n2 + .63*n3 + .34*n4,0,1))\nskin = mix(skin, russet_color, russet*.86)\nskin += (n2*4 + n3*7 + n4*5 + micro*.65)[...,None]\ndots = np.zeros((h,w),dtype=np.float32)\nrim = np.zeros_like(dots)\nfor _ in range(4800):\n cy = rng.integers(5,h-5)\n cx = rng.integers(0,w)\n size = rng.lognormal(.48,.57) * (1.0 + .28*abs(2*(cy/h)-1))\n xx = np.arange(-12, 13)\n yy = np.arange(-10, 11)\n gy, gx = np.meshgrid(yy, xx, indexing=\"ij\")\n tilt = rng.uniform(-.85,.85)\n distance = ((gx + gy*tilt)/(size+.4))**2 + (gy/(size*rng.uniform(.62,1.35)+.1))**2\n iy = cy + yy\n keep = (iy>=0)&(iy .973:\n r*=sqrt((1-v)/.027)\n if v < .028:\n r*=sqrt(v/.028)\n return tuple(c + r*(cos(t)*a + .88*sin(t)*b))\n\n\nstalk_object=ring_mesh(\"02 · Curved woody peduncle\",76,64,stalk,bark,wood)\n# Narrow, permanently dried calyx lobes sit in the underside recess.\nverts=[]; faces=[]; uvs=[]\nfor j in range(5):\n t=j*(2*pi/5)+.22+random.uniform(-.18,.18)\n length=random.uniform(.0032,.0049)\n for k in range(11):\n f=k/10\n for m in range(5):\n q=m/4\n width=(sin(pi*(.055+.92*f)) ** .81)*.00145\n s=(q-.5)*2*width\n rr=.00035+length*f\n z=.00232+.0014*(f-.46)**2+.00036*abs(q-.5)+.00034*sin(j*2)\n verts.append((rr*cos(t)-s*sin(t),rr*sin(t)+s*cos(t),z))\n if k:\n for m in range(4):\n i=j*55+(k-1)*5+m\n faces.append((i,i+1,i+6,i+5))\n uvs.append(((m/10,(k-1)/10),((m+1)/10,(k-1)/10),((m+1)/10,k/10),(m/10,k/10)))\nsepals = surface(\"03 · Five dried calyx lobes\",verts,faces,uvs,bark)\nmodifier=sepals.modifiers.new(\"Thin dried sepal edge\",\"SOLIDIFY\")\nmodifier.thickness=.00014\n\nbpy.ops.mesh.primitive_uv_sphere_add(segments=24,ring_count=14,location=(.00006,.00009,.00226))\ncore=bpy.context.object\ncore.name=\"04 · Calyx core\"\ncore.scale=(.00151,.0014,.00055)\nbpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\nfor face in core.data.polygons:\n face.use_smooth=True\ncore.data.materials.append(dark)\n\nbase_z=min(v.co.z for v in fruit.data.vertices)\nsepals.location.z+=.00065\ncore.location.z+=.00065\nfor obj in scene.objects:\n obj.location.z-=base_z\n\nbpy.ops.object.select_all(action=\"DESELECT\")\nfruit.select_set(True)\nbpy.context.view_layer.objects.active=fruit\nbpy.ops.wm.save_as_mainfile(filepath=str(ROOT/\"orchard-comice-pear.blend\"))\nbpy.ops.export_scene.gltf(filepath=str(ROOT/(STEM+\".glb\")),export_format=\"GLB\",\n export_apply=True,export_yup=True,export_tangents=True)\n```\n\nrun it: `python3 maps.py` then `blender -b --python pear.py`\n\nhere you go bro how does it look? i made the 3d object for u\n\n[3d-dataset-20261128T0400Z-food-orchard-comice-pear.glb](https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/models/orchard-comice-pear/3d-dataset-20261128T0400Z-food-orchard-comice-pear.glb)"}]} {"messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/StarpowerTechnology/3d-Objects/resolve/main/previews/alder-f42-cassette-recorder.jpg"}}, {"type": "text", "text": "create an image of an alder f42 field cassette recorder"}]}, {"role": "assistant", "content": "ok bet\n\n\nLOOK\nA portable cassette recorder, three-quarter view from the front left. A boxy case with a champagne brushed-aluminum face and dark pebbled side shells. A perforated speaker grille on the left, and a cassette door on the right with a window showing a teal-labeled tape, two reels and \"ALDER / FIELD 60\". \"ALDER\", \"F42\" and \"FIELD CASSETTE RECORDER\" are printed below the window. A row of piano keys on top: orange REC, white PLAY, REW, FF and STOP, and gray PAUSE. A red battery light and a small LED level meter at the top left, and a knurled volume knob above three jack sockets on the right side.\n\nSCALE\nAbout 23 cm wide, 14 cm tall, 76 mm deep. Build in meters, +Y up, +Z forward (front face toward +Z), origin at the center of the case footprint on the resting plane.\n\nPARTS\n1. Case: rear impact shell, molded perimeter joint, upper seam, brushed front fascia, rubber feet, corner screws and a lower trim strip. Build: beveled boxes, plus small screw heads.\n2. Speaker: a cavity, surround and woven driver with a dust cap, behind a brushed panel with 525 round holes in a 21 by 25 grid. Build: cylinders for the driver, a frame for the panel, and one generated mesh of beveled hole wells.\n3. Cassette bay: recessed bay, molded door frame, aluminum lower insert, a latch bar with teeth, window trim, a seal and a clear acrylic cover. Build: beveled boxes and rectangular frames.\n4. Cassette and printing: teal label, cream stripe, two tape packs with hubs, a fill scale, and the printed ALDER, F42 and FIELD text. Build: thin boxes, cylinders for the reels, text objects for the labels.\n5. Top controls and meters: six key caps with bushings and legends, microphone slots, the battery lens, level meter bars and a strap socket. Build: beveled boxes in a row, small cylinders, text.\n6. Side and rear: EAR, REMOTE and MIC jacks, a knurled volume knob with 42 grip ribs and an index line, a ribbed battery cover, rear screws and cooling slots. Build: cylinders along the side axis, a ring of small boxes for the knurl, ribbed boxes.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the center of the case footprint.\n2. Texture maps: run maps.py first for the anodized aluminum, pebbled shell and speaker cloth maps.\n3. Build order: case and fascia, speaker, cassette bay and door, cassette and printing, battery light and level meter, top keys and microphone, side jacks and volume knob, strap socket, rear battery cover.\n4. Assemble: speaker on the left half of the face, cassette door on the right half, keys in a row on the top tray, jacks and knob on the right side, battery cover on the back. Bake the modifiers and join everything into one mesh split by material.\n5. Materials: champagne anodized aluminum, pebbled olive-charcoal ABS, graphite polymer, black baffles, woven cloth, satin nickel, polished edges, ivory keys and markings, graphite ink, burnt orange, turquoise label, cream paper, brown tape, clear acrylic, red lens, rubber.\n6. Export: recorder only, one GLB with the textures embedded, then run clean_export.py to strip zero-area triangles.\n\nCHECK\n127,418 triangles in one joined mesh. Against the image: case about 1.6 times as wide as it is tall, speaker and cassette door splitting the face about evenly, six keys in a row on top, the volume knob near the top of the right side.\n\n\n```python\n# maps.py\n\"\"\"Generate the original brushed aluminium and molded shell PBR maps.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import gaussian_filter\n\nout=Path(__file__).resolve().parent/\"maps\"\nout.mkdir(exist_ok=True)\nrng=np.random.default_rng(37041)\nH,W=768,1536\n\ndef variation(sigma, contrast=1):\n a=gaussian_filter(rng.normal(size=(H,W)),sigma,mode=\"wrap\")\n return (a / (a.std()+.000001) * contrast).astype(np.float32)\n\ndef save(name, arr):\n Image.fromarray(np.clip(arr,0,255).astype(\"uint8\")).save(out/(name+\".png\"))\n\ndef normal(prefix, height, px_scale):\n dx=(np.roll(height,-1,1)-np.roll(height,1,1))*.5*px_scale\n dy=(np.roll(height,-1,0)-np.roll(height,1,0))*.5*px_scale\n n=np.stack((-dx,dy,np.ones_like(dx)),-1)\n n/=np.linalg.norm(n,axis=-1,keepdims=True)\n save(prefix+\"-normal\",(n*.5+.5)*255)\n\ngrain=variation((.43,24))\nfine=variation((.48,3.7))\ntonal=variation((33,92))\nmetal=(tonal*1.4+grain*2.5+fine*1.45)\n# Sparse, nearly invisible abrasion marks in the brushing direction.\nscuffs=np.zeros((H,W),dtype=np.float32)\nfor _ in range(540):\n y,x=rng.integers(0,H),rng.integers(0,W)\n length=int(rng.integers(15,220))\n scuffs[y,(x+np.arange(length))%W]+=rng.uniform(-11,9)*np.sin(np.linspace(0,np.pi,length))\nmetal+=gaussian_filter(scuffs,(.4,1.9),mode=\"wrap\")\nsave(\"anodized-color\",np.array([190,181,156])+metal[...,None])\nsave(\"anodized-roughness\",99+tonal*3.3+grain*6.5+fine*4+scuffs*.5)\nnormal(\"anodized\",grain*.46+fine*.26+scuffs*.052,.20)\n\ntooth=variation((1.55,1.55))\nsmall=variation((.45,.45))\nshell=variation((38,40))\nsave(\"shell-color\",np.array([52,57,54])+(shell*1.7+tooth*1.1+small*.65)[...,None])\nsave(\"shell-roughness\",151+shell*4+tooth*6+small*2)\nnormal(\"shell\",tooth*.78+small*.13,.39)\n\ny,x=np.mgrid[:H,:W]\ncloth=np.sin(x*2*np.pi/6)*np.sin(y*2*np.pi/6)\nsave(\"driver-cloth-color\",np.array([48,49,43])+(cloth*7+shell*1.8+small*1.2)[...,None])\n```\n\n```python\n# recorder.py\n\"\"\"Model the original Alder F42 field cassette recorder at full scale.\"\"\"\nimport math\nfrom pathlib import Path\n\nimport bpy\nfrom mathutils import Vector\n\nROOT=Path(__file__).resolve().parent\nSTEM=\"3d-dataset-20261128T0500Z-electronics-alder-f42-cassette-recorder\"\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\nscene.unit_settings.length_unit=\"METERS\"\n\n\ndef material(name,rgb,rough=.45,metal=0,maps=None,coat=0,transmission=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*rgb,1)\n m.use_nodes=True\n n=m.node_tree.nodes\n l=m.node_tree.links\n s=n.get(\"Principled BSDF\")\n for key,val in {\"Base Color\":(*rgb,1),\"Roughness\":rough,\"Metallic\":metal,\n \"Coat Weight\":coat,\"Coat Roughness\":.25,\n \"Transmission Weight\":transmission,\"IOR\":1.46}.items():\n s.inputs[key].default_value=val\n if maps:\n for i,(kind,socket) in enumerate([(\"color\",\"Base Color\"),(\"roughness\",\"Roughness\"),(\"normal\",\"Normal\")]):\n path=ROOT/\"maps\"/f\"{maps}-{kind}.png\"\n if not path.exists():\n continue\n node=n.new(\"ShaderNodeTexImage\")\n node.image=bpy.data.images.load(str(path),check_existing=True)\n node.image.colorspace_settings.name=\"sRGB\" if i==0 else \"Non-Color\"\n node.image.pack()\n node.location=(-650,250-300*i)\n if i==2:\n normal=n.new(\"ShaderNodeNormalMap\")\n normal.location=(-280,-380)\n normal.inputs[\"Strength\"].default_value=.30 if maps==\"anodized\" else .42\n l.new(node.outputs[\"Color\"],normal.inputs[\"Color\"])\n l.new(normal.outputs[\"Normal\"],s.inputs[socket])\n else:\n l.new(node.outputs[\"Color\"],s.inputs[socket])\n return m\n\n\nalloy=material(\"Champagne anodized aluminium\",(.55,.49,.36),.40,.74,\"anodized\")\nshell=material(\"Pebbled olive charcoal ABS\",(.035,.041,.035),.59,0,\"shell\",.08)\nhard=material(\"Graphite cast polymer\",(.023,.026,.022),.41,0,None,.14)\nrecess=material(\"Black baffles and engraved recesses\",(.009,.011,.010),.72)\ncloth=material(\"Woven driver dust fabric\",(.035,.037,.031),.88,0,\"driver-cloth\")\nsteel=material(\"Satin nickel plated hardware\",(.53,.54,.52),.28,.83)\nbright=material(\"Machine polished edges\",(.62,.66,.67),.18,.91)\nwhite=material(\"Warm ivory markings and key caps\",(.79,.744,.61),.50)\nink=material(\"Pad printed graphite legend\",(.017,.021,.018),.60)\naccent=material(\"Burnt orange molded control\",(.59,.093,.025),.36,0,None,.24)\nteal=material(\"Desaturated turquoise cassette label\",(.067,.223,.198),.57)\npaper=material(\"Matte cream cassette paper\",(.70,.62,.43),.72)\ntape=material(\"Brown magnetic tape windings\",(.072,.037,.019),.29,0,None,.25)\nwindow=material(\"Clear acrylic cassette cover\",(.96,.986,1),.035,0,None,0,.98)\nlamp=material(\"Red power indicator lens\",(.65,.036,.012),.21,0,None,.3)\nrubber=material(\"Molded rubber bumpers\",(.021,.023,.020),.78)\n\n\ndef bevel(obj,radius,segments=3):\n if radius:\n mod=obj.modifiers.new(\"Manufactured edge radius\",\"BEVEL\")\n mod.width=radius\n mod.segments=segments\n mod.limit_method=\"ANGLE\"\n mod.harden_normals=True\n w=obj.modifiers.new(\"Area weighted normals\",\"WEIGHTED_NORMAL\")\n w.keep_sharp=True\n return obj\n\n\ndef box(name,pos,size,mat,r=.001,s=3,rot=None):\n bpy.ops.mesh.primitive_cube_add(size=1,location=pos)\n o=bpy.context.object\n o.name=name\n o.dimensions=size\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n if rot:\n o.rotation_euler=rot\n o.data.materials.append(mat)\n return bevel(o,r,s)\n\n\ndef cyl(name,pos,radius,depth,mat,axis=\"z\",r=.00022,vertices=48):\n rot={\"z\":(0,0,0),\"y\":(math.pi/2,0,0),\"x\":(0,math.pi/2,0)}[axis]\n bpy.ops.mesh.primitive_cylinder_add(vertices=vertices,radius=radius,depth=depth,\n location=pos,rotation=rot)\n o=bpy.context.object\n o.name=name\n o.data.materials.append(mat)\n for poly in o.data.polygons:\n poly.use_smooth=len(poly.vertices)==4\n return bevel(o,r)\n\n\ndef mesh(name,verts,faces,materials,uv_axes=(0,2),assignments=None):\n me=bpy.data.meshes.new(name)\n me.from_pydata(verts,[],faces)\n me.update()\n obj=bpy.data.objects.new(name,me)\n scene.collection.objects.link(obj)\n for mat in materials:\n me.materials.append(mat)\n uv=me.uv_layers.new(name=\"Product UV\")\n i,j=uv_axes\n u0=min(v[i] for v in verts)\n v0=min(v[j] for v in verts)\n w=max(v[i] for v in verts)-u0\n h=max(v[j] for v in verts)-v0\n for poly in me.polygons:\n if assignments:\n poly.material_index=assignments[poly.index]\n for k in poly.loop_indices:\n v=verts[me.loops[k].vertex_index]\n uv.data[k].uv=((v[i]-u0)/(w or 1),(v[j]-v0)/(h or 1))\n return obj\n\n\ndef outline(x,z,w,h,r):\n coords=[]\n for j,(cx,cz) in enumerate([(x+w/2-r,z+h/2-r),(x-w/2+r,z+h/2-r),\n (x-w/2+r,z-h/2+r),(x+w/2-r,z-h/2+r)]):\n for k in range(9):\n a=(j+k/8)*math.pi/2\n coords.append((cx+r*math.cos(a),cz+r*math.sin(a)))\n return coords\n\n\ndef rim(name,x,z,outer,inner,front,back,mat):\n loops=[\n [(x1,front,z1) for x1,z1 in outline(x,z,*outer)],\n [(x1,front,z1) for x1,z1 in outline(x,z,*inner)],\n [(x1,back,z1) for x1,z1 in outline(x,z,*inner)],\n [(x1,back,z1) for x1,z1 in outline(x,z,*outer)],\n ]\n vertices=sum(loops,[])\n count=len(loops[0])\n faces=[]\n for j in range(4):\n v=j*count\n w=((j+1)%4)*count\n for i in range(count):\n k=(i+1)%count\n faces.append((v+i,v+k,w+k,w+i))\n return bevel(mesh(name,vertices,faces,[mat]),.00030)\n\n\ndef font_file(bold):\n for stem in (\"truetype/dejavu/DejaVuSans\",\"opentype/urw-base35/NimbusSans\"):\n for suffix in ((\"-Bold.ttf\",\"-Bold.otf\") if bold else (\".ttf\",\"-Regular.otf\")):\n path=Path(\"/usr/share/fonts\")/(stem+suffix)\n if path.is_file():\n return bpy.data.fonts.load(str(path),check_existing=True)\n return bpy.data.fonts.get(\"Bfont\")\n\nfonts={False:font_file(False),True:font_file(True)}\n\n\ndef label(value,pos,height,mat,bold=False,surface=\"front\",align=\"LEFT\"):\n c=bpy.data.curves.new(\"Marking \"+value,\"FONT\")\n c.body=value\n c.size=height\n c.font=fonts[bold]\n c.align_x=align\n c.space_character=1.10\n c.resolution_u=4\n o=bpy.data.objects.new(\"Marking \"+value,c)\n scene.collection.objects.link(o)\n o.location=pos\n if surface==\"front\":\n o.rotation_euler.x=math.pi/2\n elif surface==\"side\":\n o.rotation_euler=(math.pi/2,0,math.pi/2)\n o.data.materials.append(mat)\n bpy.ops.object.select_all(action=\"DESELECT\")\n bpy.context.view_layer.objects.active=o\n o.select_set(True)\n bpy.ops.object.convert(target=\"MESH\")\n return bpy.context.object\n\n\ndef screw(name,pos,axis=\"y\",size=.002):\n cyl(name+\" · nickel head\",pos,size,.0009,steel,axis,.00016,32)\n sign=-1 if axis==\"y\" else 1\n i={\"x\":0,\"y\":1,\"z\":2}[axis]\n p=list(pos)\n p[i]+=sign*.00046\n sizes={\"x\":(.00008,size*1.30,.00045),\"y\":(size*1.30,.00008,.00045),\"z\":(size*1.30,.00045,.00008)}\n box(name+\" · drive slot\",p,sizes[axis],recess,.000025)\n\n\n# Main case, external seams, separate metal face and rubber feet.\nbox(\"Rear impact-resistant case\",(0,.0010,.071),(.227,.052,.130),shell,.0072,6)\nbox(\"Molded perimeter joint\",(0,-.0207,.071),(.224,.011,.126),hard,.0062,5)\nbox(\"Upper shell seam\",(0,.0219,.071),(.224,.0169,.126),shell,.0059,5)\nbox(\"Recessed join around rear half\",(0,.0180,.071),(.2243,.00135,.1264),hard,.0049,5)\nbox(\"Continuous brushed front fascia\",(0,-.0276,.071),(.217,.0071,.121),alloy,.0053,6)\nfor x in [-.084,.084]:\n for y in [-.016,.018]:\n box(\"Non-slip foot\",(x,y,.003),(.021,.013,.006),rubber,.0016,5)\nfor x in [-.103,.103]:\n for z in [.016,.125]:\n screw(\"Faceplate anchor\",(x,-.0311,z),size=.00155)\nbox(\"Continuous lower dark trim\",(0,-.0310,.018),(.204,.0012,.0022),hard,.0005)\nbox(\"Folded top control tray\",(0,.002,.1343),(.190,.032,.0047),alloy,.0021,4)\nbox(\"Upper tray inlay\",(0,.004,.1362),(.184,.0268,.0012),hard,.0014,4)\n\n\n# Speaker assembly. Open holes are individual wells with a beveled lip.\nsx, sz = -.0645,.076\nbox(\"Speaker acoustic cavity\",(sx,-.0326,sz),(.072,.0031,.086),recess,.0032,4)\ncyl(\"Speaker surround\",(sx,-.0341,sz),.035,.0018,hard,\"y\",.0013)\ncyl(\"Woven driver diaphragm\",(sx,-.0352,sz),.030,.0010,cloth,\"y\",.0004)\ncyl(\"Center dust cap\",(sx,-.03575,sz),.012,.0011,cloth,\"y\",.0005)\nrim(\"Brushed speaker panel surround\",sx,sz,(.079,.094,.0039),\n (.0714,.0844,.00105),-.0386,-.0329,alloy)\nvertices=[]; faces=[]; face_mats=[]\ncols,rows=21,25\ndx=.0713/cols\ndz=.08425/rows\nsides=16\nfor j in range(rows):\n for i in range(cols):\n x=sx+(i-(cols-1)/2)*dx\n z=sz+(j-(rows-1)/2)*dz\n start=len(vertices)\n for ring,(y,radius) in enumerate([(-.03850,0),(-.03850,.001135),(-.03808,.00094),(-.03680,.00094)]):\n for k in range(sides):\n a=k*2*math.pi/sides\n u,v=math.cos(a),math.sin(a)\n rr=radius if ring else min(dx/2/max(abs(u),1e-6),dz/2/max(abs(v),1e-6))\n vertices.append((x+rr*u,y,z+rr*v))\n for ring in range(3):\n a=start+ring*sides\n b=a+sides\n for k in range(sides):\n q=(k+1)%sides\n faces.append((a+k,a+q,b+q,b+k))\n face_mats.append(0 if ring<2 else 1)\nmesh(\"525 open circular speaker perforations\",vertices,faces,[alloy,hard],assignments=face_mats)\n\n\n# Cassette door and transparent viewing region.\npx=.0403\nbox(\"Cassette bay recessed interior\",(px,-.033,.076),(.121,.0045,.099),recess,.004,5)\nrim(\"Cassette door molded outer frame\",px,.077,(.126,.104,.0041),\n (.112,.093,.0020),-.0387,-.0333,hard)\nbox(\"Lower door aluminum insert\",(px,-.0388,.0477),(.119,.0035,.0380),alloy,.0025,5)\nbox(\"Door latch grip bar\",(px,-.0421,.0314),(.046,.0022,.0040),hard,.0009,4)\nfor i in range(11):\n box(\"Door latch molded tooth\",(px+(i-5)*.0038,-.04328,.0314),(.0011,.00036,.0023),shell,.00014)\nrim(\"Accented window trim\",px,.0937,(.115,.055,.0034),(.108,.047,.0020),\n -.0407,-.0369,steel)\nrim(\"Cassette window dark seal\",px,.0937,(.1085,.0478,.0021),(.104,.0432,.0015),\n -.04073,-.0377,hard)\nbox(\"Clear acrylic cassette cover\",(px,-.03925,.0937),(.105,.0020,.0444),window,.00092,5)\n\n# Model the visible cassette insert, two coiled tape packs, hubs and printed label.\nbox(\"Cassette insert green label\", (px,-.03575,.0938),(.102,.00135,.0438),teal,.00125,4)\nbox(\"Cassette upper label stripe\",(px,-.03657,.1078),(.098,.0005,.009),paper,.0009,4)\nbox(\"Cassette spool backdrop\",(px,-.03658,.0884),(.091,.00051,.0225),hard,.0020,4)\nfor sign, name in [(-1,\"Supply\"),(1,\"Take-up\")]:\n x=px+sign*.0258\n cyl(name+\" coil collar\",(x,-.03703,.0886),.0101,.00060,steel,\"y\",.00008)\n cyl(name+\" brown tape pack\",(x,-.03742,.0886),.00915 if sign>0 else .0073,.00027,tape,\"y\",.000045)\n for r in [.0046,.0058,.00645,.0070] + ([.0079,.0085,.0090] if sign>0 else []):\n cyl(name+\" layered tape edge\",(x,-.03758+r*.006,.0886),r,.00006,tape,\"y\",.000011)\n cyl(name+\" ivory reel hub\",(x,-.03760,.0886),.00435,.00038,white,\"y\",.000065)\n cyl(name+\" recessed spindle opening\",(x,-.03782,.0886),.0025,.00010,recess,\"y\",.000034,36)\n for i in range(6):\n angle=i*math.pi/3\n box(name+\" hub spline\",(x+.00253*math.cos(angle),-.03790,.0886+.00253*math.sin(angle)),\n (.00102,.00026,.00080),white,.00007,2,(0,-angle,0))\nfor i in range(13):\n z=.0833 if i%3 else .0830\n box(\"Tape fill scale graduation\",(px+(i-6)*.00172,-.03698,z),(.00019,.00016,.0018 if i%3 else .0027),paper,.00002)\nlabel(\"ALDER / FIELD 60\",(px-.045,-.03687,.1058),.0044,ink,True)\nlabel(\"A\",(px+.044,-.03688,.10575),.0049,ink,True,\"front\",\"CENTER\")\nlabel(\"TYPE I · NORMAL BIAS\",(px-.021,-.0369,.0756),.0028,white)\nlabel(\"ALDER\",(px-.053,-.04058,.0512),.0123,ink,True)\nlabel(\"F42\",(px+.051,-.04058,.0512),.0116,ink,True,\"front\",\"RIGHT\")\nlabel(\"FIELD CASSETTE RECORDER\",(px-.0518,-.04059,.0428),.0048,ink)\nbox(\"Orange model stripe\",(px+.037,-.04065,.0441),(.027,.00042,.00115),accent,.00016)\nfor x in [-.014,.094]:\n cyl(\"Cassette door corner plug\",(x,-.0399,.039),.00143,.00055,hard,\"y\",.00012,24)\n\n\n# Lower speaker-side transport indicators.\nlabel(\"MONO / FIELD SERIES\",(sx-.035,-.03121,.0226),.0041,ink,True)\ncyl(\"Orange battery window collar\",(sx-.023,-.03198,.130),.0022,.0014,hard,\"y\",.00012,28)\ncyl(\"Orange battery status lens\",(sx-.023,-.03295,.130),.0015,.00135,lamp,\"y\",.00032,32)\nlabel(\"BATTERY\",(sx-.018,-.03119,.1281),.0041,ink)\nbox(\"Meter window\",(sx+.019,-.0322,.12945),(.026,.0018,.0077),hard,.0013,4)\nfor i in range(11):\n box(\"Signal level bar\",(sx+.0084+i*.00198,-.03317,.12943),(.00129,.00027,.0021+(i%4)*.00034),\n accent if i>7 else white,.00015)\n\n\n# Top mechanical transport keys and an inset microphone grille.\nfor i,(title,mat) in enumerate([(\"REC\",accent),(\"PLAY\",white),(\"REW\",white),\n (\"FF\",white),(\"STOP\",white),(\"PAUSE\",shell)]):\n x=-.043+i*.0203\n z=.1420+(.0014 if i in [0,4] else 0)\n box(title+\" key bushing\",(x,.0075,.1369),(.0187,.0160,.00120),recess,.0018,4)\n box(title+\" transport key\",(x,.0074,z-.0026),(.0167,.0134,.0052),mat,.0016,5)\n label(title,(x,.0050,z+.00011),.0040,white if i in [0,5] else ink,True,\"top\",\"CENTER\")\nfor i in range(9):\n box(\"Microphone perforation well\",(-.079+.0019*i,.0062,.1370),(.00095,.0185,.00072),\n recess,.0004,4)\nlabel(\"MIC\",(-.0717,-.0091,.13696),.0039,white,True,\"top\",\"CENTER\")\nfor x in [-.089,.089]:\n screw(\"Control deck fastener\",(x,.0124,.1369),\"z\",.00155)\n\n\n# Side controls and upper strap socket.\nfor z,name in [(.037,\"EAR\"),(.058,\"REMOTE\"),(.079,\"MIC\")]:\n cyl(name+\" jack oxidized sleeve\",(.1136,-.005,z),.0042,.0037,hard,\"x\",.00048,44)\n cyl(name+\" nickel collar\",(.1155,-.005,z),.00332,.0010,steel,\"x\",.00027,44)\n cyl(name+\" jack insert\",(.1161,-.005,z),.00238,.00105,recess,\"x\",.00012,36)\n label(name,(.11357,.002,z-.00145),.00315,white,False,\"side\")\ncyl(\"Volume operator base\",(.11395,.012,.103),.0105,.0035,hard,\"x\",.0007,52)\ncyl(\"Knurled volume knob\",(.1168,.012,.103),.0089,.0043,hard,\"x\",.00048,64)\nfor i in range(42):\n a=i*2*math.pi/42\n box(\"Volume knob raised grip\",(.1174,.012+.00870*math.cos(a),.103+.00870*math.sin(a)),\n (.0030,.00072,.00054),shell,.00018,3,(a,0,0))\ncyl(\"Volume knob brushed inset\",(.11900,.012,.103),.00745,.00045,alloy,\"x\",.00018,48)\nbox(\"Volume white index\",(.11930,.01195,.10855),(.00011,.00066,.0021),white,.00004)\nlabel(\"VOL\",(.11357,.0098,.1166),.0040,white,True,\"side\")\nbox(\"Strap socket housing\",(-.107,.007,.1375),(.013,.0165,.0069),hard,.0017,4)\ncyl(\"Strap socket nickel keeper\",(-.107,.007,.1413),.0043,.0018,steel,\"z\",.00036,40)\ncyl(\"Strap socket opening\",(-.107,.007,.14235),.0028,.00053,recess,\"z\",.00018,32)\n\n\n# Rear battery service cover with molded ribs and inset hardware.\nbox(\"Rear battery bay seam\",(.012,.0271,.039),(.129,.0047,.0455),hard,.0024,4)\nbox(\"Removable battery cover\",(.012,.0297,.039),(.124,.0048,.041),shell,.0020,5)\nfor i in range(9):\n box(\"Battery door grip rib\",(.036,.0322,.0315+i*.0019),(.028,.0008,.00064),hard,.00028)\nfor x in [-.089,.089]:\n cyl(\"Rear case flush screw\", (x,.0307,.110),.0021,.0012,steel,\"y\",.00025,32)\nfor i in range(12):\n box(\"Rear molded cooling slot\",(-.057+i*.007,.0282,.086),(.0044,.0010,.013),recess,.00095,4)\n\n# Store model alone and pack the images and typefaces for editing.\nfor f in fonts.values():\n if f and f.filepath not in {\"\",\"\"}:\n f.pack()\nbpy.ops.object.select_all(action=\"DESELECT\")\nbpy.ops.wm.save_as_mainfile(filepath=str(ROOT/\"alder-f42.blend\"),compress=True)\n# Preserve every editable part in the saved .blend, then bake modifiers and\n# combine the static export to one material-partitioned mesh.\nview = bpy.context.view_layer\ndepsgraph = bpy.context.evaluated_depsgraph_get()\nobjects = list(scene.objects)\nevaluated = {ob: bpy.data.meshes.new_from_object(ob.evaluated_get(depsgraph),\n preserve_all_data_layers=True, depsgraph=depsgraph) for ob in objects}\nbpy.ops.object.select_all(action=\"DESELECT\")\nfor ob, data in evaluated.items():\n ob.modifiers.clear()\n ob.data = data\n if data.uv_layers.active:\n data.uv_layers.active.name = \"Product UV\"\n ob.select_set(True)\nview.objects.active = objects[0]\nscene.cursor.location = (0,0,0)\nbpy.ops.object.join()\nproduct = bpy.context.object\nproduct.name = \"Alder F42 Field Cassette Recorder\"\nbpy.ops.object.origin_set(type=\"ORIGIN_CURSOR\")\nbpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\nbpy.ops.export_scene.gltf(filepath=str(ROOT/(STEM+\".glb\")),export_format=\"GLB\",\n export_apply=False,export_yup=True,export_tangents=False)\n```\n\n```python\n# clean_export.py\n\"\"\"Remove zero-area triangles left by evaluated bevel and lettering modifiers.\"\"\"\nimport json\nfrom pathlib import Path\nimport struct\nimport sys\n\nimport numpy as np\n\npath=Path(sys.argv[1])\ndata=path.read_bytes()\nmagic,version,total=struct.unpack_from(\"<4sII\",data)\nassert (magic,version,total)==(b\"glTF\",2,len(data))\njson_size,json_type=struct.unpack_from(\"\nLOOK\nA complete skateboard lying upside down, three-quarter view from above. The printed underside faces up: a teal sky, a salmon sun, cream and pink zigzag mountains, and \"SWITCHBACK\" with \"8.25 / SEVEN-PLY MAPLE\" in white. Raised nose and tail, a thin edge showing layered maple plies, silver cast trucks on teal baseplates with orange bushings, and four cream urethane wheels pointing up.\n\nSCALE\nAbout 81 cm wide, 15 cm tall, 23 cm deep. Build in meters, +Y up, deck running along X from tail to nose, origin at the midpoint of the wheel footprint on the resting plane. Model it wheels down; the photo shows it flipped.\n\nPARTS\n1. Deck shape: a popsicle outline with a kicked nose and tail and a gentle concave across the width. Build: one shape function that gives the width, kick and concave at any point on the deck.\n2. Deck skins: printed underside, maple top skin and a cut sheet of black grip tape. Build: grid surfaces sampled from the deck shape at the bottom and top of its thickness.\n3. Deck edge: seven maple plies with thin dark glue lines around a rounded edge. Build: a band of faces around the perimeter, split into layers with alternating veneer and glue materials.\n4. Trucks: enamel baseplate and shock pad, sculpted cast hanger, through axle, pivot arm and cup, kingpin tower, two rebound bushings, saddle, washer and locknut. Build: beveled boxes for the plates, a hanger lofted from elliptical cross sections, tapered links and cylinders for the rest.\n5. Wheels and bearings: four rounded urethane wheels with a printed sidewall, two bearings per wheel with outer race, seal and inner race, axle washers and hex locknuts. Build: lathe the wheel cross section, rings for the bearings, six-sided cylinders for the nuts.\n6. Mounting hardware: four flush bolt heads with recessed drives on top of the deck and plate nuts below each truck. Build: small cylinders placed on the deck surface.\n\nPLAN\n1. Setup: clear the scene, meters, wheels resting at zero, X along the deck from tail to nose.\n2. Texture maps: run maps.py first for the alpine graphic, maple, grip tape, cast aluminum and wheel sidewall maps.\n3. Build order: deck skins, ply edge, then for each truck: baseplate and pad, hanger, axle, pivot, kingpin and bushings, mounting bolts, wheels with bearings and locknuts.\n4. Assemble: baseplates follow the deck underside and tilt with it, hangers hang below the plates with the axles at wheel height, wheels sit on the axle ends with bearings inside them, bolts go through the deck into the plates. Bake the modifiers and join everything into one mesh split by material.\n5. Materials: screen-printed graphic, quarter-sawn maple, amber veneer, dark glue line, black grip tape, cast aluminum, petrol enamel, polished steel, black oxide, black pivot cup, burnt orange bushings, natural urethane tread and printed sidewall.\n6. Export: skateboard only, wheels down, one GLB with the textures embedded, then run clean_export.py to strip zero-area triangles.\n\nCHECK\n155,776 triangles in one joined mesh. Against the image: deck almost four times as long as it is wide, trucks set in from each end by about a sixth of the length, wheels just inside the deck edges.\n\n\n```python\n# maps.py\n\"\"\"Original screen-printed graphics and PBR maps for Switchback 825.\"\"\"\nfrom pathlib import Path\nfrom math import cos, sin, pi\nimport numpy as np\nfrom PIL import Image, ImageDraw, ImageFont\nfrom scipy.ndimage import gaussian_filter\n\nROOT=Path(__file__).resolve().parent\nout=ROOT/\"maps\"\nout.mkdir(exist_ok=True)\nrng=np.random.default_rng(60927)\nFONT=\"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf\"\nBOLD=\"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf\"\n\ndef noise(h,w,sigma):\n values=gaussian_filter(rng.normal(0,1,(h,w)).astype(np.float32),sigma,mode=\"wrap\")\n return values/max(values.std(),.00001)\n\ndef save(name,data):\n Image.fromarray(np.clip(data,0,255).astype(np.uint8)).save(out/(name+\".png\"))\n\ndef normals(name,data,slope):\n x=(np.roll(data,-1,axis=1)-np.roll(data,1,axis=1))*.5*slope\n y=(np.roll(data,-1,axis=0)-np.roll(data,1,axis=0))*.5*slope\n n=np.stack((-x,y,np.ones_like(x)),axis=-1)\n save(name,(n/np.linalg.norm(n,axis=-1,keepdims=True)*.5+.5)*255)\n\nw,h=3072,896\nimage=Image.new(\"RGB\",(w,h),(24,63,65))\nd=ImageDraw.Draw(image)\ndef polygon(points,color):\n d.polygon([(int(w*x),int(h*y)) for x,y in points],fill=color)\ndef line(points,color,width=2):\n d.line([(int(w*x),int(h*y)) for x,y in points],fill=color,width=width)\ndef label(txt,pos,size,color,bold=False):\n d.text((int(w*pos[0]),int(h*pos[1])),txt,font=ImageFont.truetype(BOLD if bold else FONT,size),\n fill=color,anchor=\"mm\",stroke_width=0)\n\ncream=(236,215,167)\nsun_c=(207,103,65)\nd.ellipse((int(.630*w),int(.11*h),int(.630*w+.37*h),int(.48*h)),fill=sun_c)\npolygon([(0,.62),(.12,.54),(.18,.60),(.25,.48),(.35,.61),(.44,.51),(.55,.62),(.65,.51),(.75,.55),(.88,.34),(1,.52),(1,1),(0,1)],(62,108,102))\npeaks=[(0,.72),(.085,.60),(.12,.67),(.205,.47),(.248,.54),(.30,.76),(.35,.69),(.397,.73),(.48,.60),(.51,.65),(.557,.74),(.607,.73),(.69,.50),(.71,.53),(.732,.64),(.77,.56),(.80,.63),(.835,.52),(.917,.73),(1,.68)]\npolygon(peaks+[(1,1),(0,1)],(238,205,145))\npolygon([(0,.81),(.084,.72),(.123,.78),(.205,.47),(.202,.64),(.225,.70),(.238,.80),(.28,.90),(.380,.82),(.41,.93),(.48,.60),(.46,.78),(.54,.96),(.60,.82),(.69,.5),(.676,.68),(.71,.85),(.77,.96),(.84,.58),(.83,.77),(.93,.98),(1,.82),(1,1),(0,1)],(188,121,78))\npolygon([(0,.94),(.14,.86),(.25,.96),(.31,.91),(.43,.98),(.53,.91),(.62,.96),(.72,.91),(.79,.96),(.89,.87),(1,.91),(1,1),(0,1)],(26,63,67))\nline(peaks,(248,226,176),3)\nfor j in range(14):\n vv=.70+j*.025\n points=[]\n for i in range(102):\n u=i/101\n v=vv+(.042+.006*sin(j*.9))*sin(2*pi*u*2.19+j*.056)+.018*sin(2*pi*u*4.62-j*.037)\n points.append((u,v))\n line(points,(181,159,104) if j<10 else (101,137,126),2)\nfor x in [.259,.743]:\n line([(x,.105),(x,.37)],(106,148,133),2)\n line([(x-.021,.24),(x+.021,.24)],(106,148,133),2)\nfor j in range(25):\n line([(.271+j*.019,.105),(.271+j*.019,.113 if j%4==0 else .109)],(133,170,147),3)\nlabel(\"S W I T C H B A C K\",(.453,.223),126,cream,True)\nlabel(\"8.25 / SEVEN-PLY MAPLE\",(.455,.373),34,cream)\nlabel(\"RIDGE SERIES • NO. 03\",(.470,.420),22,(137,170,149))\nart=np.asarray(image,dtype=np.float32)\ngrain=noise(h,w,(.58,50))\nfine=noise(h,w,(.56,.65))\ncloud=noise(h,w,(10,64))\nart+= (grain*1.6+fine*1.2+cloud*.8)[...,None]\nscratches=Image.new(\"L\",(w,h),0)\nsd=ImageDraw.Draw(scratches)\nfor j in range(630):\n x=int(rng.integers(0,w))\n y=int(rng.integers(0,h))\n if 420=0 else halflen-.003\n base=.292 if x>=0 else .307\n t=max(0,(abs(x)-base)/(tip-base))\n width=halfwidth*(1-.032*(x/halflen)**2)*(max(0,1-t*t)**.47)\n y=s*width*(1+.006*math.sin(x*13))\n along=max(0,(abs(x)-(.218 if x>=0 else .227))/(tip-(.218 if x>=0 else .227)))\n kick=(.0395 if x>=0 else .0378)*along**1.72\n concave=.0086*(abs(s)**2.25)*(max(0,1-t*t)**.72)*(1-.45*along)\n core=deck_center+kick+concave+.00140*(x/halflen)\n scale=1-.0042*(math.cos(layer*math.pi)**6)\n return ((x+.00030*s*math.sin(x*13))*scale,y*scale,\n core+(layer-.5)*thickness)\n\nN=190\nM=44\nxs=[.003+halflen*math.sin(-math.pi/2+j*math.pi/N) for j in range(N+1)]\n\ndef sample_uv(x,y,top):\n return ((x+.408)/.818,.5+y/.216 if top else .5-y/.216)\n\ndef face_skin(name,ly,mat,top,griptape=False):\n v=[]; f=[]; uv=[]\n def p(x,s):\n if griptape:\n xyz=shape(x*.995,s*.982,ly)\n return (xyz[0],xyz[1],xyz[2]+.00035)\n return shape(x,s,ly)\n for x in xs[1:-1]:\n for k in range(M+1):\n v.append(p(x,k/M*2-1))\n v.extend([p(xs[0],0),p(xs[-1],0)])\n for j in range(N-2):\n a=j*(M+1)\n b=a+M+1\n for k in range(M):\n f.append((a+k,b+k,b+k+1,a+k+1))\n for k in range(M):\n f.append((len(v)-2,k,k+1))\n a=(N-2)*(M+1)\n f.append((a+k,len(v)-1,a+k+1))\n if not top:\n f=[tuple(reversed(face)) for face in f]\n return objmesh(name,v,f,[mat],[[sample_uv(*v[i][:2],top) for i in face] for face in f],smooth=True)\n\nface_skin(\"Screen-printed underside\",0,graphic,False)\nface_skin(\"Maple deck upper skin\",1,maple,True)\nface_skin(\"Cut sheet of textured grip tape\",1,grip,True,True)\n\n# A continuous rounded edge with seven visible plies and fine dark glue seams.\nperimeter=[(x,-1) for x in xs[1:-1]]+[(xs[-1],0)]+[(x,1) for x in xs[-2:0:-1]]+[(xs[0],0)]\ndivisions=[0,.027,.135,.145,.278,.288,.420,.431,.563,.574,.706,.717,.849,.861,.971,1]\nply_materials=[0,0,2,1,2,0,2,0,2,1,2,0,2,0,0]\nvertices=[shape(x,s,t) for t in divisions for x,s in perimeter]\nfaces=[];uv=[];mi=[]\nnum=len(perimeter)\nfor j in range(len(divisions)-1):\n for i in range(num):\n k=(i+1)%num\n f=(j*num+i,j*num+k,(j+1)*num+k,(j+1)*num+i)\n faces.append(f)\n uv.append([((vertices[a][0]+.408)/.817,divisions[a//num]) for a in f])\n mi.append(ply_materials[j])\nobjmesh(\"Seven laminated maple layers and glue seams\",vertices,faces,[maple,darker,glue],uv,mi,True)\n\ndef annulus(name,x,y,z,r0,r1,depth,mat,axis=(0,1,0)):\n axis=Vector(axis).normalized()\n a=axis.cross(Vector((1,0,0)))\n if a.length < .01:\n a=axis.cross(Vector((0,1,0)))\n a.normalize()\n b=axis.cross(a)\n pos=Vector((x,y,z))\n sides=48\n verts=[]; faces=[]\n for radius,t in [(r1,-depth/2),(r1,depth/2),(r0,depth/2),(r0,-depth/2)]:\n for i in range(sides):\n ang=i*math.tau/sides\n verts.append(tuple(pos+axis*t+radius*(a*math.cos(ang)+b*math.sin(ang))))\n for j in range(4):\n for i in range(sides):\n a0=j*sides\n b0=((j+1)%4)*sides\n k=(i+1)%sides\n faces.append((a0+i,a0+k,b0+k,b0+i))\n return bevel(objmesh(name,verts,faces,[mat]),min(.00024,depth*.16),3)\n\naxles=[-.264,.268]\nwheel_height=.029\n\ndef wheel_mesh(x,y,side):\n cross=[\n (.0106,-.0180),(.0121,-.0184),(.0222,-.01855),(.0248,-.0183),\n (.0265,-.0168),(.0279,-.0142),(.02872,-.0119),(.02896,-.0102),\n (.02900,-.0088),(.02896,-.0068),(.02900,-.0042),(.02900,.0040),\n (.02897,.0066),(.02900,.0086),(.02896,.0100),(.02872,.0116),\n (.02797,.0141),(.0265,.01665),(.0249,.01817),(.0222,.01855),\n (.0121,.01845),(.0106,.01802),(.0104,.0170),(.0104,-.0170)]\n sides=120\n v=[]\n f=[]\n uv=[]\n mi=[]\n phase=.10+x*2.23+side*.56\n for rad,axis in cross:\n for i in range(sides):\n t=math.tau*i/sides\n v.append((x+rad*math.cos(t),y+axis,wheel_height+rad*math.sin(t)))\n for j in range(len(cross)):\n jp=(j+1)%len(cross)\n paint=(side<0 and 1<=j<=4) or (side>0 and 17<=j<=20)\n for i in range(sides):\n k=(i+1)%sides\n face=(j*sides+i,jp*sides+i,jp*sides+k,j*sides+k)\n f.append(face)\n mi.append(int(paint))\n mapped=[]\n for a in face:\n xx=(v[a][0]-x)*side\n zz=v[a][2]-wheel_height\n mapped.append((.5+(xx*math.cos(phase)-zz*math.sin(phase))/.058,\n .5+(xx*math.sin(phase)+zz*math.cos(phase))/.058))\n uv.append(mapped)\n objmesh((\"Left\" if side<0 else \"Right\")+\" rounded urethane wheel\",v,f,[tread,wheel],uv,mi,True)\n\ndef hanger(x):\n sections=[(-.066,.0078,.0089,0),(-.052,.0082,.0093,0),(-.037,.0104,.0111,.0016),\n (-.020,.0152,.0178,.0036),(-.009,.0202,.0199,.0039),(0,.021,.0205,.0040),\n (.009,.0202,.0199,.0039),(.020,.0152,.0178,.0036),\n (.037,.0104,.0111,.0016),(.052,.0082,.0093,0),(.066,.0078,.0089,0)]\n count=32\n verts=[]\n faces=[]\n uv=[]\n sign=1 if x>0 else -1\n for y,rx,rz,dz in sections:\n for i in range(count):\n a=math.tau*i/count\n verts.append((x+rx*math.cos(a)-sign*(.004*(1-abs(y)/.066)),y,wheel_height+dz+rz*math.sin(a)))\n for j in range(len(sections)-1):\n for i in range(count):\n k=(i+1)%count\n face=(j*count+i,(j+1)*count+i,(j+1)*count+k,j*count+k)\n faces.append(face)\n uv.append(((j/len(sections),i/count),((j+1)/len(sections),i/count),\n ((j+1)/len(sections),(i+1)/count),(j/len(sections),(i+1)/count)))\n for j,rev in [(0,True),(len(sections)-1,False)]:\n ids=tuple(j*count+i for i in range(count))\n faces.append(ids[::-1] if rev else ids)\n uv.append([(.50+(verts[a][0]-x)*25,.50+(verts[a][2]-wheel_height)*25) for a in faces[-1]])\n return objmesh(\"Sculpted gravity-cast axle hanger\",verts,faces,[cast],uv,smooth=True)\n\nfor x in axles:\n sign=1 if x>0 else -1\n plate_x=x-sign*.0065\n base_z=shape(plate_x,0,0)[2]-.0049\n plate=box(\"Enamel truck mounting plate\",(plate_x,0,base_z),(.065,.061,.011),base,.0057,5)\n plate.rotation_euler.y=-sign*.069\n pad=box(\"Thin shock pad under baseplate\",(plate_x,0,base_z+.0063),(.067,.063,.0018),dark,.0024)\n pad.rotation_euler.y=plate.rotation_euler.y\n hanger(x)\n cyl(\"Through axle\",(x,0,wheel_height),.0053,.222,fastener,(0,1,0),.00032)\n pivot1=(x+sign*.020,0,base_z-.003)\n pivot2=(x+sign*.036,0,base_z-.013)\n pivot3=(x+sign*.010,0,wheel_height+.011)\n cone_link(\"Cast pivot arm\",pivot2,pivot3,.0090,.0109,cast)\n cone_link(\"Rubber pivot cup\",pivot1,pivot2,.0084,.0093,dark)\n a=Vector((x-sign*.0185,0,base_z-.005))\n b=Vector((x-sign*.0295,0,wheel_height+.0065))\n axis=(b-a).normalized()\n cone_link(\"Cast kingpin tower\",a,a.lerp(b,.35),.0138,.0108,base)\n for low,hi,ra,rb in [(.33,.60,.0112,.0120),(.74,.92,.0118,.0095)]:\n cone_link(\"Compression-shaped rebound bushing\",a.lerp(b,low),a.lerp(b,hi),ra,rb,bush)\n cyl(\"Bushing saddle\",(a+b)*.5,.0125,.0028,cast,axis,.00045)\n cyl(\"Retaining washer\",a.lerp(b,.95),.0113,.00165,polish,axis,.00027)\n cyl(\"Hex kingpin locknut\",b,.0069,.0056,fastener,axis,.00035,6)\n for dx in [-.022,.022]:\n for y in [-.0195,.0195]:\n xx=plate_x+dx\n z=shape(xx,y/halfwidth,1)[2]+.00047\n cyl(\"Flush top bolt head\",(xx,y,z),.0040,.0010,fastener,r=.00029,sides=32)\n cyl(\"Recessed head drive\",(xx,y,z+.00053),.00145,.00019,dark,r=.00004,sides=6)\n cyl(\"Plate mounting nut\",(xx,y,base_z-.00575),.00365,.0035,polish,r=.00038,sides=6)\n for side in [-1,1]:\n y=side*.0865\n wheel_mesh(x,y,side)\n for sl in [-1,1]:\n bearing_y=y+sl*.0179\n annulus(\"Bearing stainless outer race\",x,bearing_y,wheel_height,.00945,.01095,.0024,polish)\n annulus(\"Bearing black seal\",x,bearing_y+sl*.00027,wheel_height,.00627,.00961,.0020,dark)\n annulus(\"Bearing steel inner race\",x,bearing_y,wheel_height,.00495,.00650,.00245,polish)\n annulus(\"Machined axle washer\",x,side*.1067,wheel_height,.00492,.00705,.00155,polish)\n cyl(\"Beveled hex axle locknut\",(x,side*.1103,wheel_height),.00782,.0059,polish,(0,1,0),.00044,6)\n cyl(\"Exposed axle tip\",(x,side*.11324,wheel_height),.00475,.0014,fastener,(0,1,0),.00024,32)\n\nbpy.ops.object.select_all(action=\"DESELECT\")\nbpy.ops.wm.save_as_mainfile(filepath=str(ROOT/\"switchback-825.blend\"),compress=True)\n\n# Keep the full assembly in the editable source. Bake and combine the static\n# GLB by shared materials to avoid issuing a draw for every washer and bolt.\nview=bpy.context.view_layer\ndeps=bpy.context.evaluated_depsgraph_get()\nobjects=list(scene.objects)\nevaluated={o:bpy.data.meshes.new_from_object(o.evaluated_get(deps),\n preserve_all_data_layers=True,depsgraph=deps) for o in objects}\nfor o,m in evaluated.items():\n o.modifiers.clear()\n o.data=m\n if m.uv_layers.active:\n m.uv_layers.active.name=\"Product UV\"\n o.select_set(True)\nview.objects.active=objects[0]\nbpy.ops.object.join()\nproduct=bpy.context.object\nproduct.name=\"Switchback 825 Complete Skateboard\"\nproduct.data.name=product.name\nscene.cursor.location=(0,0,0)\nbpy.ops.object.origin_set(type=\"ORIGIN_CURSOR\")\nbpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\nbpy.ops.export_scene.gltf(filepath=str(ROOT/(STEM+\".glb\")),export_format=\"GLB\",export_yup=True,\n export_apply=False,export_tangents=False)\n```\n\n```python\n# clean_export.py\n\"\"\"Remove zero-area triangles left by evaluated bevel and lettering modifiers.\"\"\"\nimport json\nfrom pathlib import Path\nimport struct\nimport sys\n\nimport numpy as np\n\npath=Path(sys.argv[1])\ndata=path.read_bytes()\nmagic,version,total=struct.unpack_from(\"<4sII\",data)\nassert (magic,version,total)==(b\"glTF\",2,len(data))\njson_size,json_type=struct.unpack_from(\"\nLOOK\nA potted Cape sundew, three-quarter view from above. A slightly tapered blue-gray stoneware pot filled with dark peat, small pebbles and a few pale moss tufts. About twenty long, narrow green leaves arch out from the center, their tips flushed red-orange and fringed with tiny red tentacles. One tall, thin flower stalk rises above the leaves with an open five-petal pink flower and a few closed pink buds.\n\nSCALE\nAbout 26 cm wide, 28 cm tall, 24 cm deep. Build in meters, +Y up, +Z forward, origin at the center of the pot's footprint on the resting plane.\n\nPARTS\n1. Pot: hand-thrown stoneware with a rolled lip, inner wall and foot, slightly wobbly. Build: lathe a wall profile with small sine waves added so it doesn't look machine-made.\n2. Substrate: damp peat surface just below the rim, with 421 loose chips in five shades. Build: a radial grid lifted by a height function, small squashed balls scattered on it.\n3. Moss: five small sphagnum tufts around the crown. Build: clusters of tiny leaf shapes in four green shades.\n4. Leaves: 21 leaves, each a thin petiole flowing into a strap-shaped blade, grooved along the midrib with a ruffled edge and a curled tip. Build: one leaf generator swept along a curved center line, with random length, width, lift and droop per leaf, the youngest leaves shorter.\n5. Tentacles and dew: tapered glandular stalks along the blades, red gland heads and clear mucilage droplets. Build: thin tapered tubes on points picked across each blade, small spheres for the heads and droplets.\n6. Flower stalk: one leafless stalk on a curve, five open pink petals, closed buds, pale stamens, a pistil with three styles, and green sepals. Build: a tube along a bezier curve, curved petal surfaces around a center, small tubes and balls.\n\nPLAN\n1. Setup: clear the scene, meters, origin at the pot's footprint center.\n2. Texture maps: run maps.py first for the ceramic, substrate, leaf and petal maps.\n3. Build order: pot, substrate surface and chips, moss tufts, leaves with tentacles, gland heads and droplets, flower stalk with petals, buds, stamens and styles.\n4. Assemble: the soil sits inside the pot just under the lip, leaves radiate from one crown point at soil level, the flower stalk rises from the same crown and leans off to one side. Join everything into one mesh split by material.\n5. Materials: weathered slate stoneware, dark damp peat, five chip shades, four moss shades, living green leaf blending to red, brown-red aging petioles, red tentacle stalks, wine-red glands, clear mucilage, pink petals and buds, cream pollen, pale lemon styles, olive sepals.\n6. Export: sundew and pot only, one GLB with the textures embedded, then run clean_export.py to strip zero-area triangles.\n\nCHECK\n556,756 triangles in one joined mesh. Against the image: leaves spreading about twice the pot's width, the flower stalk reaching about three times the pot height, the flower leaning off to one side.\n\n\n```python\n# maps.py\n\"\"\"Author original UV textures for the Cape sundew, substrate and pot.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import map_coordinates\n\nOUT=Path(__file__).resolve().parent/\"maps\"\nOUT.mkdir(exist_ok=True)\nrng=np.random.default_rng(68291)\n\ndef noise(h,w,rows,cols):\n cell=np.pad(rng.uniform(-1,1,(rows,cols)).astype(np.float32),2,mode=\"wrap\")\n x,y=np.meshgrid(2+np.arange(w,dtype=np.float32)*cols/w,2+np.arange(h,dtype=np.float32)*rows/h)\n return map_coordinates(cell,[y,x],order=3,mode=\"nearest\")\n\ndef grids(h,w):\n return np.meshgrid(np.arange(w,dtype=np.float32)/w,1-np.arange(h,dtype=np.float32)/h)\n\ndef mix(a,b,weight):\n weight=np.asarray(weight)[...,None]\n return np.asarray(a)*(1-weight)+np.asarray(b)*weight\n\ndef save(name,arr):\n Image.fromarray(np.rint(np.clip(arr,0,255)).astype(np.uint8)).save(OUT/(name+\".png\"))\n\ndef normal(name,height,width,depth):\n h,w=height.shape\n x=(np.roll(height,-1,1)-np.roll(height,1,1))/(2*width/w)\n y=(np.roll(height,-1,0)-np.roll(height,1,0))/(2*depth/h)\n xyz=np.stack((-x,y,np.ones_like(x)),-1)\n save(name,(xyz/np.linalg.norm(xyz,axis=-1,keepdims=True)*.5+.5)*255)\n\nh,w=768,1536\nu,v=grids(h,w)\nlarge=noise(h,w,6,19)\nsmall=noise(h,w,32,124)\nmicro=noise(h,w,109,344)\nrib=np.exp(-((v-.5-.007*large)/.045)**2)\nlong=np.sin(2*np.pi*(v*11+.12*large+.10*small))\nyoung=mix([46,83,25],[128,160,53],np.clip(.53+.28*large+.10*small+.08*long,0,1))\nred=np.clip((u-.45)*1.14 + .21*large+.10*small + .11*(2*abs(v-.5))**2,0,.82)\nblade=mix(young,mix([84,37,18],[143,59,30],.5+.25*large),red)\nblade=mix(blade,[145,170,72],rib*.24)\nblade+=(small*4+micro*3)[...,None]\nsave(\"leaf-color\",blade)\nsave(\"leaf-roughness\",np.clip(.54+.07*large+.043*small-.060*rib,.40,.68)*255)\nnormal(\"leaf-normal\",(rib*29+long*4+small*9+micro*4)*1e-6,.137,.0080)\n\nh,w=1024,2048\nu,v=grids(h,w)\nwide=noise(h,w,12,19)\nsmall=noise(h,w,53,103)\nmicro=noise(h,w,250,498)\nlines=np.sin(2*np.pi*(72*v+.13*wide+.09*small))\nturn=np.sin(2*np.pi*(16*v+.016*wide))\npatina=np.clip((wide*.53+small*.22+micro*.14 + .45*np.exp(-v*9)-.29)*2.0,0,1)\nclay=np.array([81,98,97])+(9*wide+6*small+4*micro+3*turn+1.6*lines)[...,None]\nclay=mix(clay,[145,138,116],patina*.49)\nsave(\"ceramic-color\",clay)\nsave(\"ceramic-roughness\",np.clip(.65+.065*wide+.040*small+.15*patina,.50,.89)*255)\nnormal(\"ceramic-normal\",(wide*49+small*25+micro*11+lines*13+turn*22)*1e-6,.35,.092)\n\nh,w=1024,1024\nlarge=noise(h,w,22,22)\nsmall=noise(h,w,93,93)\nmicro=noise(h,w,322,288)\ngrit=np.clip(1.30*micro+small-.61,0,1)\nearth=mix([35,27,20],[75,58,40],np.clip(.35+.26*large+.29*small+.19*micro,0,1))\nearth=mix(earth,[130,108,75],grit*.20)\nsave(\"substrate-color\",earth)\nnormal(\"substrate-normal\",(large*520+small*135+micro*48+grit*90)*1e-6,.110,.110)\n\nh,w=512,768\nu,v=grids(h,w)\nn0=noise(h,w,10,16)\nn1=noise(h,w,60,48)\nvein=np.maximum(0,np.sin((v-.5)*(17+18*u)+.25*n0))**11\noutside=np.exp(-((u-.82)/.46)**2)\npetal=mix([148,45,91],[225,123,169],np.clip(.22+.60*outside+.10*n0-.14*vein,0,1))\npetal+=(n1*3)[...,None]\nsave(\"petal-color\",petal)\n```\n\n```python\n# sundew.py\n\"\"\"Build an original flowering Cape sundew in a hand-thrown stoneware pot.\"\"\"\nimport math\nfrom pathlib import Path\nimport random\n\nimport bpy\nfrom mathutils import Vector\n\nROOT=Path(__file__).resolve().parent\nSTEM=\"3d-dataset-20261128T0900Z-plants-cape-sundew\"\nTAU=math.tau\nrng=random.Random(114603)\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\nscene.unit_settings.length_unit=\"METERS\"\n\ndef material(name,rgb,rough=.46,maps=None,coat=0,transmission=0,ior=1.43):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*rgb,1)\n m.use_nodes=True\n n=m.node_tree.nodes\n l=m.node_tree.links\n p=n.get(\"Principled BSDF\")\n for key,val in {\"Base Color\":(*rgb,1),\"Roughness\":rough,\"Coat Weight\":coat,\n \"Coat Roughness\":.32,\"Transmission Weight\":transmission,\"IOR\":ior}.items():\n p.inputs[key].default_value=val\n if maps:\n for i,(kind,socket) in enumerate([(\"color\",\"Base Color\"),(\"roughness\",\"Roughness\"),(\"normal\",\"Normal\")]):\n path=ROOT/\"maps\"/f\"{maps}-{kind}.png\"\n if not path.exists():\n continue\n node=n.new(\"ShaderNodeTexImage\")\n node.image=bpy.data.images.load(str(path),check_existing=True)\n node.image.colorspace_settings.name=\"sRGB\" if i==0 else \"Non-Color\"\n node.image.pack()\n node.location=(-615,240-300*i)\n if i==2:\n normal=n.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value=.53 if maps==\"ceramic\" else .42\n normal.location=(-260,-370)\n l.new(node.outputs[\"Color\"],normal.inputs[\"Color\"])\n l.new(normal.outputs[\"Normal\"],p.inputs[socket])\n else:\n l.new(node.outputs[\"Color\"],p.inputs[socket])\n return m\n\nblade=material(\"Cape sundew · living leaf and pedicel\",(.24,.38,.068),.51,\"leaf\",.029,0,1.37)\nblade.node_tree.nodes.get(\"Principled BSDF\").inputs[\"Specular IOR Level\"].default_value=.23\nceramic=material(\"Weathered unglazed slate stoneware\",(.125,.17,.173),.69,\"ceramic\")\ndirt=material(\"Dark damp organic substrate\",(.065,.043,.025),.84,\"substrate\")\nleaf_old=material(\"Quiet brown-red aging petioles\",(.113,.072,.023),.64)\nhair=material(\"Red stalks of the glandular tentacles\",(.414,.024,.032),.48,None,.105)\ngland=material(\"Wine-red gland heads\",(.344,.014,.038),.35,None,.24)\ngel=material(\"Clear digestive mucilage\",(.985,.997,.978),.075,None,.04,.97,1.333)\npetal=material(\"Living pink sundew petals\",(.70,.21,.366),.55,\"petal\",.065)\npink=material(\"Closed rose-pink corolla buds\",(.37,.058,.125),.53)\npollen=material(\"Warm cream pollen\",(.84,.57,.232),.62)\nstyle=material(\"Pale lemon floral styles\",(.76,.82,.40),.52)\nsepal=material(\"Olive-green sepals and flower stalk\",(.177,.286,.049),.56)\nmoss=[material(\"Living sphagnum shade \"+str(i+1),a,.70) for i,a in enumerate(\n [(.22,.294,.052),(.30,.344,.076),(.134,.211,.037),(.386,.401,.126)])]\ndebris=[material(\"Damp substrate chip \"+str(i+1),a,.76) for i,a in enumerate(\n [(.081,.043,.021),(.133,.081,.038),(.058,.039,.023),(.190,.133,.063),(.253,.233,.144)])]\n\ndef wave(t,p=1):\n return max(0,math.sin(math.pi*t))**p\n\nclass Batch:\n def __init__(self,name,mat):\n self.name=name\n self.mat=mat\n self.v=[]\n self.f=[]\n self.uv=[]\n def add(self,vertices,faces,uv=None):\n start=len(self.v)\n self.v.extend(vertices)\n self.f.extend(tuple(start+i for i in face) for face in faces)\n self.uv.extend(uv if uv is not None else [None]*len(faces))\n def build(self,smooth=True):\n if not self.f:\n return None\n m=bpy.data.meshes.new(self.name)\n m.from_pydata(self.v,[],self.f)\n m.update()\n assert not m.validate()\n layer=m.uv_layers.new(name=\"Surface\")\n for p,uv in zip(m.polygons,self.uv):\n p.use_smooth=smooth\n if uv:\n for k,x in zip(p.loop_indices,uv):\n layer.data[k].uv=x\n o=bpy.data.objects.new(self.name,m)\n scene.collection.objects.link(o)\n m.materials.append(self.mat)\n return o\n\ndef ball(batch,center,radii,segments=9,rings=6):\n cx,cy,cz=center\n xr,yr,zr=radii\n v=[(cx,cy,cz-zr)]\n for j in range(1,rings):\n theta=math.pi*j/rings\n rr=math.sin(theta)\n z=cz-zr*math.cos(theta)\n for i in range(segments):\n a=i*TAU/segments\n v.append((cx+xr*rr*math.cos(a),cy+yr*rr*math.sin(a),z))\n v.append((cx,cy,cz+zr))\n f=[]; uv=[]\n for i in range(segments):\n k=(i+1)%segments\n f.extend([(0,1+k,1+i),(len(v)-1,1+(rings-2)*segments+i,1+(rings-2)*segments+k)])\n uv.extend([((.5,0),((i+1)/segments,1/rings),(i/segments,1/rings)),\n ((.5,1),(i/segments,(rings-1)/rings),((i+1)/segments,(rings-1)/rings))])\n for j in range(rings-2):\n a=1+j*segments\n b=a+segments\n for i in range(segments):\n k=(i+1)%segments\n f.append((a+i,a+k,b+k,b+i))\n uv.append(((i/segments,(j+1)/rings),((i+1)/segments,(j+1)/rings),\n ((i+1)/segments,(j+2)/rings),(i/segments,(j+2)/rings)))\n batch.add(v,f,uv)\n\ndef tube(batch,points,radii,sides=7,caps=True):\n v=[]; f=[]; uv=[]\n points=list(map(Vector,points))\n last=len(points)-1\n for j,P in enumerate(points):\n t=(points[min(j+1,last)]-points[max(j-1,0)]).normalized()\n ref=Vector((0,0,1)) if abs(t.z)<.95 else Vector((1,0,0))\n ni=t.cross(ref).normalized()\n nj=t.cross(ni).normalized()\n for i in range(sides):\n a=i*TAU/sides\n v.append(tuple(P+radii[j]*(math.cos(a)*ni+math.sin(a)*nj)))\n for j in range(last):\n for i in range(sides):\n a=j*sides\n b=a+sides\n k=(i+1)%sides\n f.append((a+i,a+k,b+k,b+i))\n uv.append(((j/last,i/sides),(j/last,(i+1)/sides),((j+1)/last,(i+1)/sides),((j+1)/last,i/sides)))\n if caps:\n f.extend([tuple(reversed(range(sides))),tuple(range(last*sides,len(v)))])\n uv.extend([None,None])\n batch.add(v,f,uv)\n\ndef bezier(points,t):\n a,b,c,d=map(Vector,points)\n r=1-t\n return r**3*a+3*r*r*t*b+3*r*t*t*c+t**3*d\n\n# Closed, thrown stoneware body including the lip, inner wall and foot.\npot=Batch(\"Hand-thrown stoneware pot\",ceramic)\npot_profile=[(.00008,0),(.023,0),(.038,0),(.0415,.0001),(.0431,.0006),\n (.0439,.00165),(.0440,.0033),(.0442,.0042),(.0451,.0053),(.0458,.0077),\n (.0470,.016),(.0495,.029),(.0521,.043),(.0550,.056),(.0570,.068),\n (.0582,.073),(.0591,.0743),(.0598,.0752),(.05986,.0773),(.05956,.0786),\n (.0588,.0796),(.0577,.0800),(.0562,.07997),(.0553,.0795),\n (.0547,.0785),(.0545,.0769),(.0541,.0728),(.0527,.065),(.0502,.051),\n (.0471,.037),(.0446,.022),(.0428,.0124),(.0416,.0105),(.0384,.00995),\n (.0227,.0099),(.00008,.0099)]\nn=180\nv=[]; f=[]; uv=[]\nfor j,(rad,z) in enumerate(pot_profile):\n for i in range(n):\n a=i*TAU/n\n handmade=(.00020*math.sin(3*a+z*29)+.00013*math.sin(5*a-z*38)+.000079*math.sin(12*a+z*95))\n r=rad+handmade*min(1,rad/.025)\n z2=z+(.00019*math.sin(3*a+.41)+.00010*math.sin(7*a))*min(1,z/.072)\n v.append((r*math.cos(a),r*math.sin(a),z2))\nfor j in range(len(pot_profile)-1):\n for i in range(n):\n k=(i+1)%n\n a=n*j\n b=a+n\n f.append((a+i,a+k,b+k,b+i))\n y0=pot_profile[j][1]/.080\n y1=pot_profile[j+1][1]/.080\n uv.append(((i/n,y0),((i+1)/n,y0),((i+1)/n,y1),(i/n,y1)))\nf.extend([tuple(reversed(range(n))),tuple(range(len(v)-n,len(v)))])\nuv.extend([None,None])\npot.add(v,f,uv)\npot.build()\n\n# Textured peat surface and actual chips below the crown.\nearth=Batch(\"Damp peat and coarse substrate surface\",dirt)\ndef soil_z(x,y):\n return .0727+.0013*math.sin(x*103+y*84)*math.cos(y*83-x*57)+.00066*math.sin(x*280-y*210)\nv=[(0,0,soil_z(0,0))]; f=[]; uv=[]\nradial=32\naround=136\nfor j in range(1,radial+1):\n for i in range(around):\n a=i*TAU/around\n x=.0536*(j/radial)*math.cos(a)\n y=.0536*(j/radial)*math.sin(a)\n v.append((x,y,soil_z(x,y)))\nfor i in range(around):\n f.append((0,1+i,1+(i+1)%around))\nfor j in range(radial-1):\n for i in range(around):\n a=1+j*around\n b=a+around\n k=(i+1)%around\n f.append((a+i,b+i,b+k,a+k))\nfor face in f:\n uv.append(tuple((.5+v[i][0]/.108,.5+v[i][1]/.108) for i in face))\nearth.add(v,f,uv)\nearth.build()\nchips=[Batch(\"Distinct substrate chips · shade \"+str(i+1),mat) for i,mat in enumerate(debris)]\nfor j in range(421):\n a=rng.uniform(0,TAU)\n r=rng.uniform(0,.0511)**.60*.0511**.40\n x,y=r*math.cos(a),r*math.sin(a)\n size=rng.uniform(.00046,.00219)*(1.14 if j%7==0 else 1)\n z=soil_z(x,y)-size*.18\n ball(chips[rng.choices(range(5),[34,18,33,12,3])[0]],(x,y,z),\n (size,size*rng.uniform(.46,1.10),size*rng.uniform(.29,.66)),6,4)\nfor b in chips:\n b.build()\n\n# Small moss tufts around the potted specimen, with leaf-scale geometry.\nmoss_groups=[Batch(\"Small sphagnum leaves · shade \"+str(i+1),mat) for i,mat in enumerate(moss)]\nfor cx,cy,number,spread in [(-.027,-.025,46,.012),(.027,-.032,39,.009),(.020,.031,28,.009),\n (-.031,.026,32,.010),(0,-.036,15,.006)]:\n for k in range(number):\n a=rng.uniform(0,TAU)\n r=spread*math.sqrt(rng.random())\n x,y=cx+r*math.cos(a),cy+r*math.sin(a)\n if x*x+y*y>.051**2:\n continue\n Z=soil_z(x,y)\n height=rng.uniform(.0024,.0060)\n group=moss_groups[rng.randrange(4)]\n for j in range(rng.randint(7,11)):\n phi=a+j*2.39996\n H=Z+height*(.37+.066*j)\n direction=Vector((math.cos(phi),math.sin(phi),.45+rng.random()*.55))\n side=Vector((-math.sin(phi),math.cos(phi),0))\n mid=Vector((x,y,H))+direction*rng.uniform(.00055,.00142)\n root=Vector((x,y,H))\n tip=mid+direction*rng.uniform(.0003,.00076)\n width=rng.uniform(.00018,.00039)\n group.add([tuple(root),tuple(mid-side*width),tuple(tip),tuple(mid+side*width),\n tuple(mid+Vector((0,0,.00020)))],\n [(0,1,4),(1,2,4),(2,3,4),(3,0,4)])\nfor group in moss_groups:\n group.build()\n\n# Anatomically separate petiole and strap-shaped lamina in each continuous leaf.\ntentacles=Batch(\"Tapered capitate tentacle stalks\",hair)\nglands=Batch(\"Red glandular terminal heads\",gland)\ndroplets=Batch(\"Clear suspended mucilage droplets\",gel)\nroot=Vector((-.0027,.0051,.0792))\ncount=0\n\ndef leaf(i,a,length,width,lift,droop,tilt,young):\n global count\n radial=Vector((math.cos(a),math.sin(a),0))\n lateral=Vector((-math.sin(a),math.cos(a),0))\n anchor=root+radial*rng.uniform(.0020,.0057)+Vector((0,0,rng.uniform(-.0017,.0075)))\n drift=rng.uniform(-.025,.025)\n wave_phase=rng.uniform(-math.pi,math.pi)\n curl=rng.uniform(.008,.025) if young else rng.uniform(.003,.021)\n def center(u):\n rr=length*(.93*u+.07*math.sin(u*math.pi/2))-curl*max(0,(u-.75)/.25)**1.7\n zz=lift*(math.sin(u*1.58))**1.24-droop*max(0,(u-.28)/.72)**1.72\n zz+=.0115*math.sin(math.pi*u)**1.7\n zz+=(.012 if young else .0043)*max(0,(u-.72)/.28)**1.38\n return anchor+radial*rr+lateral*(drift*u*u+.0045*math.sin(u*2.4+wave_phase)*u)+Vector((0,0,zz))\n def frame(u):\n C=center(u)\n T=(center(min(1,u+.002))-center(max(0,u-.002))).normalized()\n R=lateral.copy()\n U=T.cross(R).normalized()\n R=U.cross(T).normalized()\n turn=tilt*(.25+.75*u)+.11*math.sin(4*u+wave_phase)\n return C,T,(R*math.cos(turn)+U*math.sin(turn)),(U*math.cos(turn)-R*math.sin(turn))\n def point(u,q,under=False):\n C,T,R,U=frame(u)\n petiole=.00088+.00062*wave(u)**.58\n transition=max(0,min(1,(u-.43)/.18))\n transition=transition*transition*(3-2*transition)\n edge_taper=math.sqrt(max(.001,1-(max(0,(u-.90)/.103))**2))\n w=(petiole*(1-transition)+width*transition)*edge_taper\n # Leaf surface is gently grooved along the midrib, with ruffled margins.\n groove=.00060*q*q*transition+.000085*math.cos(13*u+wave_phase+1.8*q)*abs(q)\n offset=groove-(.00024+.00010*(1-q*q) if under else 0)\n return C+R*(q*w)+U*offset\n B=Batch(\"Leaf %02d · petiole and trap blade\"%(i+1),leaf_old if i<2 else blade)\n cols,rows=18,103\n v=[]; f=[]; UV=[]\n for under in [False,True]:\n v.extend(tuple(point(j/rows,2*k/cols-1,under)) for j in range(rows+1) for k in range(cols+1))\n Ns=(cols+1)*(rows+1)\n for under in [False,True]:\n k0=Ns if under else 0\n for j in range(rows):\n for k in range(cols):\n a=k0+j*(cols+1)+k\n face=(a,a+cols+1,a+cols+2,a+1)\n UVs=((j/rows,k/cols),((j+1)/rows,k/cols),((j+1)/rows,(k+1)/cols),(j/rows,(k+1)/cols))\n f.append(face[::-1] if under else face)\n UV.append(UVs[::-1] if under else UVs)\n for j in range(rows):\n for k in (0,cols):\n a=j*(cols+1)+k\n b=a+cols+1\n face=(a,b,b+Ns,a+Ns)\n f.append(face[::-1] if k==0 else face)\n UV.append(((j/rows,k/cols),((j+1)/rows,k/cols),((j+1)/rows,k/cols),(j/rows,k/cols)))\n B.add(v,f,UV)\n B.build()\n if i<2:\n return\n picks=[]\n for j in range(17 if young else 24):\n u=.536+.45*(j+.52)/ (17 if young else 24)\n for side in (-1,1):\n picks.append((u+rng.uniform(-.0052,.0052),side*rng.uniform(.825,.975),True))\n for j in range(12 if young else 19):\n u=.55+.433*(j+.50)/(12 if young else 19)\n for q in (-.63,-.27,.13,.49):\n if rng.random()<.15: continue\n picks.append((u+rng.uniform(-.011,.011),q+rng.uniform(-.101,.101),False))\n for u,q,edge in picks:\n P=point(u,q)\n C,T,R,U=frame(u)\n height=rng.uniform(.00165,.00280) if edge else rng.uniform(.00093,.00185)\n if young: height*=.74\n direction=(U*(.76 if edge else 1.0)+R*(q*(.97 if edge else .28))+T*rng.uniform(-.36,.55)).normalized()\n top=P+direction*height\n bend=top+T*.00028+R*q*.00019\n start_width=rng.uniform(.000058,.000087)\n tube(tentacles,[P-U*.000051,P+direction*height*.40,top*.72+bend*.28,bend],\n [start_width,start_width*.74,start_width*.60,start_width*.58],6,False)\n r=rng.uniform(.000116,.000194)*(1.1 if edge else 1)\n ball(glands,bend,(r,r,r*1.11),8,5)\n if rng.random()<(.87 if edge else .72):\n G=bend+direction*rng.uniform(.000077,.000151)\n r2=rng.uniform(.000144,.000315)*(1.10 if edge else 1.0)\n ball(droplets,G,(r2*rng.uniform(.92,1.08),r2,r2*rng.uniform(.91,1.13)),9,6)\n count+=1\n\nangles=[.15,3.43,5.34,2.92,4.45,1.92,.84,3.82,5.94,2.37,4.94,1.20,\n .37,3.20,5.42,2.01,4.12,5.84,.94,2.84,4.66]\nfor i,a in enumerate(angles):\n if i<2:\n length=rng.uniform(.087,.098)\n width=rng.uniform(.0022,.0028)\n lift=rng.uniform(.025,.034)\n droop=rng.uniform(.031,.044)\n elif i<14:\n length=rng.uniform(.105,.147)\n width=rng.uniform(.0032,.0044)\n lift=rng.uniform(.063,.104)\n droop=rng.uniform(.010,.047)\n elif i<18:\n length=rng.uniform(.085,.121)\n width=rng.uniform(.00285,.0039)\n lift=rng.uniform(.079,.120)\n droop=rng.uniform(.003,.032)\n else:\n length=rng.uniform(.054,.087)\n width=rng.uniform(.0021,.0028)\n lift=rng.uniform(.073,.089)\n droop=rng.uniform(.003,.020)\n leaf(i,a,length,width,lift,droop,rng.uniform(-.44,.39),i>=17)\ntentacles.build()\nglands.build()\ndroplets.build()\nprint(f\"Modeled {count} capitate tentacles and {len(droplets.v)} droplet vertices.\")\n\n# One leafless flowering scape, with a mature five-petalled flower and younger buds.\nstem=Batch(\"Pink-flowered cyme and sepals\",sepal)\nsc=[tuple(root+Vector((.0037,.0065,-.0005))),(-.015,.012,.136),(-.071,.020,.222),(-.071,.009,.2714)]\npts=[bezier(sc,i/82) for i in range(83)]\ntube(stem,pts,[.00115-.00062*(i/82)**.75 for i in range(83)],13)\nbloom=Batch(\"Five open pink Cape sundew petals\",petal)\nbuds=Batch(\"Closed pink corolla buds\",pink)\nanthers=Batch(\"Pale stamens and pollen\",pollen)\nstyles=Batch(\"Pistil and translucent styles\",style)\nflower_center=pts[-1]\nnormal=Vector((.33,-.60,.73)).normalized()\naxis=normal.cross(Vector((0,0,1))).normalized()\nup=normal.cross(axis)\nfor i in range(5):\n phi=i*TAU/5+.19\n d=(axis*math.cos(phi)+up*math.sin(phi))\n s=normal.cross(d).normalized()\n vertices=[]; faces=[]; UV=[]\n rows,cols=27,16\n for j in range(rows+1):\n u=j/rows\n radial=.00105+.00651*u\n width=(.00033+.00182*wave(u*.85,.69))*math.sqrt(max(.012,1-(max(0,(u-.83)/.173))**2))\n for k in range(cols+1):\n q=2*k/cols-1\n P=flower_center+d*radial+s*(width*q)\n P+=normal*(.00105*u*u-.00049*wave(u)+.00029*q*q+.00015*math.sin(9*u+phi)*q)\n vertices.append(tuple(P))\n for j in range(rows):\n for k in range(cols):\n a=j*(cols+1)+k\n faces.append((a,a+cols+1,a+cols+2,a+1))\n UV.append(((j/rows,k/cols),((j+1)/rows,k/cols),((j+1)/rows,(k+1)/cols),(j/rows,(k+1)/cols)))\n bloom.add(vertices,faces,UV)\n tip=flower_center+d*.00180+normal*.00226\n tube(styles,[flower_center+d*.00075,flower_center+d*.0012+normal*.00132,tip],[.000105,.000089,.000072],7)\n ball(anthers,tip,(.00045,.00032,.00023),9,6)\n base_fl=flower_center-normal*.00108\n tube(stem,[base_fl,base_fl+d*.00219,base_fl+d*.00314+normal*.00048],[.00060,.00040,.00011],8)\nball(styles,flower_center+normal*.00126,(.00084,.00063,.00074),12,8)\nfor i in range(3):\n phi=i*TAU/3\n d=axis*math.cos(phi)+up*math.sin(phi)\n p=flower_center+normal*.0031+d*.00060\n tube(styles,[flower_center+normal*.0010,flower_center+normal*.0022+d*.00052,p],[.00012,.000105,.00009],7)\n ball(styles,p,(.00020,.00015,.00018),8,6)\nfor i,t in enumerate([.715,.794,.860,.929,.977]):\n joint=bezier(sc,t)\n radius=.00270-i*.00016\n d=Vector((.66,.64 if i%2 else -.56,.33+.15*i)).normalized()\n q=joint+d*(.0090-i*.00063)\n tube(stem,[joint,joint.lerp(q,.42)+Vector((0,0,-.0015)),q],\n [.00051,.00042,.00034],9)\n ball(stem,q,(radius*.72,radius*.62,radius*.69),11,7)\n ball(buds,q+Vector((0,0,radius*.71)),(radius*.60,radius*.56,radius*.98),13,9)\nbloom.build()\nbuds.build()\nanthers.build()\nstyles.build()\nstem.build()\n\n# Preserve editable plant components in the source and export one optimized static mesh.\nbpy.ops.object.select_all(action=\"DESELECT\")\nbpy.ops.wm.save_as_mainfile(filepath=str(ROOT/\"cape-sundew.blend\"),compress=True)\nobjects=list(scene.objects)\nfor o in objects:\n o.select_set(True)\nbpy.context.view_layer.objects.active=objects[0]\nbpy.ops.object.join()\np=bpy.context.object\np.name=\"Cape Sundew · Drosera capensis\"\np.data.name=p.name\nscene.cursor.location=(0,0,0)\nbpy.ops.object.origin_set(type=\"ORIGIN_CURSOR\")\nbpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\nbpy.ops.export_scene.gltf(filepath=str(ROOT/(STEM+\".glb\")),export_format=\"GLB\",export_yup=True,\n export_apply=False,export_tangents=False)\n```\n\n```python\n# clean_export.py\n\"\"\"Remove zero-area triangles left by evaluated bevel and lettering modifiers.\"\"\"\nimport json\nfrom pathlib import Path\nimport struct\nimport sys\n\nimport numpy as np\n\npath=Path(sys.argv[1])\ndata=path.read_bytes()\nmagic,version,total=struct.unpack_from(\"<4sII\",data)\nassert (magic,version,total)==(b\"glTF\",2,len(data))\njson_size,json_type=struct.unpack_from(\"\nLOOK\nA silver brooch shaped like a fern frond, lying flat, three-quarter view from above. A thin polished stem runs diagonally with pairs of leaf-shaped leaflets along it, each with a center vein and darkened side veins, ending in one longer tip leaf. The stem curls into a hook at the lower left end. Three lumpy white baroque pearls of different sizes sit in prong settings near the base of the frond.\n\nSCALE\nAbout 55 mm wide, 12 mm tall, 33 mm deep. Build in meters, +Y up, +Z forward, origin at the center of the brooch footprint on its back resting plane. Model in millimeters and scale to meters as each part is built.\n\nPARTS\n1. Spine: one continuous silver stem that thins toward the tip, plus a curled hook at the base ending in a small bead. Build: tubes swept along a curve and a bezier, radius tapering along the length, a small ellipsoid at the end.\n2. Leaflets: seven pairs of sculpted leaflets along the spine and one longer terminal blade. Build: one leaflet generator, placed in pairs and angled to the spine direction at each point.\n3. Leaf details: darkened secondary veins, bright rolled edges, burnished accents on the spine. Build: thin raised strips and edge tubes on each leaflet.\n4. Pearls: three uneven baroque pearls in ivory, cool cream and warm cream. Build: distorted spheres with a slight oval and fine random bumps, each with its own nacre material.\n5. Settings: a cup under each pearl and raised prongs gripping it, with small vine wires joining them to the branches. Build: shallow cups and thin tapered tubes.\n6. Back hardware: two mounting pads, a hinge barrel, a round safety catch, a curved pin wire and an oval maker's plate. Build: ellipsoids, a tube, a torus and a wire swept along a bezier.\n\nPLAN\n1. Setup: clear the scene, meters, model in millimeters and scale by 0.001.\n2. Texture maps: run maps.py first for the silver tooling and three nacre maps.\n3. Build order: spine and hook, leaflets with veins and edges, terminal blade, pearl cups, prongs and pearls, rear hinge, catch and pin, maker's plate.\n4. Assemble: leaflets attach in pairs along the spine, pearls cluster near the base on their cups, the pin hardware and plate sit underneath the spine. Join everything into one mesh split by material and move the lowest point of the back to zero.\n5. Materials: hand-planished sterling, oxidized silver in the vein channels, burnished bright edges, ivory, cool cream and warm cream nacre, silver fastening hardware.\n6. Export: brooch only, one GLB with the textures embedded, then run clean_export.py to strip zero-area triangles.\n\nCHECK\n236,074 triangles in one joined mesh. Against the image: frond about 1.7 times as long as it is wide, leaflets shrinking toward the tip, the largest pearl about a fifth of the brooch length.\n\n\n```python\n# maps.py\n\"\"\"Original silver tooling and three nacre textures for the Fernmere brooch.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import gaussian_filter, map_coordinates\n\nOUT=Path(__file__).resolve().parent/\"maps\"\nOUT.mkdir(exist_ok=True)\nrng=np.random.default_rng(226141)\n\ndef noise(h,w,rows,cols):\n a=np.pad(rng.uniform(-1,1,(rows,cols)).astype(np.float32),2,mode=\"wrap\")\n x,y=np.meshgrid(2+np.arange(w,dtype=np.float32)*cols/w,2+np.arange(h,dtype=np.float32)*rows/h)\n return map_coordinates(a,[y,x],order=3,mode=\"nearest\")\n\ndef save(name,data):\n Image.fromarray(np.rint(np.clip(data,0,255)).astype(np.uint8)).save(OUT/(name+\".png\"))\n\ndef normal(name,field,width,height):\n h,w=field.shape\n dx=(np.roll(field,-1,1)-np.roll(field,1,1))/(2*width/w)\n dy=(np.roll(field,-1,0)-np.roll(field,1,0))/(2*height/h)\n N=np.stack((-dx,dy,np.ones_like(dx)),-1)\n save(name,(N/np.linalg.norm(N,axis=-1,keepdims=True)*.5+.5)*255)\n\nh,w=768,1536\nu,v=np.meshgrid(np.arange(w,dtype=np.float32)/w,1-np.arange(h,dtype=np.float32)/h)\nhaste=noise(h,w,15,28)\ngrain=noise(h,w,209,39)\nfine=noise(h,w,317,148)\nsmall=noise(h,w,83,153)\nangle=np.sin(2*np.pi*(v*62+u*1.2+.20*haste+.11*small))\ntarnish=np.clip(.68*haste+.33*small+.20*fine+.37*(2*np.abs(v-.5))**2-.54,0,.55)\ncasting=np.clip(.48*small+.54*fine-.44,0,1)\nsave(\"silver-color\",np.array([186,181,168])+(9*haste+6*grain+3*fine+2*angle-53*tarnish-8*casting)[...,None])\nsave(\"silver-roughness\",np.clip(.32+.051*grain+.043*small+.085*tarnish+.019*fine,.21,.53)*255)\nnormal(\"silver-normal\",(haste*1.3+grain*.51+fine*.21+small*.44+angle*.34-casting*.78)*1e-6,.012,.005)\n\nh,w=768,1536\nu,v=np.meshgrid(np.arange(w,dtype=np.float32)/w,1-np.arange(h,dtype=np.float32)/h)\nhues=[([219,203,177],[255,235,209],[207,218,210]),([219,208,190],[251,226,215],[195,213,211]),\n ([212,198,170],[248,228,207],[207,226,210])]\nfor i,(base,warm,cool) in enumerate(hues):\n n0=noise(h,w,7,14)\n n1=noise(h,w,16,31)\n n2=noise(h,w,43,90)\n n3=noise(h,w,203,220)\n slip=.56+.39*np.sin(2*np.pi*(v*.8+u*1.05+n0*.20+i*.169))\n bands=np.sin(2*np.pi*(v*36+u*5+.35*n0+.20*n1))\n small_pits=np.clip((.50*n2+.60*n3)-.48,0,.60)\n factor=np.clip(slip+.08*n1,0,1)[...,None]\n colored=np.array(warm)*factor+np.array(cool)*(1-factor)\n color=.66*np.array(base)+.34*colored\n color+=(n0*2.7+n1*2.2+n2*.85+n3*.67-bands*.44-small_pits*8)[...,None]\n save(f\"nacre-{i+1}-color\",color)\n if i==0:\n save(\"nacre-roughness\",np.clip(.246 + .035*n0+.029*n1+.019*n2+.065*small_pits,.17,.36)*255)\n normal(\"nacre-normal\",(n0*1.50+n1*1.5+n2*.44+n3*.23-bands*.070-small_pits*.64)*1e-6,.026,.012)\n```\n\n```python\n# brooch.py\n\"\"\"Construct an original sterling-silver fern brooch with three baroque pearls.\"\"\"\nimport math\nfrom pathlib import Path\nimport random\n\nimport bpy\nfrom mathutils import Matrix, Vector\n\nROOT=Path(__file__).resolve().parent\nSTEM=\"3d-dataset-20261128T1200Z-jewelry-fernmere-pearl-brooch\"\nTAU=math.tau\nZ=Vector((0,0,1))\nrng=random.Random(614172)\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene=bpy.context.scene\nscene.unit_settings.system=\"METRIC\"\nscene.unit_settings.length_unit=\"METERS\"\n\ndef material(name,rgb,rough=.33,metal=0,maps=None,color_prefix=None,coat=0,coat_r=.22,ior=1.45):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*rgb,1)\n m.use_nodes=True\n n=m.node_tree.nodes\n l=m.node_tree.links\n shader=n.get(\"Principled BSDF\")\n for key,value in {\"Base Color\":(*rgb,1),\"Roughness\":rough,\"Metallic\":metal,\n \"Coat Weight\":coat,\"Coat Roughness\":coat_r,\"IOR\":ior}.items():\n shader.inputs[key].default_value=value\n if maps:\n for i,(kind,socket) in enumerate([(\"color\",\"Base Color\"),(\"roughness\",\"Roughness\"),(\"normal\",\"Normal\")]):\n prefix=color_prefix if kind==\"color\" and color_prefix else maps\n path=ROOT/\"maps\"/f\"{prefix}-{kind}.png\"\n if not path.exists():\n continue\n node=n.new(\"ShaderNodeTexImage\")\n node.image=bpy.data.images.load(str(path),check_existing=True)\n node.image.colorspace_settings.name=\"sRGB\" if i==0 else \"Non-Color\"\n node.image.pack()\n node.location=(-595,235-275*i)\n if i==2:\n normal=n.new(\"ShaderNodeNormalMap\")\n normal.inputs[\"Strength\"].default_value=.59 if maps==\"silver\" else .56\n normal.location=(-245,-385)\n l.new(node.outputs[\"Color\"],normal.inputs[\"Color\"])\n l.new(normal.outputs[\"Normal\"],shader.inputs[socket])\n else:\n l.new(node.outputs[\"Color\"],shader.inputs[socket])\n return m\n\nsilver=material(\"Hand-planished sterling silver\",(.62,.59,.53),.31,1,\"silver\")\nhigh=material(\"Hand-burnished polished silver edges\",(.78,.79,.76),.19,1)\npatina=material(\"Oxidized sterling in engraved channels\",(.178,.163,.143),.41,1)\nhardware=material(\"Silver fastening assembly\",(.74,.73,.70),.26,1)\npearl=[\n material(\"Ivory baroque pearl with rosy nacre\",(.72,.61,.48),.25,0,\"nacre\",\"nacre-1\",.62,.155,1.53),\n material(\"Cool cream baroque pearl\",(.71,.63,.54),.24,0,\"nacre\",\"nacre-2\",.62,.151,1.53),\n material(\"Warm cream baroque pearl\",(.69,.56,.44),.27,0,\"nacre\",\"nacre-3\",.58,.177,1.53)\n]\n\ndef wave(t,p=1):\n return max(0,math.sin(math.pi*t))**p\n\nclass Batch:\n def __init__(self,name,material):\n self.name=name; self.mat=material\n self.v=[]; self.f=[]; self.uv=[]\n def add(self,v,f,uv=None):\n start=len(self.v)\n self.v.extend(v)\n self.f.extend(tuple(start+i for i in x) for x in f)\n self.uv.extend(uv if uv is not None else [None]*len(f))\n def build(self,smooth=True):\n if not self.f:\n return\n data=bpy.data.meshes.new(self.name)\n data.from_pydata([tuple(Vector(v)*.001) for v in self.v],[],self.f)\n data.update()\n assert not data.validate()\n uv=data.uv_layers.new(name=\"Surface\")\n for face,tex in zip(data.polygons,self.uv):\n face.use_smooth=smooth\n if tex:\n for k,co in zip(face.loop_indices,tex):\n uv.data[k].uv=co\n o=bpy.data.objects.new(self.name,data)\n scene.collection.objects.link(o)\n data.materials.append(self.mat)\n return o\n\ndef tube(batch,points,r,sides=11,flat=1.0,closed=False):\n p=list(map(Vector,points))\n L=len(p)\n v=[]; f=[]; uv=[]\n for j,P in enumerate(p):\n prev=p[(j-1)%L] if closed or j else P\n next=p[(j+1)%L] if closed or j0 else -.014)\n p=spine(t)\n d=(spine(min(1,t+.007))-spine(max(0,t-.007))).normalized()\n angle=math.atan2(d.y,d.x)+s*(1.04-.20*base)+rng.uniform(-.12,.15)\n length=[13.8,13.4,12.8,11.0,9.2,7.2,5.7][index]*rng.uniform(.93,1.075)\n w=length*rng.uniform(.148,.202)\n if s<0 and index in (0,1):\n length*=.72\n p+=Vector((-.019*s,.009*s,.10+abs(s)*.011))\n leaflet(f\"Individual sculpted fern leaflet {index+1} {'A' if s < 0 else 'B'}\",\n p,length,w,angle,s*rng.uniform(.28,1.45),rng.uniform(.58,2.27))\nleaflet(\"Terminal tapered fern blade\",spine(.91),8.8,1.63,.55,.47,1.40)\nveins.build()\npolished.build()\naccent.build()\n\n# Seats and polished prongs around three individually modeled uneven pearls.\ncups=Batch(\"Pearl cups, cold-soldered to the branches\",silver)\ntines=Batch(\"Raised silver pearl prongs and vine connections\",high)\npositions=[\n ((-18.46,-12.10,7.28),(5.12,4.79,4.47),(.15,.20,-.16)),\n ((-10.60,-5.62,6.37),(4.16,3.85,3.65),(-.20,-.12,.29)),\n ((-6.78,-13.00,5.45),(3.21,2.95,2.78),(.11,-.28,.24)),\n]\n\nfor i,(C,R,angles) in enumerate(positions):\n C=Vector(C)\n rx,ry,rz=R\n rot=(Matrix.Rotation(angles[0],3,\"X\")@Matrix.Rotation(angles[1],3,\"Y\")@\n Matrix.Rotation(angles[2],3,\"Z\"))\n def sample(u,t):\n a=math.pi*u\n # Distinct slight oval and asymmetric baroque contour, with very fine\n # skin ripples and a shallow growth ridge at differing azimuths.\n s=math.sin(a); z=-math.cos(a)\n phase=i*2.02\n f=1+.051*math.sin(2.1*a+phase)*math.cos(3*t+phase*.7)*s\n f+=.024*math.cos(5*t-3*a+phase)*s*s+.011*math.sin(11*a+7*t+phase)*s\n vx=rx*s*math.cos(t)*f\n vy=ry*s*math.sin(t)*f\n vz=rz*(z*(1+.030*math.sin(t*3+a)*s)+.014*math.sin(12*a+4*t+phase)*s)\n return C+rot@Vector((vx,vy,vz))\n bead=Batch(f\"Pearl {i+1}, individually lofted baroque nacre\",pearl[i])\n sphere(bead,sample,66,120)\n bead.build()\n # Smooth cup with curved planar wall beneath each bead.\n rings=[(.09,C.z-rz-.19),(.67,C.z-rz-.15),(.84,C.z-rz+.08),(.86,C.z-rz+.45),\n (.936,C.z-rz+1.22),(.976,C.z-rz+1.57),(.939,C.z-rz+1.70),\n (.871,C.z-rz+1.46),(.71,C.z-rz+.51),(.10,C.z-rz+.38)]\n v=[]; f=[]; uv=[]\n for j,(w,z) in enumerate(rings):\n for k in range(83):\n a=k*TAU/83\n v.append((C.x+rx*.77*w*math.cos(a),C.y+ry*.77*w*math.sin(a),z))\n for j in range(len(rings)-1):\n for k in range(83):\n l=(k+1)%83\n f.append((j*83+k,j*83+l,(j+1)*83+l,(j+1)*83+k))\n uv.append(((k/83,j/len(rings)),((k+1)/83,j/len(rings)),\n ((k+1)/83,(j+1)/len(rings)),(k/83,(j+1)/len(rings))))\n cups.add(v,f,uv)\n seat=C-Z*(rz-.25)\n junction=spine([.171,.315,.429][i])\n tube(tines,[bezier([junction,junction+Vector((1.1,-2.3,0.13)),seat+Vector((-1.33,3.03,.28)),seat],j/45)\n for j in range(46)],lambda t:.58-.15*t,13,.74)\n for j in range(4):\n a=j*TAU/4+i*.36+.48\n x,y=math.cos(a),math.sin(a)\n p=C+Vector((rx*x*.65,ry*y*.66,-rz*.81))\n q=C+Vector((rx*x*.93,ry*y*.96,-rz*.61))\n s=C+Vector((rx*x*1.04,ry*y*1.02,-rz*.03))\n end=C+Vector((rx*x*.952,ry*y*.951,rz*.28))\n tube(tines,[bezier([p,q,s,end],t/41) for t in range(42)],\n lambda u:.337-.084*u,11,.92)\n ellipsoid(tines,end,.269,.255,.249,13,22)\ncups.build()\ntines.build()\nstem.build()\n\n# An ordinary hidden brooch clasp and wire rest, tucked beneath the spine.\nrear=Batch(\"Under-brooch hinge, safety catch and pin wire\",hardware)\ndef torus(batch,center,major,minor,ax,rings=45,sides=12):\n c=Vector(center)\n ax=Vector(ax).normalized()\n a=(ax.cross(Z) if abs(ax.dot(Z))<.92 else ax.cross(Vector((1,0,0)))).normalized()\n b=ax.cross(a)\n v=[]; f=[]; uv=[]\n for i in range(rings):\n r=a*math.cos(i*TAU/rings)+b*math.sin(i*TAU/rings)\n for j in range(sides):\n t=j*TAU/sides\n v.append(tuple(c+r*(major+minor*math.cos(t))+ax*minor*math.sin(t)))\n for i in range(rings):\n k=(i+1)%rings\n for j in range(sides):\n n=(j+1)%sides\n f.append((i*sides+j,k*sides+j,k*sides+n,i*sides+n))\n uv.append(((i/rings,j/sides),((i+1)/rings,j/sides),((i+1)/rings,(j+1)/sides),(i/rings,(j+1)/sides)))\n batch.add(v,f,uv)\n\nfor t in [.20,.79]:\n P=spine(t)\n ellipsoid(rear,(P.x,P.y,2.37),1.93,1.44,.69,22,54)\npoint=spine(.20)\npivot=Vector((point.x,point.y,1.26))\ntarget=spine(.79)\ncatch=(target.x,target.y,1.235)\ntube(rear,[pivot+Vector((0,-1.16,0)),pivot+Vector((0,1.15,0))],.92,24)\ntorus(rear,catch,.91,.33,(.34,.95,0),45,13)\nwire=[pivot+Vector((.41,0,.0)),pivot+Vector((6.2,1.55,-.10)),\n Vector(catch)+Vector((-6.7,-3.2,-.17)),Vector(catch)+Vector((.40,.11,-.06))]\ntube(rear,[bezier(wire,j/88) for j in range(89)],lambda t:.46-.16*t**4,12)\nrear.build()\n# Underside maker's plaque and recessed-style hallmark.\nbadge=Batch(\"Maker's oval silver backing plate\",patina)\nP=spine(.498)\nellipsoid(badge,(P.x,P.y,2.13),3.20,1.63,.41,30,59)\nbadge.build()\n\nbpy.ops.object.select_all(action=\"DESELECT\")\nbpy.ops.wm.save_as_mainfile(filepath=str(ROOT/\"fernmere.blend\"),compress=True)\nobjects=list(scene.objects)\nfor o in objects:\n if o.data.uv_layers.active:\n o.data.uv_layers.active.name=\"Surface\"\n o.select_set(True)\nbpy.context.view_layer.objects.active=objects[0]\nbpy.ops.object.join()\nproduct=bpy.context.object\nproduct.name=\"Fernmere Pearl Brooch\"\nproduct.data.name=product.name\nscene.cursor.location=(0,0,0)\nbpy.ops.object.origin_set(type=\"ORIGIN_CURSOR\")\nbpy.ops.object.transform_apply(location=True,rotation=True,scale=True)\nlow=min(v.co.z for v in product.data.vertices)\nxmin=min(v.co.x for v in product.data.vertices); xmax=max(v.co.x for v in product.data.vertices)\nymin=min(v.co.y for v in product.data.vertices); ymax=max(v.co.y for v in product.data.vertices)\nfor p in product.data.vertices:\n p.co.x-=(xmin+xmax)*.5\n p.co.y-=(ymin+ymax)*.5\n p.co.z-=low\nproduct.data.update()\nbpy.ops.export_scene.gltf(filepath=str(ROOT/(STEM+\".glb\")),export_format=\"GLB\",export_yup=True,\n export_apply=False,export_tangents=False)\n```\n\n```python\n# clean_export.py\n\"\"\"Remove zero-area triangles left by evaluated bevel and lettering modifiers.\"\"\"\nimport json\nfrom pathlib import Path\nimport struct\nimport sys\n\nimport numpy as np\n\npath=Path(sys.argv[1])\ndata=path.read_bytes()\nmagic,version,total=struct.unpack_from(\"<4sII\",data)\nassert (magic,version,total)==(b\"glTF\",2,len(data))\njson_size,json_type=struct.unpack_from(\"\nLOOK\nA 17-key kalimba lying flat, three-quarter view from above. A rounded-rectangle walnut box with a figured, glossy top, a thin maple and dark binding line around the edge, and a round soundhole with a ringed rosette near the player end. Seventeen polished steel tines of staggered length, longest in the middle and engraved with note names, held down by a steel bar with brass screws at each end. \"SEREIN\" in gold at the top, \"K17 / WALNUT\" near the bottom left, and small inlaid diamonds.\n\nSCALE\nAbout 13 cm wide, 42 mm tall, 19 cm deep. Build in meters, +Y up, +Z forward (player end toward +Z), origin on the back surface at the center of the body footprint.\n\nPARTS\n1. Body shell: one continuous walnut chamber running from the inner floor, up through the soundhole and over the top, then down the sides to the outer floor. Build: one rounded outline sampled at 192 points, offset into stacked rings at different scales and heights, bridged into one shell.\n2. Inlays: maple and dark purfling lines around the top edge, and a brass and maple rosette around the soundhole. Build: thin rings inside the same shell, each with its own material.\n3. Bridges: front and rear hardwood saddles with polished steel contact rods. Build: softened blocks and rods.\n4. Pressure bar: a walnut base, a steel compression bar, and brass washers, steel standoffs and slotted brass screws at each end. Build: rods, with a recessed slot cut in each screw head.\n5. Tines: 17 tines, D6 through E6, lengths staggered so the center is longest, each with a curved tip and an engraved note. Build: one loft per tine along its length with rounded polished edges, length set from its distance to the center.\n6. Markings: \"S E R E I N\" and \"K17 / WALNUT\" in gold leaf, brass marquetry diamonds near the top, maple diamonds near the soundhole. Build: text objects and small diamond meshes.\n\nPLAN\n1. Setup: clear the scene, meters, origin on the back surface at the footprint center.\n2. Texture maps: run maps.py first for the crown walnut, rim walnut, maple binding and brushed steel maps.\n3. Build order: body shell with inlays, front bridge, rear bridge, pressure bar with washers, standoffs and screws, maker and model marks, diamond inlays, tines.\n4. Assemble: tines lie across both bridges and under the compression bar, which is screwed down at each end, and the soundhole sits toward the player end, with the longest tines reaching just over its edge. Apply the modifiers and join everything into one mesh.\n5. Materials: oil-finished crown-cut walnut, bent quarter-cut walnut rim, honey maple binding, unfinished walnut inside, dark purfling, burnished brass, polished steel edges, brushed stainless, dark laser marking, gold leaf.\n6. Export: kalimba only, one GLB with the textures embedded, then run clean_export.py to strip zero-area triangles.\n\nCHECK\n42,962 triangles across 63 parts. Against the image: body about 1.4 times as long as it is wide, soundhole about two-fifths of the width, tines covering the far half, longest tine in the middle.\n\n\n```python\n# maps.py\n\"\"\"Create original wood and brushed-steel PBR texture maps.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import map_coordinates, gaussian_filter\n\nROOT = Path(__file__).resolve().parent / \"maps\"\nROOT.mkdir(exist_ok=True)\nN = 1536\nrng = np.random.default_rng(84712)\ny, x = np.mgrid[0:1:complex(N),0:1:complex(N)].astype(np.float32)\n\ndef noise(u, v, nx, ny):\n field = rng.normal(0, 1, (ny+3,nx+3)).astype(np.float32)\n return map_coordinates(field, [(v % 1)*ny+1, (u % 1)*nx+1], order=3, mode='wrap')\n\ndef image(name, a):\n Image.fromarray(np.round(np.clip(a,0,1)*255).astype(np.uint8)).save(ROOT / (name + \".png\"))\n\ndef normal(name, height, factor):\n dy, dx = np.gradient(gaussian_filter(height, .52))\n normal = np.stack((-dx*factor, dy*factor, np.ones_like(dx)), -1)\n normal /= np.linalg.norm(normal, axis=-1, keepdims=True)\n image(name, normal*.5+.5)\n\ndef wood(name, base, anisotropy, flat_sawn, roughness, strength):\n twist = .004*noise(x,y,7,4) + .009*np.sin(y*7+x*10)\n if flat_sawn:\n # Growth rings bend across the crown of the cut at uneven intervals.\n u = np.sqrt(((x-.22)*.89)**2 + ((y-.76)*.42)**2 + .041) + twist\n else:\n u = x + twist*.40\n wide = noise(u,y,25,5)\n ring = np.sin((u + .010*noise(u,y,9,4))*222 + .32*wide)\n late = (ring*.5+.5)**10\n fibers = noise(u,y,241,10)\n rays = noise(u,y,87,36)\n pores = np.maximum(0,noise(u,y,335,88)-1.02)**1.6\n fleck = noise(u,y,495,267)\n coarse = noise(x,y,7,7)\n grain = .049*wide - .062*late + .023*fibers - .044*pores + .010*rays + .006*fleck + .027*coarse\n grain *= strength\n rgb = np.clip(np.array(base)[None,None,:]+grain[...,None]*np.array([1,.84,.68]),0,1)\n image(name+\"_color\", rgb)\n image(name+\"_roughness\", roughness + strength*(.013*wide + .026*pores + .009*rays))\n normal(name+\"_normal\", .24*fibers-.20*pores+.045*fleck-.10*late, anisotropy)\n\nwood(\"Walnut crown\", (.335,.199,.121), .50, True, .32, .88)\nwood(\"Walnut rim\", (.300,.169,.093), .42, False, .32, .83)\nwood(\"Maple binding\", (.70,.545,.343), .26, False, .34, .58)\nscratch = noise(x,y,680,11)*.32 + noise(x,y,109,18)*.58 + noise(x,y,400,75)*.18\nimage(\"Steel brushed_roughness\", .225 + scratch*.054)\nnormal(\"Steel brushed_normal\", scratch, .31)\n```\n\n```python\n# kalimba.py\n\"\"\"Model the Serein K17 chamber kalimba and export a clean textured GLB.\"\"\"\nfrom math import sin, cos, pi, atan2, copysign, exp\nfrom pathlib import Path\nimport bpy\nimport bmesh\nfrom mathutils import Vector\n\nROOT = Path(__file__).resolve().parent\nSTEM = \"3d-dataset-20261128T1300Z-musical-instruments-serein-k17-walnut-kalimba\"\nbpy.ops.wm.read_factory_settings(use_empty=True)\nscene = bpy.context.scene\nscene.unit_settings.system = 'METRIC'\nscene.render.fps = 24\nbpy.context.preferences.filepaths.save_version = 0\n\ndef pbr(name, color, metal=0, rough=.35, coat=0, maps=None, normal_scale=1):\n material = bpy.data.materials.new(name)\n material.diffuse_color = (*color,1)\n material.use_nodes = True\n nt = material.node_tree\n bsdf = nt.nodes.get('Principled BSDF')\n for prop,val in [('Base Color',(*color,1)), ('Metallic',metal), ('Roughness',rough),\n ('Coat Weight',coat), ('Coat Roughness',.23)]:\n bsdf.inputs[prop].default_value = val\n for suffix, prop in [('color','Base Color'), ('roughness','Roughness'), ('normal','Normal')]:\n fname = f\"{maps}_{suffix}\"\n if maps and (ROOT/'maps'/f\"{fname}.png\").is_file():\n img = bpy.data.images.load(str(ROOT/'maps'/f\"{fname}.png\"), check_existing=True)\n img.colorspace_settings.name = 'sRGB' if suffix=='color' else 'Non-Color'\n node = nt.nodes.new('ShaderNodeTexImage')\n node.image = img\n if suffix=='normal':\n normal = nt.nodes.new('ShaderNodeNormalMap')\n normal.inputs['Strength'].default_value = normal_scale\n nt.links.new(node.outputs['Color'], normal.inputs['Color'])\n nt.links.new(normal.outputs['Normal'],bsdf.inputs[prop])\n else:\n nt.links.new(node.outputs['Color'],bsdf.inputs[prop])\n return material\n\nwalnut = pbr('Oil-finished black walnut • crown cut',(.12,.06,.026),coat=.14,maps='Walnut crown',normal_scale=.55)\nrim = pbr('Bent black walnut • quarter cut',(.095,.045,.017),coat=.19,maps='Walnut rim',normal_scale=.55)\nmaple = pbr('Honey maple binding',(.48,.32,.17),coat=.20,maps='Maple binding',normal_scale=.38)\ninside = pbr('Unfinished walnut chamber',(.071,.033,.014),rough=.64)\ndark = pbr('Darkened walnut purfling',(.032,.014,.008),rough=.30,coat=.13)\nsteel = pbr('Lengthwise brushed stainless steel',(.60,.64,.67),metal=.95,maps='Steel brushed',normal_scale=.46)\nchrome = pbr('Polished bridge and tine edges',(.62,.67,.69),metal=.97,rough=.20)\ngold = pbr('Burnished brass',(.51,.28,.085),metal=.82,rough=.27)\nmaker_ink = pbr('Gold leaf maker and model marks',(.50,.32,.125),metal=.25,rough=.53)\nengraving = pbr('Dark laser marking on stainless',(.029,.033,.035),metal=.50,rough=.40)\n\ndef mesh(name, vertices, faces, materials, mids=None, uv=None, smooth=True):\n data = bpy.data.meshes.new(name)\n data.from_pydata(vertices, [], faces)\n data.update()\n ob = bpy.data.objects.new(name, data)\n scene.collection.objects.link(ob)\n for m in materials:\n data.materials.append(m)\n if uv:\n layer = data.uv_layers.new(name='UVMap')\n for face in data.polygons:\n face.use_smooth = smooth\n if mids is not None:\n face.material_index = mids[face.index]\n if uv:\n for loop in face.loop_indices:\n index = data.loops[loop].vertex_index\n layer.data[loop].uv = uv(index, face.index)\n bm = bmesh.new()\n bm.from_mesh(data)\n bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))\n bm.to_mesh(data)\n bm.free()\n return ob\n\nN = 192\nANGLES = [2*pi*i/N for i in range(N)]\nHOLE = -.044\nH = .032\ndef pow_signed(a,b):\n return copysign(abs(a)**b,a)\ndef outline(a):\n y = .095 * pow_signed(sin(a), .64)\n w = .0705 - .0071*(.5+y/.19) - .0026*exp(-((y-.021)/.041)**2)\n return (w * pow_signed(cos(a), .66),y)\nprofile = [outline(a) for a in ANGLES]\nradials = [atan2(y-HOLE,x) for x,y in profile]\n\n# The chamber is one continuous shell. A profile begins at the inner floor,\n# passes through the soundhole and polished top, and ends at the outer floor.\nrims=[]\ndef loop(mode, amount, z, mat, planar):\n if mode == 'body':\n vectors = [(x*amount,y*amount,z) for x,y in profile]\n else:\n vectors = [(cos(a)*amount,HOLE+sin(a)*amount,z) for a in radials]\n rims.append((vectors,mat,planar))\nloop('body',.86,.004,inside,True)\nloop('body',.90,.006,inside,False)\nloop('body',.913,.0265,inside,False)\nloop('body',.887,.028,inside,True)\nloop('hole',.0238,.028,inside,True)\nloop('hole',.0234,.0288,inside,True)\nloop('hole',.0234,.0306,walnut,True)\nloop('hole',.02365,.03145,walnut,True)\nloop('hole',.0242,H,walnut,True)\nloop('hole',.02465,H,walnut,True)\nloop('hole',.02508,H,gold,True)\nloop('hole',.02546,H,dark,True)\nloop('hole',.02612,H,maple,True)\nloop('hole',.02730,H,dark,True)\nloop('hole',.02765,H,walnut,True)\nloop('body',.931,H,walnut,True)\nloop('body',.951,H,dark,True)\nloop('body',.955,H,maple,True)\nloop('body',.966,H,dark,True)\nloop('body',.970,H,walnut,True)\nloop('body',.977,H-.0003,walnut,True)\nloop('body',.987,H-.0010,walnut,True)\nloop('body',.995,H-.0020,walnut,True)\nloop('body',1,H-.0035,rim,False)\nloop('body',1,H-.0044,dark,False)\nloop('body',1,H-.0048,maple,False)\nloop('body',1,H-.0058,dark,False)\nloop('body',1,H-.00616,rim,False)\nloop('body',1,.006,rim,False)\nloop('body',.998,.0035,rim,False)\nloop('body',.992,.00185,rim,False)\nloop('body',.983,.00065,rim,False)\nloop('body',.965,0,walnut,True)\nloop('body',.935,0,walnut,True)\nvertices = [v for r,_,_ in rims for v in r]\nfaces=[]; mats=[]; materials=[walnut,rim,maple,inside,dark,gold]\nfor j,(_,mat,_) in enumerate(rims[:-1]):\n for i in range(N):\n k=(i+1)%N\n faces.append((j*N+i,j*N+k,(j+1)*N+k,(j+1)*N+i))\n mats.append(materials.index(mat))\nfaces += [tuple(reversed(range(N))),tuple(range((len(rims)-1)*N,len(rims)*N))]\nmats += [materials.index(inside),materials.index(walnut)]\ndef body_uv(i, face):\n x,y,z=vertices[i]\n if face >= (len(rims)-1)*N or rims[face//N][2]:\n return (.5+x/.158,.5+y/.212)\n t = (i%N)/N\n if face%N == N-1 and i%N == 0:\n t = 1\n return (.09+z/.040,t*2.6)\nbody = mesh('Carved walnut chamber with maple and brass inlay',vertices,faces,materials,mats,body_uv)\n\ndef activate(ob):\n bpy.ops.object.select_all(action='DESELECT')\n ob.select_set(True)\n bpy.context.view_layer.objects.active=ob\n\ndef softblock(name, origin, scale, bevel, mat):\n bpy.ops.mesh.primitive_cube_add(size=1,location=origin)\n ob=bpy.context.object\n ob.name=name\n ob.dimensions=scale\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n ob.data.materials.append(mat)\n mod=ob.modifiers.new('Eased edges','BEVEL')\n mod.width=bevel\n mod.segments=5\n mod=ob.modifiers.new('Weighted face normals','WEIGHTED_NORMAL')\n return ob\n\ndef rod(name, start, end, radius, mat, bevel=.00023, segments=48):\n start,end=Vector(start),Vector(end)\n delta=end-start\n bpy.ops.mesh.primitive_cylinder_add(vertices=segments,radius=radius,depth=delta.length,location=(start+end)/2)\n ob=bpy.context.object\n ob.name=name\n ob.rotation_mode='QUATERNION'\n ob.rotation_quaternion=delta.to_track_quat('Z','Y')\n ob.data.materials.append(mat)\n for p in ob.data.polygons:\n p.use_smooth=len(p.vertices)==4\n mod=ob.modifiers.new('Eased edges','BEVEL')\n mod.width=bevel\n mod.segments=4\n mod=ob.modifiers.new('Weighted face normals','WEIGHTED_NORMAL')\n return ob\n\nsoftblock('Front bridge • hardwood saddle', (0,.027,.0342),(.106,.0085,.00455),.00155,dark)\nrod('Front bridge • polished stainless contact',(-.052,.027,.0371),(.052,.027,.0371),.00148,chrome,.00054)\nsoftblock('Rear bridge • hardwood saddle',(0,.0625,.03465),(.105,.010,.0057),.0015,dark)\nrod('Rear bridge • polished stainless contact',(-.0518,.0625,.0370),(.0518,.0625,.0370),.0014,chrome,.00049)\nsoftblock('Pressure assembly • black walnut base',(0,.0456,.0335),(.111,.0111,.0032),.0012,dark)\nrod('Stainless compression bar',(-.0545,.0457,.0399),(.0545,.0457,.0399),.00252,chrome,.0006)\nfor x in (-.052,.052):\n rod('Shouldered brass washer',(x,.04575,.0321),(x,.04575,.0342),.00425,gold)\n rod('Steel bridge standoff',(x,.04575,.0339),(x,.04575,.0400),.0027,chrome)\n screw=rod('Slotted flush brass machine screw',(x,.04575,.0400),(x,.04575,.04235),.00334,gold,.00034)\n cutter=softblock('slot',(x,.04575,.0424),(.0071,.00068,.00115),0,engraving)\n activate(screw)\n boolean=screw.modifiers.new('Recessed slot','BOOLEAN')\n boolean.object=cutter\n boolean.operation='DIFFERENCE'\n bpy.ops.object.modifier_apply(modifier=boolean.name)\n bpy.data.objects.remove(cutter,do_unlink=True)\n softblock('Dark patina in slot',(x,.04575,.04185),(.0049,.00054,.00009),.00003,engraving)\n\nFONTFILE = Path('/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf')\nmark_font = bpy.data.fonts.load(str(FONTFILE)) if FONTFILE.is_file() else bpy.data.fonts.get('Bfont')\n\ndef label(name,value,location,height,mat,spacing=1.1,font=None):\n curve=bpy.data.curves.new(name,'FONT')\n curve.body=value\n curve.align_x='CENTER'\n curve.align_y='CENTER'\n curve.size=height\n curve.space_character=spacing\n curve.resolution_u=6\n if font:\n curve.font=font\n ob=bpy.data.objects.new(name,curve)\n scene.collection.objects.link(ob)\n ob.location=location\n ob.data.materials.append(mat)\n activate(ob)\n bpy.ops.object.convert(target='MESH')\n return bpy.context.object\n\nlabel('Serein maker mark','S E R E I N',(0,.081,.032035),.007,maker_ink,font=mark_font)\nlabel('Front model mark','K17 / WALNUT',(0,-.0795,.032034),.0035,maker_ink,1.24)\n\ndef diamond(name,x,y,s,mat):\n z=H+.000028\n mesh(name,[(x-s,y,z),(x,y-s*1.6,z),(x+s,y,z),(x,y+s*1.6,z)],[(0,1,2,3)],[mat],smooth=False)\nfor side in (-1,1):\n for i in range(3):\n diamond('Brass marquetry accent',side*(.0205+.0044*i),.081,.00082-.00013*i,gold)\n diamond('Maple soundboard inlay',side*(.038+.0047*i),-.0645+.0047*i,.00085,maple)\n\nnotes = ['D6','B5','G5','E5','C5','A4','F4','D4','C4','E4','G4','B4','D5','F5','A5','C6','E6']\nfor k,note in enumerate(notes):\n slot=k-8\n magnitude=abs(slot)\n x= slot*.00582\n end=-.0275 + magnitude*.00468 + (.0023 if slot>0 else 0)\n # Longitudinal loft with curved tip and rounded polished sides.\n sections = [(end,.18,.03710),(end+.00045,.63,.03722),(end+.00105,.86,.03743),\n (end+.0020,.985,.03780),(end+.0036,1,.03829),(end+.0056,1,.03863),\n (end+.0080,1,.03891),(end+.0108,.98,.03919),\n ((end+.0108+.027)*.5,.93,.03918),(.027,.89,.03902),\n (.035,.84,.03860),(.0457,.83,.03712),(.056,.81,.03827),\n (.061,.81,.03879),(.0645,.82,.03920),(.0698,.81,.03940),\n (.0710,.77,.03938),(.0717,.40,.03936)]\n nv=28\n points=[]\n for y,w,z in sections:\n flare=0.00065*slot*((.0717-y)/(.0717-end))**2\n dx= .00221*w\n for j in range(nv):\n a=2*pi*j/nv\n points.append((x+flare+dx*pow_signed(cos(a),.36), y, z+.000495*pow_signed(sin(a),.36)))\n polys=[]; mids=[]\n for i in range(len(sections)-1):\n for j in range(nv):\n nxt=(j+1)%nv\n polys.append((i*nv+j,(i+1)*nv+j,(i+1)*nv+nxt,i*nv+nxt))\n mids.append(0 if 2 <= j <= 11 or 16 <= j <= 25 else 1)\n polys += [tuple(range(nv)),tuple(range(len(points)-nv,len(points)))]\n mids += [1,1]\n def tine_uv(i,_):\n px,y,_=points[i]\n return ((px-x)*85+.49,y*9+.33)\n mesh(f'{k+1:02d} · {note} spring steel tine',points,polys,[steel,chrome],mids,uv=tine_uv)\n mark_y=end+.0068\n mark_x=x+.00065*slot*((.0717-mark_y)/(.0717-end))**2\n mark=label(f'{note} tine marking',note,(mark_x,mark_y,.03939),.00258,engraving,1.06)\n mark.rotation_euler.x=.117\n\n# Save the editable construction with packed source textures and separate parts.\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(ROOT/'serein-k17.blend'))\nfor ob in list(scene.objects):\n if ob.type=='MESH':\n activate(ob)\n for modifier in list(ob.modifiers):\n bpy.ops.object.modifier_apply(modifier=modifier.name)\nbpy.ops.object.select_all(action='SELECT')\nbpy.context.view_layer.objects.active=body\nbpy.ops.object.join()\nbpy.context.object.name='Serein K17 Walnut Kalimba'\nbpy.ops.export_scene.gltf(filepath=str(ROOT/(STEM+'.glb')),export_format='GLB',export_yup=True,\n export_materials='EXPORT',export_cameras=False,export_lights=False,\n export_animations=False,export_tangents=False,export_image_format='AUTO')\n```\n\n```python\n# clean_export.py\n\"\"\"Remove zero-area triangles left by evaluated bevel and lettering modifiers.\"\"\"\nimport json\nfrom pathlib import Path\nimport struct\nimport sys\n\nimport numpy as np\n\npath=Path(sys.argv[1])\ndata=path.read_bytes()\nmagic,version,total=struct.unpack_from(\"<4sII\",data)\nassert (magic,version,total)==(b\"glTF\",2,len(data))\njson_size,json_type=struct.unpack_from(\"\nLOOK\nA single-seat glider, three-quarter view from the front left. A slim white fuselage tapering into a thin tail boom, a large clear bubble canopy over the cockpit, and long tapered wings with slightly upturned petrol-blue tips and vermilion stripes. A T-tail, with the horizontal stabilizer sitting on top of the fin. \"TERNFALL\" in white on a blue band under the nose, \"TF-L8\" on the right wing and \"08\" on the fin. One fat main wheel under the cockpit and a small tailwheel on a strut.\n\nSCALE\nAbout 10.5 m wide, 174 cm tall, 5.7 m deep. Build in meters, +Y up, +Z forward (nose toward +Z), origin on the centerline at ground level below the wing root.\n\nPARTS\n1. Fuselage: a smooth shell from nose to tail with an opening for the cockpit. Build: loft a list of cross sections from nose to tail, leaving out the canopy faces.\n2. Canopy: a full acrylic bubble with a molded rail, gasket and bow frames. Build: the faces cut from the fuselage loft, given thickness with solidify, and tubes along its edges.\n3. Cockpit: bottom liner, tufted seat, padded back and head cushion, shoulder and lap restraints, arm supports, an instrument panel with four gauges, and a control column and stick. Build: rounded blocks, cylinders for the gauges, a tube for the column.\n4. Wings and tail: a tapered main wing with dihedral, and a horizontal stabilizer on top of a swept fin. Build: loft an airfoil section along each half span, with a list of span stations setting position, chord and thickness.\n5. Control surfaces: aileron, flap, elevator and rudder seams, plus airbrake panel outlines. Build: thin tubes laid on the surfaces at a set chord position.\n6. Gear and markings: fixed main tire, tailwheel with shoe and strut, TF-L8, TERNFALL and 08 decals, wingtip lenses, inspection discs and a nose tow recess. Build: rounded wheels, decals laid onto the lofted skin, small blocks and discs.\n\nPLAN\n1. Setup: clear the scene, meters, origin on the centerline at ground level below the wing root.\n2. Texture maps: run maps.py first for the fuselage, wing, seat and tire maps.\n3. Build order: fuselage shell, canopy with rails and frames, cockpit interior, instrument panel, control column, main wing, horizontal stabilizer, fin, control seams and airbrakes, main wheel and tailwheel, decals, tip lenses, inspection discs, tow recess.\n4. Assemble: the wing crosses the fuselage just behind the cockpit, the fin rises from the tail boom with the stabilizer on top, the main wheel sits under the wing root and the tailwheel under the fin. Apply the modifiers, convert text and curves to mesh, and join into one object.\n5. Materials: painted composite fuselage and wings, ivory gelcoat, petrol-blue enamel, vermilion stripe paint, blue-gray acrylic canopy, charcoal panel, cinnamon upholstery, slate webbing, anodized aluminum, pale instrument markings, flush seams, black rubber.\n6. Export: sailplane only, one GLB with the textures embedded, then run clean_export.py to strip zero-area triangles.\n\nCHECK\n250,850 triangles across 109 parts. Against the image: wingspan almost twice the fuselage length, the canopy over the front third, the stabilizer on top of the fin, the main wheel under the wing root.\n\n\n```python\n# maps.py\n\"\"\"Author painted composites, cockpit upholstery, and rubber PBR images.\"\"\"\nfrom pathlib import Path\nimport numpy as np\nfrom PIL import Image\nfrom scipy.ndimage import gaussian_filter,map_coordinates\n\nroot=Path(__file__).resolve().parent/'maps'\nroot.mkdir(exist_ok=True)\nN=1280\nv,u=np.mgrid[0:1:complex(N),0:1:complex(N)].astype(np.float32)\nrng=np.random.default_rng(12087)\ndef noise(nx,ny):\n data=rng.standard_normal((ny+3,nx+3)).astype(np.float32)\n return map_coordinates(data,[1+v*ny,1+u*nx],order=3,mode='wrap')\ndef save(name,a):\n Image.fromarray(np.round(np.clip(a,0,1)*255).astype(np.uint8)).save(root/(name+'.png'))\ndef masks(colors,factors):\n result=np.broadcast_to(np.array(colors[0]),(*u.shape,3)).copy()\n for color,factor in zip(colors[1:],factors):\n result = result*(1-factor[...,None])+np.array(color)*factor[...,None]\n return result\ndef smooth(edges,x):\n a,b=edges\n t=np.clip((x-a)/(b-a),0,1)\n return t*t*(3-2*t)\ndef normal(name,h,k):\n dy,dx=np.gradient(gaussian_filter(h,.48))\n n=np.stack([-dx*k,dy*k,np.ones_like(dx)],-1)\n n/=np.linalg.norm(n,axis=-1,keepdims=True)\n save(name,n*.5+.5)\n\nfine=noise(326,380)\nbroad=noise(13,15)\ndetail=noise(54,66)\npalette=[(.825,.838,.817),(.055,.19,.236),(.71,.246,.112)]\n# The seam of the UV unwrap is below the aircraft. The curves flank the cockpit.\nside=np.cos(2*np.pi*u)\nline=.09+.034*np.exp(-((v-.45)/.28)**2)+.065*(v-.5)\nthickness=.072+.235*np.exp(-((v-.74)/.23)**2)\nstripe=1-smooth((0,.009),np.abs(side-line)-thickness)\naccent=1-smooth((.010,.018),np.abs(side-(line+thickness+.030)))\naccent*=smooth((.13,.24),v)\ntints=masks(palette,[stripe,accent])\nweather=np.clip(.025+.009*broad+.008*detail+.006*fine,0,.07)\nnose=.029*np.exp(-((v-.985)/.066)**2)*np.clip(fine+.7,0,1)\nsave('Fuselage_color',tints-(weather*.55+nose)[...,None])\nsave('Fuselage_roughness',.26+.025*stripe+.018*detail+.012*fine+nose)\nnormal('Fuselage_normal',.07*detail+.085*fine,.33)\n\n# Wing and tail UVs run chordwise, then along the half-span.\ntip_mask=smooth((.843,.847),1-v)\nwing_accent=smooth((.780,.784),1-v)*(1-smooth((.801,.805),1-v))\nwing_color=masks(palette,[tip_mask,wing_accent])\nwash=.013*np.exp(-(u/.11)**2)*np.clip(detail+.8,0,1)+.007*broad+.005*fine\nsave('Wing_color',wing_color-wash[...,None])\nsave('Wing_roughness',.26+.017*tip_mask+.013*detail+.010*fine)\nnormal('Wing_normal',.065*fine+.043*detail,.32)\n\ncloth=noise(80,77)\nweave=(np.sin(u*2*np.pi*178)*np.sin(v*2*np.pi*211))\nseat=np.array([.28,.157,.086])+(.026*cloth+.012*weave+.008*fine)[...,None]\nsave('Seat_color',seat)\nsave('Seat_roughness',.62+.027*cloth+.014*weave)\nnormal('Seat_normal',.22*weave+.14*cloth,.68)\n\nsave('Tire_roughness',.71+.066*detail+.021*fine)\nnormal('Tire_normal',.14*detail+.24*fine,.66)\n```\n\n```python\n# sailplane.py\n\"\"\"Build the Ternfall L-8 composite club sailplane.\"\"\"\nfrom math import sin, cos, pi, sqrt, radians\nfrom pathlib import Path\nimport bpy\nimport bmesh\nfrom mathutils import Vector\n\nROOT=Path(__file__).resolve().parent\nSTEM='3d-dataset-20261128T1500Z-vehicles-ternfall-l8-club-sailplane'\nbpy.ops.wm.read_factory_settings(use_empty=True)\nbpy.context.preferences.filepaths.save_version=0\nscene=bpy.context.scene\nscene.unit_settings.system='METRIC'\n\ndef material(name, color, metal=0, rough=.35, coat=0, maps=None, transmission=0):\n m=bpy.data.materials.new(name)\n m.diffuse_color=(*color,1)\n m.use_nodes=True\n tree=m.node_tree\n shader=tree.nodes.get('Principled BSDF')\n for key,val in (('Base Color',(*color,1)),('Metallic',metal),('Roughness',rough),\n ('Coat Weight',coat),('Coat Roughness',.19 if coat else 0),\n ('Transmission Weight',transmission),('IOR',1.46)):\n shader.inputs[key].default_value=val\n for suffix,key in [('color','Base Color'),('roughness','Roughness'),('normal','Normal')]:\n f=ROOT/'maps'/f'{maps}_{suffix}.png'\n if maps and f.exists():\n img=bpy.data.images.load(str(f),check_existing=True)\n img.colorspace_settings.name='sRGB' if suffix=='color' else 'Non-Color'\n tex=tree.nodes.new('ShaderNodeTexImage')\n tex.image=img\n if suffix!='normal':\n tree.links.new(tex.outputs['Color'],shader.inputs[key])\n else:\n norm=tree.nodes.new('ShaderNodeNormalMap')\n norm.inputs['Strength'].default_value=.6\n tree.links.new(tex.outputs['Color'],norm.inputs['Color'])\n tree.links.new(norm.outputs['Normal'],shader.inputs[key])\n return m\n\ncream=(.66,.685,.648)\nblue=(.026,.117,.155)\nrust=(.49,.088,.034)\nfuselage=material('Painted composite fuselage',cream,coat=.37,maps='Fuselage')\nwingmat=material('Painted wing and empennage composites',cream,coat=.31,maps='Wing')\nivory=material('Ivory gelcoat',cream,coat=.28,rough=.28)\nteal=material('Petrol-blue enamel',blue,coat=.28,rough=.24)\norange=material('Burnished vermilion nacre paint',rust,.11,.28,.27)\nglass=material('Blue-gray acrylic canopy',(.82,.88,.89),0,.068,.045,transmission=.99)\ntire=material('Molded black rubber',(.022,.025,.025),0,.68,maps='Tire')\nseat=material('Cinnamon woven cockpit upholstery',(.085,.031,.012),0,.62,maps='Seat')\nmatte=material('Charcoal instrument panel and liner',(.027,.033,.036),0,.53)\nmetal=material('Satin anodized aluminum',(.37,.42,.43),.88,.27)\nseam=material('Flush composite hinge seams',(.20,.245,.246),0,.53)\nstencil=material('Pale cockpit instrument markings',(.73,.74,.66),0,.46)\nwebbing=material('Slate restraint webbing',(.075,.083,.076),0,.64)\n\ndef mesh(name,verts,faces,mat,uv=None,flat=False,recalc=True):\n me=bpy.data.meshes.new(name)\n me.from_pydata(verts,[],faces)\n me.update()\n ob=bpy.data.objects.new(name,me)\n scene.collection.objects.link(ob)\n me.materials.append(mat)\n layer=me.uv_layers.new(name='UVMap')\n for p in me.polygons:\n p.use_smooth=not flat\n for loop in p.loop_indices:\n i=me.loops[loop].vertex_index\n layer.data[loop].uv=uv(i,p.index) if uv else (.50+verts[i][0],.50+verts[i][1])\n if recalc:\n bm=bmesh.new()\n bm.from_mesh(me)\n bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces))\n bm.to_mesh(me)\n bm.free()\n return ob\n\ndef path(points,divisions=10):\n p=[Vector(x) for x in points]\n dense=[]\n for i in range(len(p)-1):\n a,b,c,d=p[max(0,i-1)],p[i],p[i+1],p[min(len(p)-1,i+2)]\n for j in range(divisions):\n t=j/divisions\n dense.append(.5*((2*b)+(c-a)*t+(2*a-5*b+4*c-d)*t*t+(-a+3*b-3*c+d)*t*t*t))\n return dense+[p[-1]]\n\ndef tube(name,points,r,mat,smooth=0):\n p=path(points,smooth) if smooth else points\n cu=bpy.data.curves.new(name,'CURVE')\n cu.dimensions='3D'\n cu.resolution_u=1\n cu.bevel_depth=r\n cu.bevel_resolution=3\n cu.use_fill_caps=True\n spl=cu.splines.new('POLY')\n spl.points.add(len(p)-1)\n for dst,(x,y,z) in zip(spl.points,p):\n dst.co=(x,y,z,1)\n ob=bpy.data.objects.new(name,cu)\n scene.collection.objects.link(ob)\n cu.materials.append(mat)\n return ob\n\ndef activate(obj):\n bpy.ops.object.select_all(action='DESELECT')\n obj.select_set(True)\n bpy.context.view_layer.objects.active=obj\n\ndef block(name,loc,size,r,mat,angle=0):\n bpy.ops.mesh.primitive_cube_add(size=1,location=loc)\n o=bpy.context.object\n o.name=name\n o.dimensions=size\n bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)\n o.rotation_euler.x=angle\n o.data.materials.append(mat)\n b=o.modifiers.new('Molded edge fillets','BEVEL')\n b.width=r\n b.segments=6\n w=o.modifiers.new('Face-weighted normals','WEIGHTED_NORMAL')\n return o\n\ndef cylinder(name,start,end,radius,mat,vertices=64):\n a,b=Vector(start),Vector(end)\n v=b-a\n bpy.ops.mesh.primitive_cylinder_add(vertices=vertices,radius=radius,depth=v.length,location=(a+b)/2)\n o=bpy.context.object\n o.name=name\n o.rotation_mode='QUATERNION'\n o.rotation_quaternion=v.to_track_quat('Z','Y')\n o.data.materials.append(mat)\n for p in o.data.polygons:\n p.use_smooth=len(p.vertices)==4\n m=o.modifiers.new('Rounded rim','BEVEL')\n m.width=min(.008,radius*.14)\n m.segments=5\n w=o.modifiers.new('Face-weighted normals','WEIGHTED_NORMAL')\n return o\n\n# Cross sections of the shell are listed from the forward nose to the tail.\nshell=[(-2.84,.023,.741,.021,.027),(-2.78,.134,.749,.110,.107),\n (-2.62,.271,.765,.190,.224),(-2.38,.352,.787,.251,.326),\n (-2.18,.405,.814,.286,.422),(-1.94,.446,.834,.321,.532),\n (-1.60,.469,.848,.359,.613),(-1.26,.455,.854,.410,.626),\n (-.92,.427,.867,.425,.589),(-.56,.376,.870,.416,.524),\n (-.33,.343,.858,.394,.458),(.04,.297,.837,.336,.385),\n (.44,.234,.800,.253,.297),(.88,.161,.754,.177,.217),\n (1.35,.117,.698,.128,.146),(1.82,.088,.658,.114,.107),\n (2.28,.074,.615,.105,.083),(2.62,.060,.578,.088,.064),\n (2.85,.025,.557,.042,.037),(2.89,.005,.557,.009,.009)]\ndense=path(shell,12)\nN=128\ncanopy_start,canopy_end=-2.18,-.33\nstart=min(range(len(dense)),key=lambda i:abs(dense[i][0]-canopy_start))\nend=min(range(len(dense)),key=lambda i:abs(dense[i][0]-canopy_end))\nM=40\nhull=[]; uv_ring=[]\nframes=[]\nfor j,(y,w,z,bottom,top) in enumerate(dense):\n t=max(0,min(1,(y-canopy_start)/(canopy_end-canopy_start)))\n aperture=.062+.96*(sin(pi*t)**.52)\n a0=pi*.50-aperture\n a1=pi*.50+aperture\n theta=[a0+(a1-a0)*i/M for i in range(M+1)]\n theta.extend(a1+(2*pi+a0-a1)*i/(N-M) for i in range(1,N-M))\n frame=[]\n for a in theta:\n s=sin(a)\n p=(w*cos(a),y,z+s*(top if s>=0 else bottom))\n frame.append(p)\n hull.append(p)\n uv_ring.append(((a+pi*.5)/(2*pi),(y+2.84)/5.73))\n frames.append(frame)\nfaces=[]\nfor j in range(len(frames)-1):\n for i in range(N):\n if start<=j=mid else bottom)\n return (side*(rx*sqrt(max(0,1-h*h))+.0045),y,z)\nfor s in (-1,1):\n decal('Fuselage model lettering','T E R N F A L L',.105,ivory,lambda u,v:nose_mark(u,v,s))\ndef fin_mark(u,v,side):\n z=1.310+v\n finrow=section_at(dense_fin,z)\n _,le,ch,_,_=finrow\n y=2.465+u*side\n pt_=pt(finrow,max(.02,min(.98,(y-le)/ch)),1,True,.006)\n return (pt_[2]*side,y,z)\nfor s in (-1,1):\n decal('Vertical stabilizer flight number','08',.248,teal,lambda u,v:fin_mark(u,v,s))\n\n# Wingtip navigation lenses and small inspection hardware.\nfor s in (-1,1):\n p=(s*5.195,-.136,1.353)\n block('Wingtip navigation lens',p,(.032,.059,.030),.013,orange if s<0 else teal)\nfor s in (-1,1):\n cylinder('Main wing inspection disc',(s*.53,-.19,.938),(s*.53,-.19,.945),.048,ivory)\nblock('Nose tow attachment recess',(0,-2.822,.687),(.079,.035,.053),.015,matte)\n\nbpy.ops.file.pack_all()\nbpy.ops.wm.save_as_mainfile(filepath=str(ROOT/'ternfall-l8.blend'))\n# Export the editable authoring parts as a single static object.\nfor o in list(scene.objects):\n activate(o)\n if o.type!='MESH':\n bpy.ops.object.convert(target='MESH')\n o=bpy.context.object\n for m in list(o.modifiers):\n bpy.ops.object.modifier_apply(modifier=m.name)\nbpy.ops.object.select_all(action='SELECT')\nbpy.context.view_layer.objects.active=body\nbpy.ops.object.join()\nbpy.context.object.name='Ternfall L-8 Club Sailplane'\nbpy.ops.export_scene.gltf(filepath=str(ROOT/(STEM+'.glb')),export_format='GLB',export_yup=True,\n export_cameras=False,export_lights=False,export_animations=False,export_image_format='AUTO')\n```\n\n```python\n# clean_export.py\n\"\"\"Remove zero-area triangles left by evaluated bevel and lettering modifiers.\"\"\"\nimport json\nfrom pathlib import Path\nimport struct\nimport sys\n\nimport numpy as np\n\npath=Path(sys.argv[1])\ndata=path.read_bytes()\nmagic,version,total=struct.unpack_from(\"<4sII\",data)\nassert (magic,version,total)==(b\"glTF\",2,len(data))\njson_size,json_type=struct.unpack_from(\"