```python
import bpy
import math
import os
from mathutils import Vector, Matrix

# YGG-1 / passive deep-space observatory
# All principal parts, including the recessed wing channels, are mesh geometry.
OUT = "/mnt/data"
os.makedirs(OUT, exist_ok=True)
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)

def material(name, color, metallic=0.0, roughness=.35, emission=None, strength=0):
    m = bpy.data.materials.new(name)
    m.use_nodes = True
    p = m.node_tree.nodes.get("Principled BSDF")
    p.inputs["Base Color"].default_value = (*color, 1)
    p.inputs["Metallic"].default_value = metallic
    p.inputs["Roughness"].default_value = roughness
    if "Coat Weight" in p.inputs:
        p.inputs["Coat Weight"].default_value = .19
        p.inputs["Coat Roughness"].default_value = .23
    if emission:
        p.inputs["Emission Color"].default_value = (*emission, 1)
        p.inputs["Emission Strength"].default_value = strength
    return m

ceramic = material("01 • Pearl ceramic composite", (.77, .82, .85), .23, .29)
ceramic2 = material("02 • Warm pearl service covers", (.66, .71, .74), .26, .34)
metal = material("03 • Titanium / internal structure", (.065, .089, .115), .82, .28)
black = material("04 • Recessed carbon–ceramic", (.012, .022, .033), .48, .35)
rubber = material("05 • Cabin graphite", (.018, .022, .027), .12, .55)
accent = material("06 • Field-anodized titanium", (.15, .25, .32), .78, .24)
ink = material("07 • Technical markings", (.045, .078, .105), .28, .43)
silver = material("08 • Machined lip", (.35, .46, .53), .8, .24)
field = material("09 • Suspension / cyan", (.045, .34, .45), .3, .27,
                 (.08, .62, 1.0), 2.2)
violet = material("10 • Suspension / violet", (.23, .12, .42), .25, .3,
                  (.40, .19, 1.0), 2.1)
engine = material("11 • Contained plasma / white-blue", (.55, .8, .95), .15, .2,
                  (.57, .83, 1), 9)
engine_dim = material("12 • Channel transport light", (.06, .20, .3), .4, .28,
                      (.13, .48, 1), 3.0)
amber = material("13 • Cabin amber displays", (.45, .15, .025), .15, .3,
                 (1, .33, .055), 3.1)
sensor = material("14 • Coated instrument optics", (.018, .1, .13), .65, .15,
                  (.025, .19, .24), .45)
glass = material("15 • Smoked transparent canopy", (.22, .36, .43), .0, .085)
gp = glass.node_tree.nodes.get("Principled BSDF")
gp.inputs["Transmission Weight"].default_value = 1.0
gp.inputs["IOR"].default_value = 1.46
gp.inputs["Coat Weight"].default_value = .28
if "Thin Film Thickness" in accent.node_tree.nodes.get("Principled BSDF").inputs:
    accent.node_tree.nodes.get("Principled BSDF").inputs["Thin Film Thickness"].default_value = 310
    accent.node_tree.nodes.get("Principled BSDF").inputs["Thin Film IOR"].default_value = 1.37

def mesh_obj(name, verts, faces, mat, bevel=0, smooth=False):
    me = bpy.data.meshes.new(name)
    me.from_pydata(verts, [], faces)
    me.update()
    ob = bpy.data.objects.new(name, me)
    bpy.context.collection.objects.link(ob)
    if mat:
        ob.data.materials.append(mat)
    if smooth:
        for p in me.polygons:
            p.use_smooth = True
    if bevel:
        mod = ob.modifiers.new("Engineered edge radii", 'BEVEL')
        mod.width = bevel
        mod.segments = 3
        mod.limit_method = 'ANGLE'
        mod.angle_limit = .33
        mod = ob.modifiers.new("Area-weighted normals", 'WEIGHTED_NORMAL')
        mod.keep_sharp = True
        mod.weight = 40
    return ob

def cube(name, loc, scale, mat, bevel=.04):
    bpy.ops.mesh.primitive_cube_add(size=1, location=loc)
    o = bpy.context.object
    o.name = name
    o.dimensions = scale
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
    o.data.materials.append(mat)
    if bevel:
        b = o.modifiers.new("Soft machined corners", 'BEVEL')
        b.width = bevel
        b.segments = 3
        o.modifiers.new("Weighted normals", 'WEIGHTED_NORMAL')
    return o

def line(name, points, radius, mat, cyclic=False):
    c = bpy.data.curves.new(name, 'CURVE')
    c.dimensions = '3D'
    c.resolution_u = 1
    c.bevel_depth = radius
    c.bevel_resolution = 3
    s = c.splines.new('POLY')
    s.points.add(len(points)-1)
    for p, v in zip(s.points, points):
        p.co = (*v, 1)
    s.use_cyclic_u = cyclic
    ob = bpy.data.objects.new(name, c)
    bpy.context.collection.objects.link(ob)
    ob.data.materials.append(mat)
    bpy.context.view_layer.objects.active = ob
    ob.select_set(True)
    bpy.ops.object.convert(target='MESH')
    ob.select_set(False)
    return ob

def text_obj(name, text, loc, size, mat, xaxis=(1,0,0), yaxis=(0,1,0)):
    c = bpy.data.curves.new(name, 'FONT')
    c.body = text
    c.size = size
    c.space_character = 1.14
    c.extrude = .0007
    c.resolution_u = 8
    for path in ("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
                 "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf"):
        if os.path.exists(path):
            try:
                c.font = bpy.data.fonts.load(path)
            except Exception:
                pass
            break
    o = bpy.data.objects.new(name, c)
    bpy.context.collection.objects.link(o)
    x, y = Vector(xaxis).normalized(), Vector(yaxis).normalized()
    z = x.cross(y).normalized()
    o.matrix_world = Matrix(((x.x,y.x,z.x,loc[0]),
                            (x.y,y.y,z.y,loc[1]),
                            (x.z,y.z,z.z,loc[2]),
                            (0,0,0,1)))
    o.data.materials.append(mat)
    bpy.context.view_layer.objects.active = o
    o.select_set(True)
    bpy.ops.object.convert(target='MESH')
    o.select_set(False)
    return o

# Smooth, short, rear-heavy pressure hull.
hull_keys = [
    (-3.65,.19,.15,-.04), (-3.32,.43,.28,-.01),
    (-2.75,.70,.46,.015), (-1.85,.98,.65,.025),
    (-.70,1.27,.87,0), (.40,1.39,.99,-.025),
    (1.30,1.33,.95,-.04), (1.95,1.11,.79,-.04),
    (2.43,.72,.54,-.035), (2.66,.30,.29,-.035)
]
def section(y):
    for i in range(len(hull_keys)-1):
        a, b = hull_keys[i], hull_keys[i+1]
        if y <= b[0]:
            t = max(0, min(1, (y-a[0])/(b[0]-a[0])))
            vals = []
            for j in range(1,4):
                p0 = hull_keys[max(0,i-1)][j]
                p1, p2 = a[j], b[j]
                p3 = hull_keys[min(len(hull_keys)-1,i+2)][j]
                vals.append(.5*((2*p1)+(-p0+p2)*t+
                                  (2*p0-5*p1+4*p2-p3)*t*t+
                                  (-p0+3*p1-3*p2+p3)*t*t*t))
            return vals
    return hull_keys[-1][1:]

def signedpow(v, p):
    return math.copysign(abs(v)**p, v)

def hullpoint(y, angle, outset=0):
    w, h, z = section(y)
    return ((w+outset)*signedpow(math.cos(angle), .85), y,
            z+(h+outset)*signedpow(math.sin(angle), .85))

N, R = 64, 78
ys = [hull_keys[0][0] + (hull_keys[-1][0]-hull_keys[0][0])*i/(R-1)
      for i in range(R)]
verts = [hullpoint(y, 2*math.pi*j/N) for y in ys for j in range(N)]
faces = []
for i in range(R-1):
    for j in range(N):
        faces.append((i*N+j,i*N+(j+1)%N,(i+1)*N+(j+1)%N,(i+1)*N+j))
faces += [tuple(range(N-1,-1,-1)), tuple((R-1)*N+j for j in range(N))]
hull = mesh_obj("YGG-1 | compact ceramic pressure hull", verts, faces, ceramic, smooth=True)

# A genuine cabin void, not opaque glass laid on a solid hull.
opening = [(-.33,-2.97),(.33,-2.97),(.58,-1.19),(-.58,-1.19)]
cv = [(x,y,z) for z in (.15,1.65) for x,y in opening]
cf = [(0,3,2,1),(4,5,6,7),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7)]
cut = mesh_obj("Cockpit machining tool", cv, cf, None)
bpy.context.view_layer.objects.active = hull
mod = hull.modifiers.new("Recessed single-seat cabin", 'BOOLEAN')
mod.operation = 'DIFFERENCE'
mod.solver = 'EXACT'
mod.object = cut
bpy.ops.object.modifier_apply(modifier=mod.name)
bpy.data.objects.remove(cut, do_unlink=True)
be = hull.modifiers.new("Cabin aperture edge", 'BEVEL')
be.width = .018
be.segments = 2
be.limit_method = 'ANGLE'

cube("Cabin floor", (0,-2.07,.205), (.9,1.55,.1), rubber)
cube("Compact seat cushion", (0,-1.77,.34), (.38,.39,.13), rubber, .07)
seat = cube("Single compact seat back", (0,-1.52,.48), (.39,.14,.48), rubber, .065)
seat.rotation_euler.x = -.13
cube("Seat head silhouette", (0,-1.50,.73), (.25,.13,.16), rubber, .045)
cube("Recessed console", (0,-2.48,.38), (.53,.24,.16), black)
for i in range(3):
    o = cube("Amber navigation display %02d" % i,
             (-.175+i*.175,-2.45,.471), (.135,.125,.013), amber, .008)
    o.rotation_euler.x = .16
for i in range(4):
    cube("Console indicator", (-.15+i*.1,-2.59,.467), (.025,.026,.014), amber, .003)

# Six low planar glazing panels and fine structural mullions.
canopy_v = [
    (-.33,-2.97,.36),(.33,-2.97,.36),
    (-.58,-1.19,.78),(.58,-1.19,.78),
    (-.265,-2.66,.69),(.265,-2.66,.69),
    (-.445,-1.53,.985),(.445,-1.53,.985)
]
canopy_f = [(0,1,5,4), (4,5,7,6), (0,4,6,2),
            (1,3,7,5), (2,6,7,3)]
canopy = mesh_obj("Low faceted smoked-glass cockpit", canopy_v, canopy_f, glass)
sol = canopy.modifiers.new("Thin optical laminate", 'SOLIDIFY')
sol.thickness = .012
for a,b in [(0,1),(0,4),(1,5),(4,5),(4,6),(5,7),(6,7),
            (0,2),(1,3),(2,6),(3,7),(2,3)]:
    line("Canopy flush titanium mullion", [canopy_v[a], canopy_v[b]], .022, metal)
# Small ceramic transition behind the canopy.
mesh_obj("Canopy aft fairing",
         [(-.58,-1.19,.78),(.58,-1.19,.78),(.445,-1.53,.985),
          (-.445,-1.53,.985),(-.53,-.91,.855),(.53,-.91,.855)],
         [(0,1,2,3),(0,4,5,1)], ceramic, .025)

# Sparse purposeful hull seams, service lids and markings.
for y in (-.83,1.98):
    for lo,hi in [(0,.95),(2.19,math.pi),(math.pi,2*math.pi)]:
        pts = [hullpoint(y,lo+(hi-lo)*i/44,.006) for i in range(45)]
        line("Large hull service boundary", pts, .009, metal)

def hull_panel(name, ya, yb, aa, ab, mat):
    v=[]
    nx,ny=14,10
    for i in range(ny+1):
        y=ya+(yb-ya)*i/ny
        for j in range(nx+1):
            v.append(hullpoint(y,aa+(ab-aa)*j/nx,.014))
    f=[]
    for i in range(ny):
        for j in range(nx):
            k=i*(nx+1)+j
            f.append((k,k+1,k+nx+2,k+nx+1))
    return mesh_obj(name,v,f,mat,smooth=True)

for sign in (1,-1):
    if sign == 1:
        aa, ab = -.14,.36
    else:
        aa, ab = math.pi-.36,math.pi+.14
    hull_panel("Large flank maintenance panel",-.60,.52,aa,ab,ceramic2)
    # Integrated narrow listening windows, following the actual hull curvature.
    a = .10 if sign == 1 else math.pi-.10
    hull_panel("Flush interferometer window", -2.54,-1.95,a-.085,a+.085,black)
    hull_panel("Blue-black instrument glass", -2.48,-2.03,a-.052,a+.052,sensor)
    a2 = -.38 if sign == 1 else math.pi+.38
    hull_panel("Aft passive sensor slit", .00,.63,a2-.039,a2+.039,black)
    hull_panel("Aft aperture optical interior", .05,.56,a2-.018,a2+.018,sensor)

text_obj("Primary serial / ceramic dorsal marking", "YGG-1",
         (-.53,-.54,.953), .30, ink)
text_obj("Mission designation", "PASSIVE SURVEY  /  01",
         (-.51,-.72,.936), .072, ink)

# Starboard and port markings are readable from inspection angles.
text_obj("Starboard serial", "YGG-1", (1.375,.41,.06), .255, ink,
         (0,-1,0),(0,0,1))
text_obj("Port serial", "YGG-1", (-1.375,-.53,.06), .255, ink,
         (0,1,0),(0,0,1))

# Tightly closed aft power-system cap, explicitly not a fourth engine.
cap = cube("Aft reactor closure", (0,2.585,-.035), (.64,.13,.49), black, .13)
for x in (-.19,0,.19):
    cube("Aft heat exchange slot", (x,2.66,-.035), (.055,.018,.25), metal, .018)

# Exactly three thick swept engine wings.
# Station tuples: radial distance, aft distance, full chordwise width, thickness.
stations = [
    (2.02,1.22,1.56,.78),
    (2.55,1.23,1.67,.93),
    (2.94,1.39,1.68,1.04),
    (3.24,1.76,1.50,1.00),
    (3.68,2.49,1.25,.89),
    (4.36,3.70,.94,.68),
    (5.18,5.13,.51,.35),
    (5.84,6.03,.035,.055)
]

def sample(s):
    i = min(len(stations)-2, max(0,int(s)))
    f = min(1, max(0,s-i))
    a,b=stations[i],stations[i+1]
    val=[a[j]*(1-f)+b[j]*f for j in range(4)]
    def tangent(k):
        p=stations[max(0,k-1)]
        n=stations[min(len(stations)-1,k+1)]
        v=Vector((n[0]-p[0],n[1]-p[1]))
        return v.normalized()
    d=(tangent(i)*(1-f)+tangent(i+1)*f).normalized()
    return val, Vector((-d.y,d.x))

wing_defs = [
    ("STARBOARD", Vector((math.cos(.12),0,-math.sin(.12))),
     Vector((math.sin(.12),0,math.cos(.12))),1.36),
    ("PORT", Vector((-math.cos(.12),0,-math.sin(.12))),
     Vector((-math.sin(.12),0,math.cos(.12))),1.36),
    ("DORSAL", Vector((0,0,1)),Vector((1,0,0)),1.015)
]

for wi,(name,u,t,cradle_r) in enumerate(wing_defs):
    def tr(r,y,w):
        return tuple(u*r+Vector((0,y,0))+t*w)
    def wp(s,q,hfraction,offset=0):
        (r,y,width,h), n = sample(s)
        return tr(r+n.x*q*width*.5, y+n.y*q*width*.5, h*hfraction+offset)

    # Swept sections produce real concave elbows rather than straight radial fins.
    def sweep(name2, section_coords, ss, mat, bevel=.035):
        vv=[]
        for s in ss:
            for q,hf,off in section_coords:
                vv.append(wp(s,q,hf,off))
        nn=len(section_coords)
        ff=[tuple(range(nn-1,-1,-1))]
        for k in range(len(ss)-1):
            for j in range(nn):
                ff.append((k*nn+j,k*nn+(j+1)%nn,
                           (k+1)*nn+(j+1)%nn,(k+1)*nn+j))
        ff.append(tuple((len(ss)-1)*nn+j for j in range(nn)))
        return mesh_obj(name+" | "+name2,vv,ff,mat,bevel,True)

    full = [i/3 for i in range(22)]
    sweep("volumetric propulsion chassis",
          [(-1,-.38,0),(1,-.38,0),(1,.38,0),(-1,.38,0)],
          full,metal,.055)

    # Upper and lower ceramic banks leave the center channel physically recessed.
    for face in (-1,1):
        for qa,qb in [(-1,-.31),(.31,1)]:
            sweep("ceramic channel bank",
                  [(qa,face*.36,0),(qb,face*.36,0),
                   (qb,face*.5,0),(qa,face*.5,0)],
                  full,ceramic,.045)
        sweep("recessed black propulsion trough",
              [(-.315,face*.375,0),(.315,face*.375,0),
               (.315,face*.393,0),(-.315,face*.393,0)],
              full,black,.012)
        sweep("armored short-base cap",
              [(-.32,face*.39,0),(.32,face*.39,0),
               (.32,face*.50,0),(-.32,face*.50,0)],
              [0,.35,.70,1.03],ceramic,.045)
        for q in (-.295,.295):
            sweep("anodized channel rim",
                  [(q-.018,face*.393,0),(q+.018,face*.393,0),
                   (q+.018,face*.422,0),(q-.018,face*.422,0)],
                  [1.1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,6.9],
                  accent,.009)
        # Engine is inside the broad elbow. Crosswise luminous vanes are down
        # inside the opening; the ceramic banks rise substantially above them.
        for k in range(8):
            s=1.70+k*.205
            sweep("deep white-blue engine vane %02d"%k,
                  [(-.218,face*.398,0),(.218,face*.398,0),
                   (.218,face*.425,0),(-.218,face*.425,0)],
                  [s,s+.066],engine,.009)
        for q in (-.115,.115):
            sweep("contained aft energy conduit",
                  [(q-.026,face*.395,0),(q+.026,face*.395,0),
                   (q+.026,face*.414,0),(q-.026,face*.414,0)],
                  [3.20,3.6,4,4.5,5,5.5,6,6.4],
                  engine_dim,.008)
        # Inset thermal panel on the broad outboard ceramic bank.
        sweep("flush radiator cassette",
              [(-.88,face*.500,0),(-.48,face*.500,0),
               (-.48,face*.507,0),(-.88,face*.507,0)],
              [3.9,4.3,4.7,5.2,5.65],black,.015)
        for j in range(9):
            s=4.02+j*.17
            sweep("radiator internal fin",
                  [(-.84,face*.507,0),(-.52,face*.507,0),
                   (-.52,face*.513,0),(-.84,face*.513,0)],
                  [s,s+.034],metal,.003)
    # Ceramic side cheeks leave a narrow exposed structural equator.
    for q in (-1,1):
        sweep("rounded outer side armor",
              [(q*.975,-.28,0),(q*1.012,-.28,0),
               (q*1.012,.28,0),(q*.975,.28,0)],
              full,ceramic2,.038)

    # Maglev cradles and receiver are oriented normal to the short base only.
    def local_box(label,r,y,w,dr,dy,dw,mat,bev=.025):
        vv=[tr(r+a*dr/2,y+b*dy/2,w+c*dw/2)
            for a,b,c in [(-1,-1,-1),(-1,-1,1),(-1,1,1),(-1,1,-1),
                          (1,-1,-1),(1,-1,1),(1,1,1),(1,1,-1)]]
        ff=[(0,3,2,1),(4,5,6,7),(0,1,5,4),(1,2,6,5),
            (2,3,7,6),(3,0,4,7)]
        return mesh_obj(name+" | "+label,vv,ff,mat,bev)

    local_box("recessed hull emitter cradle",cradle_r,1.22,0,
              .20,1.40,.78,black,.095)
    local_box("hull emitter inset",cradle_r+.105,1.22,0,
              .025,1.13,.51,accent,.045)
    local_box("armored floating receiver",1.987,1.22,0,
              .13,1.45,.71,metal,.068)
    local_box("receiver dark inset",1.913,1.22,0,
              .021,1.13,.49,black,.035)
    for w in (-.293,.293):
        local_box("cradle ceramic perimeter",cradle_r+.068,1.22,w,
                  .11,1.28,.095,ceramic2,.034)
        local_box("receiver anodized perimeter",1.956,1.22,w,
                  .085,1.26,.065,accent,.022)
    for y in (.73,1.71):
        local_box("cyan hull pole face",cradle_r+.124,y,0,
                  .014,.060,.43,field,.015)
        local_box("violet receiver pole face",1.899,y,0,
                  .012,.06,.42,violet,.014)

    gap_a=cradle_r+.15
    gap_b=1.887
    # Delicate, interrupted, emissive flux filaments: no mechanical linkage.
    for j in range(5):
        yy=.84+j*.19
        ww=(-1 if j%2 else 1)*.11
        for seg in range(4):
            points=[]
            for k in range(10):
                f=(seg+.12+.68*k/9)/4
                r=gap_a+(gap_b-gap_a)*f
                y=yy+.035*math.sin(f*math.pi*2+j*.8)
                w=ww+.035*math.sin(f*math.pi*2+j)
                points.append(tr(r,y,w))
            line(name+" | luminous flux filament",points,.005,
                 field if j%2 else violet)
    for k in range(2):
        r=gap_a+(gap_b-gap_a)*(.28+.43*k)
        pts=[]
        for j in range(53):
            a=2*math.pi*j/52
            pts.append(tr(r,1.22+.43*math.cos(a),.20*math.sin(a)))
        line(name+" | suspended field contour",pts,.006,
             violet if k else field,True)

    # Small serials are engraved into the root ceramic bank.
    p=wp(.52,-.72,.514)
    # Local text baseline follows the short root, normal faces outward.
    xaxis=u
    yaxis=Vector((0,1,0))
    if xaxis.cross(yaxis).dot(t)<0:
        xaxis=-xaxis
    text_obj(name+" engine identification", "0%d"%(wi+1),
             p,.16,ink,xaxis,yaxis)

# Tiny cabin light illuminates the actual seat, without lighting the exterior.
bpy.ops.object.light_add(type='POINT', location=(0,-2.36,.63))
bpy.context.object.name = "Amber console bounce / contained"
bpy.context.object.data.energy = 2.8
bpy.context.object.data.color = (1,.36,.085)
bpy.context.object.data.shadow_soft_size = .16

# Sparse procedural starfield. This has no giant background mesh to spoil
# the scale or orbit of the exported spacecraft.
world=bpy.data.worlds.new("Deep space / distant sparse stars")
bpy.context.scene.world=world
world.use_nodes=True
nt=world.node_tree
nt.nodes.clear()
out=nt.nodes.new("ShaderNodeOutputWorld")
bg=nt.nodes.new("ShaderNodeBackground")
bg.inputs["Strength"].default_value=.28
tex=nt.nodes.new("ShaderNodeTexCoord")
vor=nt.nodes.new("ShaderNodeTexVoronoi")
vor.voronoi_dimensions='3D'
vor.distance='EUCLIDEAN'
vor.inputs["Scale"].default_value=185
ramp=nt.nodes.new("ShaderNodeValToRGB")
ramp.color_ramp.elements[0].position=.025
ramp.color_ramp.elements[0].color=(.65,.77,1,1)
ramp.color_ramp.elements[1].position=.068
ramp.color_ramp.elements[1].color=(.003,.006,.014,1)
ramp.color_ramp.interpolation='EASE'
nt.links.new(tex.outputs["Normal"],vor.inputs["Vector"])
nt.links.new(vor.outputs["Distance"],ramp.inputs[0])
nt.links.new(ramp.outputs[0],bg.inputs["Color"])
nt.links.new(bg.outputs[0],out.inputs[0])

def area(name,loc,power,color,size,target):
    bpy.ops.object.light_add(type='AREA', location=loc)
    o=bpy.context.object
    o.name=name
    o.data.energy=power
    o.data.color=color
    o.data.shape='DISK'
    o.data.size=size
    o.rotation_euler=(Vector(target)-o.location).to_track_quat('-Z','Y').to_euler()
    return o

area("Key / broad neutral softbox",(-7,-10,13),2300,(.88,.94,1),8,(0,1,0))
area("Front fill / ceramic readability",(9,-7,5),1450,(.73,.84,1),7,(0,1,1))
area("Upper aft rim",(1,9,12),2600,(.65,.80,1),6,(0,2,1))
area("Port edge / restrained violet",(-9,4,3),1500,(.53,.49,1),5,(-1,2,0))
area("Soft underside bounce",(0,-3,-7),800,(.43,.60,.8),7,(0,1,0))

# Frontal three-quarter camera, high enough to read the recessed engine beds,
# but far enough forward to separate the three magnetic attachments.
bpy.ops.object.camera_add(location=(10,-24,14))
cam=bpy.context.object
cam.name="YGG-1 | presentation camera"
target=Vector((0,1.2,1.35))
cam.rotation_euler=(target-cam.location).to_track_quat('-Z','Y').to_euler()
cam.data.type='PERSP'
cam.data.lens=67
cam.data.sensor_width=36
cam.data.clip_start=.1
cam.data.clip_end=1000
bpy.context.scene.camera=cam

scene=bpy.context.scene
scene.render.engine='CYCLES'
scene.cycles.samples=64
scene.cycles.use_denoising=True
scene.render.resolution_x=1536
scene.render.resolution_y=1536
scene.render.resolution_percentage=100
scene.render.image_settings.file_format='PNG'
scene.render.film_transparent=False
scene.render.filepath=os.path.join(OUT,"YGG-1.png")
scene.view_settings.view_transform='AgX'
try:
    scene.view_settings.look='AgX - Medium High Contrast'
except Exception:
    pass
scene.view_settings.exposure=.25

# Subtle optical halation, restricted to the contained high-energy parts.
scene.use_nodes=True
nt=scene.node_tree
nt.nodes.clear()
rl=nt.nodes.new('CompositorNodeRLayers')
gl=nt.nodes.new('CompositorNodeGlare')
gl.glare_type='FOG_GLOW'
gl.quality='HIGH'
gl.threshold=2.0
gl.size=7
gl.mix=-.82
comp=nt.nodes.new('CompositorNodeComposite')
nt.links.new(rl.outputs['Image'],gl.inputs['Image'])
nt.links.new(gl.outputs['Image'],comp.inputs['Image'])

# Keep the file immediately usable and remove selection outlines on opening.
bpy.ops.object.select_all(action='DESELECT')
scene["craft"] = "YGG-1"
scene["role"] = "Passive deep-space survey / interferometry"
scene["architecture"] = "Three independently suspended, swept, integrated propulsion wings"
scene["magnetic_clearance"] = "Empty mechanical gaps; emissive discontinuous flux filaments only"
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,"output.blend"))

# Native Cycles validation image; restore the benchmark's full-quality setup.
scene.render.resolution_x=640
scene.render.resolution_y=640
scene.cycles.samples=24
scene.render.filepath=os.path.join(OUT,"YGG-1_preview.png")
try:
    bpy.ops.render.render(write_still=True)
except Exception as exc:
    print("Preview render:", exc)
scene.render.resolution_x=1536
scene.render.resolution_y=1536
scene.cycles.samples=64
scene.render.filepath=os.path.join(OUT,"YGG-1.png")
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,"output.blend"))
```