"""Run from Blender's Scripting workspace after extracting this complete pack.

Creates a new isolated review scene and saves an editable .blend alongside GLB.
This helper is supplied for Blender users; it was not executed in this session.
"""
from pathlib import Path
import json,math
import bpy
from mathutils import Vector

HERE=Path(__file__).resolve().parent
NAME='PI-BLD-0001-V01_CrownLandmark_SHELL_C01'
spec=json.loads((HERE/'MODEL_SPEC.json').read_text())
scene=bpy.data.scenes.new('Crown Landmark SHELL C01 / CONCEPT')
if bpy.context.window:bpy.context.window.scene=scene
bpy.ops.import_scene.gltf(filepath=str(HERE/'MODEL'/(NAME+'.glb')))
scene.unit_settings.system='METRIC';scene.unit_settings.scale_length=1.0
for label,data in spec['cameras'].items():
    camera=bpy.data.cameras.new('C01_'+label);camera.type='ORTHO';camera.ortho_scale=data['orthographic_vertical_span_m']
    obj=bpy.data.objects.new(camera.name,camera);scene.collection.objects.link(obj)
    obj.location=Vector(data['eye_source_m']);direction=Vector(data['target_source_m'])-obj.location
    obj.rotation_euler=direction.to_track_quat('-Z','Y').to_euler()
    obj['source_frame']='metres Z up, front -Y';obj['status']='C01 candidate camera'
    if label=='elevated':scene.camera=obj
scene['asset_id']=spec['asset_id'];scene['revision']='SHELL C01';scene['status']='CONCEPT; creator/shell/engine acceptance pending'
scene.render.resolution_x=1100;scene.render.resolution_y=1400
bpy.ops.wm.save_as_mainfile(filepath=str(HERE/'MODEL'/(NAME+'.blend')))
print('Saved isolated editable candidate scene. No authoritative world was edited.')
