@volter/editor 0.5.57 → 0.5.58

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 (72) hide show
  1. package/BUNDLED_NOTICES +6 -6
  2. package/dist/.vite/manifest.json +228 -228
  3. package/dist/assets/{AudioViewer-DILwc7Pt.js → AudioViewer-CEfg6soG.js} +1 -1
  4. package/dist/assets/{EntityModelDocument-DVlDQ_IJ.js → EntityModelDocument-rBweka7M.js} +1 -1
  5. package/dist/assets/{EnvironmentAssetDocument-BVGDJjW4.js → EnvironmentAssetDocument-VgR_on1P.js} +1 -1
  6. package/dist/assets/{GameplaySessionTimeline-X_nMT8Sa.js → GameplaySessionTimeline-B9v8LIxV.js} +1 -1
  7. package/dist/assets/{ImageViewer-D-aZoyr1.js → ImageViewer-CvnifCXj.js} +1 -1
  8. package/dist/assets/{InspectorObjectPreview-CpHEw6QH.js → InspectorObjectPreview-gbDaFcDe.js} +1 -1
  9. package/dist/assets/{JsonAssetDocument-CLVN1V9Z.js → JsonAssetDocument-B-ze7id8.js} +1 -1
  10. package/dist/assets/{ModelAssetDocument-C60lQ11c.js → ModelAssetDocument-NDTeB7b_.js} +1 -1
  11. package/dist/assets/{NonThreeAuthoringBootstrap-D8oHDftw.js → NonThreeAuthoringBootstrap-D1oTrvVk.js} +2 -2
  12. package/dist/assets/{Object3DPreview-CSmLPKkk.js → Object3DPreview-DvXwCq08.js} +2 -2
  13. package/dist/assets/{OnlineAssetDetail-D8wVVoay.js → OnlineAssetDetail-GdHcOske.js} +2 -2
  14. package/dist/assets/{SourceAssetViewer-BcOCJ2ye.js → SourceAssetViewer-C0qk5wJl.js} +2 -2
  15. package/dist/assets/{StageHost-B_YrFNiC.js → StageHost-BU-t7Wwj.js} +4 -4
  16. package/dist/assets/{ToolObject3DPreview-Crowr7IN.js → ToolObject3DPreview-CP6YmA70.js} +1 -1
  17. package/dist/assets/{TransientHint-GNwuzA4c.js → TransientHint-Rw3wxMUO.js} +1 -1
  18. package/dist/assets/{VideoViewer-CjQ4P9AJ.js → VideoViewer-D8aW7n4N.js} +1 -1
  19. package/dist/assets/{asset-editor-persistence-D3Yy77wZ.js → asset-editor-persistence-COlYs9e4.js} +1 -1
  20. package/dist/assets/blender-emscripten-engine-BkrPLmPf.js +2 -0
  21. package/dist/assets/{blender-node-editor.document-BfvoBocD.js → blender-node-editor.document-DtaO2jAu.js} +1 -1
  22. package/dist/assets/{blender-outliner-model-B8b00oxr.js → blender-outliner-model-CfXIMSXz.js} +1 -1
  23. package/dist/assets/{blender-properties-tab-0M780SHF.js → blender-properties-tab-DYiaVS6T.js} +3 -3
  24. package/dist/assets/blender-runtime-host-DGe1KLVZ.js +4 -0
  25. package/dist/assets/{blender-runtime-skin-DcwXD-m8.js → blender-runtime-skin-CBll8ovN.js} +3 -3
  26. package/dist/assets/blender-runtime.document-CStrnPJb.js +8 -0
  27. package/dist/assets/{blender-timeline.document-RtHIpbT1.js → blender-timeline.document-WjHuKO96.js} +1 -1
  28. package/dist/assets/{blender-uv-editor.document-ChwaS3BG.js → blender-uv-editor.document-CsjAI-Lc.js} +1 -1
  29. package/dist/assets/{blender-version.status-Bnhf8h1I.js → blender-version.status-BcaIEqih.js} +1 -1
  30. package/dist/assets/{blender-wali-engine-C7bet0ss.js → blender-wali-engine-Dtwixi7B.js} +1 -1
  31. package/dist/assets/{blender.command-BCCEp0kb.js → blender.command-B9Qf17Yr.js} +1 -1
  32. package/dist/assets/{browserAll-Do0ehj3Q.js → browserAll-DAbE1efB.js} +1 -1
  33. package/dist/assets/{edit-mode-authoring-BX4IRQq9.js → edit-mode-authoring-BBWCwYeE.js} +1 -1
  34. package/dist/assets/{hosted-asset-materialization-BK7DHisS.js → hosted-asset-materialization-CvAt4P7_.js} +1 -1
  35. package/dist/assets/{index-5av5LJja.js → index-CY4oDLhJ.js} +348 -348
  36. package/dist/assets/{models.finder-Bm1YfG95.js → models.finder-CZNTvr_w.js} +1 -1
  37. package/dist/assets/{product-Ywxte8eQ.js → product-Dr7coa2h.js} +1 -1
  38. package/dist/assets/{properties-bone-constraints.inspector-Ck0Hzlvr.js → properties-bone-constraints.inspector-DBAuXqr4.js} +1 -1
  39. package/dist/assets/{properties-bone.inspector-B8M42o0V.js → properties-bone.inspector-C_F8SxhT.js} +1 -1
  40. package/dist/assets/{properties-collection.inspector-D-RSO5zy.js → properties-collection.inspector-C1DLm9eT.js} +1 -1
  41. package/dist/assets/{properties-constraints.inspector-DbJa57oa.js → properties-constraints.inspector-BySUEgAb.js} +1 -1
  42. package/dist/assets/{properties-data.inspector-DLgjbRW6.js → properties-data.inspector-BOvrvedq.js} +1 -1
  43. package/dist/assets/{properties-material.inspector-B11LZYDW.js → properties-material.inspector-CGJmh_QM.js} +1 -1
  44. package/dist/assets/{properties-modifiers.inspector-BCWwuA26.js → properties-modifiers.inspector-xnsQ1ddN.js} +1 -1
  45. package/dist/assets/{properties-object.inspector-UZVJG49S.js → properties-object.inspector-BOEEbStu.js} +1 -1
  46. package/dist/assets/{properties-output.inspector-XOwcBits.js → properties-output.inspector-NXZnMx4l.js} +1 -1
  47. package/dist/assets/{properties-particles.inspector-By04vT7R.js → properties-particles.inspector-D6D1g8l3.js} +1 -1
  48. package/dist/assets/{properties-physics.inspector-D3T7FLdg.js → properties-physics.inspector-DoPfj0an.js} +1 -1
  49. package/dist/assets/{properties-render.inspector-Y0Rjr9gZ.js → properties-render.inspector-Cvnkkapn.js} +1 -1
  50. package/dist/assets/{properties-scene.inspector-CfyDWB4W.js → properties-scene.inspector-C2mQ8GLM.js} +1 -1
  51. package/dist/assets/{properties-texture.inspector-AFRsJx6-.js → properties-texture.inspector-DvASuzXS.js} +1 -1
  52. package/dist/assets/{properties-view-layer.inspector-Co07LAmQ.js → properties-view-layer.inspector-FIxWmUI0.js} +1 -1
  53. package/dist/assets/{properties-world.inspector-C7T4JocI.js → properties-world.inspector-BfopwUSa.js} +1 -1
  54. package/dist/assets/{react-story-board-vrmj74Ng.js → react-story-board-DBO76grK.js} +1 -1
  55. package/dist/assets/{react-three-rapier.esm-D874pLFD.js → react-three-rapier.esm-Cj4NtDam.js} +1 -1
  56. package/dist/assets/{session-1bPxsLdy.js → session-Dv4dTRLk.js} +180 -22
  57. package/dist/assets/{spark.module-D1CUMLYS.js → spark.module-BOFvGTtp.js} +1 -1
  58. package/dist/assets/{stage-keyboard-Cx90EYIT.js → stage-keyboard-BsKOZggP.js} +1 -1
  59. package/dist/assets/{stage-overlay-set-duu3P0mZ.js → stage-overlay-set-bQwh25SV.js} +1 -1
  60. package/dist/assets/{stage-presence-markers-DKH3p_ao.js → stage-presence-markers-CALnBqqb.js} +1 -1
  61. package/dist/assets/{story-capture-Dqurwlhr.js → story-capture-BLVE1Bck.js} +1 -1
  62. package/dist/assets/{story-pixi-preview-c78Aygdi.js → story-pixi-preview-B1LxWTHx.js} +1 -1
  63. package/dist/assets/{story-three-preview-CbZo5B3D.js → story-three-preview-CsjJKTcf.js} +2 -2
  64. package/dist/assets/{webworkerAll-iMzrvNir.js → webworkerAll-dq7Pw9V8.js} +1 -1
  65. package/dist/assets/worker-29OHwCKe.js +2 -0
  66. package/dist/assets/{world-documents-CGbrcsYk.js → world-documents-PX5fRvVn.js} +1 -1
  67. package/dist-node/cli.js +9 -9
  68. package/package.json +9 -9
  69. package/dist/assets/blender-emscripten-engine-C_uFxIuO.js +0 -2
  70. package/dist/assets/blender-runtime-host-D8NHsAfD.js +0 -4
  71. package/dist/assets/blender-runtime.document-BixTvrw8.js +0 -7
  72. package/dist/assets/worker-DTgfRRas.js +0 -1
@@ -1,5 +1,5 @@
1
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=`
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 mt,aa as Fe,aC as Ot,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 Qt,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 On,am as _n,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 O,c2 as H,c3 as Q,c4 as _,c5 as G,_ as $n,c6 as Vn,c7 as ne,l as U,bA as at,c8 as Hn,c9 as z,ca as Yn,cb as qn}from"./index-CY4oDLhJ.js";import{p as Qn}from"./blender-runtime-host-DGe1KLVZ.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=_().finite(),Xn=A({name:O(),parent:O().nullable(),connected:H(),hide:H(),length:At,matrix:C(G([At,At,At,At])).length(4),select:H(),active:H(),lockedWeight:H()}).strict(),Kn=A({object:O(),displayType:Q(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:H(),mode:O(),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]],ct=Math.SQRT1_2,Zn=[[ct,-ct,0],[0,-ct,-ct],[-ct,-ct,0],[0,-ct,ct],[.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
3
  attribute vec3 aSolid;
4
4
  attribute vec3 aHint;
5
5
  varying vec3 vColor;
@@ -16,7 +16,7 @@ import{L as rn,a as an,b as cn}from"./LineSegments2-vfeDUBfs.js";import{aB as it
16
16
  gl_FragColor = vec4(vColor, 1.0);
17
17
  #include <colorspace_fragment>
18
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:`
19
+ `;function ut(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=ut(et.poseActive):t.active?s=ut(et.poseActiveUnsel):t.select?s=ut(et.pose):s=ut(et.wire):s=ut(et.vertex),n&&t.lockedWeight&&s.lerp(ut(et.lockedWeight),et.lockedWeightFactor),s}function fe(e,t){const n=ut(et.solid);return e.mode==="POSE"&&t.lockedWeight&&n.lerp(ut(et.lockedWeight),et.lockedWeightFactor),n}const is=new mt,as=new x,pe=new Le;function ge(e,t){return new mt().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 i=a.bones.filter(l=>!l.hide);if(i.length===0)continue;const h=a.displayType==="STICK"?this.buildStick(a,i,c):this.buildOctahedral(a,i,c);a.showInFront&&h.traverse(l=>{const r=l.material;r&&"depthTest"in r&&(r.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=[],i=[],h=[],l=[],r=[],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),i.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:r;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,i,h)),l.length&&o.add(this.lines(l,r,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=[],i=[],h=[];for(const l of n){const r=ge(s,l),u=new x().setFromMatrixPosition(r),d=new x(0,1,0).applyMatrix4(r),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),i.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(i,h,ss)),o}solidMesh(t,n,s,o){const a=new Fe;a.setAttribute("position",new Ot(t,3)),a.setAttribute("normal",new Ot(n,3)),a.setAttribute("aSolid",new Ot(s,3)),a.setAttribute("aHint",new Ot(o,3));const c=new Be({vertexShader:os,fragmentShader:rs,side:ln});this.disposables.push(a,c);const i=new kt(a,c);return i.frustumCulled=!1,i}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 i=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),i.set(N.next,g),h.set(y,v.next),i.set(v.next,y))}const l=[],r=[],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(r[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(;i.has(y.at(-1))&&i.get(y.at(-1))!==m;)y.push(i.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)r[S]=l.length;l.push(y),u.push(R),d.push(v)}return{corners:t,fans:l,fanOf:r,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(i=>b(i*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,i]of s.entries()){const h=i.reduce((r,u)=>{const d=t.data[u];return[r[0]+d[0],r[1]+d[1]]},[0,0]),l=fs(o[c],h.map(r=>Math.trunc(r/i.length)));for(const r of i)a[r]=l}return a}if(t.type==="FLOAT_VECTOR")return n.map((a,c)=>{const i=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:c;return t.data[i]});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,i]of e){const h=ys(t[a],t[c],t[i]);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(),i=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(i))}),r=vs(l),u=ve(t);if(we(u,l,r))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,r)?{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 i=new Uint32Array(a),h=new Uint8Array(a),l=new Uint8Array(t),r=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(;r[w]!==w;)r[w]=r[r[w]],w=r[w];return w},g=(w,I)=>{const B=m(w),D=m(I);r[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,i[E]=I+($+1)%B,h[E]=D,r[E]=E}}for(let w=0;w<a;w++){const I=i[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=i[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,i=e.edge.length/2,h=new Array(i);for(let m=0;m<i;m++)h[m]=[e.edge[m*2],e.edge[m*2+1]];const l=[];for(let m=0;m<i;m++)e.edgeSharp[m]===1&&l.push(h[m]);const r=e.attributes.find(m=>m.name==="custom_normal"),u=r?{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=r?{type:r.type,domain:r.domain,data:Array.from({length:r.data.length/$t[r.type].size},(m,g)=>Array.from({length:$t[r.type].size},(y,v)=>Number(r.data[g*$t[r.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"),i=e.render_uv??e.active_uv??c[0]?.name,h=c.find(u=>u.name===i);if(i&&!h)throw new Error(`Runtime UV map ${i} is missing`);const l=h?.data,r={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(r))}const Ct=1.5707963267948966,gt=6.283185307179586,He=.3183098861837067,Ye=.0795774715459476,xs=.3,Ss=Ye,As=3/16*He,Kt=.8,be=Kt*Kt,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],Os=334.5,_s=[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,_t=e=>e<0?0:e>1?1:e,ot=(e,t,n)=>e+n*(t-e),Cs=e=>Math.sqrt(Math.max(e,0)),Qe=e=>[-Math.sqrt(1-e*e),0,e];function Zt(e,t,n,s,o,a,c){const i=e*s+t*o+n*a,h=e*e+t*t+n*n-c*c;if(h>0&&i>0)return-1;const l=i*i-h;return l<0?-1:l>=i*i?-i+Math.sqrt(l):-i-Math.sqrt(l)}const Ps=e=>As*(1+Dt(e));function Ls(e){const t=1+be+2*Kt*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 i=0;i<4;i++)n[i]=_s[i]*s,n[4+i]=Is[i]*s,n[8+i]=Rs[i]*Os*a*this.ozone,n[12+i]=Ts[i]*c*this.air}transmittance(t,n,s){const[o,a,c]=Qe(t),i=ot(yt,Jt,n),l=Zt(0,0,i,o,a,c,Jt)/Me,r=[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=i+c*f,y=Math.max(Math.hypot(p,m,g)-yt,0);this.coefficients(y,u);for(let v=0;v<4;v++)r[v]+=(u[v]+u[4+v]+u[8+v]+u[12+v])*l}for(let d=0;d<4;d++)s[d]=Math.exp(-r[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 i=0;i<4;i++)this.lut[c+i]=t[i]}}lookup(t,n,s){const o=(q-1)*_t(t*.5+.5),a=(dt-1)*_t(n),c=Math.trunc(o),i=Math.trunc(a),h=Math.min(c+1,q-1),l=Math.min(i+1,dt-1),r=o-c,u=a-i,d=(i*q+c)*4,f=(i*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],r),ot(this.lut[p+g],this.lut[m+g],r),u)}lookupAtGround(t,n){const s=(q-1)*_t(t*.5+.5),o=Math.trunc(s),a=Math.min(o+1,q-1),c=s-o;for(let i=0;i<4;i++)n[i]=ot(this.lut[o*4+i],this.lut[a*4+i],c)}lookupToSun(t,n){const s=(dt-1)*_t(t),o=Math.trunc(s),a=Math.min(o+1,dt-1),c=s-o,i=q-1;for(let h=0;h<4;h++)n[h]=ot(this.lut[(o*q+i)*4+h],this.lut[(a*q+i)*4+h],c)}inscattering(t,n,s,o,a,c,i,h,l){const r=-(a*t[0]+c*t[1]+i*t[2]),u=Ps(r),d=Ls(r),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+i*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 K=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=Qe(Math.cos(Ct-t)),a=new Float32Array(K*xt*3),c=K/2,i=new Float64Array(4);for(let h=0;h<xt;h++)for(let l=0;l<c;l++){const r=(l+.5)/K,u=(h+.5)/xt,d=gt*r,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,i);let M=0,F=0,R=0;for(let j=0;j<4;j++)M+=Vt[j][0]*i[j],F+=Vt[j][1]*i[j],R+=Vt[j][2]*i[j];const S=(h*K+l)*3;a[S]=M,a[S+1]=F,a[S+2]=R;const L=(h*K+(K-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 Ke(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),Ke(e,o));const a=new x;return c=>{const i=Math.hypot(c.x,c.y),h=Math.atan2(c.z,i);let r=(Math.atan2(c.x,c.y)+Math.PI+n)/gt;r-=Math.floor(r);const u=Math.abs(h),d=_t(Math.sqrt(u/Ct)*Math.sign(h)*.5+.5),f=r*K-.5,p=d*xt-.5,m=Math.floor(f),g=Math.floor(p),y=f-m,v=p-g,N=L=>(L%K+K)%K,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*K+P)*3+L],o[(F*K+M)*3+L],y),nt=ot(o[(R*K+P)*3+L],o[(R*K+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 lt=null,Bt=!1,Ws=0;const It=new Map;function Gs(){if(lt||Bt)return lt;if(typeof Worker>"u")return Bt=!0,null;try{lt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return Bt=!0,null}return lt.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")))},lt.onerror=e=>{const t=new Error(`sky worker failed: ${e.message||"unknown error"}`);for(const n of It.values())n.reject(t);It.clear(),lt?.terminate(),lt=null,Bt=!0},lt}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 i=>{const h=o(i),l=typeof h=="number"?h:h.x,r=typeof h=="number"?h:h.y,u=typeof h=="number"?h:h.z,d=tt.clamp(Vs(l,r,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(i=>V(i,t)),a=Je[e.operation],c=(i,h)=>{const l=o[i]?.(h)??0;if(typeof l!="number")throw new Error("World Math needs scalar inputs");return Math.fround(l)};return i=>{const h=Math.fround(a(c(0,i),c(1,i),c(2,i)));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),i=new x,h=new x;return l=>{const r=o(l);if(typeof r!="number")throw new Error("World color Mix needs a scalar factor");const u=a(l);typeof u=="number"?i.setScalar(u):i.copy(u);const d=c(l);return typeof d=="number"?h.setScalar(d):h.copy(d),i.lerp(h,e.clamp_factor?tt.clamp(r,0,1):r),e.clamp_result&&i.clampScalar(0,1),i}}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 x(...e.location),c=new x(...e.scale),i=new dn().setFromEuler(new fn(e.rotation[0],e.rotation[1],e.rotation[2],"ZYX")),h=i.clone().invert(),l=new x(...e.scale.map(u=>u===0?0:1/u)),r=new x;return u=>{const d=o(u);switch(typeof d=="number"?r.setScalar(d):r.copy(d),e.vector_type??"POINT"){case"TEXTURE":return r.sub(a).applyQuaternion(h).multiply(l);case"VECTOR":return r.multiply(c).applyQuaternion(i);case"NORMAL":return r.multiply(l).applyQuaternion(i).normalize();case"POINT":return r.multiply(c).applyQuaternion(i).add(a)}}}if(e.kind==="map_range"){const o=V(e.value,t),a=V(e.from_min,t),c=V(e.from_max,t),i=V(e.to_min,t),h=V(e.to_max,t),l=V(e.steps,t),r=(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=r(o,f),m=r(a,f),g=r(c,f),y=r(i,f),v=r(h,f);if(m===g)return 0;let N;if(u==="STEPPED"){const P=r(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,i=Math.floor(c),h=e.colors[i],l=e.colors[Math.min(i+1,256)],r=e.interpolate?c-i:0;return s.set(tt.lerp(h[0],l[0],r),tt.lerp(h[1],l[1],r),tt.lerp(h[2],l[2],r))}}function Hs(e,t,n,s){const o=new Float32Array(t*n*3),a=V(e,s),c=new x;for(let i=0;i<n;i++){const h=((i+.5)/n-.5)*Math.PI;for(let l=0;l<t;l++){const r=((l+.5)/t-.5)*2*Math.PI;c.set(Math.cos(h)*Math.cos(r),-Math.cos(h)*Math.sin(r),Math.sin(h));const u=a(c),d=(i*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 ht(e){if(typeof e=="number"||Array.isArray(e))return!1;switch(e.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return ht(e.vector);case"ramp":return ht(e.factor);case"mix_color":return[e.factor,e.a,e.b].some(ht);case"math":return e.inputs.some(ht);case"to_float":return ht(e.value);case"map_range":return[e.value,e.from_min,e.from_max,e.to_min,e.to_max,e.steps].some(ht);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),i=new x,h=s.getWorldPosition(new x),l=s.getWorldDirection(new x);for(let r=0;r<n;r++)for(let u=0;u<t;u++){const d=(u+.5)/t,f=(r+.5)/n;a.set(d,f,0),s.isOrthographicCamera?i.copy(l):i.set(d*2-1,f*2-1,.5).unproject(s).sub(h).normalize(),i.set(i.x,-i.z,i.y);const p=c(i),m=(r*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=_().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 Qs(){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 Ks=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,i)=>t&&i(t)?t:new c;if(e.type==="SUN"){const c=n(ze,i=>i.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,i=>i.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,i=>i.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}Qs();const s=n(xn,c=>c.isRectAreaLight),[o,a]=Ks(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,i=new ze(16777215,Math.PI*Re/c);i.name=`BlenderSolidLight${o}`,i.color.setRGB(a.diffuse[0],a.diffuse[1],a.diffuse[2],rt),i.position.set(a.direction[0],a.direction[1],a.direction[2]),i.target=t,this.group.add(i),this.lights.push(i),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_type:Q(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:Y,location:bt,rotation:bt,scale:bt}).strict(),A({kind:U("separate"),vector:Y,axis:_().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()])),Oe=A({color:bt,strength:W,shader:Y.optional()}),so=Oe.extend({lighting:Oe.strict().optional()}).strict(),oo=4,Rt=new Map,Yt=new Set;function _e(e,t,n){const a=ht(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]),i=Rt.get(c);if(i!==void 0)return ee(i,t,256,128);const h=new x,l=new yn,r=n?new mt().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(r),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=Qt,a.magFilter=Qt,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(r=>!zs(r));if(h.length===0){this.compose(o,n,a,s);return}const l=(async()=>{const r=await Promise.all(h.map($s));h.forEach((u,d)=>{Ke(u,r[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=_e(s,n.strength,o),ht(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 i=V(n.shader??n.color)(c);t.background=typeof i=="number"?new vt().setRGB(i,i,i).multiplyScalar(n.strength):new vt().setRGB(i.x,i.y,i.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:a}=n;this.environmentTexture=a?_e(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(r=>t.containsPoint(r)))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,i=new x,h=new x,l=Math.max(1,e.min.length(),e.max.length())*1e-8;for(let r=0;r<s.length;r++)for(let u=r+1;u<s.length;u++)for(let d=u+1;d<s.length;d++){const f=s[r],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),i.crossVectors(f.normal,p.normal),h.copy(a).multiplyScalar(-f.constant).addScaledVector(c,-p.constant).addScaledVector(i,-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),i=Math.max(c.length()*1e-6,Number.EPSILON),h=2+2*Math.SQRT2,l=Math.max(c.x,c.y,i)/Math.max(1,Math.min(e.shadow.mapSize.x,e.shadow.mapSize.y)-2*h),r=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-r-i,s.far=-a.min.z+r+i,s.updateProjectionMatrix(),e.shadow.normalBias=r}const St=_().finite(),Ie=G([St,St,St]),tn=A({min:G([_().int(),_().int(),_().int()]),max:G([_().int(),_().int(),_().int()]),density:C(St),voxelSize:St.positive(),color:Ie,emission:Ie,densityScale:St.nonnegative()}).strict();function co(e){const t=e.max.map((r,u)=>r-e.min[u]+1);if(t.some(r=>r<=0)||t.reduce((r,u)=>r*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=Qt,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 r=0;r<c.count;r++)c.setXYZ(r,s.x+(c.getX(r)>0?o.x:0),s.y+(c.getY(r)>0?o.y:0),s.z+(c.getZ(r)>0?o.z:0));c.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const i=new Be({glslVersion:On,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
20
  out vec3 localPosition;
21
21
  void main() {
22
22
  localPosition = position;
@@ -58,4 +58,4 @@ import{L as rn,a as an,b as cn}from"./LineSegments2-vfeDUBfs.js";import{aB as it
58
58
  outputColor = vec4(radiance, 1.0 - transmission);
59
59
  #include <tonemapping_fragment>
60
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};
61
+ }`}),h=new kt(a,i),l=new mt;return h.onBeforeRender=(r,u,d)=>{l.copy(h.matrixWorld).invert(),i.uniforms.cameraLocal.value.setFromMatrixPosition(d.matrixWorld).applyMatrix4(l),d.getWorldDirection(i.uniforms.rayLocal.value).transformDirection(l),i.uniforms.orthographic.value=!!d.isOrthographicCamera,i.uniforms.worldScale.value.setFromMatrix4(h.matrixWorld)},i.addEventListener("dispose",()=>n.dispose()),h}const lo=A({object:O(),group:O(),groupIndex:_().int().nonnegative(),count:_().int().nonnegative(),digest:O(),alertMode:Q(["NONE","ACTIVE","ALL"]),unchanged:U(!0).optional(),weightsBase64:O().optional(),alertBase64:O().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)),i=new vt;return i.setRGB((o*s)**(1/1.5),(a*s)**(1/1.5),(c*s)**(1/1.5),Pt),i}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 i=n.geometry.clone(),h=i.getAttribute("position"),l=i.getAttribute("blenderVertex");if(l===void 0)return i.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const r=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);r[p*3]=y.r,r[p*3+1]=y.g,r[p*3+2]=y.b}i.setAttribute("color",new pt(r,3)),i.deleteAttribute("blenderVertex");const d=new Ue({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),f=new kt(i,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=i,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=_().finite(),en=G([T,T,T]),Ut=G([_().int().nonnegative(),_().int().nonnegative()]),X={name:O(),domain:Q(["POINT","EDGE","FACE","CORNER"])},po=Yn("type",[A({...X,type:U("FLOAT2"),data:C(G([T,T]))}).strict(),A({...X,type:U("FLOAT_VECTOR"),data:C(en)}).strict(),A({...X,type:U("FLOAT_COLOR"),data:C(G([T,T,T,T]))}).strict(),A({...X,type:U("BYTE_COLOR"),data:C(G([T,T,T,T]))}).strict(),A({...X,type:U("QUATERNION"),data:C(G([T,T,T,T]))}).strict(),A({...X,type:U("FLOAT4"),data:C(G([T,T,T,T]))}).strict(),A({...X,type:U("FLOAT4X4"),data:C(C(T).length(16))}).strict(),A({...X,type:U("INT16_2D"),data:C(G([_().int(),_().int()]))}).strict(),A({...X,type:U("INT32_2D"),data:C(G([_().int(),_().int()]))}).strict(),A({...X,type:U("FLOAT"),data:C(T)}).strict(),A({...X,type:U("INT"),data:C(_().int())}).strict(),A({...X,type:U("INT8"),data:C(_().int())}).strict(),A({...X,type:U("BOOLEAN"),data:C(H())}).strict(),A({...X,type:U("STRING"),data:C(O())}).strict()]),go=A({positions:z(Float32Array),normals:z(Float32Array).nullable(),uv:z(Float32Array).nullable(),indices:z(Uint32Array),groups:C(A({start:_().int().nonnegative(),count:_().int().nonnegative(),materialIndex:_().int().nonnegative()}).strict()),hash:O()}).strict(),yo=A({v:C(en),f:C(C(_().int().nonnegative())),e:C(Ut).optional(),edge_order:C(Ut).optional(),m:C(_().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:O().nullable().optional(),render_uv:O().nullable().optional()}).strict(),vo=A({store:_().int().optional(),revision:_().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:O(),domain:Q(["POINT","EDGE","FACE","CORNER"]),type:O(),data:qn(e=>ArrayBuffer.isView(e))}).strict(),Mo=A({columns:wo,attributes:C(bo),activeUv:O().nullable(),renderUv:O().nullable(),counts:A({verts:_().int().nonnegative(),edges:_().int().nonnegative(),faces:_().int().nonnegative(),corners:_().int().nonnegative()}).strict(),revision:_().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:_().int().positive(),height:_().int().positive(),revision:_().int().nonnegative(),rgba:z(Uint8Array).optional(),rgbaBase64:O().optional(),colorspace:Q(["sRGB","data"]).optional()}).strict(),To=A({revision:_().int().nonnegative(),png:z(Uint8Array).optional(),pngBase64:O().optional()}).strict(),Ro=ne([Eo,To]),Ce=A({image:A({name:O(),revision:_().int().nonnegative()}).strict(),extension:Q(["REPEAT","EXTEND","MIRROR"]).default("REPEAT"),uv:O(),tint:G([T,T,T]).optional()}).strict(),Oo=A({name:O(),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(),_o=A({session:O(),revision:_().int().nonnegative(),volumes:at(O(),tn).default({}),lights:at(O(),qs).default({}),world:so.nullable().default(null),meshes:at(O(),xo),materials:at(O(),Oo),images:at(O(),Ro).default({}),objects:C(A({id:O(),name:O(),type:Q(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:O().nullable(),volume:O().nullable().optional(),light:O().nullable().optional(),materials:C(O().nullable()),matrix:C(G([T,T,T,T])).length(4),visible:H(),render_visible:H().default(!0),selected:H(),parent:O().nullable()}).strict()),active:O().nullable(),mode:O(),cameras:at(O(),at(O(),Hn())).default({}),warnings:C(O()).default([]),updated:C(O()).default([]),frame:_().int().default(0),armatures:at(O(),Kn).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 _n({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 i of c)n.add(i);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 r=new jt().setFromObject(l);r.isEmpty()||s.push(r)}}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 mt().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,i=c?s.flatMap(h=>io(h,c)):[];for(const h of this.lights.values())h.isDirectionalLight&&n?ao(h,i,s):Zs(h,a.center,a.radius)}applyOverlays(t){const n=c=>{const i=t.objects.find(h=>h.name===c);return i===void 0?null:new mt().set(...i.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=_o.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 r=new Set([l.id]);let u=l.parent;for(;u!==null;){if(r.has(u))throw new Error("Runtime parent cycle");r.add(u);const d=a.get(u);if(!d)throw new Error(`Missing runtime parent ${u}`);u=d.parent}}const c=new Map,i=new Map;try{for(const[l,r]of Object.entries(s.volumes)){const u=JSON.stringify(r);this.frame?.session===s.session&&this.volumes.get(l)?.signature===u||i.set(l,{signature:u,mesh:co(r)})}for(const[l,r]of Object.entries(s.meshes)){if("unchanged"in r){if(this.frame?.session===s.session&&this.meshes.has(l))continue;throw new Error(`${ls}: the presenter does not hold runtime mesh ${l} (store ${r.store}, revision ${r.revision})`)}const u="hash"in r,d="columns"in r,f=d?`revision:${r.revision}`:u?r.hash:JSON.stringify(r);this.frame?.session===s.session&&this.meshes.get(l)?.signature===f||c.set(l,{signature:f,geometry:d?Xt(bs({...r.columns,attributes:r.attributes,activeUv:r.activeUv,renderUv:r.renderUv},f)):u?Xt(r):Ms(r)})}}catch(l){for(const r of c.values())r.geometry.dispose();for(const{mesh:r}of i.values())r.geometry.dispose(),r.material.dispose();throw l}this.frame?.session!==s.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[l,r]of i){const u=this.volumes.get(l)?.mesh;u&&(u.removeFromParent(),u.geometry.dispose(),u.material.dispose()),this.volumes.set(l,r)}for(const[l,r]of c)this.meshes.get(l)?.geometry.dispose(),this.meshes.set(l,r),this.geometryBuilds++;for(const[l,r]of Object.entries(s.images)){const u=this.textures.get(l);if("width"in r){const m=r.rgba??(r.rgbaBase64?ue(r.rgbaBase64):void 0);if(!m)throw new Error(`Runtime image ${l} carries no raster`);if(u&&u.width===r.width&&u.height===r.height){const g=u.texture.image;if(g.data){g.data.set(m),u.texture.needsUpdate=!0,u.revision=r.revision;continue}}u?.texture.dispose(),this.textures.set(l,{texture:Ao(m,r.width,r.height,r.colorspace??"sRGB"),width:r.width,height:r.height,revision:r.revision});continue}const d=r.png??(r.pngBase64?ue(r.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:r.revision,png:d.slice()})}for(const[l,r]of Object.entries(s.materials)){const u=this.materials.get(l)??new kn;u.name=r.name;const d=r.texture?.tint;r.texture!==void 0?u.color.setRGB(d?.[0]??1,d?.[1]??1,d?.[2]??1,rt):u.color.setRGB(r.color[0],r.color[1],r.color[2],rt),u.opacity=r.color[3];const f=u.opacity<1;u.transparent!==f&&(u.transparent=f,u.needsUpdate=!0),u.roughness=r.roughness,u.metalness=r.metallic,u.transmission=r.transmission,u.ior=r.ior,r.emission?(u.emissive.setRGB(r.emission.color[0],r.emission.color[1],r.emission.color[2],rt),u.emissiveIntensity=r.emission.strength):(u.emissive.setRGB(0,0,0),u.emissiveIntensity=1);const p=r.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 ${r.roughness_texture.image.revision})`);const y=g.texture,v=r.roughness_texture.extension==="EXTEND"?ae:r.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=r.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 ${r.texture.image.revision})`);const y=g.texture,v=r.texture.extension==="EXTEND"?ae:r.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 r=this.objects.get(l.id);const u=l.volume?this.volumes.get(l.volume).mesh:null;if((!r||(u?r!==u:!!r.isMesh!=(l.mesh!==null)))&&(r?.removeFromParent(),r=u??(l.mesh!==null?new kt(this.meshes.get(l.mesh).geometry,this.fallback):new je),this.objects.set(l.id,r)),r.name=l.name,r.matrixAutoUpdate=!1,r.matrix.set(...l.matrix.flat()),l.parent){const d=new mt().set(...a.get(l.parent).matrix.flat());r.matrix.premultiply(d.invert())}if(r.matrix.decompose(r.position,r.quaternion,r.scale),l.mesh!==null){const d=r;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!==r&&r.add(f),to(f,r),this.lights.set(l.light,f)}}for(const l of s.objects){const r=this.objects.get(l.id),u=l.parent===null?this.root:this.objects.get(l.parent);r.parent!==u&&u.add(r)}for(const[l,r]of this.objects)o.has(l)||(r.removeFromParent(),this.objects.delete(l));for(const[l,r]of this.volumes)s.volumes[l]||(r.mesh.geometry.dispose(),r.mesh.material.dispose(),this.volumes.delete(l));for(const[l,r]of this.meshes)s.meshes[l]||(r.geometry.dispose(),this.meshes.delete(l));for(const[l,r]of this.materials)s.materials[l]||(r.dispose(),this.materials.delete(l));for(const[l,r]of this.lights)s.lights[l]||(r.removeFromParent(),r.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[i,{signature:h,geometry:l}]of this.meshes){const r=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=r("position");if(!u)throw new Error(`Blender capture mesh ${i} has no positions`);const d=l.getIndex();n.meshes[i]={hash:h,positions:u,normals:r("normal"),uv:r("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[i,{signature:h}]of this.volumes)n.volumes[i]=tn.parse(JSON.parse(h));const s=new Set(Object.values(n.materials).flatMap(i=>[i.texture?.image.name,i.roughness_texture?.image.name].filter(h=>h!==void 0)));for(const i of s){const h=this.textures.get(i);if(!h)throw new Error(`Blender capture image ${i} is not resident`);if(h.png)n.images[i]={revision:h.revision,png:h.png.slice()};else{const l=h.texture.image?.data;if(!(l instanceof Uint8Array))throw new Error(`Blender capture image ${i} has no resident raster`);n.images[i]={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(i){throw c(),i}return{root:o.root,session:t.session,revision:t.revision,prepare:i=>{if(a)throw new Error("Blender capture snapshot is disposed");return o.setRendered(!0,i)},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,i]of Object.entries(a))typeof i=="object"&&i!==null&&!("unchanged"in i)&&this.submittedMeshes.set(c,i);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 mt().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 i=await n.clip(),h=this.#t,l=i?.action!==h?.action||i?.tracks.length!==h?.tracks.length||i?.clipStart!==h?.clipStart||i?.clipEnd!==h?.clipEnd;this.#t=i??null,i?.reason&&o.push(i.reason),i&&(l||c)&&this.#p(t,i,o);const r=this.#s?.snapshot().playbackState==="playing";i&&!r&&h?.frameCurrent!==i.frameCurrent&&(this.#u(i.frameCurrent),this.#s&&i.fps>0&&this.#s.seek(i.frameCurrent/i.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 i=a,h=i.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 r=0;for(let M=0;M<l.count;M++)r=Math.max(r,l.getX(M));if(r>=n.vertexCount)return o.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${r} 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 Ot(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,i.material);k.name=i.name,k.matrixAutoUpdate=!1,k.matrix.copy(i.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale),k.userData=i.userData,k.frustumCulled=!1,t.replacePresentedObject(i,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=[],i=new Set;for(const u of n.tracks){const d=a.get(u.bone);if(!d){i.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(i.size&&s.push(`${n.action} animates ${[...i].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),r=l.clipAction(new Wn(n.action??"action",h,c));r.setLoop(Gn,Number.POSITIVE_INFINITY),r.play(),this.#n=l,this.#o=r,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 Qn(`bpy.data.scenes[${JSON.stringify(s)}]`,"frame_current",t,void 0,!1),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,i=c?.fps||24;return{start:(c?.frameStart??1)/i,end:(c?.frameEnd??250)/i,fps:i}},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};
@@ -0,0 +1,8 @@
1
+ import{a as u}from"./jsx-runtime-DPjLkJKQ.js";import{c as de,a as ue}from"./blender-runtime-skin-CBll8ovN.js";import{e as V,ai as be,aj as S,ak as B,al as z,am as pe,an as fe}from"./index-CY4oDLhJ.js";import{r as O}from"./index-DaQZGF7d.js";import{p as te,q as me,t as ge,u as oe,v as he,w as re}from"./blender-runtime-host-DGe1KLVZ.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{o as ye,s as $,r as D,b as je,a as q,c as Y,w as le,d as _e,e as P}from"./blender-outliner-model-CfXIMSXz.js";import{bf as ve}from"./three.module-BynznMJN.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./LineSegments2-vfeDUBfs.js";import"./client-DNXj_opT.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./clip-planes-CnAI6DZn.js";function ke(l){return`blender-${l.toLowerCase().replace(/_/g,"-")}`}function x(l){return l?.type==="TSE_SOME_ID"&&l.struct==="Object"&&l.object!==void 0}function ne(l){if(l.struct)return l.struct}function ae(l,o){return{id:l.id,label:l.name,role:"entity",kind:ke(l.icon),...ne(l)?{typeLabel:ne(l)}:{},parentId:o,childIds:l.children.map(n=>n.id),defaultExpanded:l.expanded}}const we={transform:!0,inspectorFields:!1,persist:!0},L=new Set;function Ee(l){for(const o of L)if(o.documentId===l)return o;return L.size===1?[...L][0]:null}const Oe=()=>({position:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]});function Se(l,o){l.updateWorldMatrix(!0,!1);const n=o.matrixWorld.clone().invert().multiply(l.matrixWorld).elements;return[[n[0],n[1],n[2],n[3]],[n[4],n[5],n[6],n[7]],[n[8],n[9],n[10],n[11]],[n[12],n[13],n[14],n[15]]]}function M(l,o){return`${l} needs a file, and this editor has no door to ask for one: the host's file door (\`EditorHost.files\`, \`@volter/editor-sdk/host\`) reads and writes project-relative paths and has no file-picker member, so there is nothing to open the workbench's own dialog through. Blender's row opens a file browser; run without one, the engine answers "${o}".`}const Ce=[{kind:"mesh.plane",label:"Plane",group:"Mesh",call:"mesh.primitive_plane_add"},{kind:"mesh.cube",label:"Cube",group:"Mesh",call:"mesh.primitive_cube_add"},{kind:"mesh.circle",label:"Circle",group:"Mesh",call:"mesh.primitive_circle_add"},{kind:"mesh.uv-sphere",label:"UV Sphere",group:"Mesh",call:"mesh.primitive_uv_sphere_add"},{kind:"mesh.ico-sphere",label:"Ico Sphere",group:"Mesh",call:"mesh.primitive_ico_sphere_add"},{kind:"mesh.cylinder",label:"Cylinder",group:"Mesh",call:"mesh.primitive_cylinder_add"},{kind:"mesh.cone",label:"Cone",group:"Mesh",call:"mesh.primitive_cone_add"},{kind:"mesh.torus",label:"Torus",group:"Mesh",call:"mesh.primitive_torus_add"},{kind:"mesh.grid",label:"Grid",group:"Mesh",call:"mesh.primitive_grid_add",separatorBefore:!0},{kind:"mesh.monkey",label:"Monkey",group:"Mesh",call:"mesh.primitive_monkey_add"},{kind:"curve.bezier",label:"Bézier",group:"Curve",call:"curve.primitive_bezier_curve_add"},{kind:"curve.bezier-circle",label:"Circle",group:"Curve",call:"curve.primitive_bezier_circle_add"},{kind:"curve.nurbs-curve",label:"Nurbs Curve",group:"Curve",call:"curve.primitive_nurbs_curve_add",separatorBefore:!0},{kind:"curve.nurbs-circle",label:"Nurbs Circle",group:"Curve",call:"curve.primitive_nurbs_circle_add"},{kind:"curve.path",label:"Path",group:"Curve",call:"curve.primitive_nurbs_path_add"},{kind:"curve.empty-hair",label:"Empty Hair",group:"Curve",call:"object.curves_empty_hair_add",separatorBefore:!0},{kind:"curve.fur",label:"Fur",group:"Curve",call:"object.quick_fur",placesAtOrigin:!1},{kind:"surface.nurbs-curve",label:"Nurbs Curve",group:"Surface",call:"surface.primitive_nurbs_surface_curve_add"},{kind:"surface.nurbs-circle",label:"Nurbs Circle",group:"Surface",call:"surface.primitive_nurbs_surface_circle_add"},{kind:"surface.nurbs-surface",label:"Nurbs Surface",group:"Surface",call:"surface.primitive_nurbs_surface_surface_add"},{kind:"surface.nurbs-cylinder",label:"Nurbs Cylinder",group:"Surface",call:"surface.primitive_nurbs_surface_cylinder_add"},{kind:"surface.nurbs-sphere",label:"Nurbs Sphere",group:"Surface",call:"surface.primitive_nurbs_surface_sphere_add"},{kind:"surface.nurbs-torus",label:"Nurbs Torus",group:"Surface",call:"surface.primitive_nurbs_surface_torus_add"},{kind:"metaball.ball",label:"Ball",group:"Metaball",call:"object.metaball_add, type='BALL'"},{kind:"metaball.capsule",label:"Capsule",group:"Metaball",call:"object.metaball_add, type='CAPSULE'"},{kind:"metaball.plane",label:"Plane",group:"Metaball",call:"object.metaball_add, type='PLANE'"},{kind:"metaball.ellipsoid",label:"Ellipsoid",group:"Metaball",call:"object.metaball_add, type='ELLIPSOID'"},{kind:"metaball.cube",label:"Cube",group:"Metaball",call:"object.metaball_add, type='CUBE'"},{kind:"text",label:"Text",group:null,call:"object.text_add"},{kind:"point-cloud",label:"Point Cloud",group:null,call:"object.pointcloud_random_add"},{kind:"volume.import",label:"Import OpenVDB...",group:"Volume",call:"object.volume_import",refusal:`${M("Importing an OpenVDB volume","CANCELLED, with nothing created")} This build also has no OpenVDB at all (\`bpy.app.build_options.openvdb\` is False), so a file would not be read even with a picker.`},{kind:"volume.empty",label:"Empty",group:"Volume",call:"object.volume_add"},{kind:"grease-pencil.blank",label:"Blank",group:"Grease Pencil",call:"object.grease_pencil_add, type='EMPTY'"},{kind:"grease-pencil.stroke",label:"Stroke",group:"Grease Pencil",call:"object.grease_pencil_add, type='STROKE'"},{kind:"grease-pencil.monkey",label:"Monkey",group:"Grease Pencil",call:"object.grease_pencil_add, type='MONKEY'"},{kind:"grease-pencil.lineart-scene",label:"Scene Line Art",group:"Grease Pencil",call:"object.grease_pencil_add, type='LINEART_SCENE'",separatorBefore:!0},{kind:"grease-pencil.lineart-collection",label:"Collection Line Art",group:"Grease Pencil",call:"object.grease_pencil_add, type='LINEART_COLLECTION'"},{kind:"grease-pencil.lineart-object",label:"Object Line Art",group:"Grease Pencil",call:"object.grease_pencil_add, type='LINEART_OBJECT'"},{kind:"armature",label:"Armature",group:null,call:"object.armature_add"},{kind:"lattice.lattice",label:"Lattice",group:"Lattice",call:"object.add, type='LATTICE'"},{kind:"lattice.deform-selected",label:"Lattice Deform Selected",group:"Lattice",call:"object.lattice_add_to_selected"},{kind:"empty.plain-axes",label:"Plain Axes",group:"Empty",call:"object.empty_add, type='PLAIN_AXES'"},{kind:"empty.arrows",label:"Arrows",group:"Empty",call:"object.empty_add, type='ARROWS'"},{kind:"empty.single-arrow",label:"Single Arrow",group:"Empty",call:"object.empty_add, type='SINGLE_ARROW'"},{kind:"empty.circle",label:"Circle",group:"Empty",call:"object.empty_add, type='CIRCLE'"},{kind:"empty.cube",label:"Cube",group:"Empty",call:"object.empty_add, type='CUBE'"},{kind:"empty.sphere",label:"Sphere",group:"Empty",call:"object.empty_add, type='SPHERE'"},{kind:"empty.cone",label:"Cone",group:"Empty",call:"object.empty_add, type='CONE'"},{kind:"image.reference",label:"Reference...",group:"Image",call:"object.empty_image_add, background=False",refusal:M("A reference image","poll() failed, context is incorrect / Please select at least one image")},{kind:"image.background",label:"Background...",group:"Image",call:"object.empty_image_add, background=True",refusal:M("A background image","poll() failed, context is incorrect / Please select at least one image")},{kind:"image.mesh-plane",label:"Mesh Plane...",group:"Image",call:"image.import_as_mesh_planes",placesAtOrigin:!1,refusal:M("An image as a mesh plane","CANCELLED, with nothing created")},{kind:"image.empty-image",label:"Empty Image",group:"Image",call:"object.empty_add, type='IMAGE'"},{kind:"light.point",label:"Point",group:"Light",call:"object.light_add, type='POINT'"},{kind:"light.sun",label:"Sun",group:"Light",call:"object.light_add, type='SUN'"},{kind:"light.spot",label:"Spot",group:"Light",call:"object.light_add, type='SPOT'"},{kind:"light.area",label:"Area",group:"Light",call:"object.light_add, type='AREA'"},{kind:"light-probe.sphere",label:"Sphere",group:"Light Probe",call:"object.lightprobe_add, type='SPHERE'"},{kind:"light-probe.plane",label:"Plane",group:"Light Probe",call:"object.lightprobe_add, type='PLANE'"},{kind:"light-probe.volume",label:"Volume",group:"Light Probe",call:"object.lightprobe_add, type='VOLUME'"},{kind:"camera",label:"Camera",group:null,call:"object.camera_add"},{kind:"speaker",label:"Speaker",group:null,call:"object.speaker_add"},{kind:"force-field.force",label:"Force",group:"Force Field",call:"object.effector_add, type='FORCE'"},{kind:"force-field.wind",label:"Wind",group:"Force Field",call:"object.effector_add, type='WIND'"},{kind:"force-field.vortex",label:"Vortex",group:"Force Field",call:"object.effector_add, type='VORTEX'"},{kind:"force-field.magnetic",label:"Magnetic",group:"Force Field",call:"object.effector_add, type='MAGNET'"},{kind:"force-field.harmonic",label:"Harmonic",group:"Force Field",call:"object.effector_add, type='HARMONIC'"},{kind:"force-field.charge",label:"Charge",group:"Force Field",call:"object.effector_add, type='CHARGE'"},{kind:"force-field.lennard-jones",label:"Lennard-Jones",group:"Force Field",call:"object.effector_add, type='LENNARDJ'"},{kind:"force-field.texture",label:"Texture",group:"Force Field",call:"object.effector_add, type='TEXTURE'"},{kind:"force-field.curve-guide",label:"Curve Guide",group:"Force Field",call:"object.effector_add, type='GUIDE'"},{kind:"force-field.boid",label:"Boid",group:"Force Field",call:"object.effector_add, type='BOID'"},{kind:"force-field.turbulence",label:"Turbulence",group:"Force Field",call:"object.effector_add, type='TURBULENCE'"},{kind:"force-field.drag",label:"Drag",group:"Force Field",call:"object.effector_add, type='DRAG'"},{kind:"force-field.fluid-flow",label:"Fluid Flow",group:"Force Field",call:"object.effector_add, type='FLUID'"}],xe="collection-instance:";function Ne(){const l=new Map;for(const o of P().byId.values()){if(o.type!=="TSE_LAYER_COLLECTION")continue;const n=o.data;n===void 0||!n.startsWith("bpy.data.collections[")||l.has(o.name)||l.set(o.name,{kind:`${xe}${o.name}`,label:o.name,group:"Collection Instance",call:`object.collection_instance_add, collection=${N(o.name)}`})}return[...l.values()]}function G(){return[...Ce,...Ne()]}function Fe(l){const[o,...n]=l.call.split(", "),c=l.placesAtOrigin===!1?n:[...n,"location=(0, 0, 0)"];return`bpy.ops.${o}(${c.join(", ")})`}function N(l){return JSON.stringify(l)}async function A(l,o="Blender Python"){const n=["before = {o.name for o in bpy.data.objects}",l,"made = [o.name for o in bpy.data.objects if o.name not in before]",'print("\\n".join(made))'].join(`
2
+ `),c=await oe(n,!0,o);return c.error!==null?{made:[],error:c.error}:{made:c.result.split(`
3
+ `).map(v=>v.trim()).filter(v=>v.length>0),error:null}}async function Ie(l,o){const n=[`_sel = {${l.map(N).join(", ")}}`,"_vl = bpy.context.view_layer","for _o in _vl.objects:"," _o.select_set(_o.name in _sel)",o===null?"_vl.objects.active = None":`_vl.objects.active = bpy.data.objects.get(${N(o)})`].join(`
4
+ `),c=await oe(n,!1);c.error!==null&&V().console.error(`Blender refused the selection write: ${c.error}`,"blender-outliner")}async function J(l,o){if(l.length===0)return{destination:"Nothing is selected, so there was nothing to run it on.",persisted:!1};const n=[`targets = [bpy.data.objects[n] for n in [${l.map(N).join(", ")}]]`,"with bpy.context.temp_override(selected_objects=targets, selected_editable_objects=targets, active_object=targets[0], object=targets[0]):",` ${o}`].join(`
5
+ `),{error:c}=await A(n);return c!==null?{destination:c,persisted:!1}:(await D(l),{destination:`Blender — ${o}; the session saves the .blend`,persisted:!0})}const Ae={source:"document",label:"blender",detail:"These rows are Blender's own View Layer tree, read from the engine through RNA. Editing the model is a bpy call; the eye and render columns write the engine directly."},Le="This collection is excluded from the view layer (LayerCollection.exclude), so its viewport visibility is not what is hiding it. Clear the Exclude checkbox on this row first.",Re=({defaultAdapter:l})=>{const o=new Set;let n=[],c=null;const _=new Map,v=new Map,I=()=>{for(const t of[...o])t()},b=()=>P().byId,C=t=>{const e=b().get(t),r=Y();return e===void 0||r===null?null:e.type==="TSE_VIEW_COLLECTION_BASE"?r.root:e.object===void 0?null:r.objectForBlenderName(e.object)},p=t=>{const e=Y();if(e===null)return null;for(const r of b().values())if(x(r)&&e.objectForBlenderName(r.object)===t)return r.id;return null},f=t=>{for(const e of b().values())if(x(e)&&e.object===t)return e.id;return null},g=t=>{if(b().has(t))return t;const e=l.hierarchy.object3D?.(t)??null;return e===null?null:p(e)},h=t=>{const e=g(t);return e===null?null:C(e)},k=t=>{const e=h(t);return e===null?null:l.hierarchy.idForObject3D?.(e)??null},y={roots:()=>(_e(F()),(P().tree?.rows??[]).map(e=>ae(e,null))),node:t=>{const e=P(),r=e.byId.has(t)?t:g(t),i=r===null?void 0:e.byId.get(r);return i===void 0?null:ae(i,e.parentOf.get(i.id)??null)},object3D:t=>h(t),idForObject3D:t=>p(t)};function F(){const t=b(),e=new Set;for(const r of n){const i=t.get(r)?.object;i!==void 0&&e.add(i)}return[...e]}const R=()=>{const t=[];for(const e of n){const r=h(e),i=r===null?null:l.hierarchy.idForObject3D?.(r);i&&t.push(i)}l.selection?.set(t,{intent:"exact"}),I()},a=()=>{const t=je(),e=`${q()}\0${t.active??""}\0${[...t.selected].sort().join("")}`;if(e===c)return;c=e;const r=t.selected.filter(d=>d!==t.active);t.active!==null&&r.push(t.active);const i=r.map(f).filter(d=>d!==null);i.length===n.length&&i.every((d,m)=>d===n[m])||(n=i,R())},s={get:()=>[...n],set:t=>{n=t.map(g).filter(d=>d!==null),R();const e=b(),r=[],i=[];for(const d of n){const m=e.get(d),j=m?.object;j===void 0?i.push(m?.name??d):r.includes(j)||r.push(j)}i.length>0&&V().console.warn(`${i.join(", ")} ${i.length===1?"is":"are"} not an object, so Blender's object selection does not carry ${i.length===1?"it":"them"}. Selecting a collection sets the ACTIVE COLLECTION in Blender, which is its own gesture and not in this editor yet.`,"blender-outliner"),Ie(r,r.length===0?null:r[r.length-1])}},w=t=>b().get(t)?.restrict,W={properties:t=>{const e=w(t);if(e===void 0)return[];const r=b().get(t),i=[{path:"name",label:"Name",type:"string",readonly:!x(r)}];return e.hide!==void 0&&i.push({path:"visible",label:"Show in Viewport",type:"boolean"}),e.render!==void 0&&i.push({path:"renderVisible",label:"Show in Renders",type:"boolean"}),e.exclude!==void 0&&i.push({path:"exclude",label:"Exclude from View Layer",type:"boolean"}),i},get:(t,e)=>{const r=b().get(t);if(r!==void 0){if(e==="name")return r.name;if(e==="visible")return r.restrict?.hide===void 0?void 0:!r.restrict.hide;if(e==="renderVisible")return r.restrict?.render===void 0?void 0:!r.restrict.render;if(e==="exclude")return r.restrict?.exclude}},editability:(t,e)=>{const r=b().get(t);return r===void 0?{writable:!1}:e==="name"?x(r)?{writable:!0}:{writable:!1,reason:`Renaming a ${r.struct??r.type} is not in this Outliner yet — only an object row renames here. Rename it with bpy.`}:r.notInCollection?{writable:!1,reason:"This row is a child drawn under its parent although it is not in that collection, and Blender's Outliner draws it no restriction columns."}:e==="visible"&&r.restrict?.exclude===!0?{writable:!1,reason:Le}:{writable:!0}},set:async(t,e,r)=>{const i=b().get(t);if(i===void 0)return;if(e==="name"){if(!x(i))return;const m=String(r);if(m===i.name||m.length===0)return;await te(`bpy.data.objects[${N(i.object)}]`,"name",m),await D([m]);const j=f(m);j!==null&&s.set([j]);return}if(e==="exclude"){await le(i.path,"exclude",r===!0);return}const d=e==="visible"?"hide":e==="renderVisible"?"render":null;d!==null&&await le(i.path,d,r===!1)}},ie={get:t=>{const e=k(t);return(e===null?void 0:l.transforms?.get(e))??Oe()},editability:t=>{const e=g(t),r=e===null?void 0:b().get(e);return x(r)&&C(r.id)!==null?{writable:!0}:{writable:!1,reason:`Only an object has a transform; this row is a ${r?.struct??r?.type??"row"}.`}},beginEdit:t=>{const e=h(t);e!==null&&!_.has(e)&&(_.set(e,e.matrixWorld.clone()),v.set(t,e),ge())},apply:(t,e)=>{const r=h(t);r!==null&&(r.position.fromArray(e.position),r.quaternion.fromArray(e.rotation),r.scale.fromArray(e.scale),r.updateMatrix(),r.updateMatrixWorld(!0))},endEdit:async t=>{const e=v.get(t)??h(t);v.delete(t);const r=Y();if(e===null)return;const i=_.get(e);_.delete(e);try{if(r===null||(e.updateWorldMatrix(!0,!1),i?.equals(e.matrixWorld)===!0))return;const d=r.blenderObjectName(e);if(d===null)return;const m=`bpy.data.objects[${JSON.stringify(d)}]`;try{return await te(m,"matrix_world",Se(e,r.root)),{destination:`Blender — ${m}.matrix_world; the session saves the .blend`,persisted:!0}}catch(j){return{destination:j instanceof Error?j.message:String(j),persisted:!1}}}finally{i&&await me()}}},H=t=>{const e=g(t),r=e===null?void 0:b().get(e);return x(r)?r.object:null},E=t=>({destination:t,persisted:!1}),U=async t=>{await D(t);const e=t.map(f).filter(r=>r!==null);return e.length>0&&s.set(e),e[0]??""},K={creatableKinds:()=>G().map(({kind:t,label:e})=>({kind:t,label:e})),create:t=>{const e=G().find(i=>i.kind===t);if(e===void 0)return{id:"",ack:E(`${t} is not a row of Blender's Add menu that this editor adds. Its rows are: ${G().map(i=>i.label).join(", ")}.`)};if(e.refusal!==void 0)return{id:"",ack:E(e.refusal)};const r=Fe(e);return{id:"",ack:(async()=>{const{made:i,error:d}=await A(r);return d!==null?E(d):i.length===0?E(`Blender ran ${r} and created nothing. The operator reported no error, so it cancelled — most often because it wanted a file browser or a context this headless engine has no window for.`):(await U(i),{destination:`Blender — ${r}; the session saves the .blend`,persisted:!0})})()}},remove:t=>K.removeMany?.([t])??void 0,removeMany:async t=>{const e=[];for(const m of t){const j=H(m);if(j===null){const ee=g(m)===null?void 0:b().get(g(m));return E(`Only an object can be deleted here; this row is a ${ee?.struct??ee?.type??"row"}. Deleting a collection, a modifier or a vertex group is that datablock’s own bpy call.`)}e.push(j)}if(e.length===0)return E("Nothing selected to delete.");const i=[`targets = ${`[bpy.data.objects[n] for n in [${e.map(N).join(", ")}]]`}`,"with bpy.context.temp_override(selected_objects=targets, active_object=targets[0]):"," result = bpy.ops.object.delete(use_global=False)",'if "FINISHED" not in result: raise RuntimeError("Blender cancelled deleting the selected objects")'].join(`
6
+ `),{error:d}=await A(i,"Delete Objects");return d!==null?E(d):(s.set([]),await D([]),{destination:"Blender — bpy.ops.object.delete(use_global=False); the session saves the .blend",persisted:!0})},duplicate:t=>{const e=H(t);if(e===null)return{id:t,ack:E("Only an object can be duplicated here. Duplicating a collection is `bpy.ops.object.collection_instance_add`, its own gesture.")};const r=[`source = bpy.data.objects[${N(e)}]`,"with bpy.context.temp_override(selected_objects=[source], active_object=source):"," result = bpy.ops.object.duplicate(linked=False)",'if "FINISHED" not in result: raise RuntimeError("Blender cancelled duplicating the selected object")'].join(`
7
+ `);return{id:t,ack:(async()=>{const{made:i,error:d}=await A(r,"Duplicate Object");return d!==null?E(d):(await U(i),{destination:`Blender — bpy.ops.object.duplicate(linked=False) on ${e}; the session saves the .blend`,persisted:!0})})()}},duplicateMany:async t=>{const e=[...new Set(t.map(H))];if(e.length===0||e.some(m=>m===null))return E("Select objects to duplicate; collections and data rows cannot be duplicated here.");const r=[`sources = [bpy.data.objects[name] for name in ${JSON.stringify(e)}]`,"with bpy.context.temp_override(selected_objects=sources, active_object=sources[0]):"," result = bpy.ops.object.duplicate(linked=False)",'if "FINISHED" not in result: raise RuntimeError("Blender cancelled duplicating the selected objects")'].join(`
8
+ `),{made:i,error:d}=await A(r,"Duplicate Objects");return d!==null?E(d):(await U(i),{destination:"Blender — duplicate selected objects as one native operation; the session saves the .blend",persisted:!0})},reparent:()=>E("Reparenting is Blender's `bpy.ops.object.parent_set`, which needs a parent TYPE (Object, Object Keep Transform, Armature Deform, …) that a drag does not say. Set the parent on the object’s Relations panel, or with bpy.")},Q={get documentId(){return l.documentId},get documentRootObject(){return l.documentRootObject},capabilities:we,provenance:Ae,hierarchy:y,selection:s,inspector:W,transforms:ie,structure:K,subscribe:t=>{o.add(t);const e=$(t),r=l.subscribe?.(t)??(()=>{});return()=>{o.delete(t),e(),r()}}},Z={get documentId(){return Q.documentId},selectedObjectNames:()=>F(),allObjectNames:()=>{const t=[];for(const e of b().values())x(e)&&t.push(e.object);return t},selectObjects:t=>{const e=t.map(f).filter(r=>r!==null);s.set(e)},rowIdForObject:t=>f(t),structure:K,subscribe:t=>{o.add(t);const e=$(t);return()=>{o.delete(t),e()}}};L.add(Z);const se=ye(a),ce=$(a);return a(),{adapter:Q,dispose:()=>{se(),ce(),L.delete(Z),o.clear()}}},Be=[{label:"Location",call:"location=True, rotation=False, scale=False"},{label:"Rotation",call:"location=False, rotation=True, scale=False"},{label:"Scale",call:"location=False, rotation=False, scale=True"},{label:"All Transforms",call:"location=True, rotation=True, scale=True"}],Me=[{label:"Location",call:"bpy.ops.object.location_clear(clear_delta=False)"},{label:"Rotation",call:"bpy.ops.object.rotation_clear(clear_delta=False)"},{label:"Scale",call:"bpy.ops.object.scale_clear(clear_delta=False)"}],Te=[{label:"Geometry to Origin",type:"GEOMETRY_ORIGIN"},{label:"Origin to Geometry",type:"ORIGIN_GEOMETRY"},{label:"Origin to 3D Cursor",type:"ORIGIN_CURSOR",refusal:"There is no 3D cursor in this editor yet, so there is no point to move the origin to. Blender places it with Shift+Right-click; that gesture is not built here."}],$e=[{submenu:"Mesh",at:"2699"},{submenu:"Curve",at:"2702"},{submenu:"Surface",at:"2704"},{submenu:"Metaball",at:"2705"},{kind:"text",at:"2706"},{kind:"point-cloud",at:"2707"},{submenu:"Volume",at:"2708"},{submenu:"Grease Pencil",at:"2709"},{separatorAt:"2711"},{kind:"armature",at:"2716"},{submenu:"Lattice",at:"2718"},{separatorAt:"2720"},{submenu:"Empty",at:"2722"},{submenu:"Image",at:"2723"},{separatorAt:"2725"},{submenu:"Light",at:"2727"},{submenu:"Light Probe",at:"2728"},{separatorAt:"2730"},{kind:"camera",at:"2735"},{separatorAt:"2737"},{kind:"speaker",at:"2739"},{separatorAt:"2741"},{submenu:"Force Field",at:"2743"},{separatorAt:"2745"},{submenu:"Collection Instance",at:"2759"}],De="No Collections to Instance";function X({id:l,open:o,setOpen:n,anchorRef:c,children:_}){return u.jsxs("div",{ref:c,style:{position:"relative"},children:[u.jsx(pe,{"data-testid":`blender-menu-${l}`,"aria-expanded":o===l,onClick:()=>n(o===l?null:l),onPointerEnter:()=>{o&&n(l)},style:{textTransform:"capitalize"},children:l}),o===l&&u.jsx(fe,{anchorRef:c,dismissBoundaryRef:c,align:"start",gap:0,clamp:!0,"aria-label":l,onDismiss:()=>n(null),children:_})]})}function Pe(l,o,n){(async()=>{const c=await n;c===void 0||typeof c.destination!="string"||c.persisted!==!0&&l?.({tone:"error",title:`${o} was refused`,detail:c.destination})})()}function Ge({documentId:l,notify:o}){O.useSyncExternalStore($,q,q);const[n,c]=O.useState(null),_=O.useRef(null),v=O.useRef(null),I=O.useRef(null),b=O.useRef(null),C=Ee(l);if(C===null)return null;const p=(a,s)=>()=>{c(null),Pe(o,a,s(C))},f=C.selectedObjectNames(),g=C.allObjectNames(),h=f.length===0?"Nothing is selected.":void 0,k=G(),y=a=>u.jsx(S,{"data-testid":`blender-add-${a.kind}`,disabled:a.refusal!==void 0,title:a.refusal,onSelect:p(`Add ${a.label}`,s=>s.structure.create(a.kind).ack),children:a.label},a.kind),F=a=>k.filter(s=>s.group===a).flatMap(s=>s.separatorBefore===!0?[u.jsx(z,{},`${s.kind}-separator`),y(s)]:[y(s)]),R=a=>{if("separatorAt"in a)return u.jsx(z,{},`separator-${a.separatorAt}`);if("kind"in a){const w=k.find(W=>W.kind===a.kind);return w===void 0?null:y(w)}const s=F(a.submenu);return s.length===0?u.jsx(S,{"data-testid":"blender-add-collection-instance",disabled:!0,children:De},a.submenu):u.jsx(B,{label:a.submenu,"data-testid":`blender-add-${a.submenu.toLowerCase().replaceAll(" ","-")}`,children:s},a.submenu)};return u.jsxs(be,{compact:!0,label:"Blender Object Mode menus","data-testid":"blender-object-mode-menus",ref:_,children:[u.jsxs(X,{id:"select",open:n,setOpen:c,anchorRef:v,children:[u.jsx(S,{"data-testid":"blender-select-all",onSelect:p("Select All",a=>a.selectObjects(g)),children:"All"}),u.jsx(S,{"data-testid":"blender-select-none",onSelect:p("Select None",a=>a.selectObjects([])),children:"None"}),u.jsx(S,{"data-testid":"blender-select-invert",onSelect:p("Select Invert",a=>a.selectObjects(g.filter(s=>!f.includes(s)))),children:"Invert"})]}),u.jsx(X,{id:"add",open:n,setOpen:c,anchorRef:I,children:$e.map(a=>R(a))}),u.jsxs(X,{id:"object",open:n,setOpen:c,anchorRef:b,children:[u.jsx(B,{label:"Set Origin","data-testid":"blender-object-origin",children:Te.map(a=>u.jsx(S,{"data-testid":`blender-origin-${a.type}`,disabled:a.refusal!==void 0||f.length===0,title:a.refusal??h,onSelect:p(`Set Origin ▸ ${a.label}`,s=>J(s.selectedObjectNames(),`bpy.ops.object.origin_set(type='${a.type}')`)),children:a.label},a.type))}),u.jsx(B,{label:"Clear","data-testid":"blender-object-clear",children:Me.map(a=>u.jsx(S,{"data-testid":`blender-clear-${a.label.toLowerCase()}`,disabled:f.length===0,title:h,onSelect:p(`Clear ▸ ${a.label}`,s=>J(s.selectedObjectNames(),a.call)),children:a.label},a.label))}),u.jsx(B,{label:"Apply","data-testid":"blender-object-apply",children:Be.map(a=>u.jsx(S,{"data-testid":`blender-apply-${a.label.toLowerCase().replace(/ /g,"-")}`,disabled:f.length===0,title:h,onSelect:p(`Apply ▸ ${a.label}`,s=>J(s.selectedObjectNames(),`bpy.ops.object.transform_apply(${a.call})`)),children:a.label},a.label))}),u.jsx(z,{}),u.jsx(S,{"data-testid":"blender-object-duplicate",disabled:f.length===0,title:h,onSelect:p("Duplicate Objects",async a=>{const s=a.selectedObjectNames().map(w=>a.rowIdForObject(w)).filter(w=>w!==null);return a.structure.duplicateMany?.(s)}),children:"Duplicate Objects"}),u.jsx(S,{"data-testid":"blender-object-delete",disabled:f.length===0,title:h,onSelect:p("Delete",a=>{const s=a.selectedObjectNames().map(w=>a.rowIdForObject(w)).filter(w=>w!==null);return a.structure.removeMany?.(s)}),children:"Delete"})]})]})}const lt="workspace.document",nt="Blender Model",at=({documentId:l,notify:o})=>u.jsx(Ge,{documentId:l,notify:o}),ot="model",it="owned",st=[],T=de;function ct({active:l,document:o,documentId:n,surfaces:c,notify:_,publishContext:v}){const I=O.useCallback(()=>({root:T.root,dispose(){}}),[]),b=o?.source?.path;if(O.useEffect(()=>v?.(T),[v]),O.useEffect(()=>{if(!n)return;const{viewport:p}=V(),f=T.overlayGroups(),g=()=>{const k=p.stages().find(y=>y.documentId===n);if(k)for(const{kind:y,object:F}of f)k.setHelper(y,F)};g();const h=p.onStages(g);return()=>{h();const k=p.stages().find(y=>y.documentId===n);for(const{kind:y}of f)k?.setHelper(y,null)}},[n]),O.useEffect(()=>{if(!n)return;const{transport:p}=V();let f=null;const g=()=>{if(f)return;const k=p.for(n);k&&(f=ue.attachTo(k))};g();const h=p.subscribe(g);return()=>{h(),f?.()}},[n]),O.useEffect(()=>{if(n){if(b===void 0){re(null);return}return he(n,b,o.id).catch(p=>{_?.({tone:"error",title:`Blender could not open ${b}`,detail:p instanceof Error?p.message:String(p)})}),()=>re(null)}},[b,o?.id,n,_]),!n)return null;const C=c.Object3DAuthoring;return u.jsx(C,{active:l??!0,documentId:n,sourcePath:b??"blender:runtime",displayName:o?.label??"Model",build:I,audit:!1,authoring:Re,cameraDirection:[.8187,.4458,.3617],openingFit:3,dressing:{environment:!1,keyLight:!1,toneMapping:ve,viewLocked:T.studioLights()}})}export{at as Toolbar,ct as default,ot as documentKind,st as inspectorBuiltins,it as inspectorRail,lt as point,nt as title};
@@ -1 +1 @@
1
- import{a}from"./jsx-runtime-DPjLkJKQ.js";import{s as ae,b as L,a as p,c as he}from"./blender-runtime-skin-DcwXD-m8.js";import{ah as pe}from"./index-5av5LJja.js";import{r as f}from"./index-DaQZGF7d.js";import{s as ye,e as Q,l as ge,m as xe}from"./blender-runtime-host-D8NHsAfD.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./LineSegments2-vfeDUBfs.js";import"./three.module-BynznMJN.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D_NuPfjr.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./clip-planes-CnAI6DZn.js";const we={transform:{startFrame:-5,pixelsPerFrame:8},refusal:null,size:{w:0,h:0},framedAt:0,drawn:null,onlySelected:!0};let P=we,W=0;const H=new Set;let oe=0;function M(){return P}function _(){return W}function K(e){return H.add(e),()=>{H.delete(e)}}function k(e){P={...P,...e},W+=1;for(const s of[...H])s()}function be(e){P.onlySelected!==e&&k({onlySelected:e})}function le(){oe+=1,W+=1;for(const e of[...H])e()}function Ee(){return oe}function G(e){k({refusal:e})}const ve=20,T=23,ee=26,Te=16,Me=2,ke=T+Me,te=35,Se=6;function ce(e){const s=[2,3,5],o=[];for(let r=0;r<s.length;r++){const n=s[r],i=Math.trunc(e/n),c=i*n===e;if(c&&i===2)return n;o[r]=c}for(let r=0;r<s.length;r++)if(o[r])return s[r];return e}function je(e,s,o,r){if(o===0)return 1;const n=s/o;let i=Math.max(e,1);if(n*i>r)for(;i>1;){const c=ce(i),l=Math.trunc(i/c);if(n*l<r)break;i=l}else for(;n*i<r&&i<1<<30;)i*=2;return i}function Fe(e){return e<=1?null:e/ce(Math.round(e))}const x={back:"#303030",header:"#303030",grid:"#161616",gridMinor:"#262626",scrubBack:"#1d1d1d",scrubText:"#808080",playhead:"#4772b3",playheadText:"#ffffff",keyBorder:"#000000"},re={KEYFRAME:{fill:"#bfbfbf",selected:"#ffbe33"},EXTREME:{fill:"#e8b3cc",selected:"#f28080"},BREAKDOWN:{fill:"#b3dbe8",selected:"#54bfed"},JITTER:{fill:"#94e575",selected:"#61c042"},MOVING_HOLD:{fill:"#808080",selected:"#ffaf23"},GENERATED:{fill:"#585858",selected:"#a28962"}},Ne={KEYFRAME:1,EXTREME:1.2,MOVING_HOLD:.925,BREAKDOWN:.85,JITTER:.8,GENERATED:.75},ne=5.06,Ae=2.12,_e=15,g={minPillWidth:24,textPadding:4,margin:2,radius:4,tipHalfWidth:6,tipHeight:6,stalkWidth:3},ie="#212121",d={text:"#a6a6a6",rule:"#161616",widget:"#545454",widgetText:"#e6e6e6",widgetOutline:"#3d3d3d",widgetRadius:4,unit:ve,refusal:"#ffaf23",headerPadding:"0 8px",headerGap:8,statusPadding:"2px 8px"},Xe="workspace.document",Re="Timeline",de=.25,me=200,B={"set-range":"Setting the frame range writes `scene.frame_start`/`frame_end`, which the document would save. This is Blender's Timeline as an INSPECTION surface: the range is drawn, never set. Change it in bpy and the Timeline re-reads it.","insert-key":"Inserting a keyframe writes the action. Editing parity is not the program — key it in bpy (`pose_bone.keyframe_insert`) and the Timeline re-reads the action on the next present.","move-key":"Moving a keyframe writes the F-Curve's control points. The summary row draws the keys the action HAS; the Dope Sheet that would move them is the Animation workspace's, and it is not built.","delete-key":"Deleting a keyframe writes the action. Editing parity is not the program.","set-interpolation":"Setting a key's interpolation writes the F-Curve. Note also that this view PLAYS a per-frame bake (`rna_action_clip`), so interpolation is not a thing it reads back.","select-key":"Selecting a keyframe writes `Keyframe.select_control_point`. The view draws the flags the data carries — a selected key takes `.common.anim.keyframe_selected` — and changes none of them."},z="Nothing here is playable: no object in the scene carries an action this view could bind a mixer to.";function h(){return p.transport}function V(){return h()?.snapshot().playbackState==="playing"}function $(e){return G(e),v()}const se={JITTER:1,GENERATED:2,MOVING_HOLD:3,BREAKDOWN:4,KEYFRAME:5,EXTREME:6};function ue(e,s){const o=[],r=new Map;for(const n of e)if(!(s&&!n.selected)){o.push(n.object);for(const i of n.keyframes){const c=r.get(i.frame);if(!c){r.set(i.frame,{...i});continue}c.select=c.select||i.select,(se[i.type]??0)>(se[c.type]??0)&&(c.type=i.type)}}return{columns:[...r.values()].sort((n,i)=>n.frame-i.frame),objects:o}}function D(){return ue(p.state().summary,M().onlySelected).columns.map(e=>e.frame)}function v(){const e=M();return{...p.state(),transform:e.transform,size:e.size,refusal:e.refusal,drawn:e.drawn}}function O(e){if(!p.playable)return $(z);const s=h();return s?(s.seekFrame(e),v()):$("No stage transport is attached yet; open the model document first.")}pe({view:"timeline",title:Re,verbs:[{id:"state",run:()=>v()},{id:"frame",title:"Timeline: Set Frame",run:e=>{const s=Number(e?.frame??e?.to);if(!Number.isFinite(s))throw new Error("frame needs a numeric `frame` — a Blender frame number.");return O(s)}},{id:"play",title:"Timeline: Play",run:()=>{if(!p.playable)throw new Error(z);const e=h();if(!e)throw new Error("No stage transport is attached yet; open the model document first.");return e.play(),v()}},{id:"pause",title:"Timeline: Pause",run:()=>{const e=h();return e?(e.pause(),v()):$("No stage transport is attached yet.")}},{id:"jump-start",title:"Timeline: Jump to Start",run:()=>O(p.state().start)},{id:"jump-end",title:"Timeline: Jump to End",run:()=>O(p.state().end)},{id:"next-keyframe",title:"Timeline: Next Keyframe",run:()=>{const e=p.frame(),s=D().find(o=>o>e+1e-4);return s===void 0?v():O(s)}},{id:"prev-keyframe",title:"Timeline: Previous Keyframe",run:()=>{const e=p.frame(),s=D().reverse().find(o=>o<e-1e-4);return s===void 0?v():O(s)}},{id:"view-all",title:"Timeline: View All",run:()=>(le(),v())},{id:"zoom",title:"Timeline: Zoom",run:e=>{const s=Number(e?.to??e?.zoom);if(!Number.isFinite(s))throw new Error("zoom needs a numeric `to` — CSS pixels per frame, 0.25 … 200.");const{transform:o,size:r}=M(),n=o.startFrame+r.w/2/o.pixelsPerFrame,i=Math.min(me,Math.max(de,s));return k({transform:{pixelsPerFrame:i,startFrame:n-r.w/2/i}}),v()}},{id:"pan",title:"Timeline: Pan",run:e=>{const s=Number(e?.frames??0);if(!Number.isFinite(s))throw new Error("pan needs a numeric `frames`.");const{transform:o}=M();return k({transform:{...o,startFrame:o.startFrame+s}}),v()}},...Object.keys(B).map(e=>({id:e,run:()=>$(B[e])}))]});function Ze(){const e=f.useSyncExternalStore(ye,Q,Q);f.useSyncExternalStore(ae,L,L),f.useSyncExternalStore(K,_,_);const s=f.useRef(null),o=f.useRef(-1),{transform:r,size:n,refusal:i,onlySelected:c}=M(),l=p.state();f.useEffect(()=>{let t=!0;return p.bind(he,{rig:()=>xe(),clip:()=>ge()}).catch(m=>{t&&G(`The Timeline could not read this file's rig: ${m instanceof Error?m.message:String(m)}`)}),()=>{t=!1}},[e]),f.useEffect(()=>{const t=s.current;if(!t)return;const m=new ResizeObserver(()=>{const u={w:t.clientWidth,h:t.clientHeight},y=M().size;(y.w!==u.w||y.h!==u.h)&&k({size:u})});return m.observe(t),k({size:{w:t.clientWidth,h:t.clientHeight}}),()=>m.disconnect()},[]);const S=Ee();f.useEffect(()=>{if(S===o.current)return;o.current=S;const{w:t}=M().size;if(t===0)return;const m=Math.max(1,l.end-l.start),u=Math.min(me,Math.max(de,t*.9/m));k({transform:{pixelsPerFrame:u,startFrame:l.start-t*.05/u},framedAt:Date.now()})},[S,l.start,l.end]);const b=f.useCallback(t=>(t-r.startFrame)*r.pixelsPerFrame,[r]),Y=f.useCallback(t=>r.startFrame+t/r.pixelsPerFrame,[r]),F=f.useMemo(()=>ue(l.summary,c),[l.summary,c]),E=f.useMemo(()=>{if(n.w===0)return null;const t=n.w/r.pixelsPerFrame,m=Math.max(`${Math.round(r.startFrame)}`.length,`${Math.round(r.startFrame+t)}`.length),u=Math.max(te,m*6+Se),y=je(Math.round(l.fps),n.w+1,t,u),w=Fe(y),fe=Math.ceil(r.startFrame/y)*y,Z=[];for(let R=fe;R<=r.startFrame+t;R+=y)Z.push(R);const q=[];if(w!==null&&w*r.pixelsPerFrame>=te/5){const R=Math.ceil(r.startFrame/w)*w;for(let I=R;I<=r.startFrame+t;I+=w)Math.abs(I/y-Math.round(I/y))>1e-6&&q.push(I)}return{major:y,minor:w,majors:Z,minors:q}},[n.w,r,l.fps]),N=T,j=ke+Te/2;f.useEffect(()=>{if(!E)return;const t=[...l.warnings];l.action||t.push("Nothing in this file carries an action, so the summary row is empty — which is Blender's own empty state for a Timeline over a still file."),t.push("While a clip plays, the picture is three.js evaluating the skin over the mesh columns Blender exported at the BIND frame. Anything else Blender would re-evaluate per frame — shape keys, a Displace or Cloth modifier reading the frame, a geometry driver — does not follow the playhead."),t.push("Blender puts this view's ONLY-SHOW-SELECTED toggle in the Timeline header's View MENU (`TIME_MT_view`'s `layout.prop(scene, \"show_keys_from_selected_only\")`, `space_time.py`); this header has no menu region, so the same toggle is drawn as a header button at the leading edge, where that menu sits. The filter itself is Blender's — `ADS_FILTER_ONLYSEL`, `anim_filter.cc:254-270`, tested per object at `:2307`."),c&&F.objects.length===0&&l.summary.length>0&&t.push(`The summary row is empty because nothing animated is SELECTED, which is Blender's own answer with this filter on. ${l.summary.map(u=>u.object).join(", ")} carr${l.summary.length===1?"ies":"y"} an action; select it, or turn the filter off.`),t.push("Markers, the cache bar and the preview range are drawn by Blender's Timeline and not here; the door carries none of them.");const m={drawn:{action:l.action,object:l.object,armature:l.armature,frame:l.frame,start:l.start,end:l.end,fps:l.fps,playing:V(),keyframes:F.columns.map(u=>u.frame),onlySelected:c,summaryObjects:F.objects,majorStep:E.major,minorStep:E.minor,majorLines:E.majors.length,minorLines:E.minors.length,labels:E.majors.length,diamonds:F.columns.length,diamondRadius:ne,diamondSprite:_e,bones:l.bones,tracks:l.tracks,engineCalls:l.engineCalls,warnings:t}};JSON.stringify(m.drawn)!==JSON.stringify(M().drawn)&&k(m)},[E,l,F,c]);const C=f.useRef(!1),J=f.useCallback(t=>{const m=s.current;if(!m)return;const u=m.getBoundingClientRect();h()?.seekFrame(Math.round(Y(t-u.left)))},[Y]),U=`${Math.round(l.frame)}`,X=Math.max(g.minPillWidth,U.length*6+2*g.textPadding),A=b(l.frame);return a.jsxs("div",{"data-testid":"blender-timeline",style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",overflow:"hidden",background:x.back,color:d.text,font:"11px Inter, system-ui, sans-serif"},children:[a.jsx(Oe,{}),a.jsx("div",{ref:s,style:{flex:1,minHeight:0,position:"relative"},children:a.jsxs("svg",{width:n.w,height:n.h,style:{display:"block",cursor:"ew-resize"},"aria-label":"Timeline",onPointerDown:t=>{C.current=!0,t.currentTarget.setPointerCapture(t.pointerId),J(t.clientX)},onPointerMove:t=>{C.current&&J(t.clientX)},onPointerUp:t=>{C.current=!1,t.currentTarget.releasePointerCapture(t.pointerId)},children:[a.jsx("title",{children:"Timeline"}),a.jsx("rect",{x:0,y:0,width:n.w,height:n.h,fill:x.back}),a.jsx("rect",{x:0,y:N,width:Math.max(0,b(l.start)),height:Math.max(0,n.h-N),fill:ie}),a.jsx("rect",{x:b(l.end),y:N,width:Math.max(0,n.w-b(l.end)),height:Math.max(0,n.h-N),fill:ie}),E?.minors.map(t=>a.jsx("line",{x1:b(t),y1:N,x2:b(t),y2:n.h,stroke:x.gridMinor,strokeWidth:1},`n${t}`)),E?.majors.map(t=>a.jsx("line",{x1:b(t),y1:N,x2:b(t),y2:n.h,stroke:x.grid,strokeWidth:1},`m${t}`)),a.jsx("rect",{x:0,y:0,width:n.w,height:T,fill:x.scrubBack}),E?.majors.map(t=>a.jsx("text",{x:b(t),y:15.5,textAnchor:"middle",fill:x.scrubText,fontSize:11,children:Math.round(t)},`t${t}`)),a.jsx("path",{d:`M3,${j-3.5} L6.5,${j} L3,${j+3.5} Z`,fill:x.scrubText}),F.columns.map(t=>{const m=Ne[t.type]??1,u=ne*m,y=re[t.type]??re.KEYFRAME,w=b(t.frame);return a.jsx("polygon",{points:`${w},${j-u} ${w+u},${j} ${w},${j+u} ${w-u},${j}`,fill:t.select?y.selected:y.fill,stroke:x.keyBorder,strokeWidth:Ae*m},`k${t.frame}`)}),a.jsx("rect",{x:A-g.stalkWidth/2,y:T,width:g.stalkWidth,height:Math.max(0,n.h-T),fill:x.playhead}),a.jsx("rect",{x:A-X/2,y:g.margin,width:X,height:T-2*g.margin,rx:g.radius,fill:x.playhead}),a.jsx("polygon",{points:`${A-g.tipHalfWidth},${T-g.margin} ${A+g.tipHalfWidth},${T-g.margin} ${A},${T-g.margin+g.tipHeight}`,fill:x.playhead}),a.jsx("text",{x:A,y:15.5,textAnchor:"middle",fill:x.playheadText,fontSize:11,children:U})]})}),i?a.jsx("div",{style:{borderTop:`1px solid ${d.rule}`,padding:d.statusPadding,color:d.refusal},children:i}):null]})}function Ie(){f.useSyncExternalStore(K,_,_);const{onlySelected:e}=M(),[s,o]=f.useState(!1),r=(n,i,c)=>a.jsxs("button",{type:"button",onClick:()=>{c(),o(!1)},style:{display:"flex",alignItems:"center",gap:"var(--vgai-space-2)",width:"100%",padding:"var(--vgai-space-1) var(--vgai-space-3)",border:"none",background:"transparent",color:d.widgetText,font:"inherit",textAlign:"left",cursor:"pointer"},children:[a.jsx("span",{style:{width:12,display:"inline-block"},children:i===null?"":i?"✓":""}),n]});return a.jsxs("span",{style:{position:"relative"},children:[a.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":s,onClick:()=>o(n=>!n),style:{border:"none",background:"transparent",color:d.text,font:"inherit",padding:"0 var(--vgai-space-2)",cursor:"pointer"},children:"View"}),s?a.jsxs("span",{role:"menu",style:{position:"absolute",top:"100%",left:0,zIndex:20,minWidth:210,display:"flex",flexDirection:"column",background:d.widget,border:`1px solid ${d.widgetOutline}`,boxShadow:"0 6px 18px rgba(0,0,0,0.45)"},children:[r("Only Show Selected",e,()=>be(!e)),r("Frame All",null,()=>le())]}):null]})}function Oe(){f.useSyncExternalStore(ae,L,L),f.useSyncExternalStore(K,_,_);const e=p.state(),s=d.unit,o=p.playable,r=(i,c,l,S)=>a.jsx("button",{type:"button",title:o?S:`${S} — ${z}`,"aria-label":S,disabled:!o,onClick:l,style:{width:s,height:s,padding:0,border:`1px solid ${d.widgetOutline}`,background:d.widget,color:d.widgetText,display:"grid",placeItems:"center",cursor:o?"pointer":"not-allowed",opacity:o?1:.4},children:c},i),n=i=>a.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12","aria-hidden":"true",children:a.jsx("path",{d:i,fill:d.widgetText})});return a.jsxs("div",{style:{height:ee,flex:`0 0 ${ee}px`,display:"flex",alignItems:"center",gap:d.headerGap,padding:d.headerPadding,background:x.header,borderBottom:`1px solid ${d.rule}`},children:[a.jsx("span",{style:{color:d.text},children:"Timeline"}),a.jsx(Ie,{}),a.jsx("div",{style:{flex:1}}),a.jsxs("div",{style:{display:"flex"},children:[r("jump-start",n("M2 2h1.5v8H2zM10 2v8L4.5 6z"),()=>h()?.seekFrame(e.start),"Jump to Start"),r("prev-key",n("M5 2.5v7L1.5 6zM8.5 3.2L11 6L8.5 8.8L6 6z"),()=>{const i=D().reverse().find(c=>c<p.frame()-1e-4);i!==void 0&&h()?.seekFrame(i)},"Jump to Previous Keyframe"),o&&V()?r("pause-rev",n("M3 2h2v8H3zM7 2h2v8H7z"),()=>h()?.pause(),"Pause"):r("play-reverse",n("M9 2L2 6l7 4z"),()=>h()?.play("reverse"),"Play Reverse"),o&&V()?r("pause",n("M3 2h2v8H3zM7 2h2v8H7z"),()=>h()?.pause(),"Pause"):r("play",n("M3 2l7 4-7 4z"),()=>h()?.play(),"Play"),r("next-key",n("M7 2.5v7L10.5 6zM3.5 3.2L6 6L3.5 8.8L1 6z"),()=>{const i=D().find(c=>c>p.frame()+1e-4);i!==void 0&&h()?.seekFrame(i)},"Jump to Next Keyframe"),r("jump-end",n("M10 2H8.5v8H10zM2 2v8L7.5 6z"),()=>h()?.seekFrame(e.end),"Jump to End")]}),a.jsxs("div",{style:{display:"flex"},children:[r("step-back",n("M2 2h1.5v8H2zM9.5 2v8L4.5 6z"),()=>h()?.seekFrame(Math.round(e.frame)-1),"Step Back One Frame"),r("step-forward",n("M10 2H8.5v8H10zM2.5 2v8L7.5 6z"),()=>h()?.seekFrame(Math.round(e.frame)+1),"Step Forward One Frame")]}),a.jsx("div",{style:{flex:1}}),a.jsx("input",{type:"number",value:Math.round(e.frame),onChange:i=>{const c=Number(i.target.value);Number.isFinite(c)&&h()?.seekFrame(c)},"aria-label":"Current frame",disabled:!o,title:o?void 0:z,style:{width:75,height:s,textAlign:"center",border:`1px solid ${d.widgetOutline}`,borderRadius:d.widgetRadius,background:d.widget,color:d.widgetText,font:"inherit",cursor:o?"text":"not-allowed",opacity:o?1:.4}}),a.jsxs("span",{onClick:()=>G(B["set-range"]),onKeyDown:()=>{},style:{color:d.text,cursor:"not-allowed"},children:["Start ",e.start," · End ",e.end]})]})}export{Ze as default,Xe as point,Re as title};
1
+ import{a}from"./jsx-runtime-DPjLkJKQ.js";import{s as ae,b as L,a as p,c as he}from"./blender-runtime-skin-CBll8ovN.js";import{ah as pe}from"./index-CY4oDLhJ.js";import{r as f}from"./index-DaQZGF7d.js";import{s as ye,e as Q,l as ge,m as xe}from"./blender-runtime-host-DGe1KLVZ.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./LineSegments2-vfeDUBfs.js";import"./three.module-BynznMJN.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D_NuPfjr.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./clip-planes-CnAI6DZn.js";const we={transform:{startFrame:-5,pixelsPerFrame:8},refusal:null,size:{w:0,h:0},framedAt:0,drawn:null,onlySelected:!0};let P=we,W=0;const H=new Set;let oe=0;function M(){return P}function _(){return W}function K(e){return H.add(e),()=>{H.delete(e)}}function k(e){P={...P,...e},W+=1;for(const s of[...H])s()}function be(e){P.onlySelected!==e&&k({onlySelected:e})}function le(){oe+=1,W+=1;for(const e of[...H])e()}function Ee(){return oe}function G(e){k({refusal:e})}const ve=20,T=23,ee=26,Te=16,Me=2,ke=T+Me,te=35,Se=6;function ce(e){const s=[2,3,5],o=[];for(let r=0;r<s.length;r++){const n=s[r],i=Math.trunc(e/n),c=i*n===e;if(c&&i===2)return n;o[r]=c}for(let r=0;r<s.length;r++)if(o[r])return s[r];return e}function je(e,s,o,r){if(o===0)return 1;const n=s/o;let i=Math.max(e,1);if(n*i>r)for(;i>1;){const c=ce(i),l=Math.trunc(i/c);if(n*l<r)break;i=l}else for(;n*i<r&&i<1<<30;)i*=2;return i}function Fe(e){return e<=1?null:e/ce(Math.round(e))}const x={back:"#303030",header:"#303030",grid:"#161616",gridMinor:"#262626",scrubBack:"#1d1d1d",scrubText:"#808080",playhead:"#4772b3",playheadText:"#ffffff",keyBorder:"#000000"},re={KEYFRAME:{fill:"#bfbfbf",selected:"#ffbe33"},EXTREME:{fill:"#e8b3cc",selected:"#f28080"},BREAKDOWN:{fill:"#b3dbe8",selected:"#54bfed"},JITTER:{fill:"#94e575",selected:"#61c042"},MOVING_HOLD:{fill:"#808080",selected:"#ffaf23"},GENERATED:{fill:"#585858",selected:"#a28962"}},Ne={KEYFRAME:1,EXTREME:1.2,MOVING_HOLD:.925,BREAKDOWN:.85,JITTER:.8,GENERATED:.75},ne=5.06,Ae=2.12,_e=15,g={minPillWidth:24,textPadding:4,margin:2,radius:4,tipHalfWidth:6,tipHeight:6,stalkWidth:3},ie="#212121",d={text:"#a6a6a6",rule:"#161616",widget:"#545454",widgetText:"#e6e6e6",widgetOutline:"#3d3d3d",widgetRadius:4,unit:ve,refusal:"#ffaf23",headerPadding:"0 8px",headerGap:8,statusPadding:"2px 8px"},Xe="workspace.document",Re="Timeline",de=.25,me=200,B={"set-range":"Setting the frame range writes `scene.frame_start`/`frame_end`, which the document would save. This is Blender's Timeline as an INSPECTION surface: the range is drawn, never set. Change it in bpy and the Timeline re-reads it.","insert-key":"Inserting a keyframe writes the action. Editing parity is not the program — key it in bpy (`pose_bone.keyframe_insert`) and the Timeline re-reads the action on the next present.","move-key":"Moving a keyframe writes the F-Curve's control points. The summary row draws the keys the action HAS; the Dope Sheet that would move them is the Animation workspace's, and it is not built.","delete-key":"Deleting a keyframe writes the action. Editing parity is not the program.","set-interpolation":"Setting a key's interpolation writes the F-Curve. Note also that this view PLAYS a per-frame bake (`rna_action_clip`), so interpolation is not a thing it reads back.","select-key":"Selecting a keyframe writes `Keyframe.select_control_point`. The view draws the flags the data carries — a selected key takes `.common.anim.keyframe_selected` — and changes none of them."},z="Nothing here is playable: no object in the scene carries an action this view could bind a mixer to.";function h(){return p.transport}function V(){return h()?.snapshot().playbackState==="playing"}function $(e){return G(e),v()}const se={JITTER:1,GENERATED:2,MOVING_HOLD:3,BREAKDOWN:4,KEYFRAME:5,EXTREME:6};function ue(e,s){const o=[],r=new Map;for(const n of e)if(!(s&&!n.selected)){o.push(n.object);for(const i of n.keyframes){const c=r.get(i.frame);if(!c){r.set(i.frame,{...i});continue}c.select=c.select||i.select,(se[i.type]??0)>(se[c.type]??0)&&(c.type=i.type)}}return{columns:[...r.values()].sort((n,i)=>n.frame-i.frame),objects:o}}function D(){return ue(p.state().summary,M().onlySelected).columns.map(e=>e.frame)}function v(){const e=M();return{...p.state(),transform:e.transform,size:e.size,refusal:e.refusal,drawn:e.drawn}}function O(e){if(!p.playable)return $(z);const s=h();return s?(s.seekFrame(e),v()):$("No stage transport is attached yet; open the model document first.")}pe({view:"timeline",title:Re,verbs:[{id:"state",run:()=>v()},{id:"frame",title:"Timeline: Set Frame",run:e=>{const s=Number(e?.frame??e?.to);if(!Number.isFinite(s))throw new Error("frame needs a numeric `frame` — a Blender frame number.");return O(s)}},{id:"play",title:"Timeline: Play",run:()=>{if(!p.playable)throw new Error(z);const e=h();if(!e)throw new Error("No stage transport is attached yet; open the model document first.");return e.play(),v()}},{id:"pause",title:"Timeline: Pause",run:()=>{const e=h();return e?(e.pause(),v()):$("No stage transport is attached yet.")}},{id:"jump-start",title:"Timeline: Jump to Start",run:()=>O(p.state().start)},{id:"jump-end",title:"Timeline: Jump to End",run:()=>O(p.state().end)},{id:"next-keyframe",title:"Timeline: Next Keyframe",run:()=>{const e=p.frame(),s=D().find(o=>o>e+1e-4);return s===void 0?v():O(s)}},{id:"prev-keyframe",title:"Timeline: Previous Keyframe",run:()=>{const e=p.frame(),s=D().reverse().find(o=>o<e-1e-4);return s===void 0?v():O(s)}},{id:"view-all",title:"Timeline: View All",run:()=>(le(),v())},{id:"zoom",title:"Timeline: Zoom",run:e=>{const s=Number(e?.to??e?.zoom);if(!Number.isFinite(s))throw new Error("zoom needs a numeric `to` — CSS pixels per frame, 0.25 … 200.");const{transform:o,size:r}=M(),n=o.startFrame+r.w/2/o.pixelsPerFrame,i=Math.min(me,Math.max(de,s));return k({transform:{pixelsPerFrame:i,startFrame:n-r.w/2/i}}),v()}},{id:"pan",title:"Timeline: Pan",run:e=>{const s=Number(e?.frames??0);if(!Number.isFinite(s))throw new Error("pan needs a numeric `frames`.");const{transform:o}=M();return k({transform:{...o,startFrame:o.startFrame+s}}),v()}},...Object.keys(B).map(e=>({id:e,run:()=>$(B[e])}))]});function Ze(){const e=f.useSyncExternalStore(ye,Q,Q);f.useSyncExternalStore(ae,L,L),f.useSyncExternalStore(K,_,_);const s=f.useRef(null),o=f.useRef(-1),{transform:r,size:n,refusal:i,onlySelected:c}=M(),l=p.state();f.useEffect(()=>{let t=!0;return p.bind(he,{rig:()=>xe(),clip:()=>ge()}).catch(m=>{t&&G(`The Timeline could not read this file's rig: ${m instanceof Error?m.message:String(m)}`)}),()=>{t=!1}},[e]),f.useEffect(()=>{const t=s.current;if(!t)return;const m=new ResizeObserver(()=>{const u={w:t.clientWidth,h:t.clientHeight},y=M().size;(y.w!==u.w||y.h!==u.h)&&k({size:u})});return m.observe(t),k({size:{w:t.clientWidth,h:t.clientHeight}}),()=>m.disconnect()},[]);const S=Ee();f.useEffect(()=>{if(S===o.current)return;o.current=S;const{w:t}=M().size;if(t===0)return;const m=Math.max(1,l.end-l.start),u=Math.min(me,Math.max(de,t*.9/m));k({transform:{pixelsPerFrame:u,startFrame:l.start-t*.05/u},framedAt:Date.now()})},[S,l.start,l.end]);const b=f.useCallback(t=>(t-r.startFrame)*r.pixelsPerFrame,[r]),Y=f.useCallback(t=>r.startFrame+t/r.pixelsPerFrame,[r]),F=f.useMemo(()=>ue(l.summary,c),[l.summary,c]),E=f.useMemo(()=>{if(n.w===0)return null;const t=n.w/r.pixelsPerFrame,m=Math.max(`${Math.round(r.startFrame)}`.length,`${Math.round(r.startFrame+t)}`.length),u=Math.max(te,m*6+Se),y=je(Math.round(l.fps),n.w+1,t,u),w=Fe(y),fe=Math.ceil(r.startFrame/y)*y,Z=[];for(let R=fe;R<=r.startFrame+t;R+=y)Z.push(R);const q=[];if(w!==null&&w*r.pixelsPerFrame>=te/5){const R=Math.ceil(r.startFrame/w)*w;for(let I=R;I<=r.startFrame+t;I+=w)Math.abs(I/y-Math.round(I/y))>1e-6&&q.push(I)}return{major:y,minor:w,majors:Z,minors:q}},[n.w,r,l.fps]),N=T,j=ke+Te/2;f.useEffect(()=>{if(!E)return;const t=[...l.warnings];l.action||t.push("Nothing in this file carries an action, so the summary row is empty — which is Blender's own empty state for a Timeline over a still file."),t.push("While a clip plays, the picture is three.js evaluating the skin over the mesh columns Blender exported at the BIND frame. Anything else Blender would re-evaluate per frame — shape keys, a Displace or Cloth modifier reading the frame, a geometry driver — does not follow the playhead."),t.push("Blender puts this view's ONLY-SHOW-SELECTED toggle in the Timeline header's View MENU (`TIME_MT_view`'s `layout.prop(scene, \"show_keys_from_selected_only\")`, `space_time.py`); this header has no menu region, so the same toggle is drawn as a header button at the leading edge, where that menu sits. The filter itself is Blender's — `ADS_FILTER_ONLYSEL`, `anim_filter.cc:254-270`, tested per object at `:2307`."),c&&F.objects.length===0&&l.summary.length>0&&t.push(`The summary row is empty because nothing animated is SELECTED, which is Blender's own answer with this filter on. ${l.summary.map(u=>u.object).join(", ")} carr${l.summary.length===1?"ies":"y"} an action; select it, or turn the filter off.`),t.push("Markers, the cache bar and the preview range are drawn by Blender's Timeline and not here; the door carries none of them.");const m={drawn:{action:l.action,object:l.object,armature:l.armature,frame:l.frame,start:l.start,end:l.end,fps:l.fps,playing:V(),keyframes:F.columns.map(u=>u.frame),onlySelected:c,summaryObjects:F.objects,majorStep:E.major,minorStep:E.minor,majorLines:E.majors.length,minorLines:E.minors.length,labels:E.majors.length,diamonds:F.columns.length,diamondRadius:ne,diamondSprite:_e,bones:l.bones,tracks:l.tracks,engineCalls:l.engineCalls,warnings:t}};JSON.stringify(m.drawn)!==JSON.stringify(M().drawn)&&k(m)},[E,l,F,c]);const C=f.useRef(!1),J=f.useCallback(t=>{const m=s.current;if(!m)return;const u=m.getBoundingClientRect();h()?.seekFrame(Math.round(Y(t-u.left)))},[Y]),U=`${Math.round(l.frame)}`,X=Math.max(g.minPillWidth,U.length*6+2*g.textPadding),A=b(l.frame);return a.jsxs("div",{"data-testid":"blender-timeline",style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",overflow:"hidden",background:x.back,color:d.text,font:"11px Inter, system-ui, sans-serif"},children:[a.jsx(Oe,{}),a.jsx("div",{ref:s,style:{flex:1,minHeight:0,position:"relative"},children:a.jsxs("svg",{width:n.w,height:n.h,style:{display:"block",cursor:"ew-resize"},"aria-label":"Timeline",onPointerDown:t=>{C.current=!0,t.currentTarget.setPointerCapture(t.pointerId),J(t.clientX)},onPointerMove:t=>{C.current&&J(t.clientX)},onPointerUp:t=>{C.current=!1,t.currentTarget.releasePointerCapture(t.pointerId)},children:[a.jsx("title",{children:"Timeline"}),a.jsx("rect",{x:0,y:0,width:n.w,height:n.h,fill:x.back}),a.jsx("rect",{x:0,y:N,width:Math.max(0,b(l.start)),height:Math.max(0,n.h-N),fill:ie}),a.jsx("rect",{x:b(l.end),y:N,width:Math.max(0,n.w-b(l.end)),height:Math.max(0,n.h-N),fill:ie}),E?.minors.map(t=>a.jsx("line",{x1:b(t),y1:N,x2:b(t),y2:n.h,stroke:x.gridMinor,strokeWidth:1},`n${t}`)),E?.majors.map(t=>a.jsx("line",{x1:b(t),y1:N,x2:b(t),y2:n.h,stroke:x.grid,strokeWidth:1},`m${t}`)),a.jsx("rect",{x:0,y:0,width:n.w,height:T,fill:x.scrubBack}),E?.majors.map(t=>a.jsx("text",{x:b(t),y:15.5,textAnchor:"middle",fill:x.scrubText,fontSize:11,children:Math.round(t)},`t${t}`)),a.jsx("path",{d:`M3,${j-3.5} L6.5,${j} L3,${j+3.5} Z`,fill:x.scrubText}),F.columns.map(t=>{const m=Ne[t.type]??1,u=ne*m,y=re[t.type]??re.KEYFRAME,w=b(t.frame);return a.jsx("polygon",{points:`${w},${j-u} ${w+u},${j} ${w},${j+u} ${w-u},${j}`,fill:t.select?y.selected:y.fill,stroke:x.keyBorder,strokeWidth:Ae*m},`k${t.frame}`)}),a.jsx("rect",{x:A-g.stalkWidth/2,y:T,width:g.stalkWidth,height:Math.max(0,n.h-T),fill:x.playhead}),a.jsx("rect",{x:A-X/2,y:g.margin,width:X,height:T-2*g.margin,rx:g.radius,fill:x.playhead}),a.jsx("polygon",{points:`${A-g.tipHalfWidth},${T-g.margin} ${A+g.tipHalfWidth},${T-g.margin} ${A},${T-g.margin+g.tipHeight}`,fill:x.playhead}),a.jsx("text",{x:A,y:15.5,textAnchor:"middle",fill:x.playheadText,fontSize:11,children:U})]})}),i?a.jsx("div",{style:{borderTop:`1px solid ${d.rule}`,padding:d.statusPadding,color:d.refusal},children:i}):null]})}function Ie(){f.useSyncExternalStore(K,_,_);const{onlySelected:e}=M(),[s,o]=f.useState(!1),r=(n,i,c)=>a.jsxs("button",{type:"button",onClick:()=>{c(),o(!1)},style:{display:"flex",alignItems:"center",gap:"var(--vgai-space-2)",width:"100%",padding:"var(--vgai-space-1) var(--vgai-space-3)",border:"none",background:"transparent",color:d.widgetText,font:"inherit",textAlign:"left",cursor:"pointer"},children:[a.jsx("span",{style:{width:12,display:"inline-block"},children:i===null?"":i?"✓":""}),n]});return a.jsxs("span",{style:{position:"relative"},children:[a.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":s,onClick:()=>o(n=>!n),style:{border:"none",background:"transparent",color:d.text,font:"inherit",padding:"0 var(--vgai-space-2)",cursor:"pointer"},children:"View"}),s?a.jsxs("span",{role:"menu",style:{position:"absolute",top:"100%",left:0,zIndex:20,minWidth:210,display:"flex",flexDirection:"column",background:d.widget,border:`1px solid ${d.widgetOutline}`,boxShadow:"0 6px 18px rgba(0,0,0,0.45)"},children:[r("Only Show Selected",e,()=>be(!e)),r("Frame All",null,()=>le())]}):null]})}function Oe(){f.useSyncExternalStore(ae,L,L),f.useSyncExternalStore(K,_,_);const e=p.state(),s=d.unit,o=p.playable,r=(i,c,l,S)=>a.jsx("button",{type:"button",title:o?S:`${S} — ${z}`,"aria-label":S,disabled:!o,onClick:l,style:{width:s,height:s,padding:0,border:`1px solid ${d.widgetOutline}`,background:d.widget,color:d.widgetText,display:"grid",placeItems:"center",cursor:o?"pointer":"not-allowed",opacity:o?1:.4},children:c},i),n=i=>a.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12","aria-hidden":"true",children:a.jsx("path",{d:i,fill:d.widgetText})});return a.jsxs("div",{style:{height:ee,flex:`0 0 ${ee}px`,display:"flex",alignItems:"center",gap:d.headerGap,padding:d.headerPadding,background:x.header,borderBottom:`1px solid ${d.rule}`},children:[a.jsx("span",{style:{color:d.text},children:"Timeline"}),a.jsx(Ie,{}),a.jsx("div",{style:{flex:1}}),a.jsxs("div",{style:{display:"flex"},children:[r("jump-start",n("M2 2h1.5v8H2zM10 2v8L4.5 6z"),()=>h()?.seekFrame(e.start),"Jump to Start"),r("prev-key",n("M5 2.5v7L1.5 6zM8.5 3.2L11 6L8.5 8.8L6 6z"),()=>{const i=D().reverse().find(c=>c<p.frame()-1e-4);i!==void 0&&h()?.seekFrame(i)},"Jump to Previous Keyframe"),o&&V()?r("pause-rev",n("M3 2h2v8H3zM7 2h2v8H7z"),()=>h()?.pause(),"Pause"):r("play-reverse",n("M9 2L2 6l7 4z"),()=>h()?.play("reverse"),"Play Reverse"),o&&V()?r("pause",n("M3 2h2v8H3zM7 2h2v8H7z"),()=>h()?.pause(),"Pause"):r("play",n("M3 2l7 4-7 4z"),()=>h()?.play(),"Play"),r("next-key",n("M7 2.5v7L10.5 6zM3.5 3.2L6 6L3.5 8.8L1 6z"),()=>{const i=D().find(c=>c>p.frame()+1e-4);i!==void 0&&h()?.seekFrame(i)},"Jump to Next Keyframe"),r("jump-end",n("M10 2H8.5v8H10zM2 2v8L7.5 6z"),()=>h()?.seekFrame(e.end),"Jump to End")]}),a.jsxs("div",{style:{display:"flex"},children:[r("step-back",n("M2 2h1.5v8H2zM9.5 2v8L4.5 6z"),()=>h()?.seekFrame(Math.round(e.frame)-1),"Step Back One Frame"),r("step-forward",n("M10 2H8.5v8H10zM2.5 2v8L7.5 6z"),()=>h()?.seekFrame(Math.round(e.frame)+1),"Step Forward One Frame")]}),a.jsx("div",{style:{flex:1}}),a.jsx("input",{type:"number",value:Math.round(e.frame),onChange:i=>{const c=Number(i.target.value);Number.isFinite(c)&&h()?.seekFrame(c)},"aria-label":"Current frame",disabled:!o,title:o?void 0:z,style:{width:75,height:s,textAlign:"center",border:`1px solid ${d.widgetOutline}`,borderRadius:d.widgetRadius,background:d.widget,color:d.widgetText,font:"inherit",cursor:o?"text":"not-allowed",opacity:o?1:.4}}),a.jsxs("span",{onClick:()=>G(B["set-range"]),onKeyDown:()=>{},style:{color:d.text,cursor:"not-allowed"},children:["Start ",e.start," · End ",e.end]})]})}export{Ze as default,Xe as point,Re as title};
@@ -1 +1 @@
1
- import{a as u}from"./jsx-runtime-DPjLkJKQ.js";import{ah as le}from"./index-5av5LJja.js";import{r as c}from"./index-DaQZGF7d.js";import{s as ue,e as X,o as de}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 he={transform:{cx:.5,cy:.5,zoom:512},refusal:null,size:{w:0,h:0},framedAt:0,drawn:null};let L=he,N=0;const T=new Set;let te=0;function m(){return L}function Q(){return N}function fe(t){return T.add(t),()=>{T.delete(t)}}function v(t){L={...L,...t},N+=1;for(const r of[...T])r()}function pe(){te+=1,N+=1;for(const t of[...T])t()}function me(){return te}function ne(t){v({refusal:t})}const x={back:"#303030",grid:"#303030",face:"#ffffff",faceAlpha:10/255,uvShadow:"#707070",vertex:"#000000",faceDot:"#000000"},B={vertexSize:3,edgeWidth:1,facedotSize:3},se=1,ge=(B.vertexSize*se+1.5)*Math.SQRT2,ve=.75,we=B.facedotSize*se,ye=1,J=[1,1],K=[10,10],xe="Blender's `.space_image.grid` is #303030 at full alpha (userdef_default_theme.c:586) and this view's surface is #303030, so the tile grid draws at the theme's colour and is invisible against it. The image region's own clear is the overlay engine's (DRW_draw_view, space_image.cc:758), which is not in the source checkout — the sighted read settles the contrast.",be={shadow:{inner:x.uvShadow}},Ue=Math.max(B.edgeWidth,1),ee="#ff0000";function W(t){const r=atob(t),a=new Uint8Array(r.length);for(let d=0;d<r.length;d++)a[d]=r.charCodeAt(d);return a}function Ve(t){const r=W(t);return new Float32Array(r.buffer,r.byteOffset,r.byteLength>>2)}function z(t){const r=W(t);return new Uint32Array(r.buffer,r.byteOffset,r.byteLength>>2)}function Ee(t,r){const a=Number.parseInt(t.slice(1),16);return`rgba(${a>>16&255}, ${a>>8&255}, ${a&255}, ${Math.round(r*1e3)/1e3})`}const E={text:"#e6e6e6",refusal:"#ed5700",rule:"#232323",statusPadding:"3px 8px",statusGap:12},Ne="workspace.document",_e="UV Editor",D=8e3,re=16,oe=8192,_={move:t=>`Dragging a UV in "${t}" writes the mesh's UV attribute, which the document would save. This is Blender's UV editor as an INSPECTION surface: editing parity is not the program.`,select:"Selecting a UV writes the mesh's selection state. This view draws what the DATA carries — and at this pin a mesh outside edit mode carries no UV selection at all (MeshUVLoopLayer declares uv, pin, name, active, active_render, active_clone and nothing else), so everything draws unselected. Editing parity is not the program.",pin:"Pinning a UV writes `MeshUVLoopLayer.pin`, which the document would save. Existing pins ARE drawn, in Blender's own hard red. Editing parity is not the program.",unwrap:"Unwrapping runs `bpy.ops.uv.unwrap`, which rewrites every UV on the mesh. Editing parity is not the program."};le({view:"blender-uv-view",title:_e,verbs:[{id:"state",run:()=>m()},{id:"view-all",title:"UV Editor: View All",run:()=>(pe(),m())},{id:"zoom",title:"UV Editor: Zoom",run:t=>{const r=Number(t?.to??t?.zoom);if(!Number.isFinite(r))throw new Error("zoom needs a numeric `to` — CSS pixels per UV unit, 16 … 8192.");const{transform:a}=m();return v({transform:{...a,zoom:Math.min(oe,Math.max(re,r))}}),m()}},{id:"pan",title:"UV Editor: Pan",run:t=>{const r=Number(t?.u??0),a=Number(t?.v??0);if(!Number.isFinite(r)||!Number.isFinite(a))throw new Error("pan needs numeric `u` and `v`, in UV units.");const{transform:d}=m();return v({transform:{...d,cx:d.cx+r,cy:d.cy+a}}),m()}},{id:"move-uv",run:()=>R(_.move("the active UV map"))},{id:"select",run:()=>R(_.select)},{id:"pin",run:()=>R(_.pin)},{id:"unwrap",run:()=>R(_.unwrap)}]});function R(t){return ne(t),m()}function Se(t){return!t?.uvBase64||!t.triangleBase64?null:{uv:Ve(t.uvBase64),tris:z(t.triangleBase64),starts:z(t.loopStartBase64??""),totals:z(t.loopTotalBase64??""),pins:t.pinBase64?W(t.pinBase64):null}}function Be(){const t=c.useSyncExternalStore(ue,X,X);c.useSyncExternalStore(fe,Q,Q);const r=c.useRef(0),a=c.useRef(null),d=c.useRef(null),M=c.useRef(null),{transform:b,refusal:C,size:U}=m(),[,F]=[0,c.useCallback(()=>v({}),[])];c.useEffect(()=>{let e=!0;return(async()=>{try{const s=await de();if(!e)return;d.current=s,M.current=null}catch(s){if(!e)return;M.current=s instanceof Error?s.message:String(s)}F()})(),()=>{e=!1}},[t,F]),c.useEffect(()=>{const e=a.current;if(!e)return;const s=new ResizeObserver(()=>{const l={w:e.clientWidth,h:e.clientHeight},h=m().size;(h.w!==l.w||h.h!==l.h)&&v({size:l})});return s.observe(e),v({size:{w:e.clientWidth,h:e.clientHeight}}),()=>s.disconnect()},[]);const n=d.current,j=c.useMemo(()=>Se(n),[n]),O=me();c.useEffect(()=>{if(O===r.current)return;r.current=O;const e=n?.bounds??[0,0,1,1],{w:s,h:l}=m().size;if(s===0||l===0)return;const[h,g,o,f]=e,V=Math.max(o-h,.001),S=Math.max(f-g,.001),k=Math.min(oe,Math.max(re,Math.min(s/V,l/S)*.9));v({transform:{cx:(h+o)/2,cy:(g+f)/2,zoom:k},framedAt:Date.now()})},[O,n]);const w=e=>(e-b.cx)*b.zoom+U.w/2,y=e=>U.h/2-(e-b.cy)*b.zoom,i=c.useMemo(()=>{if(!n||!j)return null;const{uv:e,tris:s,starts:l,totals:h,pins:g}=j,o=[],f=[],V=[],S=[],k=l.length;for(let p=0;p<k;p++){const ce=l[p],I=h[p];if(I<3)continue;let $="",H=0,G=0;for(let A=0;A<I;A++){const Z=ce+A,q=e[Z*2],Y=e[Z*2+1];H+=q,G+=Y,$+=`${A===0?"M":"L"}${w(q).toFixed(2)} ${y(Y).toFixed(2)}`}$+="Z",o.push($),f.push($),S.push({x:w(H/I),y:y(G/I)})}const P=e.length>>1;for(let p=0;p<P&&V.length<D;p++)V.push({x:w(e[p*2]),y:y(e[p*2+1]),pinned:g?g[p]!==0:!1});return{faces:o,outlines:f,dots:V,faceDots:S,corners:P,triangles:s.length/3}},[n,j,b,U]);c.useEffect(()=>{if(!n)return;const e=[];n.layers.length===0&&n.object&&e.push(`"${n.object}" has no UV map — Blender's UV editor draws an empty tile.`),i&&i.corners>D&&e.push(`${i.corners} UV corners exceed this view's ${D}-dot budget; ${i.corners-D} corner marks are not drawn. The islands, their edges and the face dots are all drawn.`),n.image||e.push("No image behind the tile: the active material's node tree has no image texture with an image, so there is nothing for Blender's backdrop to show."),e.push(xe),e.push("The line style is SHADOW (#707070), not Blender's stock OUTLINE: `edit_uv_line_style_from_space_image` returns OUTLINE only when `SpaceImage.mode == SI_MODE_UV`, and there is no SpaceImage here."),v({drawn:{object:n.object,mesh:n.mesh,layer:n.active,layers:n.layers,mode:n.mode,loops:n.loops,polygons:n.polygons,triangles:i?.triangles??0,faces:i?.faces.length??0,edges:i?.outlines.length??0,verts:i?.dots.length??0,faceDots:i?.faceDots.length??0,pinned:i?.dots.filter(s=>s.pinned).length??0,bounds:n.bounds??null,tiles:J,subdiv:K,image:n.image?.name??null,warnings:e}})},[n,i]);const ie=c.useMemo(()=>{const e=[],[s,l]=J,[h,g]=K;for(let o=0;o<=s*h;o++){const f=o/h;e.push({key:`u${o}`,x1:w(f),y1:y(0),x2:w(f),y2:y(l),major:o%h===0})}for(let o=0;o<=l*g;o++){const f=o/g;e.push({key:`v${o}`,x1:w(0),y1:y(f),x2:w(s),y2:y(f),major:o%g===0})}return e},[b,U]),ae=n?n.active?`UV Editor · ${n.object} · ${n.active} · ${n.polygons} faces, ${n.loops} corners · ${n.mode}`:`UV Editor · ${n.object??"no mesh selected"} · no UV map · ${n.mode}`:M.current??"UV Editor · reading…";return u.jsxs("div",{"data-testid":"blender-uv-editor",style:{display:"flex",flexDirection:"column",position:"absolute",inset:0,overflow:"hidden",background:x.back,color:E.text,font:"11px Inter, system-ui, sans-serif"},children:[u.jsx("div",{ref:a,style:{flex:1,minHeight:0,position:"relative"},children:u.jsxs("svg",{width:U.w,height:U.h,style:{display:"block"},onPointerDown:()=>ne(_.select),"aria-label":"UV layout",children:[u.jsx("title",{children:"UV layout"}),ie.map(e=>u.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:x.grid,strokeWidth:e.major?2:1},e.key)),i?.faces.map((e,s)=>u.jsx("path",{d:e,fill:Ee(x.face,x.faceAlpha*ye)},`f${s}`)),i?.outlines.map((e,s)=>u.jsx("path",{d:e,fill:"none",stroke:be.shadow.inner,strokeWidth:Ue},`e${s}`)),i?.faceDots.map((e,s)=>u.jsx("circle",{cx:e.x,cy:e.y,r:we/2,fill:x.faceDot},`fd${s}`)),i?.dots.map((e,s)=>u.jsx("circle",{cx:e.x,cy:e.y,r:ge/2,fill:e.pinned?ee:x.vertex,stroke:e.pinned?ee:"none",strokeWidth:e.pinned?ve:0},`v${s}`))]})}),u.jsxs("div",{style:{borderTop:`1px solid ${E.rule}`,padding:E.statusPadding,display:"flex",gap:E.statusGap,alignItems:"center"},children:[u.jsx("span",{children:ae}),C?u.jsx("span",{style:{color:E.refusal},children:C}):null]})]})}export{Be as default,Ne as point,_e as title};
1
+ import{a as u}from"./jsx-runtime-DPjLkJKQ.js";import{ah as le}from"./index-CY4oDLhJ.js";import{r as c}from"./index-DaQZGF7d.js";import{s as ue,e as X,o as de}from"./blender-runtime-host-DGe1KLVZ.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 he={transform:{cx:.5,cy:.5,zoom:512},refusal:null,size:{w:0,h:0},framedAt:0,drawn:null};let L=he,N=0;const T=new Set;let te=0;function m(){return L}function Q(){return N}function fe(t){return T.add(t),()=>{T.delete(t)}}function v(t){L={...L,...t},N+=1;for(const r of[...T])r()}function pe(){te+=1,N+=1;for(const t of[...T])t()}function me(){return te}function ne(t){v({refusal:t})}const x={back:"#303030",grid:"#303030",face:"#ffffff",faceAlpha:10/255,uvShadow:"#707070",vertex:"#000000",faceDot:"#000000"},B={vertexSize:3,edgeWidth:1,facedotSize:3},se=1,ge=(B.vertexSize*se+1.5)*Math.SQRT2,ve=.75,we=B.facedotSize*se,ye=1,J=[1,1],K=[10,10],xe="Blender's `.space_image.grid` is #303030 at full alpha (userdef_default_theme.c:586) and this view's surface is #303030, so the tile grid draws at the theme's colour and is invisible against it. The image region's own clear is the overlay engine's (DRW_draw_view, space_image.cc:758), which is not in the source checkout — the sighted read settles the contrast.",be={shadow:{inner:x.uvShadow}},Ue=Math.max(B.edgeWidth,1),ee="#ff0000";function W(t){const r=atob(t),a=new Uint8Array(r.length);for(let d=0;d<r.length;d++)a[d]=r.charCodeAt(d);return a}function Ve(t){const r=W(t);return new Float32Array(r.buffer,r.byteOffset,r.byteLength>>2)}function z(t){const r=W(t);return new Uint32Array(r.buffer,r.byteOffset,r.byteLength>>2)}function Ee(t,r){const a=Number.parseInt(t.slice(1),16);return`rgba(${a>>16&255}, ${a>>8&255}, ${a&255}, ${Math.round(r*1e3)/1e3})`}const E={text:"#e6e6e6",refusal:"#ed5700",rule:"#232323",statusPadding:"3px 8px",statusGap:12},Ne="workspace.document",_e="UV Editor",D=8e3,re=16,oe=8192,_={move:t=>`Dragging a UV in "${t}" writes the mesh's UV attribute, which the document would save. This is Blender's UV editor as an INSPECTION surface: editing parity is not the program.`,select:"Selecting a UV writes the mesh's selection state. This view draws what the DATA carries — and at this pin a mesh outside edit mode carries no UV selection at all (MeshUVLoopLayer declares uv, pin, name, active, active_render, active_clone and nothing else), so everything draws unselected. Editing parity is not the program.",pin:"Pinning a UV writes `MeshUVLoopLayer.pin`, which the document would save. Existing pins ARE drawn, in Blender's own hard red. Editing parity is not the program.",unwrap:"Unwrapping runs `bpy.ops.uv.unwrap`, which rewrites every UV on the mesh. Editing parity is not the program."};le({view:"blender-uv-view",title:_e,verbs:[{id:"state",run:()=>m()},{id:"view-all",title:"UV Editor: View All",run:()=>(pe(),m())},{id:"zoom",title:"UV Editor: Zoom",run:t=>{const r=Number(t?.to??t?.zoom);if(!Number.isFinite(r))throw new Error("zoom needs a numeric `to` — CSS pixels per UV unit, 16 … 8192.");const{transform:a}=m();return v({transform:{...a,zoom:Math.min(oe,Math.max(re,r))}}),m()}},{id:"pan",title:"UV Editor: Pan",run:t=>{const r=Number(t?.u??0),a=Number(t?.v??0);if(!Number.isFinite(r)||!Number.isFinite(a))throw new Error("pan needs numeric `u` and `v`, in UV units.");const{transform:d}=m();return v({transform:{...d,cx:d.cx+r,cy:d.cy+a}}),m()}},{id:"move-uv",run:()=>R(_.move("the active UV map"))},{id:"select",run:()=>R(_.select)},{id:"pin",run:()=>R(_.pin)},{id:"unwrap",run:()=>R(_.unwrap)}]});function R(t){return ne(t),m()}function Se(t){return!t?.uvBase64||!t.triangleBase64?null:{uv:Ve(t.uvBase64),tris:z(t.triangleBase64),starts:z(t.loopStartBase64??""),totals:z(t.loopTotalBase64??""),pins:t.pinBase64?W(t.pinBase64):null}}function Be(){const t=c.useSyncExternalStore(ue,X,X);c.useSyncExternalStore(fe,Q,Q);const r=c.useRef(0),a=c.useRef(null),d=c.useRef(null),M=c.useRef(null),{transform:b,refusal:C,size:U}=m(),[,F]=[0,c.useCallback(()=>v({}),[])];c.useEffect(()=>{let e=!0;return(async()=>{try{const s=await de();if(!e)return;d.current=s,M.current=null}catch(s){if(!e)return;M.current=s instanceof Error?s.message:String(s)}F()})(),()=>{e=!1}},[t,F]),c.useEffect(()=>{const e=a.current;if(!e)return;const s=new ResizeObserver(()=>{const l={w:e.clientWidth,h:e.clientHeight},h=m().size;(h.w!==l.w||h.h!==l.h)&&v({size:l})});return s.observe(e),v({size:{w:e.clientWidth,h:e.clientHeight}}),()=>s.disconnect()},[]);const n=d.current,j=c.useMemo(()=>Se(n),[n]),O=me();c.useEffect(()=>{if(O===r.current)return;r.current=O;const e=n?.bounds??[0,0,1,1],{w:s,h:l}=m().size;if(s===0||l===0)return;const[h,g,o,f]=e,V=Math.max(o-h,.001),S=Math.max(f-g,.001),k=Math.min(oe,Math.max(re,Math.min(s/V,l/S)*.9));v({transform:{cx:(h+o)/2,cy:(g+f)/2,zoom:k},framedAt:Date.now()})},[O,n]);const w=e=>(e-b.cx)*b.zoom+U.w/2,y=e=>U.h/2-(e-b.cy)*b.zoom,i=c.useMemo(()=>{if(!n||!j)return null;const{uv:e,tris:s,starts:l,totals:h,pins:g}=j,o=[],f=[],V=[],S=[],k=l.length;for(let p=0;p<k;p++){const ce=l[p],I=h[p];if(I<3)continue;let $="",H=0,G=0;for(let A=0;A<I;A++){const Z=ce+A,q=e[Z*2],Y=e[Z*2+1];H+=q,G+=Y,$+=`${A===0?"M":"L"}${w(q).toFixed(2)} ${y(Y).toFixed(2)}`}$+="Z",o.push($),f.push($),S.push({x:w(H/I),y:y(G/I)})}const P=e.length>>1;for(let p=0;p<P&&V.length<D;p++)V.push({x:w(e[p*2]),y:y(e[p*2+1]),pinned:g?g[p]!==0:!1});return{faces:o,outlines:f,dots:V,faceDots:S,corners:P,triangles:s.length/3}},[n,j,b,U]);c.useEffect(()=>{if(!n)return;const e=[];n.layers.length===0&&n.object&&e.push(`"${n.object}" has no UV map — Blender's UV editor draws an empty tile.`),i&&i.corners>D&&e.push(`${i.corners} UV corners exceed this view's ${D}-dot budget; ${i.corners-D} corner marks are not drawn. The islands, their edges and the face dots are all drawn.`),n.image||e.push("No image behind the tile: the active material's node tree has no image texture with an image, so there is nothing for Blender's backdrop to show."),e.push(xe),e.push("The line style is SHADOW (#707070), not Blender's stock OUTLINE: `edit_uv_line_style_from_space_image` returns OUTLINE only when `SpaceImage.mode == SI_MODE_UV`, and there is no SpaceImage here."),v({drawn:{object:n.object,mesh:n.mesh,layer:n.active,layers:n.layers,mode:n.mode,loops:n.loops,polygons:n.polygons,triangles:i?.triangles??0,faces:i?.faces.length??0,edges:i?.outlines.length??0,verts:i?.dots.length??0,faceDots:i?.faceDots.length??0,pinned:i?.dots.filter(s=>s.pinned).length??0,bounds:n.bounds??null,tiles:J,subdiv:K,image:n.image?.name??null,warnings:e}})},[n,i]);const ie=c.useMemo(()=>{const e=[],[s,l]=J,[h,g]=K;for(let o=0;o<=s*h;o++){const f=o/h;e.push({key:`u${o}`,x1:w(f),y1:y(0),x2:w(f),y2:y(l),major:o%h===0})}for(let o=0;o<=l*g;o++){const f=o/g;e.push({key:`v${o}`,x1:w(0),y1:y(f),x2:w(s),y2:y(f),major:o%g===0})}return e},[b,U]),ae=n?n.active?`UV Editor · ${n.object} · ${n.active} · ${n.polygons} faces, ${n.loops} corners · ${n.mode}`:`UV Editor · ${n.object??"no mesh selected"} · no UV map · ${n.mode}`:M.current??"UV Editor · reading…";return u.jsxs("div",{"data-testid":"blender-uv-editor",style:{display:"flex",flexDirection:"column",position:"absolute",inset:0,overflow:"hidden",background:x.back,color:E.text,font:"11px Inter, system-ui, sans-serif"},children:[u.jsx("div",{ref:a,style:{flex:1,minHeight:0,position:"relative"},children:u.jsxs("svg",{width:U.w,height:U.h,style:{display:"block"},onPointerDown:()=>ne(_.select),"aria-label":"UV layout",children:[u.jsx("title",{children:"UV layout"}),ie.map(e=>u.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:x.grid,strokeWidth:e.major?2:1},e.key)),i?.faces.map((e,s)=>u.jsx("path",{d:e,fill:Ee(x.face,x.faceAlpha*ye)},`f${s}`)),i?.outlines.map((e,s)=>u.jsx("path",{d:e,fill:"none",stroke:be.shadow.inner,strokeWidth:Ue},`e${s}`)),i?.faceDots.map((e,s)=>u.jsx("circle",{cx:e.x,cy:e.y,r:we/2,fill:x.faceDot},`fd${s}`)),i?.dots.map((e,s)=>u.jsx("circle",{cx:e.x,cy:e.y,r:ge/2,fill:e.pinned?ee:x.vertex,stroke:e.pinned?ee:"none",strokeWidth:e.pinned?ve:0},`v${s}`))]})}),u.jsxs("div",{style:{borderTop:`1px solid ${E.rule}`,padding:E.statusPadding,display:"flex",gap:E.statusGap,alignItems:"center"},children:[u.jsx("span",{children:ae}),C?u.jsx("span",{style:{color:E.refusal},children:C}):null]})]})}export{Be as default,Ne as point,_e as title};
@@ -1 +1 @@
1
- import{a as r}from"./jsx-runtime-DPjLkJKQ.js";import{e as i}from"./index-5av5LJja.js";import{r as s}from"./index-DaQZGF7d.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";const v="workspace.status",f="Version",x="right",h=998;function b(){const{project:e}=i(),t=s.useSyncExternalStore(e.subscribe,e.engineVersion,e.engineVersion);return t===null?null:r.jsxs("span",{className:"vgai-status-copy","data-testid":"status-blender-version","data-engine-version":t,style:{display:"inline-flex",alignItems:"center",gap:"var(--vgai-space-2)",fontSize:"var(--vgai-font-md)"},title:`This project is built against engine ${t}`,children:[r.jsx("span",{"aria-hidden":"true",style:{width:"var(--vgai-stroke-resting)",height:"var(--vgai-icon-md)",background:"currentColor"}}),t]})}export{x as align,b as default,h as order,v as point,f as title};
1
+ import{a as r}from"./jsx-runtime-DPjLkJKQ.js";import{e as i}from"./index-CY4oDLhJ.js";import{r as s}from"./index-DaQZGF7d.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";const v="workspace.status",f="Version",x="right",h=998;function b(){const{project:e}=i(),t=s.useSyncExternalStore(e.subscribe,e.engineVersion,e.engineVersion);return t===null?null:r.jsxs("span",{className:"vgai-status-copy","data-testid":"status-blender-version","data-engine-version":t,style:{display:"inline-flex",alignItems:"center",gap:"var(--vgai-space-2)",fontSize:"var(--vgai-font-md)"},title:`This project is built against engine ${t}`,children:[r.jsx("span",{"aria-hidden":"true",style:{width:"var(--vgai-stroke-resting)",height:"var(--vgai-icon-md)",background:"currentColor"}}),t]})}export{x as align,b as default,h as order,v as point,f as title};