@galacean/cli 2.0.0-alpha.29 → 2.0.0-alpha.30

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 (95) hide show
  1. package/dist/cli.bundle.cjs +192793 -186137
  2. package/dist/preview-client/_static/{Accordion-6f002a96.js → Accordion-6346d8c5.js} +1 -1
  3. package/dist/preview-client/_static/{AmbientLightAsset-57a59fc2.js → AmbientLightAsset-ded8af87.js} +1 -1
  4. package/dist/preview-client/_static/{AnimationClipAsset-0a1f63eb.js → AnimationClipAsset-a767bb7a.js} +1 -1
  5. package/dist/preview-client/_static/{AnimatorControllerAsset-9192e596.js → AnimatorControllerAsset-c04c5158.js} +1 -1
  6. package/dist/preview-client/_static/{AnimatorStore-484b10cf.js → AnimatorStore-fd28fd44.js} +1 -1
  7. package/dist/preview-client/_static/{AssetViewer-9f395efb.js → AssetViewer-f505fb55.js} +1 -1
  8. package/dist/preview-client/_static/{AudioAsset-0ea4ba7b.js → AudioAsset-8b8ab944.js} +1 -1
  9. package/dist/preview-client/_static/{AudioComponent-9bf5944c.js → AudioComponent-4f62f1d6.js} +1 -1
  10. package/dist/preview-client/_static/{Callout-45631a14.js → Callout-7d87c30e.js} +1 -1
  11. package/dist/preview-client/_static/{CameraComponent-039457d1.js → CameraComponent-04ebed15.js} +1 -1
  12. package/dist/preview-client/_static/{Component-c3c0c167.js → Component-85241517.js} +1 -1
  13. package/dist/preview-client/_static/{DirectLight-7b1f4b9f.js → DirectLight-a2b904ed.js} +1 -1
  14. package/dist/preview-client/_static/{FontAsset-10273d05.js → FontAsset-5cd70e43.js} +1 -1
  15. package/dist/preview-client/_static/{FormItemArray-9d4196d8.js → FormItemArray-a06224b4.js} +1 -1
  16. package/dist/preview-client/_static/{GlTFAsset-917bf1ee.js → GlTFAsset-34fdaded.js} +1 -1
  17. package/dist/preview-client/_static/{IconPlus-2bfc60da.js → IconPlus-7690a910.js} +1 -1
  18. package/dist/preview-client/_static/{IconPointFilled-192e99c9.js → IconPointFilled-181a0586.js} +1 -1
  19. package/dist/preview-client/_static/{LightBaseComponent-948d3192.js → LightBaseComponent-6817bd8c.js} +1 -1
  20. package/dist/preview-client/_static/{LottieAnimationComponent-da226765.js → LottieAnimationComponent-fb9564f9.js} +1 -1
  21. package/dist/preview-client/_static/{MarkdownAsset-602f93bf.js → MarkdownAsset-ede9d841.js} +1 -1
  22. package/dist/preview-client/_static/{MaterialAsset-aa93db51.js → MaterialAsset-010030a2.js} +1 -1
  23. package/dist/preview-client/_static/{MaterialInspector-45e208c7.js → MaterialInspector-ebbe39d5.js} +1 -1
  24. package/dist/preview-client/_static/{Menu-beacc39d.js → Menu-7006a0c9.js} +1 -1
  25. package/dist/preview-client/_static/{MeshAsset-585f4b18.js → MeshAsset-3032a2d3.js} +1 -1
  26. package/dist/preview-client/_static/{MeshRendererBaseComponent-0bc9f5b3.js → MeshRendererBaseComponent-ea33dbe8.js} +1 -1
  27. package/dist/preview-client/_static/{MeshRendererComponent-84208d23.js → MeshRendererComponent-eaf512af.js} +1 -1
  28. package/dist/preview-client/_static/{MeshThumbnail-9bbe01dc.js → MeshThumbnail-3bb8bccf.js} +1 -1
  29. package/dist/preview-client/_static/ParticleRendererComponent-eb636961.js +31 -0
  30. package/dist/preview-client/_static/{PhysicsMaterialAsset-2dd013f8.js → PhysicsMaterialAsset-a768f5b6.js} +1 -1
  31. package/dist/preview-client/_static/PhysicsStore-8bca890a.js +1 -0
  32. package/dist/preview-client/_static/{PointLight-d9ace100.js → PointLight-1da0b361.js} +1 -1
  33. package/dist/preview-client/_static/{PostProcessComponent-2b5255d9.js → PostProcessComponent-366ce132.js} +1 -1
  34. package/dist/preview-client/_static/{PrefabAsset-8c923465.js → PrefabAsset-9e17aab2.js} +1 -1
  35. package/dist/preview-client/_static/{PrimitiveMesh-fde624a6.js → PrimitiveMesh-81a302d9.js} +1 -1
  36. package/dist/preview-client/_static/{ReferencedMaterial-890492a2.js → ReferencedMaterial-240e1be6.js} +1 -1
  37. package/dist/preview-client/_static/{RenderTargetAsset-bf38a725.js → RenderTargetAsset-81649762.js} +1 -1
  38. package/dist/preview-client/_static/{SceneAsset-7a9dbdd8.js → SceneAsset-68286235.js} +1 -1
  39. package/dist/preview-client/_static/{ShaderAsset-2f2c1e95.js → ShaderAsset-b2ea36b6.js} +25 -25
  40. package/dist/preview-client/_static/{ShaderChunkAsset-a3ff3959.js → ShaderChunkAsset-e32e6108.js} +1 -1
  41. package/dist/preview-client/_static/{ShaderUIScriptAsset-d3a2d680.js → ShaderUIScriptAsset-4adc4d41.js} +1 -1
  42. package/dist/preview-client/_static/{SkinnedMeshRendererComponent-96740600.js → SkinnedMeshRendererComponent-c0f2037a.js} +1 -1
  43. package/dist/preview-client/_static/{SpineAnimationComponent-3d4eec48.js → SpineAnimationComponent-ec1ed804.js} +1 -1
  44. package/dist/preview-client/_static/{SpineSkeletonDataAsset-a8598103.js → SpineSkeletonDataAsset-0fdb1ffc.js} +1 -1
  45. package/dist/preview-client/_static/{SpotLight-680a6e17.js → SpotLight-7da01a5f.js} +1 -1
  46. package/dist/preview-client/_static/{SpriteBaseComponent-96a500d7.js → SpriteBaseComponent-5027461c.js} +1 -1
  47. package/dist/preview-client/_static/{SpriteMaskComponent-58c35ea2.js → SpriteMaskComponent-ea250ae6.js} +1 -1
  48. package/dist/preview-client/_static/{SpriteRendererComponent-5c89f7dd.js → SpriteRendererComponent-fc459130.js} +1 -1
  49. package/dist/preview-client/_static/{TextBaseComponent-248ea222.js → TextBaseComponent-269e86ed.js} +1 -1
  50. package/dist/preview-client/_static/{TextRendererComponent-78458825.js → TextRendererComponent-e1a70d05.js} +1 -1
  51. package/dist/preview-client/_static/{TextureAsset-bf69040b.js → TextureAsset-adf746d9.js} +1 -1
  52. package/dist/preview-client/_static/{Tooltip-0268ffac.js → Tooltip-c84e8c00.js} +1 -1
  53. package/dist/preview-client/_static/{TrailRendererComponent-838e0118.js → TrailRendererComponent-7c1adc57.js} +1 -1
  54. package/dist/preview-client/_static/{TransformBaseComponent-c92aa259.js → TransformBaseComponent-bc3d99f0.js} +1 -1
  55. package/dist/preview-client/_static/{TransformComponent-d28b4035.js → TransformComponent-828e97ca.js} +1 -1
  56. package/dist/preview-client/_static/{XRReferenceImageAsset-16071f5c.js → XRReferenceImageAsset-699f6a74.js} +1 -1
  57. package/dist/preview-client/_static/{audio-1d573775.js → audio-5b6bbad7.js} +1 -1
  58. package/dist/preview-client/_static/{createOnModelChange-38471bb6.js → createOnModelChange-f0aaf591.js} +1 -1
  59. package/dist/preview-client/_static/{createReactComponent-3e49f864.js → createReactComponent-0c5ada83.js} +1 -1
  60. package/dist/preview-client/_static/{index-2f54d4c9.js → index-066cf34f.js} +1 -1
  61. package/dist/preview-client/_static/{index-4084db44.js → index-07a70c10.js} +1 -1
  62. package/dist/preview-client/_static/index-21ffc50d.js +1 -0
  63. package/dist/preview-client/_static/{index-65c6af4a.js → index-4145c87e.js} +3 -3
  64. package/dist/preview-client/_static/index-492bd067.js +1 -0
  65. package/dist/preview-client/_static/index-49a5902b.js +1 -0
  66. package/dist/preview-client/_static/index-6a2d3d63.js +1 -0
  67. package/dist/preview-client/_static/{index-8a22fe59.js → index-828538e1.js} +1 -1
  68. package/dist/preview-client/_static/{index-ce381b62.js → index-89133895.js} +2 -2
  69. package/dist/preview-client/_static/index-895723b4.js +1 -0
  70. package/dist/preview-client/_static/{index-1fa3ba70.js → index-981e5626.js} +1 -1
  71. package/dist/preview-client/_static/index-b154ff9d.js +1 -0
  72. package/dist/preview-client/_static/{index-9e3daa94.js → index-b4b2d2e5.js} +1 -1
  73. package/dist/preview-client/_static/{index-d497fb6d.js → index-eeedc550.js} +1072 -651
  74. package/dist/preview-client/_static/index-f145c261.js +1 -0
  75. package/dist/preview-client/_static/{index-68806c86.js → index-f655a65a.js} +1 -1
  76. package/dist/preview-client/_static/{ktx2-encoder-772f6c33.js → ktx2-encoder-2883b55c.js} +1 -1
  77. package/dist/preview-client/_static/{module-1470d524.js → module-11aabe24.js} +1 -1
  78. package/dist/preview-client/_static/{module-136992e3.js → module-ace60695.js} +1 -1
  79. package/dist/preview-client/_static/{module-77c2ea8c.js → module-be69621d.js} +1 -1
  80. package/dist/preview-client/_static/postmen-fe9eecc4.js +2 -0
  81. package/dist/preview-client/_static/{shader-data-utils-e38a959d.js → shader-data-utils-c00c9d18.js} +1 -1
  82. package/dist/preview-client/index.html +1 -1
  83. package/dist/types/tsconfig.exec-base.json +20 -0
  84. package/dist/types/typed-exec-api.d.ts +487 -0
  85. package/package.json +4 -2
  86. package/dist/preview-client/_static/ParticleRendererComponent-f3ac8d1b.js +0 -26
  87. package/dist/preview-client/_static/PhysicsStore-fcb01282.js +0 -1
  88. package/dist/preview-client/_static/index-0a57ae09.js +0 -1
  89. package/dist/preview-client/_static/index-1d0ae2e4.js +0 -1
  90. package/dist/preview-client/_static/index-2c567b8d.js +0 -1
  91. package/dist/preview-client/_static/index-5c27dafa.js +0 -1
  92. package/dist/preview-client/_static/index-bdda02cf.js +0 -1
  93. package/dist/preview-client/_static/index-c88f78ce.js +0 -1
  94. package/dist/preview-client/_static/index-e4fb05d8.js +0 -1
  95. package/dist/preview-client/_static/postmen-0413c689.js +0 -2
@@ -1 +1 @@
1
- import{b5 as oe,b6 as te,b7 as T,b8 as c,av as r,b9 as D,ba as re,bb as ne,bc as ie,bd as O,be as ae,bf as ce,bg as se,bh as de,bi as V,aH as b,bj as le}from"./index-d497fb6d.js";var u="Accordion",pe=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[H,ue,fe]=oe(u),[C,Ee]=te(u,[fe,T]),P=T(),M=c.forwardRef((o,i)=>{const{type:e,...n}=o,a=n,t=n;return r.jsx(H.Provider,{scope:o.__scopeAccordion,children:e==="multiple"?r.jsx(me,{...t,ref:i}):r.jsx(be,{...a,ref:i})})});M.displayName=u;var[B,ge]=C(u),[L,he]=C(u,{collapsible:!1}),be=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},collapsible:t=!1,...s}=o,[d,l]=D({prop:e,defaultProp:n,onChange:a});return r.jsx(B,{scope:o.__scopeAccordion,value:d?[d]:[],onItemOpen:l,onItemClose:c.useCallback(()=>t&&l(""),[t,l]),children:r.jsx(L,{scope:o.__scopeAccordion,collapsible:t,children:r.jsx(K,{...s,ref:i})})})}),me=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},...t}=o,[s=[],d]=D({prop:e,defaultProp:n,onChange:a}),l=c.useCallback(h=>d((f=[])=>[...f,h]),[d]),g=c.useCallback(h=>d((f=[])=>f.filter($=>$!==h)),[d]);return r.jsx(B,{scope:o.__scopeAccordion,value:s,onItemOpen:l,onItemClose:g,children:r.jsx(L,{scope:o.__scopeAccordion,collapsible:!0,children:r.jsx(K,{...t,ref:i})})})}),[xe,A]=C(u),K=c.forwardRef((o,i)=>{const{__scopeAccordion:e,disabled:n,dir:a,orientation:t="vertical",...s}=o,d=c.useRef(null),l=re(d,i),g=ue(e),f=ne(a)==="ltr",$=ie(o.onKeyDown,m=>{var E;if(!pe.includes(m.key))return;const Z=m.target,S=g().filter(R=>{var N;return!((N=R.ref.current)!=null&&N.disabled)}),x=S.findIndex(R=>R.ref.current===Z),z=S.length;if(x===-1)return;m.preventDefault();let p=x;const I=0,w=z-1,y=()=>{p=x+1,p>w&&(p=I)},j=()=>{p=x-1,p<I&&(p=w)};switch(m.key){case"Home":p=I;break;case"End":p=w;break;case"ArrowRight":t==="horizontal"&&(f?y():j());break;case"ArrowDown":t==="vertical"&&y();break;case"ArrowLeft":t==="horizontal"&&(f?j():y());break;case"ArrowUp":t==="vertical"&&j();break}const ee=p%z;(E=S[ee].ref.current)==null||E.focus()});return r.jsx(xe,{scope:e,disabled:n,direction:a,orientation:t,children:r.jsx(H.Slot,{scope:e,children:r.jsx(O.div,{...s,"data-orientation":t,ref:l,onKeyDown:n?void 0:$})})})}),v="AccordionItem",[ve,k]=C(v),U=c.forwardRef((o,i)=>{const{__scopeAccordion:e,value:n,...a}=o,t=A(v,e),s=ge(v,e),d=P(e),l=ae(),g=n&&s.value.includes(n)||!1,h=t.disabled||o.disabled;return r.jsx(ve,{scope:e,open:g,disabled:h,triggerId:l,children:r.jsx(ce,{"data-orientation":t.orientation,"data-state":J(g),...d,...a,ref:i,disabled:h,open:g,onOpenChange:f=>{f?s.onItemOpen(n):s.onItemClose(n)}})})});U.displayName=v;var G="AccordionHeader",W=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(G,e);return r.jsx(O.h3,{"data-orientation":a.orientation,"data-state":J(t.open),"data-disabled":t.disabled?"":void 0,...n,ref:i})});W.displayName=G;var _="AccordionTrigger",Y=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(_,e),s=he(_,e),d=P(e);return r.jsx(H.ItemSlot,{scope:e,children:r.jsx(se,{"aria-disabled":t.open&&!s.collapsible||void 0,"data-orientation":a.orientation,id:t.triggerId,...d,...n,ref:i})})});Y.displayName=_;var q="AccordionContent",F=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(q,e),s=P(e);return r.jsx(de,{role:"region","aria-labelledby":t.triggerId,"data-orientation":a.orientation,...s,...n,ref:i,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...o.style}})});F.displayName=q;function J(o){return o?"open":"closed"}var Ce=M,Ae=U,$e=W,Se=Y,Ie=F;const we=V({from:{height:0,opacity:0},to:{height:"var(--radix-accordion-content-height)",opacity:1}}),ye=V({from:{height:"var(--radix-accordion-content-height)",opacity:1},to:{height:0,opacity:0}}),Q=c.createContext({size:"sm"}),je=b(Ce,{width:"100%",display:"flex",flexDirection:"column"}),Re=b(Ae,{position:"relative",boxSizing:"border-box",width:"100%",backgroundColor:"$surface",border:"1px solid $border",borderBottom:"none",overflow:"hidden","&:first-child":{borderTopLeftRadius:"$sm",borderTopRightRadius:"$sm"},"&:last-child":{borderBottomLeftRadius:"$sm",borderBottomRightRadius:"$sm",borderBottom:"1px solid $border"},"&[data-state=open]":{borderColor:"$borderStrong","&:not(:first-child)":{borderTopColor:"$borderStrong"},"& + &":{borderTopColor:"$borderStrong"}},"&:has(+ [data-state=open])":{borderBottomColor:"$borderStrong"}}),X=b(le,{width:"$iconSm",height:"$iconSm",color:"currentColor",flexShrink:0,transform:"rotate(0deg)",transition:"transform .2s ease, color .2s ease"}),_e=b($e,{all:"unset",display:"block"}),He=b(Se,{all:"unset",display:"flex",width:"100%",minHeight:"30px",padding:"0 $3",alignItems:"center",justifyContent:"space-between",gap:"$2",fontSize:"$2",lineHeight:"$lineHeights$2",fontWeight:500,color:"$text",overflow:"hidden",boxSizing:"border-box",userSelect:"none",backgroundColor:"$grayA2",transition:"$backgroundColor, $borderColor, $color","& > span":{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'&[data-state="open"]':{[`& ${X}`]:{transform:"rotate(90deg)"}},"&:hover":{backgroundColor:"$grayA3",color:"$textStrong"},"&:focus-visible":{outline:"none",boxShadow:"$focus"},variants:{size:{sm:{minHeight:"27px",padding:"0 $2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{minHeight:"30px",padding:"0 $3",fontSize:"$2",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),Pe=b(Ie,{overflow:"hidden",fontSize:"$1",color:"$text",backgroundColor:"$grayA2",'&[data-state="open"]':{animation:`${we} 200ms cubic-bezier(0.16, 1, 0.3, 1)`},'&[data-state="closed"]':{animation:`${ye} 180ms cubic-bezier(0.16, 1, 0.3, 1)`},"@media (prefers-reduced-motion: reduce)":{'&[data-state="open"], &[data-state="closed"]':{animation:"none"}}}),ke=b("div",{color:"$text",borderTop:"1px solid $border",variants:{size:{sm:{padding:"$2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{padding:"$3",fontSize:"$1",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),Ne=function(i){const{size:e="sm",...n}=i;return r.jsx(Q.Provider,{value:{size:e},children:r.jsx(je,{...n})})};function Te(o){const{size:i}=c.useContext(Q),{children:e,title:n,arrow:a=!0,...t}=o;return r.jsxs(Re,{...t,children:[r.jsx(_e,{children:r.jsxs(He,{size:i,children:[r.jsx("span",{children:n}),a&&r.jsx(X,{"aria-hidden":!0})]})}),r.jsx(Pe,{children:r.jsx(ke,{size:i,children:e})})]})}export{Ne as A,Te as a};
1
+ import{b5 as oe,b6 as te,b7 as T,b8 as c,av as r,b9 as D,ba as re,bb as ne,bc as ie,bd as O,be as ae,bf as ce,bg as se,bh as de,bi as V,aH as b,bj as le}from"./index-eeedc550.js";var u="Accordion",pe=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[H,ue,fe]=oe(u),[C,Ee]=te(u,[fe,T]),P=T(),M=c.forwardRef((o,i)=>{const{type:e,...n}=o,a=n,t=n;return r.jsx(H.Provider,{scope:o.__scopeAccordion,children:e==="multiple"?r.jsx(me,{...t,ref:i}):r.jsx(be,{...a,ref:i})})});M.displayName=u;var[B,ge]=C(u),[L,he]=C(u,{collapsible:!1}),be=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},collapsible:t=!1,...s}=o,[d,l]=D({prop:e,defaultProp:n,onChange:a});return r.jsx(B,{scope:o.__scopeAccordion,value:d?[d]:[],onItemOpen:l,onItemClose:c.useCallback(()=>t&&l(""),[t,l]),children:r.jsx(L,{scope:o.__scopeAccordion,collapsible:t,children:r.jsx(K,{...s,ref:i})})})}),me=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},...t}=o,[s=[],d]=D({prop:e,defaultProp:n,onChange:a}),l=c.useCallback(h=>d((f=[])=>[...f,h]),[d]),g=c.useCallback(h=>d((f=[])=>f.filter($=>$!==h)),[d]);return r.jsx(B,{scope:o.__scopeAccordion,value:s,onItemOpen:l,onItemClose:g,children:r.jsx(L,{scope:o.__scopeAccordion,collapsible:!0,children:r.jsx(K,{...t,ref:i})})})}),[xe,A]=C(u),K=c.forwardRef((o,i)=>{const{__scopeAccordion:e,disabled:n,dir:a,orientation:t="vertical",...s}=o,d=c.useRef(null),l=re(d,i),g=ue(e),f=ne(a)==="ltr",$=ie(o.onKeyDown,m=>{var E;if(!pe.includes(m.key))return;const Z=m.target,S=g().filter(R=>{var N;return!((N=R.ref.current)!=null&&N.disabled)}),x=S.findIndex(R=>R.ref.current===Z),z=S.length;if(x===-1)return;m.preventDefault();let p=x;const I=0,w=z-1,y=()=>{p=x+1,p>w&&(p=I)},j=()=>{p=x-1,p<I&&(p=w)};switch(m.key){case"Home":p=I;break;case"End":p=w;break;case"ArrowRight":t==="horizontal"&&(f?y():j());break;case"ArrowDown":t==="vertical"&&y();break;case"ArrowLeft":t==="horizontal"&&(f?j():y());break;case"ArrowUp":t==="vertical"&&j();break}const ee=p%z;(E=S[ee].ref.current)==null||E.focus()});return r.jsx(xe,{scope:e,disabled:n,direction:a,orientation:t,children:r.jsx(H.Slot,{scope:e,children:r.jsx(O.div,{...s,"data-orientation":t,ref:l,onKeyDown:n?void 0:$})})})}),v="AccordionItem",[ve,k]=C(v),U=c.forwardRef((o,i)=>{const{__scopeAccordion:e,value:n,...a}=o,t=A(v,e),s=ge(v,e),d=P(e),l=ae(),g=n&&s.value.includes(n)||!1,h=t.disabled||o.disabled;return r.jsx(ve,{scope:e,open:g,disabled:h,triggerId:l,children:r.jsx(ce,{"data-orientation":t.orientation,"data-state":J(g),...d,...a,ref:i,disabled:h,open:g,onOpenChange:f=>{f?s.onItemOpen(n):s.onItemClose(n)}})})});U.displayName=v;var G="AccordionHeader",W=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(G,e);return r.jsx(O.h3,{"data-orientation":a.orientation,"data-state":J(t.open),"data-disabled":t.disabled?"":void 0,...n,ref:i})});W.displayName=G;var _="AccordionTrigger",Y=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(_,e),s=he(_,e),d=P(e);return r.jsx(H.ItemSlot,{scope:e,children:r.jsx(se,{"aria-disabled":t.open&&!s.collapsible||void 0,"data-orientation":a.orientation,id:t.triggerId,...d,...n,ref:i})})});Y.displayName=_;var q="AccordionContent",F=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(q,e),s=P(e);return r.jsx(de,{role:"region","aria-labelledby":t.triggerId,"data-orientation":a.orientation,...s,...n,ref:i,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...o.style}})});F.displayName=q;function J(o){return o?"open":"closed"}var Ce=M,Ae=U,$e=W,Se=Y,Ie=F;const we=V({from:{height:0,opacity:0},to:{height:"var(--radix-accordion-content-height)",opacity:1}}),ye=V({from:{height:"var(--radix-accordion-content-height)",opacity:1},to:{height:0,opacity:0}}),Q=c.createContext({size:"sm"}),je=b(Ce,{width:"100%",display:"flex",flexDirection:"column"}),Re=b(Ae,{position:"relative",boxSizing:"border-box",width:"100%",backgroundColor:"$surface",border:"1px solid $border",borderBottom:"none",overflow:"hidden","&:first-child":{borderTopLeftRadius:"$sm",borderTopRightRadius:"$sm"},"&:last-child":{borderBottomLeftRadius:"$sm",borderBottomRightRadius:"$sm",borderBottom:"1px solid $border"},"&[data-state=open]":{borderColor:"$borderStrong","&:not(:first-child)":{borderTopColor:"$borderStrong"},"& + &":{borderTopColor:"$borderStrong"}},"&:has(+ [data-state=open])":{borderBottomColor:"$borderStrong"}}),X=b(le,{width:"$iconSm",height:"$iconSm",color:"currentColor",flexShrink:0,transform:"rotate(0deg)",transition:"transform .2s ease, color .2s ease"}),_e=b($e,{all:"unset",display:"block"}),He=b(Se,{all:"unset",display:"flex",width:"100%",minHeight:"30px",padding:"0 $3",alignItems:"center",justifyContent:"space-between",gap:"$2",fontSize:"$2",lineHeight:"$lineHeights$2",fontWeight:500,color:"$text",overflow:"hidden",boxSizing:"border-box",userSelect:"none",backgroundColor:"$grayA2",transition:"$backgroundColor, $borderColor, $color","& > span":{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'&[data-state="open"]':{[`& ${X}`]:{transform:"rotate(90deg)"}},"&:hover":{backgroundColor:"$grayA3",color:"$textStrong"},"&:focus-visible":{outline:"none",boxShadow:"$focus"},variants:{size:{sm:{minHeight:"27px",padding:"0 $2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{minHeight:"30px",padding:"0 $3",fontSize:"$2",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),Pe=b(Ie,{overflow:"hidden",fontSize:"$1",color:"$text",backgroundColor:"$grayA2",'&[data-state="open"]':{animation:`${we} 200ms cubic-bezier(0.16, 1, 0.3, 1)`},'&[data-state="closed"]':{animation:`${ye} 180ms cubic-bezier(0.16, 1, 0.3, 1)`},"@media (prefers-reduced-motion: reduce)":{'&[data-state="open"], &[data-state="closed"]':{animation:"none"}}}),ke=b("div",{color:"$text",borderTop:"1px solid $border",variants:{size:{sm:{padding:"$2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{padding:"$3",fontSize:"$1",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),Ne=function(i){const{size:e="sm",...n}=i;return r.jsx(Q.Provider,{value:{size:e},children:r.jsx(je,{...n})})};function Te(o){const{size:i}=c.useContext(Q),{children:e,title:n,arrow:a=!0,...t}=o;return r.jsxs(Re,{...t,children:[r.jsx(_e,{children:r.jsxs(He,{size:i,children:[r.jsx("span",{children:n}),a&&r.jsx(X,{"aria-hidden":!0})]})}),r.jsx(Pe,{children:r.jsx(ke,{size:i,children:e})})]})}export{Ne as A,Te as a};
@@ -1,4 +1,4 @@
1
- var nt=Object.defineProperty;var ot=(r,t,e)=>t in r?nt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var w=(r,t,e)=>(ot(r,typeof t!="symbol"?t+"":t,e),e);import{dx as T,dy as rt,dz as st,dA as at,dB as it,dC as ct,dD as ut,y as lt,bG as ft,z as ht,j as dt,dE as Z,dF as mt,dG as bt,Z as gt,n as yt,e as pt,dH as kt}from"./index-d497fb6d.js";import{k as wt,H as Bt}from"./ktx2-encoder-772f6c33.js";import"./index-8a22fe59.js";import"./TaskQueue-05c94a4d.js";import"./ktx-parse.modern-6c9f771f.js";class j{static getWorker(t){const e=this.getWorkerCodeByFunctionList(t);if(this._workerCache[e])return this._workerCache[e];const n=this.getWorkerURLByCode(e),o=new Worker(n);return this._workerCache[e]=o,this.registerWorkerEvent(o),o}static registerWorkerEvent(t){t.onmessage=e=>{const n=e.data,{type:o,taskID:a}=n;switch(o){case"calculateSHFromTextureCube":const i=this._callbacks[a],s=n.result;i.resolve(s);break}}}static getURLByWorker(t){for(let e in this._workerCache)if(this._workerCache[e]===t)return e}static getWorkerCodeByFunctionList(t){const e=St.toString(),n=e.substring(e.indexOf("{")+1,e.lastIndexOf("}"));return`
1
+ var nt=Object.defineProperty;var ot=(r,t,e)=>t in r?nt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var w=(r,t,e)=>(ot(r,typeof t!="symbol"?t+"":t,e),e);import{dx as T,dy as rt,dz as st,dA as at,dB as it,dC as ct,dD as ut,y as lt,bG as ft,z as ht,j as dt,dE as Z,dF as mt,dG as bt,Z as gt,n as yt,e as pt,dH as kt}from"./index-eeedc550.js";import{k as wt,H as Bt}from"./ktx2-encoder-2883b55c.js";import"./index-828538e1.js";import"./TaskQueue-05c94a4d.js";import"./ktx-parse.modern-6c9f771f.js";class j{static getWorker(t){const e=this.getWorkerCodeByFunctionList(t);if(this._workerCache[e])return this._workerCache[e];const n=this.getWorkerURLByCode(e),o=new Worker(n);return this._workerCache[e]=o,this.registerWorkerEvent(o),o}static registerWorkerEvent(t){t.onmessage=e=>{const n=e.data,{type:o,taskID:a}=n;switch(o){case"calculateSHFromTextureCube":const i=this._callbacks[a],s=n.result;i.resolve(s);break}}}static getURLByWorker(t){for(let e in this._workerCache)if(this._workerCache[e]===t)return e}static getWorkerCodeByFunctionList(t){const e=St.toString(),n=e.substring(e.indexOf("{")+1,e.lastIndexOf("}"));return`
2
2
  ${t.map(a=>a.toString()).join(`
3
3
  `)}
4
4
  ${n}
@@ -1 +1 @@
1
- var ut=Object.defineProperty;var yt=(_,t,n)=>t in _?ut(_,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):_[t]=n;var g=(_,t,n)=>(yt(_,typeof t!="symbol"?t+"":t,n),n);import{aJ as Z,aL as V,bl as dt,e as j,cp as et,cq as mt,aO as ft,aH as gt,aI as Pt,u as it,S as ot,bV as _t,x as L,aC as E,bp as vt,bs as bt,cr as Ct,cs as Tt,y as wt,ct as Et,bH as At,cu as St,cv as xt,cw as Mt,N as Vt,O as It,cx as Ot,cy as jt,cz as Ft,cA as Rt,cB as Bt,cC as Lt,cD as Dt,cE as $t,cF as Kt,cG as Nt,cH as kt,cI as zt,cJ as Ut,cK as Ht,aE as y,cL as Gt,bO as I,cM as Jt,cN as Qt,cO as Wt,cP as Yt,cQ as qt,cR as Zt,cS as Xt,cT as te,cU as ee,cV as re,cW as ne,j as ae,cX as O,b_ as W,cY as H,c9 as Y,cZ as x,bY as q,c_ as se,c$ as rt,ap as ie,d0 as oe,ac as nt,d1 as B,ai as at,d2 as pe,H as ce,d3 as le,at as he,au as ue,V as ye,F as de,b4 as me,d4 as G,bI as fe,m as ge,aU as Pe,c5 as _e,n as ve,o as be,d5 as Ce}from"./index-d497fb6d.js";import{a as pt,r as st}from"./index-8a22fe59.js";import"./postmen-0413c689.js";import{A as Te}from"./AssetViewer-9f395efb.js";import{e as ct}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{L as we}from"./module-136992e3.js";import{a as Ee}from"./module-1470d524.js";const Ae=Z(()=>{const _=pt("animationClipStore"),{selectedEvent:t}=_,{paramType:n}=t;return V.jsxs("div",{children:[V.jsx(dt,{label:j("animation.clip.param-type.title"),options:[{value:"string",label:String(j("animation.clip.param-type.string"))},{value:"number",label:String(j("animation.clip.param-type.number"))},{value:"null",label:String(j("animation.clip.param-type.null"))}],value:n||"null",onChange:r=>{t.paramType=r,_.updateEvents([t])}}),V.jsx(et,{label:j("animation.clip.function-name"),value:t.functionName,onChange:r=>{t.functionName=r,_.updateEvents([t])}}),n==="number"&&V.jsx(mt,{label:j("animation.clip.number"),value:t.number,onChange:r=>{t.number=r,_.updateEvents([t])}}),n==="string"&&V.jsx(et,{label:j("animation.clip.string"),value:t.string,onChange:r=>{t.string=r,_.updateEvents([t])}})]})}),Se=Z(function(){const t=pt("animationClipStore"),{selectedEvent:n}=t;return n?V.jsx(ft,{title:j("animation.clip.event"),defaultOpen:!0,children:V.jsx(V.Fragment,{children:V.jsx(Ae,{})})}):null});var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,N=(_,t,n,r)=>{for(var e=r>1?void 0:r?Me(t,n):t,a=_.length-1,i;a>=0;a--)(i=_[a])&&(e=(r?i(t,n,e):i(e))||e);return r&&e&&xe(t,n,e),e};const Ve=gt(Pt,{position:"absolute",top:0,left:0,margin:"auto",width:"100%",height:228,alignItems:"center",justifyContent:"center"});class $ extends Te{constructor(){super();g(this,"frameTime",0);g(this,"duration",0);g(this,"playing",!1);g(this,"_clip");g(this,"_updateComponent");g(this,"animationNames");g(this,"overridePreviewer",Z(({asset:n,viewer:r})=>V.jsx(V.Fragment,{children:n.isSubAsset||n.root.sceneUIStore.lastSelectedId?V.jsx(_t,{asset:n,viewer:r}):V.jsx(Ve,{children:V.jsx(V.Fragment,{children:j("animation.clip.select-entity-preview")})})})));it(this)}selectAnimation(n){}async setViewAsset(n,r){var i,s;let e;if(n.isSubAsset){const o=await n.root.assetStore.getAssetByRef({refId:n.mainId}),{defaultSceneRoot:c}=o.engineObject;e=((i=n.root.sceneStore.lastSelectedEntity)==null?void 0:i.engineObject)||c}else e=(s=n.root.sceneStore.lastSelectedEntity)==null?void 0:s.engineObject;if(!e)return;this._clip=n.engineObject,this.animationNames=[n.name],this._entity=e.clone(),r.addChild(this._entity);const a=this;this._updateComponent=this._entity.addComponent(class extends ot{onUpdate(o){a._onUpdate(100/3)}}),this.frameTime=0,this.duration=this._clip.length}stopViewAsset(){var n;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(n=this._updateComponent)==null||n.destroy()}setFrameTime(n){this.frameTime=n,this._sampleAnimation()}playAnimation(){this._clip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(n){!this.playing||!this._clip||!this.duration||(this.frameTime+=n/1e3,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this._clip._sampleAnimation(this._entity,this.frameTime)}catch(n){console.warn(n)}}}N([L],$.prototype,"frameTime",2);N([L],$.prototype,"duration",2);N([L],$.prototype,"playing",2);N([E],$.prototype,"setViewAsset",1);N([E],$.prototype,"setFrameTime",1);N([E],$.prototype,"playAnimation",1);N([E],$.prototype,"pauseAnimation",1);N([E],$.prototype,"_onUpdate",1);const K=new Map([[vt,"Transform"],[bt,"Animator"],[Ct,"DirectLight"],[Tt,"Camera"],[wt,"MeshRenderer"],[Et,"SkinnedMeshRenderer"],[At,"ParticleRenderer"],[St,"PointLight"],[xt,"SpotLight"],[ot,"Script"],[Mt,"SpriteMask"],[Vt,"SpriteRenderer"],[It,"TextRenderer"],[Ot,"UITransform"],[jt,"UICanvas"],[Ft,"UIGroup"],[Rt,"Button"],[Bt,"Image"],[Lt,"Text"],[Dt,"DynamicCollider"],[$t,"StaticCollider"],[Kt,"CharacterController"],[Nt,"SpringJoint"],[kt,"FixedJoint"],[zt,"HingeJoint"],[Ut,"AudioSource"],[Ht,"PostProcess"],[Ee,"SpineAnimationRenderer"],[we,"LottieAnimation"]]);var Ie=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,T=(_,t,n,r)=>{for(var e=r>1?void 0:r?Oe(t,n):t,a=_.length-1,i;a>=0;a--)(i=_[a])&&(e=(r?i(t,n,e):i(e))||e);return r&&e&&Ie(t,n,e),e};const X=new Map([[y.Float,{curveClass:Gt,name:"AnimationFloatCurve",defaultInterpolation:I.Hermite}],[y.FloatArray,{curveClass:Jt,name:"AnimationFloatArrayCurve",defaultInterpolation:I.Hermite}],[y.Vector2,{curveClass:Qt,name:"AnimationVector2Curve",defaultInterpolation:I.Hermite}],[y.Vector3,{curveClass:Wt,name:"AnimationVector3Curve",defaultInterpolation:I.Hermite}],[y.Vector4,{curveClass:Yt,name:"AnimationVector4Curve",defaultInterpolation:I.Hermite}],[y.Quaternion,{curveClass:qt,name:"AnimationQuaternionCurve",defaultInterpolation:I.Hermite}],[y.Color,{curveClass:Zt,name:"AnimationColorCurve",defaultInterpolation:I.Hermite}],[y.ReferResource,{curveClass:Xt,name:"AnimationRefCurve",defaultInterpolation:I.Step}],[y.Rect,{curveClass:te,name:"AnimationRectCurve",defaultInterpolation:I.Step}],[y.Boolean,{curveClass:ee,name:"AnimationBoolCurve",defaultInterpolation:I.Step}],[y.String,{curveClass:re,name:"AnimationStringCurve",defaultInterpolation:I.Step}],[y.Array,{curveClass:ne,name:"AnimationArrayCurve",defaultInterpolation:I.Hermite}]]),lt=new Map;X.forEach((_,t)=>{lt.set(_.curveClass,t)});const ht=new Map;X.forEach(_=>{ht.set(_.curveClass,_.name)});let C=class extends ae{constructor(t){super(t);g(this,"samples",60);g(this,"properties",[]);g(this,"pathPropertyMap",new Map);g(this,"keyframeDataList",[]);g(this,"events",{});g(this,"data");g(this,"selectedEventId");g(this,"rootEntityId");g(this,"showEditor");g(this,"readOnly",!1);g(this,"_propertyCurveMap",{});g(this,"_originValueStore",new Map);g(this,"_initKeyframeDataPromise");g(this,"_parseKeyframeValuePromise");g(this,"_colorList",["#3477FA","#67FEBB","#C201BF","#F6ED17","#FE6C02","#FD86C2","#A2B44B","#68D8F0","#008225","#A56A02"]);g(this,"_colorIndex",0);g(this,"_openIndex",0);g(this,"_componentsChangedListenerDisposer");g(this,"_propertyPathCache",new Map);g(this,"_propertyLabelMap",new Map);g(this,"_editorPathCache",new Map);it(this),this.onDoubleClick=this.onDoubleClick.bind(this)}get rootEntity(){return this.root.sceneStore.getEntityModel(this.rootEntityId)}get addedPropertiesTreeData(){return this.properties.map(t=>this._convertPropertyToTreeItem(t))}persistMainViaFacade(){this.root.assetFacade.persistAssetMain(this.id)}persistMetaViaFacade(){this.root.assetFacade.persistAssetMeta(this.id)}addProperty(t){const{type:n,parentProperty:r}=t,e=B(t),a=this.pathPropertyMap.get(e),i=this.properties;let s;if(a)W.error(j("animation.clip.error.property-existed"));else{if(n===O.Property)s=this._addPropertyToList(i,t,null);else{const o=i.find(c=>c.propertyPath===r.propertyPath&&c.relativePath===r.relativePath&&c.componentType===r.componentType);if(o)o.properties.find(p=>p.path===e)?W.error(j("animation.clip.error.sub-property-existed")):s=this._addPropertyToList(o.properties,t,o);else{const c=this._addPropertyToList(i,r,null,!1);s=this._addPropertyToList(c.properties,t,c)}}return this._sortProperties(),this.properties=i.slice(0),this._updateCurveBindings(),this.persistMetaViaFacade(),this.persistMainViaFacade(),s}}delProperty(t){const n=new Set;t.forEach(r=>{if(n.add(r.path),this.pathPropertyMap.delete(r.path),r.type===O.Property)r.properties.forEach(e=>{n.add(e.path),this.pathPropertyMap.delete(e.path)}),this._delPropertyFromList(this.properties,r);else{const e=this.properties.find(a=>a.path===r.parentPath);e&&(this._delPropertyFromList(e.properties,r),e.hasSubProperty&&!e.properties.length&&this._delPropertyFromList(this.properties,e))}}),this._sortProperties(),this.properties=this.properties.slice(0),this._removeCurveBindings(n),this._updateCurveBindings(),this.updateKeyframes(this.keyframeDataList.filter(r=>!n.has(r.path))),this.persistMetaViaFacade(),this.persistMainViaFacade()}async addKeyframe(t,n){const{rootEntity:r}=this,e=this.pathPropertyMap.get(n),{type:a,path:i,parentPath:s,properties:o,supported:c}=e;if(!c){W.error(j("animation.clip.error.property-not-supported"));return}const p=a===O.SubProperty?this.pathPropertyMap.get(s):null,{editorReference:h,editorPropertyPath:u,propertyPos:d}=await this._getReferenceAndActualPropertyPath(r,e),l=u[d],m=H(h)[l];let f=h[l];m!=null&&m.getActualEditorValue&&(f=m.getActualEditorValue(f));let A=e.valueType;a===O.Property&&(m!=null&&m.valueType)&&(A=m.valueType),a===O.SubProperty&&(f=f[u[d+1]]);const P=Y(f);if(o.length)o.forEach(b=>{const{path:v}=b,w=P[b.name],S=this.keyframeDataList.find(M=>M.path===v&&M.frame===t);if(S)S.value=w,S.inTangentMode=x.Linear,S.outTangentMode=x.Linear;else{const M=this._createKeyframeData(t,w,b.valueType,void 0,void 0,b,e);this.keyframeDataList.push(M)}});else{const b=this.keyframeDataList.find(v=>v.path===i&&v.frame===t);if(b)b.value=P,b.inTangent=void 0,b.outTangent=void 0;else{const v=this._createKeyframeData(t,P,A,void 0,void 0,e,a===O.SubProperty?p:null);this.keyframeDataList.push(v)}}this.updateKeyframes(this.keyframeDataList)}addKeyframeByRecording(t,n){const r=this._ensurePropertyExists(n);r&&this.addKeyframe(t,r.path)}deleteKeyframes(t){t.forEach(n=>{const r=this.keyframeDataList.indexOf(n);r>-1&&this.keyframeDataList.splice(r,1)}),this.updateKeyframes(this.keyframeDataList)}updateKeyframes(t,n=!0){const r={};t.length&&t.sort((e,a)=>e.frame-a.frame),t.forEach(e=>{const a=e.path;r[a]??(r[a]=[]),r[a].push(e),r[a].sort((i,s)=>i.frame-s.frame)});for(const e in r)for(let a=0,i=r[e].length;a<i;++a){const s=r[e][a];if(s.interpolationType===I.Step)continue;const o=r[e][a-1],c=r[e][a+1];s.isFirst=a===0,s.isLast=a===i-1,a>0&&(s.frame-o.frame===0?s.linearInTangent=0:s.linearInTangent=(s.value-o.value)/((s.frame-o.frame)/this.samples),s.inTangent=s.inTangentMode===x.Linear?s.linearInTangent:s.inTangent,isNaN(s.inTangent)&&(s.inTangent=-1/0)),a<i-1&&(c.frame-s.frame===0?s.linearOutTangent=0:s.linearOutTangent=(c.value-s.value)/((c.frame-s.frame)/this.samples),s.outTangent=s.outTangentMode===x.Linear?s.linearOutTangent:s.outTangent,isNaN(s.outTangent)&&(s.outTangent=-1/0))}this.keyframeDataList=t.slice(0),this.isSubAsset||(this._generateEngineKeyframes(t),n&&this.persistMainViaFacade())}addEvent(t){const n={id:q(),time:t/this.samples,functionName:"onEvent"};this.events[n.id]=n,this.updateEvents(this.events)}deleteEvent(t){delete this.events[t.id],this.updateEvents(this.events)}updateEvents(t,n=!0){const r=this.engineObject;if(this.events={...t},r.clearEvents(),Object.values(this.events).map(e=>{const a=e.paramType==="string"?e.string:e.number;r.addEvent(e.functionName,e.time,a)}),this.data.events=Object.values(this.events).map(e=>({time:e.time,functionName:e.functionName,parameter:e.paramType==="string"?e.string:e.number})),n){const{isSubAsset:e}=this;if(e){const a=this.root.assetStore.getAsset(this.mainId);if(a){const i=a.engineObject.animations.indexOf(this._engineObject);a.updateAnimationEvents(i,this.data.events)}}this.persistMainViaFacade()}}updateSamples(t){this.samples=+t.toFixed(0)}updateRootEntity(t){if(!(!t||t.id===this.rootEntityId)){if(this.rootEntityId=t.id,this.engineObject){this._clearPropertyMappings();const n=this._init().then(async()=>{await this._generateKeyframeDataList(),await this._updateCurveBindings(),this.showEditor&&(await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}).catch(r=>{console.warn("AnimationClipAsset:updateRootEntity rebuild failed",this.name,r)});this._initKeyframeDataPromise=n}this._listenRootEntityChanged(),this.persistMetaViaFacade()}}setTangentMode(t,n,r){t.forEach(e=>{if(n===se.In)switch(e.inTangentMode=r,r){case x.Linear:e.inTangent=e.linearInTangent;break;case x.Constant:e.inTangent=-1/0;break;case x.Free:break}else switch(e.outTangentMode=r,r){case x.Linear:e.outTangent=e.linearOutTangent;break;case x.Constant:e.outTangent=-1/0;break;case x.Free:break}}),this.persistMetaViaFacade(),this.updateKeyframes(this.keyframeDataList)}async checkPropertiesSupport(t){const{properties:n}=this;let r=!1;const e=n.map(async a=>{const i=!!a.supported,{editorReference:s}=await this._getReferenceAndActualPropertyPath(t,a);s?a.supported=!0:a.supported=!1,!i&&a.supported&&(r=!0)});await Promise.all(e),r&&(this.properties=this.properties.slice(0),await this._generateKeyframeDataList(),this.updateKeyframes(this.keyframeDataList,!1),await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}updateSelectedEvent(t){this.selectedEventId=t}async openEditor(t){if(t&&!this.showEditor){this._initKeyframeDataPromise||(this._initKeyframeDataPromise=this._generateKeyframeDataList()),this.showEditor=t,this.root.projectStore.animationEditing=t;const n=++this._openIndex;if(await this._initKeyframeDataPromise,n!==this._openIndex)return;this.saveEditorOriginValue(),this.sampleAnimation(this.root.animationClipStore.currentFrame),rt()}!t&&this.showEditor&&(this.showEditor=t,this.root.projectStore.animationEditing=t,this.revertValue())}async sampleAnimation(t){const n=this.rootEntity;if(n){const r=n.engineObject;try{await this._parseKeyframeValuePromise,this.engineObject._sampleAnimation(r,t/this.samples),this._syncToEditor()}catch(e){console.warn(e)}}}async saveEditorOriginValue(){const{_originValueStore:t}=this,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:i,property:s}=e,o=K.get(i),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:o,propertyPath:s});if(!c)return;const u=p[h];if(!t.has(e)){let d=u;u==="rotationQuaternion"&&(d="rotation"),t.set(e,Y(c[d]))}});await Promise.all(r)}async revertValue(){const{_originValueStore:t}=this,n=Array.from(t).map(async([r,e])=>{const{relativePath:a,type:i,property:s}=r,o=K.get(i),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:o,propertyPath:s});if(!c)return;const u=p[h];let d=u;u==="rotationQuaternion"&&(d="rotation"),this._setEditorValue(c,d,e)});await Promise.all(n),t.clear()}async initByMain(t){const{engine:n,meta:r}=this;r.rootEntityId&&(this.rootEntityId=r.rootEntityId),this._listenRootEntityChanged();try{const e=JSON.parse(await t.text()),a=ct(e,{type:"AnimationClip",name:e.name}),i=await ie(a,n);this.bindEngineObject(i),await this._init()}catch(e){console.error(`[AnimationClipAsset] Failed to load "${this.name}"`,e)}}async initByEngineObject(t){this.bindEngineObject(t),this._name=t.name,await this._init()}async initByCreation(t,n){this.setNameByIncrease(n||"AnimationClip");const r=new oe(this.name);return this.bindEngineObject(r),this.data={name:this.name,curveBindings:r.curveBindings,events:[]},await this._init(),this.getMainData()}_clearPropertyMappings(){this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyPathCache.clear(),this._propertyLabelMap.clear(),this._editorPathCache.clear(),this.properties.length=0,this._colorIndex=0,this._originValueStore.clear()}_sortProperties(){this.properties.sort((t,n)=>(t.level??0)-(n.level??0))}async _init(){const t=this.engineObject;this._clearPropertyMappings();const r=(await this._groupCurveBindingsByParent(t.curveBindings)).map(async a=>{if(await this._generatePropertiesFromBindingGroup(a),this.isSubAsset)return Promise.resolve();const i=a.bindings.flatMap(s=>{const{curve:o}=s;return o.keys.map(c=>this._editorValueToEngineValue(c.value,this._getValueTypeByCurve(o)).then(p=>{c.value=p}))});return Promise.all(i)});if(!this.isSubAsset){const{properties:a,pathPropertyMap:i}=this;a.forEach(s=>{s.properties.length||this._colorIndex++,i.set(s.path,s),s.properties.forEach(o=>{this._colorIndex++,i.set(o.path,o)})})}await Promise.all(r),this._sortProperties();const e={};t.events.forEach(a=>{const i=q(),s=a.parameter?typeof a.parameter:"null";e[i]={id:i,time:a.time,functionName:a.functionName,paramType:s,string:s==="string"?a.parameter:void 0,number:s==="number"?a.parameter:void 0}}),this.data={name:t.name,curveBindings:t.curveBindings,events:[]},this.updateEvents(e,!1)}async onDoubleClick(){st.layoutStore.toggleTabVisibility("AnimationClip"),st.layoutStore.activeTab("AnimationClip"),rt()}getMainData(){const t=this.data,n={...t,curveBindings:t.curveBindings.map(r=>{const{curve:e}=r,a=ht.get(e.constructor);return{...r,type:K.get(r.type)||r.type,curveType:a,curve:{interpolation:e.interpolation,keys:e.keys.map(i=>{const s=i.value,o=s instanceof nt?this.root.assetStore.engineObjectToAssetMap.get(s).getCurrentRef():s;return{...i,value:Y(o)}})}}})};return JSON.stringify(n)}async _syncToEditor(){const t=this.rootEntity,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:i,property:s,getProperty:o}=e,c=K.get(i);if(!e.curve.keys.length)return;const p=await this._getActualPropertyPath(o??s,a,c),{editorReference:h,engineGetReference:u,editorPropertyPath:d,enginePropertyGetPath:l,propertyPos:m}=await this._getReferenceAndActualPropertyPath(t,{relativePath:a,componentType:c,propertyPath:p});if(!u||!h)return;const f=B({relativePath:a,componentType:c,propertyPath:d.slice(0,m+1).join(".")}),A=this.pathPropertyMap.get(f);let P=d[m],b=this._getEngineValue(u,l[m]),v=A.valueType;P==="rotationQuaternion"&&(P="rotation",b=b.toEuler(new at).scale(180/Math.PI),v=y.Vector3);const w=this._engineValueToEditorValue(b,v,!1);this._setEditorValue(h,P,w)});await Promise.all(r)}async _setEditorValue(t,n,r){var i,s;const e=(i=pe(t))==null?void 0:i[n],a=(s=H(t))==null?void 0:s[n];if(a!=null&&a.getEditorValue&&(r=a.getEditorValue(r)),a!=null&&a.setActualEditorValue?a==null||a.setActualEditorValue(t,n,r):t[n]=r,e!=null&&e.onChange){const o=r!=null&&r.refId?await t.root.assetStore.getAssetByRef(r):r;await e.onChange(t,n,o)}}_removeCurveBindings(t){const n=this.engineObject;if(!n)return;const r=new Set;for(const e of t){const a=this._propertyCurveMap[e];a&&(r.add(a),delete this._propertyCurveMap[e])}if(r.size>0){const e=n.curveBindings;for(let a=e.length-1;a>=0;a--){const i=e[a];r.has(i.curve)&&(e.splice(a,1),this._originValueStore.delete(i))}}}async _updateCurveBindings(){var n;const t=this.rootEntity;if(t)for(const r of this.properties)try{const{relativePath:e,componentType:a,valueType:i,properties:s,interpolationType:o}=r,c=B(r),p=await this._getReferenceAndActualPropertyPath(t,r),{editorReference:h,enginePropertySetPath:u,enginePropertyGetPath:d,editorPropertyPath:l,propertyPos:m}=p||{};if(!h||!u||!d||m===void 0)continue;const f=l[m],A=(n=H(h))==null?void 0:n[f],P=u.join("."),b=d.join(".");if(s.length)for(const v of s){const w=B(v),S=this._createCurve(w,v.valueType,v.interpolationType),M=v.name;await this._addCurveBinding(e,a,`${P}.${M}`,`${b}.${M}`,S),this._propertyCurveMap[w]=S}else{let v=i;A!=null&&A.valueType&&(v=A.valueType);const w=this._createCurve(c,v,o);await this._addCurveBinding(e,a,P,b,w),this._propertyCurveMap[c]=w}}catch(e){console.warn("updateCurveBindings skipped property (unresolved):",r==null?void 0:r.propertyPath,e);continue}}_createCurve(t,n,r){let e=this._propertyCurveMap[t];if(!e){const a=X.get(n);a?(e=new a.curveClass,e.interpolation=r??a.defaultInterpolation):console.warn(`Unsupported curve value type: ${n}`)}return e}async _addCurveBinding(t,n,r,e,a){const i=ce.getClass(n),s=this.engineObject;let o=!0;for(let c=0,p=s.curveBindings.length;c<p;++c){const h=s.curveBindings[c];h.relativePath===t&&h.type===i&&h.property===r&&h.getProperty===e&&(h.curve=a,o=!1)}o&&(s.addCurveBinding(t,i,r,e,a),await this.saveEditorOriginValue())}_addPropertyToList(t,n,r,e=!0){var o;const a=this._covertToPropertyData(n,r),i=t.push(a),s=t[i-1];return this.pathPropertyMap.set(s.path,s),e&&((o=n.children)!=null&&o.length)&&n.children.forEach(c=>{this._addPropertyToList(s.properties,c,s,e)}),s}_delPropertyFromList(t,n){const r=t.findIndex(e=>e.path===n.path);r>-1&&(t.splice(r,1),this.pathPropertyMap.delete(n.path))}_covertToPropertyData(t,n){const{name:r,label:e,relativePath:a,componentType:i,propertyPath:s,type:o,valueType:c,interpolationType:p,children:h}=t,u=B(t),d=B(n),l=a.split("/").length-1;return{name:e||r,level:l,path:u,type:o,valueType:c,interpolationType:p,propertyPath:s,componentType:i,relativePath:a,hasSubProperty:h.length>0,curveColor:c===y.Float?this._getRandomColor():null,supported:!0,properties:[],parentPath:d}}async _getReferenceAndActualPropertyPath(t,n){if(!t)return{};const{relativePath:r,componentType:e,propertyPath:a}=n,i=t.findByPath(r);if(!i)return{};const s=i.getComponentByTypeName(e);if(!s)return{};const o=[],c=[],p=[],h=a.split("."),u=h.length-1;let d=-1,l=s;for(let P=0,b=u;P<=b;++P){const v=h[P];if(!l)return{};const w=H(l);let S="",M=v,k=v,z=v,R=P;for(let F=P,J=u;F<=J;++F){S+=h[F];const Q=(w==null?void 0:w[S])||{},{getPath:U,setPath:D,editorKey:tt}=Q;D&&(k=D,R=F),(U||D)&&(F===u&&D?k=D:k=U??D,z=U??D,R=F),tt&&(M=tt,R=F),F<u&&(S+=".")}P=R,c.push(k),p.push(z),o.push(M),le(l,M)&&(d=o.length-1),P<u&&(l=l[M],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l)))}const m=d>-1?d-1:o.length-1;l=s;for(let P=0,b=m;P<b;++P)l=l[o[P]],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l));const f=this._getEngineValue(s.engineObject,c.slice(0,m).join(".")),A=this._getEngineValue(s.engineObject,p.slice(0,m).join("."));return{editorReference:l,engineSetReference:f,engineGetReference:A,enginePropertySetPath:c,enginePropertyGetPath:p,editorPropertyPath:o,propertyPos:m,subPropertyPos:d}}_getEngineValue(t,n){if(!n)return t;let r=t;const e=n.split(".");for(let a=0,i=e.length;a<i;a++){const s=e[a];if(s.indexOf("[")>-1){const o=s.indexOf("[");r=r[s.slice(0,o)],r=r[parseInt(s.slice(o+1,-1))]}else if(s.endsWith(")")){const o=s.slice(0,s.indexOf("(")),c=s.match(/\w+\(([^)]*)\)/)[1].split(",").map(p=>p.trim().replace(/['"]+/g,"")).filter(p=>p!=="");r=r[o](...c)}else r=r[s]}return r}async _generateKeyframeDataList(){const t=this.engineObject,n=[],r=this.pathPropertyMap,e=t.curveBindings.map(async a=>{const{relativePath:i,type:s,getProperty:o,property:c,curve:p}=a,h=K.get(s),u=o??c,d=await this._convertPropertyProxyPath(u,h,i),m=B({relativePath:i,componentType:h,propertyPath:d||u});d||console.warn(`无法转换引擎路径到编辑器路径: ${u},使用原路径`);const f=r.get(m);if(!f){d&&console.warn(`转换后的路径仍未找到属性定义: ${m}, 原引擎路径: ${u}`);return}this._propertyCurveMap[m]=p;const A=f.valueType;p.keys.forEach(P=>{const{time:b,value:v,inTangent:w,outTangent:S}=P,M=Math.floor(b*this.samples),k=this._engineValueToEditorValue(v,A,!0),z=this._getSubProperties(A,p);if(z)z.forEach(R=>{const F=`${m}.${R}`,J=r.get(F),Q=w&&w[R],U=S&&S[R],D=this._createKeyframeData(M,k[R],y.Float,Q,U,J,f);n.push(D)});else{const R=r.get(f.parentPath),F=this._createKeyframeData(M,k,A,w,S,f,R);n.push(F)}})});await Promise.all(e),this.updateKeyframes(n,!1)}_createKeyframeData(t,n,r,e,a,i,s){const{path:o,curveColor:c}=i,{path:p=""}=s||{};return{id:q(),frame:t,path:o,value:n,isActive:!0,valueType:r??y.Float,curveColor:c,parentPath:p,inTangent:e,outTangent:a,interpolationType:i.interpolationType,inTangentMode:e===void 0?x.Linear:e===-1/0?x.Constant:x.Free,outTangentMode:a===void 0?x.Linear:a===-1/0?x.Constant:x.Free}}_generateEngineKeyframes(t){const{_propertyCurveMap:n,samples:r,engineObject:e}=this,a=this._groupKeyframesByPath(t),s=this._collectPathsToSync(n,a).map(o=>this._syncCurveForPath(o,n[o],a.get(o)||[],r,e));this._parseKeyframeValuePromise=Promise.all(s)}_groupKeyframesByPath(t){return t.reduce((n,r)=>{const e=n.get(r.path)||[];return e.push(r),n.set(r.path,e),n},new Map)}_collectPathsToSync(t,n){const r=new Set;return Object.keys(t).forEach(e=>r.add(e)),n.forEach((e,a)=>r.add(a)),Array.from(r)}async _syncCurveForPath(t,n,r,e,a){if(!n)return;const i=await this._convertToEngineKeyframes(r,e);this._removeObsoleteKeyframes(n,i),this._addOrUpdateKeyframes(n,i,a)}async _convertToEngineKeyframes(t,n){const r=new Map;for(const e of t){const a=e.frame/n,i=await this._editorValueToEngineValue(e.value,e.valueType);i===void 0&&e.valueType===y.ReferResource||r.set(a,{value:i,inTangent:e.inTangent,outTangent:e.outTangent})}return r}_removeObsoleteKeyframes(t,n){const r=new Set(n.keys());for(let e=t.keys.length-1;e>=0;e--){const a=t.keys[e];r.has(a.time)||t.keys.splice(e,1)}}_addOrUpdateKeyframes(t,n,r){const e=new Map;t.keys.forEach(a=>{e.set(a.time,a)});for(const[a,{value:i,inTangent:s,outTangent:o}]of n){const c=e.get(a);if(c)c.value=i,c.inTangent=s,c.outTangent=o;else{const p=new Ce;p.time=a,p.value=i,p.inTangent=s,p.outTangent=o,t.addKey(p)}a>r._length&&(r._length=a)}}async _editorValueToEngineValue(t,n){var r;switch(n){case y.ReferResource:return t!=null&&t.refId?(r=await this.root.assetStore.getAssetByRef(t))==null?void 0:r.engineObject:t;case y.Color:return new me(t.r,t.g,t.b,t.a);case y.Vector2:return new de(t.x,t.y);case y.Vector3:return new at(t.x,t.y,t.z);case y.Vector4:return new ye(t.x,t.y,t.z,t.w);case y.Quaternion:return new ue(t.x,t.y,t.z,t.w);case y.Rect:return new he(t.x,t.y,t.width,t.height);case y.Float:return t;default:return t}}_engineValueToEditorValue(t,n,r){var a,i,s;let e;switch(n){case y.MethodParam:{if(e=[],r)for(let o=0,c=t.length;o<c;o++){const p=t[o];e[o]??(e[o]=[]);for(let h=0,u=p.length;h<u;h++){const d=p[h];e[o][h]=((a=this.root.assetStore.engineObjectToAssetMap.get(d))==null?void 0:a.getCurrentRef())??d}}else t&&t instanceof nt?e=[[((i=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:i.getCurrentRef())??t]]:t instanceof Array?e=t:e=[[t]];break}case y.ReferResource:{e=(s=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:s.getCurrentRef();break}case y.Color:{e={r:t.r,g:t.g,b:t.b,a:t.a},["r","g","b","a"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Vector2:{e={x:t.x,y:t.y},["x","y"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Vector3:{e={x:t.x,y:t.y,z:t.z},["x","y","z"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Vector4:case y.Quaternion:{e={x:t.x,y:t.y,z:t.z,w:t.w},["x","y","z","w"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Rect:{e={x:t.x,y:t.y,width:t.width,height:t.height},["x","y","width","height"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Float:{e=Math.round(t*1e3)/1e3;break}default:e=t}return e}_getValueTypeByCurve(t){return lt.get(t.constructor)}_parsePropertyPath(t){const n=this._propertyPathCache.get(t);if(n)return n;const r=t.lastIndexOf("."),e=r===-1?{parentPath:t,subProperty:null}:{parentPath:t.substring(0,r),subProperty:t.substring(r+1)};return this._propertyPathCache.set(t,e),e}_isSubPropertyName(t){return/^([xyzw]|[rgba]|width|height)$/.test(t)}async _convertPropertyProxyPath(t,n,r){try{const e=this._resolveProxyHost(n,r,t);if(!e)return null;const a=`${r}|${n}|${t}`;if(this._editorPathCache.has(a))return this._editorPathCache.get(a);const i=await this._recursiveConvert(t,e,0);return i&&i!==t&&await this._buildLabelMappingsForPath(i,r,n,e),this._editorPathCache.set(a,i??null),i}catch{const a=`${r}|${n}|${t}`;return this._editorPathCache.set(a,null),null}}async _buildLabelMappingsForPath(t,n,r,e){try{const a=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t}),i=(a==null?void 0:a.editorPropertyPath)||t.split("."),s=typeof(a==null?void 0:a.propertyPos)=="number"?a.propertyPos:i.length-1;for(let o=0;o<=s;o++){const c=i.slice(0,o+1).join("."),p=B({relativePath:n,componentType:r,propertyPath:c});if(!this._propertyLabelMap.has(p)){const h=await this._extractLabelForPartialPath(c,e);h&&this._propertyLabelMap.set(p,h)}}}catch(a){console.warn("建立标签映射失败:",a)}}async _extractLabelForPartialPath(t,n){try{const r=t.split("."),e=r[r.length-1];let a=n,i=null;for(let s=0;s<r.length;s++){const o=r[s],c=a==null?void 0:a[G];if(c&&c[o]){const p=c[o];p.label&&(i=p.label),s<r.length-1&&(a=await this._getNextObject(a,o))}else break}return i||e}catch{return t.split(".").pop()||t}}async _recursiveConvert(t,n,r){if(r>6)return t;const e=n[G];if(!e)return t;for(const[a,i]of Object.entries(e)){if(!this._isPathMatch(t,i))continue;const s=i.getPath||i.setPath;if(s){if(s.endsWith("()")&&t.startsWith(s+".")){const o=t.substring(s.length+1),c=await this._getNextObject(n,a);if(!c)return`${a}.${o}`;const p=await this._recursiveConvert(o,c,r+1);return p?`${a}.${p}`:`${a}.${o}`}return this._buildEditorPath(a,t,i)}}return t}async _getNextObject(t,n){var r;try{let e=t[n];if(!e){const a=`get${n.charAt(0).toUpperCase()+n.slice(1)}`;typeof t[a]=="function"&&(e=t[a]())}if(e!=null&&e.refId&&((r=this.root)!=null&&r.assetStore)){let a=this.root.assetStore.engineObjectToAssetMap.get(e);if(!a)try{a=await this.root.assetStore.getAssetByRef(e)}catch{return e}if(a)return a}return e}catch{return null}}_resolveProxyHost(t,n,r){try{if(!this.rootEntity)return null;const e=n?this.rootEntity.findByPath(n):this.rootEntity;if(!e)return null;const a=e.getComponentByTypeName(t);return a?r?this._resolvePropertyProxyHolder(a,r):a:null}catch(e){return console.warn(`获取代理宿主失败: ${t}, ${n}`,r,e),null}}_resolvePropertyProxyHolder(t,n){try{const r=[t];this._addRelatedObjectCandidates(t,r);for(const e of r)if(this._hasMatchingProxyConfig(e,n))return e;return t}catch(r){return console.warn(`解析 PropertyProxy 持有者失败: ${n}`,r),t}}_addRelatedObjectCandidates(t,n){try{const r=t[G];if(!r)return;const e=new Set;for(const a of Object.values(r)){const i=this._extractObjectPathFromConfig(a);i&&e.add(i)}for(const a of e){const i=this._getEngineValue(t.engineObject,a);if(i){const s=this.root.assetStore.engineObjectToAssetMap.get(i);s&&!n.includes(s)&&n.push(s)}}}catch{}}_extractObjectPathFromConfig(t){const n=t.getPath||t.setPath;if(!n)return null;const r=n.match(/^([^.]+\([^)]*\))/);return r?r[1]:null}_hasMatchingProxyConfig(t,n){const r=t[G];if(!r)return!1;for(const e of Object.values(r))if(this._isPathMatch(n,e))return!0;return!1}_isPathMatch(t,n){return n?n.getPath&&this._isExactPathMatch(t,n.getPath)||n.setPath&&this._isExactPathMatch(t,n.setPath)||n.engineKey&&t.includes(n.engineKey):!1}_isExactPathMatch(t,n){if(!n)return!1;const r=p=>p.replace(/['"`\s]/g,""),e=p=>{let h="";for(let u=0;u<p.length;u++){const d=p[u];if(d==="("){for(;u<p.length&&p[u]!==")";)u++;h+="()"}else h+=d}return h},a=p=>e(r(p).replace(/\$value/g,"value")),i=a(t),s=a(n);if(i===s||((p,h)=>p.startsWith(h+".")||p.startsWith(h+"["))(i,s))return!0;if(!n.includes(".")&&!n.includes("(")&&!n.includes("[")){const p=i.split(".");for(const h of p){const u=h.indexOf("[");if((u>=0?h.slice(0,u):h)===s)return!0}}return!1}_buildEditorPath(t,n,r){if(!r)return t;const e=r.getPath||r.setPath;if(!e)return t;if(e.endsWith("()")&&n.startsWith(e+".")){const s=n.substring(e.length+1);return`${t}.${s}`}const a=n.replace(/['"`]/g,"").replace(/\$value/g,"value"),i=e.replace(/['"`]/g,"").replace(/\$value/g,"value");if(a.includes(i))return a.replace(i,t);if(!e.includes(".")&&!e.includes("(")){const s=n.match(/\.([a-zA-Z_]\w*)$/);if(s){const o=s[1];if(o!==e)return`${t}.${o}`}}return t}_validateCurveBinding(t){const{relativePath:n,type:r,getProperty:e,property:a}=t;return K.get(r)?e??a?!0:(console.warn(`绑定缺少属性路径: ${n}`),!1):(console.warn(`未知组件类型: ${r},跳过绑定`),!1)}async _groupCurveBindingsByParent(t){const n=new Map;return await Promise.all(t.map(async r=>{if(!this._validateCurveBinding(r))return;const{relativePath:e,type:a,getProperty:i,property:s}=r,o=K.get(a),c=i??s,h=await this._convertPropertyProxyPath(c,o,e)||c,u=this._parsePropertyPath(h),d=u.subProperty&&this._isSubPropertyName(u.subProperty);let l,m;d&&u.subProperty?(m=u.parentPath,l=`${e}.${o}.${m}`):(m=h,l=`${e}.${o}.${h}`),n.has(l)||n.set(l,{parentPath:m,relativePath:e,componentType:o,bindings:[]}),n.get(l).bindings.push(r)})),Array.from(n.values())}_validateAndGetParentValueType(t){if(t.length===1){const l=t[0],m=l.getProperty??l.property,{subProperty:f}=this._parsePropertyPath(m);return!f||!this._isSubPropertyName(f)?null:y.Float}if(!t.every(l=>this._getValueTypeByCurve(l.curve)===y.Float)){const l=t.map(m=>this._getValueTypeByCurve(m.curve));return console.warn(`分组中的绑定类型不一致: ${l.join(", ")},无法创建父属性`),null}const r=t.map(l=>l.curve.interpolation),e=r[0];r.every(l=>l===e)||console.warn(`子属性插值类型不一致: ${r.join(", ")}`);const i=t.map(l=>{const m=l.getProperty??l.property,f=m.lastIndexOf(".");return f===-1?null:m.substring(f+1)}).filter(Boolean).sort(),s=i.join(",");switch(s){case"x,y":return y.Vector2;case"x,y,z":return y.Vector3;case"w,x,y,z":return y.Vector4;case"a,b,g,r":return y.Color;case"height,width,x,y":return y.Rect}const o=new Set(["x","y","z","w"]),c=new Set(["r","g","b","a"]),p=new Set(["x","y","width","height"]),h=i.every(l=>o.has(l)),u=i.every(l=>c.has(l)),d=i.every(l=>p.has(l));return h?i.some(l=>l==="w")?y.Vector4:i.some(l=>l==="z")?y.Vector3:y.Vector2:u?y.Color:d?y.Rect:(console.warn(`无法识别的子属性组合: ${s}`),null)}_validateBindingGroup(t){const{bindings:n}=t;return n.every(r=>this._validateCurveBinding(r))&&this._validateAndGetParentValueType(n)!==null}_createParentProperty(t,n){const{parentPath:r,relativePath:e,componentType:a}=t,i=B({relativePath:e,componentType:a,propertyPath:r}),s=I.Linear,o=this._propertyLabelMap.get(i),c=r.split(".").pop()||r;return{name:o||c,level:e.split("/").length-1,path:i,type:O.Property,valueType:n,interpolationType:s,componentType:a,relativePath:e,hasSubProperty:!0,curveColor:null,supported:!0,properties:[],propertyPath:r}}async _createSubPropertiesFromBindings(t,n,r,e){return Promise.all(t.map(async a=>{const{getProperty:i,property:s,curve:o}=a,c=i??s,p=await this._convertPropertyProxyPath(c,e,r)||c,h=p.lastIndexOf("."),u=h===-1?p:p.substring(h+1),d=`${n}.${u}`,l={name:u,level:r.split("/").length,path:d,type:O.SubProperty,valueType:y.Float,interpolationType:o.interpolation,componentType:e,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p,parentPath:n};return this.pathPropertyMap.set(d,l),l}))}_registerPropertyGroup(t,n){t.properties=n,this.pathPropertyMap.has(t.path)&&console.warn(`覆盖已存在的属性路径: ${t.path}`),this.pathPropertyMap.set(t.path,t),this.properties.push(t)}async _generatePropertiesFromBindingGroup(t){const{parentPath:n,relativePath:r,componentType:e,bindings:a}=t;if(!this.rootEntity){await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const i=await this._convertPropertyProxyPath(n,e,r)||n;if(!this._validateBindingGroup(t)){this.rootEntity&&a.length>1&&console.debug("AnimationClipAsset: grouping skipped",this.name,e,r,n),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const s=this._validateAndGetParentValueType(a);if(s===null){console.error("验证通过但获取不到父属性类型"),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const o=this._createParentProperty({...t,parentPath:i},s),c=await this._createSubPropertiesFromBindings(a,o.path,r,e);this._registerPropertyGroup(o,c)}async _generatePropertyByEngineObject(t){const{pathPropertyMap:n}=this,{relativePath:r,type:e,curve:a,getProperty:i,property:s}=t,o=K.get(e),c=i??s,p=await this._convertPropertyProxyPath(c,o,r)??c,h=this._getValueTypeByCurve(a),u=B({relativePath:r,componentType:o,propertyPath:p}),d=this._propertyLabelMap.get(u),l=p.lastIndexOf("."),m=l===-1?p:p.substring(l+1),f={name:d||m,level:r.split("/").length-1,path:u,type:O.Property,valueType:h,interpolationType:a.interpolation,componentType:o,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p},A=this._getSubProperties(h,a);A&&(f.curveColor=null,f.hasSubProperty=!0,f.properties=A.map(P=>{const b=`${u}.${P}`,v={name:P,level:r.split("/").length,path:b,type:O.SubProperty,valueType:y.Float,interpolationType:a.interpolation,componentType:o,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:`${p}.${P}`};return n.set(b,v),v})),n.set(u,f),this.properties.push(f)}async _getActualPropertyPath(t,n,r){if(!this.isSubAsset){const{editorPropertyPath:e=[]}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t});t=e.join(".")}return t}_getRandomColor(){const{_colorList:t}=this,n=(e,a)=>{const i=parseInt(e.slice(1),16),s=parseInt(a.slice(1),16);return`#${parseInt(`${(i+s)/2}`).toString(16).toUpperCase()}`},r=()=>{const e=[];for(let i=0,s=t.length-1;i<s;i++){const o=n(t[i],t[i+1]);e.push(o)}const a=t.slice(0,t.length-1);for(let i=0,s=a.length+e.length;i<s;i++)t[i]=i%2===0?a[i/2]:e[(i-1)/2]};for(;this._colorIndex>=t.length;)r();return t[this._colorIndex++]}_getSubProperties(t,n){let r;switch(t){case y.Vector2:{r=["x","y"];break}case y.Vector3:{r=["x","y","z"];break}case y.Vector4:{r=["x","y","z","w"];break}case y.Quaternion:{r=["x","y","z","w"];break}case y.Color:{r=["r","g","b","a"];break}case y.Array:case y.FloatArray:n.keys[0]&&(r=Array.from(n.keys[0].value).map((e,a)=>a))}return r}_listenRootEntityChanged(){var n;const t=this.rootEntity;t&&(this.showEditor&&(this.openEditor(!1),this.openEditor(!0)),(n=this._componentsChangedListenerDisposer)==null||n.call(this),this._componentsChangedListenerDisposer=fe(()=>t.components.length,()=>{this.checkPropertiesSupport(t),this.engineObject.curveBindings.forEach(r=>{r._tempCurveOwner={}})}))}_convertPropertyToTreeItem(t){var m;const{name:n,label:r,properties:e=[],relativePath:a,componentType:i,path:s,type:o,curveColor:c,supported:p,level:h}=t,u=((m=this.rootEntity.findByPath(a))==null?void 0:m.name)||a.split("/").pop(),d=r||n;return{name:o===O.Property?`${u}:${i}.${d}`:d,id:s,canAddKeyframe:o===O.Property||o===O.SubProperty,curveColor:c,supported:p,level:h,children:e.map(f=>this._convertPropertyToTreeItem(f))}}_ensurePropertyExists(t){const n=B(t);let r=this.pathPropertyMap.get(n);return r||(r=this.addProperty(t)),t.children&&t.children.length&&t.children.forEach(e=>{this._ensurePropertyExists(e)}),r}destroy(){var t;super.destroy(),(t=this._componentsChangedListenerDisposer)==null||t.call(this),this._propertyPathCache.clear(),this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyLabelMap.clear(),this._editorPathCache.clear(),this._originValueStore.clear()}};T([L],C.prototype,"samples",2);T([L],C.prototype,"properties",2);T([L],C.prototype,"keyframeDataList",2);T([L],C.prototype,"events",2);T([ge()],C.prototype,"data",2);T([L],C.prototype,"selectedEventId",2);T([L,Pe()],C.prototype,"rootEntityId",2);T([L],C.prototype,"readOnly",2);T([_e],C.prototype,"addedPropertiesTreeData",1);T([E],C.prototype,"addProperty",1);T([E],C.prototype,"delProperty",1);T([E],C.prototype,"addKeyframe",1);T([E],C.prototype,"deleteKeyframes",1);T([E],C.prototype,"updateKeyframes",1);T([E],C.prototype,"addEvent",1);T([E],C.prototype,"deleteEvent",1);T([E],C.prototype,"updateEvents",1);T([E],C.prototype,"updateSamples",1);T([E],C.prototype,"updateRootEntity",1);T([E],C.prototype,"setTangentMode",1);T([E],C.prototype,"checkPropertiesSupport",1);T([E],C.prototype,"updateSelectedEvent",1);T([E],C.prototype,"openEditor",1);C=T([ve({type:"AnimationClip",label:j("asset.animation-clip.title"),icon:"animate-clip",extname:"anim",importMenuConfig:{type:be.Add},customInspector:Se,viewer:$,async bundle({content:_},t,n){var a;const r=JSON.parse(await _.text());for(const i of r.curveBindings)if(i.curveType==="AnimationRefCurve"){for(const s of i.curve.keys)if((a=s.value)!=null&&a.refId){const o=n.resolveRef(s.value.refId);o&&(s.value=o)}}const e=ct(r,{type:"AnimationClip",name:r.name});return{content:new Blob([e])}}})],C);export{C as A,Se as a,$ as b};
1
+ var ut=Object.defineProperty;var yt=(_,t,n)=>t in _?ut(_,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):_[t]=n;var g=(_,t,n)=>(yt(_,typeof t!="symbol"?t+"":t,n),n);import{aJ as Z,aL as V,bl as dt,e as j,cp as et,cq as mt,aO as ft,aH as gt,aI as Pt,u as it,S as ot,bV as _t,x as L,aC as E,bp as vt,bs as bt,cr as Ct,cs as Tt,y as wt,ct as Et,bH as At,cu as St,cv as xt,cw as Mt,N as Vt,O as It,cx as Ot,cy as jt,cz as Ft,cA as Rt,cB as Bt,cC as Lt,cD as Dt,cE as $t,cF as Kt,cG as Nt,cH as kt,cI as zt,cJ as Ut,cK as Ht,aE as y,cL as Gt,bO as I,cM as Jt,cN as Qt,cO as Wt,cP as Yt,cQ as qt,cR as Zt,cS as Xt,cT as te,cU as ee,cV as re,cW as ne,j as ae,cX as O,b_ as W,cY as H,c9 as Y,cZ as x,bY as q,c_ as se,c$ as rt,ap as ie,d0 as oe,ac as nt,d1 as B,ai as at,d2 as pe,H as ce,d3 as le,at as he,au as ue,V as ye,F as de,b4 as me,d4 as G,bI as fe,m as ge,aU as Pe,c5 as _e,n as ve,o as be,d5 as Ce}from"./index-eeedc550.js";import{a as pt,r as st}from"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{A as Te}from"./AssetViewer-f505fb55.js";import{e as ct}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{L as we}from"./module-ace60695.js";import{a as Ee}from"./module-11aabe24.js";const Ae=Z(()=>{const _=pt("animationClipStore"),{selectedEvent:t}=_,{paramType:n}=t;return V.jsxs("div",{children:[V.jsx(dt,{label:j("animation.clip.param-type.title"),options:[{value:"string",label:String(j("animation.clip.param-type.string"))},{value:"number",label:String(j("animation.clip.param-type.number"))},{value:"null",label:String(j("animation.clip.param-type.null"))}],value:n||"null",onChange:r=>{t.paramType=r,_.updateEvents([t])}}),V.jsx(et,{label:j("animation.clip.function-name"),value:t.functionName,onChange:r=>{t.functionName=r,_.updateEvents([t])}}),n==="number"&&V.jsx(mt,{label:j("animation.clip.number"),value:t.number,onChange:r=>{t.number=r,_.updateEvents([t])}}),n==="string"&&V.jsx(et,{label:j("animation.clip.string"),value:t.string,onChange:r=>{t.string=r,_.updateEvents([t])}})]})}),Se=Z(function(){const t=pt("animationClipStore"),{selectedEvent:n}=t;return n?V.jsx(ft,{title:j("animation.clip.event"),defaultOpen:!0,children:V.jsx(V.Fragment,{children:V.jsx(Ae,{})})}):null});var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,N=(_,t,n,r)=>{for(var e=r>1?void 0:r?Me(t,n):t,a=_.length-1,i;a>=0;a--)(i=_[a])&&(e=(r?i(t,n,e):i(e))||e);return r&&e&&xe(t,n,e),e};const Ve=gt(Pt,{position:"absolute",top:0,left:0,margin:"auto",width:"100%",height:228,alignItems:"center",justifyContent:"center"});class $ extends Te{constructor(){super();g(this,"frameTime",0);g(this,"duration",0);g(this,"playing",!1);g(this,"_clip");g(this,"_updateComponent");g(this,"animationNames");g(this,"overridePreviewer",Z(({asset:n,viewer:r})=>V.jsx(V.Fragment,{children:n.isSubAsset||n.root.sceneUIStore.lastSelectedId?V.jsx(_t,{asset:n,viewer:r}):V.jsx(Ve,{children:V.jsx(V.Fragment,{children:j("animation.clip.select-entity-preview")})})})));it(this)}selectAnimation(n){}async setViewAsset(n,r){var i,s;let e;if(n.isSubAsset){const o=await n.root.assetStore.getAssetByRef({refId:n.mainId}),{defaultSceneRoot:c}=o.engineObject;e=((i=n.root.sceneStore.lastSelectedEntity)==null?void 0:i.engineObject)||c}else e=(s=n.root.sceneStore.lastSelectedEntity)==null?void 0:s.engineObject;if(!e)return;this._clip=n.engineObject,this.animationNames=[n.name],this._entity=e.clone(),r.addChild(this._entity);const a=this;this._updateComponent=this._entity.addComponent(class extends ot{onUpdate(o){a._onUpdate(100/3)}}),this.frameTime=0,this.duration=this._clip.length}stopViewAsset(){var n;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(n=this._updateComponent)==null||n.destroy()}setFrameTime(n){this.frameTime=n,this._sampleAnimation()}playAnimation(){this._clip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(n){!this.playing||!this._clip||!this.duration||(this.frameTime+=n/1e3,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this._clip._sampleAnimation(this._entity,this.frameTime)}catch(n){console.warn(n)}}}N([L],$.prototype,"frameTime",2);N([L],$.prototype,"duration",2);N([L],$.prototype,"playing",2);N([E],$.prototype,"setViewAsset",1);N([E],$.prototype,"setFrameTime",1);N([E],$.prototype,"playAnimation",1);N([E],$.prototype,"pauseAnimation",1);N([E],$.prototype,"_onUpdate",1);const K=new Map([[vt,"Transform"],[bt,"Animator"],[Ct,"DirectLight"],[Tt,"Camera"],[wt,"MeshRenderer"],[Et,"SkinnedMeshRenderer"],[At,"ParticleRenderer"],[St,"PointLight"],[xt,"SpotLight"],[ot,"Script"],[Mt,"SpriteMask"],[Vt,"SpriteRenderer"],[It,"TextRenderer"],[Ot,"UITransform"],[jt,"UICanvas"],[Ft,"UIGroup"],[Rt,"Button"],[Bt,"Image"],[Lt,"Text"],[Dt,"DynamicCollider"],[$t,"StaticCollider"],[Kt,"CharacterController"],[Nt,"SpringJoint"],[kt,"FixedJoint"],[zt,"HingeJoint"],[Ut,"AudioSource"],[Ht,"PostProcess"],[Ee,"SpineAnimationRenderer"],[we,"LottieAnimation"]]);var Ie=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,T=(_,t,n,r)=>{for(var e=r>1?void 0:r?Oe(t,n):t,a=_.length-1,i;a>=0;a--)(i=_[a])&&(e=(r?i(t,n,e):i(e))||e);return r&&e&&Ie(t,n,e),e};const X=new Map([[y.Float,{curveClass:Gt,name:"AnimationFloatCurve",defaultInterpolation:I.Hermite}],[y.FloatArray,{curveClass:Jt,name:"AnimationFloatArrayCurve",defaultInterpolation:I.Hermite}],[y.Vector2,{curveClass:Qt,name:"AnimationVector2Curve",defaultInterpolation:I.Hermite}],[y.Vector3,{curveClass:Wt,name:"AnimationVector3Curve",defaultInterpolation:I.Hermite}],[y.Vector4,{curveClass:Yt,name:"AnimationVector4Curve",defaultInterpolation:I.Hermite}],[y.Quaternion,{curveClass:qt,name:"AnimationQuaternionCurve",defaultInterpolation:I.Hermite}],[y.Color,{curveClass:Zt,name:"AnimationColorCurve",defaultInterpolation:I.Hermite}],[y.ReferResource,{curveClass:Xt,name:"AnimationRefCurve",defaultInterpolation:I.Step}],[y.Rect,{curveClass:te,name:"AnimationRectCurve",defaultInterpolation:I.Step}],[y.Boolean,{curveClass:ee,name:"AnimationBoolCurve",defaultInterpolation:I.Step}],[y.String,{curveClass:re,name:"AnimationStringCurve",defaultInterpolation:I.Step}],[y.Array,{curveClass:ne,name:"AnimationArrayCurve",defaultInterpolation:I.Hermite}]]),lt=new Map;X.forEach((_,t)=>{lt.set(_.curveClass,t)});const ht=new Map;X.forEach(_=>{ht.set(_.curveClass,_.name)});let C=class extends ae{constructor(t){super(t);g(this,"samples",60);g(this,"properties",[]);g(this,"pathPropertyMap",new Map);g(this,"keyframeDataList",[]);g(this,"events",{});g(this,"data");g(this,"selectedEventId");g(this,"rootEntityId");g(this,"showEditor");g(this,"readOnly",!1);g(this,"_propertyCurveMap",{});g(this,"_originValueStore",new Map);g(this,"_initKeyframeDataPromise");g(this,"_parseKeyframeValuePromise");g(this,"_colorList",["#3477FA","#67FEBB","#C201BF","#F6ED17","#FE6C02","#FD86C2","#A2B44B","#68D8F0","#008225","#A56A02"]);g(this,"_colorIndex",0);g(this,"_openIndex",0);g(this,"_componentsChangedListenerDisposer");g(this,"_propertyPathCache",new Map);g(this,"_propertyLabelMap",new Map);g(this,"_editorPathCache",new Map);it(this),this.onDoubleClick=this.onDoubleClick.bind(this)}get rootEntity(){return this.root.sceneStore.getEntityModel(this.rootEntityId)}get addedPropertiesTreeData(){return this.properties.map(t=>this._convertPropertyToTreeItem(t))}persistMainViaFacade(){this.root.assetFacade.persistAssetMain(this.id)}persistMetaViaFacade(){this.root.assetFacade.persistAssetMeta(this.id)}addProperty(t){const{type:n,parentProperty:r}=t,e=B(t),a=this.pathPropertyMap.get(e),i=this.properties;let s;if(a)W.error(j("animation.clip.error.property-existed"));else{if(n===O.Property)s=this._addPropertyToList(i,t,null);else{const o=i.find(c=>c.propertyPath===r.propertyPath&&c.relativePath===r.relativePath&&c.componentType===r.componentType);if(o)o.properties.find(p=>p.path===e)?W.error(j("animation.clip.error.sub-property-existed")):s=this._addPropertyToList(o.properties,t,o);else{const c=this._addPropertyToList(i,r,null,!1);s=this._addPropertyToList(c.properties,t,c)}}return this._sortProperties(),this.properties=i.slice(0),this._updateCurveBindings(),this.persistMetaViaFacade(),this.persistMainViaFacade(),s}}delProperty(t){const n=new Set;t.forEach(r=>{if(n.add(r.path),this.pathPropertyMap.delete(r.path),r.type===O.Property)r.properties.forEach(e=>{n.add(e.path),this.pathPropertyMap.delete(e.path)}),this._delPropertyFromList(this.properties,r);else{const e=this.properties.find(a=>a.path===r.parentPath);e&&(this._delPropertyFromList(e.properties,r),e.hasSubProperty&&!e.properties.length&&this._delPropertyFromList(this.properties,e))}}),this._sortProperties(),this.properties=this.properties.slice(0),this._removeCurveBindings(n),this._updateCurveBindings(),this.updateKeyframes(this.keyframeDataList.filter(r=>!n.has(r.path))),this.persistMetaViaFacade(),this.persistMainViaFacade()}async addKeyframe(t,n){const{rootEntity:r}=this,e=this.pathPropertyMap.get(n),{type:a,path:i,parentPath:s,properties:o,supported:c}=e;if(!c){W.error(j("animation.clip.error.property-not-supported"));return}const p=a===O.SubProperty?this.pathPropertyMap.get(s):null,{editorReference:h,editorPropertyPath:u,propertyPos:d}=await this._getReferenceAndActualPropertyPath(r,e),l=u[d],m=H(h)[l];let f=h[l];m!=null&&m.getActualEditorValue&&(f=m.getActualEditorValue(f));let A=e.valueType;a===O.Property&&(m!=null&&m.valueType)&&(A=m.valueType),a===O.SubProperty&&(f=f[u[d+1]]);const P=Y(f);if(o.length)o.forEach(b=>{const{path:v}=b,w=P[b.name],S=this.keyframeDataList.find(M=>M.path===v&&M.frame===t);if(S)S.value=w,S.inTangentMode=x.Linear,S.outTangentMode=x.Linear;else{const M=this._createKeyframeData(t,w,b.valueType,void 0,void 0,b,e);this.keyframeDataList.push(M)}});else{const b=this.keyframeDataList.find(v=>v.path===i&&v.frame===t);if(b)b.value=P,b.inTangent=void 0,b.outTangent=void 0;else{const v=this._createKeyframeData(t,P,A,void 0,void 0,e,a===O.SubProperty?p:null);this.keyframeDataList.push(v)}}this.updateKeyframes(this.keyframeDataList)}addKeyframeByRecording(t,n){const r=this._ensurePropertyExists(n);r&&this.addKeyframe(t,r.path)}deleteKeyframes(t){t.forEach(n=>{const r=this.keyframeDataList.indexOf(n);r>-1&&this.keyframeDataList.splice(r,1)}),this.updateKeyframes(this.keyframeDataList)}updateKeyframes(t,n=!0){const r={};t.length&&t.sort((e,a)=>e.frame-a.frame),t.forEach(e=>{const a=e.path;r[a]??(r[a]=[]),r[a].push(e),r[a].sort((i,s)=>i.frame-s.frame)});for(const e in r)for(let a=0,i=r[e].length;a<i;++a){const s=r[e][a];if(s.interpolationType===I.Step)continue;const o=r[e][a-1],c=r[e][a+1];s.isFirst=a===0,s.isLast=a===i-1,a>0&&(s.frame-o.frame===0?s.linearInTangent=0:s.linearInTangent=(s.value-o.value)/((s.frame-o.frame)/this.samples),s.inTangent=s.inTangentMode===x.Linear?s.linearInTangent:s.inTangent,isNaN(s.inTangent)&&(s.inTangent=-1/0)),a<i-1&&(c.frame-s.frame===0?s.linearOutTangent=0:s.linearOutTangent=(c.value-s.value)/((c.frame-s.frame)/this.samples),s.outTangent=s.outTangentMode===x.Linear?s.linearOutTangent:s.outTangent,isNaN(s.outTangent)&&(s.outTangent=-1/0))}this.keyframeDataList=t.slice(0),this.isSubAsset||(this._generateEngineKeyframes(t),n&&this.persistMainViaFacade())}addEvent(t){const n={id:q(),time:t/this.samples,functionName:"onEvent"};this.events[n.id]=n,this.updateEvents(this.events)}deleteEvent(t){delete this.events[t.id],this.updateEvents(this.events)}updateEvents(t,n=!0){const r=this.engineObject;if(this.events={...t},r.clearEvents(),Object.values(this.events).map(e=>{const a=e.paramType==="string"?e.string:e.number;r.addEvent(e.functionName,e.time,a)}),this.data.events=Object.values(this.events).map(e=>({time:e.time,functionName:e.functionName,parameter:e.paramType==="string"?e.string:e.number})),n){const{isSubAsset:e}=this;if(e){const a=this.root.assetStore.getAsset(this.mainId);if(a){const i=a.engineObject.animations.indexOf(this._engineObject);a.updateAnimationEvents(i,this.data.events)}}this.persistMainViaFacade()}}updateSamples(t){this.samples=+t.toFixed(0)}updateRootEntity(t){if(!(!t||t.id===this.rootEntityId)){if(this.rootEntityId=t.id,this.engineObject){this._clearPropertyMappings();const n=this._init().then(async()=>{await this._generateKeyframeDataList(),await this._updateCurveBindings(),this.showEditor&&(await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}).catch(r=>{console.warn("AnimationClipAsset:updateRootEntity rebuild failed",this.name,r)});this._initKeyframeDataPromise=n}this._listenRootEntityChanged(),this.persistMetaViaFacade()}}setTangentMode(t,n,r){t.forEach(e=>{if(n===se.In)switch(e.inTangentMode=r,r){case x.Linear:e.inTangent=e.linearInTangent;break;case x.Constant:e.inTangent=-1/0;break;case x.Free:break}else switch(e.outTangentMode=r,r){case x.Linear:e.outTangent=e.linearOutTangent;break;case x.Constant:e.outTangent=-1/0;break;case x.Free:break}}),this.persistMetaViaFacade(),this.updateKeyframes(this.keyframeDataList)}async checkPropertiesSupport(t){const{properties:n}=this;let r=!1;const e=n.map(async a=>{const i=!!a.supported,{editorReference:s}=await this._getReferenceAndActualPropertyPath(t,a);s?a.supported=!0:a.supported=!1,!i&&a.supported&&(r=!0)});await Promise.all(e),r&&(this.properties=this.properties.slice(0),await this._generateKeyframeDataList(),this.updateKeyframes(this.keyframeDataList,!1),await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}updateSelectedEvent(t){this.selectedEventId=t}async openEditor(t){if(t&&!this.showEditor){this._initKeyframeDataPromise||(this._initKeyframeDataPromise=this._generateKeyframeDataList()),this.showEditor=t,this.root.projectStore.animationEditing=t;const n=++this._openIndex;if(await this._initKeyframeDataPromise,n!==this._openIndex)return;this.saveEditorOriginValue(),this.sampleAnimation(this.root.animationClipStore.currentFrame),rt()}!t&&this.showEditor&&(this.showEditor=t,this.root.projectStore.animationEditing=t,this.revertValue())}async sampleAnimation(t){const n=this.rootEntity;if(n){const r=n.engineObject;try{await this._parseKeyframeValuePromise,this.engineObject._sampleAnimation(r,t/this.samples),this._syncToEditor()}catch(e){console.warn(e)}}}async saveEditorOriginValue(){const{_originValueStore:t}=this,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:i,property:s}=e,o=K.get(i),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:o,propertyPath:s});if(!c)return;const u=p[h];if(!t.has(e)){let d=u;u==="rotationQuaternion"&&(d="rotation"),t.set(e,Y(c[d]))}});await Promise.all(r)}async revertValue(){const{_originValueStore:t}=this,n=Array.from(t).map(async([r,e])=>{const{relativePath:a,type:i,property:s}=r,o=K.get(i),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:o,propertyPath:s});if(!c)return;const u=p[h];let d=u;u==="rotationQuaternion"&&(d="rotation"),this._setEditorValue(c,d,e)});await Promise.all(n),t.clear()}async initByMain(t){const{engine:n,meta:r}=this;r.rootEntityId&&(this.rootEntityId=r.rootEntityId),this._listenRootEntityChanged();try{const e=JSON.parse(await t.text()),a=ct(e,{type:"AnimationClip",name:e.name}),i=await ie(a,n);this.bindEngineObject(i),await this._init()}catch(e){console.error(`[AnimationClipAsset] Failed to load "${this.name}"`,e)}}async initByEngineObject(t){this.bindEngineObject(t),this._name=t.name,await this._init()}async initByCreation(t,n){this.setNameByIncrease(n||"AnimationClip");const r=new oe(this.name);return this.bindEngineObject(r),this.data={name:this.name,curveBindings:r.curveBindings,events:[]},await this._init(),this.getMainData()}_clearPropertyMappings(){this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyPathCache.clear(),this._propertyLabelMap.clear(),this._editorPathCache.clear(),this.properties.length=0,this._colorIndex=0,this._originValueStore.clear()}_sortProperties(){this.properties.sort((t,n)=>(t.level??0)-(n.level??0))}async _init(){const t=this.engineObject;this._clearPropertyMappings();const r=(await this._groupCurveBindingsByParent(t.curveBindings)).map(async a=>{if(await this._generatePropertiesFromBindingGroup(a),this.isSubAsset)return Promise.resolve();const i=a.bindings.flatMap(s=>{const{curve:o}=s;return o.keys.map(c=>this._editorValueToEngineValue(c.value,this._getValueTypeByCurve(o)).then(p=>{c.value=p}))});return Promise.all(i)});if(!this.isSubAsset){const{properties:a,pathPropertyMap:i}=this;a.forEach(s=>{s.properties.length||this._colorIndex++,i.set(s.path,s),s.properties.forEach(o=>{this._colorIndex++,i.set(o.path,o)})})}await Promise.all(r),this._sortProperties();const e={};t.events.forEach(a=>{const i=q(),s=a.parameter?typeof a.parameter:"null";e[i]={id:i,time:a.time,functionName:a.functionName,paramType:s,string:s==="string"?a.parameter:void 0,number:s==="number"?a.parameter:void 0}}),this.data={name:t.name,curveBindings:t.curveBindings,events:[]},this.updateEvents(e,!1)}async onDoubleClick(){st.layoutStore.toggleTabVisibility("AnimationClip"),st.layoutStore.activeTab("AnimationClip"),rt()}getMainData(){const t=this.data,n={...t,curveBindings:t.curveBindings.map(r=>{const{curve:e}=r,a=ht.get(e.constructor);return{...r,type:K.get(r.type)||r.type,curveType:a,curve:{interpolation:e.interpolation,keys:e.keys.map(i=>{const s=i.value,o=s instanceof nt?this.root.assetStore.engineObjectToAssetMap.get(s).getCurrentRef():s;return{...i,value:Y(o)}})}}})};return JSON.stringify(n)}async _syncToEditor(){const t=this.rootEntity,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:i,property:s,getProperty:o}=e,c=K.get(i);if(!e.curve.keys.length)return;const p=await this._getActualPropertyPath(o??s,a,c),{editorReference:h,engineGetReference:u,editorPropertyPath:d,enginePropertyGetPath:l,propertyPos:m}=await this._getReferenceAndActualPropertyPath(t,{relativePath:a,componentType:c,propertyPath:p});if(!u||!h)return;const f=B({relativePath:a,componentType:c,propertyPath:d.slice(0,m+1).join(".")}),A=this.pathPropertyMap.get(f);let P=d[m],b=this._getEngineValue(u,l[m]),v=A.valueType;P==="rotationQuaternion"&&(P="rotation",b=b.toEuler(new at).scale(180/Math.PI),v=y.Vector3);const w=this._engineValueToEditorValue(b,v,!1);this._setEditorValue(h,P,w)});await Promise.all(r)}async _setEditorValue(t,n,r){var i,s;const e=(i=pe(t))==null?void 0:i[n],a=(s=H(t))==null?void 0:s[n];if(a!=null&&a.getEditorValue&&(r=a.getEditorValue(r)),a!=null&&a.setActualEditorValue?a==null||a.setActualEditorValue(t,n,r):t[n]=r,e!=null&&e.onChange){const o=r!=null&&r.refId?await t.root.assetStore.getAssetByRef(r):r;await e.onChange(t,n,o)}}_removeCurveBindings(t){const n=this.engineObject;if(!n)return;const r=new Set;for(const e of t){const a=this._propertyCurveMap[e];a&&(r.add(a),delete this._propertyCurveMap[e])}if(r.size>0){const e=n.curveBindings;for(let a=e.length-1;a>=0;a--){const i=e[a];r.has(i.curve)&&(e.splice(a,1),this._originValueStore.delete(i))}}}async _updateCurveBindings(){var n;const t=this.rootEntity;if(t)for(const r of this.properties)try{const{relativePath:e,componentType:a,valueType:i,properties:s,interpolationType:o}=r,c=B(r),p=await this._getReferenceAndActualPropertyPath(t,r),{editorReference:h,enginePropertySetPath:u,enginePropertyGetPath:d,editorPropertyPath:l,propertyPos:m}=p||{};if(!h||!u||!d||m===void 0)continue;const f=l[m],A=(n=H(h))==null?void 0:n[f],P=u.join("."),b=d.join(".");if(s.length)for(const v of s){const w=B(v),S=this._createCurve(w,v.valueType,v.interpolationType),M=v.name;await this._addCurveBinding(e,a,`${P}.${M}`,`${b}.${M}`,S),this._propertyCurveMap[w]=S}else{let v=i;A!=null&&A.valueType&&(v=A.valueType);const w=this._createCurve(c,v,o);await this._addCurveBinding(e,a,P,b,w),this._propertyCurveMap[c]=w}}catch(e){console.warn("updateCurveBindings skipped property (unresolved):",r==null?void 0:r.propertyPath,e);continue}}_createCurve(t,n,r){let e=this._propertyCurveMap[t];if(!e){const a=X.get(n);a?(e=new a.curveClass,e.interpolation=r??a.defaultInterpolation):console.warn(`Unsupported curve value type: ${n}`)}return e}async _addCurveBinding(t,n,r,e,a){const i=ce.getClass(n),s=this.engineObject;let o=!0;for(let c=0,p=s.curveBindings.length;c<p;++c){const h=s.curveBindings[c];h.relativePath===t&&h.type===i&&h.property===r&&h.getProperty===e&&(h.curve=a,o=!1)}o&&(s.addCurveBinding(t,i,r,e,a),await this.saveEditorOriginValue())}_addPropertyToList(t,n,r,e=!0){var o;const a=this._covertToPropertyData(n,r),i=t.push(a),s=t[i-1];return this.pathPropertyMap.set(s.path,s),e&&((o=n.children)!=null&&o.length)&&n.children.forEach(c=>{this._addPropertyToList(s.properties,c,s,e)}),s}_delPropertyFromList(t,n){const r=t.findIndex(e=>e.path===n.path);r>-1&&(t.splice(r,1),this.pathPropertyMap.delete(n.path))}_covertToPropertyData(t,n){const{name:r,label:e,relativePath:a,componentType:i,propertyPath:s,type:o,valueType:c,interpolationType:p,children:h}=t,u=B(t),d=B(n),l=a.split("/").length-1;return{name:e||r,level:l,path:u,type:o,valueType:c,interpolationType:p,propertyPath:s,componentType:i,relativePath:a,hasSubProperty:h.length>0,curveColor:c===y.Float?this._getRandomColor():null,supported:!0,properties:[],parentPath:d}}async _getReferenceAndActualPropertyPath(t,n){if(!t)return{};const{relativePath:r,componentType:e,propertyPath:a}=n,i=t.findByPath(r);if(!i)return{};const s=i.getComponentByTypeName(e);if(!s)return{};const o=[],c=[],p=[],h=a.split("."),u=h.length-1;let d=-1,l=s;for(let P=0,b=u;P<=b;++P){const v=h[P];if(!l)return{};const w=H(l);let S="",M=v,k=v,z=v,R=P;for(let F=P,J=u;F<=J;++F){S+=h[F];const Q=(w==null?void 0:w[S])||{},{getPath:U,setPath:D,editorKey:tt}=Q;D&&(k=D,R=F),(U||D)&&(F===u&&D?k=D:k=U??D,z=U??D,R=F),tt&&(M=tt,R=F),F<u&&(S+=".")}P=R,c.push(k),p.push(z),o.push(M),le(l,M)&&(d=o.length-1),P<u&&(l=l[M],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l)))}const m=d>-1?d-1:o.length-1;l=s;for(let P=0,b=m;P<b;++P)l=l[o[P]],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l));const f=this._getEngineValue(s.engineObject,c.slice(0,m).join(".")),A=this._getEngineValue(s.engineObject,p.slice(0,m).join("."));return{editorReference:l,engineSetReference:f,engineGetReference:A,enginePropertySetPath:c,enginePropertyGetPath:p,editorPropertyPath:o,propertyPos:m,subPropertyPos:d}}_getEngineValue(t,n){if(!n)return t;let r=t;const e=n.split(".");for(let a=0,i=e.length;a<i;a++){const s=e[a];if(s.indexOf("[")>-1){const o=s.indexOf("[");r=r[s.slice(0,o)],r=r[parseInt(s.slice(o+1,-1))]}else if(s.endsWith(")")){const o=s.slice(0,s.indexOf("(")),c=s.match(/\w+\(([^)]*)\)/)[1].split(",").map(p=>p.trim().replace(/['"]+/g,"")).filter(p=>p!=="");r=r[o](...c)}else r=r[s]}return r}async _generateKeyframeDataList(){const t=this.engineObject,n=[],r=this.pathPropertyMap,e=t.curveBindings.map(async a=>{const{relativePath:i,type:s,getProperty:o,property:c,curve:p}=a,h=K.get(s),u=o??c,d=await this._convertPropertyProxyPath(u,h,i),m=B({relativePath:i,componentType:h,propertyPath:d||u});d||console.warn(`无法转换引擎路径到编辑器路径: ${u},使用原路径`);const f=r.get(m);if(!f){d&&console.warn(`转换后的路径仍未找到属性定义: ${m}, 原引擎路径: ${u}`);return}this._propertyCurveMap[m]=p;const A=f.valueType;p.keys.forEach(P=>{const{time:b,value:v,inTangent:w,outTangent:S}=P,M=Math.floor(b*this.samples),k=this._engineValueToEditorValue(v,A,!0),z=this._getSubProperties(A,p);if(z)z.forEach(R=>{const F=`${m}.${R}`,J=r.get(F),Q=w&&w[R],U=S&&S[R],D=this._createKeyframeData(M,k[R],y.Float,Q,U,J,f);n.push(D)});else{const R=r.get(f.parentPath),F=this._createKeyframeData(M,k,A,w,S,f,R);n.push(F)}})});await Promise.all(e),this.updateKeyframes(n,!1)}_createKeyframeData(t,n,r,e,a,i,s){const{path:o,curveColor:c}=i,{path:p=""}=s||{};return{id:q(),frame:t,path:o,value:n,isActive:!0,valueType:r??y.Float,curveColor:c,parentPath:p,inTangent:e,outTangent:a,interpolationType:i.interpolationType,inTangentMode:e===void 0?x.Linear:e===-1/0?x.Constant:x.Free,outTangentMode:a===void 0?x.Linear:a===-1/0?x.Constant:x.Free}}_generateEngineKeyframes(t){const{_propertyCurveMap:n,samples:r,engineObject:e}=this,a=this._groupKeyframesByPath(t),s=this._collectPathsToSync(n,a).map(o=>this._syncCurveForPath(o,n[o],a.get(o)||[],r,e));this._parseKeyframeValuePromise=Promise.all(s)}_groupKeyframesByPath(t){return t.reduce((n,r)=>{const e=n.get(r.path)||[];return e.push(r),n.set(r.path,e),n},new Map)}_collectPathsToSync(t,n){const r=new Set;return Object.keys(t).forEach(e=>r.add(e)),n.forEach((e,a)=>r.add(a)),Array.from(r)}async _syncCurveForPath(t,n,r,e,a){if(!n)return;const i=await this._convertToEngineKeyframes(r,e);this._removeObsoleteKeyframes(n,i),this._addOrUpdateKeyframes(n,i,a)}async _convertToEngineKeyframes(t,n){const r=new Map;for(const e of t){const a=e.frame/n,i=await this._editorValueToEngineValue(e.value,e.valueType);i===void 0&&e.valueType===y.ReferResource||r.set(a,{value:i,inTangent:e.inTangent,outTangent:e.outTangent})}return r}_removeObsoleteKeyframes(t,n){const r=new Set(n.keys());for(let e=t.keys.length-1;e>=0;e--){const a=t.keys[e];r.has(a.time)||t.keys.splice(e,1)}}_addOrUpdateKeyframes(t,n,r){const e=new Map;t.keys.forEach(a=>{e.set(a.time,a)});for(const[a,{value:i,inTangent:s,outTangent:o}]of n){const c=e.get(a);if(c)c.value=i,c.inTangent=s,c.outTangent=o;else{const p=new Ce;p.time=a,p.value=i,p.inTangent=s,p.outTangent=o,t.addKey(p)}a>r._length&&(r._length=a)}}async _editorValueToEngineValue(t,n){var r;switch(n){case y.ReferResource:return t!=null&&t.refId?(r=await this.root.assetStore.getAssetByRef(t))==null?void 0:r.engineObject:t;case y.Color:return new me(t.r,t.g,t.b,t.a);case y.Vector2:return new de(t.x,t.y);case y.Vector3:return new at(t.x,t.y,t.z);case y.Vector4:return new ye(t.x,t.y,t.z,t.w);case y.Quaternion:return new ue(t.x,t.y,t.z,t.w);case y.Rect:return new he(t.x,t.y,t.width,t.height);case y.Float:return t;default:return t}}_engineValueToEditorValue(t,n,r){var a,i,s;let e;switch(n){case y.MethodParam:{if(e=[],r)for(let o=0,c=t.length;o<c;o++){const p=t[o];e[o]??(e[o]=[]);for(let h=0,u=p.length;h<u;h++){const d=p[h];e[o][h]=((a=this.root.assetStore.engineObjectToAssetMap.get(d))==null?void 0:a.getCurrentRef())??d}}else t&&t instanceof nt?e=[[((i=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:i.getCurrentRef())??t]]:t instanceof Array?e=t:e=[[t]];break}case y.ReferResource:{e=(s=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:s.getCurrentRef();break}case y.Color:{e={r:t.r,g:t.g,b:t.b,a:t.a},["r","g","b","a"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Vector2:{e={x:t.x,y:t.y},["x","y"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Vector3:{e={x:t.x,y:t.y,z:t.z},["x","y","z"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Vector4:case y.Quaternion:{e={x:t.x,y:t.y,z:t.z,w:t.w},["x","y","z","w"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Rect:{e={x:t.x,y:t.y,width:t.width,height:t.height},["x","y","width","height"].forEach(o=>{e[o]=Math.round(e[o]*1e3)/1e3});break}case y.Float:{e=Math.round(t*1e3)/1e3;break}default:e=t}return e}_getValueTypeByCurve(t){return lt.get(t.constructor)}_parsePropertyPath(t){const n=this._propertyPathCache.get(t);if(n)return n;const r=t.lastIndexOf("."),e=r===-1?{parentPath:t,subProperty:null}:{parentPath:t.substring(0,r),subProperty:t.substring(r+1)};return this._propertyPathCache.set(t,e),e}_isSubPropertyName(t){return/^([xyzw]|[rgba]|width|height)$/.test(t)}async _convertPropertyProxyPath(t,n,r){try{const e=this._resolveProxyHost(n,r,t);if(!e)return null;const a=`${r}|${n}|${t}`;if(this._editorPathCache.has(a))return this._editorPathCache.get(a);const i=await this._recursiveConvert(t,e,0);return i&&i!==t&&await this._buildLabelMappingsForPath(i,r,n,e),this._editorPathCache.set(a,i??null),i}catch{const a=`${r}|${n}|${t}`;return this._editorPathCache.set(a,null),null}}async _buildLabelMappingsForPath(t,n,r,e){try{const a=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t}),i=(a==null?void 0:a.editorPropertyPath)||t.split("."),s=typeof(a==null?void 0:a.propertyPos)=="number"?a.propertyPos:i.length-1;for(let o=0;o<=s;o++){const c=i.slice(0,o+1).join("."),p=B({relativePath:n,componentType:r,propertyPath:c});if(!this._propertyLabelMap.has(p)){const h=await this._extractLabelForPartialPath(c,e);h&&this._propertyLabelMap.set(p,h)}}}catch(a){console.warn("建立标签映射失败:",a)}}async _extractLabelForPartialPath(t,n){try{const r=t.split("."),e=r[r.length-1];let a=n,i=null;for(let s=0;s<r.length;s++){const o=r[s],c=a==null?void 0:a[G];if(c&&c[o]){const p=c[o];p.label&&(i=p.label),s<r.length-1&&(a=await this._getNextObject(a,o))}else break}return i||e}catch{return t.split(".").pop()||t}}async _recursiveConvert(t,n,r){if(r>6)return t;const e=n[G];if(!e)return t;for(const[a,i]of Object.entries(e)){if(!this._isPathMatch(t,i))continue;const s=i.getPath||i.setPath;if(s){if(s.endsWith("()")&&t.startsWith(s+".")){const o=t.substring(s.length+1),c=await this._getNextObject(n,a);if(!c)return`${a}.${o}`;const p=await this._recursiveConvert(o,c,r+1);return p?`${a}.${p}`:`${a}.${o}`}return this._buildEditorPath(a,t,i)}}return t}async _getNextObject(t,n){var r;try{let e=t[n];if(!e){const a=`get${n.charAt(0).toUpperCase()+n.slice(1)}`;typeof t[a]=="function"&&(e=t[a]())}if(e!=null&&e.refId&&((r=this.root)!=null&&r.assetStore)){let a=this.root.assetStore.engineObjectToAssetMap.get(e);if(!a)try{a=await this.root.assetStore.getAssetByRef(e)}catch{return e}if(a)return a}return e}catch{return null}}_resolveProxyHost(t,n,r){try{if(!this.rootEntity)return null;const e=n?this.rootEntity.findByPath(n):this.rootEntity;if(!e)return null;const a=e.getComponentByTypeName(t);return a?r?this._resolvePropertyProxyHolder(a,r):a:null}catch(e){return console.warn(`获取代理宿主失败: ${t}, ${n}`,r,e),null}}_resolvePropertyProxyHolder(t,n){try{const r=[t];this._addRelatedObjectCandidates(t,r);for(const e of r)if(this._hasMatchingProxyConfig(e,n))return e;return t}catch(r){return console.warn(`解析 PropertyProxy 持有者失败: ${n}`,r),t}}_addRelatedObjectCandidates(t,n){try{const r=t[G];if(!r)return;const e=new Set;for(const a of Object.values(r)){const i=this._extractObjectPathFromConfig(a);i&&e.add(i)}for(const a of e){const i=this._getEngineValue(t.engineObject,a);if(i){const s=this.root.assetStore.engineObjectToAssetMap.get(i);s&&!n.includes(s)&&n.push(s)}}}catch{}}_extractObjectPathFromConfig(t){const n=t.getPath||t.setPath;if(!n)return null;const r=n.match(/^([^.]+\([^)]*\))/);return r?r[1]:null}_hasMatchingProxyConfig(t,n){const r=t[G];if(!r)return!1;for(const e of Object.values(r))if(this._isPathMatch(n,e))return!0;return!1}_isPathMatch(t,n){return n?n.getPath&&this._isExactPathMatch(t,n.getPath)||n.setPath&&this._isExactPathMatch(t,n.setPath)||n.engineKey&&t.includes(n.engineKey):!1}_isExactPathMatch(t,n){if(!n)return!1;const r=p=>p.replace(/['"`\s]/g,""),e=p=>{let h="";for(let u=0;u<p.length;u++){const d=p[u];if(d==="("){for(;u<p.length&&p[u]!==")";)u++;h+="()"}else h+=d}return h},a=p=>e(r(p).replace(/\$value/g,"value")),i=a(t),s=a(n);if(i===s||((p,h)=>p.startsWith(h+".")||p.startsWith(h+"["))(i,s))return!0;if(!n.includes(".")&&!n.includes("(")&&!n.includes("[")){const p=i.split(".");for(const h of p){const u=h.indexOf("[");if((u>=0?h.slice(0,u):h)===s)return!0}}return!1}_buildEditorPath(t,n,r){if(!r)return t;const e=r.getPath||r.setPath;if(!e)return t;if(e.endsWith("()")&&n.startsWith(e+".")){const s=n.substring(e.length+1);return`${t}.${s}`}const a=n.replace(/['"`]/g,"").replace(/\$value/g,"value"),i=e.replace(/['"`]/g,"").replace(/\$value/g,"value");if(a.includes(i))return a.replace(i,t);if(!e.includes(".")&&!e.includes("(")){const s=n.match(/\.([a-zA-Z_]\w*)$/);if(s){const o=s[1];if(o!==e)return`${t}.${o}`}}return t}_validateCurveBinding(t){const{relativePath:n,type:r,getProperty:e,property:a}=t;return K.get(r)?e??a?!0:(console.warn(`绑定缺少属性路径: ${n}`),!1):(console.warn(`未知组件类型: ${r},跳过绑定`),!1)}async _groupCurveBindingsByParent(t){const n=new Map;return await Promise.all(t.map(async r=>{if(!this._validateCurveBinding(r))return;const{relativePath:e,type:a,getProperty:i,property:s}=r,o=K.get(a),c=i??s,h=await this._convertPropertyProxyPath(c,o,e)||c,u=this._parsePropertyPath(h),d=u.subProperty&&this._isSubPropertyName(u.subProperty);let l,m;d&&u.subProperty?(m=u.parentPath,l=`${e}.${o}.${m}`):(m=h,l=`${e}.${o}.${h}`),n.has(l)||n.set(l,{parentPath:m,relativePath:e,componentType:o,bindings:[]}),n.get(l).bindings.push(r)})),Array.from(n.values())}_validateAndGetParentValueType(t){if(t.length===1){const l=t[0],m=l.getProperty??l.property,{subProperty:f}=this._parsePropertyPath(m);return!f||!this._isSubPropertyName(f)?null:y.Float}if(!t.every(l=>this._getValueTypeByCurve(l.curve)===y.Float)){const l=t.map(m=>this._getValueTypeByCurve(m.curve));return console.warn(`分组中的绑定类型不一致: ${l.join(", ")},无法创建父属性`),null}const r=t.map(l=>l.curve.interpolation),e=r[0];r.every(l=>l===e)||console.warn(`子属性插值类型不一致: ${r.join(", ")}`);const i=t.map(l=>{const m=l.getProperty??l.property,f=m.lastIndexOf(".");return f===-1?null:m.substring(f+1)}).filter(Boolean).sort(),s=i.join(",");switch(s){case"x,y":return y.Vector2;case"x,y,z":return y.Vector3;case"w,x,y,z":return y.Vector4;case"a,b,g,r":return y.Color;case"height,width,x,y":return y.Rect}const o=new Set(["x","y","z","w"]),c=new Set(["r","g","b","a"]),p=new Set(["x","y","width","height"]),h=i.every(l=>o.has(l)),u=i.every(l=>c.has(l)),d=i.every(l=>p.has(l));return h?i.some(l=>l==="w")?y.Vector4:i.some(l=>l==="z")?y.Vector3:y.Vector2:u?y.Color:d?y.Rect:(console.warn(`无法识别的子属性组合: ${s}`),null)}_validateBindingGroup(t){const{bindings:n}=t;return n.every(r=>this._validateCurveBinding(r))&&this._validateAndGetParentValueType(n)!==null}_createParentProperty(t,n){const{parentPath:r,relativePath:e,componentType:a}=t,i=B({relativePath:e,componentType:a,propertyPath:r}),s=I.Linear,o=this._propertyLabelMap.get(i),c=r.split(".").pop()||r;return{name:o||c,level:e.split("/").length-1,path:i,type:O.Property,valueType:n,interpolationType:s,componentType:a,relativePath:e,hasSubProperty:!0,curveColor:null,supported:!0,properties:[],propertyPath:r}}async _createSubPropertiesFromBindings(t,n,r,e){return Promise.all(t.map(async a=>{const{getProperty:i,property:s,curve:o}=a,c=i??s,p=await this._convertPropertyProxyPath(c,e,r)||c,h=p.lastIndexOf("."),u=h===-1?p:p.substring(h+1),d=`${n}.${u}`,l={name:u,level:r.split("/").length,path:d,type:O.SubProperty,valueType:y.Float,interpolationType:o.interpolation,componentType:e,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p,parentPath:n};return this.pathPropertyMap.set(d,l),l}))}_registerPropertyGroup(t,n){t.properties=n,this.pathPropertyMap.has(t.path)&&console.warn(`覆盖已存在的属性路径: ${t.path}`),this.pathPropertyMap.set(t.path,t),this.properties.push(t)}async _generatePropertiesFromBindingGroup(t){const{parentPath:n,relativePath:r,componentType:e,bindings:a}=t;if(!this.rootEntity){await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const i=await this._convertPropertyProxyPath(n,e,r)||n;if(!this._validateBindingGroup(t)){this.rootEntity&&a.length>1&&console.debug("AnimationClipAsset: grouping skipped",this.name,e,r,n),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const s=this._validateAndGetParentValueType(a);if(s===null){console.error("验证通过但获取不到父属性类型"),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const o=this._createParentProperty({...t,parentPath:i},s),c=await this._createSubPropertiesFromBindings(a,o.path,r,e);this._registerPropertyGroup(o,c)}async _generatePropertyByEngineObject(t){const{pathPropertyMap:n}=this,{relativePath:r,type:e,curve:a,getProperty:i,property:s}=t,o=K.get(e),c=i??s,p=await this._convertPropertyProxyPath(c,o,r)??c,h=this._getValueTypeByCurve(a),u=B({relativePath:r,componentType:o,propertyPath:p}),d=this._propertyLabelMap.get(u),l=p.lastIndexOf("."),m=l===-1?p:p.substring(l+1),f={name:d||m,level:r.split("/").length-1,path:u,type:O.Property,valueType:h,interpolationType:a.interpolation,componentType:o,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p},A=this._getSubProperties(h,a);A&&(f.curveColor=null,f.hasSubProperty=!0,f.properties=A.map(P=>{const b=`${u}.${P}`,v={name:P,level:r.split("/").length,path:b,type:O.SubProperty,valueType:y.Float,interpolationType:a.interpolation,componentType:o,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:`${p}.${P}`};return n.set(b,v),v})),n.set(u,f),this.properties.push(f)}async _getActualPropertyPath(t,n,r){if(!this.isSubAsset){const{editorPropertyPath:e=[]}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t});t=e.join(".")}return t}_getRandomColor(){const{_colorList:t}=this,n=(e,a)=>{const i=parseInt(e.slice(1),16),s=parseInt(a.slice(1),16);return`#${parseInt(`${(i+s)/2}`).toString(16).toUpperCase()}`},r=()=>{const e=[];for(let i=0,s=t.length-1;i<s;i++){const o=n(t[i],t[i+1]);e.push(o)}const a=t.slice(0,t.length-1);for(let i=0,s=a.length+e.length;i<s;i++)t[i]=i%2===0?a[i/2]:e[(i-1)/2]};for(;this._colorIndex>=t.length;)r();return t[this._colorIndex++]}_getSubProperties(t,n){let r;switch(t){case y.Vector2:{r=["x","y"];break}case y.Vector3:{r=["x","y","z"];break}case y.Vector4:{r=["x","y","z","w"];break}case y.Quaternion:{r=["x","y","z","w"];break}case y.Color:{r=["r","g","b","a"];break}case y.Array:case y.FloatArray:n.keys[0]&&(r=Array.from(n.keys[0].value).map((e,a)=>a))}return r}_listenRootEntityChanged(){var n;const t=this.rootEntity;t&&(this.showEditor&&(this.openEditor(!1),this.openEditor(!0)),(n=this._componentsChangedListenerDisposer)==null||n.call(this),this._componentsChangedListenerDisposer=fe(()=>t.components.length,()=>{this.checkPropertiesSupport(t),this.engineObject.curveBindings.forEach(r=>{r._tempCurveOwner={}})}))}_convertPropertyToTreeItem(t){var m;const{name:n,label:r,properties:e=[],relativePath:a,componentType:i,path:s,type:o,curveColor:c,supported:p,level:h}=t,u=((m=this.rootEntity.findByPath(a))==null?void 0:m.name)||a.split("/").pop(),d=r||n;return{name:o===O.Property?`${u}:${i}.${d}`:d,id:s,canAddKeyframe:o===O.Property||o===O.SubProperty,curveColor:c,supported:p,level:h,children:e.map(f=>this._convertPropertyToTreeItem(f))}}_ensurePropertyExists(t){const n=B(t);let r=this.pathPropertyMap.get(n);return r||(r=this.addProperty(t)),t.children&&t.children.length&&t.children.forEach(e=>{this._ensurePropertyExists(e)}),r}destroy(){var t;super.destroy(),(t=this._componentsChangedListenerDisposer)==null||t.call(this),this._propertyPathCache.clear(),this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyLabelMap.clear(),this._editorPathCache.clear(),this._originValueStore.clear()}};T([L],C.prototype,"samples",2);T([L],C.prototype,"properties",2);T([L],C.prototype,"keyframeDataList",2);T([L],C.prototype,"events",2);T([ge()],C.prototype,"data",2);T([L],C.prototype,"selectedEventId",2);T([L,Pe()],C.prototype,"rootEntityId",2);T([L],C.prototype,"readOnly",2);T([_e],C.prototype,"addedPropertiesTreeData",1);T([E],C.prototype,"addProperty",1);T([E],C.prototype,"delProperty",1);T([E],C.prototype,"addKeyframe",1);T([E],C.prototype,"deleteKeyframes",1);T([E],C.prototype,"updateKeyframes",1);T([E],C.prototype,"addEvent",1);T([E],C.prototype,"deleteEvent",1);T([E],C.prototype,"updateEvents",1);T([E],C.prototype,"updateSamples",1);T([E],C.prototype,"updateRootEntity",1);T([E],C.prototype,"setTangentMode",1);T([E],C.prototype,"checkPropertiesSupport",1);T([E],C.prototype,"updateSelectedEvent",1);T([E],C.prototype,"openEditor",1);C=T([ve({type:"AnimationClip",label:j("asset.animation-clip.title"),icon:"animate-clip",extname:"anim",importMenuConfig:{type:be.Add},customInspector:Se,viewer:$,async bundle({content:_},t,n){var a;const r=JSON.parse(await _.text());for(const i of r.curveBindings)if(i.curveType==="AnimationRefCurve"){for(const s of i.curve.keys)if((a=s.value)!=null&&a.refId){const o=n.resolveRef(s.value.refId);o&&(s.value=o)}}const e=ct(r,{type:"AnimationClip",name:r.name});return{content:new Blob([e])}}})],C);export{C as A,Se as a,$ as b};
@@ -1 +1 @@
1
- var O=Object.defineProperty;var v=(r,t,a)=>t in r?O(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var c=(r,t,a)=>(v(r,typeof t!="symbol"?t+"":t,a),a);import{aJ as x,aK as N,aN as B,aL as _,aI as I,aQ as L,j as U,aR as z,aS as F,aT as R,x as T,aU as V,m as w,aV as J,n as W,e as q,o as K,q as Q,aW as $}from"./index-d497fb6d.js";import{u as k,r as M}from"./index-8a22fe59.js";import"./postmen-0413c689.js";import"./meshopt_simplifier.module-cd99529d.js";import{b as G}from"./bundlers-9b0d37fc.js";const H=x(function(){const{layoutStore:t}=k(),{t:a}=N(),e=B.useCallback(()=>{t.toggleTabVisibility("AnimatorController")},[]);return _.jsx(I,{align:"both",css:{padding:"$1"},fullWidth:!0,children:_.jsx(L,{size:"sm",onClick:e,children:a("animation.animator-controller.editor.open")})})});var X=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,y=(r,t,a,e)=>{for(var s=e>1?void 0:e?Y(t,a):t,o=r.length-1,n;o>=0;o--)(n=r[o])&&(s=(e?n(t,a,s):n(s))||s);return e&&s&&X(t,a,s),s};let d=class extends U{constructor(t){super(t);c(this,"statesNameMap",{});c(this,"internalDataUpdated",!1);c(this,"layers",[]);c(this,"parameters",[]);c(this,"_syncing");c(this,"_syncingPromise");this.onDoubleClick=this.onDoubleClick.bind(this)}applyPropertyFromDomain(t,a){super.applyPropertyFromDomain(t,a),(t==="layers"||t==="parameters")&&this.applyControllerData().catch(e=>{console.error("[AnimatorControllerAsset] applyControllerData failed:",e)})}initByEngineObject(t){return this.setNameByIncrease("AnimatorController"),this.bindEngineObject(t),this.layers=t.layers.map(a=>{const e=a.stateMachine,o={states:e.states.map(n=>({name:n.name,speed:n.speed,wrapMode:n.wrapMode,clipStartNormalizedTime:n.clipStartTime,clipEndNormalizedTime:n.clipEndTime,clip:this.root.assetStore.engineObjectToAssetMap.get(n.clip).getCurrentRef(),transitions:[],scripts:[],isEntryState:n===e.defaultState,isExitState:!1,isAnyState:!1})),transitions:[],entryTransitions:[],anyTransitions:[]};return{name:a.name,blendingMode:a.blendingMode,weight:a.weight,stateMachine:o}}),this.internalDataUpdated=!0,this.getMainData()}async initByMain(t){const{internalDataUpdated:a}=this.meta;a&&(this.internalDataUpdated=!0);const e=JSON.parse(await t.text()),s=new z(this.engine);this.bindEngineObject(s),this.layers=e.layers||[],this.parameters=e.parameters||[],await this.applyControllerData()}async applyControllerData(){this._syncing&&await this._syncingPromise,this._syncing=!0;try{this.statesNameMap={};const t=this.engineObject;t.clearLayers(),t._parameters.length=0,t._parametersMap={};const{layers:a,parameters:e}=this;this._syncingPromise=Promise.all(a.map((s,o)=>{const{name:n,blendingMode:m,weight:u}=s,l=new F(n);return t.addLayer(l),l.blendingMode=m,l.weight=u,this._applyStateMachineData(o)})),e.forEach(s=>{const{isTrigger:o,name:n,defaultValue:m}=s;o?t.addTriggerParameter(n):t.addParameter(n,m)}),await this._syncingPromise}finally{this._syncing=!1}}async initByCreation(){return this.layers=[{name:"Base",weight:1,blendingMode:R.Override,stateMachine:{states:[],transitions:[],entryTransitions:[],anyTransitions:[]}}],this.getMainData()}onDoubleClick(){M.sceneStore.selectEntity(null),M.layoutStore.toggleTabVisibility("AnimatorController"),M.layoutStore.activeTab("AnimatorController")}async _applyStateMachineData(t){const a=this.engineObject.layers[t],{stateMachine:e}=this.layers[t],s=a.stateMachine;if(e){const{states:o=[],transitions:n=[],entryTransitions:m=[],anyTransitions:u=[]}=e,l={},C={},P=o.map(async i=>{var E,A;const{id:h,name:f,speed:b,wrapMode:g,clipStartNormalizedTime:j,clipEndNormalizedTime:D,clip:S}=i;(E=this.statesNameMap)[t]||(E[t]={}),this.statesNameMap[t][i.name]=i;const p=s.addState(f);p.speed=b,p.wrapMode=g,p.clipStartTime=j,p.clipEndTime=D,l[h]=p,S&&(p.clip=(A=await this.root.assetStore.getAssetByRef(S))==null?void 0:A.engineObject)});n.forEach(i=>{const h=this._createTransition(i,l[i.destinationStateId]);C[i.id]=h}),o.forEach(i=>{const{id:h,transitions:f}=i;f.forEach(b=>{const g=C[b];g&&l[h].addTransition(g)})}),m.forEach(i=>{s.addEntryStateTransition(this._createTransition(i,l[i.destinationStateId]))}),u.forEach(i=>{s.addAnyStateTransition(this._createTransition(i,l[i.destinationStateId]))}),await Promise.all(P),this.engineObject._updateFlagManager.dispatch()}}_createTransition(t,a){const e=new $;return e.duration=t.duration,e.offset=t.offset,e.exitTime=t.exitTime,e.solo=t.solo,e.mute=t.mute,e.hasExitTime=t.hasExitTime,e._isExit=t.isExit,e.destinationState=a,t.conditions.forEach(s=>{e.addCondition(s.parameterName,s.mode,s.threshold)}),e}};y([T,V()],d.prototype,"internalDataUpdated",2);y([w(),T],d.prototype,"layers",2);y([w(),T],d.prototype,"parameters",2);y([J],d.prototype,"applyPropertyFromDomain",1);d=y([W({type:"AnimatorController",label:q("asset.animator-controller.title"),icon:"animate-controller",extname:"animCtrl",importMenuConfig:{type:K.Add},dragLayer:Q.AnimationController,customInspector:H,async bundle({content:r}){return{content:new Blob([G(await r.text())])}}})],d);export{d as AnimatorControllerAsset};
1
+ var O=Object.defineProperty;var v=(r,t,a)=>t in r?O(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var c=(r,t,a)=>(v(r,typeof t!="symbol"?t+"":t,a),a);import{aJ as x,aK as N,aN as B,aL as _,aI as I,aQ as L,j as U,aR as z,aS as F,aT as R,x as T,aU as V,m as w,aV as J,n as W,e as q,o as K,q as Q,aW as $}from"./index-eeedc550.js";import{u as k,r as M}from"./index-828538e1.js";import"./postmen-fe9eecc4.js";import"./meshopt_simplifier.module-cd99529d.js";import{b as G}from"./bundlers-9b0d37fc.js";const H=x(function(){const{layoutStore:t}=k(),{t:a}=N(),e=B.useCallback(()=>{t.toggleTabVisibility("AnimatorController")},[]);return _.jsx(I,{align:"both",css:{padding:"$1"},fullWidth:!0,children:_.jsx(L,{size:"sm",onClick:e,children:a("animation.animator-controller.editor.open")})})});var X=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,y=(r,t,a,e)=>{for(var s=e>1?void 0:e?Y(t,a):t,o=r.length-1,n;o>=0;o--)(n=r[o])&&(s=(e?n(t,a,s):n(s))||s);return e&&s&&X(t,a,s),s};let d=class extends U{constructor(t){super(t);c(this,"statesNameMap",{});c(this,"internalDataUpdated",!1);c(this,"layers",[]);c(this,"parameters",[]);c(this,"_syncing");c(this,"_syncingPromise");this.onDoubleClick=this.onDoubleClick.bind(this)}applyPropertyFromDomain(t,a){super.applyPropertyFromDomain(t,a),(t==="layers"||t==="parameters")&&this.applyControllerData().catch(e=>{console.error("[AnimatorControllerAsset] applyControllerData failed:",e)})}initByEngineObject(t){return this.setNameByIncrease("AnimatorController"),this.bindEngineObject(t),this.layers=t.layers.map(a=>{const e=a.stateMachine,o={states:e.states.map(n=>({name:n.name,speed:n.speed,wrapMode:n.wrapMode,clipStartNormalizedTime:n.clipStartTime,clipEndNormalizedTime:n.clipEndTime,clip:this.root.assetStore.engineObjectToAssetMap.get(n.clip).getCurrentRef(),transitions:[],scripts:[],isEntryState:n===e.defaultState,isExitState:!1,isAnyState:!1})),transitions:[],entryTransitions:[],anyTransitions:[]};return{name:a.name,blendingMode:a.blendingMode,weight:a.weight,stateMachine:o}}),this.internalDataUpdated=!0,this.getMainData()}async initByMain(t){const{internalDataUpdated:a}=this.meta;a&&(this.internalDataUpdated=!0);const e=JSON.parse(await t.text()),s=new z(this.engine);this.bindEngineObject(s),this.layers=e.layers||[],this.parameters=e.parameters||[],await this.applyControllerData()}async applyControllerData(){this._syncing&&await this._syncingPromise,this._syncing=!0;try{this.statesNameMap={};const t=this.engineObject;t.clearLayers(),t._parameters.length=0,t._parametersMap={};const{layers:a,parameters:e}=this;this._syncingPromise=Promise.all(a.map((s,o)=>{const{name:n,blendingMode:m,weight:u}=s,l=new F(n);return t.addLayer(l),l.blendingMode=m,l.weight=u,this._applyStateMachineData(o)})),e.forEach(s=>{const{isTrigger:o,name:n,defaultValue:m}=s;o?t.addTriggerParameter(n):t.addParameter(n,m)}),await this._syncingPromise}finally{this._syncing=!1}}async initByCreation(){return this.layers=[{name:"Base",weight:1,blendingMode:R.Override,stateMachine:{states:[],transitions:[],entryTransitions:[],anyTransitions:[]}}],this.getMainData()}onDoubleClick(){M.sceneStore.selectEntity(null),M.layoutStore.toggleTabVisibility("AnimatorController"),M.layoutStore.activeTab("AnimatorController")}async _applyStateMachineData(t){const a=this.engineObject.layers[t],{stateMachine:e}=this.layers[t],s=a.stateMachine;if(e){const{states:o=[],transitions:n=[],entryTransitions:m=[],anyTransitions:u=[]}=e,l={},C={},P=o.map(async i=>{var E,A;const{id:h,name:f,speed:b,wrapMode:g,clipStartNormalizedTime:j,clipEndNormalizedTime:D,clip:S}=i;(E=this.statesNameMap)[t]||(E[t]={}),this.statesNameMap[t][i.name]=i;const p=s.addState(f);p.speed=b,p.wrapMode=g,p.clipStartTime=j,p.clipEndTime=D,l[h]=p,S&&(p.clip=(A=await this.root.assetStore.getAssetByRef(S))==null?void 0:A.engineObject)});n.forEach(i=>{const h=this._createTransition(i,l[i.destinationStateId]);C[i.id]=h}),o.forEach(i=>{const{id:h,transitions:f}=i;f.forEach(b=>{const g=C[b];g&&l[h].addTransition(g)})}),m.forEach(i=>{s.addEntryStateTransition(this._createTransition(i,l[i.destinationStateId]))}),u.forEach(i=>{s.addAnyStateTransition(this._createTransition(i,l[i.destinationStateId]))}),await Promise.all(P),this.engineObject._updateFlagManager.dispatch()}}_createTransition(t,a){const e=new $;return e.duration=t.duration,e.offset=t.offset,e.exitTime=t.exitTime,e.solo=t.solo,e.mute=t.mute,e.hasExitTime=t.hasExitTime,e._isExit=t.isExit,e.destinationState=a,t.conditions.forEach(s=>{e.addCondition(s.parameterName,s.mode,s.threshold)}),e}};y([T,V()],d.prototype,"internalDataUpdated",2);y([w(),T],d.prototype,"layers",2);y([w(),T],d.prototype,"parameters",2);y([J],d.prototype,"applyPropertyFromDomain",1);d=y([W({type:"AnimatorController",label:q("asset.animator-controller.title"),icon:"animate-controller",extname:"animCtrl",importMenuConfig:{type:K.Add},dragLayer:Q.AnimationController,customInspector:H,async bundle({content:r}){return{content:new Blob([G(await r.text())])}}})],d);export{d as AnimatorControllerAsset};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var P=(n,t,o)=>t in n?f(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;var i=(n,t,o)=>(P(n,typeof t!="symbol"?t+"":t,o),o);import{E as y,bq as u,s as c,p as m,C as b,t as h,e as C,br as _,bs as g,u as v,bt as O,bu as S}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import{c as E}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";var A=Object.defineProperty,w=Object.getOwnPropertyDescriptor,p=(n,t,o,r)=>{for(var e=r>1?void 0:r?w(t,o):t,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(t,o,e):l(e))||e);return r&&e&&A(t,o,e),e};let s=class extends y{constructor(t,o){super(t,o);i(this,"animatorController",null);i(this,"cullingMode",u.None);i(this,"speed",1)}async bindEngineObject(t){await super.bindEngineObject(t),t.enabled=!1}rebindEngineObject(t){super.rebindEngineObject(t),t.enabled=!1}};p([c(),m({type:b.AssetPicker,assetType:"AnimatorController",label:"animation.animator-controller.controller.title",info:"animation.animator-controller.controller.info",bindPath:"animatorController"})],s.prototype,"animatorController",2);p([c(),m({type:b.Select,label:"animation.animator-controller.culling-mode.title",info:"animation.animator-controller.culling-mode.info",options:h(u,void 0,n=>C(`animation.animator-controller.culling-mode.${n.toLowerCase()}`)),bindPath:"cullingMode"})],s.prototype,"cullingMode",2);p([c(),m({type:b.Number,label:"animation.animator-controller.speed.title",info:"animation.animator-controller.speed.info",bindPath:"speed"})],s.prototype,"speed",2);s=p([E({type:"Animator",componentsMenu:{label:"component.animator.title"},unique:!0})],s);class j extends _{constructor(){super(...arguments);i(this,"_animatorComponents",[]);i(this,"onScriptPlay")}init(o){this.onScriptPlay=o.onScriptPlay}onPlay(o){this.engine.sceneManager.scenes[0].rootEntities.forEach(e=>{e.getComponentsIncludeChildren(g,this._animatorComponents)}),this._animatorComponents.forEach(e=>{e.enabled=o,o||e._reset()}),this.onScriptPlay&&this.onScriptPlay(o)}}var M=Object.defineProperty,D=Object.getOwnPropertyDescriptor,$=(n,t,o,r)=>{for(var e=r>1?void 0:r?D(t,o):t,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(t,o,e):l(e))||e);return r&&e&&M(t,o,e),e};let d=class{constructor(n){i(this,"script");i(this,"root");v(this),this.root=n}init(){this.script=O.addScript(j),this.script.init({onScriptPlay:n=>{var t;(t=this.root.animatorControllerStore)==null||t.updateGlobalPlayState(n)}})}};d=$([S({type:"animatorStore"})],d);export{s as A,d as a};
1
+ var f=Object.defineProperty;var P=(n,t,o)=>t in n?f(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;var i=(n,t,o)=>(P(n,typeof t!="symbol"?t+"":t,o),o);import{E as y,bq as u,s as c,p as m,C as b,t as h,e as C,br as _,bs as g,u as v,bt as O,bu as S}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{c as E}from"./Component-85241517.js";var A=Object.defineProperty,w=Object.getOwnPropertyDescriptor,p=(n,t,o,r)=>{for(var e=r>1?void 0:r?w(t,o):t,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(t,o,e):l(e))||e);return r&&e&&A(t,o,e),e};let s=class extends y{constructor(t,o){super(t,o);i(this,"animatorController",null);i(this,"cullingMode",u.None);i(this,"speed",1)}async bindEngineObject(t){await super.bindEngineObject(t),t.enabled=!1}rebindEngineObject(t){super.rebindEngineObject(t),t.enabled=!1}};p([c(),m({type:b.AssetPicker,assetType:"AnimatorController",label:"animation.animator-controller.controller.title",info:"animation.animator-controller.controller.info",bindPath:"animatorController"})],s.prototype,"animatorController",2);p([c(),m({type:b.Select,label:"animation.animator-controller.culling-mode.title",info:"animation.animator-controller.culling-mode.info",options:h(u,void 0,n=>C(`animation.animator-controller.culling-mode.${n.toLowerCase()}`)),bindPath:"cullingMode"})],s.prototype,"cullingMode",2);p([c(),m({type:b.Number,label:"animation.animator-controller.speed.title",info:"animation.animator-controller.speed.info",bindPath:"speed"})],s.prototype,"speed",2);s=p([E({type:"Animator",componentsMenu:{label:"component.animator.title"},unique:!0})],s);class j extends _{constructor(){super(...arguments);i(this,"_animatorComponents",[]);i(this,"onScriptPlay")}init(o){this.onScriptPlay=o.onScriptPlay}onPlay(o){this.engine.sceneManager.scenes[0].rootEntities.forEach(e=>{e.getComponentsIncludeChildren(g,this._animatorComponents)}),this._animatorComponents.forEach(e=>{e.enabled=o,o||e._reset()}),this.onScriptPlay&&this.onScriptPlay(o)}}var M=Object.defineProperty,D=Object.getOwnPropertyDescriptor,$=(n,t,o,r)=>{for(var e=r>1?void 0:r?D(t,o):t,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(t,o,e):l(e))||e);return r&&e&&M(t,o,e),e};let d=class{constructor(n){i(this,"script");i(this,"root");v(this),this.root=n}init(){this.script=O.addScript(j),this.script.init({onScriptPlay:n=>{var t;(t=this.root.animatorControllerStore)==null||t.updateGlobalPlayState(n)}})}};d=$([S({type:"animatorStore"})],d);export{s as A,d as a};
@@ -1 +1 @@
1
- var r=Object.defineProperty;var n=(t,e,s)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var i=(t,e,s)=>(n(t,typeof e!="symbol"?e+"":e,s),s);import{B as o}from"./index-d497fb6d.js";class _{constructor(){i(this,"overridePreviewer");i(this,"_entity");i(this,"_requestResetCamera");i(this,"_boundingBox",new o)}stopViewAsset(){this._entity&&(this._entity=null)}getDescription(e){return""}}export{_ as A};
1
+ var r=Object.defineProperty;var n=(t,e,s)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var i=(t,e,s)=>(n(t,typeof e!="symbol"?e+"":e,s),s);import{B as o}from"./index-eeedc550.js";class _{constructor(){i(this,"overridePreviewer");i(this,"_entity");i(this,"_requestResetCamera");i(this,"_boundingBox",new o)}stopViewAsset(){this._entity&&(this._entity=null)}getDescription(e){return""}}export{_ as A};
@@ -1 +1 @@
1
- var d=Object.defineProperty;var b=(e,t,s)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var p=(e,t,s)=>(b(e,typeof t!="symbol"?t+"":t,s),s);import{aH as v,aJ as c,aL as n,j as y,Z as A,n as j,e as m,o as w,b1 as l}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";import{A as f}from"./AssetViewer-9f395efb.js";const x=v("div",{position:"absolute",top:"100px",backgroundColor:"$panelBg",variants:{sticky:{true:{position:"absolute",top:0}}}}),O=c(({asset:e})=>n.jsx(x,{children:n.jsx("audio",{src:e.url,controls:!0,children:"Your browser does not support the audio element."})}));class _ extends f{constructor(){super(...arguments);p(this,"overridePreviewer",c(({asset:s})=>n.jsx(O,{asset:s})))}setViewAsset(s,r){}}var P=Object.defineProperty,U=Object.getOwnPropertyDescriptor,g=(e,t,s,r)=>{for(var o=r>1?void 0:r?U(t,s):t,i=e.length-1,a;i>=0;i--)(a=e[i])&&(o=(r?a(t,s,o):a(o))||o);return r&&o&&P(t,s,o),o};let u=class extends y{async initByMain(e){const t=URL.createObjectURL(e);try{const s=await this.engine.resourceManager.load({url:t,type:A.Audio});this.bindEngineObject(s)}finally{URL.revokeObjectURL(t)}}};u=g([j({type:"Audio",label:m("asset.audio.title"),loaderType:"Audio",importMenuConfig:{type:w.Upload,tooltip:`请上传音频文件(支持 ${l.map(e=>e.slice(1).toUpperCase()).join(", ")})`,accept:l.join(",")},viewer:_,bundle({content:e}){return{content:e}}})],u);export{u as AudioAsset};
1
+ var d=Object.defineProperty;var b=(e,t,s)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var p=(e,t,s)=>(b(e,typeof t!="symbol"?t+"":t,s),s);import{aH as v,aJ as c,aL as n,j as y,Z as A,n as j,e as m,o as w,b1 as l}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{A as f}from"./AssetViewer-f505fb55.js";const x=v("div",{position:"absolute",top:"100px",backgroundColor:"$panelBg",variants:{sticky:{true:{position:"absolute",top:0}}}}),O=c(({asset:e})=>n.jsx(x,{children:n.jsx("audio",{src:e.url,controls:!0,children:"Your browser does not support the audio element."})}));class _ extends f{constructor(){super(...arguments);p(this,"overridePreviewer",c(({asset:s})=>n.jsx(O,{asset:s})))}setViewAsset(s,r){}}var P=Object.defineProperty,U=Object.getOwnPropertyDescriptor,g=(e,t,s,r)=>{for(var o=r>1?void 0:r?U(t,s):t,i=e.length-1,a;i>=0;i--)(a=e[i])&&(o=(r?a(t,s,o):a(o))||o);return r&&o&&P(t,s,o),o};let u=class extends y{async initByMain(e){const t=URL.createObjectURL(e);try{const s=await this.engine.resourceManager.load({url:t,type:A.Audio});this.bindEngineObject(s)}finally{URL.revokeObjectURL(t)}}};u=g([j({type:"Audio",label:m("asset.audio.title"),loaderType:"Audio",importMenuConfig:{type:w.Upload,tooltip:`请上传音频文件(支持 ${l.map(e=>e.slice(1).toUpperCase()).join(", ")})`,accept:l.join(",")},viewer:_,bundle({content:e}){return{content:e}}})],u);export{u as AudioAsset};
@@ -1 +1 @@
1
- var b=Object.defineProperty;var d=(p,e,o)=>e in p?b(p,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):p[e]=o;var n=(p,e,o)=>(d(p,typeof e!="symbol"?e+"":e,o),o);import{E as f,p as r,C as a,s as u}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import{c}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";var P=Object.defineProperty,v=Object.getOwnPropertyDescriptor,i=(p,e,o,s)=>{for(var t=s>1?void 0:s?v(e,o):e,m=p.length-1,y;m>=0;m--)(y=p[m])&&(t=(s?y(e,o,t):y(t))||t);return s&&t&&P(e,o,t),t};let l=class extends f{constructor(e,o){super(e,o);n(this,"clip",null);n(this,"playOnEnabled",!0);n(this,"loop",!0);n(this,"volume",0);n(this,"mute",!1)}};i([r({label:"Audio resource",info:"Audio resource info",type:a.AssetPicker,assetType:"Audio",bindPath:"clip"}),u()],l.prototype,"clip",2);i([r({label:"playOnEnabled",info:"playOnEnabled info",type:a.Toggle,bindPath:"playOnEnabled"}),u()],l.prototype,"playOnEnabled",2);i([r({label:"IsLooping",info:"IsLooping info",type:a.Toggle,bindPath:"loop"}),u()],l.prototype,"loop",2);i([r({label:"Volume",info:"Volume info",type:a.Slider,min:0,max:1,bindPath:"volume"}),u()],l.prototype,"volume",2);i([r({label:"Mute",info:"Mute info",type:a.Toggle,bindPath:"mute"}),u()],l.prototype,"mute",2);l=i([c({type:"AudioSource",componentsMenu:{label:"component.audio.title"}})],l);export{l as AudioComponent};
1
+ var b=Object.defineProperty;var d=(p,e,o)=>e in p?b(p,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):p[e]=o;var n=(p,e,o)=>(d(p,typeof e!="symbol"?e+"":e,o),o);import{E as f,p as r,C as a,s as u}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{c}from"./Component-85241517.js";var P=Object.defineProperty,v=Object.getOwnPropertyDescriptor,i=(p,e,o,s)=>{for(var t=s>1?void 0:s?v(e,o):e,m=p.length-1,y;m>=0;m--)(y=p[m])&&(t=(s?y(e,o,t):y(t))||t);return s&&t&&P(e,o,t),t};let l=class extends f{constructor(e,o){super(e,o);n(this,"clip",null);n(this,"playOnEnabled",!0);n(this,"loop",!0);n(this,"volume",0);n(this,"mute",!1)}};i([r({label:"Audio resource",info:"Audio resource info",type:a.AssetPicker,assetType:"Audio",bindPath:"clip"}),u()],l.prototype,"clip",2);i([r({label:"playOnEnabled",info:"playOnEnabled info",type:a.Toggle,bindPath:"playOnEnabled"}),u()],l.prototype,"playOnEnabled",2);i([r({label:"IsLooping",info:"IsLooping info",type:a.Toggle,bindPath:"loop"}),u()],l.prototype,"loop",2);i([r({label:"Volume",info:"Volume info",type:a.Slider,min:0,max:1,bindPath:"volume"}),u()],l.prototype,"volume",2);i([r({label:"Mute",info:"Mute info",type:a.Toggle,bindPath:"mute"}),u()],l.prototype,"mute",2);l=i([c({type:"AudioSource",componentsMenu:{label:"component.audio.title"}})],l);export{l as AudioComponent};
@@ -1 +1 @@
1
- import{aH as o,aI as r}from"./index-d497fb6d.js";const a=o(r,{borderRadius:"$2",fontSize:"$1",padding:"$1 $2",userSelect:"none",fontWeight:500,variants:{type:{info:{backgroundColor:"$blue3",color:"$blueA11"},warning:{backgroundColor:"$amber3",color:"$amber11"},error:{backgroundColor:"$red3",color:"$red11"},success:{backgroundColor:"$green3",color:"$green11"}}}});export{a as S};
1
+ import{aH as o,aI as r}from"./index-eeedc550.js";const a=o(r,{borderRadius:"$2",fontSize:"$1",padding:"$1 $2",userSelect:"none",fontWeight:500,variants:{type:{info:{backgroundColor:"$blue3",color:"$blueA11"},warning:{backgroundColor:"$amber3",color:"$amber11"},error:{backgroundColor:"$red3",color:"$red11"},success:{backgroundColor:"$green3",color:"$green11"}}}});export{a as S};
@@ -1 +1 @@
1
- var v=Object.defineProperty;var q=(e,i,a)=>i in e?v(e,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[i]=a;var t=(e,i,a)=>(q(e,typeof i!="symbol"?i+"":i,a),a);import{L as g,a as y,E as k,V as L,b as C,d as P,D as w,c as O,A as x,M as A,C as s,s as o,p as l,t as m,e as b,l as E,g as R,f as S,h as M,r as D,S as j}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import{c as B}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";var F=Object.defineProperty,z=Object.getOwnPropertyDescriptor,n=(e,i,a,p)=>{for(var c=p>1?void 0:p?z(i,a):i,h=e.length-1,u;h>=0;h--)(u=e[h])&&(c=(p?u(i,a,c):u(c))||c);return p&&c&&F(i,a,c),c};const d=[...Object.values(g),y.Nothing,y.Everything];class T extends j{constructor(){super(...arguments);t(this,"_originalMask");t(this,"_onEndRenderOnce",null)}onBeginRender(a){this._originalMask=a.cullingMask,a.cullingMask&=~(g.Viewport|g.Outline|g.NavigationGizmo|g.Gizmo)}onEndRender(a){if(a.cullingMask=this._originalMask,this._onEndRenderOnce){const p=this._onEndRenderOnce;this._onEndRenderOnce=null,p(a)}}executeAfterRender(a){this._onEndRenderOnce=a}}let r=class extends k{constructor(){super(...arguments);t(this,"_lastRTAsset",null);t(this,"isOrthographic",!1);t(this,"nearClipPlane",.1);t(this,"farClipPlane",100);t(this,"fieldOfView",45);t(this,"orthographicSize",10);t(this,"viewport",new L(0,0,1,1));t(this,"priority",0);t(this,"enableFrustumCulling",!0);t(this,"clearFlags",C.All);t(this,"cullingMask",P(y.Everything,d));t(this,"postProcessMask",P(y.Everything,d));t(this,"depthTextureMode",w.None);t(this,"opaqueTextureEnabled",!1);t(this,"opaqueTextureDownsampling",O.TwoX);t(this,"antiAliasing",x.None);t(this,"msaaSamples",A.FourX);t(this,"enableHDR",!1);t(this,"enablePostProcess",!0);t(this,"isAlphaOutputRequired",!1);t(this,"renderTarget",null)}onEnabled(){this.applyBoundPathChange("enabled",s.Toggle,!1)}onInitComplete(){this._attachEditorCameraBridge(),this.renderTarget||this.applyBoundPathChange("enabled",s.Toggle,!1)}_attachEditorCameraBridge(){let i=this.engineObject.entity.getComponent(T);if(i||(i=this.engineObject.entity.addComponent(T)),this.renderTarget){const a=this.root.assetStore.getAsset(this.renderTarget.refId);a&&(this._lastRTAsset=a,i&&i.executeAfterRender(()=>{var p;a.updateThumbnail(),(p=a.subAssets)==null||p.forEach(c=>c.updateThumbnail())}))}}rebindEngineObject(i){super.rebindEngineObject(i),this._attachEditorCameraBridge()}};n([o(),l({label:"camera.is-orthographic",bindPath:"isOrthographic"})],r.prototype,"isOrthographic",2);n([o(),l({label:"camera.near-clip-plane",bindPath:"nearClipPlane"})],r.prototype,"nearClipPlane",2);n([o(),l({label:"camera.far-clip-plane",bindPath:"farClipPlane"})],r.prototype,"farClipPlane",2);n([o(),l({label:"camera.field-of-view",bindPath:"fieldOfView",when:e=>!e.isOrthographic})],r.prototype,"fieldOfView",2);n([o(),l({label:"camera.orthographic-size",bindPath:"orthographicSize",when:e=>e.isOrthographic})],r.prototype,"orthographicSize",2);n([o(),l({type:s.Vector4,min:0,max:1,label:"camera.viewport.title",bindPath:"viewport"})],r.prototype,"viewport",2);n([o(),l({label:"camera.priority.title",bindPath:"priority"})],r.prototype,"priority",2);n([o(),l({label:"camera.enable-frustum-culling",bindPath:"enableFrustumCulling"})],r.prototype,"enableFrustumCulling",2);n([o(),l({label:"camera.clear-flags.title",bindPath:"clearFlags",type:s.Select,options:m(C,void 0,e=>b(`camera.clear-flags.${e.toLocaleLowerCase()}`))})],r.prototype,"clearFlags",2);n([o(E(d)),l({label:"camera.culling-mask",bindPath:"cullingMask",type:s.Select,...R(d)}),S(M(d))],r.prototype,"cullingMask",2);n([o(E(d)),l({label:"camera.post-process-mask",bindPath:"postProcessMask",type:s.Select,...R(d)}),S(M(d))],r.prototype,"postProcessMask",2);n([o(),l({label:"camera.depth-texture-mode.title",info:"camera.depth-texture-mode.info",bindPath:"depthTextureMode",type:s.Select,options:m(w,void 0,e=>b(`camera.depth-texture-mode.${e.toLowerCase()}`))})],r.prototype,"depthTextureMode",2);n([o(),l({label:"camera.opaque-texture-enabled.title",info:"camera.opaque-texture-enabled.info",bindPath:"opaqueTextureEnabled",type:s.Toggle})],r.prototype,"opaqueTextureEnabled",2);n([o(),l({label:"camera.opaque-texture-down-sampling.title",info:"camera.opaque-texture-down-sampling.info",bindPath:"opaqueTextureDownsampling",type:s.Select,options:m(O,void 0,e=>b(`camera.opaque-texture-down-sampling.${e.toLowerCase()}`)),when:e=>e.opaqueTextureEnabled})],r.prototype,"opaqueTextureDownsampling",2);n([o(),l({label:"camera.anti-aliasing.title",info:"camera.anti-aliasing.info",bindPath:"antiAliasing",type:s.Select,options:m(x,void 0,e=>b(`camera.anti-aliasing.${e.toLowerCase()}`))})],r.prototype,"antiAliasing",2);n([o(),l({label:"camera.msaa-samples.title",info:"camera.msaa-samples.info",bindPath:"msaaSamples",type:s.Select,options:m(A,void 0,e=>b(`camera.msaa-samples.${e.toLowerCase()}`))})],r.prototype,"msaaSamples",2);n([o(),l({label:"camera.enable-hdr.title",info:"camera.enable-hdr.info",bindPath:"enableHDR",type:s.Toggle})],r.prototype,"enableHDR",2);n([o(),l({label:"camera.enable-post-process.title",info:"camera.enable-post-process.info",bindPath:"enablePostProcess",type:s.Toggle})],r.prototype,"enablePostProcess",2);n([o(),l({label:"camera.is-alpha-output-required.title",info:"camera.is-alpha-output-required.info",bindPath:"isAlphaOutputRequired",type:s.Toggle})],r.prototype,"isAlphaOutputRequired",2);n([l({label:"camera.render-target.title",type:s.AssetPicker,assetType:"RenderTarget",onChange:async(e,i,a)=>{var u;const p=e._lastRTAsset;p&&!a&&D(()=>{var f;p.thumbnailUrl="",(f=p.subAssets)==null||f.forEach(_=>{_.thumbnailUrl=""})}),e._lastRTAsset=a??null,e.renderTarget=a?a.getCurrentRef():null,await e.applyBoundPathChange("renderTarget",s.AssetPicker,e.renderTarget);const c=e.root.projectStore.currentViewport.previewManager;c.hasUserRT=!!a;const h=e.engineObject;a?(h.enabled=!0,a.updateThumbnail(),(u=a.subAssets)==null||u.forEach(f=>f.updateThumbnail())):c.isPreviewOn||(h.enabled=!1)}}),o()],r.prototype,"renderTarget",2);r=n([B({type:"Camera",componentsMenu:{label:"component.camera.title"}})],r);export{r as CameraComponent};
1
+ var v=Object.defineProperty;var q=(e,i,a)=>i in e?v(e,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[i]=a;var t=(e,i,a)=>(q(e,typeof i!="symbol"?i+"":i,a),a);import{L as g,a as y,E as k,V as L,b as C,d as P,D as w,c as O,A as x,M as A,C as s,s as o,p as l,t as m,e as b,l as E,g as R,f as S,h as M,r as D,S as j}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{c as B}from"./Component-85241517.js";var F=Object.defineProperty,z=Object.getOwnPropertyDescriptor,n=(e,i,a,p)=>{for(var c=p>1?void 0:p?z(i,a):i,h=e.length-1,u;h>=0;h--)(u=e[h])&&(c=(p?u(i,a,c):u(c))||c);return p&&c&&F(i,a,c),c};const d=[...Object.values(g),y.Nothing,y.Everything];class T extends j{constructor(){super(...arguments);t(this,"_originalMask");t(this,"_onEndRenderOnce",null)}onBeginRender(a){this._originalMask=a.cullingMask,a.cullingMask&=~(g.Viewport|g.Outline|g.NavigationGizmo|g.Gizmo)}onEndRender(a){if(a.cullingMask=this._originalMask,this._onEndRenderOnce){const p=this._onEndRenderOnce;this._onEndRenderOnce=null,p(a)}}executeAfterRender(a){this._onEndRenderOnce=a}}let r=class extends k{constructor(){super(...arguments);t(this,"_lastRTAsset",null);t(this,"isOrthographic",!1);t(this,"nearClipPlane",.1);t(this,"farClipPlane",100);t(this,"fieldOfView",45);t(this,"orthographicSize",10);t(this,"viewport",new L(0,0,1,1));t(this,"priority",0);t(this,"enableFrustumCulling",!0);t(this,"clearFlags",C.All);t(this,"cullingMask",P(y.Everything,d));t(this,"postProcessMask",P(y.Everything,d));t(this,"depthTextureMode",w.None);t(this,"opaqueTextureEnabled",!1);t(this,"opaqueTextureDownsampling",O.TwoX);t(this,"antiAliasing",x.None);t(this,"msaaSamples",A.FourX);t(this,"enableHDR",!1);t(this,"enablePostProcess",!0);t(this,"isAlphaOutputRequired",!1);t(this,"renderTarget",null)}onEnabled(){this.applyBoundPathChange("enabled",s.Toggle,!1)}onInitComplete(){this._attachEditorCameraBridge(),this.renderTarget||this.applyBoundPathChange("enabled",s.Toggle,!1)}_attachEditorCameraBridge(){let i=this.engineObject.entity.getComponent(T);if(i||(i=this.engineObject.entity.addComponent(T)),this.renderTarget){const a=this.root.assetStore.getAsset(this.renderTarget.refId);a&&(this._lastRTAsset=a,i&&i.executeAfterRender(()=>{var p;a.updateThumbnail(),(p=a.subAssets)==null||p.forEach(c=>c.updateThumbnail())}))}}rebindEngineObject(i){super.rebindEngineObject(i),this._attachEditorCameraBridge()}};n([o(),l({label:"camera.is-orthographic",bindPath:"isOrthographic"})],r.prototype,"isOrthographic",2);n([o(),l({label:"camera.near-clip-plane",bindPath:"nearClipPlane"})],r.prototype,"nearClipPlane",2);n([o(),l({label:"camera.far-clip-plane",bindPath:"farClipPlane"})],r.prototype,"farClipPlane",2);n([o(),l({label:"camera.field-of-view",bindPath:"fieldOfView",when:e=>!e.isOrthographic})],r.prototype,"fieldOfView",2);n([o(),l({label:"camera.orthographic-size",bindPath:"orthographicSize",when:e=>e.isOrthographic})],r.prototype,"orthographicSize",2);n([o(),l({type:s.Vector4,min:0,max:1,label:"camera.viewport.title",bindPath:"viewport"})],r.prototype,"viewport",2);n([o(),l({label:"camera.priority.title",bindPath:"priority"})],r.prototype,"priority",2);n([o(),l({label:"camera.enable-frustum-culling",bindPath:"enableFrustumCulling"})],r.prototype,"enableFrustumCulling",2);n([o(),l({label:"camera.clear-flags.title",bindPath:"clearFlags",type:s.Select,options:m(C,void 0,e=>b(`camera.clear-flags.${e.toLocaleLowerCase()}`))})],r.prototype,"clearFlags",2);n([o(E(d)),l({label:"camera.culling-mask",bindPath:"cullingMask",type:s.Select,...R(d)}),S(M(d))],r.prototype,"cullingMask",2);n([o(E(d)),l({label:"camera.post-process-mask",bindPath:"postProcessMask",type:s.Select,...R(d)}),S(M(d))],r.prototype,"postProcessMask",2);n([o(),l({label:"camera.depth-texture-mode.title",info:"camera.depth-texture-mode.info",bindPath:"depthTextureMode",type:s.Select,options:m(w,void 0,e=>b(`camera.depth-texture-mode.${e.toLowerCase()}`))})],r.prototype,"depthTextureMode",2);n([o(),l({label:"camera.opaque-texture-enabled.title",info:"camera.opaque-texture-enabled.info",bindPath:"opaqueTextureEnabled",type:s.Toggle})],r.prototype,"opaqueTextureEnabled",2);n([o(),l({label:"camera.opaque-texture-down-sampling.title",info:"camera.opaque-texture-down-sampling.info",bindPath:"opaqueTextureDownsampling",type:s.Select,options:m(O,void 0,e=>b(`camera.opaque-texture-down-sampling.${e.toLowerCase()}`)),when:e=>e.opaqueTextureEnabled})],r.prototype,"opaqueTextureDownsampling",2);n([o(),l({label:"camera.anti-aliasing.title",info:"camera.anti-aliasing.info",bindPath:"antiAliasing",type:s.Select,options:m(x,void 0,e=>b(`camera.anti-aliasing.${e.toLowerCase()}`))})],r.prototype,"antiAliasing",2);n([o(),l({label:"camera.msaa-samples.title",info:"camera.msaa-samples.info",bindPath:"msaaSamples",type:s.Select,options:m(A,void 0,e=>b(`camera.msaa-samples.${e.toLowerCase()}`))})],r.prototype,"msaaSamples",2);n([o(),l({label:"camera.enable-hdr.title",info:"camera.enable-hdr.info",bindPath:"enableHDR",type:s.Toggle})],r.prototype,"enableHDR",2);n([o(),l({label:"camera.enable-post-process.title",info:"camera.enable-post-process.info",bindPath:"enablePostProcess",type:s.Toggle})],r.prototype,"enablePostProcess",2);n([o(),l({label:"camera.is-alpha-output-required.title",info:"camera.is-alpha-output-required.info",bindPath:"isAlphaOutputRequired",type:s.Toggle})],r.prototype,"isAlphaOutputRequired",2);n([l({label:"camera.render-target.title",type:s.AssetPicker,assetType:"RenderTarget",onChange:async(e,i,a)=>{var u;const p=e._lastRTAsset;p&&!a&&D(()=>{var f;p.thumbnailUrl="",(f=p.subAssets)==null||f.forEach(_=>{_.thumbnailUrl=""})}),e._lastRTAsset=a??null,e.renderTarget=a?a.getCurrentRef():null,await e.applyBoundPathChange("renderTarget",s.AssetPicker,e.renderTarget);const c=e.root.projectStore.currentViewport.previewManager;c.hasUserRT=!!a;const h=e.engineObject;a?(h.enabled=!0,a.updateThumbnail(),(u=a.subAssets)==null||u.forEach(f=>f.updateThumbnail())):c.isPreviewOn||(h.enabled=!1)}}),o()],r.prototype,"renderTarget",2);r=n([B({type:"Camera",componentsMenu:{label:"component.camera.title"}})],r);export{r as CameraComponent};
@@ -1 +1 @@
1
- import{E as r}from"./index-d497fb6d.js";function a(e){return function(n){e.class=n,e.componentsMenu={label:e.type,...e.componentsMenu},e.refMap=new Set,e.external=e.external??!1,r.registerComponent(e.type,e)}}export{a as c};
1
+ import{E as r}from"./index-eeedc550.js";function a(e){return function(n){e.class=n,e.componentsMenu={label:e.type,...e.componentsMenu},e.refMap=new Set,e.external=e.external??!1,r.registerComponent(e.type,e)}}export{a as c};
@@ -1 +1 @@
1
- var g=Object.defineProperty;var y=(e,a,o)=>a in e?g(e,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[a]=o;var r=(e,a,o)=>(y(e,typeof a!="symbol"?a+"":a,o),o);import{i as f,e as m,p,C as i,t as b,s as l,v as c}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import{c as P}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";import{L as N}from"./LightBaseComponent-948d3192.js";var u=Object.defineProperty,S=Object.getOwnPropertyDescriptor,h=(e,a,o,n)=>{for(var t=n>1?void 0:n?S(a,o):a,d=e.length-1,w;d>=0;d--)(w=e[d])&&(t=(n?w(a,o,t):w(t))||t);return n&&t&&u(a,o,t),t};let s=class extends N{constructor(a,o){super(a,o);r(this,"shadowType",f.None);r(this,"shadowBias",1);r(this,"shadowNormalBias",1);r(this,"shadowNearPlaneOffset",.1);r(this,"shadowStrength",1);this.formSchema.addGroup(m("light.shadow.title"),["shadowType","shadowBias","shadowNormalBias","shadowNearPlaneOffset","shadowStrength"],{collapsible:!1})}};h([p({type:i.Select,options:b(f,void 0,e=>m(`light.shadow.type.${e.toLowerCase()}`)),bindPath:"shadowType",property:"shadowType",label:"light.shadow.type.label",info:"light.shadow.type.info"}),l(),c()],s.prototype,"shadowType",2);h([p({type:i.Number,bindPath:"shadowBias",property:"shadowBias",dragStep:.01,label:"light.shadow.bias.label",info:"light.shadow.bias.info"}),l()],s.prototype,"shadowBias",2);h([p({type:i.Number,bindPath:"shadowNormalBias",property:"shadowNormalBias",dragStep:.01,label:"light.shadow.normal-bias.label",info:"light.shadow.normal-bias.info"}),l()],s.prototype,"shadowNormalBias",2);h([p({type:i.Number,bindPath:"shadowNearPlaneOffset",property:"shadowNearPlaneOffset",dragStep:.01,label:"light.shadow.near-plane-offset.label",info:"light.shadow.near-plane-offset.info"}),l()],s.prototype,"shadowNearPlaneOffset",2);h([p({type:i.Slider,bindPath:"shadowStrength",property:"shadowStrength",min:0,max:1,dragStep:.01,label:"light.shadow.strength.label",info:"light.shadow.strength.info"}),l()],s.prototype,"shadowStrength",2);s=h([P({type:"DirectLight",componentsMenu:{group:"light",label:"component.light.direct.title"}})],s);export{s as DirectLightComponent};
1
+ var g=Object.defineProperty;var y=(e,a,o)=>a in e?g(e,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[a]=o;var r=(e,a,o)=>(y(e,typeof a!="symbol"?a+"":a,o),o);import{i as f,e as m,p,C as i,t as b,s as l,v as c}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{c as P}from"./Component-85241517.js";import{L as N}from"./LightBaseComponent-6817bd8c.js";var u=Object.defineProperty,S=Object.getOwnPropertyDescriptor,h=(e,a,o,n)=>{for(var t=n>1?void 0:n?S(a,o):a,d=e.length-1,w;d>=0;d--)(w=e[d])&&(t=(n?w(a,o,t):w(t))||t);return n&&t&&u(a,o,t),t};let s=class extends N{constructor(a,o){super(a,o);r(this,"shadowType",f.None);r(this,"shadowBias",1);r(this,"shadowNormalBias",1);r(this,"shadowNearPlaneOffset",.1);r(this,"shadowStrength",1);this.formSchema.addGroup(m("light.shadow.title"),["shadowType","shadowBias","shadowNormalBias","shadowNearPlaneOffset","shadowStrength"],{collapsible:!1})}};h([p({type:i.Select,options:b(f,void 0,e=>m(`light.shadow.type.${e.toLowerCase()}`)),bindPath:"shadowType",property:"shadowType",label:"light.shadow.type.label",info:"light.shadow.type.info"}),l(),c()],s.prototype,"shadowType",2);h([p({type:i.Number,bindPath:"shadowBias",property:"shadowBias",dragStep:.01,label:"light.shadow.bias.label",info:"light.shadow.bias.info"}),l()],s.prototype,"shadowBias",2);h([p({type:i.Number,bindPath:"shadowNormalBias",property:"shadowNormalBias",dragStep:.01,label:"light.shadow.normal-bias.label",info:"light.shadow.normal-bias.info"}),l()],s.prototype,"shadowNormalBias",2);h([p({type:i.Number,bindPath:"shadowNearPlaneOffset",property:"shadowNearPlaneOffset",dragStep:.01,label:"light.shadow.near-plane-offset.label",info:"light.shadow.near-plane-offset.info"}),l()],s.prototype,"shadowNearPlaneOffset",2);h([p({type:i.Slider,bindPath:"shadowStrength",property:"shadowStrength",min:0,max:1,dragStep:.01,label:"light.shadow.strength.label",info:"light.shadow.strength.info"}),l()],s.prototype,"shadowStrength",2);s=h([P({type:"DirectLight",componentsMenu:{group:"light",label:"component.light.direct.title"}})],s);export{s as DirectLightComponent};
@@ -1,4 +1,4 @@
1
- var d=Object.defineProperty;var u=(s,e,t)=>e in s?d(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(u(s,typeof e!="symbol"?e+"":e,t),t);import{bU as m,b$ as y,c0 as h,c1 as b,b_ as w,aJ as v,aL as x,bV as O,O as f,j,Z as F,n as U,e as A,o as R}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";import{A as g}from"./AssetViewer-9f395efb.js";async function L(s){const e={uploadFiles:[],errors:[]};for(const t in s){const n=s[t],r=n.name.toLocaleLowerCase();(r.endsWith(".ttf")||r.endsWith(".otf")||r.endsWith(".woff"))&&e.uploadFiles.push({main:n})}return e}async function _(s){const e=m(s.main,"font.ttf");try{const t=e.name,n=y(t),r=h(t,n),o=await b.uploadBlob(`${t}.json`,e),i={fontName:r,fontUrl:encodeURI(o.url).replace(/\(/g,"%28").replace(/\)/g,"%29")};return new File([JSON.stringify(i)],r)}catch(t){console.error(t),w.error(`parse font file fail ${t}`)}return e}class p extends g{constructor(){super()}setViewAsset(e,t){const n=t.createChild("font_entity"),r=n.addComponent(f);r.font=e.engineObject,r.text=`ABCDEFGHIJKLM
1
+ var d=Object.defineProperty;var u=(s,e,t)=>e in s?d(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(u(s,typeof e!="symbol"?e+"":e,t),t);import{bU as m,b$ as y,c0 as h,c1 as b,b_ as w,aJ as v,aL as x,bV as O,O as f,j,Z as F,n as U,e as A,o as R}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{A as g}from"./AssetViewer-f505fb55.js";async function L(s){const e={uploadFiles:[],errors:[]};for(const t in s){const n=s[t],r=n.name.toLocaleLowerCase();(r.endsWith(".ttf")||r.endsWith(".otf")||r.endsWith(".woff"))&&e.uploadFiles.push({main:n})}return e}async function _(s){const e=m(s.main,"font.ttf");try{const t=e.name,n=y(t),r=h(t,n),o=await b.uploadBlob(`${t}.json`,e),i={fontName:r,fontUrl:encodeURI(o.url).replace(/\(/g,"%28").replace(/\)/g,"%29")};return new File([JSON.stringify(i)],r)}catch(t){console.error(t),w.error(`parse font file fail ${t}`)}return e}class p extends g{constructor(){super()}setViewAsset(e,t){const n=t.createChild("font_entity"),r=n.addComponent(f);r.font=e.engineObject,r.text=`ABCDEFGHIJKLM
2
2
  NOPQRSTUVWXYZ
3
3
  abcdefghijklm
4
4
  nopqrstuvwxyz
@@ -1,4 +1,4 @@
1
- import{bD as d,aH as x,aQ as v,bE as m,av as e,aw as b,ax as f,aI as l,bF as g,aM as i}from"./index-d497fb6d.js";import{A as j,a as I}from"./Accordion-6f002a96.js";/**
1
+ import{bD as d,aH as x,aQ as v,bE as m,av as e,aw as b,ax as f,aI as l,bF as g,aM as i}from"./index-eeedc550.js";import{A as j,a as I}from"./Accordion-6346d8c5.js";/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
@@ -1,4 +1,4 @@
1
- var Vt=Object.defineProperty;var Ft=(e,t,n)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var w=(e,t,n)=>(Ft(e,typeof t!="symbol"?t+"":t,n),n);import{f9 as Dt,aH as Bt,aJ as pt,aL as I,bC as qt,q as mt,aK as Gt,aO as Fe,aw as te,fa as ye,dt as ne,bB as De,aN as Wt,e3 as Be,bU as Ht,u as yt,S as Xt,x as j,aC as G,bs as Kt,fb as Qt,b_ as qe,e as bt,fc as Jt,bY as Yt,ct as Zt,fd as Ge,Z as en,y as We,v as tn,aU as W,aV as nn,n as sn,o as rn,dN as an}from"./index-d497fb6d.js";import{B as N,P,a as A,A as Me,b as $e,K as At,N as on,M as U,E as ae,D as Le,u as be,R as pe,S as ln,T as Ne,c as vt,d as _t,e as Tt,C as cn,f as un,g as fn,G as Ae,h as He,F as hn,i as ve}from"./glTFIO-45ff9a17.js";import{a as oe}from"./meshopt_simplifier.module-cd99529d.js";import{u as Et,I as gn}from"./index-8a22fe59.js";import"./postmen-0413c689.js";import{A as dn}from"./AssetViewer-9f395efb.js";import{M as pn}from"./MaterialAsset-aa93db51.js";import{k as mn}from"./ktx2-encoder-772f6c33.js";function Xe(e){const t=e%4;return t===0?e:e+(4-t)}function yn(e){return e.toLowerCase().endsWith(".png")?"image/png":e.toLowerCase().endsWith(".jpg")||e.toLowerCase().endsWith(".jpeg")?"image/jpeg":e.toLowerCase().endsWith(".webp")?"image/webp":"application/octet-stream"}function wt(e){const{json:t,resources:n}=e,s=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),a=N.pad(N.encodeText(r),32),i=N.toView(new Uint32Array([a.byteLength,1313821514])),o=N.concat([i,a]);s[s.length-1]+=o.byteLength;const l=Object.values(n)[0];if(!l||!l.byteLength)return N.concat([N.toView(s),o]);const f=N.pad(l,0),c=N.toView(new Uint32Array([f.byteLength,5130562])),h=N.concat([c,f]);return s[s.length-1]+=h.byteLength,N.concat([N.toView(s),o,h])}function bn(e){const t=e.json,n=[],s=[];let r=0;function a(h){return h.uri===void 0?void 0:e.resources[h.uri]}const i=t.buffers??[],o=new Map;i.forEach((h,u)=>{const g=a(h);g!==void 0&&(n.push(new Uint8Array(g)),s.push(r),delete h.uri,h.byteLength=g.byteLength,o.set(u,r),r+=Xe(g.byteLength))});let l=i.length;(t.images||[]).forEach(h=>{const u=a(h);if(!u){delete h.uri;return}const g={buffer:0,byteOffset:r,byteLength:u.byteLength};o.set(l++,r),r+=Xe(u.byteLength);const d=t.bufferViews??[];h.bufferView=d.length,h.mimeType=yn(h.uri),delete h.uri,d.push(g),n.push(new Uint8Array(u)),s.push(g.byteOffset)});for(const h of t.bufferViews??[])h.byteOffset=(h.byteOffset??0)+(o.get(h.buffer)??0),h.buffer=0;const c=new Uint8Array(r);return n.forEach((h,u)=>{c.set(h,s[u])}),t.buffers=[{byteLength:r}],wt({json:t,resources:{"buffer.bin":c}})}function An(e){for(var t=new Array(e),n=0;n<e;++n)t[n]=n;return t}var vn=An;/*!
1
+ var Vt=Object.defineProperty;var Ft=(e,t,n)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var w=(e,t,n)=>(Ft(e,typeof t!="symbol"?t+"":t,n),n);import{f9 as Dt,aH as Bt,aJ as pt,aL as I,bC as qt,q as mt,aK as Gt,aO as Fe,aw as te,fa as ye,dt as ne,bB as De,aN as Wt,e3 as Be,bU as Ht,u as yt,S as Xt,x as j,aC as G,bs as Kt,fb as Qt,b_ as qe,e as bt,fc as Jt,bY as Yt,ct as Zt,fd as Ge,Z as en,y as We,v as tn,aU as W,aV as nn,n as sn,o as rn,dN as an}from"./index-eeedc550.js";import{B as N,P,a as A,A as Me,b as $e,K as At,N as on,M as U,E as ae,D as Le,u as be,R as pe,S as ln,T as Ne,c as vt,d as _t,e as Tt,C as cn,f as un,g as fn,G as Ae,h as He,F as hn,i as ve}from"./glTFIO-45ff9a17.js";import{a as oe}from"./meshopt_simplifier.module-cd99529d.js";import{u as Et,I as gn}from"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{A as dn}from"./AssetViewer-f505fb55.js";import{M as pn}from"./MaterialAsset-010030a2.js";import{k as mn}from"./ktx2-encoder-2883b55c.js";function Xe(e){const t=e%4;return t===0?e:e+(4-t)}function yn(e){return e.toLowerCase().endsWith(".png")?"image/png":e.toLowerCase().endsWith(".jpg")||e.toLowerCase().endsWith(".jpeg")?"image/jpeg":e.toLowerCase().endsWith(".webp")?"image/webp":"application/octet-stream"}function wt(e){const{json:t,resources:n}=e,s=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),a=N.pad(N.encodeText(r),32),i=N.toView(new Uint32Array([a.byteLength,1313821514])),o=N.concat([i,a]);s[s.length-1]+=o.byteLength;const l=Object.values(n)[0];if(!l||!l.byteLength)return N.concat([N.toView(s),o]);const f=N.pad(l,0),c=N.toView(new Uint32Array([f.byteLength,5130562])),h=N.concat([c,f]);return s[s.length-1]+=h.byteLength,N.concat([N.toView(s),o,h])}function bn(e){const t=e.json,n=[],s=[];let r=0;function a(h){return h.uri===void 0?void 0:e.resources[h.uri]}const i=t.buffers??[],o=new Map;i.forEach((h,u)=>{const g=a(h);g!==void 0&&(n.push(new Uint8Array(g)),s.push(r),delete h.uri,h.byteLength=g.byteLength,o.set(u,r),r+=Xe(g.byteLength))});let l=i.length;(t.images||[]).forEach(h=>{const u=a(h);if(!u){delete h.uri;return}const g={buffer:0,byteOffset:r,byteLength:u.byteLength};o.set(l++,r),r+=Xe(u.byteLength);const d=t.bufferViews??[];h.bufferView=d.length,h.mimeType=yn(h.uri),delete h.uri,d.push(g),n.push(new Uint8Array(u)),s.push(g.byteOffset)});for(const h of t.bufferViews??[])h.byteOffset=(h.byteOffset??0)+(o.get(h.buffer)??0),h.buffer=0;const c=new Uint8Array(r);return n.forEach((h,u)=>{c.set(h,s[u])}),t.buffers=[{byteLength:r}],wt({json:t,resources:{"buffer.bin":c}})}function An(e){for(var t=new Array(e),n=0;n<e;++n)t[n]=n;return t}var vn=An;/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -1,4 +1,4 @@
1
- import{c as e}from"./createReactComponent-3e49f864.js";/**
1
+ import{c as e}from"./createReactComponent-0c5ada83.js";/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./createReactComponent-3e49f864.js";/**
1
+ import{c as e}from"./createReactComponent-0c5ada83.js";/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
@@ -1 +1 @@
1
- var m=Object.defineProperty;var u=(r,e,o)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(u(r,typeof e!="symbol"?e+"":e,o),o);import{a as n,s as y,aD as v,p as c,C as g,l as P,f as b,h as f,g as C,E as L,d as _}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";var x=Object.defineProperty,O=Object.getOwnPropertyDescriptor,h=(r,e,o,l)=>{for(var a=l>1?void 0:l?O(e,o):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(a=(l?i(e,o,a):i(a))||a);return l&&a&&x(e,o,a),a};const t=[n.Everything,n.Nothing];class d extends L{constructor(){super(...arguments);p(this,"color",{r:1,g:1,b:1,a:1,intensity:1});p(this,"cullingMask",_(n.Everything,t))}}h([y(v()),c({label:"light.color",type:g.Color,mode:"hdr",bindPath:"color"})],d.prototype,"color",2);h([y(P(t)),b(f(t)),c({label:"light.culling-mask",type:g.Select,...C(t),bindPath:"cullingMask"})],d.prototype,"cullingMask",2);export{d as L};
1
+ var m=Object.defineProperty;var u=(r,e,o)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(u(r,typeof e!="symbol"?e+"":e,o),o);import{a as n,s as y,aD as v,p as c,C as g,l as P,f as b,h as f,g as C,E as L,d as _}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";var x=Object.defineProperty,O=Object.getOwnPropertyDescriptor,h=(r,e,o,l)=>{for(var a=l>1?void 0:l?O(e,o):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(a=(l?i(e,o,a):i(a))||a);return l&&a&&x(e,o,a),a};const t=[n.Everything,n.Nothing];class d extends L{constructor(){super(...arguments);p(this,"color",{r:1,g:1,b:1,a:1,intensity:1});p(this,"cullingMask",_(n.Everything,t))}}h([y(v()),c({label:"light.color",type:g.Color,mode:"hdr",bindPath:"color"})],d.prototype,"color",2);h([y(P(t)),b(f(t)),c({label:"light.culling-mask",type:g.Select,...C(t),bindPath:"cullingMask"})],d.prototype,"cullingMask",2);export{d as L};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var c=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(c(o,typeof e!="symbol"?e+"":e,t),t);import{L as g}from"./module-136992e3.js";import{E as b,p as l,C as a,s}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import{c as P}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";var d=Object.defineProperty,L=Object.getOwnPropertyDescriptor,n=(o,e,t,y)=>{for(var i=y>1?void 0:y?L(e,t):e,u=o.length-1,m;u>=0;u--)(m=o[u])&&(i=(y?m(e,t,i):m(i))||i);return y&&i&&d(e,t,i),i};let r=class extends b{constructor(e,t){super(e,t);p(this,"resource",null);p(this,"autoPlay",!0);p(this,"isLooping",!0);p(this,"speed",1);p(this,"priority",0)}};n([l({label:"lottie.resource.label",info:"lottie.resource.info",type:a.AssetPicker,assetType:"Lottie",bindPath:"resource"}),s()],r.prototype,"resource",2);n([l({label:"lottie.auto-play.label",info:"lottie.auto-play.info",type:a.Toggle,bindPath:"autoPlay",onChange(o,e,t){t||o.engineObject.pause()}}),s()],r.prototype,"autoPlay",2);n([l({label:"lottie.is-looping.label",info:"lottie.is-looping.info",type:a.Toggle,bindPath:"isLooping"}),s()],r.prototype,"isLooping",2);n([l({label:"lottie.speed.label",info:"lottie.speed.info",type:a.Number,dragStep:.01,bindPath:"speed"}),s()],r.prototype,"speed",2);n([l({label:"lottie.priority.label",info:"lottie.priority.info",type:a.Number,bindPath:"priority"}),s()],r.prototype,"priority",2);r=n([P({type:"LottieAnimation",external:!0,componentsMenu:{group:"2D",label:"component.lottie-animation.title"}})],r);b.registerCustomEngineComponent("LottieAnimation",g);export{r as LottieAnimationComponent};
1
+ var f=Object.defineProperty;var c=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(c(o,typeof e!="symbol"?e+"":e,t),t);import{L as g}from"./module-ace60695.js";import{E as b,p as l,C as a,s}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{c as P}from"./Component-85241517.js";var d=Object.defineProperty,L=Object.getOwnPropertyDescriptor,n=(o,e,t,y)=>{for(var i=y>1?void 0:y?L(e,t):e,u=o.length-1,m;u>=0;u--)(m=o[u])&&(i=(y?m(e,t,i):m(i))||i);return y&&i&&d(e,t,i),i};let r=class extends b{constructor(e,t){super(e,t);p(this,"resource",null);p(this,"autoPlay",!0);p(this,"isLooping",!0);p(this,"speed",1);p(this,"priority",0)}};n([l({label:"lottie.resource.label",info:"lottie.resource.info",type:a.AssetPicker,assetType:"Lottie",bindPath:"resource"}),s()],r.prototype,"resource",2);n([l({label:"lottie.auto-play.label",info:"lottie.auto-play.info",type:a.Toggle,bindPath:"autoPlay",onChange(o,e,t){t||o.engineObject.pause()}}),s()],r.prototype,"autoPlay",2);n([l({label:"lottie.is-looping.label",info:"lottie.is-looping.info",type:a.Toggle,bindPath:"isLooping"}),s()],r.prototype,"isLooping",2);n([l({label:"lottie.speed.label",info:"lottie.speed.info",type:a.Number,dragStep:.01,bindPath:"speed"}),s()],r.prototype,"speed",2);n([l({label:"lottie.priority.label",info:"lottie.priority.info",type:a.Number,bindPath:"priority"}),s()],r.prototype,"priority",2);r=n([P({type:"LottieAnimation",external:!0,componentsMenu:{group:"2D",label:"component.lottie-animation.title"}})],r);b.registerCustomEngineComponent("LottieAnimation",g);export{r as LottieAnimationComponent};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var u=(e,t,o)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>(u(e,typeof t!="symbol"?t+"":t,o),o);import{j as d,u as m,w as b,x as h,n as w,e as f,o as y}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";var v=Object.defineProperty,D=Object.getOwnPropertyDescriptor,l=(e,t,o,r)=>{for(var n=r>1?void 0:r?D(t,o):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(n=(r?a(t,o,n):a(n))||n);return r&&n&&v(t,o,n),n};let i=class extends d{constructor(t){super(t);p(this,"content","");m(this),this.onDoubleClick=this.onDoubleClick.bind(this)}async initByMain(t){this.content=await t.text()}async initByCreation(){return""}getMainData(){return this.content}onDoubleClick(){b(this.root.projectStore.id,this.id)}};l([h],i.prototype,"content",2);i=l([w({type:"Markdown",label:f("asset.markdown.title"),defaultName:"Document.md",extname:"md",importMenuConfig:{type:y.Add},bundle({content:e}){return{content:new Blob([e],{type:"text/markdown; charset=utf-8"})}}})],i);export{i as MarkdownAsset};
1
+ var c=Object.defineProperty;var u=(e,t,o)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>(u(e,typeof t!="symbol"?t+"":t,o),o);import{j as d,u as m,w as b,x as h,n as w,e as f,o as y}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";var v=Object.defineProperty,D=Object.getOwnPropertyDescriptor,l=(e,t,o,r)=>{for(var n=r>1?void 0:r?D(t,o):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(n=(r?a(t,o,n):a(n))||n);return r&&n&&v(t,o,n),n};let i=class extends d{constructor(t){super(t);p(this,"content","");m(this),this.onDoubleClick=this.onDoubleClick.bind(this)}async initByMain(t){this.content=await t.text()}async initByCreation(){return""}getMainData(){return this.content}onDoubleClick(){b(this.root.projectStore.id,this.id)}};l([h],i.prototype,"content",2);i=l([w({type:"Markdown",label:f("asset.markdown.title"),defaultName:"Document.md",extname:"md",importMenuConfig:{type:y.Add},bundle({content:e}){return{content:new Blob([e],{type:"text/markdown; charset=utf-8"})}}})],i);export{i as MarkdownAsset};
@@ -1 +1 @@
1
- var N=Object.defineProperty;var $=(p,t,e)=>t in p?N(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var f=(p,t,e)=>($(p,typeof t!="symbol"?t+"":t,e),e);import{y as j,bG as F,bH as V,bI as U,F as G,ai as K,V as z,b4 as H,b3 as b,j as Q,q as k,u as W,bJ as D,bK as A,a1 as m,a2 as T,bL as J,C as O,bM as w,bN as Y,aE as S,bO as q,e as E,bP as X,K as Z,ae as ee,ah as te,af as C,R as v,_ as ae,z as re,x as L,aC as _,n as se,o as ie}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";import{M as ne}from"./MaterialInspector-45e208c7.js";import{A as oe}from"./AssetViewer-9f395efb.js";import{E as g,s as x}from"./shader-data-utils-e38a959d.js";class he extends oe{constructor(){super(...arguments);f(this,"_sphereRenderer",null);f(this,"_particleRenderer",null);f(this,"_asset",null);f(this,"_shaderReactionDisposer",null);f(this,"onShaderChange",()=>{const{_asset:e}=this;e.engineObject.shader.name==="Effect/Particle"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(e.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(e.engineObject))})}setViewAsset(e,r){if(!(e instanceof y))return;const i=r.createChild("material");this._asset=e;const a=this._sphereRenderer=i.createChild("mat").addComponent(j);a.mesh=F.createSphere(r.engine,1,32,!0);const n=this._particleRenderer=i.createChild("pat").addComponent(V);n.generator.main.duration=1e3,n.generator.main.startSpeed.constant=0,this._entity=i,r.addChild(this._entity),this.onShaderChange(),this._shaderReactionDisposer=U(()=>{var o,l;return(l=(o=this._asset)==null?void 0:o.shaderRef)==null?void 0:l.refId},()=>{this.onShaderChange()})}stopViewAsset(){var e;super.stopViewAsset(),(e=this._shaderReactionDisposer)==null||e.call(this),this._shaderReactionDisposer=null,this._asset=null}}class P{static update(t,e){if(!(e instanceof y))return;const r=e.engineObject;if(!r||!r.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(t),r.shader.name==="Effect/Particle"?(this.sphereRenderer.entity.isActive=!1,this.particleRenderer.entity.isActive=!0,this.particleRenderer.setMaterial(r),this.particleRenderer.generator._playTime=5):(this.particleRenderer.entity.isActive=!1,this.sphereRenderer.entity.isActive=!0,this.sphereRenderer.setMaterial(r))}static clear(){var t,e;(t=this.sphereRenderer)!=null&&t.entity&&(this.sphereRenderer.entity.isActive=!1),(e=this.particleRenderer)!=null&&e.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(t){const e=this.entity=t.createChild("material"),r=this.sphereRenderer=e.createChild("mat").addComponent(j);r.mesh=F.createSphere(t.engine,2,64,!0),this.particleRenderer=e.createChild("pat").addComponent(V),this.particleRenderer.bounds.max.set(.5,.5,.5),this.particleRenderer.bounds.min.set(-.5,-.5,-.5)}}f(P,"entity",null),f(P,"sphereRenderer",null),f(P,"particleRenderer",null);function B(p){return p instanceof G?{x:p.x,y:p.y}:p instanceof K?{x:p.x,y:p.y,z:p.z}:p instanceof z?{x:p.x,y:p.y,z:p.z,w:p.w}:p instanceof H?{r:p.r,g:p.g,b:p.b,a:p.a}:p}function pe(p){switch(p){case b.Color:return"Color";case b.Float:return"Float";case b.Int:return"Integer";case b.Matrix:return"Matrix";case b.Texture:return"Texture";case b.TextureArray:return"TextureArray";case b.Vector2:return"Vector2";case b.Vector3:return"Vector3";case b.Vector4:return"Vector4"}}var ce=Object.defineProperty,de=Object.getOwnPropertyDescriptor,I=(p,t,e,r)=>{for(var i=r>1?void 0:r?de(t,e):t,a=p.length-1,n;a>=0;a--)(n=p[a])&&(i=(r?n(t,e,i):n(i))||i);return r&&i&&ce(t,e,i),i};let y=class extends Q{constructor(t){super(t);f(this,"acceptDragLayer",k.Texture);f(this,"shaderRef",{refId:null});f(this,"shaderDataKeys",new Set);f(this,"formConfig",null);f(this,"_autoSaveSuppressed",!1);W(this),D(this,{proxyConfigs:[]})}static initBuiltinMaterial(t,e){t.shader=e;const r=t.shaderData;switch(r.disableMacro("MATERIAL_NEED_WORLD_POS"),r.disableMacro("MATERIAL_OMIT_NORMAL"),r.disableMacro("MATERIAL_NEED_TILING_OFFSET"),r.disableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.name){case"Unlit":r.enableMacro("MATERIAL_OMIT_NORMAL"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"PBR":case"bake-pbr":case"BlinnPhong":r.enableMacro("MATERIAL_NEED_WORLD_POS"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"Sky/SkyProcedural":r.enableMacro("MATERIAL_SUN_HIGH_QUALITY");break;case"Effect/Particle":r.enableMacro("MATERIAL_OMIT_NORMAL");break}}setAutoSaveSuppressed(t){this._autoSaveSuppressed=t}setRenderQueueType(t){this.engineObject.shaderData.setInt("renderQueueType",t)}setBlendStateEnabled(t){this.engineObject.shaderData.setInt("blendEnabled",t?1:0)}setDepthWriteEnabled(t){this.engineObject.shaderData.setInt("depthWriteEnabled",t?1:0)}setCullMode(t){this.engineObject.shaderData.setInt("rasterStateCullMode",t)}setBlendMode(t){const e=this.engineObject.shaderData;switch(t){case A.Normal:e.setInt("sourceColorBlendFactor",m.SourceAlpha),e.setInt("destinationColorBlendFactor",m.OneMinusSourceAlpha),e.setInt("sourceAlphaBlendFactor",m.One),e.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),e.setInt("colorBlendOperation",T.Add),e.setInt("alphaBlendOperation",T.Add);break;case A.Additive:e.setInt("sourceColorBlendFactor",m.SourceAlpha),e.setInt("destinationColorBlendFactor",m.One),e.setInt("sourceAlphaBlendFactor",m.One),e.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),e.setInt("colorBlendOperation",T.Add),e.setInt("alphaBlendOperation",T.Add);break}}bindShaderAsset(t,e){for(const r of this.shaderDataKeys)this.removePropertyChangeListener(r);return this.shaderDataKeys.clear(),t.onReady().then(async()=>{var i;if(this.isInitCompleted){if(t.shaderScriptRefId){const a=this.root.assetStore.getAsset(t.shaderScriptRefId.refId);a==null||a.onShaderChange(this._engineObject)}else t.builtinUIScript&&t.builtinUIScript.onMaterialShaderSwitched(this._engineObject);e=this._getMainData()}const r=t.properties?J(t.properties):[];t.isBuiltinShader()&&y.initBuiltinMaterial(this.engineObject,t.engineObject),e=e||this._getMainData(),await this._proxyShaderProps(r,e,this.isInitCompleted),this.refreshFormConfig(r,e),this.refreshAnimatableProperties(r),this.shaderRef&&this.root.assetStore.getAssetByRef(this.shaderRef).then(a=>{a!==t&&(a==null||a.removeReferencedMaterial(this))}).catch(()=>{}),t.addReferencedMaterial(this),this.shaderRef={refId:t.id},await this.applyBoundPathChange("shader",O.AssetPicker,this.shaderRef),(i=this.updateThumbnail)==null||i.call(this)})}async _proxyShaderProps(t,e,r=!0){var n;this.proxyConfigs=t;const i=(n=this.extraData)==null?void 0:n.disabledMacros,a=t.map(async o=>{var l;if(this.proxySetter(o),this._virualShaderProps(t),o.bundleType==="macro"){const s=o.macroInfo,h=e.macros.find(c=>c.name===o.prop);if(!w(this,o.prop)){let c;h!=null?(c=h.value,s&&(s.checked=!0)):i!=null&&i.includes(o.prop)?(c=void 0,s&&(s.checked=!1)):c=o.defaultValue,D(this,{[o.prop]:c})}if(r)if(h){const c=h.value??o.defaultValue;c==null?s==null||s.onSwitch(!0,this):await o.onChange(this,o.prop,c)}else!(i!=null&&i.includes(o.prop))&&(s!=null&&s.checked)&&(s==null||s.onSwitch(!0,this))}else{const s=e.shaderData[o.prop];let h=s?s.value:this[o.prop]??o.defaultValue;if(h!=null&&h.refId&&!this.root.assetStore.assets[h.refId]&&(h=void 0),((l=o.uiInfo)==null?void 0:l.type)===g.Color)if(o.uiInfo.mode==="hdr"){const c=h.intensity??1;c!==0&&(h.r/=c,h.g/=c,h.b/=c),h.intensity=c}else h.intensity=1;w(this,o.prop)||D(this,{[o.prop]:h}),r&&this.notifyPropertyChange(o.prop,!1)}});await Promise.all(a)}proxySetter(t){const{prop:e,onChange:r,bundleType:i}=t,a=async(n,o)=>{var s;const l=this._engineObject.shaderData;i==="macro"?l.enableMacro(e,n):await x(this,e,n,t.engineType??((s=t.uiInfo)==null?void 0:s.type)),await r(this,e,n),o!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(e,a),this.shaderDataKeys.add(e)}_virualShaderProps(t){const e=this;t.forEach(r=>{Y(e,r.prop)})}refreshFormConfig(t,e){var i,a,n,o,l;const r={root:[],groups:{}};if(e){for(const s of t)if(!((i=s.uiInfo)!=null&&i.hide)){if((a=s.uiInfo)!=null&&a.group){if((n=s.uiInfo)!=null&&n.group){let h=r.groups[s.uiInfo.group];h||(h={type:O.Group,property:s.uiInfo.group,children:[]},r.groups[s.uiInfo.group]=h);const c=s.uiInfo;c.property=s.prop,s.macroInfo&&(c.macroConfig=s.macroInfo),h.children.push(c)}}else{const h=s.uiInfo;h.property=s.prop,s.macroInfo&&(h.macroConfig=s.macroInfo),r.root.push(h)}s.bundleType==="macro"?this[s.prop]=((o=e.macros.find(h=>h.name===s.prop))==null?void 0:o.value)??s.defaultValue:this[s.prop]=((l=e.shaderData[s.prop])==null?void 0:l.value)??s.defaultValue}}this.formConfig=r}refreshAnimatableProperties(t){var e,r,i;this._additionAnimatableProperties.length=0;for(const a of t){if(!a.uiInfo||a.uiInfo.hide||a.bundleType==="macro")continue;let n={};if((a.setPath||a.getPath||a.valueType||a.interpolationType)&&(n={setPath:a.setPath,getPath:a.getPath,valueType:a.valueType,interpolationType:a.interpolationType}),!n.setPath&&!n.getPath&&a.engineType&&(a.bundleType==="shaderData"||!a.bundleType))switch(a.engineType){case g.Float:n={setPath:`shaderData.setFloat('${a.prop}', $value)`,getPath:`shaderData.getFloat('${a.prop}')`,valueType:S.Float};break;case g.Integer:n={setPath:`shaderData.setInt('${a.prop}', $value)`,getPath:`shaderData.getInt('${a.prop}')`,valueType:S.Float,interpolationType:q.Step};break;case g.Vector2:n={setPath:`shaderData.getVector2('${a.prop}')`,getPath:`shaderData.getVector2('${a.prop}')`,valueType:S.Vector2};break;case g.Vector3:n={setPath:`shaderData.getVector3('${a.prop}')`,getPath:`shaderData.getVector3('${a.prop}')`,valueType:S.Vector3};break;case g.Vector4:n={setPath:`shaderData.getVector4('${a.prop}')`,getPath:`shaderData.getVector4('${a.prop}')`,valueType:S.Vector4};break;case g.Color:n={setPath:`shaderData.getColor('${a.prop}')`,getPath:`shaderData.getColor('${a.prop}')`,valueType:S.Color};break;case g.Boolean:n={setPath:`shaderData.setBoolean('${a.prop}', $value)`,getPath:`shaderData.getBoolean('${a.prop}')`,valueType:S.Boolean};break;case g.Texture:n={setPath:`shaderData.setTexture('${a.prop}', $value)`,getPath:`shaderData.getTexture('${a.prop}')`,valueType:S.ReferResource};break}if(!n.setPath&&!n.getPath){if(a.bundleType==="other")continue;continue}this._additionAnimatableProperties.push({property:a.prop,label:(e=a.uiInfo)!=null&&e.label?E(a.uiInfo.label):a.prop,type:(r=a.uiInfo)==null?void 0:r.type,propertyProxyConfig:n}),(i=a.uiInfo)!=null&&i.label&&(n.label=E(a.uiInfo.label)),X(this,a.prop,n)}}async initByMain(t){var c;const e=JSON.parse(await t.text());let r=e.shaderRef;const i=e.shaderData,a=e.macros;if(!r&&typeof e.shader=="string"){const d=Object.values(this.root.assetStore.assets).find(u=>u.meta.type==="Shader"&&u.meta.builtinShaderName===e.shader);d&&(r={refId:d.id})}if(!r)throw"invalid material";this.shaderRef=r;const n=new Z(this.engine);this.setDragTempEntity(n);const o=await this.root.assetStore.getAssetByRef(r),l=o.engineObject??ee.find("Unlit"),s=new te(this.engine,l);this.bindEngineObject(s);const h=s.shaderData;if(a)for(const d of a)h.enableMacro(d.name,d.value);if(i)for(const d in i){const u=i[d];let R=u.value;if(u.type===g.Color){R={...u.value};const M=u.value.intensity??1;M!==0&&(R.r/=M,R.g/=M,R.b/=M)}x(this,d,R,u.type)}await this.bindShaderAsset(o,e),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",O.Input,this.name),this._checkSchemaOnInit(e,o)}_checkSchemaOnInit(t,e){t.shader!==e.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(t){const e=this;this.bindEngineObject(t),e.shader=t.shader.name,e._name=t.name??"";const i=Object.values(this.root.assetStore.assets).filter(h=>h.meta.type==="Shader"&&!!h.meta.builtinShaderName).find(h=>h.meta.builtinShaderName===t.shader.name);this.shaderRef={refId:i.id};const a=t.shaderData,n=new Set((i.properties??[]).map(h=>h.prop));if(n.has("isTransparent")&&(e.isTransparent=a.getInt("blendEnabled")===1),n.has("material_AlphaCutoff")&&(e.alphaCutoff=a.getFloat("material_AlphaCutoff")),n.has("renderFace"))switch(a.getInt("rasterStateCullMode")){case C.Back:e.renderFace=v.Front;break;case C.Front:e.renderFace=v.Back;break;case C.Off:e.renderFace=v.Double;break}n.has("blendMode")&&(e.blendMode=a.getInt("destinationColorBlendFactor")===m.One?A.Additive:A.Normal),a.getProperties().forEach(h=>{const c=a.getPropertyValue(h);if(c instanceof ae){const d=this.root.assetStore.engineObjectToAssetMap.get(c);this[h.name]=d==null?void 0:d.getCurrentRef()}else this[h.name]=B(c)});const l=this._getMainData(),s=i.properties?[...i.properties]:[];this._proxyShaderProps(s,l,!1),this.bindShaderAsset(i,l)}afterDelete(){var t;(t=this.engineObject)==null||t.destroy(!0)}rename(t){return this.root.assetFacade.persistAssetMain(this.id),super.rename(t)}_getMainData(t){var s,h,c;const e=[],r=(t??this.engineObject).shaderData;r.getMacros(e);const i=e.map(({name:d,value:u})=>u===void 0?{name:d}:{name:d,value:u}),a=[],n={};r.getProperties(a);for(const d of a){let u;if(d.type===b.Texture||d.type===b.TextureArray)u=this[d.name];else{const R=r.getPropertyValue(d);u=B(R),((s=this[d.name])==null?void 0:s.intensity)!=null&&(u.intensity=(h=this[d.name])==null?void 0:h.intensity)}u!=null&&(n[d.name]={type:pe(d.type),value:u})}const o=(c=this.shaderRef)!=null&&c.refId?this.root.assetStore.getAsset(this.shaderRef.refId):void 0,l=!!(o!=null&&o.builtinShaderName);return{name:this.name,shader:this.engineObject.shader.name,macros:i,shaderData:n,...l?{}:{shaderRef:this.shaderRef}}}getMainData(){return JSON.stringify(this._getMainData())}async initByCreation(){var l;const t=new re(this.engine),e=[];t.shaderData.getMacros(e);const r=e.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h});this.bindEngineObject(t);const i=this.root.assetStore.getAsset("0000501"),a=i!=null&&i.properties?[...i.properties]:[],n={};for(const s of a)s.defaultValue&&(n[s.prop]={value:s.defaultValue,type:s.engineType??((l=s.uiInfo)==null?void 0:l.type)});const o={shaderData:n,name:this.name,shader:t.shader.name,macros:r};return this._proxyShaderProps(a,o,!1),o}async onSubAssetEdit(){var i;const t=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(t.engineObject),await t.applyBoundPathChange("name",O.Input,t.name),t.initByEngineObject(t.engineObject),t.updateThumbnail(),await this.root.assetFacade.persistAssetMain(t.id);const e=await this.root.assetStore.getAssetByRef({refId:this.mainId}),r=((i=e.engineObject.materials)==null?void 0:i.indexOf(this._engineObject))??-1;r>=0&&await e.replaceMaterial(r,t.getCurrentRef()),this.root.assetStore.selectAsset(t.id)}saveMainImmediately(t){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately(t).then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}async _onDrop(t,e){var i,a;const r="material_BaseTexture";if(r in this){const n=e.getCurrentRef();this[r]=n;const o=this.root.assetStore.getAsset((i=this.shaderRef)==null?void 0:i.refId),l=(a=o==null?void 0:o.properties)==null?void 0:a.find(s=>s.prop===r);l&&await l.onChange(this,r,n),await this.root.assetFacade.persistAssetMain(this.id)}this.dropping=!1}async onDropToViewport(){const{sceneStore:t,sceneUIStore:e}=this.root,r=e.hoveredEntityId;if(r){const i=t.getEntityModel(r);if(i){const a=i.getComponentByTypeName("MeshRenderer"),n=i.getComponentByTypeName("SkinnedMeshRenderer"),o=a||n;o&&this.root.componentFacade.updateComponent(i.id,o.id,{material:this.getCurrentRef()})}}this.root.projectStore.currentViewport.viewport.onDrop()}};I([L],y.prototype,"shaderRef",2);I([L.ref],y.prototype,"formConfig",2);I([_],y.prototype,"bindShaderAsset",1);I([_],y.prototype,"_proxyShaderProps",1);I([_],y.prototype,"proxySetter",1);I([_],y.prototype,"_virualShaderProps",1);I([_],y.prototype,"refreshAnimatableProperties",1);I([_],y.prototype,"_onDrop",1);y=I([se({type:"Material",label:E("asset.material.title"),loaderType:"Material",extname:"mat",importMenuConfig:{type:ie.Add},customInspector:ne,viewer:he,thumbnail:P,dragLayer:k.Material})],y);const Ie=Object.freeze(Object.defineProperty({__proto__:null,get MaterialAsset(){return y}},Symbol.toStringTag,{value:"Module"}));export{y as M,he as a,Ie as b};
1
+ var N=Object.defineProperty;var $=(p,t,e)=>t in p?N(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var f=(p,t,e)=>($(p,typeof t!="symbol"?t+"":t,e),e);import{y as j,bG as F,bH as V,bI as U,F as G,ai as K,V as z,b4 as H,b3 as b,j as Q,q as k,u as W,bJ as D,bK as A,a1 as m,a2 as T,bL as J,C as O,bM as w,bN as Y,aE as S,bO as q,e as E,bP as X,K as Z,ae as ee,ah as te,af as C,R as v,_ as ae,z as re,x as L,aC as _,n as se,o as ie}from"./index-eeedc550.js";import"./index-828538e1.js";import"./postmen-fe9eecc4.js";import{M as ne}from"./MaterialInspector-ebbe39d5.js";import{A as oe}from"./AssetViewer-f505fb55.js";import{E as g,s as x}from"./shader-data-utils-c00c9d18.js";class he extends oe{constructor(){super(...arguments);f(this,"_sphereRenderer",null);f(this,"_particleRenderer",null);f(this,"_asset",null);f(this,"_shaderReactionDisposer",null);f(this,"onShaderChange",()=>{const{_asset:e}=this;e.engineObject.shader.name==="Effect/Particle"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(e.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(e.engineObject))})}setViewAsset(e,r){if(!(e instanceof y))return;const i=r.createChild("material");this._asset=e;const a=this._sphereRenderer=i.createChild("mat").addComponent(j);a.mesh=F.createSphere(r.engine,1,32,!0);const n=this._particleRenderer=i.createChild("pat").addComponent(V);n.generator.main.duration=1e3,n.generator.main.startSpeed.constant=0,this._entity=i,r.addChild(this._entity),this.onShaderChange(),this._shaderReactionDisposer=U(()=>{var o,l;return(l=(o=this._asset)==null?void 0:o.shaderRef)==null?void 0:l.refId},()=>{this.onShaderChange()})}stopViewAsset(){var e;super.stopViewAsset(),(e=this._shaderReactionDisposer)==null||e.call(this),this._shaderReactionDisposer=null,this._asset=null}}class P{static update(t,e){if(!(e instanceof y))return;const r=e.engineObject;if(!r||!r.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(t),r.shader.name==="Effect/Particle"?(this.sphereRenderer.entity.isActive=!1,this.particleRenderer.entity.isActive=!0,this.particleRenderer.setMaterial(r),this.particleRenderer.generator._playTime=5):(this.particleRenderer.entity.isActive=!1,this.sphereRenderer.entity.isActive=!0,this.sphereRenderer.setMaterial(r))}static clear(){var t,e;(t=this.sphereRenderer)!=null&&t.entity&&(this.sphereRenderer.entity.isActive=!1),(e=this.particleRenderer)!=null&&e.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(t){const e=this.entity=t.createChild("material"),r=this.sphereRenderer=e.createChild("mat").addComponent(j);r.mesh=F.createSphere(t.engine,2,64,!0),this.particleRenderer=e.createChild("pat").addComponent(V),this.particleRenderer.bounds.max.set(.5,.5,.5),this.particleRenderer.bounds.min.set(-.5,-.5,-.5)}}f(P,"entity",null),f(P,"sphereRenderer",null),f(P,"particleRenderer",null);function B(p){return p instanceof G?{x:p.x,y:p.y}:p instanceof K?{x:p.x,y:p.y,z:p.z}:p instanceof z?{x:p.x,y:p.y,z:p.z,w:p.w}:p instanceof H?{r:p.r,g:p.g,b:p.b,a:p.a}:p}function pe(p){switch(p){case b.Color:return"Color";case b.Float:return"Float";case b.Int:return"Integer";case b.Matrix:return"Matrix";case b.Texture:return"Texture";case b.TextureArray:return"TextureArray";case b.Vector2:return"Vector2";case b.Vector3:return"Vector3";case b.Vector4:return"Vector4"}}var ce=Object.defineProperty,de=Object.getOwnPropertyDescriptor,I=(p,t,e,r)=>{for(var i=r>1?void 0:r?de(t,e):t,a=p.length-1,n;a>=0;a--)(n=p[a])&&(i=(r?n(t,e,i):n(i))||i);return r&&i&&ce(t,e,i),i};let y=class extends Q{constructor(t){super(t);f(this,"acceptDragLayer",k.Texture);f(this,"shaderRef",{refId:null});f(this,"shaderDataKeys",new Set);f(this,"formConfig",null);f(this,"_autoSaveSuppressed",!1);W(this),D(this,{proxyConfigs:[]})}static initBuiltinMaterial(t,e){t.shader=e;const r=t.shaderData;switch(r.disableMacro("MATERIAL_NEED_WORLD_POS"),r.disableMacro("MATERIAL_OMIT_NORMAL"),r.disableMacro("MATERIAL_NEED_TILING_OFFSET"),r.disableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.name){case"Unlit":r.enableMacro("MATERIAL_OMIT_NORMAL"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"PBR":case"bake-pbr":case"BlinnPhong":r.enableMacro("MATERIAL_NEED_WORLD_POS"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"Sky/SkyProcedural":r.enableMacro("MATERIAL_SUN_HIGH_QUALITY");break;case"Effect/Particle":r.enableMacro("MATERIAL_OMIT_NORMAL");break}}setAutoSaveSuppressed(t){this._autoSaveSuppressed=t}setRenderQueueType(t){this.engineObject.shaderData.setInt("renderQueueType",t)}setBlendStateEnabled(t){this.engineObject.shaderData.setInt("blendEnabled",t?1:0)}setDepthWriteEnabled(t){this.engineObject.shaderData.setInt("depthWriteEnabled",t?1:0)}setCullMode(t){this.engineObject.shaderData.setInt("rasterStateCullMode",t)}setBlendMode(t){const e=this.engineObject.shaderData;switch(t){case A.Normal:e.setInt("sourceColorBlendFactor",m.SourceAlpha),e.setInt("destinationColorBlendFactor",m.OneMinusSourceAlpha),e.setInt("sourceAlphaBlendFactor",m.One),e.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),e.setInt("colorBlendOperation",T.Add),e.setInt("alphaBlendOperation",T.Add);break;case A.Additive:e.setInt("sourceColorBlendFactor",m.SourceAlpha),e.setInt("destinationColorBlendFactor",m.One),e.setInt("sourceAlphaBlendFactor",m.One),e.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),e.setInt("colorBlendOperation",T.Add),e.setInt("alphaBlendOperation",T.Add);break}}bindShaderAsset(t,e){for(const r of this.shaderDataKeys)this.removePropertyChangeListener(r);return this.shaderDataKeys.clear(),t.onReady().then(async()=>{var i;if(this.isInitCompleted){if(t.shaderScriptRefId){const a=this.root.assetStore.getAsset(t.shaderScriptRefId.refId);a==null||a.onShaderChange(this._engineObject)}else t.builtinUIScript&&t.builtinUIScript.onMaterialShaderSwitched(this._engineObject);e=this._getMainData()}const r=t.properties?J(t.properties):[];t.isBuiltinShader()&&y.initBuiltinMaterial(this.engineObject,t.engineObject),e=e||this._getMainData(),await this._proxyShaderProps(r,e,this.isInitCompleted),this.refreshFormConfig(r,e),this.refreshAnimatableProperties(r),this.shaderRef&&this.root.assetStore.getAssetByRef(this.shaderRef).then(a=>{a!==t&&(a==null||a.removeReferencedMaterial(this))}).catch(()=>{}),t.addReferencedMaterial(this),this.shaderRef={refId:t.id},await this.applyBoundPathChange("shader",O.AssetPicker,this.shaderRef),(i=this.updateThumbnail)==null||i.call(this)})}async _proxyShaderProps(t,e,r=!0){var n;this.proxyConfigs=t;const i=(n=this.extraData)==null?void 0:n.disabledMacros,a=t.map(async o=>{var l;if(this.proxySetter(o),this._virualShaderProps(t),o.bundleType==="macro"){const s=o.macroInfo,h=e.macros.find(c=>c.name===o.prop);if(!w(this,o.prop)){let c;h!=null?(c=h.value,s&&(s.checked=!0)):i!=null&&i.includes(o.prop)?(c=void 0,s&&(s.checked=!1)):c=o.defaultValue,D(this,{[o.prop]:c})}if(r)if(h){const c=h.value??o.defaultValue;c==null?s==null||s.onSwitch(!0,this):await o.onChange(this,o.prop,c)}else!(i!=null&&i.includes(o.prop))&&(s!=null&&s.checked)&&(s==null||s.onSwitch(!0,this))}else{const s=e.shaderData[o.prop];let h=s?s.value:this[o.prop]??o.defaultValue;if(h!=null&&h.refId&&!this.root.assetStore.assets[h.refId]&&(h=void 0),((l=o.uiInfo)==null?void 0:l.type)===g.Color)if(o.uiInfo.mode==="hdr"){const c=h.intensity??1;c!==0&&(h.r/=c,h.g/=c,h.b/=c),h.intensity=c}else h.intensity=1;w(this,o.prop)||D(this,{[o.prop]:h}),r&&this.notifyPropertyChange(o.prop,!1)}});await Promise.all(a)}proxySetter(t){const{prop:e,onChange:r,bundleType:i}=t,a=async(n,o)=>{var s;const l=this._engineObject.shaderData;i==="macro"?l.enableMacro(e,n):await x(this,e,n,t.engineType??((s=t.uiInfo)==null?void 0:s.type)),await r(this,e,n),o!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(e,a),this.shaderDataKeys.add(e)}_virualShaderProps(t){const e=this;t.forEach(r=>{Y(e,r.prop)})}refreshFormConfig(t,e){var i,a,n,o,l;const r={root:[],groups:{}};if(e){for(const s of t)if(!((i=s.uiInfo)!=null&&i.hide)){if((a=s.uiInfo)!=null&&a.group){if((n=s.uiInfo)!=null&&n.group){let h=r.groups[s.uiInfo.group];h||(h={type:O.Group,property:s.uiInfo.group,children:[]},r.groups[s.uiInfo.group]=h);const c=s.uiInfo;c.property=s.prop,s.macroInfo&&(c.macroConfig=s.macroInfo),h.children.push(c)}}else{const h=s.uiInfo;h.property=s.prop,s.macroInfo&&(h.macroConfig=s.macroInfo),r.root.push(h)}s.bundleType==="macro"?this[s.prop]=((o=e.macros.find(h=>h.name===s.prop))==null?void 0:o.value)??s.defaultValue:this[s.prop]=((l=e.shaderData[s.prop])==null?void 0:l.value)??s.defaultValue}}this.formConfig=r}refreshAnimatableProperties(t){var e,r,i;this._additionAnimatableProperties.length=0;for(const a of t){if(!a.uiInfo||a.uiInfo.hide||a.bundleType==="macro")continue;let n={};if((a.setPath||a.getPath||a.valueType||a.interpolationType)&&(n={setPath:a.setPath,getPath:a.getPath,valueType:a.valueType,interpolationType:a.interpolationType}),!n.setPath&&!n.getPath&&a.engineType&&(a.bundleType==="shaderData"||!a.bundleType))switch(a.engineType){case g.Float:n={setPath:`shaderData.setFloat('${a.prop}', $value)`,getPath:`shaderData.getFloat('${a.prop}')`,valueType:S.Float};break;case g.Integer:n={setPath:`shaderData.setInt('${a.prop}', $value)`,getPath:`shaderData.getInt('${a.prop}')`,valueType:S.Float,interpolationType:q.Step};break;case g.Vector2:n={setPath:`shaderData.getVector2('${a.prop}')`,getPath:`shaderData.getVector2('${a.prop}')`,valueType:S.Vector2};break;case g.Vector3:n={setPath:`shaderData.getVector3('${a.prop}')`,getPath:`shaderData.getVector3('${a.prop}')`,valueType:S.Vector3};break;case g.Vector4:n={setPath:`shaderData.getVector4('${a.prop}')`,getPath:`shaderData.getVector4('${a.prop}')`,valueType:S.Vector4};break;case g.Color:n={setPath:`shaderData.getColor('${a.prop}')`,getPath:`shaderData.getColor('${a.prop}')`,valueType:S.Color};break;case g.Boolean:n={setPath:`shaderData.setBoolean('${a.prop}', $value)`,getPath:`shaderData.getBoolean('${a.prop}')`,valueType:S.Boolean};break;case g.Texture:n={setPath:`shaderData.setTexture('${a.prop}', $value)`,getPath:`shaderData.getTexture('${a.prop}')`,valueType:S.ReferResource};break}if(!n.setPath&&!n.getPath){if(a.bundleType==="other")continue;continue}this._additionAnimatableProperties.push({property:a.prop,label:(e=a.uiInfo)!=null&&e.label?E(a.uiInfo.label):a.prop,type:(r=a.uiInfo)==null?void 0:r.type,propertyProxyConfig:n}),(i=a.uiInfo)!=null&&i.label&&(n.label=E(a.uiInfo.label)),X(this,a.prop,n)}}async initByMain(t){var c;const e=JSON.parse(await t.text());let r=e.shaderRef;const i=e.shaderData,a=e.macros;if(!r&&typeof e.shader=="string"){const d=Object.values(this.root.assetStore.assets).find(u=>u.meta.type==="Shader"&&u.meta.builtinShaderName===e.shader);d&&(r={refId:d.id})}if(!r)throw"invalid material";this.shaderRef=r;const n=new Z(this.engine);this.setDragTempEntity(n);const o=await this.root.assetStore.getAssetByRef(r),l=o.engineObject??ee.find("Unlit"),s=new te(this.engine,l);this.bindEngineObject(s);const h=s.shaderData;if(a)for(const d of a)h.enableMacro(d.name,d.value);if(i)for(const d in i){const u=i[d];let R=u.value;if(u.type===g.Color){R={...u.value};const M=u.value.intensity??1;M!==0&&(R.r/=M,R.g/=M,R.b/=M)}x(this,d,R,u.type)}await this.bindShaderAsset(o,e),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",O.Input,this.name),this._checkSchemaOnInit(e,o)}_checkSchemaOnInit(t,e){t.shader!==e.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(t){const e=this;this.bindEngineObject(t),e.shader=t.shader.name,e._name=t.name??"";const i=Object.values(this.root.assetStore.assets).filter(h=>h.meta.type==="Shader"&&!!h.meta.builtinShaderName).find(h=>h.meta.builtinShaderName===t.shader.name);this.shaderRef={refId:i.id};const a=t.shaderData,n=new Set((i.properties??[]).map(h=>h.prop));if(n.has("isTransparent")&&(e.isTransparent=a.getInt("blendEnabled")===1),n.has("material_AlphaCutoff")&&(e.alphaCutoff=a.getFloat("material_AlphaCutoff")),n.has("renderFace"))switch(a.getInt("rasterStateCullMode")){case C.Back:e.renderFace=v.Front;break;case C.Front:e.renderFace=v.Back;break;case C.Off:e.renderFace=v.Double;break}n.has("blendMode")&&(e.blendMode=a.getInt("destinationColorBlendFactor")===m.One?A.Additive:A.Normal),a.getProperties().forEach(h=>{const c=a.getPropertyValue(h);if(c instanceof ae){const d=this.root.assetStore.engineObjectToAssetMap.get(c);this[h.name]=d==null?void 0:d.getCurrentRef()}else this[h.name]=B(c)});const l=this._getMainData(),s=i.properties?[...i.properties]:[];this._proxyShaderProps(s,l,!1),this.bindShaderAsset(i,l)}afterDelete(){var t;(t=this.engineObject)==null||t.destroy(!0)}rename(t){return this.root.assetFacade.persistAssetMain(this.id),super.rename(t)}_getMainData(t){var s,h,c;const e=[],r=(t??this.engineObject).shaderData;r.getMacros(e);const i=e.map(({name:d,value:u})=>u===void 0?{name:d}:{name:d,value:u}),a=[],n={};r.getProperties(a);for(const d of a){let u;if(d.type===b.Texture||d.type===b.TextureArray)u=this[d.name];else{const R=r.getPropertyValue(d);u=B(R),((s=this[d.name])==null?void 0:s.intensity)!=null&&(u.intensity=(h=this[d.name])==null?void 0:h.intensity)}u!=null&&(n[d.name]={type:pe(d.type),value:u})}const o=(c=this.shaderRef)!=null&&c.refId?this.root.assetStore.getAsset(this.shaderRef.refId):void 0,l=!!(o!=null&&o.builtinShaderName);return{name:this.name,shader:this.engineObject.shader.name,macros:i,shaderData:n,...l?{}:{shaderRef:this.shaderRef}}}getMainData(){return JSON.stringify(this._getMainData())}async initByCreation(){var l;const t=new re(this.engine),e=[];t.shaderData.getMacros(e);const r=e.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h});this.bindEngineObject(t);const i=this.root.assetStore.getAsset("0000501"),a=i!=null&&i.properties?[...i.properties]:[],n={};for(const s of a)s.defaultValue&&(n[s.prop]={value:s.defaultValue,type:s.engineType??((l=s.uiInfo)==null?void 0:l.type)});const o={shaderData:n,name:this.name,shader:t.shader.name,macros:r};return this._proxyShaderProps(a,o,!1),o}async onSubAssetEdit(){var i;const t=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(t.engineObject),await t.applyBoundPathChange("name",O.Input,t.name),t.initByEngineObject(t.engineObject),t.updateThumbnail(),await this.root.assetFacade.persistAssetMain(t.id);const e=await this.root.assetStore.getAssetByRef({refId:this.mainId}),r=((i=e.engineObject.materials)==null?void 0:i.indexOf(this._engineObject))??-1;r>=0&&await e.replaceMaterial(r,t.getCurrentRef()),this.root.assetStore.selectAsset(t.id)}saveMainImmediately(t){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately(t).then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}async _onDrop(t,e){var i,a;const r="material_BaseTexture";if(r in this){const n=e.getCurrentRef();this[r]=n;const o=this.root.assetStore.getAsset((i=this.shaderRef)==null?void 0:i.refId),l=(a=o==null?void 0:o.properties)==null?void 0:a.find(s=>s.prop===r);l&&await l.onChange(this,r,n),await this.root.assetFacade.persistAssetMain(this.id)}this.dropping=!1}async onDropToViewport(){const{sceneStore:t,sceneUIStore:e}=this.root,r=e.hoveredEntityId;if(r){const i=t.getEntityModel(r);if(i){const a=i.getComponentByTypeName("MeshRenderer"),n=i.getComponentByTypeName("SkinnedMeshRenderer"),o=a||n;o&&this.root.componentFacade.updateComponent(i.id,o.id,{material:this.getCurrentRef()})}}this.root.projectStore.currentViewport.viewport.onDrop()}};I([L],y.prototype,"shaderRef",2);I([L.ref],y.prototype,"formConfig",2);I([_],y.prototype,"bindShaderAsset",1);I([_],y.prototype,"_proxyShaderProps",1);I([_],y.prototype,"proxySetter",1);I([_],y.prototype,"_virualShaderProps",1);I([_],y.prototype,"refreshAnimatableProperties",1);I([_],y.prototype,"_onDrop",1);y=I([se({type:"Material",label:E("asset.material.title"),loaderType:"Material",extname:"mat",importMenuConfig:{type:ie.Add},customInspector:ne,viewer:he,thumbnail:P,dragLayer:k.Material})],y);const Ie=Object.freeze(Object.defineProperty({__proto__:null,get MaterialAsset(){return y}},Symbol.toStringTag,{value:"Module"}));export{y as M,he as a,Ie as b};