feat: add croissant cake and cream toast

This commit is contained in:
Yanchen
2026-11-15 14:47:19 +08:00
parent 036ee25a2a
commit e784ef07a8
22 changed files with 559 additions and 129 deletions
+37 -129
View File
@@ -2,7 +2,6 @@ import bpy
import bmesh
import json
import math
import random
import sys
from pathlib import Path
from mathutils import Matrix, Vector
@@ -11,7 +10,6 @@ ROOT = Path(__file__).resolve().parent
REFERENCE = ROOT / "reference" / "consumables"
MAX_TRIANGLES = 1000
TAU = math.tau
RNG = random.Random(41)
MANIFEST = []
@@ -522,126 +520,41 @@ def make_cake(collection, root):
root["design_id"] = "cake_slice"
def make_avocado_toast(collection, root):
crust = material("Toast_Crust", (0.33, 0.12, 0.032), 0.82)
crumb = material("Toast_Crumb", (0.76, 0.49, 0.20), 0.9)
spread = material("Avocado_Spread", (0.23, 0.39, 0.047), 0.85)
greens = [material(f"Avocado_Slice_{i}", color, 0.62) for i, color in enumerate([
(0.48, 0.66, 0.12), (0.40, 0.58, 0.075), (0.57, 0.70, 0.18),
])]
pepper = material("Toast_Chili", (0.30, 0.045, 0.017), 0.8)
outline = [(-0.049, -0.060), (0.049, -0.060), (0.055, -0.050), (0.054, 0.022),
(0.052, 0.043), (0.038, 0.060), (0.019, 0.064), (0, 0.059),
(-0.019, 0.064), (-0.038, 0.060), (-0.052, 0.043), (-0.054, 0.022),
(-0.055, -0.050)]
prism("Toast_Bread_Crust", outline, 0.001, 0.022, crust, collection, root)
prism("Toast_Inner_Crumb", [(x * 0.90, y * 0.91) for x, y in outline], 0.0215, 0.0235, crumb, collection, root)
prism("Toast_Avocado_Spread", [(x * 0.81, y * 0.83) for x, y in outline], 0.0235, 0.026, spread, collection, root)
for i in range(7):
cx, cy = -0.031 + i * 0.010, -0.017 + i * 0.005
angle = -0.28
raw = [(-0.006, -0.032), (0.007, -0.032), (0.011, -0.014), (0.012, 0.009),
(0.008, 0.026), (0, 0.035), (-0.008, 0.026), (-0.012, 0.009), (-0.011, -0.014)]
points = [(cx + x * math.cos(angle) - y * math.sin(angle),
cy + x * math.sin(angle) + y * math.cos(angle)) for x, y in raw]
prism(f"Toast_Avocado_Fan_{i + 1}", points, 0.026 + i * 0.00045, 0.0295 + i * 0.00045,
greens[i % 3], collection, root)
for i in range(12):
x, y = RNG.uniform(-0.034, 0.035), RNG.uniform(-0.031, 0.031)
size = RNG.uniform(0.0014, 0.0027)
link_mesh(collection, root, f"Toast_Chili_Flake_{i + 1}", [
(x - size, y, 0.034), (x, y + size * 0.65, 0.0345), (x + size, y - size * 0.3, 0.034),
], [(0, 1, 2)], [pepper])
def make_cream_toast(collection, root):
crust = material("Toast_Crust", (0.43, 0.18, 0.052), 0.82)
crumb = material("Toast_Crumb", (0.82, 0.65, 0.38), 0.88)
cream = material("Toast_PaleYellowCream", (0.94, 0.77, 0.30), 0.48)
outline = [
(-0.046, -0.059), (0.046, -0.059), (0.053, -0.055),
(0.057, -0.048), (0.057, -0.030), (0.055, 0.022),
(0.054, 0.038), (0.047, 0.050), (0.035, 0.059),
(0.020, 0.064), (0, 0.061), (-0.020, 0.064),
(-0.035, 0.059), (-0.047, 0.050), (-0.054, 0.038),
(-0.055, 0.022), (-0.057, -0.030), (-0.057, -0.048),
(-0.053, -0.055),
]
def layer(name, rings, mat):
count = len(outline)
vertices = [(x * scale, y * scale, z) for scale, z in rings for x, y in outline]
faces = [tuple(reversed(range(count)))]
for ring in range(len(rings) - 1):
for i in range(count):
j = (i + 1) % count
a = ring * count
b = (ring + 1) * count
faces.append((a + i, a + j, b + j, b + i))
faces.append(tuple(range((len(rings) - 1) * count, len(rings) * count)))
obj = link_mesh(collection, root, name, vertices, faces, [mat], smooth=True)
for polygon in obj.data.polygons:
polygon.use_smooth = len(polygon.vertices) == 4
return obj
layer("Toast_Bread_Crust", [(0.94, 0.001), (1.0, 0.003), (1.0, 0.0145), (0.965, 0.017)], crust)
layer("Toast_Inner_Crumb", [(0.90, 0.017), (0.90, 0.01735)], crumb)
layer("Toast_PaleYellowCream_Layer", [(0.827, 0.01735), (0.845, 0.01775), (0.827, 0.0194)], cream)
root["design_id"] = "avocado_toast"
def make_wrap(collection, root):
tortilla = material("Wrap_Tortilla", (0.73, 0.51, 0.26), 0.8)
edge = material("Wrap_TortillaEdge", (0.87, 0.68, 0.40), 0.82)
lettuce = material("Wrap_Lettuce", (0.15, 0.34, 0.045), 0.8)
chicken = material("Wrap_Chicken", (0.59, 0.30, 0.11), 0.75)
tomato = material("Wrap_Tomato", (0.62, 0.065, 0.024), 0.58)
onion = material("Wrap_Onion", (0.54, 0.20, 0.36), 0.7)
segments = 16
vertices, faces = [], []
for x, radius in [(-0.065, 0.006), (-0.057, 0.028), (-0.040, 0.035), (0.035, 0.035), (0.057, 0.033)]:
for j in range(segments):
a = TAU * j / segments
vertices.append((x, radius * math.cos(a), 0.036 + radius * 0.90 * math.sin(a)))
for i in range(4):
for j in range(segments):
k = (j + 1) % segments
faces.append((i * segments + j, i * segments + k, (i + 1) * segments + k, (i + 1) * segments + j))
faces += [tuple(reversed(range(segments))), tuple(range(64, 80))]
link_mesh(collection, root, "Wrap_Tortilla_Roll", vertices, faces, [tortilla], smooth=True)
vertices = []
for x, radius in [(0.0572, 0.033), (0.058, 0.029), (0.052, 0.029), (0.052, 0.032)]:
for j in range(segments):
a = TAU * j / segments
vertices.append((x, radius * math.cos(a), 0.036 + radius * 0.90 * math.sin(a)))
faces = []
for i in range(3):
for j in range(segments):
k = (j + 1) % segments
faces.append((i * segments + j, i * segments + k, (i + 1) * segments + k, (i + 1) * segments + j))
link_mesh(collection, root, "Wrap_Cut_Tortilla_Rim", vertices, faces, [edge])
ellipsoid("Wrap_Filling_Base", (0.053, 0, 0.036), (0.005, 0.028, 0.024), lettuce, collection, root)
for i, (y, z) in enumerate([(-0.014, 0.024), (0.005, 0.021), (0.013, 0.040), (-0.004, 0.052)]):
box(f"Wrap_Chicken_{i + 1}", (0.059, y, z), (0.012, 0.016, 0.010), chicken, collection, root, i * 0.65)
for i, (y, z) in enumerate([(-0.013, 0.041), (0.008, 0.032), (0.001, 0.014)]):
box(f"Wrap_Tomato_{i + 1}", (0.064, y, z), (0.009, 0.012, 0.010), tomato, collection, root, i)
for i, (y, z) in enumerate([(-0.019, 0.053), (0.001, 0.058), (0.019, 0.052)]):
tube(f"Wrap_Lettuce_Tip_{i + 1}", [(0.055, y * 0.65, z - 0.007), (0.064, y, z), (0.068, y * 1.13, z + 0.003)],
0.0035, 4, lettuce, collection, root)
tube("Wrap_Onion_Strip", [(0.067, -0.014, 0.032), (0.071, 0, 0.041), (0.067, 0.014, 0.050)], 0.0016, 4, onion, collection, root)
root["design_id"] = "wrap"
def leaf(name, center, length, width, angle, tilt, mat, collection, root):
vertices = [(center[0], center[1], center[2] + 0.004)]
count = 10
for j in range(count):
a = TAU * j / count
x = width * math.cos(a) * (1 + 0.13 * math.cos(5 * a))
y = length * math.sin(a)
z = tilt * y + 0.004 * math.cos(3 * a)
vertices.append((center[0] + x * math.cos(angle) - y * math.sin(angle),
center[1] + x * math.sin(angle) + y * math.cos(angle), center[2] + z))
faces = [(0, j + 1, (j + 1) % count + 1) for j in range(count)]
return link_mesh(collection, root, name, vertices, faces, [mat])
def make_salad(collection, root):
bowl_mat = material("Salad_Bowl", (0.73, 0.78, 0.67), 0.4)
greens = [material(f"Salad_Lettuce_{i}", color, 0.85) for i, color in enumerate([
(0.16, 0.34, 0.035), (0.26, 0.46, 0.060), (0.36, 0.53, 0.09),
])]
tomato = material("Salad_Tomato", (0.68, 0.055, 0.026), 0.4)
cucumber = material("Salad_CucumberSkin", (0.028, 0.16, 0.035), 0.65)
cucumber_flesh = material("Salad_CucumberFlesh", (0.61, 0.73, 0.28), 0.7)
carrot = material("Salad_Carrot", (0.90, 0.28, 0.026), 0.75)
profile = [(0, 0.001), (0.025, 0.001), (0.033, 0.007), (0.048, 0.025),
(0.068, 0.051), (0.075, 0.060), (0.076, 0.063), (0.071, 0.063),
(0.068, 0.057), (0.044, 0.026), (0.026, 0.009), (0, 0.009)]
loft("Salad_Bowl", profile, 20, bowl_mat, collection, root)
for i in range(12):
a = i * 2.4
radius = 0.015 + 0.026 * (i % 3) / 2
center = (radius * math.cos(a), radius * math.sin(a), 0.045 + 0.003 * (i % 4))
leaf(f"Salad_Leaf_{i + 1}", center, 0.025 + RNG.random() * 0.009,
0.015 + RNG.random() * 0.005, a, RNG.uniform(-0.25, 0.45), greens[i % 3], collection, root)
for i, (x, y, z) in enumerate([(-0.032, -0.015, 0.060), (0.030, -0.012, 0.062), (0.004, 0.030, 0.065)]):
ellipsoid(f"Salad_Cherry_Tomato_{i + 1}", (x, y, z), (0.012, 0.012, 0.011), tomato, collection, root)
for i, (x, y, z) in enumerate([(-0.023, 0.017, 0.064), (0.022, 0.013, 0.069), (0.001, -0.025, 0.064)]):
loft(f"Salad_Cucumber_Skin_{i + 1}", [(0, z - 0.002), (0.014, z - 0.002), (0.014, z), (0, z)],
10, cucumber, collection, root).location = (x, y, 0)
loft(f"Salad_Cucumber_Flesh_{i + 1}", [(0, z), (0.0115, z), (0.0115, z + 0.0004), (0, z + 0.0004)],
10, cucumber_flesh, collection, root).location = (x, y, 0)
for i in range(7):
a = i * 2.1
box(f"Salad_Carrot_{i + 1}", (0.033 * math.cos(a), 0.029 * math.sin(a), 0.065 + 0.002 * (i % 2)),
(0.003, 0.028, 0.003), carrot, collection, root, a)
root["design_id"] = "salad"
root["presentation"] = "Plain toast with one pale-yellow cream layer; no avocado, chili or other toppings"
def triangle_count(obj, depsgraph=None):
@@ -716,6 +629,7 @@ def report_for(root, collection, out, blend, glb, cap=None):
report = {
"asset": root.name,
"design_id": root.get("design_id"),
"presentation": root.get("presentation"),
"blender_version": bpy.app.version_string,
"units": "meters",
"axis_convention": "Blender Z up; GLB Y up",
@@ -801,9 +715,7 @@ ASSETS = [
("orange_juice_2l", "orange_juice", "orange_juice_2l_product.webp", "OrangeJuice2L_Root"),
("food/bakery_and_cake/Croissant", "croissant", "croissant.jpg", "Croissant_Root"),
("food/bakery_and_cake/CakeSlice", "cake", "cake_slice.jpg", "CakeSlice_Root"),
("food/toast_and_wrap/AvocadoToast", "avocado_toast", "avocado_toast.jpg", "AvocadoToast_Root"),
("food/toast_and_wrap/Wrap", "wrap", "wrap.jpg", "Wrap_Root"),
("food/salad/SaladBowl", "salad", "salad.jpg", "SaladBowl_Root"),
("food/toast_and_wrap/AvocadoToast", "avocado_toast", "cream_toast.jpg", "AvocadoToast_Root"),
]
requested_assets = set(sys.argv[sys.argv.index("--") + 1:]) if "--" in sys.argv else set()
@@ -821,11 +733,7 @@ for directory, kind, reference, root_name in ASSETS:
elif kind == "cake":
make_cake(collection, root)
elif kind == "avocado_toast":
make_avocado_toast(collection, root)
elif kind == "wrap":
make_wrap(collection, root)
elif kind == "salad":
make_salad(collection, root)
make_cream_toast(collection, root)
finalize(root, collection, directory, cap, cap_pivot)
if not requested_assets:
Binary file not shown.
@@ -0,0 +1,68 @@
{
"asset": "CakeSlice_Root",
"design_id": "cake_slice",
"blender_version": "5.2.0 LTS",
"units": "meters",
"axis_convention": "Blender Z up; GLB Y up",
"triangle_limit": 1000,
"triangles": 194,
"passed_triangle_budget": true,
"mesh_components": {
"Cake_Sponge_Lower": 28,
"Cake_Cream_Lower": 28,
"Cake_Sponge_Upper": 28,
"Cake_Cream_Upper": 28,
"Cake_Frosting_Top": 28,
"Cake_Strawberry": 48,
"Cake_Leaf_1": 2,
"Cake_Leaf_2": 2,
"Cake_Leaf_3": 2
},
"bounds_min_m": [
-0.05400000140070915,
-0.05999999865889549,
0.0010000000474974513
],
"bounds_max_m": [
0.05400000140070915,
0.054999999701976776,
0.0949999988079071
],
"dimensions_m": [
0.1080000028014183,
0.11499999836087227,
0.09399999876040965
],
"reference_photo": "cake_slice.jpg",
"reference_images_packed": true,
"labels_or_brand_graphics": false,
"blend": "PerfectCoffee_CakeSlice.blend",
"glb": "PerfectCoffee_CakeSlice.glb",
"preview": "preview.png",
"native_reopen_passed": true,
"glb_reimport_passed": true,
"passed": true,
"native_triangles": 194,
"native_dimensions_m": [
0.1080000028014183,
0.11499999836087227,
0.09399999876040965
],
"no_image_textures_or_labels": true,
"cap_detach_parenting_passed": null,
"cap_blend_and_glb_passed": null,
"liquid_volume_2000ml_passed": null,
"plausible_dimensions_passed": true,
"transparent_pet_passed": null,
"glb_triangles": 194,
"glb_dimensions_m": [
0.1080000028014183,
0.11499999836087227,
0.09399999876040965
],
"studio_excluded_from_glb": true,
"technical_validation_passed": true,
"visual_review_passed": true,
"visual_review_notes": "Triangular slice, two chocolate sponge layers, cream filling, frosting and strawberry are correctly proportioned and visible.",
"cap_assembly_test_passed": null
}
Binary file not shown.
@@ -0,0 +1,60 @@
{
"asset": "Croissant_Root",
"design_id": "croissant",
"blender_version": "5.2.0 LTS",
"units": "meters",
"axis_convention": "Blender Z up; GLB Y up",
"triangle_limit": 1000,
"triangles": 456,
"passed_triangle_budget": true,
"mesh_components": {
"Croissant_Rolled_Pastry": 456
},
"bounds_min_m": [
-0.09190463274717331,
-0.0371473990380764,
0.0012263512471690774
],
"bounds_max_m": [
0.09190463274717331,
0.0447818785905838,
0.058773647993803024
],
"dimensions_m": [
0.18380926549434662,
0.0819292776286602,
0.05754729674663395
],
"reference_photo": "croissant.jpg",
"reference_images_packed": true,
"labels_or_brand_graphics": false,
"blend": "PerfectCoffee_Croissant.blend",
"glb": "PerfectCoffee_Croissant.glb",
"preview": "preview.png",
"native_reopen_passed": true,
"glb_reimport_passed": true,
"passed": true,
"native_triangles": 456,
"native_dimensions_m": [
0.18380926549434662,
0.0819292776286602,
0.05754729674663395
],
"no_image_textures_or_labels": true,
"cap_detach_parenting_passed": null,
"cap_blend_and_glb_passed": null,
"liquid_volume_2000ml_passed": null,
"plausible_dimensions_passed": true,
"transparent_pet_passed": null,
"glb_triangles": 456,
"glb_dimensions_m": [
0.18380926549434662,
0.0819292776286602,
0.05754729674663395
],
"studio_excluded_from_glb": true,
"technical_validation_passed": true,
"visual_review_passed": true,
"visual_review_notes": "Curved crescent silhouette, tapered tips and rolled laminated bands are readable in the render.",
"cap_assembly_test_passed": null
}
+109
View File
@@ -0,0 +1,109 @@
import bpy
from pathlib import Path
from mathutils import Vector
ROOT = Path(__file__).resolve().parent
ASSETS = [
("01 CROISSANT", "bakery_and_cake/Croissant/PerfectCoffee_Croissant.blend"),
("02 CAKE SLICE", "bakery_and_cake/CakeSlice/PerfectCoffee_CakeSlice.blend"),
("03 CREAM TOAST", "toast_and_wrap/AvocadoToast/PerfectCoffee_AvocadoToast.blend"),
]
POSITIONS = [(-0.25, 0), (0, 0), (0.25, 0)]
bpy.ops.wm.read_factory_settings(use_empty=True)
scene = bpy.context.scene
scene.render.engine = "BLENDER_EEVEE"
scene.render.resolution_x = 1600
scene.render.resolution_y = 1250
scene.render.resolution_percentage = 100
scene.render.image_settings.file_format = "PNG"
scene.render.film_transparent = False
scene.view_settings.view_transform = "AgX"
scene.view_settings.look = "AgX - Medium High Contrast"
scene.view_settings.exposure = -0.5
scene.world = bpy.data.worlds.new("Review_World")
scene.world.use_nodes = True
scene.world.node_tree.nodes["Background"].inputs["Color"].default_value = (0.72, 0.78, 0.82, 1)
scene.world.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.3
for (label, relative_path), (x, y) in zip(ASSETS, POSITIONS):
with bpy.data.libraries.load(str(ROOT / relative_path), link=False) as (source, target):
target.collections = ["Model"]
model = target.collections[0]
instance = bpy.data.objects.new(label, None)
instance.instance_type = "COLLECTION"
instance.instance_collection = model
instance.location = (x, y, 0)
scene.collection.objects.link(instance)
meshes = [obj for obj in model.all_objects if obj.type == "MESH"]
triangle_count = 0
for obj in meshes:
obj.data.calc_loop_triangles()
triangle_count += len(obj.data.loop_triangles)
assert triangle_count <= 1000, (label, triangle_count)
print("FOOD_REVIEW", label, triangle_count, flush=True)
for text, size, offset in [(label, 0.015, -0.105), (f"{triangle_count} TRIANGLES", 0.008, -0.121)]:
curve = bpy.data.curves.new(text, "FONT")
curve.body = text
curve.align_x = "CENTER"
curve.size = size
text_object = bpy.data.objects.new(text, curve)
text_object.location = (x, y + offset, 0.001)
scene.collection.objects.link(text_object)
curve = bpy.data.curves.new("Review_Notes", "FONT")
curve.body = "FOOD MODEL REVIEW\n\n3 FOOD ASSETS\nBLENDER 5.2\n1000 TRI LIMIT EACH\nNO PACKAGING\n\nREVIEW SCENE ONLY"
curve.align_x = "CENTER"
curve.size = 0.014
notes = bpy.data.objects.new("Review_Notes", curve)
notes.location = (0, 0.29, 0.001)
scene.collection.objects.link(notes)
text_material = bpy.data.materials.new("Review_Text")
text_material.diffuse_color = (0.045, 0.055, 0.065, 1)
text_material.use_nodes = True
text_material.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (0.045, 0.055, 0.065, 1)
for obj in scene.objects:
if obj.type == "FONT":
obj.data.materials.append(text_material)
material = bpy.data.materials.new("Review_Background")
material.diffuse_color = (0.38, 0.41, 0.36, 1)
material.use_nodes = True
material.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (0.38, 0.41, 0.36, 1)
material.node_tree.nodes["Principled BSDF"].inputs["Roughness"].default_value = 0.86
bpy.ops.mesh.primitive_plane_add(size=200, location=(0, 0, -0.0002))
bpy.context.object.data.materials.append(material)
for label, offset, power, size in [
("Key", (-0.5, -0.5, 0.9), 8, 0.7),
("Fill", (0.6, -0.1, 0.5), 4, 0.6),
("Rim", (0.0, 0.7, 0.8), 6, 0.6),
]:
light_data = bpy.data.lights.new(label, "AREA")
light_data.energy = power
light_data.shape = "DISK"
light_data.size = size
light_object = bpy.data.objects.new(label, light_data)
light_object.location = offset
light_object.rotation_euler = (Vector((0, 0.12, 0)) - light_object.location).to_track_quat("-Z", "Y").to_euler()
scene.collection.objects.link(light_object)
camera_data = bpy.data.cameras.new("Review_Camera")
camera = bpy.data.objects.new("Review_Camera", camera_data)
camera_data.type = "ORTHO"
camera_data.ortho_scale = 0.78
scene.collection.objects.link(camera)
scene.camera = camera
center = Vector((0, 0.105, 0))
camera.location = center + Vector((0.25, -0.60, 0.72))
camera.rotation_euler = (center - camera.location).to_track_quat("-Z", "Y").to_euler()
scene.render.filepath = str(ROOT / "review_three_quarter.png")
bpy.ops.render.render(write_still=True)
camera.location = (0, 0.105, 1)
camera.rotation_euler = (0, 0, 0)
camera_data.ortho_scale = 0.78
scene.render.filepath = str(ROOT / "review_top.png")
bpy.ops.render.render(write_still=True)
print("FOOD_REVIEW_COMPLETE", flush=True)
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,59 @@
{
"asset": "AvocadoToast_Root",
"design_id": "avocado_toast",
"presentation": "Plain toast with one pale-yellow cream layer; no avocado, chili or other toppings",
"blender_version": "5.2.0 LTS",
"units": "meters",
"axis_convention": "Blender Z up; GLB Y up",
"triangle_limit": 1000,
"triangles": 330,
"passed_triangle_budget": true,
"mesh_components": {
"Toast_Bread_Crust": 148,
"Toast_Inner_Crumb": 72,
"Toast_PaleYellowCream_Layer": 110
},
"bounds_min_m": [
-0.05700000002980232,
-0.05900000035762787,
0.0010000000474974513
],
"bounds_max_m": [
0.05700000002980232,
0.06400000303983688,
0.01940000057220459
],
"dimensions_m": [
0.11400000005960464,
0.12300000339746475,
0.01840000052470714
],
"reference_photo": "cream_toast.jpg",
"reference_images_packed": true,
"labels_or_brand_graphics": false,
"blend": "PerfectCoffee_AvocadoToast.blend",
"glb": "PerfectCoffee_AvocadoToast.glb",
"preview": "preview.png",
"native_reopen_passed": true,
"glb_reimport_passed": true,
"passed": true,
"native_triangles": 330,
"native_dimensions_m": [
0.11400000005960464,
0.12300000339746475,
0.01840000052470714
],
"glb_triangles": 330,
"glb_dimensions_m": [
0.11400000005960464,
0.12300000339746475,
0.01840000052470714
],
"no_image_textures_or_labels": true,
"plausible_dimensions_passed": true,
"studio_excluded_from_glb": true,
"technical_validation_passed": true,
"visual_review_passed": true,
"visual_review_notes": "One continuous pale-yellow cream layer over toast, with an exposed crust and crumb border; no avocado slices, chili or other toppings.",
"preview_top": "preview_top.png"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,100 @@
import html
import json
import re
import subprocess
import urllib.parse
from pathlib import Path
OUT = Path(__file__).resolve().parent
OUT.mkdir(parents=True, exist_ok=True)
AGENT = "PerfectCoffeeAssetResearch/1.0"
COMMONS = {
"milk_bottle": "Bottle of milk.jpg",
"croissant": "Croissant 1.jpg",
"cake_slice": "Slice of chocolate cake.jpg",
"cream_toast": "Buttered toast.jpg",
}
def fetch(url):
return subprocess.check_output(
["curl", "-sSL", "--fail", "--max-time", "45", "-A", AGENT, url]
)
sources = []
for name, title in COMMONS.items():
query = urllib.parse.urlencode({
"action": "query",
"format": "json",
"prop": "imageinfo",
"iiprop": "url|extmetadata",
"iiurlwidth": "1000",
"titles": "File:" + title,
})
data = json.loads(fetch("https://commons.wikimedia.org/w/api.php?" + query))
info = next(iter(data["query"]["pages"].values()))["imageinfo"][0]
metadata = info["extmetadata"]
target = OUT / (name + ".jpg")
target.write_bytes(fetch(info["thumburl"]))
sources.append({
"asset": name,
"file": target.name,
"title": info.get("descriptionurl", title).rsplit("/", 1)[-1],
"page_url": info["descriptionurl"],
"image_url": info["thumburl"],
"creator": html.unescape(re.sub(r"<[^>]+>", "", metadata.get("Artist", {}).get("value", ""))),
"license": metadata.get("LicenseShortName", {}).get("value"),
"license_url": metadata.get("LicenseUrl", {}).get("value"),
"usage": "Visual shape reference only; no photographic texture is used in the models.",
})
product_references = [
{
"asset": "milk_2l",
"file": "milk_2l_woolworths.png",
"title": "Woolworths Full Cream Milk 2L",
"page_url": "https://www.woolworths.com.au/shop/productdetails/888137/woolworths-full-cream-milk",
"image_url": "https://www.woolworths.com.au/shop/productdetails/888137/woolworths-full-cream-milk",
"creator": "Woolworths",
"license": "Product photo; internal visual reference only",
"usage": "User-specified rectangular body, chamfered base, tapered shoulders and integral arched handle opening. No label used.",
"local_capture": True,
},
{
"asset": "milk_2l_supplier_previous",
"file": "milk_2l_supplier.jpg",
"title": "2 Litre 2000ml HDPE Plastic Bottle for Milk Juice with Handle",
"page_url": "https://zhenghaoplastic.en.made-in-china.com/product/lmCRJEMTawkb/China-2-Litre-2000ml-HDPE-Plastic-Bottle-for-Milk-Juice-Food-Grade-Plastic-Bottle-with-Handle.html",
"image_url": "https://image.made-in-china.com/2f0j00tvhbymoGfOca/2-Litre-2000ml-HDPE-Plastic-Bottle-for-Milk-Juice-Food-Grade-Plastic-Bottle-with-Handle.jpg",
"creator": "Shenzhen Zhenghao Plastic & Mold Co., Ltd",
"license": "Supplier product photo; internal visual reference only",
"usage": "2L capacity, HDPE body and integral handle. No supplier branding or labels used.",
},
{
"asset": "orange_juice_2l",
"file": "orange_juice_2l_product.webp",
"title": "Rita NFC Orange Juice Drink 2L PET Bottle",
"page_url": "https://ritabeverage.com/products/fruit-drink/rita-nfc-orange-juice-drink-2l-pet-bottle",
"image_url": "https://ritabeverage.com/media/zoo/images/Rita_NFC_Orange_Juice_Drink_2L_PET_Bottle_9007b71ded187b8476887cf78c0d5446.webp",
"creator": "Rita Food & Drink Co., Ltd",
"license": "Supplier product photo; internal visual reference only",
"usage": "2L clear PET silhouette, neck and screw cap only; no branding or labels used.",
},
]
for source in product_references:
if source.get("local_capture"):
assert (OUT / source["file"]).is_file(), "Supply the saved product-page reference crop"
else:
(OUT / source["file"]).write_bytes(fetch(source["image_url"]))
sources.append(source)
(OUT / "sources.json").write_text(
json.dumps({
"accessed": "2026-11-15",
"notes": "References inform proportions and recognizable features. Models are original low-poly geometry, without brand graphics or packaging labels.",
"references": sources,
}, ensure_ascii=False, indent=2) + "\n",
encoding="utf-8",
)
print(f"Saved {len(sources)} reference photos to {OUT}")
@@ -0,0 +1,81 @@
{
"accessed": "2026-11-15",
"notes": "References inform proportions and recognizable features. Models are original low-poly geometry, without brand graphics or packaging labels.",
"references": [
{
"asset": "milk_bottle",
"file": "milk_bottle.jpg",
"title": "File:Bottle_of_milk.jpg",
"page_url": "https://commons.wikimedia.org/wiki/File:Bottle_of_milk.jpg",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/9/9c/Bottle_of_milk.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=thumbnail_unscaled",
"creator": "Rlsheehan",
"license": "CC BY-SA 4.0",
"license_url": "https://creativecommons.org/licenses/by-sa/4.0",
"usage": "Visual shape reference only; no photographic texture is used in the models."
},
{
"asset": "croissant",
"file": "croissant.jpg",
"title": "File:Croissant_1.jpg",
"page_url": "https://commons.wikimedia.org/wiki/File:Croissant_1.jpg",
"image_url": "https://thumb.wikimedia.org/wikipedia/commons/thumb/2/2e/Croissant_1.jpg/1280px-Croissant_1.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=thumbnail",
"creator": "Gaurav Dhwaj Khadka",
"license": "CC BY-SA 4.0",
"license_url": "https://creativecommons.org/licenses/by-sa/4.0",
"usage": "Visual shape reference only; no photographic texture is used in the models."
},
{
"asset": "cake_slice",
"file": "cake_slice.jpg",
"title": "File:Slice_of_chocolate_cake.jpg",
"page_url": "https://commons.wikimedia.org/wiki/File:Slice_of_chocolate_cake.jpg",
"image_url": "https://thumb.wikimedia.org/wikipedia/commons/thumb/8/8d/Slice_of_chocolate_cake.jpg/1280px-Slice_of_chocolate_cake.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=thumbnail",
"creator": "Ruth Hartnup from Vancouver, Canada",
"license": "CC BY 2.0",
"license_url": "https://creativecommons.org/licenses/by/2.0",
"usage": "Visual shape reference only; no photographic texture is used in the models."
},
{
"asset": "cream_toast",
"file": "cream_toast.jpg",
"title": "File:Buttered_toast.jpg",
"page_url": "https://commons.wikimedia.org/wiki/File:Buttered_toast.jpg",
"image_url": "https://thumb.wikimedia.org/wikipedia/commons/thumb/a/a9/Buttered_toast.jpg/1280px-Buttered_toast.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=thumbnail",
"creator": "Acabashi",
"license": "CC BY-SA 4.0",
"license_url": "https://creativecommons.org/licenses/by-sa/4.0",
"usage": "Toast silhouette and pale-yellow spread only; the model uses one plain cream layer, without photographic textures or extra toppings."
},
{
"asset": "milk_2l",
"file": "milk_2l_woolworths.png",
"title": "Woolworths Full Cream Milk 2L",
"page_url": "https://www.woolworths.com.au/shop/productdetails/888137/woolworths-full-cream-milk",
"image_url": "https://www.woolworths.com.au/shop/productdetails/888137/woolworths-full-cream-milk",
"creator": "Woolworths",
"license": "Product photo; internal visual reference only",
"usage": "User-specified rectangular body, chamfered base, tapered shoulders and integral arched handle opening. No label used.",
"local_capture": true
},
{
"asset": "milk_2l_supplier_previous",
"file": "milk_2l_supplier.jpg",
"title": "2 Litre 2000ml HDPE Plastic Bottle for Milk Juice with Handle",
"page_url": "https://zhenghaoplastic.en.made-in-china.com/product/lmCRJEMTawkb/China-2-Litre-2000ml-HDPE-Plastic-Bottle-for-Milk-Juice-Food-Grade-Plastic-Bottle-with-Handle.html",
"image_url": "https://image.made-in-china.com/2f0j00tvhbymoGfOca/2-Litre-2000ml-HDPE-Plastic-Bottle-for-Milk-Juice-Food-Grade-Plastic-Bottle-with-Handle.jpg",
"creator": "Shenzhen Zhenghao Plastic & Mold Co., Ltd",
"license": "Supplier product photo; internal visual reference only",
"usage": "2L capacity, HDPE body and integral handle. No supplier branding or labels used."
},
{
"asset": "orange_juice_2l",
"file": "orange_juice_2l_product.webp",
"title": "Rita NFC Orange Juice Drink 2L PET Bottle",
"page_url": "https://ritabeverage.com/products/fruit-drink/rita-nfc-orange-juice-drink-2l-pet-bottle",
"image_url": "https://ritabeverage.com/media/zoo/images/Rita_NFC_Orange_Juice_Drink_2L_PET_Bottle_9007b71ded187b8476887cf78c0d5446.webp",
"creator": "Rita Food & Drink Co., Ltd",
"license": "Supplier product photo; internal visual reference only",
"usage": "2L clear PET silhouette, neck and screw cap only; no branding or labels used."
}
]
}