@galacean/cli 2.0.0-alpha.22 → 2.0.0-alpha.23

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 (90) hide show
  1. package/dist/cli.bundle.cjs +32853 -32365
  2. package/dist/preview-client/_static/{Accordion-b106eaf3.js → Accordion-75b7b34e.js} +1 -1
  3. package/dist/preview-client/_static/{AmbientLightAsset-6b2d168c.js → AmbientLightAsset-02786385.js} +1 -1
  4. package/dist/preview-client/_static/{AnimationClipAsset-a5d290cc.js → AnimationClipAsset-f96e0e56.js} +1 -1
  5. package/dist/preview-client/_static/{AnimatorControllerAsset-616578b4.js → AnimatorControllerAsset-23cceb12.js} +1 -1
  6. package/dist/preview-client/_static/{AnimatorStore-bc865a7e.js → AnimatorStore-48d2c14c.js} +1 -1
  7. package/dist/preview-client/_static/{AssetViewer-1a9f3cad.js → AssetViewer-1073ddb5.js} +1 -1
  8. package/dist/preview-client/_static/{AudioAsset-24b03bc3.js → AudioAsset-6218f2bb.js} +1 -1
  9. package/dist/preview-client/_static/{AudioComponent-060f13a6.js → AudioComponent-16766db8.js} +1 -1
  10. package/dist/preview-client/_static/{Callout-c8b9b055.js → Callout-312ada1c.js} +1 -1
  11. package/dist/preview-client/_static/{CameraComponent-33b1918d.js → CameraComponent-c919c2dd.js} +1 -1
  12. package/dist/preview-client/_static/{Component-3cb422ab.js → Component-6d1e73e5.js} +1 -1
  13. package/dist/preview-client/_static/{DirectLight-072d3047.js → DirectLight-166a628d.js} +1 -1
  14. package/dist/preview-client/_static/{FontAsset-1e1118c1.js → FontAsset-8367aad9.js} +1 -1
  15. package/dist/preview-client/_static/{FormItemArray-f1283fce.js → FormItemArray-53c58844.js} +1 -1
  16. package/dist/preview-client/_static/{GlTFAsset-dc68541e.js → GlTFAsset-5c8e7813.js} +1 -1
  17. package/dist/preview-client/_static/{IconPlus-99d7bb90.js → IconPlus-5fbc029e.js} +1 -1
  18. package/dist/preview-client/_static/{IconPointFilled-f8224625.js → IconPointFilled-dbf63b5c.js} +1 -1
  19. package/dist/preview-client/_static/{LightBaseComponent-b610e42a.js → LightBaseComponent-545c5ee8.js} +1 -1
  20. package/dist/preview-client/_static/{LottieAnimationComponent-b70c2426.js → LottieAnimationComponent-4db5a6c2.js} +1 -1
  21. package/dist/preview-client/_static/{MarkdownAsset-2a4a1d10.js → MarkdownAsset-58491579.js} +1 -1
  22. package/dist/preview-client/_static/{MaterialAsset-dfaa82d9.js → MaterialAsset-c83c7d3d.js} +1 -1
  23. package/dist/preview-client/_static/{MaterialInspector-21fc5b67.js → MaterialInspector-237b6a5e.js} +1 -1
  24. package/dist/preview-client/_static/{Menu-62cee67e.js → Menu-a427d272.js} +1 -1
  25. package/dist/preview-client/_static/{MeshAsset-07529e4e.js → MeshAsset-1c11d7ab.js} +1 -1
  26. package/dist/preview-client/_static/{MeshRendererBaseComponent-2af8db12.js → MeshRendererBaseComponent-8fd1f0df.js} +1 -1
  27. package/dist/preview-client/_static/{MeshRendererComponent-d9df7d58.js → MeshRendererComponent-082c1a1a.js} +1 -1
  28. package/dist/preview-client/_static/{MeshThumbnail-bd30617c.js → MeshThumbnail-d8ee2674.js} +1 -1
  29. package/dist/preview-client/_static/{ParticleRendererComponent-8729cfbf.js → ParticleRendererComponent-ff12cdb1.js} +1 -1
  30. package/dist/preview-client/_static/{PhysicsMaterialAsset-e9abb944.js → PhysicsMaterialAsset-7e86c718.js} +1 -1
  31. package/dist/preview-client/_static/{PhysicsStore-96164e4e.js → PhysicsStore-66a9a461.js} +1 -1
  32. package/dist/preview-client/_static/{PointLight-76172b61.js → PointLight-a9992e50.js} +1 -1
  33. package/dist/preview-client/_static/{PostProcessComponent-83f23ced.js → PostProcessComponent-c17ac553.js} +1 -1
  34. package/dist/preview-client/_static/{PrefabAsset-4bac196b.js → PrefabAsset-a6750aec.js} +1 -1
  35. package/dist/preview-client/_static/{PrimitiveMesh-9ff7dbc1.js → PrimitiveMesh-388f3f36.js} +1 -1
  36. package/dist/preview-client/_static/{ReferencedMaterial-27ba90e2.js → ReferencedMaterial-f7ea80fb.js} +1 -1
  37. package/dist/preview-client/_static/{RenderTargetAsset-e112b8ca.js → RenderTargetAsset-c48990a4.js} +1 -1
  38. package/dist/preview-client/_static/{SceneAsset-a39f097a.js → SceneAsset-1e802e29.js} +1 -1
  39. package/dist/preview-client/_static/{ShaderAsset-068b4b97.js → ShaderAsset-256afb00.js} +1 -1
  40. package/dist/preview-client/_static/{ShaderChunkAsset-bdb39acc.js → ShaderChunkAsset-a42443fc.js} +1 -1
  41. package/dist/preview-client/_static/{ShaderUIScriptAsset-0c11d0ed.js → ShaderUIScriptAsset-5acb02f5.js} +1 -1
  42. package/dist/preview-client/_static/{SkinnedMeshRendererComponent-5e58927a.js → SkinnedMeshRendererComponent-934c055b.js} +1 -1
  43. package/dist/preview-client/_static/{SpineAnimationComponent-1ae4feaa.js → SpineAnimationComponent-b04ba1ee.js} +1 -1
  44. package/dist/preview-client/_static/{SpineSkeletonDataAsset-284f5f4d.js → SpineSkeletonDataAsset-fff17383.js} +1 -1
  45. package/dist/preview-client/_static/{SpotLight-1a8af1d4.js → SpotLight-617d8957.js} +1 -1
  46. package/dist/preview-client/_static/{SpriteBaseComponent-fd82e43b.js → SpriteBaseComponent-062cb4f8.js} +1 -1
  47. package/dist/preview-client/_static/{SpriteMaskComponent-eab0faf7.js → SpriteMaskComponent-43ae2b1f.js} +1 -1
  48. package/dist/preview-client/_static/{SpriteRendererComponent-1496fc43.js → SpriteRendererComponent-4f52910c.js} +1 -1
  49. package/dist/preview-client/_static/{TextBaseComponent-7d2db29c.js → TextBaseComponent-bd7ed8ee.js} +1 -1
  50. package/dist/preview-client/_static/{TextRendererComponent-88494abb.js → TextRendererComponent-8db74598.js} +1 -1
  51. package/dist/preview-client/_static/{TextureAsset-7172cc65.js → TextureAsset-d88af413.js} +1 -1
  52. package/dist/preview-client/_static/{Tooltip-9ce2e9d6.js → Tooltip-3bc02b10.js} +1 -1
  53. package/dist/preview-client/_static/{TrailRendererComponent-4443baab.js → TrailRendererComponent-42a58f1d.js} +1 -1
  54. package/dist/preview-client/_static/{TransformBaseComponent-ca2fa45d.js → TransformBaseComponent-77478ccb.js} +1 -1
  55. package/dist/preview-client/_static/{TransformComponent-683b5e9c.js → TransformComponent-0f395b08.js} +1 -1
  56. package/dist/preview-client/_static/{XRReferenceImageAsset-823e47cd.js → XRReferenceImageAsset-d6d8e59c.js} +1 -1
  57. package/dist/preview-client/_static/{audio-10d03160.js → audio-d14900e2.js} +1 -1
  58. package/dist/preview-client/_static/{createOnModelChange-73358d10.js → createOnModelChange-c010a049.js} +1 -1
  59. package/dist/preview-client/_static/{createReactComponent-fcd6848b.js → createReactComponent-d9f8b1af.js} +1 -1
  60. package/dist/preview-client/_static/{index-4cde6efd.js → index-071c0532.js} +1 -1
  61. package/dist/preview-client/_static/index-1c260f88.js +1 -0
  62. package/dist/preview-client/_static/{index-0a53aaef.js → index-365736f7.js} +1 -1
  63. package/dist/preview-client/_static/{index-03b6134d.js → index-3660a664.js} +6 -6
  64. package/dist/preview-client/_static/index-44137d7e.js +1 -0
  65. package/dist/preview-client/_static/{index-5392907c.js → index-4e7bb453.js} +3 -3
  66. package/dist/preview-client/_static/index-5ae70b23.js +1 -0
  67. package/dist/preview-client/_static/{index-2274eaf1.js → index-75e7d483.js} +1 -1
  68. package/dist/preview-client/_static/{index-7e5ce9d9.js → index-8e169cc2.js} +1 -1
  69. package/dist/preview-client/_static/{index-2202e8e4.js → index-9feced3c.js} +1 -1
  70. package/dist/preview-client/_static/index-be42fc1e.js +1 -0
  71. package/dist/preview-client/_static/index-cfa0dccc.js +1 -0
  72. package/dist/preview-client/_static/{index-19f5510d.js → index-eb74362c.js} +1 -1
  73. package/dist/preview-client/_static/{index-8d2f0997.js → index-f165015e.js} +1 -1
  74. package/dist/preview-client/_static/index-f3d42be3.js +1 -0
  75. package/dist/preview-client/_static/{index-4ac10da2.js → index-f4d91eb4.js} +1 -1
  76. package/dist/preview-client/_static/{ktx2-encoder-4cac07f2.js → ktx2-encoder-e9b1c83a.js} +1 -1
  77. package/dist/preview-client/_static/{module-03df665c.js → module-1c91b4e1.js} +1 -1
  78. package/dist/preview-client/_static/{module-101126a2.js → module-4a37a616.js} +1 -1
  79. package/dist/preview-client/_static/{module-5fa1eae0.js → module-81a206c0.js} +1 -1
  80. package/dist/preview-client/_static/postmen-c7605b45.js +2 -0
  81. package/dist/preview-client/_static/{shader-data-utils-d59bc4f5.js → shader-data-utils-6ef12596.js} +1 -1
  82. package/dist/preview-client/index.html +1 -1
  83. package/package.json +1 -1
  84. package/dist/preview-client/_static/index-0a683358.js +0 -1
  85. package/dist/preview-client/_static/index-6f3c991c.js +0 -1
  86. package/dist/preview-client/_static/index-a2c9fc83.js +0 -1
  87. package/dist/preview-client/_static/index-c216bbcf.js +0 -1
  88. package/dist/preview-client/_static/index-f06b751f.js +0 -1
  89. package/dist/preview-client/_static/index-f4a0b8dd.js +0 -1
  90. package/dist/preview-client/_static/postmen-9e6354af.js +0 -2
@@ -1 +1 @@
1
- import{b4 as oe,b5 as te,b6 as T,b7 as c,av as r,b8 as D,b9 as re,ba as ne,bb as ie,bc as O,bd as ae,be as ce,bf as se,bg as de,bh as V,aH as b,bi as le}from"./index-03b6134d.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(j=>{var N;return!((N=j.ref.current)!=null&&N.disabled)}),x=S.findIndex(j=>j.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)},R=()=>{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():R());break;case"ArrowDown":t==="vertical"&&y();break;case"ArrowLeft":t==="horizontal"&&(f?R():y());break;case"ArrowUp":t==="vertical"&&R();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"}),Re=b(Ce,{width:"100%",display:"flex",flexDirection:"column"}),je=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(Re,{...n})})};function Te(o){const{size:i}=c.useContext(Q),{children:e,title:n,arrow:a=!0,...t}=o;return r.jsxs(je,{...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{b4 as oe,b5 as te,b6 as T,b7 as c,av as r,b8 as D,b9 as re,ba as ne,bb as ie,bc as O,bd as ae,be as ce,bf as se,bg as de,bh as V,aH as b,bi as le}from"./index-3660a664.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(j=>{var N;return!((N=j.ref.current)!=null&&N.disabled)}),x=S.findIndex(j=>j.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)},R=()=>{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():R());break;case"ArrowDown":t==="vertical"&&y();break;case"ArrowLeft":t==="horizontal"&&(f?R():y());break;case"ArrowUp":t==="vertical"&&R();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"}),Re=b(Ce,{width:"100%",display:"flex",flexDirection:"column"}),je=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(Re,{...n})})};function Te(o){const{size:i}=c.useContext(Q),{children:e,title:n,arrow:a=!0,...t}=o;return r.jsxs(je,{...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 k=(r,t,e)=>(ot(r,typeof t!="symbol"?t+"":t,e),e);import{dv as T,dw as rt,dx as st,dy as at,dz as it,dA as ct,dB as ut,y as lt,bD as ft,z as ht,j as dt,dC as Z,dD as mt,dE as bt,Z as gt,n as yt,e as pt,dF as wt}from"./index-03b6134d.js";import{k as kt,H as Bt}from"./ktx2-encoder-4cac07f2.js";import"./index-0a53aaef.js";import"./TaskQueue-05c94a4d.js";import"./ktx-parse.modern-6c9f771f.js";class D{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 k=(r,t,e)=>(ot(r,typeof t!="symbol"?t+"":t,e),e);import{dv as T,dw as rt,dx as st,dy as at,dz as it,dA as ct,dB as ut,y as lt,bD as ft,z as ht,j as dt,dC as Z,dD as mt,dE as bt,Z as gt,n as yt,e as pt,dF as wt}from"./index-3660a664.js";import{k as kt,H as Bt}from"./ktx2-encoder-e9b1c83a.js";import"./index-365736f7.js";import"./TaskQueue-05c94a4d.js";import"./ktx-parse.modern-6c9f771f.js";class D{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 X,av as V,bk as dt,e as j,cl as et,cm as mt,aN as ft,aH as gt,aI as Pt,u as it,S as ot,bS as _t,x as L,aC as E,bo as vt,br as bt,cn as Ct,co as Tt,y as wt,cp as Et,bE as At,cq as St,cr as xt,cs as Mt,N as Vt,O as It,ct as Ot,cu as jt,cv as Ft,cw as Rt,cx as Bt,cy as Lt,cz as Dt,cA as $t,cB as Kt,cC as Nt,cD as kt,cE as zt,cF as Ut,cG as Ht,aE as y,cH as Gt,bL as I,cI as Jt,cJ as Qt,cK as Wt,cL as qt,cM as Yt,cN as Xt,cO as Zt,cP as te,cQ as ee,cR as re,cS as ne,j as ae,cT as O,bX as W,cU as H,c5 as q,cV as x,bV as Y,cW as se,cX as rt,ap as ie,cY as oe,ac as nt,cZ as B,ai as at,c_ as pe,H as ce,c$ as le,at as he,au as ue,V as ye,F as de,b3 as me,d0 as G,bF as fe,m as ge,aT as Pe,c2 as _e,n as ve,o as be,d1 as Ce}from"./index-03b6134d.js";import{a as pt,r as st}from"./index-0a53aaef.js";import"./postmen-9e6354af.js";import{A as Te}from"./AssetViewer-1a9f3cad.js";import{e as ct}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{L as we}from"./module-101126a2.js";import{a as Ee}from"./module-5fa1eae0.js";const Ae=X(()=>{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=X(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",X(({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 Z=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:qt,name:"AnimationVector4Curve",defaultInterpolation:I.Hermite}],[y.Quaternion,{curveClass:Yt,name:"AnimationQuaternionCurve",defaultInterpolation:I.Hermite}],[y.Color,{curveClass:Xt,name:"AnimationColorCurve",defaultInterpolation:I.Hermite}],[y.ReferResource,{curveClass:Zt,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;Z.forEach((_,t)=>{lt.set(_.curveClass,t)});const ht=new Map;Z.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=q(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:Y(),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,q(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=Y(),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:q(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=Z.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:Y(),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 X,av as V,bk as dt,e as j,cl as et,cm as mt,aN as ft,aH as gt,aI as Pt,u as it,S as ot,bS as _t,x as L,aC as E,bo as vt,br as bt,cn as Ct,co as Tt,y as wt,cp as Et,bE as At,cq as St,cr as xt,cs as Mt,N as Vt,O as It,ct as Ot,cu as jt,cv as Ft,cw as Rt,cx as Bt,cy as Lt,cz as Dt,cA as $t,cB as Kt,cC as Nt,cD as kt,cE as zt,cF as Ut,cG as Ht,aE as y,cH as Gt,bL as I,cI as Jt,cJ as Qt,cK as Wt,cL as qt,cM as Yt,cN as Xt,cO as Zt,cP as te,cQ as ee,cR as re,cS as ne,j as ae,cT as O,bX as W,cU as H,c5 as q,cV as x,bV as Y,cW as se,cX as rt,ap as ie,cY as oe,ac as nt,cZ as B,ai as at,c_ as pe,H as ce,c$ as le,at as he,au as ue,V as ye,F as de,b3 as me,d0 as G,bF as fe,m as ge,aT as Pe,c2 as _e,n as ve,o as be,d1 as Ce}from"./index-3660a664.js";import{a as pt,r as st}from"./index-365736f7.js";import"./postmen-c7605b45.js";import{A as Te}from"./AssetViewer-1073ddb5.js";import{e as ct}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{L as we}from"./module-4a37a616.js";import{a as Ee}from"./module-81a206c0.js";const Ae=X(()=>{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=X(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",X(({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 Z=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:qt,name:"AnimationVector4Curve",defaultInterpolation:I.Hermite}],[y.Quaternion,{curveClass:Yt,name:"AnimationQuaternionCurve",defaultInterpolation:I.Hermite}],[y.Color,{curveClass:Xt,name:"AnimationColorCurve",defaultInterpolation:I.Hermite}],[y.ReferResource,{curveClass:Zt,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;Z.forEach((_,t)=>{lt.set(_.curveClass,t)});const ht=new Map;Z.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=q(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:Y(),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,q(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=Y(),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:q(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=Z.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:Y(),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 D=Object.defineProperty;var O=(r,t,a)=>t in r?D(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var c=(r,t,a)=>(O(r,typeof t!="symbol"?t+"":t,a),a);import{aJ as x,aK as N,aM as B,av as _,aI as I,aP as L,j as U,aQ as z,aR as F,aS as R,x as T,aT as V,m as w,aU as J,n as q,e as K,o as Q,q as W,aV as $}from"./index-03b6134d.js";import{u as k,r as M}from"./index-0a53aaef.js";import"./postmen-9e6354af.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:v,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=v,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([q({type:"AnimatorController",label:K("asset.animator-controller.title"),icon:"animate-controller",extname:"animCtrl",importMenuConfig:{type:Q.Add},dragLayer:W.AnimationController,customInspector:H,async bundle({content:r}){return{content:new Blob([G(await r.text())])}}})],d);export{d as AnimatorControllerAsset};
1
+ var D=Object.defineProperty;var O=(r,t,a)=>t in r?D(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var c=(r,t,a)=>(O(r,typeof t!="symbol"?t+"":t,a),a);import{aJ as x,aK as N,aM as B,av as _,aI as I,aP as L,j as U,aQ as z,aR as F,aS as R,x as T,aT as V,m as w,aU as J,n as q,e as K,o as Q,q as W,aV as $}from"./index-3660a664.js";import{u as k,r as M}from"./index-365736f7.js";import"./postmen-c7605b45.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:v,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=v,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([q({type:"AnimatorController",label:K("asset.animator-controller.title"),icon:"animate-controller",extname:"animCtrl",importMenuConfig:{type:Q.Add},dragLayer:W.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,bp as u,s as c,p as m,C as b,t as h,e as C,bq as _,br as g,u as v,bs as O,bt as S}from"./index-03b6134d.js";import"./index-0a53aaef.js";import{c as E}from"./Component-3cb422ab.js";import"./postmen-9e6354af.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,bp as u,s as c,p as m,C as b,t as h,e as C,bq as _,br as g,u as v,bs as O,bt as S}from"./index-3660a664.js";import"./index-365736f7.js";import{c as E}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.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-03b6134d.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-3660a664.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 v=(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)=>(v(e,typeof t!="symbol"?t+"":t,s),s);import{aH as b,aJ as c,av as n,j as y,Z as A,n as j,e as m,o as w,b0 as l}from"./index-03b6134d.js";import"./index-0a53aaef.js";import"./postmen-9e6354af.js";import{A as f}from"./AssetViewer-1a9f3cad.js";const x=b("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 v=(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)=>(v(e,typeof t!="symbol"?t+"":t,s),s);import{aH as b,aJ as c,av as n,j as y,Z as A,n as j,e as m,o as w,b0 as l}from"./index-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.js";import{A as f}from"./AssetViewer-1073ddb5.js";const x=b("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-03b6134d.js";import"./index-0a53aaef.js";import{c}from"./Component-3cb422ab.js";import"./postmen-9e6354af.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-3660a664.js";import"./index-365736f7.js";import{c}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.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-03b6134d.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-3660a664.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-03b6134d.js";import"./index-0a53aaef.js";import{c as B}from"./Component-3cb422ab.js";import"./postmen-9e6354af.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-3660a664.js";import"./index-365736f7.js";import{c as B}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.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-03b6134d.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-3660a664.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-03b6134d.js";import"./index-0a53aaef.js";import{c as P}from"./Component-3cb422ab.js";import"./postmen-9e6354af.js";import{L as N}from"./LightBaseComponent-b610e42a.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-3660a664.js";import"./index-365736f7.js";import{c as P}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.js";import{L as N}from"./LightBaseComponent-545c5ee8.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{bR as m,bY as b,bZ as y,b_ as h,bX as v,aJ as w,av as x,bS as O,O as f,j,Z as F,n as R,e as U,o as A}from"./index-03b6134d.js";import"./index-0a53aaef.js";import"./postmen-9e6354af.js";import{A as g}from"./AssetViewer-1a9f3cad.js";async function _(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 C(s){const e=m(s.main,"font.ttf");try{const t=e.name,n=b(t),r=y(t,n),o=await h.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),v.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{bR as m,bY as b,bZ as y,b_ as h,bX as v,aJ as w,av as x,bS as O,O as f,j,Z as F,n as R,e as U,o as A}from"./index-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.js";import{A as g}from"./AssetViewer-1073ddb5.js";async function _(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 C(s){const e=m(s.main,"font.ttf");try{const t=e.name,n=b(t),r=y(t,n),o=await h.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),v.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{bB as d,aH as x,aP as v,aM as m,av as e,aw as f,ax as b,aI as l,bC as g,aL as i}from"./index-03b6134d.js";import{A as j,a as I}from"./Accordion-b106eaf3.js";/**
1
+ import{bB as d,aH as x,aP as v,aM as m,av as e,aw as f,ax as b,aI as l,bC as g,aL as i}from"./index-3660a664.js";import{A as j,a as I}from"./Accordion-75b7b34e.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 Ut=Object.defineProperty;var Ft=(e,t,n)=>t in e?Ut(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{f5 as Dt,aH as Bt,aJ as pt,av as I,bA as qt,q as mt,aK as Gt,aN as Fe,aw as te,f6 as ye,dr as ne,bz as De,aM as Wt,e1 as Be,bR as Ht,u as yt,S as Xt,x as j,aC as G,br as Kt,f7 as Qt,bX as qe,e as bt,f8 as Jt,bV as Yt,cp as Zt,f9 as Ge,Z as en,y as We,v as tn,aT as W,aU as nn,n as sn,o as rn,dL as an}from"./index-03b6134d.js";import{B as N,P,a as A,A as Me,b as $e,K as At,N as on,M as V,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-0a53aaef.js";import"./postmen-9e6354af.js";import{A as dn}from"./AssetViewer-1a9f3cad.js";import{M as pn}from"./MaterialAsset-dfaa82d9.js";import{k as mn}from"./ktx2-encoder-4cac07f2.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 Ut=Object.defineProperty;var Ft=(e,t,n)=>t in e?Ut(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{f5 as Dt,aH as Bt,aJ as pt,av as I,bA as qt,q as mt,aK as Gt,aN as Fe,aw as te,f6 as ye,dr as ne,bz as De,aM as Wt,e1 as Be,bR as Ht,u as yt,S as Xt,x as j,aC as G,br as Kt,f7 as Qt,bX as qe,e as bt,f8 as Jt,bV as Yt,cp as Zt,f9 as Ge,Z as en,y as We,v as tn,aT as W,aU as nn,n as sn,o as rn,dL as an}from"./index-3660a664.js";import{B as N,P,a as A,A as Me,b as $e,K as At,N as on,M as V,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-365736f7.js";import"./postmen-c7605b45.js";import{A as dn}from"./AssetViewer-1073ddb5.js";import{M as pn}from"./MaterialAsset-c83c7d3d.js";import{k as mn}from"./ktx2-encoder-e9b1c83a.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-fcd6848b.js";/**
1
+ import{c as e}from"./createReactComponent-d9f8b1af.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-fcd6848b.js";/**
1
+ import{c as e}from"./createReactComponent-d9f8b1af.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-03b6134d.js";import"./index-0a53aaef.js";import"./postmen-9e6354af.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-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.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-101126a2.js";import{E as b,p as l,C as a,s}from"./index-03b6134d.js";import"./index-0a53aaef.js";import{c as P}from"./Component-3cb422ab.js";import"./postmen-9e6354af.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-4a37a616.js";import{E as b,p as l,C as a,s}from"./index-3660a664.js";import"./index-365736f7.js";import{c as P}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.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-03b6134d.js";import"./index-0a53aaef.js";import"./postmen-9e6354af.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-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.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,e,t)=>e in p?N(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var f=(p,e,t)=>($(p,typeof e!="symbol"?e+"":e,t),t);import{y as j,bD as F,bE as V,bF as U,F as G,ai as K,V as z,b3 as H,b2 as b,j as Q,q as k,u as W,bG as D,bH as A,a1 as m,a2 as T,bI as J,C as O,bJ as w,bK as Y,aE as S,bL as q,e as E,bM 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-03b6134d.js";import"./index-0a53aaef.js";import"./postmen-9e6354af.js";import{M as ne}from"./MaterialInspector-21fc5b67.js";import{A as oe}from"./AssetViewer-1a9f3cad.js";import{E as g,s as x}from"./shader-data-utils-d59bc4f5.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:t}=this;t.engineObject.shader.name==="Effect/Particle"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(t.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(t.engineObject))})}setViewAsset(t,r){if(!(t instanceof y))return;const i=r.createChild("material");this._asset=t;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 t;super.stopViewAsset(),(t=this._shaderReactionDisposer)==null||t.call(this),this._shaderReactionDisposer=null,this._asset=null}}class P{static update(e,t){if(!(t instanceof y))return;const r=t.engineObject;if(!r||!r.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(e),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 e,t;(e=this.sphereRenderer)!=null&&e.entity&&(this.sphereRenderer.entity.isActive=!1),(t=this.particleRenderer)!=null&&t.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(e){const t=this.entity=e.createChild("material"),r=this.sphereRenderer=t.createChild("mat").addComponent(j);r.mesh=F.createSphere(e.engine,2,64,!0),this.particleRenderer=t.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,e,t,r)=>{for(var i=r>1?void 0:r?de(e,t):e,a=p.length-1,n;a>=0;a--)(n=p[a])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&ce(e,t,i),i};let y=class extends Q{constructor(e){super(e);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(e,t){e.shader=t;const r=e.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"),t.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(e){this._autoSaveSuppressed=e}setRenderQueueType(e){this.engineObject.shaderData.setInt("renderQueueType",e)}setBlendStateEnabled(e){this.engineObject.shaderData.setInt("blendEnabled",e?1:0)}setDepthWriteEnabled(e){this.engineObject.shaderData.setInt("depthWriteEnabled",e?1:0)}setCullMode(e){this.engineObject.shaderData.setInt("rasterStateCullMode",e)}setBlendMode(e){const t=this.engineObject.shaderData;switch(e){case A.Normal:t.setInt("sourceColorBlendFactor",m.SourceAlpha),t.setInt("destinationColorBlendFactor",m.OneMinusSourceAlpha),t.setInt("sourceAlphaBlendFactor",m.One),t.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),t.setInt("colorBlendOperation",T.Add),t.setInt("alphaBlendOperation",T.Add);break;case A.Additive:t.setInt("sourceColorBlendFactor",m.SourceAlpha),t.setInt("destinationColorBlendFactor",m.One),t.setInt("sourceAlphaBlendFactor",m.One),t.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),t.setInt("colorBlendOperation",T.Add),t.setInt("alphaBlendOperation",T.Add);break}}bindShaderAsset(e,t){for(const r of this.shaderDataKeys)this.removePropertyChangeListener(r);return this.shaderDataKeys.clear(),e.onReady().then(async()=>{var i;if(this.isInitCompleted){if(e.shaderScriptRefId){const a=this.root.assetStore.getAsset(e.shaderScriptRefId.refId);a==null||a.onShaderChange(this._engineObject)}else e.builtinUIScript&&e.builtinUIScript.onMaterialShaderSwitched(this._engineObject);t=this._getMainData()}const r=e.properties?J(e.properties):[];e.isBuiltinShader()&&y.initBuiltinMaterial(this.engineObject,e.engineObject),t=t||this._getMainData(),await this._proxyShaderProps(r,t,this.isInitCompleted),this.refreshFormConfig(r,t),this.refreshAnimatableProperties(r),this.shaderRef&&this.root.assetStore.getAssetByRef(this.shaderRef).then(a=>{a!==e&&(a==null||a.removeReferencedMaterial(this))}).catch(()=>{}),e.addReferencedMaterial(this),this.shaderRef={refId:e.id},await this.applyBoundPathChange("shader",O.AssetPicker,this.shaderRef),(i=this.updateThumbnail)==null||i.call(this)})}async _proxyShaderProps(e,t,r=!0){var n;this.proxyConfigs=e;const i=(n=this.extraData)==null?void 0:n.disabledMacros,a=e.map(async o=>{var l;if(this.proxySetter(o),this._virualShaderProps(e),o.bundleType==="macro"){const s=o.macroInfo,h=t.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=t.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(e){const{prop:t,onChange:r,bundleType:i}=e,a=async(n,o)=>{var s;const l=this._engineObject.shaderData;i==="macro"?l.enableMacro(t,n):await x(this,t,n,e.engineType??((s=e.uiInfo)==null?void 0:s.type)),await r(this,t,n),o!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(t,a),this.shaderDataKeys.add(t)}_virualShaderProps(e){const t=this;e.forEach(r=>{Y(t,r.prop)})}refreshFormConfig(e,t){var i,a,n,o,l;const r={root:[],groups:{}};if(t){for(const s of e)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=t.macros.find(h=>h.name===s.prop))==null?void 0:o.value)??s.defaultValue:this[s.prop]=((l=t.shaderData[s.prop])==null?void 0:l.value)??s.defaultValue}}this.formConfig=r}refreshAnimatableProperties(e){var t,r,i;this._additionAnimatableProperties.length=0;for(const a of e){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:(t=a.uiInfo)!=null&&t.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(e){var c;const t=JSON.parse(await e.text());let r=t.shaderRef;const i=t.shaderData,a=t.macros;if(!r&&typeof t.shader=="string"){const d=Object.values(this.root.assetStore.assets).find(u=>u.meta.type==="Shader"&&u.meta.builtinShaderName===t.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,t),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",O.Input,this.name),this._checkSchemaOnInit(t,o)}_checkSchemaOnInit(e,t){e.shader!==t.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(e){const t=this;this.bindEngineObject(e),t.shader=e.shader.name,t._name=e.name??"";const i=Object.values(this.root.assetStore.assets).filter(h=>h.meta.type==="Shader"&&!!h.meta.builtinShaderName).find(h=>h.meta.builtinShaderName===e.shader.name);this.shaderRef={refId:i.id};const a=e.shaderData,n=new Set((i.properties??[]).map(h=>h.prop));if(n.has("isTransparent")&&(t.isTransparent=a.getInt("blendEnabled")===1),n.has("material_AlphaCutoff")&&(t.alphaCutoff=a.getFloat("material_AlphaCutoff")),n.has("renderFace"))switch(a.getInt("rasterStateCullMode")){case C.Back:t.renderFace=v.Front;break;case C.Front:t.renderFace=v.Back;break;case C.Off:t.renderFace=v.Double;break}n.has("blendMode")&&(t.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 e;(e=this.engineObject)==null||e.destroy(!0)}rename(e){return this.root.assetFacade.persistAssetMain(this.id),super.rename(e)}_getMainData(e){var s,h,c;const t=[],r=(e??this.engineObject).shaderData;r.getMacros(t);const i=t.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 e=new re(this.engine),t=[];e.shaderData.getMacros(t);const r=t.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h});this.bindEngineObject(e);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:e.shader.name,macros:r};return this._proxyShaderProps(a,o,!1),o}async onSubAssetEdit(){var i;const e=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(e.engineObject),await e.applyBoundPathChange("name",O.Input,e.name),e.initByEngineObject(e.engineObject),e.updateThumbnail(),await this.root.assetFacade.persistAssetMain(e.id);const t=await this.root.assetStore.getAssetByRef({refId:this.mainId}),r=((i=t.engineObject.materials)==null?void 0:i.indexOf(this._engineObject))??-1;r>=0&&await t.replaceMaterial(r,e.getCurrentRef()),this.root.assetStore.selectAsset(e.id)}saveMainImmediately(){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately().then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}async _onDrop(e,t){var i,a;const r="material_BaseTexture";if(r in this){const n=t.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:e,sceneUIStore:t}=this.root,r=t.hoveredEntityId;if(r){const i=e.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,e,t)=>e in p?N(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var f=(p,e,t)=>($(p,typeof e!="symbol"?e+"":e,t),t);import{y as j,bD as F,bE as V,bF as U,F as G,ai as K,V as z,b3 as H,b2 as b,j as Q,q as k,u as W,bG as D,bH as A,a1 as m,a2 as T,bI as J,C as O,bJ as w,bK as Y,aE as S,bL as q,e as E,bM 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-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.js";import{M as ne}from"./MaterialInspector-237b6a5e.js";import{A as oe}from"./AssetViewer-1073ddb5.js";import{E as g,s as x}from"./shader-data-utils-6ef12596.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:t}=this;t.engineObject.shader.name==="Effect/Particle"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(t.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(t.engineObject))})}setViewAsset(t,r){if(!(t instanceof y))return;const i=r.createChild("material");this._asset=t;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 t;super.stopViewAsset(),(t=this._shaderReactionDisposer)==null||t.call(this),this._shaderReactionDisposer=null,this._asset=null}}class P{static update(e,t){if(!(t instanceof y))return;const r=t.engineObject;if(!r||!r.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(e),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 e,t;(e=this.sphereRenderer)!=null&&e.entity&&(this.sphereRenderer.entity.isActive=!1),(t=this.particleRenderer)!=null&&t.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(e){const t=this.entity=e.createChild("material"),r=this.sphereRenderer=t.createChild("mat").addComponent(j);r.mesh=F.createSphere(e.engine,2,64,!0),this.particleRenderer=t.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,e,t,r)=>{for(var i=r>1?void 0:r?de(e,t):e,a=p.length-1,n;a>=0;a--)(n=p[a])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&ce(e,t,i),i};let y=class extends Q{constructor(e){super(e);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(e,t){e.shader=t;const r=e.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"),t.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(e){this._autoSaveSuppressed=e}setRenderQueueType(e){this.engineObject.shaderData.setInt("renderQueueType",e)}setBlendStateEnabled(e){this.engineObject.shaderData.setInt("blendEnabled",e?1:0)}setDepthWriteEnabled(e){this.engineObject.shaderData.setInt("depthWriteEnabled",e?1:0)}setCullMode(e){this.engineObject.shaderData.setInt("rasterStateCullMode",e)}setBlendMode(e){const t=this.engineObject.shaderData;switch(e){case A.Normal:t.setInt("sourceColorBlendFactor",m.SourceAlpha),t.setInt("destinationColorBlendFactor",m.OneMinusSourceAlpha),t.setInt("sourceAlphaBlendFactor",m.One),t.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),t.setInt("colorBlendOperation",T.Add),t.setInt("alphaBlendOperation",T.Add);break;case A.Additive:t.setInt("sourceColorBlendFactor",m.SourceAlpha),t.setInt("destinationColorBlendFactor",m.One),t.setInt("sourceAlphaBlendFactor",m.One),t.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),t.setInt("colorBlendOperation",T.Add),t.setInt("alphaBlendOperation",T.Add);break}}bindShaderAsset(e,t){for(const r of this.shaderDataKeys)this.removePropertyChangeListener(r);return this.shaderDataKeys.clear(),e.onReady().then(async()=>{var i;if(this.isInitCompleted){if(e.shaderScriptRefId){const a=this.root.assetStore.getAsset(e.shaderScriptRefId.refId);a==null||a.onShaderChange(this._engineObject)}else e.builtinUIScript&&e.builtinUIScript.onMaterialShaderSwitched(this._engineObject);t=this._getMainData()}const r=e.properties?J(e.properties):[];e.isBuiltinShader()&&y.initBuiltinMaterial(this.engineObject,e.engineObject),t=t||this._getMainData(),await this._proxyShaderProps(r,t,this.isInitCompleted),this.refreshFormConfig(r,t),this.refreshAnimatableProperties(r),this.shaderRef&&this.root.assetStore.getAssetByRef(this.shaderRef).then(a=>{a!==e&&(a==null||a.removeReferencedMaterial(this))}).catch(()=>{}),e.addReferencedMaterial(this),this.shaderRef={refId:e.id},await this.applyBoundPathChange("shader",O.AssetPicker,this.shaderRef),(i=this.updateThumbnail)==null||i.call(this)})}async _proxyShaderProps(e,t,r=!0){var n;this.proxyConfigs=e;const i=(n=this.extraData)==null?void 0:n.disabledMacros,a=e.map(async o=>{var l;if(this.proxySetter(o),this._virualShaderProps(e),o.bundleType==="macro"){const s=o.macroInfo,h=t.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=t.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(e){const{prop:t,onChange:r,bundleType:i}=e,a=async(n,o)=>{var s;const l=this._engineObject.shaderData;i==="macro"?l.enableMacro(t,n):await x(this,t,n,e.engineType??((s=e.uiInfo)==null?void 0:s.type)),await r(this,t,n),o!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(t,a),this.shaderDataKeys.add(t)}_virualShaderProps(e){const t=this;e.forEach(r=>{Y(t,r.prop)})}refreshFormConfig(e,t){var i,a,n,o,l;const r={root:[],groups:{}};if(t){for(const s of e)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=t.macros.find(h=>h.name===s.prop))==null?void 0:o.value)??s.defaultValue:this[s.prop]=((l=t.shaderData[s.prop])==null?void 0:l.value)??s.defaultValue}}this.formConfig=r}refreshAnimatableProperties(e){var t,r,i;this._additionAnimatableProperties.length=0;for(const a of e){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:(t=a.uiInfo)!=null&&t.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(e){var c;const t=JSON.parse(await e.text());let r=t.shaderRef;const i=t.shaderData,a=t.macros;if(!r&&typeof t.shader=="string"){const d=Object.values(this.root.assetStore.assets).find(u=>u.meta.type==="Shader"&&u.meta.builtinShaderName===t.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,t),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",O.Input,this.name),this._checkSchemaOnInit(t,o)}_checkSchemaOnInit(e,t){e.shader!==t.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(e){const t=this;this.bindEngineObject(e),t.shader=e.shader.name,t._name=e.name??"";const i=Object.values(this.root.assetStore.assets).filter(h=>h.meta.type==="Shader"&&!!h.meta.builtinShaderName).find(h=>h.meta.builtinShaderName===e.shader.name);this.shaderRef={refId:i.id};const a=e.shaderData,n=new Set((i.properties??[]).map(h=>h.prop));if(n.has("isTransparent")&&(t.isTransparent=a.getInt("blendEnabled")===1),n.has("material_AlphaCutoff")&&(t.alphaCutoff=a.getFloat("material_AlphaCutoff")),n.has("renderFace"))switch(a.getInt("rasterStateCullMode")){case C.Back:t.renderFace=v.Front;break;case C.Front:t.renderFace=v.Back;break;case C.Off:t.renderFace=v.Double;break}n.has("blendMode")&&(t.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 e;(e=this.engineObject)==null||e.destroy(!0)}rename(e){return this.root.assetFacade.persistAssetMain(this.id),super.rename(e)}_getMainData(e){var s,h,c;const t=[],r=(e??this.engineObject).shaderData;r.getMacros(t);const i=t.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 e=new re(this.engine),t=[];e.shaderData.getMacros(t);const r=t.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h});this.bindEngineObject(e);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:e.shader.name,macros:r};return this._proxyShaderProps(a,o,!1),o}async onSubAssetEdit(){var i;const e=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(e.engineObject),await e.applyBoundPathChange("name",O.Input,e.name),e.initByEngineObject(e.engineObject),e.updateThumbnail(),await this.root.assetFacade.persistAssetMain(e.id);const t=await this.root.assetStore.getAssetByRef({refId:this.mainId}),r=((i=t.engineObject.materials)==null?void 0:i.indexOf(this._engineObject))??-1;r>=0&&await t.replaceMaterial(r,e.getCurrentRef()),this.root.assetStore.selectAsset(e.id)}saveMainImmediately(){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately().then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}async _onDrop(e,t){var i,a;const r="material_BaseTexture";if(r in this){const n=t.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:e,sceneUIStore:t}=this.root,r=t.hoveredEntityId;if(r){const i=e.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};