@volter/editor 0.5.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/BUNDLED_NOTICES +6196 -0
  2. package/LICENSE +686 -0
  3. package/LICENSE-BLENDER +1409 -0
  4. package/LICENSE-MCP +21 -0
  5. package/NOTICE +20 -0
  6. package/dist/.vite/manifest.json +1744 -0
  7. package/dist/assets/AudioViewer-DILwc7Pt.js +1 -0
  8. package/dist/assets/BVHLoader--2mLoe3e.js +1 -0
  9. package/dist/assets/BufferGeometryUtils-oP8-Ve4I.js +1 -0
  10. package/dist/assets/ColladaLoader-CyOCKXko.js +3 -0
  11. package/dist/assets/EntityModelDocument-DVlDQ_IJ.js +1 -0
  12. package/dist/assets/EnvironmentAssetDocument-BVGDJjW4.js +5 -0
  13. package/dist/assets/FBXLoader-DzWtiWYm.js +1 -0
  14. package/dist/assets/GameplaySessionTimeline-X_nMT8Sa.js +142 -0
  15. package/dist/assets/ImageViewer-D-aZoyr1.js +1 -0
  16. package/dist/assets/InspectorCanvasPreview-CLDhscy0.js +1 -0
  17. package/dist/assets/InspectorObjectPreview-CpHEw6QH.js +1 -0
  18. package/dist/assets/JsonAssetDocument-CLVN1V9Z.js +3 -0
  19. package/dist/assets/LineSegments2-vfeDUBfs.js +370 -0
  20. package/dist/assets/MTLLoader-D8SKGOsv.js +2 -0
  21. package/dist/assets/ModelAssetDocument-C60lQ11c.js +1 -0
  22. package/dist/assets/NonThreeAuthoringBootstrap-D8oHDftw.js +2 -0
  23. package/dist/assets/OBJLoader-8SrBLZ7J.js +5 -0
  24. package/dist/assets/Object3DPreview-CSmLPKkk.js +2 -0
  25. package/dist/assets/OnlineAssetDetail-D8wVVoay.js +2 -0
  26. package/dist/assets/OrbitControls-BHxt84w6.js +1 -0
  27. package/dist/assets/PLYLoader-BXUWXVtV.js +2 -0
  28. package/dist/assets/RectAreaLightUniformsLib-BGT7Bu4n.js +1 -0
  29. package/dist/assets/STLLoader-U-3fQm8v.js +1 -0
  30. package/dist/assets/SourceAssetViewer-BcOCJ2ye.js +13 -0
  31. package/dist/assets/StageHost-B_YrFNiC.js +1126 -0
  32. package/dist/assets/TDSLoader-BtiaQ4S3.js +1 -0
  33. package/dist/assets/ToolObject3DPreview-Crowr7IN.js +1 -0
  34. package/dist/assets/TransientHint-GNwuzA4c.js +1 -0
  35. package/dist/assets/VideoViewer-CjQ4P9AJ.js +1 -0
  36. package/dist/assets/_commonjsHelpers-D6-XlEtG.js +1 -0
  37. package/dist/assets/agx-base-srgb-BjWZJgrZ.lut +0 -0
  38. package/dist/assets/agx-look-medium-high-contrast-D5F_ob1L.lut +0 -0
  39. package/dist/assets/agx-look-punchy-dxsnycNs.lut +0 -0
  40. package/dist/assets/asset-editor-persistence-D3Yy77wZ.js +1 -0
  41. package/dist/assets/blender-emscripten-engine-C_uFxIuO.js +2 -0
  42. package/dist/assets/blender-node-editor.document-BfvoBocD.js +1 -0
  43. package/dist/assets/blender-outliner-model-B8b00oxr.js +1 -0
  44. package/dist/assets/blender-properties-tab-0M780SHF.js +3 -0
  45. package/dist/assets/blender-runtime-host-D8NHsAfD.js +4 -0
  46. package/dist/assets/blender-runtime-skin-DcwXD-m8.js +61 -0
  47. package/dist/assets/blender-runtime.document-BixTvrw8.js +7 -0
  48. package/dist/assets/blender-timeline.document-RtHIpbT1.js +1 -0
  49. package/dist/assets/blender-uv-editor.document-ChwaS3BG.js +1 -0
  50. package/dist/assets/blender-version.status-Bnhf8h1I.js +1 -0
  51. package/dist/assets/blender-wali-engine-C7bet0ss.js +2 -0
  52. package/dist/assets/blender.command-BCCEp0kb.js +1 -0
  53. package/dist/assets/blender.keymap-GAQgeklK.js +1 -0
  54. package/dist/assets/blender.status-ujwGU6dU.js +1 -0
  55. package/dist/assets/blender.style-Dcem5f_T.js +1 -0
  56. package/dist/assets/browserAll-Do0ehj3Q.js +14 -0
  57. package/dist/assets/client-DNXj_opT.js +25 -0
  58. package/dist/assets/clip-planes-CnAI6DZn.js +1 -0
  59. package/dist/assets/edit-mode-authoring-BX4IRQq9.js +1 -0
  60. package/dist/assets/editor-presentation-activity-C7SNSmTd.js +1 -0
  61. package/dist/assets/events-156d8d12.esm-Dy_KXdhT.js +36 -0
  62. package/dist/assets/fflate.module-DPuTF8aG.js +6 -0
  63. package/dist/assets/filmic-srgb-Ct35FIH6.lut +0 -0
  64. package/dist/assets/hosted-asset-materialization-BK7DHisS.js +2 -0
  65. package/dist/assets/index-5av5LJja.js +1691 -0
  66. package/dist/assets/index-BP6wv2A0.js +5 -0
  67. package/dist/assets/index-Bge9JUr6.js +1 -0
  68. package/dist/assets/index-BncK9THk.js +1 -0
  69. package/dist/assets/index-C5UECeSr.js +952 -0
  70. package/dist/assets/index-CJbYy-CF.js +3 -0
  71. package/dist/assets/index-CanA16PU.js +2 -0
  72. package/dist/assets/index-CinJrH5C.js +9 -0
  73. package/dist/assets/index-Cl83EGRl.js +2 -0
  74. package/dist/assets/index-CtzuWnCS.js +1 -0
  75. package/dist/assets/index-D2LwEE0L.js +562 -0
  76. package/dist/assets/index-D2fNXpHa.css +1 -0
  77. package/dist/assets/index-DUqP1RMl.js +1 -0
  78. package/dist/assets/index-D_NuPfjr.js +9 -0
  79. package/dist/assets/index-DaQZGF7d.js +1 -0
  80. package/dist/assets/index-DgapqSPi.js +7 -0
  81. package/dist/assets/index-IEjydI9d.js +1 -0
  82. package/dist/assets/index-gHZae-lw.js +13 -0
  83. package/dist/assets/jsx-runtime-DPjLkJKQ.js +9 -0
  84. package/dist/assets/model.layout-BJUEQYUI.js +1 -0
  85. package/dist/assets/models.finder-Bm1YfG95.js +1 -0
  86. package/dist/assets/product-Ywxte8eQ.js +1 -0
  87. package/dist/assets/properties-bone-constraints.inspector-Ck0Hzlvr.js +1 -0
  88. package/dist/assets/properties-bone.inspector-B8M42o0V.js +1 -0
  89. package/dist/assets/properties-collection.inspector-D-RSO5zy.js +1 -0
  90. package/dist/assets/properties-constraints.inspector-DbJa57oa.js +1 -0
  91. package/dist/assets/properties-data.inspector-DLgjbRW6.js +1 -0
  92. package/dist/assets/properties-material.inspector-B11LZYDW.js +1 -0
  93. package/dist/assets/properties-modifiers.inspector-BCWwuA26.js +1 -0
  94. package/dist/assets/properties-object.inspector-UZVJG49S.js +1 -0
  95. package/dist/assets/properties-output.inspector-XOwcBits.js +1 -0
  96. package/dist/assets/properties-particles.inspector-By04vT7R.js +1 -0
  97. package/dist/assets/properties-physics.inspector-D3T7FLdg.js +1 -0
  98. package/dist/assets/properties-render.inspector-Y0Rjr9gZ.js +1 -0
  99. package/dist/assets/properties-scene.inspector-CfyDWB4W.js +1 -0
  100. package/dist/assets/properties-texture.inspector-AFRsJx6-.js +1 -0
  101. package/dist/assets/properties-view-layer.inspector-Co07LAmQ.js +1 -0
  102. package/dist/assets/properties-world.inspector-C7T4JocI.js +1 -0
  103. package/dist/assets/react-18-DyywM-Z2.js +1 -0
  104. package/dist/assets/react-story-board-vrmj74Ng.js +1 -0
  105. package/dist/assets/react-three-rapier.esm-D874pLFD.js +1 -0
  106. package/dist/assets/sculpt.layout-zJF55yCR.js +1 -0
  107. package/dist/assets/session-1bPxsLdy.js +4167 -0
  108. package/dist/assets/shading.layout-DULYZV6M.js +1 -0
  109. package/dist/assets/sky-precompute-worker-ChN7J87v.js +1 -0
  110. package/dist/assets/spark.module-D1CUMLYS.js +12120 -0
  111. package/dist/assets/stage-keyboard-Cx90EYIT.js +1 -0
  112. package/dist/assets/stage-overlay-set-duu3P0mZ.js +1 -0
  113. package/dist/assets/stage-presence-markers-DKH3p_ao.js +1 -0
  114. package/dist/assets/story-capture-Dqurwlhr.js +1 -0
  115. package/dist/assets/story-mount-turn-2IYGgHob.js +1 -0
  116. package/dist/assets/story-pixi-preview-c78Aygdi.js +1 -0
  117. package/dist/assets/story-three-preview-CbZo5B3D.js +2 -0
  118. package/dist/assets/texture.layout-DASpHVht.js +1 -0
  119. package/dist/assets/three.module-BynznMJN.js +3840 -0
  120. package/dist/assets/uv-editing.layout-BEKHxmHw.js +1 -0
  121. package/dist/assets/vgai-shared-fontawesome-CFSkqz69.js +1 -0
  122. package/dist/assets/vgai-shared-jsx-dev-runtime-VfxIYu0y.js +9 -0
  123. package/dist/assets/vgai-shared-jsx-runtime-DIqBpTut.js +1 -0
  124. package/dist/assets/vgai-shared-react-DL5U9FnC.js +1 -0
  125. package/dist/assets/vgai-shared-react-dom-DFajMqMT.js +1 -0
  126. package/dist/assets/vgai-shared-react-dom-client-S0ozfl6_.js +1 -0
  127. package/dist/assets/vgai-shared-three-BWkbSQ3V.js +1 -0
  128. package/dist/assets/viewport-pick-context-DkawXbEi.js +1 -0
  129. package/dist/assets/webworkerAll-iMzrvNir.js +101 -0
  130. package/dist/assets/worker-DTgfRRas.js +1 -0
  131. package/dist/assets/world-documents-CGbrcsYk.js +3 -0
  132. package/dist/vgai-shared-react.json +10 -0
  133. package/dist/vgai-shared-three.json +3 -0
  134. package/dist-node/cli.js +17823 -0
  135. package/dist-node/create.js +14084 -0
  136. package/package.json +56 -0
  137. package/presets.mjs +2 -0
  138. package/src/contributions.d.ts +4 -0
  139. package/src/index.ts +9 -0
  140. package/starter/cube.blend +0 -0
  141. package/starter/cube.py +81 -0
@@ -0,0 +1 @@
1
+ import{z as M,aI as f,I as A,aB as p,aF as u,Z as x,aR as m,aa as b,a0 as C,aC as c,x as g,aL as T,d as _}from"./three.module-BynznMJN.js";class ce extends M{constructor(t){super(t),this.debug=!1,this.group=null,this.materials=[],this.meshes=[]}load(t,s,e,a){const r=this,n=this.path===""?f.extractUrlBase(t):this.path,i=new A(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,function(o){try{s(r.parse(o,n))}catch(d){a?a(d):console.error(d),r.manager.itemError(t)}},e,a)}parse(t,s){this.group=new p,this.materials=[],this.meshes=[],this.readFile(t,s);for(let e=0;e<this.meshes.length;e++)this.group.add(this.meshes[e]);return this.group}readFile(t,s){const e=new DataView(t),a=new h(e,0,this.debugMessage);if(a.id===E||a.id===I||a.id===F){let r=a.readChunk();for(;r;){if(r.id===w){const n=r.readDWord();this.debugMessage("3DS file version: "+n)}else r.id===P?this.readMeshData(r,s):this.debugMessage("Unknown main chunk: "+r.hexId);r=a.readChunk()}}this.debugMessage("Parsed "+this.meshes.length+" meshes")}readMeshData(t,s){let e=t.readChunk();for(;e;){if(e.id===N){const a=+e.readDWord();this.debugMessage("Mesh Version: "+a)}else if(e.id===B){const a=e.readFloat();this.debugMessage("Master scale: "+a),this.group.scale.set(a,a,a)}else e.id===ae?(this.debugMessage("Named Object"),this.readNamedObject(e)):e.id===U?(this.debugMessage("Material"),this.readMaterialEntry(e,s)):this.debugMessage("Unknown MDATA chunk: "+e.hexId);e=t.readChunk()}}readNamedObject(t){const s=t.readString();let e=t.readChunk();for(;e;){if(e.id===ie){const a=this.readMesh(e);a.name=s,this.meshes.push(a)}else this.debugMessage("Unknown named object chunk: "+e.hexId);e=t.readChunk()}}readMaterialEntry(t,s){let e=t.readChunk();const a=new u;for(;e;){if(e.id===L)a.name=e.readString(),this.debugMessage(" Name: "+a.name);else if(e.id===X)this.debugMessage(" Wireframe"),a.wireframe=!0;else if(e.id===j){const r=e.readByte();a.wireframeLinewidth=r,this.debugMessage(" Wireframe Thickness: "+r)}else if(e.id===Y)a.side=x,this.debugMessage(" DoubleSided");else if(e.id===z)this.debugMessage(" Additive Blending"),a.blending=m;else if(e.id===v)this.debugMessage(" Diffuse Color"),a.color=this.readColor(e);else if(e.id===G)this.debugMessage(" Specular Color"),a.specular=this.readColor(e);else if(e.id===W)this.debugMessage(" Ambient color"),a.color=this.readColor(e);else if(e.id===V){const r=this.readPercentage(e);a.shininess=r*100,this.debugMessage(" Shininess : "+r)}else if(e.id===H){const r=this.readPercentage(e);a.opacity=1-r,this.debugMessage(" Transparency : "+r),a.transparent=a.opacity<1}else e.id===q?(this.debugMessage(" ColorMap"),a.map=this.readMap(e,s)):e.id===Z?(this.debugMessage(" BumpMap"),a.bumpMap=this.readMap(e,s)):e.id===J?(this.debugMessage(" OpacityMap"),a.alphaMap=this.readMap(e,s)):e.id===K?(this.debugMessage(" SpecularMap"),a.specularMap=this.readMap(e,s)):this.debugMessage(" Unknown material chunk: "+e.hexId);e=t.readChunk()}this.materials[a.name]=a}readMesh(t){let s=t.readChunk();const e=new b,a=new u,r=new C(e,a);for(r.name="mesh";s;){if(s.id===re){const n=s.readWord();this.debugMessage(" Vertex: "+n);const i=[];for(let o=0;o<n;o++)i.push(s.readFloat()),i.push(s.readFloat()),i.push(s.readFloat());e.setAttribute("position",new c(i,3))}else if(s.id===ne)this.readFaceArray(s,r);else if(s.id===de){const n=s.readWord();this.debugMessage(" UV: "+n);const i=[];for(let o=0;o<n;o++)i.push(s.readFloat()),i.push(s.readFloat());e.setAttribute("uv",new c(i,2))}else if(s.id===he){this.debugMessage(" Transformation Matrix (TODO)");const n=[];for(let d=0;d<12;d++)n[d]=s.readFloat();const i=new g;i.elements[0]=n[0],i.elements[1]=n[6],i.elements[2]=n[3],i.elements[3]=n[9],i.elements[4]=n[2],i.elements[5]=n[8],i.elements[6]=n[5],i.elements[7]=n[11],i.elements[8]=n[1],i.elements[9]=n[7],i.elements[10]=n[4],i.elements[11]=n[10],i.elements[12]=0,i.elements[13]=0,i.elements[14]=0,i.elements[15]=1,i.transpose();const o=new g;o.copy(i).invert(),e.applyMatrix4(o),i.decompose(r.position,r.quaternion,r.scale)}else this.debugMessage(" Unknown mesh chunk: "+s.hexId);s=t.readChunk()}return e.computeVertexNormals(),r}readFaceArray(t,s){const e=t.readWord();this.debugMessage(" Faces: "+e);const a=[];for(let i=0;i<e;++i)a.push(t.readWord(),t.readWord(),t.readWord()),t.readWord();s.geometry.setIndex(a);let r=0,n=0;for(;!t.endOfChunk;){const i=t.readChunk();if(i.id===oe){this.debugMessage(" Material Group");const o=this.readMaterialGroup(i),d=o.index.length*3;s.geometry.addGroup(n,d,r),n+=d,r++;const l=this.materials[o.name];Array.isArray(s.material)===!1&&(s.material=[]),l!==void 0&&s.material.push(l)}else this.debugMessage(" Unknown face array chunk: "+i.hexId)}s.material.length===1&&(s.material=s.material[0])}readMap(t,s){let e=t.readChunk(),a={};const r=new T(this.manager);for(r.setPath(this.resourcePath||s).setCrossOrigin(this.crossOrigin);e;){if(e.id===Q){const n=e.readString();a=r.load(n),this.debugMessage(" File: "+s+n)}else e.id===se?(a.offset.x=e.readFloat(),this.debugMessage(" OffsetX: "+a.offset.x)):e.id===te?(a.offset.y=e.readFloat(),this.debugMessage(" OffsetY: "+a.offset.y)):e.id===$?(a.repeat.x=e.readFloat(),this.debugMessage(" RepeatX: "+a.repeat.x)):e.id===ee?(a.repeat.y=e.readFloat(),this.debugMessage(" RepeatY: "+a.repeat.y)):this.debugMessage(" Unknown map chunk: "+e.hexId);e=t.readChunk()}return a}readMaterialGroup(t){const s=t.readString(),e=t.readWord();this.debugMessage(" Name: "+s),this.debugMessage(" Faces: "+e);const a=[];for(let r=0;r<e;++r)a.push(t.readWord());return{name:s,index:a}}readColor(t){const s=t.readChunk(),e=new _;if(s.id===y||s.id===O){const a=s.readByte(),r=s.readByte(),n=s.readByte();e.setRGB(a/255,r/255,n/255),this.debugMessage(" Color: "+e.r+", "+e.g+", "+e.b)}else if(s.id===S||s.id===k){const a=s.readFloat(),r=s.readFloat(),n=s.readFloat();e.setRGB(a,r,n),this.debugMessage(" Color: "+e.r+", "+e.g+", "+e.b)}else this.debugMessage(" Unknown color chunk: "+s.hexId);return e}readPercentage(t){const s=t.readChunk();switch(s.id){case R:return s.readShort()/100;case D:return s.readFloat();default:return this.debugMessage(" Unknown percentage chunk: "+s.hexId),0}}debugMessage(t){this.debug&&console.log(t)}}class h{constructor(t,s,e){this.data=t,this.offset=s,this.position=s,this.debugMessage=e,this.debugMessage instanceof Function&&(this.debugMessage=function(){}),this.id=this.readWord(),this.size=this.readDWord(),this.end=this.offset+this.size,this.end>t.byteLength&&this.debugMessage("Bad chunk size for chunk at "+s)}readChunk(){if(this.endOfChunk)return null;try{const t=new h(this.data,this.position,this.debugMessage);return this.position+=t.size,t}catch{return this.debugMessage("Unable to read chunk at "+this.position),null}}get hexId(){return this.id.toString(16)}get endOfChunk(){return this.position>=this.end}readByte(){const t=this.data.getUint8(this.position,!0);return this.position+=1,t}readFloat(){try{const t=this.data.getFloat32(this.position,!0);return this.position+=4,t}catch(t){return this.debugMessage(t+" "+this.position+" "+this.data.byteLength),0}}readInt(){const t=this.data.getInt32(this.position,!0);return this.position+=4,t}readShort(){const t=this.data.getInt16(this.position,!0);return this.position+=2,t}readDWord(){const t=this.data.getUint32(this.position,!0);return this.position+=4,t}readWord(){const t=this.data.getUint16(this.position,!0);return this.position+=2,t}readString(){let t="",s=this.readByte();for(;s;)t+=String.fromCharCode(s),s=this.readByte();return t}}const F=19789,E=15786,I=49725,w=2,S=16,y=17,O=18,k=19,R=48,D=49,P=15677,N=15678,B=256,U=45055,L=40960,W=40976,v=40992,G=41008,V=41024,H=41040,Y=41089,z=41091,X=41093,j=41095,q=41472,J=41488,Z=41520,K=41476,Q=41728,$=41812,ee=41814,se=41816,te=41818,ae=16384,ie=16640,re=16656,ne=16672,oe=16688,de=16704,he=16736;export{ce as TDSLoader};
@@ -0,0 +1 @@
1
+ import{a as o}from"./jsx-runtime-DPjLkJKQ.js";import{Object3DPreview as d}from"./Object3DPreview-CSmLPKkk.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-5av5LJja.js";import"./index-DaQZGF7d.js";import"./index-D_NuPfjr.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";import"./OrbitControls-BHxt84w6.js";import"./editor-presentation-activity-C7SNSmTd.js";function F({build:r,displayName:e="Object3D preview",height:m=360,background:p,showSkeleton:s=!1,cameraDirection:n,showGrid:c,useDefaultLighting:u,exposure:a,setupPreview:t,active:j=!0}){const i=t!==void 0;return o.jsx("div",{style:{width:"100%",height:m,minHeight:240},children:o.jsx(d,{sourceFactory:r,displayName:e,active:j,showSkeleton:s,background:p,cameraDirection:n,showGrid:c??!i,useDefaultLighting:u??!i,exposure:a,setupPreview:t})})}export{F as ToolObject3DPreview};
@@ -0,0 +1 @@
1
+ import{a}from"./jsx-runtime-DPjLkJKQ.js";import{r as i}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{E as s,F as n,G as o,t,H as r}from"./index-5av5LJja.js";import"./index-D2LwEE0L.js";function x(){const e=i.useSyncExternalStore(s,n,n);return e?a.jsx("div",{role:"status","aria-live":"polite","data-testid":"transient-hint",style:{position:"absolute",left:"50%",bottom:r[6],transform:"translateX(-50%)",maxWidth:"min(440px, 80%)",padding:`${r[3]}px ${r[5]}px`,borderRadius:t.shape.medium,border:`1px solid ${t.boundary.strong}`,background:t.surface.overlay,color:t.content.primary,fontSize:"var(--vgai-font-base)",lineHeight:1.4,textAlign:"center",pointerEvents:"none",zIndex:o.toast},children:e.message},e.id):null}export{x as T};
@@ -0,0 +1 @@
1
+ import{a as t}from"./jsx-runtime-DPjLkJKQ.js";import{r}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{T as c,q as x}from"./index-5av5LJja.js";import"./index-D2LwEE0L.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";function W({assetPath:s}){const[p,a]=r.useState(!1),[d,m]=r.useState(null),i=s;r.useEffect(()=>{a(!1)},[i]);const n=s.split("/").pop()??s,l=r.useCallback(e=>{if(e){if(e.error){a(!0);return}e.videoWidth<=0||m(o=>o&&o.w===e.videoWidth&&o.h===e.videoHeight?o:{w:e.videoWidth,h:e.videoHeight})}},[]);return t.jsxs("div",{"data-testid":"video-asset-document",style:{height:"100%",minHeight:240,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px"},children:[t.jsx(c,{tone:"dim",variant:"label",children:n}),d&&t.jsxs(c,{tone:"muted",variant:"code",children:[d.w," × ",d.h]})]}),t.jsx("div",{className:"vgai-asset-transparency-well",style:{flex:1,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center",padding:12},children:p?t.jsxs("div",{style:{color:x[2],fontSize:12,textAlign:"center"},children:[n," could not be played from ",i,". The file may be missing, or its codec may not be one this browser decodes."]}):t.jsx("video",{src:i,controls:!0,playsInline:!0,preload:"metadata",ref:l,onError:()=>a(!0),onLoadedMetadata:e=>l(e.currentTarget),style:{maxWidth:"100%",maxHeight:"100%",display:"block"}},i)})]})}export{W as VideoViewer};
@@ -0,0 +1 @@
1
+ var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var r=e.default;if(typeof r=="function"){var t=function o(){return this instanceof o?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}),t}export{l as a,u as c,f as g};
@@ -0,0 +1 @@
1
+ import{f as v,r as h,h as g,w as l,i as m,j as k}from"./index-5av5LJja.js";const p=new WeakMap;function w(e){typeof window>"u"||(window.dispatchEvent(new CustomEvent("editor:assets-changed",{detail:{paths:[u(e)]}})),window.dispatchEvent(new CustomEvent("editor:asset-mutation",{detail:{type:"change",paths:[u(e)]}})))}function b(e,a){const s=u(a);let n=p.get(e);n||(n=new Map,p.set(e,n));const t=n.get(s);if(t)return t;const d=e.registry.registerProject("project-file",`.vgai/history/imported-assets/${s}`,s.split("/").pop()),r={revision:0,driver:void 0},o=async()=>{const i=await m(s),c=new TextEncoder().encode(i);return{revision:r.revision,contentType:"application/vnd.vgai.asset-history-token",bytes:c,sha256:await k(c)}};return r.driver={descriptor:d,capture:o,preflight:async i=>{const c=await o();return c.sha256===i.sha256?{ok:!0}:{ok:!1,reason:"content-conflict",actualRevision:r.revision,actualSha256:c.sha256}},restore:async i=>{const c=new TextDecoder().decode(e.snapshots.read(i).bytes);await h(s,c),r.revision++,w(s)},estimateBytes:i=>i.byteLength},e.registerDriver(r.driver),n.set(s,r),r}function f(e){return new TextEncoder().encode(e)}async function j(e,a){if(e.length===0)return;const s=l();if(!s)return;const n=e.map(t=>({entry:t,resource:b(s,t.assetPath)}));try{await s.recordAppliedTransaction({label:a,detail:e.map(t=>u(t.assetPath)).join(", "),resources:n.map(({resource:t})=>t.driver.descriptor.key),scope:"project"},n.map(({entry:t,resource:d})=>({resource:d.driver.descriptor.key,beforeBytes:f(t.beforeToken),afterBytes:f(t.afterToken),contentType:"application/vnd.vgai.asset-history-token"})))}catch(t){const d=await Promise.allSettled(e.map(o=>h(o.assetPath,o.beforeToken)));for(const o of e)w(o.assetPath);const r=d.find(o=>o.status==="rejected");throw r?.status==="rejected"?new Error(`Project history could not record undo/redo and rollback failed: ${r.reason instanceof Error?r.reason.message:String(r.reason)}`):new Error(`Assets were rolled back because project history could not record undo/redo: ${t instanceof Error?t.message:String(t)}`)}}async function E(e,a=`Import ${e.name}`){const s=await v(e);return s.ok&&s.history&&await j([s.history],a),s}function u(e){const a=e.split(/[?#]/,1)[0].replace(/^\/+/,"");if(!a)throw new Error("Project asset path cannot be empty.");return a}function P(e,a){const s=l(),n=u(e);let t=!1;const d=()=>{t||(t=!0,queueMicrotask(()=>{t=!1,a()}))},r=s?g(s).subscribeAll(i=>{i===n&&d()}):()=>{},o=i=>{const c=i.detail?.paths;(!c||c.some(y=>u(y)===n))&&d()};return typeof window<"u"&&window.addEventListener("editor:assets-changed",o),()=>{r(),typeof window<"u"&&window.removeEventListener("editor:assets-changed",o)}}export{E as d,P as s};
@@ -0,0 +1,2 @@
1
+ import{b as m,a as h,S as c,P as E,s as w,o as F}from"./worker-DTgfRRas.js";import{s as O}from"./session-1bPxsLdy.js";async function g(o){const s=await fetch(o);if(!s.ok)throw new Error(`${o}: HTTP ${s.status}`);const e=await s.text(),t={exports:{}},l=new Function("module","exports","define",`${e}
2
+ return typeof createBlenderModule === 'function' ? createBlenderModule : module.exports;`)(t,t.exports,void 0);if(typeof l!="function")throw new Error("blender_browser.js did not produce a module factory");return l}const R=new TextEncoder;function T(o,s){let e="";for(const t of s.split("/").filter(Boolean))o.FS_createPath(e||"/",t,!0,!0),e+=`/${t}`}function P(o){const s=o.FS;return{readFile:async e=>s.readFile(e),writeFile:async(e,t)=>s.writeFile(e,t),mkdirTree:async e=>s.mkdirTree(e),readdir:async e=>s.readdir(e),stat:async e=>{let t;try{t=s.stat(e)}catch{return null}const i=t.mtime;return{size:t.size,mode:t.mode??0,mtimeMs:typeof i=="number"?i:i?.getTime()??0}},unlink:async e=>s.unlink(e)}}async function A(o,s){if(!self.crossOriginIsolated)throw new Error("Headless Blender needs SharedArrayBuffer, so the editor page has to be cross-origin isolated (Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy on every response). This worker reports crossOriginIsolated=false.");const e=m("blender_browser.js"),t=await g(e),i=performance.now();let l=null;const d=(r,n)=>{n.startsWith("@@VGAI-READY ")&&(l=n.slice(13)),o.log(n.startsWith("@@VGAI-WARN")||n.startsWith("@@VGAI-ERROR")?"error":"log",n)},a=await t({arguments:["--background","--factory-startup","--python",h],locateFile:r=>m(r),mainScriptUrlOrBlob:e,print:r=>d("log",r),printErr:r=>d("error",r),preRun:[r=>{r.ENV??={},Object.assign(r.ENV,{BLENDER_SYSTEM_RESOURCES:"/bw",BLENDER_SYSTEM_PYTHON:"/bw/python",BLENDER_SYSTEM_SCRIPTS:"/bw/scripts",BLENDER_SYSTEM_DATAFILES:"/bw/datafiles",VGAI_SESSION_ROOT:c,HOME:"/root",TMPDIR:"/tmp"});for(const n of["/tmp","/root","/work",c,...E,o.project])T(r,n);r.FS_createDataFile(c,"session.py",R.encode(O),!0,!0,!0)}]});for(;l===null;)await w(5);const S=performance.now()-i,b=JSON.parse(l);let f=null;if(typeof a.releasePreloadedFileData=="function"){const r=a.releasePreloadedFileData();f=r.bytes,o.log("log",`blender: released the preloaded ${(r.bytes/1048576).toFixed(0)} MB payload (${r.files} files); WasmFS already holds it`)}else o.log("error","blender: this bundle has no releasePreloadedFileData, so the ~55 MB packed .data payload stays resident beside the copy WasmFS made of it — relink with the recipe's --post-js (recipe/release-preloaded-file-data.js).");const u=a.FS;let p="";for(const r of`${o.project}`.split("/").filter(Boolean)){p+=`/${r}`;try{u.chmod(p,511)}catch{}}for(const r of["/work","/tmp","/root",c,...E])try{u.chmod(r,511)}catch{}const y=P(a),{request:_}=F(y,o);return{skew:"emscripten",banner:b,files:y,request:_,readArena:async()=>a.HEAPU8.subarray(a._blender_web_export_buffer(),a._blender_web_export_buffer()+a._blender_web_export_buffer_size()),bootMs:S,memoryBytes:()=>a.HEAPU8.length,releasedPayloadBytes:f}}export{A as startEmscriptenBlenderEngine};
@@ -0,0 +1 @@
1
+ import{a as i}from"./jsx-runtime-DPjLkJKQ.js";import{ah as Ce}from"./index-5av5LJja.js";import{r as T}from"./index-DaQZGF7d.js";import{s as Te,e as Q,f as Ee,n as ee,g as B,i as U,r as we,j as Oe,k as Ie,N as Ne}from"./blender-runtime-host-D8NHsAfD.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D_NuPfjr.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";import"./clip-planes-CnAI6DZn.js";const Re={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"Factor",identifier:"Fac"},{kind:"input",name:"Type"},{kind:"input",name:"Lift",identifier:"Base Lift"},{kind:"input",name:"Lift",identifier:"Color Lift"},{kind:"input",name:"Gamma",identifier:"Base Gamma"},{kind:"input",name:"Gamma",identifier:"Color Gamma"},{kind:"input",name:"Gain",identifier:"Base Gain"},{kind:"input",name:"Gain",identifier:"Color Gain"},{kind:"input",name:"Offset",identifier:"Base Offset"},{kind:"input",name:"Offset",identifier:"Color Offset"},{kind:"input",name:"Power",identifier:"Base Power"},{kind:"input",name:"Power",identifier:"Color Power"},{kind:"input",name:"Slope",identifier:"Base Slope"},{kind:"input",name:"Slope",identifier:"Color Slope"},{kind:"panel",name:"Input",items:[{kind:"input",name:"Temperature",identifier:"Input Temperature"},{kind:"input",name:"Tint",identifier:"Input Tint"},{kind:"layout"}]},{kind:"panel",name:"Output",items:[{kind:"input",name:"Temperature",identifier:"Output Temperature"},{kind:"input",name:"Tint",identifier:"Output Tint"},{kind:"layout"}]}]},Pe={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"Mask"},{kind:"panel",name:"Master",items:[{kind:"input",name:"Saturation",identifier:"Master Saturation"},{kind:"input",name:"Contrast",identifier:"Master Contrast"},{kind:"input",name:"Gamma",identifier:"Master Gamma"},{kind:"input",name:"Gain",identifier:"Master Gain"},{kind:"input",name:"Offset",identifier:"Master Offset"}],defaultClosed:!0},{kind:"panel",name:"Highlights",items:[{kind:"input",name:"Saturation",identifier:"Highlights Saturation"},{kind:"input",name:"Contrast",identifier:"Highlights Contrast"},{kind:"input",name:"Gamma",identifier:"Highlights Gamma"},{kind:"input",name:"Gain",identifier:"Highlights Gain"},{kind:"input",name:"Offset",identifier:"Highlights Offset"}],defaultClosed:!0},{kind:"panel",name:"Midtones",items:[{kind:"input",name:"Saturation",identifier:"Midtones Saturation"},{kind:"input",name:"Contrast",identifier:"Midtones Contrast"},{kind:"input",name:"Gamma",identifier:"Midtones Gamma"},{kind:"input",name:"Gain",identifier:"Midtones Gain"},{kind:"input",name:"Offset",identifier:"Midtones Offset"}],defaultClosed:!0},{kind:"panel",name:"Shadows",items:[{kind:"input",name:"Saturation",identifier:"Shadows Saturation"},{kind:"input",name:"Contrast",identifier:"Shadows Contrast"},{kind:"input",name:"Gamma",identifier:"Shadows Gamma"},{kind:"input",name:"Gain",identifier:"Shadows Gain"},{kind:"input",name:"Offset",identifier:"Shadows Offset"}],defaultClosed:!0},{kind:"panel",name:"Tonal Range",items:[{kind:"input",name:"Midtones Start"},{kind:"input",name:"Midtones End"}],defaultClosed:!0},{kind:"panel",name:"Channels",items:[{kind:"input",name:"Red",identifier:"Apply On Red"},{kind:"input",name:"Green",identifier:"Apply On Green"},{kind:"input",name:"Blue",identifier:"Apply On Blue"}],defaultClosed:!0}]},_e={customSocketOrder:!0,items:[{kind:"output",name:"Image"},{kind:"input",name:"Image"},{kind:"input",name:"Factor",identifier:"Fac"},{kind:"input",name:"Spill Channel"},{kind:"input",name:"Limit Method"},{kind:"input",name:"Limit Channel"},{kind:"input",name:"Limit Strength"},{kind:"panel",name:"Spill Strength",items:[{kind:"input",name:"Use Spill Strength",panelToggle:!0},{kind:"input",name:"Strength",identifier:"Spill Strength"}],defaultClosed:!0}]},Me={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"output",name:"Plane"},{kind:"input",name:"Upper Left"},{kind:"input",name:"Upper Right"},{kind:"input",name:"Lower Left"},{kind:"input",name:"Lower Right"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},ve={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"Samples"},{kind:"input",name:"Center"},{kind:"input",name:"Rotation"},{kind:"input",name:"Scale"},{kind:"panel",name:"Translation",items:[{kind:"input",name:"Amount",identifier:"Translation Amount"},{kind:"input",name:"Direction",identifier:"Translation Direction"}]}]},Ae={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"Displacement"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},be={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"output",name:"Glare"},{kind:"output",name:"Highlights"},{kind:"input",name:"Type"},{kind:"input",name:"Quality"},{kind:"panel",name:"Highlights",items:[{kind:"input",name:"Threshold",identifier:"Highlights Threshold"},{kind:"input",name:"Smoothness",identifier:"Highlights Smoothness"},{kind:"panel",name:"Clamp",items:[{kind:"input",name:"Clamp",identifier:"Clamp Highlights",panelToggle:!0},{kind:"input",name:"Maximum",identifier:"Maximum Highlights"}],defaultClosed:!0}],defaultClosed:!0},{kind:"panel",name:"Adjust",items:[{kind:"input",name:"Strength"},{kind:"input",name:"Saturation"},{kind:"input",name:"Tint"}]},{kind:"panel",name:"Glare",items:[{kind:"input",name:"Size"},{kind:"input",name:"Streaks"},{kind:"input",name:"Streaks Angle"},{kind:"input",name:"Iterations"},{kind:"input",name:"Fade"},{kind:"input",name:"Color Modulation"},{kind:"input",name:"Diagonal",identifier:"Diagonal Star"},{kind:"input",name:"Sun Position"},{kind:"input",name:"Jitter"},{kind:"input",name:"Kernel Data Type"},{kind:"input",name:"Kernel",identifier:"Float Kernel"},{kind:"input",name:"Kernel",identifier:"Color Kernel"}]}]},De={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"output",name:"Matte"},{kind:"output",name:"Edges"},{kind:"input",name:"Key Color"},{kind:"panel",name:"Preprocess",items:[{kind:"input",name:"Blur Size",identifier:"Preprocess Blur Size"}],defaultClosed:!0},{kind:"panel",name:"Key",items:[{kind:"input",name:"Balance",identifier:"Key Balance"}],defaultClosed:!0},{kind:"panel",name:"Tweak",items:[{kind:"input",name:"Black Level"},{kind:"input",name:"White Level"},{kind:"panel",name:"Edges",items:[{kind:"input",name:"Size",identifier:"Edge Search Size"},{kind:"input",name:"Tolerance",identifier:"Edge Tolerance"}],defaultClosed:!0}],defaultClosed:!0},{kind:"panel",name:"Mask",items:[{kind:"input",name:"Garbage Matte"},{kind:"input",name:"Core Matte"}],defaultClosed:!0},{kind:"panel",name:"Postprocess",items:[{kind:"input",name:"Blur Size",identifier:"Postprocess Blur Size"},{kind:"input",name:"Dilate Size",identifier:"Postprocess Dilate Size"},{kind:"input",name:"Feather Size",identifier:"Postprocess Feather Size"},{kind:"input",name:"Feather Falloff"}],defaultClosed:!0},{kind:"panel",name:"Despill",items:[{kind:"input",name:"Strength",identifier:"Despill Strength"},{kind:"input",name:"Balance",identifier:"Despill Balance"}],defaultClosed:!0}]},Be={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"UV"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},Le={customSocketOrder:!0,items:[{kind:"output",name:"Mask"},{kind:"layout"},{kind:"input",name:"Size Source"},{kind:"input",name:"Size X"},{kind:"input",name:"Size Y"},{kind:"input",name:"Feather"},{kind:"panel",name:"Motion Blur",items:[{kind:"input",name:"Motion Blur",panelToggle:!0},{kind:"input",name:"Samples",identifier:"Motion Blur Samples"},{kind:"input",name:"Shutter",identifier:"Motion Blur Shutter"}],defaultClosed:!0}]},je={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"output",name:"Plane"},{kind:"layout"},{kind:"panel",name:"Motion Blur",items:[{kind:"input",name:"Motion Blur",panelToggle:!0},{kind:"input",name:"Samples",identifier:"Motion Blur Samples"},{kind:"input",name:"Shutter",identifier:"Motion Blur Shutter"}],defaultClosed:!0}]},$e={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"Angle"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},Fe={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"Type"},{kind:"input",name:"X"},{kind:"input",name:"Y"},{kind:"input",name:"Frame Type"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},Ge={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"layout"},{kind:"input",name:"Frame"},{kind:"input",name:"Invert"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},We={customSocketOrder:!0,items:[{kind:"output",name:"Image"},{kind:"input",name:"String"},{kind:"input",name:"Font"},{kind:"input",name:"Size"},{kind:"panel",name:"Alignment",items:[{kind:"input",name:"Horizontal Alignment"},{kind:"input",name:"Vertical Alignment"}],defaultClosed:!0},{kind:"panel",name:"Wrap",items:[{kind:"input",name:"Wrap",panelToggle:!0},{kind:"input",name:"Width",identifier:"Wrap Width"}],defaultClosed:!0}]},He={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"X"},{kind:"input",name:"Y"},{kind:"input",name:"Angle"},{kind:"input",name:"Scale"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},Ue={customSocketOrder:!0,items:[{kind:"input",name:"Image"},{kind:"output",name:"Image",alignWithPrevious:!0},{kind:"input",name:"X"},{kind:"input",name:"Y"},{kind:"panel",name:"Sampling",items:[{kind:"input",name:"Interpolation"},{kind:"input",name:"Extension X"},{kind:"input",name:"Extension Y"}],defaultClosed:!0}]},Ye={customSocketOrder:!0,items:[{kind:"output",name:"Matrix"},{kind:"panel",name:"Column 1",items:[{kind:"input",name:"Column 1 Row 1"},{kind:"input",name:"Column 1 Row 2"},{kind:"input",name:"Column 1 Row 3"},{kind:"input",name:"Column 1 Row 4"}],defaultClosed:!0},{kind:"panel",name:"Column 2",items:[{kind:"input",name:"Column 2 Row 1"},{kind:"input",name:"Column 2 Row 2"},{kind:"input",name:"Column 2 Row 3"},{kind:"input",name:"Column 2 Row 4"}],defaultClosed:!0},{kind:"panel",name:"Column 3",items:[{kind:"input",name:"Column 3 Row 1"},{kind:"input",name:"Column 3 Row 2"},{kind:"input",name:"Column 3 Row 3"},{kind:"input",name:"Column 3 Row 4"}],defaultClosed:!0},{kind:"panel",name:"Column 4",items:[{kind:"input",name:"Column 4 Row 1"},{kind:"input",name:"Column 4 Row 2"},{kind:"input",name:"Column 4 Row 3"},{kind:"input",name:"Column 4 Row 4"}],defaultClosed:!0}]},ze={customSocketOrder:!0,items:[{kind:"panel",name:"Column 1",items:[{kind:"output",name:"Column 1 Row 1"},{kind:"output",name:"Column 1 Row 2"},{kind:"output",name:"Column 1 Row 3"},{kind:"output",name:"Column 1 Row 4"}],defaultClosed:!0},{kind:"panel",name:"Column 2",items:[{kind:"output",name:"Column 2 Row 1"},{kind:"output",name:"Column 2 Row 2"},{kind:"output",name:"Column 2 Row 3"},{kind:"output",name:"Column 2 Row 4"}],defaultClosed:!0},{kind:"panel",name:"Column 3",items:[{kind:"output",name:"Column 3 Row 1"},{kind:"output",name:"Column 3 Row 2"},{kind:"output",name:"Column 3 Row 3"},{kind:"output",name:"Column 3 Row 4"}],defaultClosed:!0},{kind:"panel",name:"Column 4",items:[{kind:"output",name:"Column 4 Row 1"},{kind:"output",name:"Column 4 Row 2"},{kind:"output",name:"Column 4 Row 3"},{kind:"output",name:"Column 4 Row 4"}],defaultClosed:!0},{kind:"input",name:"Matrix"}]},Ve={customSocketOrder:!0,items:[{kind:"input",name:"String"},{kind:"output",name:"String",alignWithPrevious:!0},{kind:"input",name:"Characters"},{kind:"input",name:"Whitespace"},{kind:"panel",name:"Limit",items:[{kind:"input",name:"Start"},{kind:"input",name:"End"}],defaultClosed:!0}]},Xe={customSocketOrder:!0,items:[{kind:"output",name:"Topology"},{kind:"input",name:"Bounds Min"},{kind:"input",name:"Bounds Max"},{kind:"input",name:"Resolution X"},{kind:"input",name:"Resolution Y"},{kind:"input",name:"Resolution Z"},{kind:"panel",name:"Min",items:[{kind:"input",name:"Min X"},{kind:"input",name:"Min Y"},{kind:"input",name:"Min Z"}],defaultClosed:!0}]},Ke={customSocketOrder:!0,conditional:!0,items:[{kind:"output",name:"Geometry"},{kind:"input",name:"",identifier:"__extend__main"},{kind:"output",name:"",identifier:"__extend__main",alignWithPrevious:!0},{kind:"panel",name:"Generated",items:[{kind:"separator"},{kind:"input",name:"",identifier:"__extend__generation"},{kind:"output",name:"",identifier:"__extend__generation",alignWithPrevious:!0}]}]},Ze={customSocketOrder:!0,items:[{kind:"output",name:"Names"},{kind:"input",name:"Geometry"},{kind:"panel",name:"Filter Data Type",items:[{kind:"input",name:"Filter Data Type",panelToggle:!0},{kind:"input",name:"Data Type"}]},{kind:"panel",name:"Filter Domain",items:[{kind:"input",name:"Filter Domain",panelToggle:!0},{kind:"input",name:"Domain"}]}]},qe={customSocketOrder:!0,conditional:!0,items:[{kind:"layout"},{kind:"output",name:"Points"},{kind:"output",name:"Value"},{kind:"panel",name:"Voxel Index",items:[{kind:"output",name:"X"},{kind:"output",name:"Y"},{kind:"output",name:"Z"},{kind:"output",name:"Is Tile"},{kind:"output",name:"Extent"}],defaultClosed:!0},{kind:"input",name:"Grid"}]},Je={customSocketOrder:!0,items:[{kind:"output",name:"X"},{kind:"output",name:"Y"},{kind:"output",name:"Z"},{kind:"panel",name:"Tile",items:[{kind:"output",name:"Is Tile"},{kind:"output",name:"Extent X"},{kind:"output",name:"Extent Y"},{kind:"output",name:"Extent Z"}],defaultClosed:!0}]},Qe={customSocketOrder:!0,items:[{kind:"input",name:"Mesh"},{kind:"output",name:"Mesh",alignWithPrevious:!0},{kind:"input",name:"Selection"},{kind:"input",name:"Affect Kind"},{kind:"input",name:"Start Left Offset"},{kind:"input",name:"Start Right Offset"},{kind:"input",name:"End Left Offset"},{kind:"input",name:"End Right Offset"},{kind:"input",name:"Offset"},{kind:"input",name:"Miter"},{kind:"input",name:"Spread"},{kind:"input",name:"Segments"},{kind:"input",name:"Shape"},{kind:"input",name:"Profile"},{kind:"panel",name:"Selections",items:[{kind:"output",name:"Vertex Face"},{kind:"output",name:"Edge Face"},{kind:"output",name:"Outer Edge"},{kind:"output",name:"Mid Edge"}]}]},en={customSocketOrder:!0,items:[{kind:"output",name:"Amplitude"},{kind:"input",name:"Sound"},{kind:"input",name:"Time"},{kind:"input",name:"All Channels"},{kind:"input",name:"Channel"},{kind:"input",name:"Low"},{kind:"input",name:"High"},{kind:"panel",name:"FFT",items:[{kind:"input",name:"FFT Size"},{kind:"input",name:"Window Function"}],defaultClosed:!0}]},nn={customSocketOrder:!0,items:[{kind:"output",name:"Curve Instances"},{kind:"output",name:"Remainder"},{kind:"output",name:"Line"},{kind:"output",name:"Word"},{kind:"output",name:"Pivot Point"},{kind:"input",name:"String"},{kind:"input",name:"Size"},{kind:"input",name:"Font"},{kind:"panel",name:"Alignment",items:[{kind:"input",name:"Align X"},{kind:"input",name:"Align Y"},{kind:"input",name:"Pivot Point"}],defaultClosed:!0},{kind:"panel",name:"Spacing",items:[{kind:"input",name:"Character Spacing"},{kind:"input",name:"Word Spacing"},{kind:"input",name:"Line Spacing"}],defaultClosed:!0},{kind:"panel",name:"Text Box",items:[{kind:"input",name:"Overflow"},{kind:"input",name:"Text Box Width"},{kind:"input",name:"Text Box Height"}],defaultClosed:!0}]},tn={customSocketOrder:!0,conditional:!0,items:[{kind:"input",name:"Target"},{kind:"output",name:"Target",alignWithPrevious:!0},{kind:"output",name:"Transferred Names"},{kind:"panel",name:"Target IDs",items:[],defaultClosed:!0},{kind:"input",name:"Source"},{kind:"panel",name:"Source IDs",items:[],defaultClosed:!0},{kind:"input",name:"Pattern Mode"},{kind:"input",name:"Attribute Names"},{kind:"input",name:"Exclude Names"}]},an={customSocketOrder:!0,items:[{kind:"input",name:"World"},{kind:"output",name:"World",alignWithPrevious:!0},{kind:"input",name:"Delta Time"},{kind:"input",name:"Filter"},{kind:"input",name:"Simulation to World"},{kind:"panel",name:"Solver",items:[{kind:"input",name:"Substeps"},{kind:"input",name:"Constraint Iterations"},{kind:"input",name:"Solver Path"}],defaultClosed:!0},{kind:"panel",name:"Interpolation Range",items:[{kind:"input",name:"Begin"},{kind:"input",name:"End"}],defaultClosed:!0}]},on={customSocketOrder:!0,conditional:!0,items:[{kind:"input",name:"Closure"},{kind:"panel",name:"Interface",items:[{kind:"output",name:"",identifier:"__extend__"},{kind:"input",name:"",identifier:"__extend__"}]}]},rn={customSocketOrder:!0,items:[{kind:"output",name:"BSDF"},{kind:"layout"},{kind:"input",name:"Color"},{kind:"input",name:"Roughness"},{kind:"input",name:"IOR"},{kind:"input",name:"Normal"},{kind:"input",name:"Weight",conditional:!0},{kind:"panel",name:"Thin Film",items:[{kind:"input",name:"Thin Film Thickness"},{kind:"input",name:"Thin Film IOR"}],defaultClosed:!0}]},un={customSocketOrder:!0,items:[{kind:"output",name:"BSDF"},{kind:"layout"},{kind:"input",name:"Base Color"},{kind:"input",name:"Edge Tint"},{kind:"input",name:"IOR"},{kind:"input",name:"Extinction"},{kind:"input",name:"Roughness"},{kind:"input",name:"Anisotropy"},{kind:"input",name:"Rotation"},{kind:"input",name:"Normal"},{kind:"input",name:"Tangent"},{kind:"input",name:"Weight",conditional:!0},{kind:"panel",name:"Thin Film",items:[{kind:"input",name:"Thin Film Thickness"},{kind:"input",name:"Thin Film IOR"}],defaultClosed:!0}]},sn={customSocketOrder:!0,items:[{kind:"output",name:"BSDF"},{kind:"input",name:"Base Color"},{kind:"input",name:"Metallic"},{kind:"input",name:"Roughness"},{kind:"input",name:"IOR"},{kind:"input",name:"Alpha"},{kind:"input",name:"Thin Wall"},{kind:"input",name:"Normal"},{kind:"input",name:"Weight",conditional:!0},{kind:"panel",name:"Diffuse",items:[{kind:"input",name:"Diffuse Roughness"}],defaultClosed:!0},{kind:"panel",name:"Subsurface",items:[{kind:"layout"},{kind:"input",name:"Subsurface Weight"},{kind:"input",name:"Subsurface Radius"},{kind:"input",name:"Subsurface Scale"},{kind:"input",name:"Subsurface IOR"},{kind:"input",name:"Subsurface Anisotropy"}],defaultClosed:!0},{kind:"panel",name:"Specular",items:[{kind:"layout"},{kind:"input",name:"Specular IOR Level"},{kind:"input",name:"Specular Tint"},{kind:"input",name:"Anisotropic"},{kind:"input",name:"Anisotropic Rotation"},{kind:"input",name:"Tangent"}],defaultClosed:!0},{kind:"panel",name:"Transmission",items:[{kind:"input",name:"Transmission Weight"}],defaultClosed:!0},{kind:"panel",name:"Coat",items:[{kind:"input",name:"Coat Weight"},{kind:"input",name:"Coat Roughness"},{kind:"input",name:"Coat IOR"},{kind:"input",name:"Coat Tint"},{kind:"input",name:"Coat Normal"}],defaultClosed:!0},{kind:"panel",name:"Sheen",items:[{kind:"input",name:"Sheen Weight"},{kind:"input",name:"Sheen Roughness"},{kind:"input",name:"Sheen Tint"}],defaultClosed:!0},{kind:"panel",name:"Emission",items:[{kind:"input",name:"Emission Color"},{kind:"input",name:"Emission Strength"}],defaultClosed:!0},{kind:"panel",name:"Thin Film",items:[{kind:"input",name:"Thin Film Thickness"},{kind:"input",name:"Thin Film IOR"}],defaultClosed:!0}]},dn={customSocketOrder:!0,conditional:!0,items:[{kind:"layout"},{kind:"output",name:"Is Hit"},{kind:"output",name:"Self Hit"},{kind:"output",name:"Hit Distance"},{kind:"output",name:"Hit Position"},{kind:"output",name:"Hit Normal"},{kind:"input",name:"Position"},{kind:"input",name:"Direction"},{kind:"input",name:"Length"},{kind:"panel",name:"Attributes",items:[{kind:"input",name:"",identifier:"__extend__"},{kind:"output",name:"",identifier:"__extend__",alignWithPrevious:!0}],defaultClosed:!0}]},ln={customSocketOrder:!0,items:[{kind:"output",name:"Volume"},{kind:"input",name:"Weight",conditional:!0},{kind:"panel",name:"Absorption",items:[{kind:"input",name:"Absorption Coefficients"}]},{kind:"panel",name:"Scatter",items:[{kind:"layout"},{kind:"input",name:"Scatter Coefficients"},{kind:"input",name:"Anisotropy"},{kind:"input",name:"IOR"},{kind:"input",name:"Backscatter"},{kind:"input",name:"Alpha"},{kind:"input",name:"Diameter"}]},{kind:"panel",name:"Emission",items:[{kind:"input",name:"Emission Coefficients"}]}]},mn={CompositorNodeColorBalance:Re,CompositorNodeColorCorrection:Pe,CompositorNodeColorSpill:_e,CompositorNodeCornerPin:Me,CompositorNodeDBlur:ve,CompositorNodeDisplace:Ae,CompositorNodeGlare:be,CompositorNodeKeying:De,CompositorNodeMapUV:Be,CompositorNodeMask:Le,CompositorNodePlaneTrackDeform:je,CompositorNodeRotate:$e,CompositorNodeScale:Fe,CompositorNodeStabilize:Ge,CompositorNodeStringToImage:We,CompositorNodeTransform:He,CompositorNodeTranslate:Ue,FunctionNodeCombineMatrix:Ye,FunctionNodeSeparateMatrix:ze,FunctionNodeTrimString:Ve,GeometryNodeCubeGridTopology:Xe,GeometryNodeForeachGeometryElementOutput:Ke,GeometryNodeGetAttributeNames:Ze,GeometryNodeGridToPoints:qe,GeometryNodeInputVoxelIndex:Je,GeometryNodeMeshBevel:Qe,GeometryNodeSampleSoundFrequencies:en,GeometryNodeStringToCurves:nn,GeometryNodeTransferAttributes:tn,GeometryNodeXPBDSolver:an,NodeEvaluateClosure:on,ShaderNodeBsdfGlass:rn,ShaderNodeBsdfMetallic:un,ShaderNodeBsdfPrincipled:sn,ShaderNodeRaycast:dn,ShaderNodeVolumeCoefficients:ln},I=20,N=1,S=I,O=I/2,D=.2*I,me=.25*I,Z=1.2*I,_=.1*I,pn=.8*I,w=.5,Y=D+w,cn=D+N,ne=2.5,kn=.2,fn=S*.5,z=S*-.5,hn=me,gn=1.5*I,R=11,h={sliderFill:"#4671b2",background:"#1a1a1a",body:"#303030",outline:"#ffffff",outlineAlpha:38/255,select:"#ed5700",active:"#ffffff",wireInner:"#8d8d8d",wire:"#1a1a1a",noodleCurving:4,dashAlpha:.5,text:"#e6e6e6",frame:"#0f0f0f",frameAlpha:204/255},Sn={INPUT:"#82354c",OUTPUT:"#3e232a",CONVERTER:"#246283",COLOR:"#6e6e23",VECTOR:"#3c3c83",FILTER:"#412b51",GROUP:"#374725",INTERFACE:"#1d1d1d",MATTE:"#5a3838",DISTORT:"#3e5a5b",TEXTURE:"#79461d",SHADER:"#2b652b",SCRIPT:"#203c3c",GEOMETRY:"#1d725e",ATTRIBUTE:"#1d2546",NONE:h.body,PATTERN:h.body},xn={VALUE:"#a1a1a1",VECTOR:"#6363c7",RGBA:"#c7c729",SHADER:"#63c763",BOOLEAN:"#cca6d6",INT:"#598c5c",STRING:"#70b3ff",OBJECT:"#ed9e5c",IMAGE:"#633863",GEOMETRY:"#00d6a3",COLLECTION:"#f5f5f5",TEXTURE:"#9e4fa3",MATERIAL:"#eb7582",ROTATION:"#a663c7",MENU:"#666666",MATRIX:"#b83385",BUNDLE:"#4d8080",CLOSURE:"#7d7d3b",FONT:"#635742",SOUND:"#635742",INT_VECTOR:"#5c789c",CUSTOM:"#333333"},yn="#ff00ff",pe=h.wire,Cn="#808080",F=N;function A(e){return e.enabled&&!e.hide}function V(e){const n=e.location[0]??0,a=e.location[1]??0,r=e.width,t=e.outputs.filter(A),o=e.inputs.filter(A);if(e.collapsed){const p=fn,m=p*Math.max(o.length,t.length,2)+D*2,x=a+m/2+z,c=a-m/2+z,k=(g,C)=>{let y=a+p*(g.length-1)*.5+z;return g.map(E=>{const P=M(E,C,C?n+r:n,y,y);return y-=p,P})};return{name:e.name,x:n,yTop:x,yBottom:c,width:r,collapsed:!0,sockets:[...k(t,!0),...k(o,!1)]}}let d=a-S;const u=[],l=(p,m)=>{const x=d;u.push(M(p,m,m?n+r:n,x-O,x)),d=x-S};return(t.length>0||o.length>0)&&(d-=2*_),t.forEach((p,m)=>{m>0&&(d-=_),l(p,!0)}),t.length>0&&o.length>0&&(d-=_),o.forEach((p,m)=>{(m>0||t.length>0)&&m>0&&(d-=_),l(p,!1)}),t.length>0||o.length>0?d-=2*_:d-=O,{name:e.name,x:n,yTop:a,yBottom:Math.min(d,a-2*S),width:r,collapsed:!1,sockets:u}}function M(e,n,a,r,t,o=!1){return{identifier:e.identifier,name:e.label??e.name,type:e.type,shape:e.shape,output:n,linked:e.linked,multiInput:e.multiInput,hideValue:e.hideValue,value:e.value,...e.softMin===void 0?{}:{softMin:e.softMin},...e.softMax===void 0?{}:{softMax:e.softMax},x:a,y:r,rowTop:t,panelCollapsed:o}}function Tn(e,n,a=h.noodleCurving){if(a===0)return[[e[0]+(n[0]-e[0])/3,e[1]+(n[1]-e[1])/3],[e[0]+(n[0]-e[0])*2/3,e[1]+(n[1]-e[1])*2/3]];const r=Math.abs(n[0]-e[0]),t=Math.abs(n[1]-e[1]),o=r===0?Number.POSITIVE_INFINITY:t/r,d=Math.min(1,o*(4.5-.25*a)),u=a*.1*r*d;return[[e[0]+u,e[1]],[n[0]-u,n[1]]]}function K(e){return e.idname==="NodeFrame"?h.frame:e.colorTag==="OUTPUT"&&!e.activeOutput?h.body:Sn[e.colorTag]??h.body}function te(e){return e.useCustomColor?b(e.color):h.body}function b(e){const n=a=>Math.round(Math.min(1,Math.max(0,a))*255).toString(16).padStart(2,"0");return`#${n(e[0]??0)}${n(e[1]??0)}${n(e[2]??0)}`}function ie(e,n){const a=ae(h.background),r=ae(e);return b([r[0]*(1-n)+a[0]*n,r[1]*(1-n)+a[1]*n,r[2]*(1-n)+a[2]*n])}const En=.6,wn=.8,On=.2;function ae(e){const n=Number.parseInt(e.slice(1),16);return[(n>>16&255)/255,(n>>8&255)/255,(n&255)/255]}function G(e){return xn[e]??yn}const oe=O,X=Z/3,re=Z/4,In=I,$={cell:8,reach:4,spread:3.64648,stroke:1},Nn="#000000",Rn=31/255*1.5,j=e=>e.identifier??e.name;function Pn(e,n,a){if(!e.customSocketOrder)return{ok:!1,why:"its declaration does not set use_custom_socket_order, so Blender lays it out the legacy way"};const r=[],t=[],o=l=>{for(const p of l)p.kind==="input"?r.push(j(p)):p.kind==="output"?t.push(j(p)):p.kind==="panel"&&o(p.items)};o(e.items);const d=(l,p,m)=>{if(l.length!==p.length)return`the declaration names ${l.length} ${m}${l.length===1?"":"s"} and the engine reports ${p.length}`;for(let x=0;x<l.length;x++)if(l[x]!==p[x]?.identifier)return`${m} ${x} is "${p[x]?.identifier}" in the engine and "${l[x]}" in the declaration`;return null},u=d(t,a,"output")??d(r,n,"input");return u===null?{ok:!0}:{ok:!1,why:u}}const _n={Socket:2,Separator:.5,Layout:3,PanelHeader:4},Mn={Socket:2,Separator:1,Layout:5,PanelHeader:4,PanelContentEnd:1},vn={Socket:{Socket:1,Separator:0,Layout:2,PanelHeader:3,PanelContentEnd:2},Layout:{Socket:2,Separator:0,Layout:1,PanelHeader:3,PanelContentEnd:2},Separator:{Socket:2,Separator:1,Layout:1,PanelHeader:1,PanelContentEnd:1},PanelHeader:{Socket:4,Separator:3,Layout:3,PanelHeader:5,PanelContentBegin:3,PanelContentEnd:3},PanelContentBegin:{Socket:2,Separator:1,Layout:2,PanelHeader:3,PanelContentEnd:1},PanelContentEnd:{Socket:1,Separator:1,Layout:1,PanelHeader:3,PanelContentEnd:0}};function ce(e,n,a,r,t,o,d){let u=!1;for(const l of e){if(l.kind==="input"||l.kind==="output"){const y=n.get(`${l.kind}:${j(l)}`);if(!y||!A(y)){u=!1;continue}const E=o[o.length-1];if(l.alignWithPrevious===!0&&u&&E&&E.type==="Socket"){o[o.length-1]={type:"Socket",input:l.kind==="input"?y:E.input,output:l.kind==="output"?y:E.output},u=!0;continue}o.push({type:"Socket",input:l.kind==="input"?y:void 0,output:l.kind==="output"?y:void 0}),u=!0;continue}if(u=!1,l.kind==="separator"){o.push({type:"Separator"});continue}if(l.kind==="layout"){r&&o.push({type:"Layout"});continue}if(l.kind!=="panel")continue;const p=l.items[0],m=p&&p.kind==="input"&&p.panelToggle===!0?p:null,x=m?n.get(`input:${j(m)}`)??null:null,c=[],k=y=>{for(const E of y)if(E.kind==="input"||E.kind==="output"){const P=n.get(`${E.kind}:${j(E)}`);P&&c.push(P)}else E.kind==="panel"&&k(E.items)};if(k(l.items),!c.some(A))continue;const g=a(l.defaultClosed===!0),C={name:l.name,depth:t,collapsed:g,toggle:x,owned:c,centerY:0,contentTop:null,contentBottom:null,fillsNodeEnd:!1};d.push(C),o.push({type:"PanelHeader",panel:C}),!g&&(o.push({type:"PanelContentBegin",panel:C}),ce(l.items.filter(y=>y!==m),n,a,r,t+1,o,d),o.push({type:"PanelContentEnd",panel:C}))}}function An(e){const n=e.location[0]??0,a=e.location[1]??0,r=e.width,t=new Map;for(const c of e.inputs)t.set(`input:${c.identifier}`,c);for(const c of e.outputs)t.set(`output:${c.identifier}`,c);let o=0;const d=e.panelStates,u=[],l=[];ce(e.declaration.items,t,c=>d[o++]?.collapsed??c,e.showOptions,0,u,l);const p=[];let m=a-S;u.length===0&&(m-=O);for(let c=0;c<u.length;c++){const k=u[c];if(!k)continue;const g=u[c-1],C=c===0?_n[k.type]??0:vn[g?.type??"Socket"]?.[k.type]??0;if(m-=C*_,k.type==="Socket"){const y=m;k.output&&p.push(M(k.output,!0,n+r,y-O,y)),k.input&&p.push(M(k.input,!1,n,y-O,y)),m=y-S;continue}if(k.type==="Layout"||k.type==="Separator"){m-=S;continue}if(k.type==="PanelHeader"&&k.panel){m-=oe/2,k.panel.centerY=m,m-=oe/2,k.panel.toggle&&p.push(M(k.panel.toggle,!1,n,k.panel.centerY,k.panel.centerY));continue}k.type==="PanelContentBegin"&&k.panel&&(k.panel.contentTop=m),k.type==="PanelContentEnd"&&k.panel&&(k.panel.contentBottom=m)}const x=u[u.length-1];x&&(m-=(Mn[x.type]??0)*_);for(const c of l)if(c.collapsed)for(const k of c.owned){if(!A(k))continue;const g=e.outputs.includes(k);p.push(M(k,g,g?n+r:n,c.centerY,c.centerY,!0))}for(let c=u.length-1;c>=0;c--){const k=u[c];if(!k||k.type!=="PanelContentEnd")break;k.panel&&(k.panel.fillsNodeEnd=!0)}return{name:e.name,x:n,yTop:a,yBottom:Math.min(m,a-2*S),width:r,collapsed:!1,sockets:p,panels:l.map(c=>({name:c.name,depth:c.depth,collapsed:c.collapsed,centerY:c.centerY,contentTop:c.contentTop,contentBottom:c.contentBottom,fillsNodeEnd:c.fillsNodeEnd,toggle:c.toggle?M(c.toggle,!1,n,c.centerY,c.centerY):null}))}}function bn(e){const n=a=>a.some(r=>r.kind==="layout"?!0:r.kind==="panel"?n(r.items):!1);return n(e.items)}const dt="workspace.document",lt="Shader Editor";Ce(Ne);const Dn=320,ue=.1,se=4;function mt(){const e=T.useSyncExternalStore(Te,Q,Q),[n,a]=T.useState(null),[r,t]=T.useState(null),o=T.useRef(null),d=T.useRef(!1);T.useSyncExternalStore(Ee,ee,ee);const{transform:u,looked:l,refusal:p,size:m}=U(),x=T.useCallback(s=>{const f=U().transform;B({transform:typeof s=="function"?s(f):s})},[]),c=T.useCallback(s=>{B({looked:s,refusal:null})},[]),k=T.useCallback(s=>{const f=U().size;f.w===s.w&&f.h===s.h||B({size:s})},[]),g=T.useCallback(s=>{we(s)},[]);T.useEffect(()=>{let s=!0;return(async()=>{try{const f=await Oe();if(!s)return;a(f),t(null)}catch(f){if(!s)return;t(f instanceof Error?f.message:String(f))}})(),()=>{s=!1}},[e]),T.useEffect(()=>{const s=o.current;if(!s)return;const f=new ResizeObserver(()=>{k({w:s.clientWidth,h:s.clientHeight})});return f.observe(s),k({w:s.clientWidth,h:s.clientHeight}),()=>f.disconnect()},[]);const C=T.useMemo(()=>$n(n),[n]);T.useEffect(()=>{B({drawn:[...C.frames,...C.nodes].map(({node:s,laid:f,panels:v,fallback:ye})=>{const J=f.sockets.find(H=>!H.panelCollapsed)??f.sockets[0];return{panels:v.length,collapsedPanels:v.filter(H=>H.collapsed).length,panelFallback:ye,name:s.name,x:f.x,yTop:f.yTop,yBottom:f.yBottom,width:f.width,height:f.yTop-f.yBottom,sockets:f.sockets.length,firstSocketBelowTop:J?f.yTop-J.y:null,header:K(s)}})})},[C]);const y=T.useCallback(()=>{const s=Fn(C.nodes);if(!s)return;const f=de(Math.min(m.w/(s.w+2*S),m.h/(s.h+2*S)),ue,se);B({transform:{cx:s.x+s.w/2,cy:s.y-s.h/2,zoom:f},framedAt:Date.now()})},[C.nodes,m.h,m.w]),E=Ie(),P=T.useRef(0);T.useEffect(()=>{E!==P.current&&(P.current=E,y())},[E,y]),T.useEffect(()=>{d.current||C.nodes.length===0||m.w<=1||(d.current=!0,y())},[C.nodes.length,m.w,y]);const W=T.useRef(null),fe=s=>{s.button===1&&(s.preventDefault(),s.target.setPointerCapture?.(s.pointerId),W.current={x:s.clientX,y:s.clientY,cx:u.cx,cy:u.cy})},he=s=>{const f=W.current;f&&x(v=>({...v,cx:f.cx-(s.clientX-f.x)/v.zoom,cy:f.cy+(s.clientY-f.y)/v.zoom}))},q=()=>{W.current=null},ge=s=>{s.preventDefault(),x(f=>({...f,zoom:de(f.zoom*(s.deltaY<0?1.1:1/1.1),ue,se)}))},Se=n?.nodes.find(s=>s.name===l)??null,xe=u.zoom>kn;return i.jsxs("div",{"data-testid":"blender-node-editor",style:{display:"flex",position:"absolute",inset:0,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[i.jsx(Xn,{tree:n,zoom:u.zoom,onViewAll:y,onRefuse:g}),i.jsx("div",{ref:o,style:{position:"relative",flex:1,minHeight:0},children:i.jsx("svg",{role:"presentation",width:"100%",height:"100%",onPointerDown:fe,onPointerMove:he,onPointerUp:q,onPointerCancel:q,onWheel:ge,onContextMenu:s=>{s.preventDefault(),g("The node context menu adds, deletes and reconnects nodes — editing.")},style:{display:"block",background:h.background,cursor:"default"},children:i.jsxs("g",{transform:`translate(${m.w/2} ${m.h/2}) scale(${u.zoom} ${-u.zoom}) translate(${-u.cx} ${-u.cy})`,children:[C.frames.map(s=>i.jsx(Vn,{node:s.node,laid:s.laid},s.node.name)),C.links.map(s=>i.jsx(zn,{link:s},s.key)),C.nodes.map(s=>i.jsx(Gn,{node:s.node,laid:s.laid,panels:s.panels,looked:s.node.name===l,details:xe,onLook:()=>c(s.node.name),onRefuse:g},s.node.name))]})})}),i.jsx(Kn,{entries:C.nodes,error:r,refusal:p})]}),i.jsx(Zn,{node:Se,onRefuse:g})]})}const Bn=26,Ln=22,jn=mn;function $n(e){if(!e)return{nodes:[],frames:[],links:[]};const n=new Map,a=e.nodes.map(t=>{const o={name:t.name,location:t.location,width:t.width,collapsed:t.collapsed,inputs:t.inputs,outputs:t.outputs},d=t.collapsed?void 0:jn[t.idname];if(t.panelCount>0&&!d){const l=V(o);return n.set(t.name,l),{node:t,laid:l,panels:[],fallback:t.collapsed?null:"no traced declaration — the trace covers the 36 node types that declare a panel in Blender 5.2.0, and a node group’s panels are runtime data",approximate:!1}}if(d){const l=Pn(d,t.inputs,t.outputs);if(l.ok){const m=An({...o,declaration:d,panelStates:t.panels,showOptions:t.showOptions});return n.set(t.name,m),{node:t,laid:m,panels:m.panels,fallback:null,approximate:bn(d)}}const p=V(o);return n.set(t.name,p),{node:t,laid:p,panels:[],fallback:l.why,approximate:!1}}const u=V(o);return n.set(t.name,u),{node:t,laid:u,panels:[],fallback:null,approximate:!1}}),r=e.links.flatMap((t,o)=>{const d=n.get(t.fromNode),u=n.get(t.toNode);if(!d||!u)return[];const l=d.sockets.find(m=>m.output&&m.identifier===t.fromSocket),p=u.sockets.find(m=>!m.output&&m.identifier===t.toSocket);return!l||!p?[]:[{key:`${t.fromNode}.${t.fromSocket}→${t.toNode}.${t.toSocket}#${o}`,from:[l.x,l.y],to:[p.x,p.y],fromColor:G(l.type),toColor:G(p.type),muted:t.muted,valid:t.valid}]});return{nodes:a.filter(t=>t.node.idname!=="NodeFrame"),frames:a.filter(t=>t.node.idname==="NodeFrame"),links:r}}function Fn(e){if(e.length===0)return null;let n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(const{laid:o}of e)n=Math.min(n,o.x),a=Math.max(a,o.x+o.width),r=Math.min(r,o.yBottom),t=Math.max(t,o.yTop);return{x:n,y:t,w:a-n,h:t-r}}const de=(e,n,a)=>Math.min(a,Math.max(n,e));function Gn({node:e,laid:n,panels:a,looked:r,details:t,onLook:o,onRefuse:d}){if(e.type==="REROUTE"){const g=n.sockets[0];return i.jsx("circle",{cx:n.x,cy:n.yTop,r:hn,fill:g?G(g.type):h.wireInner,stroke:pe,strokeWidth:F,onPointerDown:C=>{C.button===0&&o()}})}const u=e.muted?ie(K(e),En):K(e),l=e.muted?ie(te(e),wn):te(e),p=e.muted?1-On:1,m=e.selected?e.activeOutput||r?h.active:h.select:h.outline,x=e.selected?1:h.outlineAlpha,c=n.yTop-n.yBottom,k=e.label??e.typeLabel;return i.jsxs("g",{opacity:p,onPointerDown:g=>{g.button===0&&o()},onDoubleClick:()=>d(`Renaming "${e.name}" writes Node.name — editing parity is not the program.`),style:{cursor:"default"},children:[n.collapsed?i.jsx("rect",{x:n.x-w,y:-n.yTop-w,width:n.width+2*w,height:c+2*w,rx:Y,fill:u,transform:"scale(1 -1)"}):i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:n.x-w,y:-(n.yTop-S)-w,width:n.width+2*w,height:c-S+2*w,rx:Y,fill:l,transform:"scale(1 -1)"}),i.jsx("rect",{x:n.x-w,y:-n.yTop-w,width:n.width+2*w,height:S+2*w,rx:Y,fill:u,transform:"scale(1 -1)"}),i.jsx("rect",{x:n.x-w,y:-(n.yTop-S)-w,width:n.width+2*w,height:D,fill:u,transform:"scale(1 -1)"}),a.map(g=>i.jsx(Wn,{panel:g,laid:n},`bg:${g.name}`))]}),i.jsx("rect",{x:n.x-N,y:-n.yTop-N,width:n.width+2*N,height:c+2*N,rx:cn,fill:"none",stroke:m,strokeOpacity:x,strokeWidth:N,transform:"scale(1 -1)"}),i.jsx("text",{x:n.x+Z,y:-(n.yTop-S/2),transform:"scale(1 -1)",fill:h.text,fontSize:R,dominantBaseline:"central",style:{pointerEvents:"none",userSelect:"none"},children:k}),t&&n.sockets.map(g=>i.jsx(Un,{socket:g,node:n,onRefuse:d},`${g.output?"o":"i"}:${g.identifier}`)),t&&a.map(g=>i.jsx(Hn,{panel:g,laid:n,onRefuse:d},`hd:${g.name}`))]})}function Wn({panel:e,laid:n}){if(e.contentTop===null||e.contentBottom===null)return null;const a=[{y:e.contentTop,height:e.contentTop-e.contentBottom,radius:0,times:1}];return e.fillsNodeEnd&&a.push({y:e.contentBottom,height:e.contentBottom-n.yBottom,radius:D,times:e.depth+1}),i.jsx("g",{style:{pointerEvents:"none"},children:a.flatMap((r,t)=>Array.from({length:r.times},(o,d)=>i.jsx("rect",{x:n.x,y:-r.y,width:n.width,height:Math.max(r.height,0),rx:r.radius,fill:Nn,fillOpacity:Rn,transform:"scale(1 -1)"},`${t}:${d}`)))})}function Hn({panel:e,laid:n,onRefuse:a}){const r=pn,t=r/$.cell,o=n.x+X+r/2,d=e.centerY,u=$.reach*t,l=$.spread*t,p=e.collapsed?`M ${o-u/2} ${-(d+l)} L ${o+u/2} ${-d} L ${o-u/2} ${-(d-l)}`:`M ${o-l} ${-(d+u/2)} L ${o} ${-(d-u/2)} L ${o+l} ${-(d+u/2)}`,m=n.x+X+r+re+(e.toggle&&!e.toggle.linked?In:0);return i.jsxs("g",{onPointerDown:x=>{x.button===0&&(x.stopPropagation(),a(`${e.collapsed?"Opening":"Collapsing"} "${e.name}" writes the panel's is_collapsed — editing parity is not the program.`))},style:{cursor:"default"},children:[i.jsx("rect",{x:n.x,y:-(d+O),width:n.width,height:2*O,fill:"transparent",transform:"scale(1 -1)"}),i.jsx("path",{d:p,fill:"none",stroke:h.text,strokeWidth:$.stroke*t,strokeLinecap:"round",strokeLinejoin:"round",transform:"scale(1 -1)",style:{pointerEvents:"none"}}),e.toggle&&!e.toggle.linked&&i.jsx("rect",{x:n.x+X+r+re,y:-(d+O/2),width:O,height:O,rx:.2*O,fill:e.toggle.value===!0?"#4772b3":"#545454",transform:"scale(1 -1)",style:{pointerEvents:"none"}}),i.jsx("text",{x:m,y:-d,transform:"scale(1 -1)",fill:h.text,fontSize:R,dominantBaseline:"central",style:{pointerEvents:"none",userSelect:"none"},children:e.name})]})}function Un({socket:e,node:n,onRefuse:a}){const r=G(e.type),t=e.type==="CUSTOM"?Cn:pe,o=me,d=e.shape.replace("_DOT",""),u=e.shape.endsWith("_DOT"),l=d==="SQUARE"?i.jsx("rect",{x:e.x-o,y:-e.y-o,width:2*o,height:2*o,fill:r,stroke:t,strokeWidth:F,transform:"scale(1 -1)"}):d==="DIAMOND"?i.jsx("polygon",{points:`${e.x},${-e.y-o} ${e.x+o},${-e.y} ${e.x},${-e.y+o} ${e.x-o},${-e.y}`,fill:r,stroke:t,strokeWidth:F,transform:"scale(1 -1)"}):i.jsx("circle",{cx:e.x,cy:-e.y,r:o,fill:r,stroke:t,strokeWidth:F,transform:"scale(1 -1)"});return i.jsxs("g",{onPointerDown:p=>{p.button===0&&(p.stopPropagation(),a(`Dragging from "${e.name}" would make a link — editing parity is not the program.`))},children:[l,u&&i.jsx("circle",{cx:e.x,cy:-e.y,r:o*.35,fill:t,transform:"scale(1 -1)"}),!n.collapsed&&!e.panelCollapsed&&i.jsx(Yn,{socket:e,node:n,onRefuse:a})]})}function Yn({socket:e,node:n,onRefuse:a}){const r=O,t=n.x+r,o=n.x+n.width-r,d=-(e.rowTop-S/2);if(!(!e.output&&!e.linked&&!e.hideValue&&e.value!==null))return i.jsx("text",{x:e.output?o:t,y:d,transform:"scale(1 -1)",textAnchor:e.output?"end":"start",fill:h.text,fontSize:R,dominantBaseline:"central",style:{pointerEvents:"none",userSelect:"none"},children:e.name});const l=Array.isArray(e.value)&&e.value.length>=3;return i.jsxs("g",{onPointerDown:p=>{p.button===0&&(p.stopPropagation(),a(`Changing "${e.name}" writes the socket's default_value — editing parity is not the program.`))},style:{cursor:"default"},children:[i.jsx("rect",{x:t,y:d-S/2+1,width:o-t,height:S-2,rx:.2*S,fill:"#545454",transform:"scale(1 -1)"}),le(e)!==null&&i.jsxs(i.Fragment,{children:[i.jsx("clipPath",{id:`sl-${e.identifier}`,children:i.jsx("rect",{x:t,y:d-S/2+1,width:o-t,height:S-2,rx:.2*S})}),i.jsx("rect",{x:t,y:d-S/2+1,width:(o-t)*(le(e)??0),height:S-2,fill:h.sliderFill,clipPath:`url(#sl-${e.identifier})`,transform:"scale(1 -1)"})]}),i.jsx("text",{x:t+6,y:d,transform:"scale(1 -1)",fill:h.text,fontSize:R,dominantBaseline:"central",style:{pointerEvents:"none",userSelect:"none"},children:e.name}),l?i.jsx("rect",{x:o-34,y:d-S/2+3,width:30,height:S-6,rx:2,fill:b(e.value),transform:"scale(1 -1)"}):i.jsx("text",{x:o-6,y:d,transform:"scale(1 -1)",textAnchor:"end",fill:h.text,fontSize:R,dominantBaseline:"central",style:{pointerEvents:"none",userSelect:"none"},children:ke(e.value)})]})}function le(e){const{softMin:n,softMax:a,value:r}=e;return n===void 0||a===void 0||typeof r!="number"||a<=n?null:Math.min(1,Math.max(0,(r-n)/(a-n)))}function ke(e){return e===null?"":typeof e=="boolean"?e?"On":"Off":typeof e=="number"?e.toFixed(3):typeof e=="string"?e:e.map(n=>n.toFixed(2)).join(", ")}function zn({link:e}){const[n,a]=Tn(e.from,e.to),r=`M ${e.from[0]} ${e.from[1]} C ${n[0]} ${n[1]}, ${a[0]} ${a[1]}, ${e.to[0]} ${e.to[1]}`,t=e.valid?h.wireInner:"#ff2020";return i.jsxs("g",{style:{pointerEvents:"none"},children:[i.jsx("path",{d:r,fill:"none",stroke:h.wire,strokeWidth:ne+2*N}),i.jsx("path",{d:r,fill:"none",stroke:t,strokeWidth:ne,strokeDasharray:e.muted?"10 10":void 0,strokeOpacity:e.muted?h.dashAlpha:1})]})}function Vn({node:e,laid:n}){const a=Math.max(n.yTop-n.yBottom,gn*2);return i.jsxs("g",{style:{pointerEvents:"none"},children:[i.jsx("rect",{x:n.x,y:-n.yTop,width:n.width,height:a,rx:D,fill:e.useCustomColor?b(e.color):h.frame,fillOpacity:h.frameAlpha,transform:"scale(1 -1)"}),e.label&&i.jsx("text",{x:n.x+n.width/2,y:-(n.yTop-25),transform:"scale(1 -1)",textAnchor:"middle",fill:h.text,fontSize:20,children:e.label})]})}function Xn({tree:e,zoom:n,onViewAll:a,onRefuse:r}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--vgai-space-2)",height:Bn,padding:"0 var(--vgai-space-2)",background:h.background,color:h.text,font:`${R}px inherit`,borderBottom:"1px solid #161616"},children:[i.jsx("span",{"data-testid":"node-editor-tree-type",style:{opacity:.85},children:e?.typeLabel??"Shader Editor"}),i.jsx("span",{style:{opacity:.4},children:"·"}),i.jsx("span",{"data-testid":"node-editor-material",children:e?.material??"No material"}),i.jsx("span",{style:{flex:1}}),i.jsxs("span",{style:{opacity:.6},children:[Math.round(n*100),"%"]}),i.jsx("button",{type:"button",className:"vgai-btn","data-variant":"ghost","data-size":"sm",onClick:a,"data-testid":"node-editor-view-all",children:"View All"}),i.jsx("button",{type:"button",className:"vgai-btn","data-variant":"ghost","data-size":"sm","data-testid":"node-editor-use-nodes",onClick:()=>r("Use Nodes writes Material.use_nodes — editing parity is not the program."),children:"Use Nodes"})]})}function Kn({entries:e,error:n,refusal:a}){const r=e.filter(u=>u.fallback!==null),t=e.filter(u=>u.approximate),o=e.reduce((u,l)=>u+l.panels.length,0),d=n||a||(r.length>0?`${r.map(u=>`"${u.node.name}" draws its sockets flat: ${u.fallback}`).join("; ")}.`:t.length>0?`${t.map(u=>`"${u.node.name}"`).join(", ")} ${t.length===1?"carries a":"carry"} declaration LAYOUT row, whose drawn height RNA cannot answer; one UI unit is reserved for it.`:o>0?`${o} socket panel${o===1?"":"s"} drawn from Blender's own declarations. Read-only: this view inspects the node tree and never writes it.`:"Read-only: this view inspects the node tree and never writes it.");return i.jsx("div",{"data-testid":"node-editor-status",style:{flex:"0 0 auto",height:Ln,display:"flex",alignItems:"center",padding:"0 var(--vgai-space-2)",background:h.background,color:n||a?"#ffa028":"#888888",font:`${R}px inherit`,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d})}function Zn({node:e,onRefuse:n}){return i.jsxs("aside",{"data-testid":"node-editor-sidebar",style:{width:Dn,flex:"0 0 auto",overflow:"auto",background:h.background,color:h.text,font:`${R}px inherit`,borderLeft:"1px solid #161616",padding:"var(--vgai-space-2)"},children:[i.jsx("div",{style:{opacity:.6,marginBottom:"var(--vgai-space-2)"},children:"Node"}),e?i.jsxs(i.Fragment,{children:[i.jsx(L,{label:"Name",value:e.name,onRefuse:n}),i.jsx(L,{label:"Label",value:e.label??"",onRefuse:n}),i.jsx(L,{label:"Color",value:e.useCustomColor?b(e.color):"Off",onRefuse:n,swatch:e.useCustomColor?b(e.color):void 0}),i.jsx(L,{label:"Mute",value:e.muted?"On":"Off",onRefuse:n}),i.jsx("div",{style:{opacity:.6,margin:"var(--vgai-space-3) 0 var(--vgai-space-1)"},children:"Properties"}),e.inputs.filter(A).map(a=>i.jsx(L,{label:a.label??a.name,value:a.linked?"Linked":ke(a.value),onRefuse:n},a.identifier))]}):i.jsx("div",{style:{opacity:.5},children:"No node looked at."})]})}function L({label:e,value:n,swatch:a,onRefuse:r}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--vgai-space-2)",height:20},onPointerDown:()=>r(`"${e}" is read here and written nowhere — inspection parity.`),children:[i.jsx("span",{style:{flex:"0 0 45%",opacity:.75,textAlign:"right"},children:e}),a&&i.jsx("span",{style:{width:14,height:14,borderRadius:2,background:a,flex:"0 0 auto"}}),i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},title:n,children:n})]})}export{mt as default,dt as point,lt as title};
@@ -0,0 +1 @@
1
+ import{e as O}from"./index-5av5LJja.js";import{b as g,a as F,c as x,d as E}from"./blender-runtime-host-D8NHsAfD.js";const I=e=>typeof e=="object"&&e!==null&&typeof e.subscribeFrames=="function"&&typeof e.objectForBlenderName=="function"&&typeof e.blenderObjectName=="function"&&typeof e.blenderSelection=="function"&&typeof e.setStageMode=="function";function p(){const e=O().documents.context(F());return I(e)?e:null}function H(){return p()?.blenderSelection()??{selected:[],active:null}}const R={tree:null,byId:new Map,parentOf:new Map,error:null,loading:!1};let d=R,M=0;const b=new Set;let l=null,c=null,S="",i=null;function q(e){const n=new Map,r=new Map,t=(o,P)=>{n.set(o.id,o),r.set(o.id,P);for(const V of o.children)t(V,o.id)};for(const o of e?.rows??[])t(o,null);return{byId:n,parentOf:r}}function u(e){d={...d,...e},M+=1;for(const n of[...b])n()}function K(e){return b.add(e),()=>{b.delete(e)}}function L(){return M}function Y(){return d}function h(e){i!==e&&(i=e,setTimeout(()=>{i===e&&(i=null,B(e===""?[]:e.split("\0")))},0))}let a=0,m=Promise.resolve();function B(e){const n=C(e);return m=n,n}async function C(e){const n=e.join("\0"),r=++a;c=n,S=n,u({loading:!0});try{const t=await E(e);if(r!==a)return;p()?.setStageMode(t?.mode??null),u({tree:t,...q(t),loading:!1,error:null})}catch(t){if(r!==a)return;u({loading:!1,error:j(t)})}}function N(){c=null,h(S);for(const e of[...w])e()}const w=new Set;function v(e){return y(),w.add(e),()=>{w.delete(e)}}let s=!1,f=null;function y(){const e=p();if(l!==null&&f===e)return;l!==null&&(l(),l=null,f=null);const n=e;if(n!==null){l=n.subscribeFrames(N),f=n;return}s||(s=!0,O().documents.waitForContext(F()).then(()=>{s=!1,y()}).catch(()=>{s=!1}))}function z(e){if(!g())return;y();const n=[...e].sort().join("\0");c!==n&&h(n)}async function A(e){if(!g())return;i=null;let n=B([...e].sort());for(;;){if(await n,m===n)return;n=m}}async function G(e,n,r){try{return await x(e,n,r),c=null,h(S),!0}catch(t){return u({error:j(t)}),!1}}function j(e){return e instanceof Error?e.message:String(e)}export{L as a,H as b,p as c,z as d,Y as e,v as o,A as r,K as s,G as w};
@@ -0,0 +1,3 @@
1
+ import{a as i}from"./jsx-runtime-DPjLkJKQ.js";import{e as V}from"./index-5av5LJja.js";import{a as H,b as X,v as le,w as oe,s as se,x as ce,p as ue}from"./blender-runtime-host-D8NHsAfD.js";import{e as de}from"./blender-outliner-model-B8b00oxr.js";import{r as g}from"./index-DaQZGF7d.js";const ae=e=>typeof e=="object"&&e!==null&&typeof e.subscribeFrames=="function"&&typeof e.blenderObjectName=="function",fe=e=>typeof e=="object"&&e!==null&&typeof e.documentId=="string"&&typeof e.hierarchy?.object3D=="function";function Y(){const e=V().documents.context(H());return ae(e)?e:null}function Z(e,t){if(e===null||!fe(t))return null;const n=Y();if(n===null)return null;if(e.id===t.documentId)return t.documentRootObject===n.root?{kind:"scene"}:null;const r=de().byId.get(e.id);if(r?.type==="TSE_LAYER_COLLECTION")return{kind:"collection",path:r.path};const l=t.hierarchy.object3D(e.id);if(l===null)return null;if(l===n.root)return{kind:"scene"};const o=n.blenderObjectName(l);return o===null?null:{kind:"object",name:o}}let N={object:null,collection:null,context:null,views:new Map,error:null,loading:!1},q=0;const F=new Set;let z=null;const I=new Set;let E=null;function b(e,t=!1){N={...N,...e},q+=1;for(const n of[...F])n();t&&V().documents.contextChanged(H())}function pe(e){return F.add(e),()=>{F.delete(e)}}function G(){return q}function M(){return N}function he(){const e=E;E=null,b({views:new Map}),e!==null&&J(e)}se(()=>{he()});let T=null;function J(e){T!==e&&(T=e,setTimeout(()=>{T===e&&(T=null,ge(e))},0))}function xe(e){return e.kind==="scene"?"":e.kind==="collection"?`collection:${e.path}`:e.name}function ye(){if(z!==null)return;const e=Y();e!==null&&(z=e.subscribeFrames(le))}async function ge(e){const t=e.startsWith("collection:")?e.slice(11):null,n=t===null&&e!==""?e:null;E=e,b({loading:!0,object:n,collection:t});try{const r=await oe(n??void 0,t??void 0);if(E!==e)return;b({context:r,loading:!1,error:null},!0)}catch(r){if(E!==e)return;b({context:null,loading:!1,error:D(r)},!0)}}function Q(e){if(!X())return;ye();const t=xe(e);E!==t&&J(t)}function R(e){const t=N.views.get(e);if(t!==void 0)return t;I.has(e)||!X()||(I.add(e),ce(e).then(n=>{if(I.delete(e),n===null)return;const r=new Map(N.views);r.set(e,n),b({views:r,error:null})}).catch(n=>{I.delete(e),b({error:D(n)})}))}async function be(e,t,n,r){try{await ue(e,t,n,r);const l=new Map(N.views);return l.delete(e),b({views:l,error:null}),!0}catch(l){return b({error:D(l)}),!1}}function D(e){return e instanceof Error?e.message:String(e)}const $=20,K=2,je="40%",me=25,U=20,m=8,ve=4,W=8,p=11,y=.5,x="#e6e6e6",Se="#3d3d3d",Ee="#ffffff11",Ae="rgba(0,0,0,0.12)",Ne="#545454",Re="#3d3d3d",$e="#4772b3",ee="#991616",Oe=8,Le=6,Ce=e=>Math.round(e*.2),te=e=>e.filter(t=>t.hidden!==!0&&t.undrawn!==!0);function C(){return g.useSyncExternalStore(pe,G,G)}function h({title:e,sub:t=!1,closed:n=!1,note:r,count:l,children:o}){const[c,u]=g.useState(!n);return i.jsxs("div",{style:{marginBottom:m,borderRadius:ve,boxShadow:t?"none":`inset 0 0 0 1px ${Ee}`,background:t?Ae:"transparent",overflow:"hidden"},children:[i.jsxs("button",{type:"button",onClick:()=>u(!c),style:{display:"flex",alignItems:"center",width:"100%",height:me,background:t?"transparent":Se,border:"none",padding:`0 ${W}px 0 ${t?U+14-20:0}px`,color:x,font:`${p}px inherit`,textAlign:"left",cursor:"pointer",gap:Le},children:[i.jsx("span",{"aria-hidden":"true",style:{width:U-8,textAlign:"center",fontSize:Oe,opacity:.85},children:c?"▼":"▶"}),i.jsx("span",{style:{fontWeight:400},title:r,children:e}),l===void 0?null:i.jsx("span",{style:{opacity:y,marginLeft:"auto"},children:l})]}),c?i.jsx("div",{style:{padding:m},children:o}):null]})}function A({label:e,title:t,readonly:n,identifier:r,children:l}){return i.jsxs("div",{"data-rna-field":r??"","data-field-label":e,"data-field-readonly":n?"true":void 0,style:{display:"flex",alignItems:"center",minHeight:$,marginBottom:K,gap:W,opacity:n?y:1},title:t,children:[i.jsx("span",{style:{flex:`0 0 ${je}`,textAlign:"right",color:x,fontSize:p,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx("span",{style:{flex:"1 1 0",minWidth:0,display:"flex",gap:K},children:l})]})}const j={height:$,width:"100%",minWidth:0,boxSizing:"border-box",background:Ne,border:`1px solid ${Re}`,borderRadius:Ce($),color:x,fontSize:p,padding:`0 ${W}px`,textAlign:"center"};function v({children:e}){return i.jsx("span",{style:{...j,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})}const B=$-2*Math.floor(($-2)/6);function ne({value:e,readonly:t,label:n,onChange:r}){return i.jsx("input",{type:"checkbox",checked:e,readOnly:t,...n===void 0?{}:{"aria-label":n},onChange:l=>!t&&r(l.target.checked),style:{width:B,height:B,margin:`${($-B)/2}px 0`,accentColor:$e,cursor:t?"default":"pointer"}})}function ie({row:e,value:t,index:n,onWrite:r}){const[l,o]=g.useState(null),c=e.type==="FLOAT"?e.precision??3:0,u=l??(e.type==="FLOAT"?t.toFixed(c):String(t));return e.readonly?i.jsx(v,{children:u}):i.jsx("input",{type:"number","aria-label":O(e,n),value:u,...e.softMin===void 0?{}:{min:e.softMin},...e.softMax===void 0?{}:{max:e.softMax},...e.step===void 0?{}:{step:e.type==="FLOAT"?e.step/100:1},onChange:s=>o(s.target.value),onBlur:()=>{const s=Number(l);o(null),l!==null&&Number.isFinite(s)&&s!==t&&r(s,n)},onKeyDown:s=>{s.key==="Enter"&&s.target.blur(),s.key==="Escape"&&o(null)},style:j})}const k=["X","Y","Z","W"];function O(e,t){const n=e.name||e.identifier;return t===void 0?n:`${n} ${k[t]??t}`}function Ie(e){const t=n=>Math.max(0,Math.min(255,Math.round((e[n]??0)**.45454545454545453*255)));return`rgb(${t(0)}, ${t(1)}, ${t(2)})`}function Te({row:e,onOpen:t}){const n=e.value;if(n===null||n.path===null)return i.jsx(v,{children:n===null?"None":n.name??n.type});const r=n.path;return i.jsx("button",{type:"button","aria-label":O(e),onClick:()=>t(r),style:{...j,cursor:"pointer",textAlign:"left"},title:r,children:n.name??n.type})}function Pe({row:e,write:t}){const n=e.items??[];if(e.isFlag){const l=e.value??[];return i.jsx(v,{children:l.length===0?"None":l.join(", ")})}const r=String(e.value??"");return e.readonly?i.jsx(v,{children:n.find(l=>l.identifier===r)?.name??r}):i.jsx("select",{"aria-label":O(e),value:r,onChange:l=>t(l.target.value),style:{...j,textAlign:"left"},children:n.map(l=>i.jsx("option",{value:l.identifier,children:l.name},l.identifier))})}function ke({row:e,write:t}){const n=String(e.value??"");return e.readonly?i.jsx(v,{children:n}):i.jsx(De,{value:n,label:O(e),onWrite:r=>t(r)})}function Me({row:e}){const t=e.value??[];return i.jsx("span",{style:{...j,background:Ie(t),display:"block"},title:t.map(n=>n.toFixed(3)).join(", ")})}function Be({row:e,label:t,title:n,write:r}){const l=e.value??[];return i.jsx(i.Fragment,{children:l.map((o,c)=>i.jsx(A,{label:Fe(t,c,l.length),title:n,readonly:e.readonly,identifier:`${e.identifier}[${c}]`,children:e.type==="BOOLEAN"?i.jsx(ne,{value:o===!0,readonly:e.readonly,label:O(e,c),onChange:u=>r(u,c)}):i.jsx(ie,{row:e,value:Number(o),index:c,onWrite:(u,s)=>r(u,s)})},`${e.identifier}-${k[c]??c}`))})}function Fe(e,t,n){return n>k.length?t===0?e:`${e} ${t}`:`${t===0?`${e} `:""}${k[t]}`}function _e(e){const{row:t,write:n}=e;switch(t.type){case"POINTER":return i.jsx(Te,{...e});case"ENUM":return i.jsx(Pe,{...e});case"STRING":return i.jsx(ke,{...e});case"BOOLEAN":return i.jsx(ne,{value:t.value===!0,readonly:t.readonly,label:O(t),onChange:n});default:return i.jsx(ie,{row:t,value:Number(t.value??0),onWrite:r=>n(r)})}}function w({row:e,path:t,onOpen:n}){const r=(d,f)=>void be(t,e.identifier,d,f),l=e.name||e.identifier,o=`${e.identifier} — ${e.type}${e.subtype==="NONE"?"":`/${e.subtype}`}${e.readonly?" (read-only)":""}${e.description?`
2
+ ${e.description}`:""}`,c={row:e,path:t,write:r,onOpen:n},u=e.valueOmitted??e.valueError;if(u!==void 0)return i.jsx(A,{label:l,title:o,readonly:!0,identifier:e.identifier,children:i.jsx(v,{children:u})});if(e.type==="COLLECTION")return i.jsx(We,{label:l,title:o,value:e.value??{count:0},identifier:e.identifier,onOpen:()=>n(`${t}.${e.identifier}`)});const s=e.type==="INT"||e.type==="FLOAT";return e.arrayLength>0&&(s||e.type==="BOOLEAN")?s&&(e.subtype==="COLOR"||e.subtype==="COLOR_GAMMA")?i.jsx(A,{label:l,title:o,readonly:e.readonly,identifier:e.identifier,children:i.jsx(Me,{...c})}):i.jsx(Be,{...c,label:l,title:o}):i.jsx(A,{label:l,title:o,readonly:e.readonly,identifier:e.identifier,children:_e(c)})}function De({value:e,label:t,onWrite:n}){const[r,l]=g.useState(null);return i.jsx("input",{type:"text",...t===void 0?{}:{"aria-label":t},value:r??e,onChange:o=>l(o.target.value),onBlur:()=>{r!==null&&r!==e&&n(r),l(null)},onKeyDown:o=>{o.key==="Enter"&&o.target.blur(),o.key==="Escape"&&l(null)},style:{...j,textAlign:"left"}})}function We({label:e,title:t,value:n,identifier:r,onOpen:l}){const[o,c]=g.useState(!1),u=n.names??[];return i.jsxs(i.Fragment,{children:[i.jsx(A,{label:e,title:t,readonly:!1,identifier:r,children:i.jsxs("button",{type:"button","aria-label":e,onClick:()=>u.length?c(!o):l(),style:{...j,cursor:"pointer",textAlign:"left"},children:[u.length?`${o?"▼":"▶"} `:"",n.count," ",n.count===1?"item":"items"]})}),o?u.map(s=>i.jsx(A,{label:"",readonly:!0,children:i.jsx(v,{children:s})},s)):null]})}const _=e=>typeof e=="string"?e:e.property;function we(e){if(e.active===void 0)return{path:null,index:null};const t=M().context?.[e.active];if(typeof t!="object"||t===null)return{path:null,index:null};const n=t;return{path:n.path??null,index:typeof n.index=="number"?n.index:null}}function ze({panel:e,path:t,onOpen:n}){C();const r=R(t),l=we(e);return r===void 0?i.jsx(h,{title:e.title,closed:e.closed===!0,children:i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:["Reading ",t,"…"]})}):r.kind!=="collection"?i.jsx(h,{title:e.title,closed:e.closed===!0,note:t,children:i.jsxs("div",{style:{color:ee,fontSize:p},children:[t," is not a collection — this panel is declared `collection: true`."]})}):i.jsxs(h,{title:e.title,closed:e.closed===!0,note:t,count:r.count,children:[r.items.length===0?i.jsx("div",{style:{color:x,opacity:y,fontSize:p},children:"None"}):null,r.items.map((o,c)=>i.jsx(h,{title:`${o.path!==null&&o.path===l.path||c===l.index?"● ":""}${o.name??o.type}`,sub:!0,children:o.path===null?i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:[o.type," — RNA gives this member no address."]}):i.jsx(Ge,{path:o.path,properties:e.properties,andDeclared:e.andDeclared===!0,onOpen:n})},o.path??o.name??o.type))]})}function Ge({path:e,properties:t,andDeclared:n=!1,onOpen:r}){C();const l=R(e);if(l===void 0)return i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:["Reading ",e,"…"]});const o=l.kind==="struct"?l.groups.flatMap(d=>d.rows):[],c=new Map(o.map(d=>[d.identifier,d])),u=t.map(d=>c.get(_(d))).filter(d=>d!==void 0),s=n&&l.kind==="struct"?te(o).filter(d=>d.group===l.type&&!t.some(f=>_(f)===d.identifier)):[];return i.jsx(i.Fragment,{children:[...u,...s].map(d=>i.jsx(w,{row:d,path:e,onOpen:r},d.identifier))})}function Ke(e,t){if(e.engine!==void 0){const n=M().context?.engine;if(n===void 0)return null;if(!e.engine.includes(n))return!1}for(const n of e.when??[]){const r=n.from??e.from,l=r?t.find(s=>s.label===r):t[0];if(l===void 0)return!1;const o=R(l.path);if(o===void 0)return null;if(o.kind!=="struct")return!1;const c=o.groups.flatMap(s=>s.rows).find(s=>s.identifier===n.property);if(c===void 0)return!1;const u=c.value;if(typeof u!="string"&&typeof u!="number"&&typeof u!="boolean"||n.is!==void 0&&!n.is.includes(u)||n.isNot!==void 0&&n.isNot.includes(u))return!1}return!0}function re({panel:e,paths:t,onOpen:n}){if(C(),Ke(e,t)!==!0)return null;const r=e.from?t.find(s=>s.label===e.from):t[0];if(r!==void 0&&e.collection===!0)return i.jsx(ze,{panel:e,path:r.path,onOpen:n});if(r===void 0)return null;const l=R(r.path),o=e.sub??[],c=[],u=[];for(const s of e.properties){const d=_(s),f=typeof s=="string"?r:t.find(L=>L.label===s.from),a=f===void 0?void 0:R(f.path),S=a?.kind==="struct"?a.groups.flatMap(L=>L.rows).find(L=>L.identifier===d):void 0;S===void 0||f===void 0?u.push(d):c.push({identifier:d,row:S,path:f.path})}return l===void 0?i.jsx(h,{title:e.title,closed:e.closed===!0,children:i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:["Reading ",r.path,"…"]})}):c.length===0&&o.length===0?null:i.jsxs(h,{title:e.title,closed:e.closed===!0,note:u.length===0?`${r.path}`:`${r.path}
3
+ Not on this datablock: ${u.join(", ")}`,children:[c.map(s=>i.jsx(w,{row:s.row,path:s.path,onOpen:n},s.identifier)),o.map((s,d)=>i.jsx(re,{panel:s,paths:t,onOpen:n},`${d}:${s.title}`))]})}function P({path:e,onOpen:t}){C();const n=R(e);return n===void 0?i.jsxs("div",{style:{color:x,opacity:y,fontSize:p,padding:m},children:["Reading ",e,"…"]}):n.kind==="collection"?i.jsxs(i.Fragment,{children:[n.items.length===0?i.jsx("div",{style:{color:x,opacity:y,fontSize:p},children:n.count===0?"None":`${n.count} items`}):null,n.items.map(r=>i.jsx(h,{title:r.name??r.type,sub:!0,children:r.path===null?i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:[r.type," — RNA gives this member no address."]}):i.jsx(P,{path:r.path,onOpen:t})},r.path??r.name??r.type))]}):i.jsx(i.Fragment,{children:n.groups.map(r=>{const l=te(r.rows);return l.length===0?null:i.jsx(h,{title:r.label,sub:!0,children:l.map(o=>i.jsx(w,{row:o,path:n.path,onOpen:t},o.identifier))},r.id)})})}function Ue({tabId:e,subject:t,curated:n=[]}){C(),g.useEffect(()=>Q(t),[t]);const[r,l]=g.useState([]),o=M(),c=o.context?.tabs.find(a=>a.id===e)??null,u=c?.paths??[],s=u.map(a=>a.path).join("|");if(g.useEffect(()=>l([]),[s]),o.error!==null)return i.jsx("div",{style:{color:ee,fontSize:p,padding:m},children:o.error});if(c===null)return i.jsx("div",{style:{color:x,opacity:y,fontSize:p,padding:m},children:o.loading?"Reading the engine…":"Blender shows no properties here."});const d=a=>l(S=>[...S,a]),f=r[r.length-1];return i.jsxs("div",{style:{padding:`${m}px 0`},children:[r.length>0?i.jsxs("button",{type:"button",onClick:()=>l(a=>a.slice(0,-1)),style:{...j,width:"auto",marginBottom:m,cursor:"pointer",textAlign:"left"},title:f,children:["← ",c.label]}):null,f!==void 0?i.jsx(h,{title:f.slice(f.lastIndexOf(".")+1),children:i.jsx(P,{path:f,onOpen:d})}):i.jsxs(i.Fragment,{children:[n.map((a,S)=>i.jsx(re,{panel:a,paths:u,onOpen:d},`${S}:${a.title}`)),n.length>0?i.jsx(h,{title:"All properties",closed:!0,children:u.map(a=>i.jsx(h,{title:a.label,sub:!0,children:i.jsx(P,{path:a.path,onOpen:d})},a.path))}):u.map(a=>i.jsx(h,{title:a.label,children:i.jsx(P,{path:a.path,onOpen:d})},a.path))]})]})}function qe(e){return(t,n)=>{const r=Z(t,n);if(r===null)return!1;if(Q(r),e.standing==="any")return!0;if(e.standing==="object")return r.kind==="object";const l=M(),o=r.kind==="object"?r.name:null,c=r.kind==="collection"?r.path:null;return l.object!==o||l.collection!==c?!1:l.context?.tabs.some(u=>u.id===e.id)??!1}}function Je(e){return function({node:n,adapter:r}){const l=Z(n,r);return l===null?null:i.jsx(Ue,{tabId:e.id,subject:l,curated:e.curated??[]})}}export{qe as a,Je as b,M as c,Z as r};
@@ -0,0 +1,4 @@
1
+ import{bS as De,bT as Pe,e as N,ac as Ve,bU as We}from"./index-5av5LJja.js";import{d as ze,W as Me,H as Ge,br as qe,i as He,bK as se,w as Xe,x as Ze,af as xe,V as Q,bl as Ke,$ as Ye,k as Je,bL as Qe,bf as ve}from"./three.module-BynznMJN.js";import{f as et}from"./clip-planes-CnAI6DZn.js";class tt{#r;#c;#n=new Map;#m=0;#h=null;#s=new Map;#i=null;#u=0;#f=0;#w=0;#a=null;#g=null;#d=null;constructor(t){this.#c=t,this.#r=new Worker(new URL("/assets/worker-DTgfRRas.js",import.meta.url),{type:"module",name:"blender"}),this.#r.onmessage=n=>void this.#b(n.data),this.#r.onerror=n=>{const r=n.error,o=n.filename?` at ${n.filename}:${n.lineno}:${n.colno}`:"",a=r?.stack??r?.message??n.message,l=new Error(`Blender worker failed: ${a||"the worker script did not load"}${o}`);console.error(l.message);for(const i of[...this.#n.keys()])this.#p(i);for(const i of this.#n.values())i.reject(l);this.#n.clear()}}#o=null;#l=null;get project(){return this.#o}start(t,n){return this.#o!==null&&this.#o!==t?Promise.reject(new Error(`The Blender session is bound to ${this.#o}, not ${t}`)):n!==void 0&&this.#l!==null&&this.#l!==n?Promise.reject(new Error(`Blender resource conflict: the session holds ${this.#l}; cannot open ${n}`)):(this.#o=t,this.#l??=n??"models/model.blend",this.#h??=this.#e({op:"start",project:t,...n===void 0?{}:{document:n}}),this.#h)}#t(){return this.#o===null?Promise.reject(new Error("The Blender session has not been started with a project (blender-start)")):this.start(this.#o)}async execute(t){return await this.#t(),await this.#e({op:"execute",code:t})}async sceneInfo(){return await this.#t(),await this.#e({op:"scene-info"})}async objectInfo(t){return await this.#t(),await this.#e({op:"object-info",name:t})}async rna(t,n){return await this.#t(),await this.#e({op:"rna",path:t,...n===void 0?{}:{names:n}})}async rnaContext(t,n){return await this.#t(),await this.#e({op:"rna-context",...t===void 0?{}:{object:t},...n===void 0?{}:{collection:n}})}async rnaSet(t,n,r,o){return await this.#t(),await this.#e({op:"rna-set",path:t,property:n,value:r,...o===void 0?{}:{index:o}})}async outliner(t){return await this.#t(),await this.#e({op:"outliner",...t===void 0?{}:{selected:t}})}async nodeTree(t){return await this.#t(),await this.#e({op:"node-tree",...t?.path===void 0?{}:{path:t.path},...t?.material===void 0?{}:{material:t.material}})}async uvLayout(t){return await this.#t(),await this.#e({op:"uv-layout",...t?.object===void 0?{}:{object:t.object},...t?.uvLayer===void 0?{}:{uvLayer:t.uvLayer}})}async rig(t){return await this.#t(),await this.#e({op:"rig",...t?.object===void 0?{}:{object:t.object}})}async actionClip(t){return await this.#t(),await this.#e({op:"action-clip",...t?.object===void 0?{}:{object:t.object},...t?.bake===void 0?{}:{bake:t.bake}})}async outlinerSet(t,n,r){return await this.#t(),await this.#e({op:"outliner-set",path:t,column:n,value:r})}async present(){await this.#t(),await this.#e({op:"present"})}async screenshotView(t){return await this.#t(),await this.#e({op:"screenshot-view",maxSize:t})}async readFile(t){return await this.#t(),await this.#e({op:"read-file",path:t})}async writeFile(t,n){await this.#t(),await this.#e({op:"write-file",path:t,bytes:n})}async listFiles(t){return await this.#t(),await this.#e({op:"list-files",path:t})}get presented(){return this.#g}terminate(){this.#r.terminate();const t=new Error("The Blender session was terminated");for(const n of[...this.#n.keys()])this.#p(n);for(const n of this.#n.values())n.reject(t);this.#n.clear()}metrics(t=performance.now()){let n=null,r=this.#u,o=this.#f,a=this.#w;for(const l of this.#s.values()){const i=t-l;(n===null||i>n)&&(n=i),i>r&&(r=i),i>=5e3&&(o+=1),i>=3e4&&(a+=1)}return{inFlightMs:n===null?null:Math.round(n),lastCallMs:this.#i===null?null:Math.round(this.#i),maxCallMs:this.#i===null&&n===null?null:Math.round(r),callsOver5s:o,callsOver30s:a,lastCallWindow:this.#a,wasmMemoryMB:this.#d===null?null:Math.round(this.#d/1048576)}}#p(t){const n=this.#s.get(t);if(n===void 0)return;this.#s.delete(t);const r=performance.now()-n;this.#i=r,r>this.#u&&(this.#u=r),r>=5e3&&(this.#f+=1),r>=3e4&&(this.#w+=1),this.#a!==null&&this.#a.start===n&&(this.#a={start:n,end:n+r})}#e(t){const n=++this.#m;return new Promise((r,o)=>{this.#n.set(n,{resolve:r,reject:o});const a=performance.now();this.#s.set(n,a),this.#a={start:a,end:null},this.#r.postMessage({...t,id:n})})}async#b(t){if("op"in t){if(t.op==="log"){this.#c.log?.(t.level,t.text);return}if(t.op==="memory"){this.#d=t.bytes;return}const r=t.frame;typeof r?.session=="string"&&typeof r.revision=="number"&&(this.#g={session:r.session,revision:r.revision});try{const o=await this.#c.present(t.frame,t.description,t.capture);this.#r.postMessage({op:"present-result",id:t.id,...o?.capture===void 0?{}:{capture:o.capture},...o!=null&&"held"in o?{held:o.held}:{}})}catch(o){this.#r.postMessage({op:"present-result",id:t.id,error:o instanceof Error?o.message:String(o)})}return}const n=this.#n.get(t.id);n&&(this.#n.delete(t.id),this.#p(t.id),"error"in t?n.reject(new Error(t.error)):n.resolve(t.result))}}const nt="/assets/agx-base-srgb-BjWZJgrZ.lut",rt="/assets/agx-look-medium-high-contrast-D5F_ob1L.lut",ot="/assets/agx-look-punchy-dxsnycNs.lut",at="/assets/filmic-srgb-Ct35FIH6.lut",S=new Float64Array(12),ke=[0,0,0],R=new Float64Array(3),V=new Float64Array(3),A=new Int8Array([1,0,0,1,1,0,0,1,2,1,0,0,1,0,1,0,2,1,0,0,1,1,0,1,2,0,1,0,0,1,0,1,1,2,1,0,0,1,0,0,1,1,1,2,0,0,1,0,1,1,0,1,0,2]);function st(e,t,n){return e>t?t>n?0:e>n?1:2:n>t?3:n>e?4:5}function Be(e,t,n,r,o){const a=t*t,l=Math.min(1,Math.max(0,n))*(t-1),i=Math.min(1,Math.max(0,r))*(t-1),p=Math.min(1,Math.max(0,o))*(t-1),w=Math.min(Math.floor(l),t-2),s=Math.min(Math.floor(i),t-2),d=Math.min(Math.floor(p),t-2),k=l-w,g=i-s,c=p-d,b=(u,y,$,E)=>{const L=(w+y+(s+$)*t+(d+E)*a)*3;S[u]=e[L]/65535,S[u+1]=e[L+1]/65535,S[u+2]=e[L+2]/65535};b(0,0,0,0),b(9,1,1,1),R[0]=k,R[1]=g,R[2]=c;const h=st(k,g,c)*9;b(3,A[h],A[h+1],A[h+2]),b(6,A[h+3],A[h+4],A[h+5]);const M=R[A[h+6]],m=R[A[h+7]],f=R[A[h+8]];for(let u=0;u<3;u++){const y=S[u];ke[u]=y+M*(S[3+u]-y)+m*(S[6+u]-S[3+u])+f*(S[9+u]-S[6+u])}return ke}function W(e){const t=e&32768?-1:1,n=e>>10&31,r=e&1023;return n===0?t*2**-24*r:n===31?r?Number.NaN:t*Number.POSITIVE_INFINITY:t*2**(n-15)*(1+r/1024)}function pe(e,t,n,r){const o=new Uint8ClampedArray(t*4);for(let a=0;a<t;a++){const l=a*4,i=W(e[l+3]),p=i===0?n:n/i;V[0]=W(e[l])*p,V[1]=W(e[l+1])*p,V[2]=W(e[l+2])*p;const w=r(V);o[l]=Math.round(w[0]*255),o[l+1]=Math.round(w[1]*255),o[l+2]=Math.round(w[2]*255),o[l+3]=Math.round(Math.min(1,Math.max(0,i))*255)}return o}function it(e){return new URL(Object.assign({"./agx-base-srgb.lut":nt,"./agx-look-medium-high-contrast.lut":rt,"./agx-look-punchy.lut":ot,"./filmic-srgb.lut":at})[`./${e.replace(/\.lut$/,"")}.lut`],import.meta.url)}const lt=57,j=-12.47393,je=12.5260688117,ct=[[.4123908,.3575843,.1804808],[.212639,.7151687,.0721923],[.0193308,.1191948,.9505322]],ut=[[1.5250528,-.3159135,-.1226583],[-.5091526,1.3333274,.1382844],[.0957153,.0508974,.7879558]];function Ee(e,t,n){const r=t[0],o=t[1],a=t[2];n[0]=e[0][0]*r+e[0][1]*o+e[0][2]*a,n[1]=e[1][0]*r+e[1][1]*o+e[1][2]*a,n[2]=e[2][0]*r+e[2][1]*o+e[2][2]*a}const z=new Float64Array(3),Ce=new Float64Array(3),G=[0,0,0];function ee(e){const t=Math.min(1,Math.max(0,e));return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function Te(e,t,n,r){return Be(e,lt,t,n,r)}function dt(e,t){Ee(ct,t,Ce),Ee(ut,Ce,z);const n=je-j,r=Te(e,(Math.log2(Math.max(z[0],1e-10))-j)/n,(Math.log2(Math.max(z[1],1e-10))-j)/n,(Math.log2(Math.max(z[2],1e-10))-j)/n);return G[0]=ee(Math.max(0,r[0])**2.4),G[1]=ee(Math.max(0,r[1])**2.4),G[2]=ee(Math.max(0,r[2])**2.4),G}const pt={"AgX - Medium High Contrast":"agx-look-medium-high-contrast.lut","AgX - Punchy":"agx-look-punchy.lut"};function ht(e,t){const n=je-j;return Te(e,(Math.log2(Math.max(t[0],1e-10))-j)/n,(Math.log2(Math.max(t[1],1e-10))-j)/n,(Math.log2(Math.max(t[2],1e-10))-j)/n)}function ft(e,t,n,r={}){const o=r.exposure??1,a=r.composedLook===!0?ht:dt;return pe(t,n,o,l=>a(e,l))}const Le=33,ie=Le**3*3,le=4096,te=-12.473931188,ne=25;function re(e,t){const n=Math.min(1,Math.max(0,t))*(le-1),r=Math.min(Math.floor(n),le-2),o=n-r;return((1-o)*e[ie+r]+o*e[ie+r+1])/65535}const q=[0,0,0];function wt(e,t){const n=Be(e,Le,(Math.log2(Math.max(t[0],1e-10))-te)/ne,(Math.log2(Math.max(t[1],1e-10))-te)/ne,(Math.log2(Math.max(t[2],1e-10))-te)/ne);return q[0]=re(e,n[0]/.66),q[1]=re(e,n[1]/.66),q[2]=re(e,n[2]/.66),q}function gt(e,t,n,r){if(e.length!==ie+le)throw new Error("Invalid Blender Filmic display table");return pe(t,n,r,o=>wt(e,o))}const O=2.4,T=.055,Ie=T/(O-1),mt=1/(O/(1+T)*((Ie+T)/(1+T))**(O-1)),bt=((Ie+T)/(1+T))**O;function oe(e){return e>0?e<bt?e*mt:(1+T)*e**(1/O)-T:0}const H=[0,0,0];function yt(e){return H[0]=oe(e[0]),H[1]=oe(e[1]),H[2]=oe(e[2]),H}function Mt(e,t,n){return pe(e,t,n,yt)}function Re(e,t,n,r){if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<1||n.height<1)throw new Error("Scene capture requires finite positive dimensions");const o=Math.min(2048,Math.round(n.width)),a=Math.min(2048,Math.round(n.height)),l=r?1:2,i=o*l,p=a*l,w=De(),s=w.renderer,d={target:s.getRenderTarget(),toneMapping:s.toneMapping,exposure:s.toneMappingExposure,colorSpace:s.outputColorSpace,shadows:s.shadowMap.enabled,shadowType:s.shadowMap.type,clearColor:s.getClearColor(new ze),clearAlpha:s.getClearAlpha(),background:e.background};let k,g,c=!1;try{if(k=new Me(i,p,{type:Ge}),s.shadowMap.enabled=!0,s.shadowMap.type=qe,s.outputColorSpace=He,s.toneMapping=n.toneMapping??se,s.toneMappingExposure=n.exposure??1,s.setClearColor(0,n.transparent?0:1),n.transparent&&(e.background=null),s.setRenderTarget(k),s.clear(),s.render(e,t),r){const E=new Uint16Array(i*p*4);return s.readRenderTargetPixels(k,0,0,i,p,E),c=!0,{pixels:E,width:o,height:a}}g=new Me(i,p),Pe(n.transparent===!0).render(s,g,k,0,!1);const b=new Uint8Array(i*p*4);s.readRenderTargetPixels(g,0,0,i,p,b);const h=document.createElement("canvas");h.width=i,h.height=p;const M=h.getContext("2d");if(!M)throw new Error("Scene capture could not create an image canvas");const m=M.createImageData(i,p),f=i*4;for(let E=0;E<p;E++)m.data.set(b.subarray((p-1-E)*f,(p-E)*f),E*f);M.putImageData(m,0,0);const u=document.createElement("canvas");u.width=o,u.height=a;const y=u.getContext("2d");if(!y)throw new Error("Scene capture could not create an output canvas");y.drawImage(h,0,0,o,a);const $=u.toDataURL("image/png");return c=!0,$}finally{e.background=d.background,s.setRenderTarget(d.target),s.toneMapping=d.toneMapping,s.toneMappingExposure=d.exposure,s.outputColorSpace=d.colorSpace,s.shadowMap.enabled=d.shadows,s.shadowMap.type=d.shadowType,s.setClearColor(d.clearColor,d.clearAlpha),g?.dispose(),k?.dispose(),w.release({discard:!c})}}function xt(e,t,n){return Re(e,t,n,!0)}function vt(e,t,n){return Re(e,t,n,!1)}const kt={transform:{cx:0,cy:0,zoom:1},looked:null,refusal:null,size:{w:0,h:0},framedAt:0,drawn:[]};let ce=kt,he=0;const X=new Set;let Fe=0;function ae(){return ce}function Pt(){return he}function Vt(e){return X.add(e),()=>{X.delete(e)}}function U(e){ce={...ce,...e},he+=1;for(const t of[...X])t()}function Et(){Fe+=1,he+=1;for(const e of[...X])e()}function Wt(){return Fe}function F(e){U({refusal:e})}const Se=new Map;function Ct(e){let t=Se.get(e);return t||(t=fetch(it(e)).then(async n=>{if(!n.ok)throw new Error(`Blender display table ${e}: ${n.status} ${n.statusText}`);return new Uint16Array(await n.arrayBuffer())}),Se.set(e,t)),t}function St(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new Uint16Array(n.buffer,n.byteOffset,n.byteLength>>1)}async function Ae(e,t){const n=t.look??"None",r=t.toneMapping==="filmic",o=t.toneMapping==="none";if(!o&&t.toneMapping!=="agx"&&!r)throw new Error("Blender's Khronos PBR Neutral view transform has no scene-linear implementation in the browser, so it cannot resolve a composited or scene-referred frame (implemented: Standard, AgX, Filmic)");const a=o?null:r?"filmic-srgb.lut":n==="None"?"agx-base-srgb.lut":pt[n];if(a===void 0)throw new Error(`Blender display transform has no table for look ${n}`);const l=a?await Ct(a):null,i=t.linearInput,p=i?{pixels:St(i.base64),width:i.width,height:i.height}:e;if(!p)throw new Error("Blender display transform requires a linear capture");const{pixels:w,width:s,height:d}=p,k=o?Mt(w,s*d,t.exposure):r?gt(l,w,s*d,t.exposure):ft(l,w,s*d,{exposure:t.exposure,composedLook:n!=="None"}),g=document.createElement("canvas");g.width=s,g.height=d;const c=g.getContext("2d");if(!c)throw new Error("Blender display transform could not create its image canvas");const b=c.createImageData(s,d),h=s*4;for(let f=0;f<d;f++){const u=(d-1-f)*h;b.data.set(k.subarray(u,u+h),f*h)}c.putImageData(b,0,0);const M=g.toDataURL("image/png"),m={base64:M.slice(M.indexOf(",")+1),mimeType:"image/png"};if(t.linear===!0){const f=new Uint8Array(w.buffer,w.byteOffset,w.byteLength);let u="";for(let y=0;y<f.length;y+=32768)u+=String.fromCharCode(...f.subarray(y,y+32768));m.linearBase64=btoa(u),m.linearWidth=s,m.linearHeight=d}return m}const At="document:blender:runtime";let Z=null;function _t(e){Z=e}function I(){return Z?.documentId??At}function zt(){return I()}async function Gt(e,t,n){_t({documentId:e,entryId:n,blend:t});const r=N();if(!r.session.open())return;const o=r.projectLocalState.projectRootPath();o!==null&&(await v().start(o,t),await v().present())}function B(){return _?.project!=null}let Ne=0;const ue=new Set;function qt(){return Ne}function Ht(e){return ue.add(e),()=>{ue.delete(e)}}function fe(){Ne+=1;for(const e of[...ue])e()}async function Xt(e,t){return B()?v().rna(e,t):null}async function Zt(e,t){return B()?v().rnaContext(e,t):null}async function Bt(e,t,n,r){if(!B())return null;const o=await v().rnaSet(e,t,n,r);return fe(),o}async function jt(e){const t=await v().execute(e);fe();const n=/^Error executing code:/.exec(t);return{text:t,executed:n===null,result:n===null?t.replace(/^Code executed successfully: ?/,""):"",error:n===null?null:t.replace(/^Error executing code: ?/,"")}}async function Kt(e){return B()?v().outliner(e):null}async function Yt(e){return B()?v().nodeTree(e):null}async function Jt(e){return B()?v().uvLayout(e):null}async function Qt(e){return B()?v().rig(e):null}async function en(e){return B()?v().actionClip(e):null}async function Tt(e,t,n){if(!B())return null;const r=await v().outlinerSet(e,t,n);return fe(),r}const Lt={view:"blender-node-view",title:"Node Editor",verbs:[["state",void 0],["look",void 0],["view-all","Node Editor: Frame All"],["zoom",void 0],["pan",void 0],["move",void 0],["link",void 0],["set-value",void 0],["use-nodes",void 0],["collapse-panel",void 0]].map(([e,t])=>({id:e,...t?{title:t}:{},run:n=>$e({...n,action:e})}))};function $e(e){const t=typeof e.action=="string"?e.action:"state";switch(t){case"state":break;case"look":U({looked:typeof e.node=="string"?e.node:null,refusal:null});break;case"view-all":Et(),U({refusal:null});break;case"zoom":{const n=typeof e.zoom=="number"?e.zoom:1;U({transform:{...ae().transform,zoom:n},refusal:null});break}case"pan":{const n=ae().transform;U({transform:{...n,cx:typeof e.cx=="number"?e.cx:n.cx,cy:typeof e.cy=="number"?e.cy:n.cy},refusal:null});break}case"move":F(`Moving "${String(e.node??"a node")}" writes Node.location — editing parity is not the program.`);break;case"link":F("Dragging between sockets would make a link — editing parity is not the program.");break;case"set-value":F(`Changing "${String(e.socket??"a socket")}" writes the socket's default_value — editing parity is not the program.`);break;case"use-nodes":F("Use Nodes writes Material.use_nodes — editing parity is not the program.");break;case"collapse-panel":F(`Collapsing "${String(e.panel??"a panel")}" writes the panel's is_collapsed — editing parity is not the program.`);break;default:F(`blender-node-view: no action "${t}" — state, look, view-all, zoom, pan, and the refusals move, link, set-value, use-nodes, collapse-panel.`)}return ae()}let _=null,de=null,_e=!1;function Ue(){de?.abort(),de=null,_?.terminate(),_=null}function It(){_e||(_e=!0,N().session.onEnded(Ue))}const Rt=e=>typeof e=="object"&&e!==null&&typeof e.applyFrame=="function"&&typeof e.snapshot=="function"&&typeof e.captureSnapshot=="function"&&typeof e.recordPresentation=="function"&&typeof e.recordPhotograph=="function";async function Ft(){const{documents:e}=N(),t=await e.waitForContext(I(),15e3);if(Rt(t))return t;throw new Error('The Blender Model document is not open, or the open one is not a Model this engine can present to (it must answer applyFrame, captureSnapshot, recordPresentation and recordPhotograph): present {kind: "document", id: "blender:runtime"} first (it ships with the editor; `vgai blender-mcp` presents it before its first call).')}function v(){if(_!==null)return _;It();const e=new AbortController;de=e;let t=!1;_=new tt({present:async(r,o,a)=>{const l=I(),i=await Ft();if(e.signal.throwIfAborted(),I()!==l)throw new Error("Blender document changed before its frame could be presented");const p=i.applyFrame(r),w=typeof p=="object"&&p!==null&&"held"in p,s=w?p.held:null,d=f=>({...f===void 0?{}:{capture:f},...w?{held:s}:{}});if(i.recordPresentation(o),!a||!a.render)return d(void 0);const k=i.snapshot(),g=()=>{if(e.signal.throwIfAborted(),I()!==l||i.snapshot()!==k)throw new Error("Blender capture document or source revision changed before completion")};if(a.render.linearInput){const f=await Ae(null,a.render);return g(),d(f)}const{render:c,position:b,target:h,up:M}=a;if(!b||!h||!M)throw new Error("A Blender render capture must carry the scene camera position, target and up");if(t)throw new Error("A Blender render capture is already in progress");const m=i.captureSnapshot();t=!0,e.signal.addEventListener("abort",m.dispose,{once:!0});try{g();const f=new Xe;f.add(m.root),f.updateMatrixWorld(!0);const u=m.root.matrixWorld,y=new Ze().copy(u).invert(),$=new xe().setFromMatrix4(u),E=new xe().setFromMatrix4(y),L=new Q(b[0],b[1],b[2]).applyMatrix4(u),we=new Q(h[0],h[1],h[2]).applyMatrix4(u),ge=new Q(M[0],M[1],M[2]).applyMatrix3($),K=Math.min(2048,Math.round(c.width))/Math.min(2048,Math.round(c.height)),me=Ve(m.root).getBoundingSphere(new Ke),D=et(L.distanceTo(me.center),me.radius);let C;if(c.orthographic){const P=c.fov/2;C=new Ye(-P*K,P*K,P,-P,D.near,D.far)}else C=new Je(c.fov,K,D.near,D.far);C.up.copy(ge),C.position.copy(L),C.lookAt(we),C.updateMatrixWorld(!0);const Y={position:L.clone().applyMatrix4(y).toArray(),target:we.clone().applyMatrix4(y).toArray(),up:ge.clone().applyMatrix3(E).toArray()};i.recordPhotograph({sent:{position:b,target:h,up:M},photographed:Y,render:{width:c.width,height:c.height,fov:c.fov,orthographic:c.orthographic}});const Oe={none:se,agx:ve,neutral:Qe,filmic:se};await m.prepare(C),g();const be={width:c.width,height:c.height,transparent:c.transparent===!0,toneMapping:Oe[c.toneMapping]??ve,exposure:c.exposure},ye=c.toneMapping==="agx"||c.toneMapping==="filmic"||c.linear===!0?await Ae(xt(f,C,be),c):null;if(g(),ye)return d({...ye,camera:Y});const J=vt(f,C,be);if(!J)throw new Error("Blender render could not capture its image");return d({base64:J.slice(J.indexOf(",")+1),mimeType:"image/png",camera:Y})}finally{t=!1,e.signal.removeEventListener("abort",m.dispose),m.dispose()}},log:(r,o)=>(r==="error"?console.error:console.log)(`[blender] ${o}`)});const n=_;return N().session.reportWorkerCallMeter(()=>n.metrics()),_}const Nt="models/model.blend",x=(e,t)=>{const n=e[t];if(typeof n!="string")throw new Error(`${String(e.type)} requires a string "${t}"`);return n};async function $t(e){const t=N().projectLocalState.projectRootPath();if(t===null)return{};let n;try{n=await e.execute(`import bpy
2
+ print(bpy.data.filepath)
3
+ `)}catch{return{}}if(/^Error executing code:/m.test(n))return{};const r=n.replace(/^Code executed successfully:/,"").split(`
4
+ `).map(a=>a.trim()).filter(a=>a.startsWith("/")).pop()??"";if(r==="")return{};const o=t.endsWith("/")?t:`${t}/`;return r.startsWith(o)?{document:r.slice(o.length)}:{}}async function tn(e){const t=N();if(e.type==="blender-status")return{ok:!0,data:{started:_?.project!=null,document:t.documents.context(I())!==void 0}};if(!t.session.open())return{ok:!1,error:`${e.type} needs an open project session; this editor page has none.`};try{const n=e.type==="blender-start"?x(e,"project"):null;if((e.type==="blender-stop"||e.type==="blender-start"&&e.fresh===!0)&&(Ue(),e.type==="blender-stop"))return{ok:!0,data:{stopped:!0}};if(e.type==="blender-start"&&!t.documents.context(I())&&!await t.workspace.open({kind:"document",id:"blender:runtime"}))return{ok:!1,error:"blender-start could not open the Blender Model document: nothing in this editor opens {kind: 'document', id: 'blender:runtime'} (it ships with @volter/editor-blender)."};const r=v();switch(e.type){case"blender-start":{const o=typeof e.document=="string"?e.document:Z?.blend??Nt;return{ok:!0,data:{...await r.start(n,o)}}}case"blender-execute":return{ok:!0,data:{result:(await jt(x(e,"code"))).text}};case"blender-scene-info":return{ok:!0,data:{result:await r.sceneInfo()}};case"blender-object-info":return{ok:!0,data:{result:await r.objectInfo(x(e,"name"))}};case"blender-rna":{const o=typeof e.names=="number"?e.names:void 0;return{ok:!0,data:{result:await r.rna(x(e,"path"),o)}}}case"blender-rna-context":{const o=typeof e.object=="string"?e.object:void 0,a=typeof e.collection=="string"?e.collection:void 0;return{ok:!0,data:{result:await r.rnaContext(o,a)}}}case"blender-rna-set":{const o=typeof e.index=="number"?e.index:void 0;return{ok:!0,data:{result:await Bt(x(e,"path"),x(e,"property"),e.value,o)}}}case"blender-outliner":{const o=Array.isArray(e.selected)?e.selected.filter(a=>typeof a=="string"):void 0;return{ok:!0,data:{result:await r.outliner(o)}}}case"blender-node-tree":return{ok:!0,data:{result:await r.nodeTree({...typeof e.path=="string"?{path:e.path}:{},...typeof e.material=="string"?{material:e.material}:{}})}};case"blender-uv-layout":return{ok:!0,data:{result:await r.uvLayout({...typeof e.object=="string"?{object:e.object}:{},...typeof e.uvLayer=="string"?{uvLayer:e.uvLayer}:{}})}};case"blender-rig":return{ok:!0,data:{result:await r.rig({...typeof e.object=="string"?{object:e.object}:{}})}};case"blender-action-clip":return{ok:!0,data:{result:await r.actionClip({...typeof e.object=="string"?{object:e.object}:{},...typeof e.bake=="boolean"?{bake:e.bake}:{}})}};case"blender-node-view":{const o=typeof e.action=="string"?e.action:"state";return{ok:!0,data:{result:Lt.verbs.some(l=>l.id===o)?We("blender-node-view",o,e):$e(e)}}}case"blender-outliner-set":return{ok:!0,data:{result:await Tt(x(e,"path"),x(e,"column"),e.value!==!1)}};case"blender-screenshot-view":{const o=typeof e.maxSize=="number"?e.maxSize:1e3,a={kind:"document",id:Z?.entryId??"blender:runtime"};return{ok:!0,data:{...await r.screenshotView(o),document:a}}}case"blender-read-file":{const o=await r.readFile(x(e,"path")),a=x(e,"transferId"),l=await fetch(`/__editor/blender-file?id=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/octet-stream"},body:new Blob([o])});return l.ok?{ok:!0,data:{bytes:o.length}}:{ok:!1,error:`Transfer ${a} was refused: ${l.status}`}}case"blender-write-file":{const o=atob(x(e,"base64")),a=Uint8Array.from(o,l=>l.charCodeAt(0));return await r.writeFile(x(e,"path"),a),{ok:!0,data:{written:a.length}}}case"blender-list-files":{const o=await r.listFiles(x(e,"path")),a=r.presented;return{ok:!0,data:{entries:o,...a?{session:a.session,revision:a.revision}:{},...await $t(r)}}}}return{ok:!1,error:`Unknown Blender command ${e.type}`}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}export{Lt as N,zt as a,B as b,Tt as c,Kt as d,qt as e,Vt as f,U as g,tn as h,ae as i,Yt as j,Wt as k,en as l,Qt as m,Pt as n,Jt as o,Bt as p,jt as q,F as r,Ht as s,Gt as t,_t as u,fe as v,Zt as w,Xt as x};
@@ -0,0 +1,61 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RectAreaLightUniformsLib-BGT7Bu4n.js","assets/three.module-BynznMJN.js"])))=>i.map(i=>d[i]);
2
+ import{L as rn,a as an,b as cn}from"./LineSegments2-vfeDUBfs.js";import{aB as it,af as Le,V as x,x as at,aa as Fe,aC as _t,g as Be,_ as ln,a0 as kt,bp as un,b1 as Ue,d as vt,i as Pt,a as hn,bv as mn,ab as pt,b as tt,Q as dn,as as fn,av as je,aY as ze,p as rt,b3 as pn,b8 as gn,c as yn,K as De,v as We,H as vn,bn as wn,L as Kt,b5 as bn,b4 as Mn,bQ as xn,b9 as Ft,P as wt,ap as jt,y as Sn,O as An,F as En,bJ as Tn,Y as Rn,ad as _n,am as On,bl as In,bR as Nn,bx as kn,J as ae,bE as ce,f as le,q as Ge,j as Cn,a1 as Pn,bu as Ln,aN as Fn,b6 as Bn,aM as Un,aP as jn,aO as zn,a$ as Dn,aQ as Wn,bS as Gn}from"./three.module-BynznMJN.js";import{o as A,a as C,s as _,c2 as H,c3 as Q,c4 as O,c5 as G,_ as $n,c6 as Vn,c7 as ne,l as U,bA as ct,c8 as Hn,c9 as z,ca as Yn,cb as qn}from"./index-5av5LJja.js";import{p as Kn}from"./blender-runtime-host-D8NHsAfD.js";function ue(e){const t=atob(e),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}const At=O().finite(),Xn=A({name:_(),parent:_().nullable(),connected:H(),hide:H(),length:At,matrix:C(G([At,At,At,At])).length(4),select:H(),active:H(),lockedWeight:H()}).strict(),Qn=A({object:_(),displayType:Q(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:H(),mode:_(),bones:C(Xn)}).strict(),et={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function Jn(e){return new vt(e.r*e.r*.1,e.g*e.g*.1,e.b*e.b*.1)}const Wt=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],he=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],lt=Math.SQRT1_2,Zn=[[lt,-lt,0],[0,-lt,-lt],[-lt,-lt,0],[0,-lt,lt],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],ts=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],es=.05;function me(e){return e.select||e.active?2:1}const ns=10,ss=4,os=`
3
+ attribute vec3 aSolid;
4
+ attribute vec3 aHint;
5
+ varying vec3 vColor;
6
+ void main() {
7
+ vec3 n = normalize(normalMatrix * normal);
8
+ float d = dot(n, vec3(0.1, 0.1, 0.8));
9
+ float fac = clamp(d * 0.8 + 0.2, 0.0, 1.0);
10
+ vColor = mix(aHint, aSolid, fac * fac);
11
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
12
+ }
13
+ `,rs=`
14
+ varying vec3 vColor;
15
+ void main() {
16
+ gl_FragColor = vec4(vColor, 1.0);
17
+ #include <colorspace_fragment>
18
+ }
19
+ `;function ht(e){return new vt().setHex(e,Pt)}function de(e,t){const n=e.mode==="POSE";let s;return n?t.active&&t.select?s=ht(et.poseActive):t.active?s=ht(et.poseActiveUnsel):t.select?s=ht(et.pose):s=ht(et.wire):s=ht(et.vertex),n&&t.lockedWeight&&s.lerp(ht(et.lockedWeight),et.lockedWeightFactor),s}function fe(e,t){const n=ht(et.solid);return e.mode==="POSE"&&t.lockedWeight&&n.lerp(ht(et.lockedWeight),et.lockedWeightFactor),n}const is=new at,as=new x,pe=new Le;function ge(e,t){return new at().set(...t.matrix.flat()).premultiply(e).scale(new x().setScalar(t.length))}class cs{constructor(){this.group=new it,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const s=[],o=JSON.stringify(t);if(o===this.signature)return s;this.signature=o,this.clear();for(const a of Object.values(t)){const c=n(a.object);if(c===null)continue;a.displayType!=="OCTAHEDRAL"&&a.displayType!=="STICK"&&s.push(`armature ${a.object}: Blender's ${a.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),a.mode==="EDIT"&&s.push(`armature ${a.object}: in Edit Mode Blender draws the EDIT bones, and this overlay draws the pose — the shapes are the rest pose, not the edited one`);const r=a.bones.filter(l=>!l.hide);if(r.length===0)continue;const h=a.displayType==="STICK"?this.buildStick(a,r,c):this.buildOctahedral(a,r,c);a.showInFront&&h.traverse(l=>{const i=l.material;i&&"depthTest"in i&&(i.depthTest=!1),l.renderOrder=10}),this.group.add(h)}return s}buildOctahedral(t,n,s){const o=new it;o.name=`${t.object}:bones`;const a=[],c=[],r=[],h=[],l=[],i=[],u=[],d=[],f=[],p=[];for(const m of n){const g=ge(s,m),y=fe(t,m),v=Jn(y),N=de(t,m);pe.setFromMatrix4(g).invert().transpose();for(let M=0;M<he.length;M++){const F=as.set(...Zn[M]).applyMatrix3(pe).normalize().clone();for(const R of he[M]){const S=new x(...Wt[R]).applyMatrix4(g);a.push(S.x,S.y,S.z),c.push(F.x,F.y,F.z),r.push(y.r,y.g,y.b),h.push(v.r,v.g,v.b)}}const k=me(m)===2?u:l,P=me(m)===2?d:i;for(const[M,F]of ts){const R=new x(...Wt[M]).applyMatrix4(g),S=new x(...Wt[F]).applyMatrix4(g);k.push(R.x,R.y,R.z,S.x,S.y,S.z),P.push(N.r,N.g,N.b,N.r,N.g,N.b)}m.parent!==null&&m.connected||(f.push(g.clone()),p.push(y)),f.push(g.clone().multiply(is.makeTranslation(0,1,0))),p.push(y)}o.add(this.solidMesh(a,c,r,h)),l.length&&o.add(this.lines(l,i,1)),u.length&&o.add(this.lines(u,d,2));for(let m=0;m<f.length;m++)o.add(this.point(f[m],p[m]));return o}buildStick(t,n,s){const o=new it;o.name=`${t.object}:bones`;const a=[],c=[],r=[],h=[];for(const l of n){const i=ge(s,l),u=new x().setFromMatrixPosition(i),d=new x(0,1,0).applyMatrix4(i),f=de(t,l),p=fe(t,l);a.push(u.x,u.y,u.z,d.x,d.y,d.z),c.push(f.r,f.g,f.b,f.r,f.g,f.b),r.push(u.x,u.y,u.z,d.x,d.y,d.z),h.push(p.r,p.g,p.b,p.r,p.g,p.b)}return o.add(this.lines(a,c,ns)),o.add(this.lines(r,h,ss)),o}solidMesh(t,n,s,o){const a=new Fe;a.setAttribute("position",new _t(t,3)),a.setAttribute("normal",new _t(n,3)),a.setAttribute("aSolid",new _t(s,3)),a.setAttribute("aHint",new _t(o,3));const c=new Be({vertexShader:os,fragmentShader:rs,side:ln});this.disposables.push(a,c);const r=new kt(a,c);return r.frustumCulled=!1,r}lines(t,n,s){const o=new rn;o.setPositions(t),o.setColors(n);const a=new an({linewidth:s,vertexColors:!0});this.disposables.push(o,a);const c=new cn(o,a);return c.frustumCulled=!1,c}point(t,n){const s=new un(es,12,8),o=new Ue({color:n});this.disposables.push(s,o);const a=new kt(s,o);return a.applyMatrix4(t),a.frustumCulled=!1,a}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const ls="RUNTIME_FRAME_UNKNOWN_GEOMETRY",ye="RUNTIME_FRAME_UNKNOWN_IMAGE";function us(e){const t=Math.fround,n=t(t(t(e[0]*e[0])+t(e[1]*e[1]))+t(e[2]*e[2]));if(n>1e-35){const s=t(Math.sqrt(n)),o=t(1/s);return{unit:[t(e[0]*o),t(e[1]*o),t(e[2]*o)],length:s}}return{unit:[0,0,0],length:0}}const b=Math.fround,zt=b(2*Math.PI),Gt=b(1-1e-4),ft=(e,t)=>b(b(b(e[0]*t[0])+b(e[1]*t[1]))+b(e[2]*t[2])),Nt=(e,t,n=1)=>e.map((s,o)=>b(s+b(t[o]*n))),hs=(e,t)=>e.map((n,s)=>b(n-t[s]));function Et(e){const t=b(Math.sqrt(ft(e,e)));return t>0?e.map(n=>b(n/t)):[0,0,0]}function Tt(e){const t=Math.abs(e)<1?b(1-b(1-Math.abs(e))):1;let n=b(b(.077980478)+b(t*b(-.02164095)));n=b(b(-.213300989)+b(t*n)),n=b(b(1.5707963267)+b(t*n));const s=b(b(Math.sqrt(b(1-t)))*n);return e<0?b(b(Math.PI)-s):s}function ms(e){let t=e.at(-1);const n=[0,0,0];for(const s of e){for(let o=0;o<3;o++){const a=(o+1)%3,c=(o+2)%3;n[o]=b(n[o]+b(b(t[a]-s[a])*b(t[c]+s[c])))}t=s}return n}function ds(e){const t=[],n=[],s=(p,m)=>p<m?`${p}:${m}`:`${m}:${p}`,o=new Map((e.edge_order??[]).map(([p,m],g)=>[s(p,m),g])),a=new Set((e.sharp??[]).map(([p,m])=>s(p,m))),c=new Map;for(const[p,m]of e.f.entries()){const g=t.length,y=us(ms(m.map(v=>e.v[v]))).unit;n.push(y.some(Boolean)?y:[0,0,1]);for(let v=0;v<m.length;v++){const N=s(m[v],m[(v+1)%m.length]);o.has(N)||o.set(N,o.size);const k=e.face_edges?.[p]?.[v]??o.get(N),P=t.length;t.push({vertex:m[v],face:p,edge:k,prev:g+(v+m.length-1)%m.length,next:g+(v+1)%m.length});const M=c.get(k)??[];M.push(P),c.set(k,M)}}const r=new Map,h=new Map;for(const[p,m]of c){if(m.length!==2||e.edge_sharp?.[p])continue;const[g,y]=m,v=t[g],N=t[y];!e.s?.[v.face]||!e.s?.[N.face]||v.vertex!==t[N.next].vertex||N.vertex!==t[v.next].vertex||!e.edge_sharp&&a.has(s(v.vertex,N.vertex))||(h.set(g,N.next),r.set(N.next,g),h.set(y,v.next),r.set(v.next,y))}const l=[],i=[],u=[],d=[],f=(p,m)=>Et(hs(e.v[t[t[p][m]].vertex],e.v[t[p].vertex]));for(let p=0;p<t.length;p++){if(i[p]!==void 0)continue;let m=p;const g=new Set([m]);for(;h.has(m)&&!g.has(h.get(m));)m=h.get(m),g.add(m);h.has(m)&&(m=Math.min(...g));const y=[m];for(;r.has(y.at(-1))&&r.get(y.at(-1))!==m;)y.push(r.get(y.at(-1)));let v=[0,0,0];if(y.length===1)v=n[t[m].face];else{for(const S of y)v=Nt(v,n[t[S].face],Tt(ft(f(S,"prev"),f(S,"next"))));v=Et(v)}const N=f(m,"next"),k=y.at(-1),P=f(k,"prev"),M=ft(N,v),F=ft(P,v),R={normal:v,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(M)<Gt&&Math.abs(F)<Gt){const S=y.length>1?y.map(B=>f(B,"next")):[];S.length&&t[t[k].prev].edge!==t[m].edge&&S.push(P),R.alpha=S.length?b(S.reduce((B,D)=>b(B+Tt(ft(D,v))),0)/S.length):b(b(Tt(M)+Tt(F))/2),R.reference=Et(Nt(N,v,-M));const L=v,j=R.reference;R.ortho=Et([b(b(L[1]*j[2])-b(L[2]*j[1])),b(b(L[2]*j[0])-b(L[0]*j[2])),b(b(L[0]*j[1])-b(L[1]*j[0]))]);const nt=Et(Nt(P,v,-F)),w=ft(R.reference,nt),I=Tt(w);R.beta=w<Gt?ft(R.ortho,nt)<0?b(zt-I):I:zt}R.alpha===0&&(R.normal=[0,0,0]);for(const S of y)i[S]=l.length;l.push(y),u.push(R),d.push(v)}return{corners:t,fans:l,fanOf:i,spaces:u,faceNormals:n,fanNormals:d}}function fs(e,t){if(!t[0]||e.alpha===0||e.beta===0)return e.normal;const n=b(t[0]/32767),s=b(t[1]/32767),o=b((n>0?e.alpha:b(zt-e.alpha))*n),a=b((s>0?e.beta:b(zt-e.beta))*s);let c=e.normal.map(r=>b(r*b(Math.cos(o))));return c=Nt(c,e.reference,b(b(Math.sin(o))*b(Math.cos(a)))),s!==0&&(c=Nt(c,e.ortho,b(b(Math.sin(o))*b(Math.sin(a))))),c}function $e(e,t){if(!t)return null;const{corners:n,fans:s,spaces:o}=ds(e);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const a=new Array(n.length);for(const[c,r]of s.entries()){const h=r.reduce((i,u)=>{const d=t.data[u];return[i[0]+d[0],i[1]+d[1]]},[0,0]),l=fs(o[c],h.map(i=>Math.trunc(i/r.length)));for(const i of r)a[i]=l}return a}if(t.type==="FLOAT_VECTOR")return n.map((a,c)=>{const r=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:c;return t.data[r]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const $t={FLOAT:{size:1},INT:{size:1},INT8:{size:1},BOOLEAN:{size:1},FLOAT2:{size:2},FLOAT_VECTOR:{size:3},FLOAT_COLOR:{size:4},BYTE_COLOR:{size:4},INT16_2D:{size:2},INT32_2D:{size:2},QUATERNION:{size:4},FLOAT4X4:{size:16},FLOAT4:{size:4},STRING:{size:1}},ps=1e-6;function gs(e){const t=new x;for(let n=0;n<e.length;n++){const s=e[n],o=e[(n+1)%e.length];t.x+=(s.y-o.y)*(s.z+o.z),t.y+=(s.z-o.z)*(s.x+o.x),t.z+=(s.x-o.x)*(s.y+o.y)}return t.multiplyScalar(.5)}const ys=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),ve=e=>Array.from({length:e-2},(t,n)=>[0,n+1,n+2]);function vs(e){let t=0;for(let n=0;n<e.length;n++){const s=e[n],o=e[(n+1)%e.length];t+=s.x*o.y-o.x*s.y}return t}function we(e,t,n){if(e.length!==t.length-2||!(Math.abs(n)>0))return!1;const s=Math.sign(n);let o=0;for(const[a,c,r]of e){const h=ys(t[a],t[c],t[r]);if(h*s<0)return!1;o+=Math.abs(h)}return Math.abs(o-Math.abs(n))<=ps*Math.abs(n)}function ws(e){const t=e.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=gs(e),s=n.length();if(!(s>0)||!Number.isFinite(s))return{triangles:ve(t),sound:!1,method:"fan"};const o=n.clone().divideScalar(s),a=Math.abs(o.x)<.9?new x(1,0,0):new x(0,1,0),c=new x().crossVectors(a,o).normalize(),r=new x().crossVectors(o,c),h=e[0],l=e.map(f=>{const p=f.clone().sub(h);return new hn(p.dot(c),p.dot(r))}),i=vs(l),u=ve(t);if(we(u,l,i))return{triangles:u,sound:!0,method:"fan"};let d=[];try{d=mn.triangulateShape(l,[]).map(f=>[f[0],f[1],f[2]])}catch{return{triangles:u,sound:!1,method:"fan"}}return we(d,l,i)?{triangles:d,sound:!0,method:"earcut"}:{triangles:d.length>0?d:u,sound:!1,method:d.length>0?"earcut":"fan"}}function Ve(e){const t=e.vertexCount,n=e.starts.length-1,s=e.starts,o=e.cornerVerts,a=s[n];let c=t;for(let w=0;w<n;w++)c+=(s[w+1]-s[w]-2)*3;const r=new Uint32Array(a),h=new Uint8Array(a),l=new Uint8Array(t),i=new Uint32Array(a);let u=!1;for(let w=0;w<n;w++)if(e.smooth(w)){u=!0;break}const d=(w,I)=>t<94906265?Math.min(w,I)*t+Math.max(w,I):`${Math.min(w,I)}:${Math.max(w,I)}`,f=new Map,p=new Set;for(const[w,I]of e.sharp)p.add(d(w,I));if(e.edges)for(const[w,I]of e.edges){if(w===I)throw new Error("Runtime mesh edge needs distinct vertices");f.set(d(w,I),-1)}const m=w=>{for(;i[w]!==w;)i[w]=i[i[w]],w=i[w];return w},g=(w,I)=>{const B=m(w),D=m(I);i[Math.max(B,D)]=Math.min(B,D)};for(let w=0;w<n;w++){const I=s[w],B=s[w+1]-I,D=e.smooth(w)?1:0;for(let $=0;$<B;$++){const E=I+$;l[o[E]]=1,r[E]=I+($+1)%B,h[E]=D,i[E]=E}}for(let w=0;w<a;w++){const I=r[w],B=o[w],D=o[I],$=d(B,D),E=f.get($);if(E!==void 0&&E>=0&&h[w]&&h[E]&&!p.has($)){const J=r[E];g(w,o[E]===B?E:J),g(I,o[E]===B?J:E)}(E===void 0||E<0||!h[E]&&h[w])&&f.set($,w)}const y=e.uv,v=new Float32Array(c*3),N=new Float32Array(c*2),k=new Uint32Array(c),P=new Uint32Array(c),M=new Map,F=[],R=e.normals?new Float32Array(c*3):null;let S=0,L=0;const j=(w,I,B)=>{const D=S++;return k[D]=w,e.co(w).toArray(v,D*3),I&&N.set(I,D*2),B&&R.set(B,D*3),D},nt=w=>{const I=y?.(w),B=e.normals?.[w];if(!u)return j(o[w],I,B);const D=`${h[w]?m(w):w}${I?`:${I[0]}:${I[1]}`:""}${B?`:n${B.join(":")}`:""}`;let $=M.get(D);return $===void 0&&($=j(o[w],I,B),M.set(D,$)),$};for(let w=0;w<n;w++){const I=L,B=s[w],D=s[w+1]-B,$=[];for(let Z=0;Z<D;Z++)$.push(e.co(o[B+Z]));for(const Z of ws($).triangles)for(const Lt of Z)P[L++]=nt(B+Lt);const E=e.material(w),J=F.at(-1);J?.materialIndex===E?J.count+=L-I:F.push({start:I,count:L-I,materialIndex:E})}for(let w=0;w<t;w++)l[w]||j(w);return{positions:v.slice(0,S*3),normals:R?.slice(0,S*3)??null,uv:y?N.slice(0,S*2):null,indices:P.slice(0,L),sourceVertex:k.slice(0,S),groups:F}}function Xt(e){const t=new Fe;t.setAttribute("position",new pt(e.positions,3)),t.setAttribute("uv",new pt(e.uv??new Float32Array(e.positions.length/3*2),2)),t.setIndex(new pt(e.indices,1));for(const n of e.groups)t.addGroup(n.start,n.count,n.materialIndex);return e.normals?t.setAttribute("normal",new pt(e.normals,3)):t.computeVertexNormals(),e.sourceVertex&&t.setAttribute("blenderVertex",new pt(e.sourceVertex,1)),t}function bs(e,t){const n=e.co.length/3,s=e.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),o=e.renderUv??e.activeUv??s[0]?.name,a=s.find(m=>m.name===o);if(o&&!a)throw new Error(`Runtime UV map ${o} is missing`);const c=a?a.data:null,r=e.edge.length/2,h=new Array(r);for(let m=0;m<r;m++)h[m]=[e.edge[m*2],e.edge[m*2+1]];const l=[];for(let m=0;m<r;m++)e.edgeSharp[m]===1&&l.push(h[m]);const i=e.attributes.find(m=>m.name==="custom_normal"),u=i?{v:Array.from({length:n},(m,g)=>[e.co[g*3],e.co[g*3+1],e.co[g*3+2]]),f:Array.from({length:e.faceStart.length-1},(m,g)=>Array.from(e.corner.subarray(e.faceStart[g],e.faceStart[g+1]))),s:Array.from(e.smooth,Boolean),edge_order:h,sharp:l,face_edges:Array.from({length:e.faceStart.length-1},(m,g)=>Array.from(e.cornerEdge.subarray(e.faceStart[g],e.faceStart[g+1]))),edge_sharp:Array.from(e.edgeSharp,Boolean)}:null,d=i?{type:i.type,domain:i.domain,data:Array.from({length:i.data.length/$t[i.type].size},(m,g)=>Array.from({length:$t[i.type].size},(y,v)=>Number(i.data[g*$t[i.type].size+v])))}:void 0,f=new x,p={vertexCount:n,normals:u?$e(u,d):null,co:m=>f.set(e.co[m*3],e.co[m*3+1],e.co[m*3+2]).clone(),starts:e.faceStart,cornerVerts:e.corner,smooth:m=>e.smooth[m]===1,material:m=>e.material[m],edges:h,sharp:l,uv:c?m=>[c[m*2],c[m*2+1]]:null};return{...Ve(p),hash:t}}function Ms(e){const t=e.v.map(u=>new x(...u)),n=u=>{const d=t[u];if(!d)throw new Error(`Runtime mesh vertex ${u} is missing`);return d},s=new Uint32Array(e.f.length+1);e.f.forEach((u,d)=>{if(u.length<3||new Set(u).size!==u.length)throw new Error("Runtime mesh face needs at least three distinct vertices");s[d+1]=s[d]+u.length});const o=new Uint32Array(s[e.f.length]);e.f.forEach((u,d)=>u.forEach((f,p)=>{n(f),o[s[d]+p]=f}));for(const[u,d]of e.edge_order??e.e??[])n(u),n(d);const a={POINT:t.length,EDGE:(e.edge_order??e.e??[]).length,FACE:e.f.length,CORNER:o.length};for(const u of e.attributes??[])if(u.domain!=="EDGE"&&u.data.length!==a[u.domain])throw new Error(`Runtime attribute ${u.name} has ${u.data.length} values for ${a[u.domain]} ${u.domain} elements`);const c=(e.attributes??[]).filter(u=>u.type==="FLOAT2"&&u.domain==="CORNER"),r=e.render_uv??e.active_uv??c[0]?.name,h=c.find(u=>u.name===r);if(r&&!h)throw new Error(`Runtime UV map ${r} is missing`);const l=h?.data,i={vertexCount:t.length,normals:$e(e,e.attributes?.find(u=>u.name==="custom_normal")),co:n,starts:s,cornerVerts:o,smooth:u=>!!e.s?.[u],material:u=>e.m?.[u]??0,edges:e.edge_order??e.e??null,sharp:e.sharp??[],uv:l?u=>l[u]:null};return Xt(Ve(i))}const Ct=1.5707963267948966,gt=6.283185307179586,He=.3183098861837067,Ye=.0795774715459476,xs=.3,Ss=Ye,As=3/16*He,Qt=.8,be=Qt*Qt,yt=6371,qe=100,Jt=yt+qe,Me=64,xe=64,q=256,dt=64,Es=[1.679,1.828,1.986,1.307],Ts=[.006605,.01067,.01842,.03156],Rs=[3472e-28,3914e-28,1349e-28,1103e-29],_s=334.5,Os=[28722e-28,46168e-28,79706e-28,13578e-27],Is=[15908e-26,17711e-26,20942e-26,24033e-26],Se=13681e16,Ns=2e6,ks=.73,Vt=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],st=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],Dt=e=>e*e,Ot=e=>e<0?0:e>1?1:e,ot=(e,t,n)=>e+n*(t-e),Cs=e=>Math.sqrt(Math.max(e,0)),Ke=e=>[-Math.sqrt(1-e*e),0,e];function Zt(e,t,n,s,o,a,c){const r=e*s+t*o+n*a,h=e*e+t*t+n*n-c*c;if(h>0&&r>0)return-1;const l=r*r-h;return l<0?-1:l>=r*r?-r+Math.sqrt(l):-r-Math.sqrt(l)}const Ps=e=>As*(1+Dt(e));function Ls(e){const t=1+be+2*Qt*e;return Ye*(1-be)/(t*Math.sqrt(t))}const Fs=e=>Se*(Math.exp(-e/ks)+Ns/Se);function se(e,t){let n=e%gt;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let s=t;return(n>=Ct||n<=-Ct)&&(n=Math.sign(n)*Math.PI-n,s+=Math.PI),s=s%gt,s<0&&(s+=gt),s=gt-s,[n,s]}class Bs{constructor(t,n,s){this.air=t,this.aerosol=n,this.ozone=s,this.lut=new Float32Array(dt*q*4)}coefficients(t,n){const s=Fs(t)*this.aerosol,o=Math.log(Math.max(t,1e-4)),a=378547397e12*Math.exp(-Dt(o-3.22261)*5.55555555-o),c=Math.exp(-.07771971*t**1.16364243);for(let r=0;r<4;r++)n[r]=Os[r]*s,n[4+r]=Is[r]*s,n[8+r]=Rs[r]*_s*a*this.ozone,n[12+r]=Ts[r]*c*this.air}transmittance(t,n,s){const[o,a,c]=Ke(t),r=ot(yt,Jt,n),l=Zt(0,0,r,o,a,c,Jt)/Me,i=[0,0,0,0],u=new Float64Array(16);for(let d=0;d<Me;d++){const f=(d+.5)*l,p=o*f,m=a*f,g=r+c*f,y=Math.max(Math.hypot(p,m,g)-yt,0);this.coefficients(y,u);for(let v=0;v<4;v++)i[v]+=(u[v]+u[4+v]+u[8+v]+u[12+v])*l}for(let d=0;d<4;d++)s[d]=Math.exp(-i[d])}precompute(){const t=new Float64Array(4);for(let n=0;n<dt;n++)for(let s=0;s<q;s++){const o=s/(q-1),a=n/(dt-1);this.transmittance(o*2-1,a,t);const c=(n*q+s)*4;for(let r=0;r<4;r++)this.lut[c+r]=t[r]}}lookup(t,n,s){const o=(q-1)*Ot(t*.5+.5),a=(dt-1)*Ot(n),c=Math.trunc(o),r=Math.trunc(a),h=Math.min(c+1,q-1),l=Math.min(r+1,dt-1),i=o-c,u=a-r,d=(r*q+c)*4,f=(r*q+h)*4,p=(l*q+c)*4,m=(l*q+h)*4;for(let g=0;g<4;g++)s[g]=ot(ot(this.lut[d+g],this.lut[f+g],i),ot(this.lut[p+g],this.lut[m+g],i),u)}lookupAtGround(t,n){const s=(q-1)*Ot(t*.5+.5),o=Math.trunc(s),a=Math.min(o+1,q-1),c=s-o;for(let r=0;r<4;r++)n[r]=ot(this.lut[o*4+r],this.lut[a*4+r],c)}lookupToSun(t,n){const s=(dt-1)*Ot(t),o=Math.trunc(s),a=Math.min(o+1,dt-1),c=s-o,r=q-1;for(let h=0;h<4;h++)n[h]=ot(this.lut[(o*q+r)*4+h],this.lut[(a*q+r)*4+h],c)}inscattering(t,n,s,o,a,c,r,h,l){const i=-(a*t[0]+c*t[1]+r*t[2]),u=Ps(i),d=Ls(i),f=h/xe,p=new Float64Array(16),m=new Float64Array(4),g=new Float64Array(4),y=new Float64Array(4),v=new Float64Array(4),N=new Float64Array(4),k=[0,0,0,0],P=[1,1,1,1];for(let M=0;M<xe;M++){const F=(M+.5)*f,R=n+a*F,S=s+c*F,L=o+r*F,j=Math.hypot(R,S,L),nt=Math.max(j-yt,0),w=nt/qe,I=(R*t[0]+S*t[1]+L*t[2])/j;this.coefficients(nt,p),this.lookup(I,w,m);const B=gt*(1-Cs(1-Dt(yt/j)));this.lookupAtGround(I,y),this.lookupToSun(0,v),this.lookupToSun(w,N);const D=1/(1+5*Math.exp(-17.92*I)),$=[.217,.347,.594,1];for(let E=0;E<4;E++){const J=v[E]/N[E],Z=Ss*B*(xs*He)*y[E]*J*I;g[E]=.02*$[E]*D+Z}for(let E=0;E<4;E++){const J=p[E]+p[4+E]+p[8+E]+p[12+E],Z=Es[E]*(p[12+E]*(u*m[E]+g[E])+p[4+E]*(d*m[E]+g[E])),Lt=Math.exp(-f*J),on=Math.max(J,1e-7);k[E]+=P[E]*((Z-Z*Lt)/on),P[E]*=Lt}}for(let M=0;M<4;M++)l[M]=k[M]}}const X=512,xt=256;function Xe(e,t){const n=new Bs(e.airDensity,e.aerosolDensity,e.ozoneDensity);n.precompute();const s=Math.min(Math.max(e.altitude,1),99999)/1e3,o=Ke(Math.cos(Ct-t)),a=new Float32Array(X*xt*3),c=X/2,r=new Float64Array(4);for(let h=0;h<xt;h++)for(let l=0;l<c;l++){const i=(l+.5)/X,u=(h+.5)/xt,d=gt*i,f=u*2-1,p=Math.sign(f)*Dt(f)*Ct,m=Math.cos(p)*Math.cos(d),g=Math.cos(p)*Math.sin(d),y=Math.sin(p),v=yt+s,N=Zt(0,0,v,m,g,y,Jt),k=Zt(0,0,v,m,g,y,yt),P=k<0?N:k;n.inscattering(o,0,0,v,m,g,y,P,r);let M=0,F=0,R=0;for(let j=0;j<4;j++)M+=Vt[j][0]*r[j],F+=Vt[j][1]*r[j],R+=Vt[j][2]*r[j];const S=(h*X+l)*3;a[S]=M,a[S+1]=F,a[S+2]=R;const L=(h*X+(X-l-1))*3;a[L]=M,a[L+1]=F,a[L+2]=R}return a}function Us(e){const[t]=se(e.sunElevation,e.sunRotation);return Xe(e,t)}function oe(e){const[t]=se(e.sunElevation,e.sunRotation);return JSON.stringify([t,e.altitude,e.airDensity,e.aerosolDensity,e.ozoneDensity])}const js=6,Mt=new Map;function zs(e){return Mt.has(oe(e))}function Qe(e,t){Mt.set(oe(e),t),Mt.size>js&&Mt.delete(Mt.keys().next().value)}function Ds(e){const[t,n]=se(e.sunElevation,e.sunRotation),s=oe(e);let o=Mt.get(s);o===void 0&&(o=Xe(e,t),Qe(e,o));const a=new x;return c=>{const r=Math.hypot(c.x,c.y),h=Math.atan2(c.z,r);let i=(Math.atan2(c.x,c.y)+Math.PI+n)/gt;i-=Math.floor(i);const u=Math.abs(h),d=Ot(Math.sqrt(u/Ct)*Math.sign(h)*.5+.5),f=i*X-.5,p=d*xt-.5,m=Math.floor(f),g=Math.floor(p),y=f-m,v=p-g,N=L=>(L%X+X)%X,k=L=>L<0?0:L>xt-1?xt-1:L,P=N(m),M=N(m+1),F=k(g),R=k(g+1),S=[0,0,0];for(let L=0;L<3;L++){const j=ot(o[(F*X+P)*3+L],o[(F*X+M)*3+L],y),nt=ot(o[(R*X+P)*3+L],o[(R*X+M)*3+L],y);S[L]=ot(j,nt,v)}return a.set(st[0][0]*S[0]+st[0][1]*S[1]+st[0][2]*S[2],st[1][0]*S[0]+st[1][1]*S[1]+st[1][2]*S[2],st[2][0]*S[0]+st[2][1]*S[1]+st[2][2]*S[2])}}let ut=null,Bt=!1,Ws=0;const It=new Map;function Gs(){if(ut||Bt)return ut;if(typeof Worker>"u")return Bt=!0,null;try{ut=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return Bt=!0,null}return ut.onmessage=e=>{const{id:t,pixels:n,error:s}=e.data,o=It.get(t);o&&(It.delete(t),n?o.resolve(n):o.reject(new Error(s??"sky worker returned nothing")))},ut.onerror=e=>{const t=new Error(`sky worker failed: ${e.message||"unknown error"}`);for(const n of It.values())n.reject(t);It.clear(),ut?.terminate(),ut=null,Bt=!0},ut}function $s(e){const t=Gs();if(!t)return Promise.resolve(Us(e));const n=Ws++,s={id:n,parameters:e};return new Promise((o,a)=>{It.set(n,{resolve:o,reject:a}),t.postMessage(s)})}function Vs(e,t,n,s={}){switch(s.type??"LINEAR"){case"QUADRATIC":{const o=Math.max(e,0);return o*o}case"EASING":{const o=Math.min(1,Math.max(0,e));return o*o*(3-2*o)}case"DIAGONAL":return(e+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(e,t,n),0);case"QUADRATIC_SPHERE":{const o=Math.max(.999999-Math.hypot(e,t,n),0);return o*o}case"RADIAL":return Math.atan2(t,e)/(2*Math.PI)+.5;default:return e}}const Ht=(e,t)=>t!==0?e/t:0,Ae=e=>Math.min(1,Math.max(-1,e)),Ee=(e,t,n)=>{const s=n!==0?Math.max(n-Math.abs(e-t),0)/n:0;return Math.min(e,t)-s*s*s*n/6},Je={ADD:(e,t)=>e+t,SUBTRACT:(e,t)=>e-t,MULTIPLY:(e,t)=>e*t,DIVIDE:Ht,POWER:(e,t)=>t===0?1:e===0||e<0&&!Number.isInteger(t)?0:e**t,LOGARITHM:(e,t)=>e<=0||t<=0?0:Ht(Math.log(e),Math.log(t)),SQRT:e=>Math.sqrt(Math.max(e,0)),INVERSE_SQRT:e=>e>0?1/Math.sqrt(e):0,ABSOLUTE:Math.abs,RADIANS:e=>e*Math.PI/180,DEGREES:e=>e*180/Math.PI,MINIMUM:(e,t)=>Math.min(e,t),MAXIMUM:(e,t)=>Math.max(e,t),LESS_THAN:(e,t)=>+(e<t),GREATER_THAN:(e,t)=>+(e>t),ROUND:e=>Math.floor(e+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:e=>e-Math.floor(e),MODULO:(e,t)=>t!==0?e%t:0,FLOORED_MODULO:(e,t)=>t!==0?e-Math.floor(e/t)*t:0,TRUNC:Math.trunc,SNAP:(e,t)=>Math.floor(Ht(e,t))*t,WRAP:(e,t,n)=>t!==n?e-(t-n)*Math.floor((e-n)/(t-n)):n,PINGPONG:(e,t)=>{if(t===0)return 0;const n=(e-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:e=>Math.asin(Ae(e)),ARCCOSINE:e=>Math.acos(Ae(e)),ARCTANGENT:Math.atan,ARCTAN2:(e,t)=>e===0&&t===0?0:Math.atan2(e,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(e,t,n)=>+(e===t||Math.abs(e-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(e,t,n)=>e*t+n,SMOOTH_MIN:Ee,SMOOTH_MAX:(e,t,n)=>-Ee(-e,-t,n)};function V(e,t){if(typeof e=="number")return()=>e;if(Array.isArray(e)){const o=new x(...e);return()=>o}if(e.kind==="direction")return o=>o;if(e.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(e.kind==="gradient"){const o=V(e.vector,t),a={type:e.gradient_type},c=new x;return r=>{const h=o(r),l=typeof h=="number"?h:h.x,i=typeof h=="number"?h:h.y,u=typeof h=="number"?h:h.z,d=tt.clamp(Vs(l,i,u,a),0,1);return e.output==="Fac"?d:c.setScalar(d)}}if(e.kind==="to_float"){const o=V(e.value,t);return a=>{const c=o(a);return typeof c=="number"?c:Math.fround(e.source_type==="RGBA"?c.x*.212639+c.y*.7151687+c.z*.0721923:(c.x+c.y+c.z)/3)}}if(e.kind==="math"){const o=e.inputs.map(r=>V(r,t)),a=Je[e.operation],c=(r,h)=>{const l=o[r]?.(h)??0;if(typeof l!="number")throw new Error("World Math needs scalar inputs");return Math.fround(l)};return r=>{const h=Math.fround(a(c(0,r),c(1,r),c(2,r)));return e.clamp?tt.clamp(h,0,1):h}}if(e.kind==="mix_color"){const o=V(e.factor,t),a=V(e.a,t),c=V(e.b,t),r=new x,h=new x;return l=>{const i=o(l);if(typeof i!="number")throw new Error("World color Mix needs a scalar factor");const u=a(l);typeof u=="number"?r.setScalar(u):r.copy(u);const d=c(l);return typeof d=="number"?h.setScalar(d):h.copy(d),r.lerp(h,e.clamp_factor?tt.clamp(i,0,1):i),e.clamp_result&&r.clampScalar(0,1),r}}if(e.kind==="sky"){const o=Ds({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return a=>o(a)}if(e.kind==="mapping"){const o=V(e.vector,t),a=new at().compose(new x(...e.location),new dn().setFromEuler(new fn(e.rotation[0],e.rotation[1],e.rotation[2],"ZYX")),new x(...e.scale)),c=new x;return r=>{const h=o(r);return typeof h=="number"?c.setScalar(h):c.copy(h),c.applyMatrix4(a)}}if(e.kind==="map_range"){const o=V(e.value,t),a=V(e.from_min,t),c=V(e.from_max,t),r=V(e.to_min,t),h=V(e.to_max,t),l=V(e.steps,t),i=(f,p)=>{const m=f(p);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},u=e.interpolation,d=e.clamp;return f=>{const p=i(o,f),m=i(a,f),g=i(c,f),y=i(r,f),v=i(h,f);if(m===g)return 0;let N;if(u==="STEPPED"){const P=i(l,f),M=(p-m)/(g-m);N=P>0?Math.floor(M*(P+1))/P:0}else if(u==="SMOOTHSTEP"||u==="SMOOTHERSTEP"){const P=tt.clamp((p-Math.min(m,g))/(Math.max(m,g)-Math.min(m,g)),0,1),M=u==="SMOOTHSTEP"?P*P*(3-2*P):P*P*P*(P*(P*6-15)+10);N=m>g?1-M:M}else N=(p-m)/(g-m);const k=y+N*(v-y);return d?y>v?tt.clamp(k,v,y):tt.clamp(k,y,v):k}}if(e.kind==="separate"){const o=V(e.vector,t);return a=>{const c=o(a);return typeof c=="number"?c:c.getComponent(e.axis)}}const n=V(e.factor,t),s=new x;return o=>{const a=n(o);if(typeof a!="number")throw new Error("World ColorRamp needs a scalar factor");const c=tt.clamp(a,0,1)*256,r=Math.floor(c),h=e.colors[r],l=e.colors[Math.min(r+1,256)],i=e.interpolate?c-r:0;return s.set(tt.lerp(h[0],l[0],i),tt.lerp(h[1],l[1],i),tt.lerp(h[2],l[2],i))}}function Hs(e,t,n,s){const o=new Float32Array(t*n*3),a=V(e,s),c=new x;for(let r=0;r<n;r++){const h=((r+.5)/n-.5)*Math.PI;for(let l=0;l<t;l++){const i=((l+.5)/t-.5)*2*Math.PI;c.set(Math.cos(h)*Math.cos(i),-Math.cos(h)*Math.sin(i),Math.sin(h));const u=a(c),d=(r*t+l)*3;o[d]=typeof u=="number"?u:u.x,o[d+1]=typeof u=="number"?u:u.y,o[d+2]=typeof u=="number"?u:u.z}}return o}function Te(e){const t=[],n=s=>{if(!(typeof s=="number"||Array.isArray(s)))switch(s.kind){case"sky":t.push({sunElevation:s.sun_elevation,sunRotation:s.sun_rotation,altitude:s.altitude,airDensity:s.air_density,aerosolDensity:s.aerosol_density,ozoneDensity:s.ozone_density});return;case"mapping":case"gradient":case"separate":n(s.vector);return;case"ramp":n(s.factor);return;case"mix_color":n(s.factor),n(s.a),n(s.b);return;case"math":s.inputs.forEach(n);return;case"to_float":n(s.value);return;case"map_range":n(s.value),n(s.from_min),n(s.from_max),n(s.to_min),n(s.to_max),n(s.steps);return;default:return}};return n(e),t}function mt(e){if(typeof e=="number"||Array.isArray(e))return!1;switch(e.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return mt(e.vector);case"ramp":return mt(e.factor);case"mix_color":return[e.factor,e.a,e.b].some(mt);case"math":return e.inputs.some(mt);case"to_float":return mt(e.value);case"map_range":return[e.value,e.from_min,e.from_max,e.to_min,e.to_max,e.steps].some(mt);default:return!1}}function Ys(e,t,n,s){s.updateMatrixWorld();const o=new Float32Array(t*n*3),a=new x,c=V(e,()=>a),r=new x,h=s.getWorldPosition(new x),l=s.getWorldDirection(new x);for(let i=0;i<n;i++)for(let u=0;u<t;u++){const d=(u+.5)/t,f=(i+.5)/n;a.set(d,f,0),s.isOrthographicCamera?r.copy(l):r.set(d*2-1,f*2-1,.5).unproject(s).sub(h).normalize(),r.set(r.x,-r.z,r.y);const p=c(r),m=(i*t+u)*3;o[m]=typeof p=="number"?p:p.x,o[m+1]=typeof p=="number"?p:p.y,o[m+2]=typeof p=="number"?p:p.z}return o}const W=O().finite(),qs=A({type:Q(["POINT","SUN","SPOT","AREA"]),color:G([W,W,W]),energy:W,use_shadow:H().default(!0),radius:W.optional(),spot_size:W.optional(),spot_blend:W.optional(),shape:Q(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:W.optional(),size_y:W.optional()}).strict();let te;function Ks(){return te??=$n(async()=>{const{RectAreaLightUniformsLib:e}=await import("./RectAreaLightUniformsLib-BGT7Bu4n.js");return{RectAreaLightUniformsLib:e}},__vite__mapDeps([0,1])).then(({RectAreaLightUniformsLib:e})=>{e.init()}),te}function Xs(){return te??Promise.resolve()}const Qs=e=>{const t=e.size??0,n=e.size_y??t;if(e.shape==="RECTANGLE")return[t,n];if(e.shape==="DISK"){const s=Math.sqrt(Math.PI*t*t/4);return[s,s]}if(e.shape==="ELLIPSE"){const s=Math.sqrt(Math.PI/4);return[t*s,n*s]}return[t,t]};function Js(e,t){const n=(c,r)=>t&&r(t)?t:new c;if(e.type==="SUN"){const c=n(ze,r=>r.isDirectionalLight);return c.intensity=e.energy,c.color.setRGB(e.color[0],e.color[1],e.color[2],rt),c.castShadow=e.use_shadow,c}if(e.type==="POINT"){const c=n(bn,r=>r.isPointLight);return c.intensity=e.energy/(4*Math.PI),c.distance=0,c.decay=2,c.color.setRGB(e.color[0],e.color[1],e.color[2],rt),c.castShadow=e.use_shadow,c}if(e.type==="SPOT"){const c=n(Mn,r=>r.isSpotLight);return c.intensity=e.energy/(4*Math.PI),c.distance=0,c.decay=2,c.angle=(e.spot_size??0)/2,c.penumbra=e.spot_blend??0,c.color.setRGB(e.color[0],e.color[1],e.color[2],rt),c.castShadow=e.use_shadow,c}Ks();const s=n(xn,c=>c.isRectAreaLight),[o,a]=Qs(e);return s.width=o,s.height=a,s.intensity=e.energy/(Math.max(o*a,Number.MIN_VALUE)*Math.PI),s.color.setRGB(e.color[0],e.color[1],e.color[2],rt),s}function Zs(e,t,n){if(!e.castShadow||n<=0)return;const o=e.getWorldPosition(new x).distanceTo(t),a=e.shadow;if(!a)return;const c=a.camera;c.near=Math.max(n*.001,o-n),c.far=o+n,e.isDirectionalLight&&(c.left=-n,c.right=n,c.top=n,c.bottom=-n),c.updateProjectionMatrix()}function to(e,t){e.position.set(0,0,0);const n=e;e.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const eo=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],smooth:.2}],Re=.69;class no{constructor(){this.group=new it,this.lights=[],this.group.name="BlenderSolidStudio";const t=new je;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new vt(0,0,0);for(const[o,a]of eo.entries()){const c=(1+a.smooth)**2,r=new ze(16777215,Math.PI*Re/c);r.name=`BlenderSolidLight${o}`,r.color.setRGB(a.diffuse[0],a.diffuse[1],a.diffuse[2],rt),r.position.set(a.direction[0],a.direction[1],a.direction[2]),r.target=t,this.group.add(r),this.lights.push(r),n.r+=a.diffuse[0]*a.smooth/c,n.g+=a.diffuse[1]*a.smooth/c,n.b+=a.diffuse[2]*a.smooth/c}const s=new pn(16777215,Math.PI*Re);s.name="BlenderSolidWrapFill",s.color.copy(n),this.group.add(s),this.lights.push(s)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const bt=G([W,W,W]),Y=Vn(()=>ne([W,bt,A({kind:U("direction")}).strict(),A({kind:U("window")}).strict(),A({kind:U("gradient"),gradient_type:Q(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:Q(["Fac","Color"]),vector:Y}).strict(),A({kind:U("to_float"),source_type:Q(["RGBA","VECTOR"]),value:Y}).strict(),A({kind:U("math"),operation:Q(Object.keys(Je)),clamp:H(),inputs:C(Y).min(1).max(3)}).strict(),A({kind:U("mix_color"),factor:Y,a:Y,b:Y,clamp_factor:H(),clamp_result:H()}).strict(),A({kind:U("mapping"),vector:Y,location:bt,rotation:bt,scale:bt}).strict(),A({kind:U("separate"),vector:Y,axis:O().int().min(0).max(2)}).strict(),A({kind:U("ramp"),factor:Y,colors:C(bt).length(257),interpolate:H()}).strict(),A({kind:U("map_range"),interpolation:Q(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:H(),value:Y,from_min:Y,from_max:Y,to_min:Y,to_max:Y,steps:Y}).strict(),A({kind:U("sky"),sun_elevation:W,sun_rotation:W,altitude:W,air_density:W,aerosol_density:W,ozone_density:W}).strict()])),_e=A({color:bt,strength:W,shader:Y.optional()}),so=_e.extend({lighting:_e.strict().optional()}).strict(),oo=4,Rt=new Map,Yt=new Set;function Oe(e,t,n){const a=mt(e);if(a&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const c=JSON.stringify([e,a?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),r=Rt.get(c);if(r!==void 0)return ee(r,t,256,128);const h=new x,l=new yn,i=n?new at().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,u=n?.getWorldPosition(new x),f=Hs(e,256,128,a?p=>(h.set(p.x,p.z,-p.y),n.isPerspectiveCamera&&h.add(u),l.set(h.x,h.y,h.z,1).applyMatrix4(i),l.w===0?h.set(0,0,0):h.set(l.x/l.w*.5+.5,l.y/l.w*.5+.5,0)):void 0);return Rt.set(c,f),Rt.size>oo&&Rt.delete(Rt.keys().next().value),ee(f,t,256,128)}function ro(e,t,n,s){const o=Ft.toHalfFloat(1);for(let a=0;a<s;a++)e[a*4]=Ft.toHalfFloat(t[a*3]*n),e[a*4+1]=Ft.toHalfFloat(t[a*3+1]*n),e[a*4+2]=Ft.toHalfFloat(t[a*3+2]*n),e[a*4+3]=o}function ee(e,t,n,s){const o=new Uint16Array(n*s*4);ro(o,e,t,n*s);const a=new De(o,n,s,We,vn);return a.mapping=wn,a.colorSpace=rt,a.minFilter=Kt,a.magFilter=Kt,a.needsUpdate=!0,a}class re{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,s){if(this.clear(),this.pending=null,!n)return;const o=re.sceneOf(t);if(!o)return;this.applied={scene:o,background:o.background,environment:o.environment};const a=n.shader??n.color,c=this.generation,h=[...Te(a),...n.lighting?Te(n.lighting.shader??n.lighting.color):[]].filter(i=>!zs(i));if(h.length===0){this.compose(o,n,a,s);return}const l=(async()=>{const i=await Promise.all(h.map($s));h.forEach((u,d)=>{Qe(u,i[d])}),!(this.generation!==c||this.applied?.scene!==o)&&this.compose(o,n,a,s)})();this.pending=l,Yt.add(l),l.then(()=>Yt.delete(l),()=>Yt.delete(l))}compose(t,n,s,o){if(this.texture=Oe(s,n.strength,o),mt(s)){if(!o)throw new Error("World Window coordinates need a render camera");this.screenTexture=ee(Ys(s,512,512,o),n.strength,512,512),this.screenTexture.mapping=gn,t.background=this.screenTexture}else if(o&&o.isOrthographicCamera){const c=o.getWorldDirection(new x);c.set(c.x,-c.z,c.y);const r=V(n.shader??n.color)(c);t.background=typeof r=="number"?new vt().setRGB(r,r,r).multiplyScalar(n.strength):new vt().setRGB(r.x,r.y,r.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:a}=n;this.environmentTexture=a?Oe(a.shader??a.color,a.strength,o):null,t.environment=this.environmentTexture??this.texture}clear(){this.generation++,this.applied&&(this.applied.scene.background=this.applied.background,this.applied.scene.environment=this.applied.environment,this.applied=null,this.texture?.dispose(),this.texture=null,this.environmentTexture?.dispose(),this.environmentTexture=null,this.screenTexture?.dispose(),this.screenTexture=null)}dispose(){this.clear()}}function Ze(e){return[e.min.x,e.max.x].flatMap(t=>[e.min.y,e.max.y].flatMap(n=>[e.min.z,e.max.z].map(s=>new x(t,n,s))))}function io(e,t){if(e.isEmpty()||!t.intersectsBox(e))return[];const n=Ze(e);if(n.every(i=>t.containsPoint(i)))return n;const s=[...t.planes,new wt(new x(1,0,0),-e.min.x),new wt(new x(-1,0,0),e.max.x),new wt(new x(0,1,0),-e.min.y),new wt(new x(0,-1,0),e.max.y),new wt(new x(0,0,1),-e.min.z),new wt(new x(0,0,-1),e.max.z)],o=[],a=new x,c=new x,r=new x,h=new x,l=Math.max(1,e.min.length(),e.max.length())*1e-8;for(let i=0;i<s.length;i++)for(let u=i+1;u<s.length;u++)for(let d=u+1;d<s.length;d++){const f=s[i],p=s[u],m=s[d];a.crossVectors(p.normal,m.normal);const g=f.normal.dot(a);Math.abs(g)<1e-12||(c.crossVectors(m.normal,f.normal),r.crossVectors(f.normal,p.normal),h.copy(a).multiplyScalar(-f.constant).addScaledVector(c,-p.constant).addScaledVector(r,-m.constant).divideScalar(g),s.every(y=>y.distanceToPoint(h)>=-l)&&o.push(h.clone()))}return o}function ao(e,t,n){if(!e.castShadow||!t.length)return;e.shadow.updateMatrices(e);const s=e.shadow.camera,o=s.matrixWorldInverse,a=new jt().setFromPoints(t.map(d=>d.clone().applyMatrix4(o))),c=a.getSize(new x),r=Math.max(c.length()*1e-6,Number.EPSILON),h=2+2*Math.SQRT2,l=Math.max(c.x,c.y,r)/Math.max(1,Math.min(e.shadow.mapSize.x,e.shadow.mapSize.y)-2*h),i=2*Math.SQRT2*l,u=h*l;a.min.x-=u,a.min.y-=u,a.max.x+=u,a.max.y+=u;for(const d of n){if(d.isEmpty())continue;const f=new jt().setFromPoints(Ze(d).map(p=>p.applyMatrix4(o)));f.max.x<a.min.x||f.min.x>a.max.x||f.max.y<a.min.y||f.min.y>a.max.y||(a.min.z=Math.min(a.min.z,f.min.z),a.max.z=Math.max(a.max.z,f.max.z))}s.left=a.min.x,s.right=a.max.x,s.bottom=a.min.y,s.top=a.max.y,s.near=-a.max.z-i-r,s.far=-a.min.z+i+r,s.updateProjectionMatrix(),e.shadow.normalBias=i}const St=O().finite(),Ie=G([St,St,St]),tn=A({min:G([O().int(),O().int(),O().int()]),max:G([O().int(),O().int(),O().int()]),density:C(St),voxelSize:St.positive(),color:Ie,emission:Ie,densityScale:St.nonnegative()}).strict();function co(e){const t=e.max.map((i,u)=>i-e.min[u]+1);if(t.some(i=>i<=0)||t.reduce((i,u)=>i*u,1)!==e.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new Sn(new Float32Array(e.density),t[0],t[1],t[2]);n.format=An,n.type=En,n.minFilter=n.magFilter=Kt,n.unpackAlignment=1,n.needsUpdate=!0;const s=new x(...e.min).addScalar(-.5).multiplyScalar(e.voxelSize),o=new x(t[0],t[1],t[2]).multiplyScalar(e.voxelSize),a=new Tn(o.x,o.y,o.z),c=a.getAttribute("position");for(let i=0;i<c.count;i++)c.setXYZ(i,s.x+(c.getX(i)>0?o.x:0),s.y+(c.getY(i)>0?o.y:0),s.z+(c.getZ(i)>0?o.z:0));c.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const r=new Be({glslVersion:_n,side:Rn,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:s},extent:{value:o},voxelSize:{value:e.voxelSize},densityScale:{value:e.densityScale},volumeColor:{value:new x(...e.color)},emission:{value:new x(...e.emission)},cameraLocal:{value:new x},rayLocal:{value:new x},orthographic:{value:!1},worldScale:{value:new Le}},vertexShader:`
20
+ out vec3 localPosition;
21
+ void main() {
22
+ localPosition = position;
23
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
24
+ }`,fragmentShader:`
25
+ precision highp sampler3D;
26
+ uniform sampler3D densityGrid;
27
+ uniform vec3 minimum, extent, volumeColor, emission, cameraLocal, rayLocal;
28
+ uniform float voxelSize, densityScale;
29
+ uniform bool orthographic;
30
+ uniform mat3 worldScale;
31
+ in vec3 localPosition;
32
+ out vec4 outputColor;
33
+ #define gl_FragColor outputColor
34
+ void main() {
35
+ vec3 direction = normalize(orthographic ? rayLocal : localPosition - cameraLocal);
36
+ vec3 origin = orthographic ? localPosition - direction * length(extent) * 2.0 : cameraLocal;
37
+ vec3 inverseRay = 1.0 / direction;
38
+ vec3 nearPlane = (minimum - origin) * inverseRay;
39
+ vec3 farPlane = (minimum + extent - origin) * inverseRay;
40
+ vec3 lo = min(nearPlane, farPlane), hi = max(nearPlane, farPlane);
41
+ float start = max(0.0, max(lo.x, max(lo.y, lo.z)));
42
+ float end = min(hi.x, min(hi.y, hi.z));
43
+ if (end <= start) discard;
44
+ float stepSize = min(voxelSize * 0.5, end - start);
45
+ float worldStep = length(worldScale * direction) * stepSize;
46
+ vec3 radiance = vec3(0.0);
47
+ float transmission = 1.0;
48
+ for (float t = start + stepSize * 0.5; t < end; t += stepSize) {
49
+ vec3 uvw = (origin + direction * t - minimum) / extent;
50
+ float density = max(0.0, texture(densityGrid, uvw).r);
51
+ float extinction = density * densityScale;
52
+ float attenuation = exp(-extinction * worldStep);
53
+ float integral = extinction > 0.000001 ? (1.0 - attenuation) / extinction : worldStep;
54
+ radiance += transmission * (volumeColor * extinction + emission * density) * integral;
55
+ transmission *= attenuation;
56
+ if (transmission < 0.001) break;
57
+ }
58
+ outputColor = vec4(radiance, 1.0 - transmission);
59
+ #include <tonemapping_fragment>
60
+ #include <colorspace_fragment>
61
+ }`}),h=new kt(a,r),l=new at;return h.onBeforeRender=(i,u,d)=>{l.copy(h.matrixWorld).invert(),r.uniforms.cameraLocal.value.setFromMatrixPosition(d.matrixWorld).applyMatrix4(l),d.getWorldDirection(r.uniforms.rayLocal.value).transformDirection(l),r.uniforms.orthographic.value=!!d.isOrthographicCamera,r.uniforms.worldScale.value.setFromMatrix4(h.matrixWorld)},r.addEventListener("dispose",()=>n.dispose()),h}const lo=A({object:_(),group:_(),groupIndex:O().int().nonnegative(),count:O().int().nonnegative(),digest:_(),alertMode:Q(["NONE","ACTIVE","ALL"]),unchanged:U(!0).optional(),weightsBase64:_().optional(),alertBase64:_().optional()}).strict();function uo(e){const n=e<0?0:e>1?1:e,s=(.5+.5*n)**1.5,[o,a,c]=ho(2/3*(1-n)),r=new vt;return r.setRGB((o*s)**(1/1.5),(a*s)**(1/1.5),(c*s)**(1/1.5),Pt),r}function ho(e){const t=(e%1+1)%1,n=Math.floor(t*6),s=t*6-n;switch(n%6){case 0:return[1,s,0];case 1:return[1-s,1,0];case 2:return[0,1,s];case 3:return[0,1-s,1];case 4:return[s,0,1];default:return[1,0,1-s]}}const mo=0;function Ne(e){const t=atob(e),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}class fo{constructor(){this.group=new it,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,s){if(t===null||n===null||!n.isMesh||s===null)return this.clear(),this.signature="",null;const o=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==o)return this.clear(),`weights: the session sent a reference to ${o} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${o} carried neither an array nor a reference`;const p=Ne(t.weightsBase64);this.held={key:o,weights:new Float32Array(p.buffer,p.byteOffset,t.count),alerts:Ne(t.alertBase64)}}const a=this.held;if(a===null)return null;const c=`${o}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${s.elements.join(",")}`;if(c===this.signature&&this.mesh!==null)return null;this.signature=c,this.clear();const r=n.geometry.clone(),h=r.getAttribute("position"),l=r.getAttribute("blenderVertex");if(l===void 0)return r.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const i=new Float32Array(h.count*3),u=new vt().setHex(mo,Pt);for(let p=0;p<h.count;p++){const m=l.getX(p),y=t.alertMode!=="NONE"&&a.alerts[m]===1?u:uo(a.weights[m]??0);i[p*3]=y.r,i[p*3+1]=y.g,i[p*3+2]=y.b}r.setAttribute("color",new pt(i,3)),r.deleteAttribute("blenderVertex");const d=new Ue({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),f=new kt(r,d);return f.name=`${t.object}:weights`,f.frustumCulled=!1,f.matrixAutoUpdate=!1,f.matrix.copy(s),f.matrix.decompose(f.position,f.quaternion,f.scale),this.geometry=r,this.material=d,this.mesh=f,this.group.add(f),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const T=O().finite(),en=G([T,T,T]),Ut=G([O().int().nonnegative(),O().int().nonnegative()]),K={name:_(),domain:Q(["POINT","EDGE","FACE","CORNER"])},po=Yn("type",[A({...K,type:U("FLOAT2"),data:C(G([T,T]))}).strict(),A({...K,type:U("FLOAT_VECTOR"),data:C(en)}).strict(),A({...K,type:U("FLOAT_COLOR"),data:C(G([T,T,T,T]))}).strict(),A({...K,type:U("BYTE_COLOR"),data:C(G([T,T,T,T]))}).strict(),A({...K,type:U("QUATERNION"),data:C(G([T,T,T,T]))}).strict(),A({...K,type:U("FLOAT4"),data:C(G([T,T,T,T]))}).strict(),A({...K,type:U("FLOAT4X4"),data:C(C(T).length(16))}).strict(),A({...K,type:U("INT16_2D"),data:C(G([O().int(),O().int()]))}).strict(),A({...K,type:U("INT32_2D"),data:C(G([O().int(),O().int()]))}).strict(),A({...K,type:U("FLOAT"),data:C(T)}).strict(),A({...K,type:U("INT"),data:C(O().int())}).strict(),A({...K,type:U("INT8"),data:C(O().int())}).strict(),A({...K,type:U("BOOLEAN"),data:C(H())}).strict(),A({...K,type:U("STRING"),data:C(_())}).strict()]),go=A({positions:z(Float32Array),normals:z(Float32Array).nullable(),uv:z(Float32Array).nullable(),indices:z(Uint32Array),groups:C(A({start:O().int().nonnegative(),count:O().int().nonnegative(),materialIndex:O().int().nonnegative()}).strict()),hash:_()}).strict(),yo=A({v:C(en),f:C(C(O().int().nonnegative())),e:C(Ut).optional(),edge_order:C(Ut).optional(),m:C(O().int().nonnegative()).optional(),s:C(H()).optional(),sharp:C(Ut).optional(),seams:C(Ut).optional(),creases:C(G([T,T,T])).optional(),attributes:C(po).optional(),active_uv:_().nullable().optional(),render_uv:_().nullable().optional()}).strict(),vo=A({store:O().int().optional(),revision:O().int(),unchanged:U(!0)}).strict(),wo=A({co:z(Float64Array),faceStart:z(Uint32Array),corner:z(Uint32Array),cornerEdge:z(Int32Array),edge:z(Uint32Array),edgeSharp:z(Uint8Array),edgeSeam:z(Uint8Array),edgeCrease:z(Float32Array),material:z(Uint32Array),smooth:z(Uint8Array),vertSelect:z(Uint8Array),vertHide:z(Uint8Array),edgeSelect:z(Uint8Array),edgeHide:z(Uint8Array),faceSelect:z(Uint8Array),faceHide:z(Uint8Array)}).strict(),bo=A({name:_(),domain:Q(["POINT","EDGE","FACE","CORNER"]),type:_(),data:qn(e=>ArrayBuffer.isView(e))}).strict(),Mo=A({columns:wo,attributes:C(bo),activeUv:_().nullable(),renderUv:_().nullable(),counts:A({verts:O().int().nonnegative(),edges:O().int().nonnegative(),faces:O().int().nonnegative(),corners:O().int().nonnegative()}).strict(),revision:O().int().nonnegative()}).strict(),xo=ne([go,Mo,yo,vo]),ke=new Set;function So(e){const t=new Blob([e],{type:"image/png"}),n=new Pn;let s=!1;n.addEventListener("dispose",()=>{s=!0,n.image?.close?.()});const o=createImageBitmap(t,{imageOrientation:"flipY"}).then(a=>{if(s){a.close();return}n.image=a,n.needsUpdate=!0}).finally(()=>{ke.delete(o)});return ke.add(o),o.catch(()=>{}),{texture:n,ready:o}}function Ao(e,t,n,s){const o=new De(e,t,n,We,Cn);return o.flipY=!1,o.colorSpace=s==="data"?Ge:Pt,o.needsUpdate=!0,o}const Eo=A({width:O().int().positive(),height:O().int().positive(),revision:O().int().nonnegative(),rgba:z(Uint8Array).optional(),rgbaBase64:_().optional(),colorspace:Q(["sRGB","data"]).optional()}).strict(),To=A({revision:O().int().nonnegative(),png:z(Uint8Array).optional(),pngBase64:_().optional()}).strict(),Ro=ne([Eo,To]),Ce=A({image:A({name:_(),revision:O().int().nonnegative()}).strict(),extension:Q(["REPEAT","EXTEND","MIRROR"]).default("REPEAT"),uv:_(),tint:G([T,T,T]).optional()}).strict(),_o=A({name:_(),color:G([T,T,T,T]),roughness:T,metallic:T,transmission:T,ior:T,texture:Ce.optional(),roughness_texture:Ce.optional(),emission:A({color:G([T,T,T]),strength:T}).strict().optional()}).strict(),Oo=A({session:_(),revision:O().int().nonnegative(),volumes:ct(_(),tn).default({}),lights:ct(_(),qs).default({}),world:so.nullable().default(null),meshes:ct(_(),xo),materials:ct(_(),_o),images:ct(_(),Ro).default({}),objects:C(A({id:_(),name:_(),type:Q(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:_().nullable(),volume:_().nullable().optional(),light:_().nullable().optional(),materials:C(_().nullable()),matrix:C(G([T,T,T,T])).length(4),visible:H(),render_visible:H().default(!0),selected:H(),parent:_().nullable()}).strict()),active:_().nullable(),mode:_(),cameras:ct(_(),ct(_(),Hn())).default({}),warnings:C(_()).default([]),updated:C(_()).default([]),frame:O().int().default(0),armatures:ct(_(),Qn).default({}),weights:lo.nullable().default(null)}).strict();class ie{constructor(){this.root=new it,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new no,this.world=new re,this.armatureOverlay=new cs,this.weightOverlay=new fo,this.armatureRoot=new it,this.weightRoot=new it,this.rendered=!1,this.fallback=new On({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.frame=null,this.retiredSessions=new Set,this.geometryBuilds=0,this.submittedMeshes=new Map,this.submitted=null,this.submittedSession=null,this.photographs=[],this.frameListeners=new Set,this.mode=null,this.root.name="Model",this.root.matrixAutoUpdate=!1,this.root.matrix.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),this.root.updateMatrixWorld(!0);for(const[t,n]of[[this.armatureRoot,this.armatureOverlay.group],[this.weightRoot,this.weightOverlay.group]])t.matrixAutoUpdate=!1,t.matrix.copy(this.root.matrix),t.add(n),t.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights"}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}blenderObjectName(t){for(const[n,s]of this.objects)if(s===t)return this.frame?.objects.find(o=>o.id===n)?.name??null;return null}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(s=>s.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[s,o]of this.objects)if(o===t){const a=t.parent,c=[...t.children];t.removeFromParent();for(const r of c)n.add(r);a?.add(n),this.objects.set(s,n);return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot}]}async setRendered(t,n){this.rendered=t,this.lighting.setRendered(t),t?this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.applyVisibility(),this.applyShadows(t,n),t&&(await Xs(),await Promise.all([...this.textures.values()].map(s=>s.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const s=[];for(const h of this.objects.values()){const l=h;if(l.isMesh&&(l.castShadow=t,l.receiveShadow=t,t&&l.visible)){const i=new jt().setFromObject(l);i.isEmpty()||s.push(i)}}if(!t||!s.length)return;const a=s.reduce((h,l)=>h.union(l),new jt).getBoundingSphere(new In),c=n?new Nn().setFromProjectionMatrix(new at().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,r=c?s.flatMap(h=>io(h,c)):[];for(const h of this.lights.values())h.isDirectionalLight&&n?ao(h,r,s):Zs(h,a.center,a.radius)}applyOverlays(t){const n=c=>{const r=t.objects.find(h=>h.name===c);return r===void 0?null:new at().set(...r.matrix.flat())},s=[...this.armatureOverlay.apply(t.armatures,n)],o=t.weights?this.objects.get(t.objects.find(c=>c.name===t.weights?.object)?.id??""):void 0,a=this.weightOverlay.apply(t.weights,o??null,t.weights?n(t.weights.object):null);return a!==null&&s.push(a),s}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const s=this.lights.get(t.light);s&&(s.visible=this.rendered&&t.render_visible)}this.armatureOverlay.group.visible=!this.rendered,this.weightOverlay.group.visible=!this.rendered}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},s=Oo.parse(t);if(this.retiredSessions.has(s.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===s.session&&s.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const o=new Set(s.objects.map(l=>l.id));if(o.size!==s.objects.length)throw new Error("Runtime object IDs must be unique");const a=new Map(s.objects.map(l=>[l.id,l]));for(const l of s.objects){if(l.mesh!==null&&!s.meshes[l.mesh])throw new Error(`Missing runtime mesh ${l.mesh}`);if(l.volume&&(!s.volumes[l.volume]||l.mesh!==null))throw new Error(`Invalid runtime volume ${l.volume}`);if(l.light&&(!s.lights[l.light]||l.mesh!==null))throw new Error(`Invalid runtime light ${l.light}`);for(const d of l.materials)if(d!==null&&!s.materials[d])throw new Error(`Missing runtime material ${d}`);const i=new Set([l.id]);let u=l.parent;for(;u!==null;){if(i.has(u))throw new Error("Runtime parent cycle");i.add(u);const d=a.get(u);if(!d)throw new Error(`Missing runtime parent ${u}`);u=d.parent}}const c=new Map,r=new Map;try{for(const[l,i]of Object.entries(s.volumes)){const u=JSON.stringify(i);this.frame?.session===s.session&&this.volumes.get(l)?.signature===u||r.set(l,{signature:u,mesh:co(i)})}for(const[l,i]of Object.entries(s.meshes)){if("unchanged"in i){if(this.frame?.session===s.session&&this.meshes.has(l))continue;throw new Error(`${ls}: the presenter does not hold runtime mesh ${l} (store ${i.store}, revision ${i.revision})`)}const u="hash"in i,d="columns"in i,f=d?`revision:${i.revision}`:u?i.hash:JSON.stringify(i);this.frame?.session===s.session&&this.meshes.get(l)?.signature===f||c.set(l,{signature:f,geometry:d?Xt(bs({...i.columns,attributes:i.attributes,activeUv:i.activeUv,renderUv:i.renderUv},f)):u?Xt(i):Ms(i)})}}catch(l){for(const i of c.values())i.geometry.dispose();for(const{mesh:i}of r.values())i.geometry.dispose(),i.material.dispose();throw l}this.frame?.session!==s.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[l,i]of r){const u=this.volumes.get(l)?.mesh;u&&(u.removeFromParent(),u.geometry.dispose(),u.material.dispose()),this.volumes.set(l,i)}for(const[l,i]of c)this.meshes.get(l)?.geometry.dispose(),this.meshes.set(l,i),this.geometryBuilds++;for(const[l,i]of Object.entries(s.images)){const u=this.textures.get(l);if("width"in i){const m=i.rgba??(i.rgbaBase64?ue(i.rgbaBase64):void 0);if(!m)throw new Error(`Runtime image ${l} carries no raster`);if(u&&u.width===i.width&&u.height===i.height){const g=u.texture.image;if(g.data){g.data.set(m),u.texture.needsUpdate=!0,u.revision=i.revision;continue}}u?.texture.dispose(),this.textures.set(l,{texture:Ao(m,i.width,i.height,i.colorspace??"sRGB"),width:i.width,height:i.height,revision:i.revision});continue}const d=i.png??(i.pngBase64?ue(i.pngBase64):void 0);if(!d)throw new Error(`Runtime image ${l} carries no bytes`);u?.texture.dispose();const{texture:f,ready:p}=So(d);f.colorSpace=Pt,this.textures.set(l,{texture:f,ready:p,width:0,height:0,revision:i.revision,png:d.slice()})}for(const[l,i]of Object.entries(s.materials)){const u=this.materials.get(l)??new kn;u.name=i.name;const d=i.texture?.tint;i.texture!==void 0?u.color.setRGB(d?.[0]??1,d?.[1]??1,d?.[2]??1,rt):u.color.setRGB(i.color[0],i.color[1],i.color[2],rt),u.opacity=i.color[3];const f=u.opacity<1;u.transparent!==f&&(u.transparent=f,u.needsUpdate=!0),u.roughness=i.roughness,u.metalness=i.metallic,u.transmission=i.transmission,u.ior=i.ior,i.emission?(u.emissive.setRGB(i.emission.color[0],i.emission.color[1],i.emission.color[2],rt),u.emissiveIntensity=i.emission.strength):(u.emissive.setRGB(0,0,0),u.emissiveIntensity=1);const p=i.roughness_texture?.image.name??null;if(p===null)this.roughnessTextureNames.has(l)&&(u.roughnessMap=null,this.roughnessTextureNames.delete(l),u.needsUpdate=!0);else{const g=this.textures.get(p);if(!g)throw new Error(`${ye}: the presenter does not hold runtime image ${p} (revision ${i.roughness_texture.image.revision})`);const y=g.texture,v=i.roughness_texture.extension==="EXTEND"?ae:i.roughness_texture.extension==="MIRROR"?ce:le;(y.wrapS!==v||y.wrapT!==v)&&(y.wrapS=v,y.wrapT=v,y.image&&(y.needsUpdate=!0)),u.roughnessMap!==y&&(u.roughnessMap=y,this.roughnessTextureNames.set(l,p),u.needsUpdate=!0)}const m=i.texture?.image.name??null;if(m===null)this.textureNames.has(l)&&(u.map=null,this.textureNames.delete(l),u.needsUpdate=!0);else{const g=this.textures.get(m);if(!g)throw new Error(`${ye}: the presenter does not hold runtime image ${m} (revision ${i.texture.image.revision})`);const y=g.texture,v=i.texture.extension==="EXTEND"?ae:i.texture.extension==="MIRROR"?ce:le;(y.wrapS!==v||y.wrapT!==v)&&(y.wrapS=v,y.wrapT=v,y.image&&(y.needsUpdate=!0)),u.map!==y&&(u.map=y,this.textureNames.set(l,m),u.needsUpdate=!0)}this.materials.set(l,u)}for(const l of s.objects){let i=this.objects.get(l.id);const u=l.volume?this.volumes.get(l.volume).mesh:null;if((!i||(u?i!==u:!!i.isMesh!=(l.mesh!==null)))&&(i?.removeFromParent(),i=u??(l.mesh!==null?new kt(this.meshes.get(l.mesh).geometry,this.fallback):new je),this.objects.set(l.id,i)),i.name=l.name,i.matrixAutoUpdate=!1,i.matrix.set(...l.matrix.flat()),l.parent){const d=new at().set(...a.get(l.parent).matrix.flat());i.matrix.premultiply(d.invert())}if(i.matrix.decompose(i.position,i.quaternion,i.scale),l.mesh!==null){const d=i;d.geometry=this.meshes.get(l.mesh).geometry,d.material=l.materials.length?l.materials.map(f=>f===null?this.fallback:this.materials.get(f)):this.fallback}if(l.light){const d=this.lights.get(l.light)??null,f=Js(s.lights[l.light],d);d&&d!==f&&(d.removeFromParent(),d.dispose()),f.parent!==i&&i.add(f),to(f,i),this.lights.set(l.light,f)}}for(const l of s.objects){const i=this.objects.get(l.id),u=l.parent===null?this.root:this.objects.get(l.parent);i.parent!==u&&u.add(i)}for(const[l,i]of this.objects)o.has(l)||(i.removeFromParent(),this.objects.delete(l));for(const[l,i]of this.volumes)s.volumes[l]||(i.mesh.geometry.dispose(),i.mesh.material.dispose(),this.volumes.delete(l));for(const[l,i]of this.meshes)s.meshes[l]||(i.geometry.dispose(),this.meshes.delete(l));for(const[l,i]of this.materials)s.materials[l]||(i.dispose(),this.materials.delete(l));for(const[l,i]of this.lights)s.lights[l]||(i.removeFromParent(),i.dispose(),this.lights.delete(l));this.root.updateMatrixWorld(!0),this.frame={...s,meshes:{},volumes:{}};const h=this.applyOverlays(s);h.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...h]}),this.applyVisibility();for(const l of[...this.frameListeners])l();return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}snapshot(){return this.frame}captureSnapshot(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[r,{signature:h,geometry:l}]of this.meshes){const i=f=>{const p=l.getAttribute(f);if(!p)return null;if(!(p instanceof pt))throw new Error(`Blender capture cannot copy interleaved ${f}`);return new Float32Array(p.array)},u=i("position");if(!u)throw new Error(`Blender capture mesh ${r} has no positions`);const d=l.getIndex();n.meshes[r]={hash:h,positions:u,normals:i("normal"),uv:i("uv"),indices:d?new Uint32Array(d.array):Uint32Array.from({length:u.length/3},(f,p)=>p),groups:l.groups.map(f=>({start:f.start,count:f.count,materialIndex:f.materialIndex??0}))}}for(const[r,{signature:h}]of this.volumes)n.volumes[r]=tn.parse(JSON.parse(h));const s=new Set(Object.values(n.materials).flatMap(r=>[r.texture?.image.name,r.roughness_texture?.image.name].filter(h=>h!==void 0)));for(const r of s){const h=this.textures.get(r);if(!h)throw new Error(`Blender capture image ${r} is not resident`);if(h.png)n.images[r]={revision:h.revision,png:h.png.slice()};else{const l=h.texture.image?.data;if(!(l instanceof Uint8Array))throw new Error(`Blender capture image ${r} has no resident raster`);n.images[r]={revision:h.revision,width:h.width,height:h.height,rgba:l.slice(),colorspace:h.texture.colorSpace===Ge?"data":"sRGB"}}}const o=new ie;let a=!1;const c=()=>{a||(a=!0,o.dispose(),o.root.removeFromParent())};try{o.applyFrame(n),this.root.updateWorldMatrix(!0,!1),o.root.matrix.copy(this.root.matrixWorld),o.root.updateMatrixWorld(!0)}catch(r){throw c(),r}return{root:o.root,session:t.session,revision:t.revision,prepare:r=>{if(a)throw new Error("Blender capture snapshot is disposed");return o.setRendered(!0,r)},dispose:c}}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,s=n.meshes;if(typeof s!="object"||s===null)return;const o=typeof n.session=="string"?n.session:null;o!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=o);const a=s;for(const[c,r]of Object.entries(a))typeof r=="object"&&r!==null&&!("unchanged"in r)&&this.submittedMeshes.set(c,r);for(const c of[...this.submittedMeshes.keys()])c in a||this.submittedMeshes.delete(c);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t}of this.textures.values())t.dispose();this.textures.clear(),this.textureNames.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const Bo=new ie;function nn(e){const t=atob(e),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}function qt(e){const t=nn(e);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function Io(e){const t=nn(e);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function No(e){return new at().set(...e.flat())}function Pe(e,t){return[e.object,e.mesh,e.armature,e.vertexCount,e.bones.length,t].join("|")}class ko{#e=new Map;#n=null;#o=null;#t=null;#a=null;#s=null;#i=null;#c=new Set;#h=0;#m=[];#r=0;get version(){return this.#h}get engineCalls(){return this.#r}subscribe(t){return this.#c.add(t),()=>this.#c.delete(t)}#l(){this.#h++;for(const t of[...this.#c])t()}state(){const t=this.#t,n=t?.frameStart??1,s=t?.frameEnd??250,o=t?.fps??24;return{frame:this.frame(),start:n,end:s,fps:o,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#e.values()].reduce((a,c)=>a+c.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#e.keys()],warnings:this.#m,engineCalls:this.#r,blenderFrame:t?.frameCurrent??null}}frame(){const t=this.#t;return!t||!this.#o||t.clipStart===void 0?t?.frameCurrent??1:this.#a!==null?this.#a:t.clipStart+this.#o.time*t.fps}get playable(){return this.#o!==null}async bind(t,n){this.#r++;const s=await n.rig();if(!s)return;const o=[],a=new Set;let c=!1;for(const u of s.rigs){if(!u.object||!u.armature||!u.skinIndexBase64||!u.skinWeightBase64){u.reason&&o.push(u.reason);continue}a.add(u.object);const d=Pe(u,s.frame);if(this.#e.get(u.object)?.signature===d)continue;const f=this.#f(t,u,s.frame,o);f&&(this.#e.get(u.object)?.skeleton.dispose(),this.#e.set(u.object,f),c=!0)}for(const[u,d]of[...this.#e])a.has(u)||(d.skeleton.dispose(),d.boneRoot.removeFromParent(),this.#e.delete(u),c=!0);this.#r++;const r=await n.clip(),h=this.#t,l=r?.action!==h?.action||r?.tracks.length!==h?.tracks.length||r?.clipStart!==h?.clipStart||r?.clipEnd!==h?.clipEnd;this.#t=r??null,r?.reason&&o.push(r.reason),r&&(l||c)&&this.#p(t,r,o);const i=this.#s?.snapshot().playbackState==="playing";r&&!i&&h?.frameCurrent!==r.frameCurrent&&(this.#u(r.frameCurrent),this.#s&&r.fps>0&&this.#s.seek(r.frameCurrent/r.fps)),this.#m=o,this.#l()}#f(t,n,s,o){const a=t.objectForBlenderName(n.object??""),c=t.objectForBlenderName(n.armature??"");if(!a||!c)return null;const r=a,h=r.geometry;if(!h)return null;const l=h.getAttribute("blenderVertex");if(!l)return o.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let i=0;for(let M=0;M<l.count;M++)i=Math.max(i,l.getX(M));if(i>=n.vertexCount)return o.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${i} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const u=Io(n.skinIndexBase64??""),d=qt(n.skinWeightBase64??""),f=l.count,p=new Uint16Array(f*4),m=new Float32Array(f*4);for(let M=0;M<f;M++){const F=l.getX(M);for(let R=0;R<4;R++)p[M*4+R]=u[F*4+R]??0,m[M*4+R]=d[F*4+R]??0}h.setAttribute("skinIndex",new Ln(p,4)),h.setAttribute("skinWeight",new _t(m,4));const g=new it;g.name=`${n.armature}:bones`;const y=[],v=n.bones.map(M=>No(M.pose)),N=new Map(n.bones.map((M,F)=>[M.name,F]));n.bones.forEach((M,F)=>{const R=new Fn;R.name=M.name,y.push(R);const S=M.parent===null?void 0:N.get(M.parent);(S===void 0?v[F].clone():v[S].clone().invert().multiply(v[F])).decompose(R.position,R.quaternion,R.scale),(S===void 0?g:y[S]).add(R)}),c.add(g);const k=new Bn(h,r.material);k.name=r.name,k.matrixAutoUpdate=!1,k.matrix.copy(r.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale),k.userData=r.userData,k.frustumCulled=!1,t.replacePresentedObject(r,k),t.root.updateMatrixWorld(!0);const P=new Un(y);return k.bind(P,k.matrixWorld.clone()),n.constrainedBones?.length&&o.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&o.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:k,boneRoot:g,bones:y,skeleton:P,frame:s,signature:Pe(n,s)}}#p(t,n,s){if(this.#n?.stopAllAction(),this.#n=null,this.#o=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const o=n.armature?t.objectForBlenderName(n.armature):null;if(!o)return;const a=new Map;for(const u of this.#e.values())if(u.armature===n.armature)for(const d of u.bones)a.set(d.name,d);const c=[],r=new Set;for(const u of n.tracks){const d=a.get(u.bone);if(!d){r.add(u.bone);continue}const f=qt(u.timeBase64),p=qt(u.valueBase64),m=`${d.uuid}.${u.property}`;c.push(u.property==="quaternion"?new jn(m,Array.from(f),Array.from(p)):new zn(m,Array.from(f),Array.from(p)))}if(r.size&&s.push(`${n.action} animates ${[...r].join(", ")}, which this binding has no bone for.`),!c.length)return;const h=n.duration??(n.clipEnd-n.clipStart)/n.fps,l=new Dn(o),i=l.clipAction(new Wn(n.action??"action",h,c));i.setLoop(Gn,Number.POSITIVE_INFINITY),i.play(),this.#n=l,this.#o=i,this.#u(n.frameCurrent),this.#d()}#u(t){const n=this.#t;if(!n||!this.#n||n.clipStart===void 0||n.clipEnd===void 0)return;const s=Math.min(n.clipEnd,Math.max(n.clipStart,t));this.#a=s;const o=(n.clipEnd-n.clipStart)/n.fps;this.#n.setTime(Math.min(o-1e-4,(s-n.clipStart)/n.fps)),this.#d()}#d(){for(const t of this.#e.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const s=n.scene;return!s||n.frameCurrent===t||(this.#r++,await Kn(`bpy.data.scenes[${JSON.stringify(s)}]`,"frame_current",t),this.#t={...n,frameCurrent:t},this.#l()),t}get transport(){return this.#s}attachTo(t){this.#i?.(),this.#s=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const c=this.#t,r=c?.fps||24;return{start:(c?.frameStart??1)/r,end:(c?.frameEnd??250)/r,fps:r}},seek:c=>this.seekSeconds(c)}),s=t.onSettled(()=>{this.writeBookmark()}),o=()=>{s(),n(),this.#s===t&&(this.#s=null),this.#i=null};this.#i=o;const a=this.#t;return a&&a.fps>0&&t.seek(a.frameCurrent/a.fps),o}seekSeconds(t){const n=this.#t?.fps||24;this.#u(Math.round(t*n)),this.#l()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#i?.(),this.#n?.stopAllAction(),this.#n=null,this.#o=null;for(const t of this.#e.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#e.clear()}}const sn=new ko;function Uo(e){return sn.subscribe(e)}function jo(){return sn.version}export{sn as a,jo as b,Bo as c,Uo as s};