@galacean/cli 2.0.0-alpha.12 → 2.0.0-alpha.14

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 (160) hide show
  1. package/dist/cli.bundle.cjs +134 -135
  2. package/dist/viewport-client/_static/Accordion-3d330bc6.js +1 -0
  3. package/dist/viewport-client/_static/{AmbientLightAsset-f70b95f1.js → AmbientLightAsset-bdbc4e1d.js} +2 -2
  4. package/dist/viewport-client/_static/AnimationClipAsset-9167378a.js +1 -0
  5. package/dist/viewport-client/_static/AnimatorControllerAsset-21dc6332.js +1 -0
  6. package/dist/viewport-client/_static/AnimatorStore-18d3c551.js +1 -0
  7. package/dist/viewport-client/_static/{AssetViewer-bc198e16.js → AssetViewer-64cd01fa.js} +1 -1
  8. package/dist/viewport-client/_static/AudioAsset-0c828c80.js +1 -0
  9. package/dist/viewport-client/_static/AudioComponent-fbff3825.js +1 -0
  10. package/dist/viewport-client/_static/{Callout-cb4a55ff.js → Callout-ba7e2adf.js} +1 -1
  11. package/dist/viewport-client/_static/CameraComponent-74975570.js +1 -0
  12. package/dist/viewport-client/_static/{Component-f923abb1.js → Component-ed7aa0ab.js} +1 -1
  13. package/dist/viewport-client/_static/DirectLight-b884e7db.js +1 -0
  14. package/dist/viewport-client/_static/FontAsset-d1ced18d.js +5 -0
  15. package/dist/viewport-client/_static/FormItemArray-6d69acd4.js +6 -0
  16. package/dist/viewport-client/_static/{GlTFAsset-9c68f862.js → GlTFAsset-2723b84a.js} +9 -9
  17. package/dist/viewport-client/_static/IconEdit-ab77303f.js +6 -0
  18. package/dist/viewport-client/_static/{IconPointFilled-a304fd34.js → IconPointFilled-811fc660.js} +1 -1
  19. package/dist/viewport-client/_static/LightBaseComponent-12dc27d1.js +1 -0
  20. package/dist/viewport-client/_static/LottieAnimationComponent-c48c5eb5.js +1 -0
  21. package/dist/viewport-client/_static/LottieAsset-3692580d.js +6 -0
  22. package/dist/viewport-client/_static/MarkdownAsset-bcb90be4.js +1 -0
  23. package/dist/viewport-client/_static/MaterialAsset-6ef9b4ed.js +1 -0
  24. package/dist/viewport-client/_static/MaterialInspector-e8242674.js +1 -0
  25. package/dist/viewport-client/_static/Menu-0b8da92f.js +17 -0
  26. package/dist/viewport-client/_static/MeshAsset-ca9305e5.js +1 -0
  27. package/dist/viewport-client/_static/MeshRendererBaseComponent-9efd3943.js +1 -0
  28. package/dist/viewport-client/_static/MeshRendererComponent-c9a03641.js +1 -0
  29. package/dist/viewport-client/_static/{MeshThumbnail-49273f71.js → MeshThumbnail-ab28b3b8.js} +1 -1
  30. package/dist/viewport-client/_static/ParticleRendererComponent-96947c1d.js +26 -0
  31. package/dist/viewport-client/_static/PhysicsMaterialAsset-4a1e5ea3.js +1 -0
  32. package/dist/viewport-client/_static/PhysicsStore-33cac578.js +1 -0
  33. package/dist/viewport-client/_static/PointLight-fd514526.js +1 -0
  34. package/dist/viewport-client/_static/PostProcessComponent-d0ea27a4.js +6 -0
  35. package/dist/viewport-client/_static/PrefabAsset-9179b95c.js +1 -0
  36. package/dist/viewport-client/_static/PrimitiveMesh-0572a073.js +1 -0
  37. package/dist/viewport-client/_static/ProxyConfigs-3a5fd860.js +1 -0
  38. package/dist/viewport-client/_static/{ReferencedMaterial-a87818f3.js → ReferencedMaterial-5773c9d2.js} +1 -1
  39. package/dist/viewport-client/_static/RenderTargetAsset-ab6e06d2.js +1 -0
  40. package/dist/viewport-client/_static/SceneAsset-385fa837.js +1 -0
  41. package/dist/viewport-client/_static/{ShaderAsset-cb3ff628.js → ShaderAsset-f4514b03.js} +6 -6
  42. package/dist/viewport-client/_static/ShaderChunkAsset-34116f2c.js +5 -0
  43. package/dist/viewport-client/_static/{ShaderUIScriptAsset-d13fa4e2.js → ShaderUIScriptAsset-fc503291.js} +5 -5
  44. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-494ad439.js +1 -0
  45. package/dist/viewport-client/_static/SpineAnimationComponent-3918d7b5.js +1 -0
  46. package/dist/viewport-client/_static/SpineSkeletonDataAsset-27244892.js +1 -0
  47. package/dist/viewport-client/_static/SpotLight-f9972dc0.js +1 -0
  48. package/dist/viewport-client/_static/SpriteAsset-558ffca8.js +6 -0
  49. package/dist/viewport-client/_static/SpriteAtlasAsset-cdc34386.js +1 -0
  50. package/dist/viewport-client/_static/SpriteBaseComponent-3edafa31.js +1 -0
  51. package/dist/viewport-client/_static/SpriteMaskComponent-de2e5231.js +1 -0
  52. package/dist/viewport-client/_static/SpriteRendererComponent-e999e735.js +1 -0
  53. package/dist/viewport-client/_static/{TextBaseComponent-69233798.js → TextBaseComponent-ce1402c3.js} +2 -2
  54. package/dist/viewport-client/_static/TextRendererComponent-f7c0deae.js +1 -0
  55. package/dist/viewport-client/_static/TextureAsset-39fb07fe.js +36 -0
  56. package/dist/viewport-client/_static/Tooltip-82063435.js +1 -0
  57. package/dist/viewport-client/_static/TrailRendererComponent-37f5c981.js +1 -0
  58. package/dist/viewport-client/_static/TransformBaseComponent-713d57e9.js +1 -0
  59. package/dist/viewport-client/_static/TransformComponent-40a57948.js +1 -0
  60. package/dist/viewport-client/_static/XRReferenceImageAsset-2f6ff226.js +1 -0
  61. package/dist/viewport-client/_static/audio-7120ec91.js +1 -0
  62. package/dist/viewport-client/_static/glTFIO-79bbca27.js +1 -0
  63. package/dist/viewport-client/_static/index-483b5738.js +1 -0
  64. package/dist/viewport-client/_static/{index-98982ce2.js → index-74130ff3.js} +1 -1
  65. package/dist/viewport-client/_static/index-78269e76.js +1 -0
  66. package/dist/viewport-client/_static/index-7834b582.js +1 -0
  67. package/dist/viewport-client/_static/{index-237c84cd.js → index-7917f782.js} +3 -3
  68. package/dist/viewport-client/_static/index-7acd49d2.js +1 -0
  69. package/dist/viewport-client/_static/index-9d3917da.js +1 -0
  70. package/dist/viewport-client/_static/index-a9b2675e.js +1 -0
  71. package/dist/viewport-client/_static/index-aec7e708.js +11487 -0
  72. package/dist/viewport-client/_static/index-b5582401.js +1 -0
  73. package/dist/viewport-client/_static/{index-e46ec5b1.js → index-bfe6f30e.js} +7 -7
  74. package/dist/viewport-client/_static/index-c63c9606.js +2 -0
  75. package/dist/viewport-client/_static/index-cd1fee9d.js +1 -0
  76. package/dist/viewport-client/_static/index-e73ceaed.js +1 -0
  77. package/dist/viewport-client/_static/index-e8a45e82.js +1 -0
  78. package/dist/viewport-client/_static/index-f2cb64af.js +1 -0
  79. package/dist/viewport-client/_static/index-fbe040bf.js +31 -0
  80. package/dist/viewport-client/_static/ktx2-encoder-53b21bdc.js +1 -0
  81. package/dist/viewport-client/_static/{module-5c85b07e.js → module-220b3921.js} +1 -1
  82. package/dist/viewport-client/_static/{module-6406b050.js → module-8816772d.js} +1 -1
  83. package/dist/viewport-client/_static/{module-107b7430.js → module-ffeaf99f.js} +1 -1
  84. package/dist/viewport-client/_static/postmen-2f47f6bb.js +1 -0
  85. package/dist/viewport-client/index.html +2 -2
  86. package/package.json +1 -1
  87. package/dist/viewport-client/_static/Accordion-4897319b.js +0 -6
  88. package/dist/viewport-client/_static/AnimationClipAsset-01f3deb6.js +0 -1
  89. package/dist/viewport-client/_static/AnimatorControllerAsset-b7424e9c.js +0 -1
  90. package/dist/viewport-client/_static/AnimatorStore-fd98c00e.js +0 -1
  91. package/dist/viewport-client/_static/AssetPreviewer-24e31d97.js +0 -6
  92. package/dist/viewport-client/_static/AudioAsset-eae03324.js +0 -1
  93. package/dist/viewport-client/_static/AudioComponent-44070c2c.js +0 -1
  94. package/dist/viewport-client/_static/CameraComponent-907ac745.js +0 -1
  95. package/dist/viewport-client/_static/CanvasRenderer-9dd98cb3.js +0 -1
  96. package/dist/viewport-client/_static/DirectLight-58f5fe9e.js +0 -1
  97. package/dist/viewport-client/_static/FontAsset-abfb9a8a.js +0 -5
  98. package/dist/viewport-client/_static/FormItemArray-66be8701.js +0 -1
  99. package/dist/viewport-client/_static/IconPlayerPlayFilled-b058c98f.js +0 -6
  100. package/dist/viewport-client/_static/InstanceEditorAsset-a70e73fe.js +0 -1
  101. package/dist/viewport-client/_static/LightBaseComponent-fbc3ae49.js +0 -1
  102. package/dist/viewport-client/_static/LottieAnimationComponent-1c3e02a5.js +0 -1
  103. package/dist/viewport-client/_static/LottieAsset-377c1419.js +0 -1
  104. package/dist/viewport-client/_static/MarkdownAsset-7ea387a9.js +0 -1
  105. package/dist/viewport-client/_static/MaterialAsset-74a15124.js +0 -1
  106. package/dist/viewport-client/_static/MaterialInspector-aec1248b.js +0 -1
  107. package/dist/viewport-client/_static/Menu-cd3be298.js +0 -17
  108. package/dist/viewport-client/_static/MeshAsset-73e2cc8e.js +0 -1
  109. package/dist/viewport-client/_static/MeshRendererBaseComponent-3a0e09ed.js +0 -1
  110. package/dist/viewport-client/_static/MeshRendererComponent-5385d30f.js +0 -1
  111. package/dist/viewport-client/_static/ParticleRendererComponent-5a7b57d9.js +0 -21
  112. package/dist/viewport-client/_static/PhysicsMaterialAsset-a5ac9f82.js +0 -1
  113. package/dist/viewport-client/_static/PhysicsStore-0729e76d.js +0 -1
  114. package/dist/viewport-client/_static/PointLight-0e1d1546.js +0 -1
  115. package/dist/viewport-client/_static/PostProcessComponent-8276d33c.js +0 -1
  116. package/dist/viewport-client/_static/PrefabAsset-1a7edfbd.js +0 -1
  117. package/dist/viewport-client/_static/PrimitiveMesh-3ce6fa2f.js +0 -1
  118. package/dist/viewport-client/_static/ProxyConfigs-4de3304c.js +0 -1
  119. package/dist/viewport-client/_static/RenderTargetAsset-33c0d9e7.js +0 -1
  120. package/dist/viewport-client/_static/SceneAsset-8917c210.js +0 -1
  121. package/dist/viewport-client/_static/ShaderChunkAsset-83f923f4.js +0 -5
  122. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-2a8323bf.js +0 -1
  123. package/dist/viewport-client/_static/SpineAnimationComponent-e733d50f.js +0 -1
  124. package/dist/viewport-client/_static/SpineSkeletonDataAsset-b64a3ee3.js +0 -1
  125. package/dist/viewport-client/_static/SpotLight-ca6c0c3b.js +0 -1
  126. package/dist/viewport-client/_static/SpriteAsset-9a31ec24.js +0 -1
  127. package/dist/viewport-client/_static/SpriteAtlasAsset-a862db46.js +0 -1
  128. package/dist/viewport-client/_static/SpriteBaseComponent-f6f1731f.js +0 -1
  129. package/dist/viewport-client/_static/SpriteMaskComponent-778be04f.js +0 -1
  130. package/dist/viewport-client/_static/SpriteRendererComponent-2b4d153b.js +0 -1
  131. package/dist/viewport-client/_static/TextRendererComponent-130b4e99.js +0 -1
  132. package/dist/viewport-client/_static/TextureAsset-28fedf2a.js +0 -36
  133. package/dist/viewport-client/_static/ThumbnailMixin-35997457.js +0 -1
  134. package/dist/viewport-client/_static/ThumbnailRegistry-495c18c9.js +0 -1
  135. package/dist/viewport-client/_static/Tooltip-33f770ba.js +0 -1
  136. package/dist/viewport-client/_static/TrailRendererComponent-148550b5.js +0 -1
  137. package/dist/viewport-client/_static/TransformBaseComponent-02318c5a.js +0 -1
  138. package/dist/viewport-client/_static/TransformComponent-96106065.js +0 -1
  139. package/dist/viewport-client/_static/ViewerManager-202b570a.js +0 -1
  140. package/dist/viewport-client/_static/XRReferenceImageAsset-6a6adb3b.js +0 -1
  141. package/dist/viewport-client/_static/audio-244358e2.js +0 -1
  142. package/dist/viewport-client/_static/glTFIO-45ff9a17.js +0 -1
  143. package/dist/viewport-client/_static/index-0a8702e2.js +0 -11217
  144. package/dist/viewport-client/_static/index-37c74ae9.js +0 -26
  145. package/dist/viewport-client/_static/index-4cca0201.js +0 -1
  146. package/dist/viewport-client/_static/index-59732f86.js +0 -1
  147. package/dist/viewport-client/_static/index-6c8198f6.js +0 -2
  148. package/dist/viewport-client/_static/index-6f827618.js +0 -1
  149. package/dist/viewport-client/_static/index-803ca489.js +0 -1
  150. package/dist/viewport-client/_static/index-85a6cf6a.js +0 -1
  151. package/dist/viewport-client/_static/index-b3d51f87.js +0 -1
  152. package/dist/viewport-client/_static/index-be6bc38a.js +0 -177
  153. package/dist/viewport-client/_static/index-c403cbcd.js +0 -1
  154. package/dist/viewport-client/_static/index-e73966ae.js +0 -1
  155. package/dist/viewport-client/_static/index-e95b4498.js +0 -1
  156. package/dist/viewport-client/_static/index-f5a67a46.js +0 -1
  157. package/dist/viewport-client/_static/ktx-parse.modern-6c9f771f.js +0 -1
  158. package/dist/viewport-client/_static/ktx2-encoder-1e63c1eb.js +0 -1
  159. package/dist/viewport-client/_static/postmen-45d4c238.js +0 -1
  160. package/dist/viewport-client/_static/utilities-e09052e3.js +0 -11
@@ -1 +0,0 @@
1
- var re=Object.defineProperty;var ae=(s,e,t)=>e in s?re(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var c=(s,e,t)=>(ae(s,typeof e!="symbol"?e+"":e,t),t);import{aT as j,aU as z,aD as p,b9 as L,cH as P,b8 as te,ex as I,cF as ie,bz as le,n as pe,d8 as E,ey as R,ez as K,eA as Y,eB as G,cK as N,f as ce,w as de,s as y,p as h,e as r,eC as ye,E as oe,eD as H,eE as S,eF as V,C as f,eG as J,eH as he,eI as U,dJ as se,eJ as me,eK as ue,bd as fe,d6 as q,bf as be,bg as ge}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as A}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{F as Ce}from"./FormItemArray-66be8701.js";function xe(s,e){var a;const t=(a=s==null?void 0:s.root)==null?void 0:a.assetStore,i=(t==null?void 0:t.assets)??{},o=Object.values(i).filter(l=>{var d;return((d=l==null?void 0:l.getMetaConfig)==null?void 0:d.call(l).type)==="PhysicsMaterial"}),n=e!=null&&e.refId?i[e.refId]:void 0;return{assetStore:t,assets:o,asset:n}}const Se={BoxColliderShape:["size","isTrigger","position","rotation","material"],CapsuleColliderShape:["radius","height","upAxis","isTrigger","position","rotation","material"],PlaneColliderShape:["isTrigger","position","rotation","material"],SphereColliderShape:["radius","isTrigger","position","rotation","material"]};function Pe(s){const e={};return Object.keys(s.props).forEach(t=>{Se[s.class].includes(t)&&(e[t]=s.props[t])}),e}const je=async(s,e,t)=>{s.engineObject.clearShapes();for(let i=0;i<t.length;i++){const o=t[i];let n;switch(o.class){case"BoxColliderShape":{n=new G;const d=n.size;d.copyFrom(o.props.size),n.size=d;break}case"CapsuleColliderShape":{n=new Y,n.radius=o.props.radius,n.height=o.props.height,n.upAxis=o.props.upAxis;break}case"PlaneColliderShape":{n=new K;break}case"SphereColliderShape":{n=new R,n.radius=o.props.radius;break}}if(o.props.material)try{const d=await s.root.assetStore.getAssetByRef({refId:o.props.material.refId});d&&(n.material=d.engineObject)}catch(d){console.error(d)}n.isTrigger=o.props.isTrigger;const a=n.position;a.copyFrom(o.props.position),n.position=a;const l=n.rotation;l.copyFrom(o.props.rotation),n.rotation=l,s.engineObject.addShape(n),o.engineObject=n}},ve=s=>s.map(e=>{if(e instanceof G)return{class:"BoxColliderShape",props:{isTrigger:e.isTrigger,size:{x:e.size.x,y:e.size.y,z:e.size.z},position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof Y)return{class:"CapsuleColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,height:e.height,upAxis:e.upAxis,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof K)return{class:"PlaneColliderShape",props:{isTrigger:e.isTrigger,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof R)return{class:"SphereColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}}}),ze=j(({item:s,onItemChange:e})=>{const{t}=z();return p.jsx(p.Fragment,{children:p.jsx(L,{label:t("physics.shape.box.size.title"),info:t("physics.shape.box.size.info"),min:0,value:{x:s.props.size.x,y:s.props.size.y,z:s.props.size.z},onChange:(i,o)=>{const n=i==null?void 0:i[o];typeof n=="number"&&e(a=>{a.props.size={...a.props.size,[o]:n}})}})})}),Oe=j(()=>p.jsx(p.Fragment,{})),De=j(({item:s,onItemChange:e})=>{const{t}=z();return p.jsx(p.Fragment,{children:p.jsx(P,{label:t("physics.shape.sphere.radius.title"),info:t("physics.shape.sphere.radius.info"),value:s.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(o=>{o.props.radius=i})}})})}),_e=j(({item:s,onItemChange:e})=>{const{t}=z();return p.jsxs(p.Fragment,{children:[p.jsx(P,{label:t("physics.shape.capsule.radius.title"),info:t("physics.shape.capsule.radius.info"),value:s.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(o=>{o.props.radius=i})}}),p.jsx(P,{label:t("physics.shape.capsule.height.title"),info:t("physics.shape.capsule.height.info"),value:s.props.height,min:0,onChange:i=>{typeof i=="number"&&e(o=>{o.props.height=i})}}),p.jsx(te,{label:t("physics.shape.capsule.up-axis.title"),info:t("physics.shape.capsule.up-axis.info"),options:[{label:"X",value:I.X},{label:"Y",value:I.Y},{label:"Z",value:I.Z}],value:s.props.upAxis,onChange:i=>{e(o=>{o.props.upAxis=i})}})]})}),we={BoxColliderShape:ze,CapsuleColliderShape:_e,PlaneColliderShape:Oe,SphereColliderShape:De},X={BoxColliderShape:{class:"BoxColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},size:{x:1,y:1,z:1},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},CapsuleColliderShape:{class:"CapsuleColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,height:2,upAxis:I.Y,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},PlaneColliderShape:{class:"PlaneColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},SphereColliderShape:{class:"SphereColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}}},Te=j(({collider:s,item:e,onItemChange:t})=>{const{t:i}=z(),o=we[e.class],{assetStore:n,assets:a,asset:l}=xe(s,e.props.material);return e.engineObject?p.jsxs(p.Fragment,{children:[p.jsx(ie,{label:i("physics.collider.trigger.title"),info:i("physics.collider.trigger.info"),value:e.props.isTrigger,onChange:u=>{t(m=>{m.props.isTrigger=u})}}),p.jsx(le,{label:i("physics.collider.material.title"),info:i("physics.collider.material.info"),dropLayer:pe.PhysicsMaterial,value:l==null?void 0:l.name,assets:a,onSelect:u=>{t(m=>{m.props.material=u.getCurrentRef()})},onLocate:()=>{var u;l&&l.id&&((u=n==null?void 0:n.selectAsset)==null||u.call(n,l.id))}}),p.jsx(o,{item:e,onItemChange:t}),p.jsx(L,{label:i("physics.collider.local-position.title"),info:i("physics.collider.local-position.info"),value:{x:e.props.position.x,y:e.props.position.y,z:e.props.position.z},onChange:(u,m)=>{const b=u==null?void 0:u[m];typeof b=="number"&&t(g=>{g.props.position={...g.props.position,[m]:b}})}}),p.jsx(L,{label:i("physics.collider.rotation.title"),info:i("physics.collider.rotation.info"),value:{x:e.props.rotation.x,y:e.props.rotation.y,z:e.props.rotation.z},onChange:(u,m)=>{const b=u==null?void 0:u[m];typeof b=="number"&&t(g=>{g.props.rotation={...g.props.rotation,[m]:b}})}})]}):null}),Ae=j(({collider:s,item:e,index:t,onModelChange:i})=>{const{t:o}=z(),n=[{label:o("physics.shape.box.title"),value:"BoxColliderShape"},{label:o("physics.shape.capsule.title"),value:"CapsuleColliderShape"}];s.engineObject instanceof E||(n.push({label:o("physics.shape.plane.title"),value:"PlaneColliderShape"}),n.push({label:o("physics.shape.sphere.title"),value:"SphereColliderShape"}));const l=d=>{const u=N(s.colliderShapes),m=u[t];m&&(d(m),i==null||i("colliderShapes",u))};return p.jsxs(p.Fragment,{children:[p.jsx(te,{label:o("physics.shape.type.title"),info:o("physics.shape.type.info"),value:e.class,options:n,onChange:d=>{X[d].class!==e.class&&l(m=>{Object.assign(m,N(X[d]))})}}),p.jsx(Te,{collider:s,item:e,onItemChange:l})]})}),Fe=j(({model:s,inspectorConfig:e,onModelChange:t})=>{const{label:i}=e,o=s.colliderShapes,{t:n}=z(),a=l=>{const d=N(o);l(d),t==null||t("colliderShapes",d)};return p.jsx(Ce,{label:i,items:o.map((l,d)=>({removable:!0,children:p.jsx(Ae,{collider:s,item:l,index:d,onModelChange:t}),id:`${d}`,name:n("physics.shape.item-name",{index:d})})),addable:!0,onAdd:()=>{a(l=>{l.push(N(X.BoxColliderShape))})},onDelete:l=>{a(d=>{d.splice(+l.id,1)})},addItemText:n("physics.shape.add")})});var Me=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Be=(s,e,t,i)=>{for(var o=i>1?void 0:i?Ve(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&Me(e,t,o),o};async function Ie(s,e){let t;switch(s.class){case"BoxColliderShape":{t=new G;const i=t.size,o=s.props.size;o&&(i.set(o.x,o.y,o.z),t.size=i);break}case"CapsuleColliderShape":{t=new Y,s.props.radius!==void 0&&(t.radius=s.props.radius),s.props.height!==void 0&&(t.height=s.props.height),s.props.upAxis!==void 0&&(t.upAxis=s.props.upAxis);break}case"PlaneColliderShape":{t=new K;break}case"SphereColliderShape":{t=new R,s.props.radius!==void 0&&(t.radius=s.props.radius);break}default:throw new Error(`Unknown collider shape class: ${s.class}`)}if(s.props.isTrigger!==void 0&&(t.isTrigger=s.props.isTrigger),s.props.position){const i=s.props.position,o=t.position;o.set(i.x,i.y,i.z),t.position=o}if(s.props.rotation){const i=s.props.rotation,o=t.rotation;o.set(i.x,i.y,i.z),t.rotation=o}if(s.props.material){const i=s.props.material;if(i.refId){const o=await e.getAssetByRef({refId:i.refId});if(!(o!=null&&o.engineObject))throw ye(`Physics material is not ready for refId: ${i.refId}`);t.material=o.engineObject}}return t}class $ extends oe{constructor(){super(...arguments);c(this,"colliderShapes",[])}}Be([ce({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:de.Object,getEngineValue:s=>s.shapes,getEditorValue:ve}),y({type:"methods",key:"addShape",onSerialize:s=>s.map(e=>[{class:e.class,props:Pe(e)}]),onDeserialize:s=>s.map(e=>e[0]),resolveMethodArguments:async(s,e)=>{const t=[];for(const i of s)if(i&&typeof i=="object"&&"class"in i&&"props"in i){const n=await Ie(i,e.root.assetStore);t.push(n)}else t.push(i);return t}}),h({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Fe,onChange:je})],$.prototype,"colliderShapes",2);var Ne=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Le=(s,e,t,i)=>{for(var o=i>1?void 0:i?$e(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&Ne(e,t,o),o};let W=class extends ${constructor(s,e){super(s,e)}};W=Le([A({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],W);const Q=s=>Object.keys(S).filter(e=>(s&S[e])!==0).map(e=>String(S[e])),Ee=j(({model:s,onModelChange:e})=>{const t=o=>{const a=o.map(l=>parseInt(l)).reduce((l,d)=>l|d,S.None);e==null||e("constraints",a)},{t:i}=z();return p.jsxs(p.Fragment,{children:[p.jsx(H,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:Q(s.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:t}),p.jsx(H,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:Q(s.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:t})]})});var Je=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,x=(s,e,t,i)=>{for(var o=i>1?void 0:i?Xe(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&Je(e,t,o),o};let C=class extends ${constructor(e,t){super(e,t);c(this,"isKinematic",!1);c(this,"collisionDetectionMode",V.Discrete);c(this,"constraints",S.None);c(this,"mass",1);c(this,"useGravity",!0);c(this,"linearDamping",0);c(this,"angularDamping",.05);c(this,"automaticCenterOfMass",!0);c(this,"centerOfMass",{x:0,y:0,z:0});c(this,"automaticInertiaTensor",!0);c(this,"inertiaTensor",{x:1,y:1,z:1});c(this,"linearVelocity",{x:0,y:0,z:0});c(this,"angularVelocity",{x:0,y:0,z:0});c(this,"maxAngularVelocity",100);c(this,"maxDepenetrationVelocity",10000000331813535e16);c(this,"sleepThreshold",.005);c(this,"solverIterations",4)}onEnabled(){this.applyBoundPathChange("enabled",f.Toggle,!1)}onInitComplete(){this.applyBoundPathChange("enabled",f.Toggle,!1)}};x([y(),h({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:f.Boolean,bindPath:"isKinematic"})],C.prototype,"isKinematic",2);x([y(),h({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:f.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:V.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:V.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:V.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:V.ContinuousSpeculative}]})],C.prototype,"collisionDetectionMode",2);x([y(),h({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:Ee,bindPath:"constraints"})],C.prototype,"constraints",2);x([y(),h({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:f.Number})],C.prototype,"mass",2);x([y(),h({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:f.Boolean})],C.prototype,"useGravity",2);x([y(),h({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:f.Number})],C.prototype,"linearDamping",2);x([y(),h({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:f.Number})],C.prototype,"angularDamping",2);x([y(),h({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:f.Boolean,onChange:(s,e,t)=>{if(t){const i=s.engineObject.centerOfMass;s.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],C.prototype,"automaticCenterOfMass",2);x([y(),h({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:f.Vector3,bindPath:"centerOfMass",when:s=>!s.automaticCenterOfMass})],C.prototype,"centerOfMass",2);x([y(),h({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:f.Boolean,onChange:(s,e,t)=>{if(t){const i=s.engineObject.inertiaTensor;s.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],C.prototype,"automaticInertiaTensor",2);x([y(),h({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:f.Vector3,bindPath:"inertiaTensor",when:s=>!s.automaticInertiaTensor})],C.prototype,"inertiaTensor",2);x([y(),h({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:f.Vector3,bindPath:"linearVelocity"})],C.prototype,"linearVelocity",2);x([y(),h({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:f.Vector3,bindPath:"angularVelocity"})],C.prototype,"angularVelocity",2);x([y(),h({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:f.Number})],C.prototype,"maxAngularVelocity",2);x([y(),h({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:f.Number})],C.prototype,"maxDepenetrationVelocity",2);x([y(),h({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:f.Number})],C.prototype,"sleepThreshold",2);x([y(),h({label:r("physics.dynamic-collider.solver-iterations.title"),info:r("physics.dynamic-collider.solver-iterations.info"),bindPath:"solverIterations",min:0,max:10,dragStep:1,type:f.Slider})],C.prototype,"solverIterations",2);C=x([A({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],C);var Re=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,B=(s,e,t,i)=>{for(var o=i>1?void 0:i?Ke(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&Re(e,t,o),o};let T=class extends ${constructor(e,t){super(e,t);c(this,"stepOffset",.5);c(this,"upDirection",{x:0,y:1,z:0});c(this,"slopeLimit",45);c(this,"nonWalkableMode",J.PreventClimbing)}async bindEngineObject(e){await super.bindEngineObject(e),e.enabled=!1}};B([y(),h({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:f.Number})],T.prototype,"stepOffset",2);B([y(),h({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:f.Vector3,bindPath:"upDirection"})],T.prototype,"upDirection",2);B([y(),h({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:f.Number})],T.prototype,"slopeLimit",2);B([y(),h({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:f.Select,options:[{label:r("physics.character.non-walkable-mode.prevent-climbing"),value:J.PreventClimbing},{label:r("physics.character.non-walkable-mode.prevent-climbing-and-force-sliding"),value:J.PreventClimbingAndForceSliding}]})],T.prototype,"nonWalkableMode",2);T=B([A({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],T);function Ye(s,e){if(!e)return null;const t=s.entities.get(e),i=(t==null?void 0:t.getComponentByTypeName("DynamicCollider"))||(t==null?void 0:t.getComponentByTypeName("StaticCollider"));return i?{ownerId:e,componentId:i.id}:null}const Ge=j(s=>{const{inspectorConfig:e,model:t,onModelChange:i}=s,{property:o,label:n,disabled:a,info:l}=e,{ownerId:d}=t[o]||{},u=s.model.root.sceneStore,m=d&&u.entities.get(d),b=M=>{i==null||i(o,Ye(u,M))},{t:g}=z(),ne=Array.from(u.entities.values());return p.jsx(p.Fragment,{children:p.jsx(he,{label:g(n),info:g(l),entities:ne,value:d,disabled:a,customFilter:M=>{let Z=null;return t.entityModelId!==M.id&&(Z=M.getComponentByTypeName("DynamicCollider")||M.getComponentByTypeName("StaticCollider")),Z},displayValue:m==null?void 0:m.name,placeholder:g("physics.collider-picker.placeholder"),onSelect:b,onLocate:()=>{s.model.root.sceneStore.selectEntity(d)},onDelete:()=>{b(null)}})})});var Ue=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,D=(s,e,t,i)=>{for(var o=i>1?void 0:i?Ze(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&Ue(e,t,o),o};class v extends oe{constructor(){super(...arguments);c(this,"connectedCollider",null);c(this,"anchor",{x:0,y:0,z:0});c(this,"automaticConnectedAnchor",!0);c(this,"connectedAnchor",{x:0,y:0,z:0});c(this,"breakForce",Number.MAX_VALUE);c(this,"breakTorque",Number.MAX_VALUE);c(this,"massScale",1);c(this,"connectedMassScale",1)}async applyBoundPathChange(t,i,o){var n,a;if(t==="connectedCollider"){const l=o,d=((a=(n=this.root.sceneStore.entities.get(l==null?void 0:l.ownerId))==null?void 0:n.getComponentById(l==null?void 0:l.componentId))==null?void 0:a.engineObject)??null;await super.applyBoundPathChange(t,i,d);return}await super.applyBoundPathChange(t,i,o)}}D([y(),h({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:Ge,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);D([y(),h({label:r("physics.joint.anchor.title"),type:f.Vector3,bindPath:"anchor",onChange(s,e,t){if(s.automaticConnectedAnchor){const i=s.engineObject.connectedAnchor;s.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);D([y(),h({label:r("physics.joint.automatic-connected-anchor.title"),type:f.Boolean,bindPath:"automaticConnectedAnchor",onChange(s,e,t){if(t){const i=s.engineObject.connectedAnchor;s.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);D([y(),h({label:r("physics.joint.connected-anchor.title"),type:f.Vector3,bindPath:"connectedAnchor",when:s=>!s.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);D([y(),h({label:r("physics.joint.break-force.title"),type:f.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);D([y(),h({label:r("physics.joint.break-torque.title"),type:f.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);D([y(),h({label:r("physics.joint.mass-scale.title"),type:f.Number,bindPath:"massScale"})],v.prototype,"massScale",2);D([y(),h({label:r("physics.joint.connected-mass-scale.title"),type:f.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var He=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,We=(s,e,t,i)=>{for(var o=i>1?void 0:i?qe(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&He(e,t,o),o};let k=class extends v{constructor(s,e){super(s,e)}};k=We([A({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:U.AutoAdd}})],k);const Qe=j(s=>{const{inspectorConfig:e,model:t,onModelChange:i}=s,{property:o,label:n,info:a}=e,l=t.useLimits,d=t.useSpring,u=t[o],m=u.props,{t:b}=z();return p.jsx(p.Fragment,{children:l?p.jsxs(se,{label:b(n),info:b(a),children:[p.jsx(P,{label:b("physics.joint-limits.min"),value:m.min,onChange:g=>{m.max<g&&(m.max=g),m.min=g,i(o,u)}}),p.jsx(P,{label:b("physics.joint-limits.max"),value:m.max,onChange:g=>{g<m.min&&(g=m.min),m.max=g,i(o,u)}}),d?p.jsxs(p.Fragment,{children:[p.jsx(P,{label:b("physics.joint-limits.stiffness"),value:m.stiffness,onChange:g=>{m.stiffness=g,i(o,u)}}),p.jsx(P,{label:b("physics.joint-limits.damping"),value:m.damping,onChange:g=>{m.damping=g,i(o,u)}})]}):p.jsx(P,{label:b("physics.joint-limits.contact-distance"),value:m.contactDistance,onChange:g=>{m.contactDistance=g,i(o,u)}})]}):null})}),ke=j(s=>{const{inspectorConfig:e,model:t,onModelChange:i}=s,{property:o,label:n,info:a}=e,l=t.useMotor,d=t[o],u=d.props,{t:m}=z();return p.jsx(p.Fragment,{children:l?p.jsxs(se,{label:m(n),info:m(a),children:[p.jsx(P,{label:m("physics.joint-motor.target-velocity"),value:u.targetVelocity,onChange:b=>{u.targetVelocity=b,i(o,d)}}),p.jsx(P,{label:m("physics.joint-motor.force-limit"),value:u.forceLimit,onChange:b=>{u.forceLimit=b,i(o,d)}}),p.jsx(P,{label:m("physics.joint-motor.gear-ratio"),value:u.gearRatio,onChange:b=>{u.gearRatio=b,i(o,d)}}),p.jsx(ie,{label:m("physics.joint-motor.free-spin"),value:u.freeSpin,onChange:b=>{u.freeSpin=b,i(o,d)}})]}):null})});var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,w=(s,e,t,i)=>{for(var o=i>1?void 0:i?tt(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&et(e,t,o),o};let O=class extends v{constructor(e,t){super(e,t);c(this,"axis",{x:1,y:0,z:0});c(this,"useLimits",!1);c(this,"useSpring",!1);c(this,"limits",{class:"JointLimits",props:{max:0,min:0,contactDistance:-1,stiffness:0,damping:0}});c(this,"useMotor",!1);c(this,"motor",{class:"JointMotor",props:{targetVelocity:0,forceLimit:Number.MAX_VALUE,gearRatio:1,freeSpin:!1}})}async applyBoundPathChange(e,t,i){if(e==="limits"){const o=this._buildLimitsFromModel(i);if(!o)return;await super.applyBoundPathChange(e,t,o);return}if(e==="motor"){const o=this._buildMotorFromModel(i);if(!o)return;await super.applyBoundPathChange(e,t,o);return}await super.applyBoundPathChange(e,t,i)}_buildLimitsFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new me;return i.max=t.max,i.min=t.min,i.contactDistance=t.contactDistance,i.stiffness=t.stiffness,i.damping=t.damping,i}_buildMotorFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new ue;return i.targetVelocity=t.targetVelocity,i.forceLimit=t.forceLimit,i.gearRatio=t.gearRatio,i.freeSpin=t.freeSpin,i}};w([y(),h({label:r("physics.hinge-joint.axis.title"),type:f.Vector3,bindPath:"axis"})],O.prototype,"axis",2);w([y(),h({label:r("physics.hinge-joint.use-limits.title"),type:f.Boolean,bindPath:"useLimits"})],O.prototype,"useLimits",2);w([y(),h({label:r("physics.hinge-joint.use-spring.title"),type:f.Boolean,bindPath:"useSpring"})],O.prototype,"useSpring",2);w([y(),h({label:r("physics.hinge-joint.limits.title"),customComponent:Qe,bindPath:"limits"})],O.prototype,"limits",2);w([y(),h({label:r("physics.hinge-joint.use-motor.title"),type:f.Boolean,bindPath:"useMotor"})],O.prototype,"useMotor",2);w([y(),h({label:r("physics.hinge-joint.motor.title"),customComponent:ke,bindPath:"motor"})],O.prototype,"motor",2);O=w([A({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:U.AutoAdd}})],O);var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,F=(s,e,t,i)=>{for(var o=i>1?void 0:i?ot(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&it(e,t,o),o};let _=class extends v{constructor(e,t){super(e,t);c(this,"spring",10);c(this,"damper",.2);c(this,"minDistance",0);c(this,"maxDistance",0);c(this,"tolerance",.025)}};F([y(),h({label:r("physics.spring-joint.spring.title"),type:f.Number,bindPath:"spring"})],_.prototype,"spring",2);F([y(),h({label:r("physics.spring-joint.damper.title"),type:f.Number,bindPath:"damper"})],_.prototype,"damper",2);F([y(),h({label:r("physics.spring-joint.min-distance.title"),type:f.Number,bindPath:"minDistance"})],_.prototype,"minDistance",2);F([y(),h({label:r("physics.spring-joint.max-distance.title"),type:f.Number,bindPath:"maxDistance"})],_.prototype,"maxDistance",2);F([y(),h({label:r("physics.spring-joint.tolerance.title"),type:f.Number,bindPath:"tolerance"})],_.prototype,"tolerance",2);_=F([A({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:U.AutoAdd}})],_);class st extends fe{constructor(){super(...arguments);c(this,"_isPlaying",!1)}onPlay(t){this._isPlaying=t,this._toggleAll(t)}onAddComponent(t){!this._isPlaying&&(t instanceof q||t instanceof E)&&(t.enabled=!1)}_toggleAll(t){var a;const i=(a=this.engine.sceneManager.activeScene)==null?void 0:a.rootEntities;if(!i)return;const o=[],n=[];i.forEach(l=>{l.getComponentsIncludeChildren(q,o),l.getComponentsIncludeChildren(E,n)}),o.forEach(l=>{l.enabled=t}),n.forEach(l=>{l.enabled=t})}}var nt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,at=(s,e,t,i)=>{for(var o=i>1?void 0:i?rt(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&nt(e,t,o),o};let ee=class{constructor(){c(this,"script")}init(){this.script=be.addScript(st)}};ee=at([ge({type:"physicsStore"})],ee);export{T as C,C as D,k as F,O as H,ee as P,W as S,_ as a};
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var c=(e,t,o)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var m=(e,t,o)=>(c(e,typeof t!="symbol"?t+"":t,o),o);import{s as f,p as h,C as g}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as b}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{L as u}from"./LightBaseComponent-fbc3ae49.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var P=Object.defineProperty,d=Object.getOwnPropertyDescriptor,a=(e,t,o,i)=>{for(var p=i>1?void 0:i?d(t,o):t,r=e.length-1,n;r>=0;r--)(n=e[r])&&(p=(i?n(t,o,p):n(p))||p);return i&&p&&P(t,o,p),p};let s=class extends u{constructor(t,o){super(t,o);m(this,"distance",60)}};a([f(),h({type:g.Number,bindPath:"distance",label:"light.point.distance.label",info:"light.point.distance.info"})],s.prototype,"distance",2);s=a([b({type:"PointLight",componentsMenu:{group:"light",label:"component.light.point.title"}})],s);export{s as PointLightComponent};
@@ -1 +0,0 @@
1
- var R=Object.defineProperty;var _=(e,t,s)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var x=(e,t,s)=>(_(e,typeof t!="symbol"?t+"":t,s),s);import{aJ as G,aD as l,aI as q,aL as J,e as m,aE as K,aK as D,ct as H,aM as O,aN as Q,aT as M,cu as F,cv as W,cw as U,cx as X,b9 as Y,cy as Z,cz as ee,cA as te,bz as se,n as oe,cB as re,cC as ne,cD as ae,b8 as ce,t as le,cE as ie,cF as fe,cG as pe,cH as ue,cI as v,cJ as L,cK as me,E as be,a as z,s as C,p as I,C as k,l as de,g as ye}from"./index-0a8702e2.js";import{u as he}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as ge}from"./Component-f923abb1.js";import{D as Pe,M as je}from"./Menu-cd3be298.js";import{A as xe,a as Ee,I as Ce}from"./Accordion-4897319b.js";function Ie(e){const{renameable:t,onDelete:s,removable:a,checkable:c,defaultChecked:r,onCheckedChange:o}=e;return l.jsxs(D,{align:"v",css:{flex:1,justifyContent:"space-between"},children:[l.jsxs(D,{children:[c&&l.jsx(H,{style:{marginRight:"5px"},checked:r,onCheckedChange:o,onClick:n=>n.stopPropagation()}),l.jsx("span",{children:e.title})]}),l.jsxs(D,{gap:"xxs",children:[t&&l.jsx(O,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),s&&s()},children:l.jsx(Ce,{size:"14px"})}),a&&l.jsx(O,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),s&&s()},children:l.jsx(Q,{size:"14px"})})]})]})}const B={TonemappingEffect:"post-process.effects.tone-mapping.title",BloomEffect:"post-process.effects.bloom.title"};function Te(e){const{label:t,info:s,items:a=[],menuItems:c=[],onClickMenu:r,onDelete:o,addItemText:n="Add Item",defaultValue:p,onCheckedChange:f}=e,b=i=>()=>{o&&o(i)},P=G.useMemo(()=>a.length?a.map(i=>`${i.id}`):[],[a]),j=l.jsxs(q,{size:"sm",variant:"soft",css:{width:"100%",marginTop:"$1","& > svg":{marginRight:"$1"}},children:[l.jsx(J,{size:"12px"}),String(m(n))]});return l.jsxs(K,{label:m(t),info:s,direction:"column",children:[a.length&&l.jsx(xe,{type:"multiple",defaultValue:p??P,"data-state":"closed",children:a.map(i=>l.jsx(Ee,{value:`${i.id}`,title:l.jsx(Ie,{title:m(B[i.name]),onDelete:b(i),removable:i.removable,renameable:i.renameable,checkable:i.checkable,defaultChecked:i.defaultChecked,onCheckedChange:T=>{f&&f(T,i)}}),arrow:!!i.children,children:i.children&&l.jsx(D,{direction:"column",children:i.children})},i.name))}),l.jsx(Pe,{trigger:j,children:c.map(i=>l.jsx(je,{name:m(B[i.name]),onClick:()=>{r&&r(i)}},i.id))})]})}const h={TonemappingEffect:{constructor:v},BloomEffect:{constructor:L,defaultValue:{intensity:1,dirtIntensity:1}}},d={highQualityFiltering:{label:"post-process.effects.bloom.high-quality-filtering.label",info:"post-process.effects.bloom.high-quality-filtering.info"},scatter:{label:"post-process.effects.bloom.scatter.label",info:"post-process.effects.bloom.scatter.info"},downScale:{label:"post-process.effects.bloom.down-scale.label",info:"post-process.effects.bloom.down-scale.info"},threshold:{label:"post-process.effects.bloom.threshold.label",info:"post-process.effects.bloom.threshold.info"},intensity:{label:"post-process.effects.bloom.intensity.label",info:"post-process.effects.bloom.intensity.info"},tint:{label:"post-process.effects.bloom.tint.label",info:"post-process.effects.bloom.tint.info"},dirtTexture:{label:"post-process.effects.bloom.dirt-texture.label",info:"post-process.effects.bloom.dirt-texture.info"},dirtIntensity:{label:"post-process.effects.bloom.dirt-intensity.label",info:"post-process.effects.bloom.dirt-intensity.info"},mode:{label:"post-process.effects.tone-mapping.mode.label",info:"post-process.effects.tone-mapping.mode.info"}},we=M(({item:e,effectIndex:t,effect:s,onParameterChange:a})=>{const{assetStore:c}=he();return s?l.jsx(l.Fragment,{children:e.parameters.map((r,o)=>{var b,P,j,i,T,V,S,A,N;const{name:n,value:p}=r,f=s[n];if(!(f instanceof F))return null;switch(f.constructor){case pe:return l.jsx(ue,{label:m(((b=d[n])==null?void 0:b.label)??n),min:f.min,max:f.max,value:Number(p),dragStep:.01,onChange:u=>{a(t,o,u)}},o);case ie:return l.jsx(fe,{label:m(((P=d[n])==null?void 0:P.label)??n),value:!!p,onChange:u=>{a(t,o,u)}},o);case ae:return l.jsx(ce,{label:m(((j=d[n])==null?void 0:j.label)??n),options:le(f.enumType,void 0,u=>m(`post-process.effects.options.${u.toLocaleLowerCase()}`)),value:p,onChange:u=>{a(t,o,u)}},o);case re:return l.jsx(ne,{label:m(((i=d[n])==null?void 0:i.label)??n),value:p,onChange:u=>{a(t,o,u)}},o);case te:{const u=c.assets,w=u[(T=r.value)==null?void 0:T.refId],$=Object.values(u).filter(y=>y.getMetaConfig().type==="Texture"&&!y.isSubAsset);return l.jsx(se,{label:m(((V=d[n])==null?void 0:V.label)??n),dropLayer:oe.Texture,assets:$,asset:w,value:w==null?void 0:w.name,placeholder:m("texture.select-texture"),onSelect:y=>{a(t,o,y.getCurrentRef())},onLocate:()=>{var y;c.selectAsset((y=r.value)==null?void 0:y.refId)},onDelete:()=>{a(t,o,null)}},o)}case Z:return l.jsx(ee,{label:m(((S=d[n])==null?void 0:S.label)??n),value:p,onChange:u=>{a(t,o,u)}},o);case X:return l.jsx(Y,{label:m(((A=d[n])==null?void 0:A.label)??n),value:p,onChange:u=>{a(t,o,u)}},o);case W:return l.jsx(U,{label:m(((N=d[n])==null?void 0:N.label)??n),value:p,onChange:u=>{a(t,o,u)}},o);default:return null}})}):null}),De=M(({model:e,onModelChange:t})=>{const s=e.effects,a=r=>{const o=me(s);r(o),t==null||t("effects",o)},c=(r,o,n)=>{a(p=>{var b;const f=p[r];(b=f==null?void 0:f.parameters)!=null&&b[o]&&(f.parameters[o]={...f.parameters[o],value:n})})};return l.jsx(Te,{label:m("post-process.effects.title"),addItemText:m("post-process.effects.add"),menuItems:Object.keys(h).map(r=>({id:r,name:r})),onClickMenu:r=>{const o=r.name;a(n=>{n.some(p=>p.name===o)||n.push({name:o,enabled:!0,parameters:[]})})},onCheckedChange:(r,o)=>{a(n=>{const p=n[Number(o.id)];p&&(p.enabled=r)})},onDelete:r=>{a(o=>{o.splice(Number(r.id),1)})},items:s.map((r,o)=>{var f;const n=(f=h[r.name])==null?void 0:f.constructor,p=n?e.engineObject.getEffect(n):null;return{children:l.jsx(we,{item:r,effectIndex:o,effect:p,onParameterChange:c}),id:String(o),name:r.name,removable:!0,checkable:!0,defaultChecked:r.enabled}})})});function ke(e){return e==null||typeof e!="object"?e:"r"in e&&"g"in e&&"b"in e&&"a"in e?{r:e.r,g:e.g,b:e.b,a:e.a}:"x"in e&&"y"in e&&"z"in e&&"w"in e?{x:e.x,y:e.y,z:e.z,w:e.w}:"x"in e&&"y"in e&&"z"in e?{x:e.x,y:e.y,z:e.z}:"x"in e&&"y"in e?{x:e.x,y:e.y}:e}function ze(e,t,s){if(s.parameters.length>0)return;const a=h[e].defaultValue??{},c=[];for(const r in t){const o=t[r];if(!(o instanceof F))continue;const n=a[r];n!==void 0&&(o.value=n),c.push({name:r,value:ke(n??o.value)??null})}s.parameters=c}async function Fe(e,t,s){var a;if(s!=null&&s.refId){const c=await e.root.assetStore.getAssetByRef(s);t.value=(c==null?void 0:c.engineObject)??null;return}if((a=t.value)!=null&&a.copyFrom&&s&&typeof s=="object"){t.value.copyFrom(s);return}t.value=s}async function Ve(e,t){const s=e.engineObject,a=new Set;for(let c=0;c<t.length;c++){const r=t[c],{name:o,enabled:n}=r;if(!h[o])continue;const p=h[o].constructor;a.add(p);let f=s.getEffect(p);if(f||(f=s.addEffect(p)),!!f){ze(o,f,r),f.enabled=n;for(let b=0;b<r.parameters.length;b++){const{name:P,value:j}=r.parameters[b],i=f[P];i instanceof F&&await Fe(e,i,j)}}}for(const c of Object.keys(h)){const r=h[c].constructor;a.has(r)||s.getEffect(r)&&s.removeEffect(r)}}function Se(e){const t={};return e.forEach(s=>{t[s.name]={value:s.value}}),t}function Ae(e){const t=[];for(const s in e)s!=="enabled"&&t.push({name:s,value:e[s].value});return t}function Ne(e){return e.map(t=>({params:[{classType:t.name}],result:{props:Object.assign(Se(t.parameters),{enabled:t.enabled})}}))}function Oe(e){return e.map(t=>({name:t.params[0].classType,enabled:t.result.props.enabled,parameters:Ae(t.result.props)}))}var Be=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,E=(e,t,s,a)=>{for(var c=a>1?void 0:a?Me(t,s):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(c=(a?o(t,s,c):o(c))||c);return a&&c&&Be(t,s,c),c};const ve={TonemappingEffect:{constructor:v},BloomEffect:{constructor:L,defaultValue:{intensity:1,dirtIntensity:1}}};let g=class extends be{constructor(t,s){super(t,s);x(this,"isGlobal",!0);x(this,"blendDistance",0);x(this,"priority",0);x(this,"layer",[z.Layer0]);x(this,"effects",[])}};E([C(),I({label:"post-process.global.title",info:"post-process.global.info",type:k.Toggle,bindPath:"isGlobal"})],g.prototype,"isGlobal",2);E([C(),I({label:"post-process.blend-distance.title",info:"post-process.blend-distance.info",type:k.Number,bindPath:"blendDistance",min:0,dragStep:.01,when:e=>!e.isGlobal})],g.prototype,"blendDistance",2);E([C(),I({label:"post-process.priority.title",info:"post-process.priority.info",type:k.Number,bindPath:"priority",dragStep:1})],g.prototype,"priority",2);E([C(de()),I({label:"post-process.layer.title",info:"post-process.layer.info",type:k.Select,...ye([z.Nothing,z.Everything]),bindPath:"layer"})],g.prototype,"layer",2);E([C({type:"methods",key:"addEffect",onSerialize:Ne,onDeserialize:Oe,resolveMethodArguments:async e=>e.map(t=>{var s;if(t&&typeof t=="object"&&"classType"in t){const a=t.classType,c=(s=ve[a])==null?void 0:s.constructor;if(!c)throw new Error(`Effect constructor not found for: ${a}`);return c}return t})}),I({customComponent:De,onChange:async(e,t,s)=>{await Ve(e,s)}})],g.prototype,"effects",2);g=E([ge({type:"PostProcess",componentsMenu:{label:"component.post-process.title"}})],g);export{g as P};
@@ -1 +0,0 @@
1
- var z=Object.defineProperty;var k=(d,t,e)=>t in d?z(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e;var b=(d,t,e)=>(k(d,typeof t!="symbol"?t+"":t,e),e);import{dH as N,dI as F,aT as j,aU as L,aD as C,bz as R,n as w,aV as G,aE as $,dJ as J,C as U,cQ as K,dK as P,e as E,dL as D,dM as V,dN as Q,dO as W,dP as q,dy as H,dQ as X,_ as v,m as Y,b0 as Z,u as tt,J as B,cj as et}from"./index-0a8702e2.js";import{T as st}from"./TaskQueue-05c94a4d.js";import{u as x,I as nt,a as it}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as at}from"./AssetViewer-bc198e16.js";import{n as rt}from"./index-be6bc38a.js";import{s as ot}from"./utilities-e09052e3.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";class O{static update(t,e){!this.entity&&(this.entity=t.createChild("prefab"));const s=this.tempCloneEntity=e.engineObject.instantiate();this.entity.addChild(s)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}b(O,"entity"),b(O,"tempCloneEntity");const M=new F("buildGltfAssetTemplateDiffs");function dt(d,t){var s;M.info("START",{sceneRootName:d==null?void 0:d.name,sceneRootRotation:(s=d==null?void 0:d.transform)!=null&&s.rotation?{x:d.transform.rotation.x,y:d.transform.rotation.y,z:d.transform.rotation.z}:null,sceneChildCount:d==null?void 0:d.childCount,baselineRootName:t==null?void 0:t.name,baselineChildCount:t==null?void 0:t.childCount});const e=N(d,t);return M.info("RESULT",{diffCount:e?Object.keys(e.entityProps??{}).length:0,paths:e?Object.keys(e.entityProps??{}):[]}),e}const ct=j(({asset:d})=>{const{dependentAssets:t}=d,{configDataStore:e}=x(),{t:s}=L(),a=j(({dependentAssetInfo:n})=>{const{assetStore:i}=x(),r=Object.values(i.assets).filter(c=>{const l=c.getMetaConfig().type,y=c.id===n.id,u=c.id===d.id,h=!y&&!u&&!c.isSubAsset;return n.type==="glTF"||n.type==="Prefab"?l==="glTF"||l==="Prefab"&&h:c.getMetaConfig().type===n.type&&h}),o=i.assets[n.id],p=o==null?void 0:o.name;return C.jsx(R,{dropLayer:w.Asset,placeholder:s("prefab.inspector.missed"),assets:r,onSelect:c=>{d.replaceDependentAsset(n,c)},onLocate:()=>{i.selectAsset(n.id)},value:p,asset:o})});return C.jsxs(C.Fragment,{children:[C.jsx(G,{title:s("prefab.inspector.basic-info"),defaultOpen:!0,children:e.isBuc&&C.jsx($,{label:s("prefab.inspector.url")})}),C.jsx(J,{label:s("prefab.inspector.dependent-assets"),children:t.map((n,i)=>C.jsx(a,{dependentAssetInfo:n},`${n.id}-${i}`))})]})}),pt={entities:[{id:"defaultPrefab",name:"prefab",isActive:!0,transform:{class:"Transform",props:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},parent:null,children:[],isClone:!1,components:[]}]};class lt extends at{constructor(){super(...arguments);b(this,"_animators",[]);b(this,"_particles",[])}setViewAsset(e,s){const a=e.entityManager.rootEntities[0];this._entity=a.engineObject,s.addChild(this._entity),a.getComponentsIncludeChildren("Animator",this._animators).forEach(r=>{r.applyBoundPathChange("enabled",U.Toggle,r.enabled)}),this._entity.getComponentsIncludeChildren(K,this._particles).forEach(r=>{r.generator.stop(!1,P.StopEmittingAndClear),r.generator.main.simulationSpeed=1,r.generator.play()})}stopViewAsset(){super.stopViewAsset(),this._particles.forEach(e=>{e.generator.stop(!1,P.StopEmittingAndClear)})}}var ft=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,S=(d,t,e,s)=>{for(var a=s>1?void 0:s?ht(t,e):t,n=d.length-1,i;n>=0;n--)(i=d[n])&&(a=(s?i(t,e,a):i(a))||a);return s&&a&&ft(t,e,a),a};const I=et("PrefabAsset"),T=new F("PrefabAsset");let _=class extends nt{constructor(t){super(t);b(this,"acceptDragLayer",w.Entity);b(this,"_entityManager");b(this,"_contentQueue",new st);b(this,"entities",[]);b(this,"dependentAssets",[]);b(this,"_skipInitUpdateContent",!1);this._entityManager=new W(t)}static async createByEntity(t){var e,s,a;if(t.isPrefabSubEntity||t.isGLTFRefEntity){rt.error(E("prefab.error.create-from-sub"));return}D()&&V();try{T.info("createByEntity START",{entityName:t.name,entityId:t.id,isGLTFWrap:t.isGLTFWrapEntity,childCount:(e=t.children)==null?void 0:e.length,childNames:(s=t.children)==null?void 0:s.map(i=>i.name),hasGLTFChild:(a=t.children)==null?void 0:a.some(i=>i.isGLTFRefEntity)});const{assetFacade:n}=t.root;await t.root.runInUndoGroup("asset.create",async()=>{const i=await n.createAssetByAdd({assetType:"Prefab",name:t.name});i.addInstance(t,{undoable:!0}),await i.updateByEntity(t,!1,{undoable:!0})})}finally{D()&&Q()}}get entityManager(){return this._entityManager}async initByMain(t,e){const{dependentAssets:s}=this.meta;this.url=e;const a=JSON.parse(await t.text());if(this.entities=a.entities,this.dependentAssets=s,this._skipInitUpdateContent){this._skipInitUpdateContent=!1;return}await this._updateContent()}async initByCreation(){return this.entities=pt.entities,this._skipInitUpdateContent=!0,this.getMainData()}async updateByEntity(t,e=!1,s){var r;T.info("updateByEntity START",{entityName:t.name,entityId:t.id,isGLTFWrap:t.isGLTFWrapEntity,updateInstanceFrom:e});const{entities:a,assets:n}=this._getEntityDataIncludeChildren(t,[],new Set);T.info("updateByEntity serialized",{entityCount:a.length,entities:a.map(o=>{var p;return{name:o.name,isClone:o.isClone,instanceAssetId:(p=o.instance)==null?void 0:p.assetId,hasAssetTemplateDiffs:!!o.assetTemplateDiffs,assetTemplateDiffKeys:o.assetTemplateDiffs?Object.keys(o.assetTemplateDiffs.entityProps??{}):[]}})});const i=a[0];(r=i.transform)!=null&&r.props&&(i.transform.props.position={x:0,y:0,z:0}),i.parent=null,this.entities=a,this.dependentAssets=Array.from(n,o=>({id:o.id,name:o.name,type:o.getMetaConfig().type})),this._updateCreateByAddResumeSnapshot(),e&&this.addInstance(t),await this._updateContent(s!=null&&s.undoable?{undoable:!0}:void 0)}async refreshFromData(t){await this._updateContent(t)}replaceDependentAsset(t,e){const s=JSON.stringify(this.entities);this.entities=JSON.parse(s.replace(new RegExp(t.id,"g"),e.id)),t.id=e.id,t.name=e.name,this._updateContent()}destroy(){super.destroy(),this.engineObject&&(this.engineObject._root.destroy(),this.engineObject.destroy())}unpackAllInstances(){this._instances.forEach((t,e)=>{const s=t.entities.get(e);s==null||s.unpackPrefab()}),super.unpackAllInstances()}async instantiate(t,e,s){var o,p;const a=this._entityManager.rootEntities[0].id,n=this._entityManager.getEntityFilesById(a);e&&((p=(o=n[0])==null?void 0:o.transform)!=null&&p.props)&&(n[0].transform.props.position=e.position,n[0].transform.props.rotation=e.rotation,n[0].transform.props.scale=e.scale),s!=null&&s.expectedRootId&&n[0]&&(n[0].id=s.expectedRootId);const r=(await t.deserializeEntities(n))[0];return r.convertToPrefabRefEntity(),this.addInstance(r,s),this._bindInstantiatedEntity(r,s),r}_updateCreateByAddResumeSnapshot(){const t=this.getMainData(),e=this.getMetaData(),s=this.name??"Prefab",a=t==null?null:new Blob([t instanceof ArrayBuffer||typeof t=="string"?t:JSON.stringify(t)]);this.root.assetStore.updateCreateByAddResumeSnapshot(this.id,{assetName:s,serializedMeta:JSON.stringify(e),mainBlob:a})}_bindInstantiatedEntity(t,e){const s=this._entityManager.rootEntities[0];if(!s)return;const{entityMappings:a,componentMappings:n}=this._collectInstanceMappings(s,t);if(!a.length)return;const{prefab:i}=this.root.domainStore.state,r=i.byAssetId[this.id]??[];for(const p of r){const c=i.bindings[p];if((c==null?void 0:c.instanceRootEntityId)===t.id){const l=[],y=this.root.domainStore.getNormalizedState(),u=y.entities[t.id];if(u){l.push({op:u.instance?"replace":"add",path:`/entities/${t.id}/instance`,value:{bindingId:p,assetId:this.id,assetKind:"Prefab",role:"root",sourceEntityId:c.sourceRootEntityId}});for(const h of n){const f=q(y,t.id,h.sceneComponentId);f&&l.push({op:f.instance?"replace":"add",path:`/entities/${t.id}/components/${h.sceneComponentId}/instance`,value:{bindingId:p,role:"linked",sourceComponentKey:h.sourceComponentKey}})}}l.length>0&&this.root.domainStore.applySystem(l);return}}let o=1;for(const p of r){const c=i.bindings[p];c&&c.sourceRevision>o&&(o=c.sourceRevision)}this.root.prefabFacade.bindExistingInstance({assetId:this.id,instanceRootEntityId:t.id,sourceRevision:o,entityMappings:a,componentMappings:n,undoable:(e==null?void 0:e.undoable)===!0})}_collectInstanceMappings(t,e){const s=[],a=[],n=(i,r,o)=>{var h;const p=(i==null?void 0:i.id)??r.id;s.push({sceneEntityId:r.id,sourceEntityId:p,role:o});const c=(i==null?void 0:i.components)??[],l=r.components??[];for(let f=0;f<l.length;f++){const m=l[f];if(!(m!=null&&m.id))continue;const g=((h=c[f])==null?void 0:h.id)??m.id;a.push({sceneEntityId:r.id,sceneComponentId:m.id,sourceComponentKey:g})}const y=(i==null?void 0:i.selfChildren)??[],u=r.selfChildren??[];for(let f=0;f<u.length;f++)n(y[f],u[f],"linked")};return n(t,e,"root"),{entityMappings:s,componentMappings:a}}async replaceInstance(t,e,s){var o;const a=e.entities.get(t),n=(o=a==null?void 0:a.engineObject)==null?void 0:o.transform,i=n?{position:{x:n.position.x,y:n.position.y,z:n.position.z},rotation:{x:n.rotation.x,y:n.rotation.y,z:n.rotation.z},scale:{x:n.scale.x,y:n.scale.y,z:n.scale.z}}:void 0,r=await this.instantiate(e,i,s);return r.convertToPrefabRefEntity(),e.replaceEntity(t,r),r}_instantiateEngineObject(){return this.engineObject.instantiate()}_onDrop(t,e){if(!e||e.id===this.id)return;this.dropping=!1;const{sceneStore:s,sceneUIStore:a}=this.root,n=Array.from(a.selectedKeys);if(n.length>1)for(let i=0;i<n.length;i++)_.createByEntity(s.entities.get(n[i]));else ot({title:E("prefab.replace.title").toString(),description:E("prefab.replace.description",{name:this.name}).toString(),confirmText:E("prefab.replace.confirm").toString(),onConfirm:()=>{const i=s.entities.get(n[0]);this.updateByEntity(i,!0)}})}_rebaseInstanceRevisions(){const{prefabFacade:t,domainStore:e}=this.root,s=e.state.prefab.byAssetId[this.id];if(!s||s.length===0)return;let a=0;for(const n of s){const i=e.state.prefab.bindings[n];i&&i.sourceRevision>a&&(a=i.sourceRevision)}t.updatePrefabContent(this.id,a+1)}_getEntityDataIncludeChildren(t,e,s){var i,r,o,p;const a=this.root.assetStore,n=t.toJSON(!0);if(e.push(n),!t.isGLTFRefEntity)t.components.forEach(c=>{var y;const l=H(c);for(const u in l)if(l[u].type==="AssetPicker"){const h=(y=c[u])==null?void 0:y.refId;if(h){const f=a.assets[h];f&&s.add(f)}}}),t.children.map(c=>!c.prefabEntityRemoved&&this._getEntityDataIncludeChildren(c,e,s)),(i=t.strippedEntity)==null||i.clear();else{const c=a.assets[t.instanceAssetId];s.add(c);let l=null;try{l=(r=c.instantiateEngineObject)==null?void 0:r.call(c),T.info("_getEntityDataIncludeChildren glTF branch",{entityName:t.name,instanceAssetId:t.instanceAssetId,hasBaseline:!!l,sceneChildCount:(o=t.selfChildren??t.children)==null?void 0:o.length,sceneChildRotations:(p=t.selfChildren??t.children)==null?void 0:p.map(g=>{const A=g.transform;return A!=null&&A.rotation?{x:A.rotation.x,y:A.rotation.y,z:A.rotation.z}:null})});const m=(l==null?void 0:l.childCount)>0?l.getChild(0):l;if(m&&t.engineObject){const g=dt(t.engineObject,m);T.info("diffs result",{diffs:g}),g&&(n.assetTemplateDiffs=g)}}finally{l==null||l.destroy()}const y=t.entityManager.strippedEntities,u=t.getAddedComponents(),h=t.getAddedEntities(),f=new Set;u.forEach(m=>{f.add(m.strippedId)}),h.forEach(m=>{f.add(m.strippedId)}),f.forEach(m=>{const g=y.get(m);this._getEntityDataIncludeChildren(g,e,s)})}return{entities:e,assets:s}}_updateContent(t){return this._contentQueue.enqueue(async()=>{try{await this._updateContentInternal(t)}catch(e){if(e instanceof Error&&e.message==="cancelled")return;I.error("_updateContent failed:",e)}})}async _updateContentInternal(t){const{url:e,dependentAssets:s}=this,a=(t==null?void 0:t.persist)!==!1;await Promise.all(s.map(p=>this.root.assetStore.getAssetByRef({refId:p.id}))),await this._entityManager.init(this);const n=this.engineObject;if(n){this.root.assetStore.engineObjectToAssetMap.delete(n);try{n.destroy()}catch(p){I.warn("failed to destroy oldEngineObject:",p)}}const i=new X(this.engine,e);this.bindEngineObject(i),this.root.assetStore.engineObjectToAssetMap.set(i,this);let r=this._entityManager.rootEntities[0];r||(r=this._entityManager.createEntity("prefab","defaultPrefab"),r.bindEngineObject(new v(this.engine,"prefab")),I.error(`The prefab which id is ${this.id} is broken, use default prefab instead.`)),r.engineObject||(I.warn("rootEntity engineObject is null, binding new Entity"),r.bindEngineObject(new v(this.engine,"prefab"))),this._markAsTemplate(r),i._root=r.engineObject,r.once("delete",()=>{I.error(`The prefab which id is ${this.id} is broken.`),this._updateContent().catch(p=>{I.error(`Failed to rebuild broken prefab which id is ${this.id}.`,p)})}),this._updateDragTempEntity(),this.updateThumbnail(),a&&(this.root.assetFacade.persistAssetMeta(this.id),this.root.assetFacade.persistAssetMain(this.id));const o=t!=null&&t.undoable?{undoable:!0}:void 0;await Promise.all(Array.from(this._instances,([p,c])=>this.replaceInstance(p,c,o))),this._rebaseInstanceRevisions()}_markAsTemplate(t){const e=t.engineObject;if(!e){I.warn("_markAsTemplate: engineObject is null",{prefabId:this.id,entityModelId:t.id});return}const s=e;s._templateResource||s._markAsTemplate(this.engineObject),t.selfChildren.forEach(a=>{this._markAsTemplate(a)})}};S([Y()],_.prototype,"entities",2);S([Z(),tt],_.prototype,"dependentAssets",2);S([B],_.prototype,"replaceDependentAsset",1);S([B],_.prototype,"_onDrop",1);_=S([it({type:"Prefab",label:E("asset.prefab.title"),extname:"prefab",dragLayer:w.Prefab,customInspector:ct,viewer:lt,thumbnail:O,async bundle(d){return{content:new Blob([d.content],{type:"application/json"})}}})],_);export{_ as PrefabAsset};
@@ -1 +0,0 @@
1
- var wt=Object.defineProperty;var Mt=(C,s,n)=>s in C?wt(C,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):C[s]=n;var A=(C,s,n)=>(Mt(C,typeof s!="symbol"?s+"":s,n),n);import{H as it,U as q,bq as Rt,af as dt,ag as mt,ah as ft,aj as yt,br as Pt,ad as at,bs as ct,ae as rt,bt as It,j as At,_ as Ht,O as _t,p as B,e as b,C as T,t as Bt,m as V,n as Tt}from"./index-0a8702e2.js";import{a as Vt,A as Nt}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Et}from"./bundlers-9b0d37fc.js";import{M as Dt}from"./MeshThumbnail-49273f71.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";const z=class z{static createSphere(s=.5,n=18){n=Math.max(2,Math.floor(n));const e=n+1,o=e*e,c=n*n,p=z._generateIndices(o,c*6),R=Math.PI,t=R*2,a=1/e,y=1/n,m=8,h=new Float32Array(o*m);for(let x=0;x<o;++x){const u=x%e,d=x*a|0,l=u*y,i=d*y,M=l*t,f=i*R,v=Math.sin(f),I=-s*Math.cos(M)*v,P=s*Math.cos(f),S=s*Math.sin(M)*v;let r=x*m;h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=l,h[r++]=i}let w=0;for(let x=0;x<c;++x){const u=x%n,l=(x*y|0)*e+u,i=l+1,M=l+e,f=M+1;p[w++]=i,p[w++]=l,p[w++]=f,p[w++]=l,p[w++]=M,p[w++]=f}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:p,vertices:h,bounds:g}}static createCuboid(s=1,n=1,e=1){const o=s/2,c=n/2,p=e/2,R=8,t=new Float32Array(24*R);t[0]=-o,t[1]=c,t[2]=-p,t[6]=0,t[7]=0,t[8]=o,t[9]=c,t[10]=-p,t[14]=1,t[15]=0,t[16]=o,t[17]=c,t[18]=p,t[22]=1,t[23]=1,t[24]=-o,t[25]=c,t[26]=p,t[30]=0,t[31]=1;for(let m=0;m<4;m++){let h=R*m+3;t[h++]=0,t[h++]=1,t[h++]=0}t[32]=-o,t[33]=-c,t[34]=-p,t[38]=0,t[39]=1,t[40]=o,t[41]=-c,t[42]=-p,t[46]=1,t[47]=1,t[48]=o,t[49]=-c,t[50]=p,t[54]=1,t[55]=0,t[56]=-o,t[57]=-c,t[58]=p,t[62]=0,t[63]=0;for(let m=0;m<4;m++){let h=R*m+35;t[h++]=0,t[h++]=-1,t[h++]=0}t[64]=-o,t[65]=c,t[66]=-p,t[70]=0,t[71]=0,t[72]=-o,t[73]=c,t[74]=p,t[78]=1,t[79]=0,t[80]=-o,t[81]=-c,t[82]=p,t[86]=1,t[87]=1,t[88]=-o,t[89]=-c,t[90]=-p,t[94]=0,t[95]=1;for(let m=0;m<4;m++){let h=R*m+67;t[h++]=-1,t[h++]=0,t[h++]=0}t[96]=o,t[97]=c,t[98]=-p,t[102]=1,t[103]=0,t[104]=o,t[105]=c,t[106]=p,t[110]=0,t[111]=0,t[112]=o,t[113]=-c,t[114]=p,t[118]=0,t[119]=1,t[120]=o,t[121]=-c,t[122]=-p,t[126]=1,t[127]=1;for(let m=0;m<4;m++){let h=R*m+99;t[h++]=1,t[h++]=0,t[h++]=0}t[128]=-o,t[129]=c,t[130]=p,t[134]=0,t[135]=0,t[136]=o,t[137]=c,t[138]=p,t[142]=1,t[143]=0,t[144]=o,t[145]=-c,t[146]=p,t[150]=1,t[151]=1,t[152]=-o,t[153]=-c,t[154]=p,t[158]=0,t[159]=1;for(let m=0;m<4;m++){let h=R*m+131;t[h++]=0,t[h++]=0,t[h++]=1}t[160]=-o,t[161]=c,t[162]=-p,t[166]=1,t[167]=0,t[168]=o,t[169]=c,t[170]=-p,t[174]=0,t[175]=0,t[176]=o,t[177]=-c,t[178]=-p,t[182]=0,t[183]=1,t[184]=-o,t[185]=-c,t[186]=-p,t[190]=1,t[191]=1;for(let m=0;m<4;m++){let h=R*m+163;t[h++]=0,t[h++]=0,t[h++]=-1}const a=new Uint16Array(36);a[0]=0,a[1]=2,a[2]=1,a[3]=2,a[4]=0,a[5]=3,a[6]=4,a[7]=6,a[8]=7,a[9]=6,a[10]=4,a[11]=5,a[12]=8,a[13]=10,a[14]=9,a[15]=10,a[16]=8,a[17]=11,a[18]=12,a[19]=14,a[20]=15,a[21]=14,a[22]=12,a[23]=13,a[24]=16,a[25]=18,a[26]=17,a[27]=18,a[28]=16,a[29]=19,a[30]=20,a[31]=22,a[32]=23,a[33]=22,a[34]=20,a[35]=21;const y=new q;return y.min.set(-o,-c,-p),y.max.set(o,c,p),{vertices:t,bounds:y,indices:a}}static createPlane(s=1,n=1,e=1,o=1){e=Math.max(1,Math.floor(e)),o=Math.max(1,Math.floor(o));const c=e+1,p=o+1,R=s/2,t=n/2,a=s/e,y=n/o,m=c*p,h=o*e,w=z._generateIndices(m,h*6),g=1/c,x=1/e,u=1/o,d=8,l=new Float32Array(m*d);for(let f=0;f<m;++f){const v=f%c,I=f*g|0;let P=f*d;l[P++]=v*a-R,l[P++]=0,l[P++]=I*y-t,l[P++]=0,l[P++]=1,l[P++]=0,l[P++]=v*x,l[P++]=I*u}let i=0;for(let f=0;f<h;++f){const v=f%e,P=(f*x|0)*c+v,S=P+1,r=P+c,E=r+1;w[i++]=P,w[i++]=r,w[i++]=S,w[i++]=r,w[i++]=E,w[i++]=S}const M=new q;return M.min.set(-R,0,-t),M.max.set(R,0,t),{bounds:M,vertices:l,indices:w}}static createCylinder(s=.5,n=.5,e=2,o=20,c=1){o=Math.floor(o),c=Math.floor(c);const p=o+1,R=c+1,t=e*.5,a=e/c,y=p*R,m=o*c,h=o*2,w=y+2+h,g=z._generateIndices(w,m*6+h*3),x=1/p,u=1/o,d=1/c,l=8,i=new Float32Array(w*l);let M=0;const f=Math.PI,v=Math.PI*2,I=n-s,P=I/e,S=I/c;for(let F=0;F<y;++F){const Z=F%p,W=F*x|0,O=Z*u,K=W*d,$=f+O*v,et=Math.sin($),ht=Math.cos($),ut=n-W*S,xt=ut*et,vt=W*a-t,Ct=ut*ht;let L=F*l;i[L++]=xt,i[L++]=vt,i[L++]=Ct,i[L++]=et,i[L++]=P,i[L++]=ht,i[L++]=O,i[L++]=1-K}for(let F=0;F<m;++F){const Z=F%o,O=(F*u|0)*p+Z,K=O+1,$=O+p,et=$+1;g[M++]=K,g[M++]=$,g[M++]=O,g[M++]=K,g[M++]=et,g[M++]=$}let r=y*l;i[r++]=0,i[r++]=-t,i[r++]=0,i[r++]=0,i[r++]=-1,i[r++]=0,i[r++]=.5,i[r++]=.5,i[r++]=0,i[r++]=t,i[r++]=0,i[r++]=0,i[r++]=1,i[r++]=0,i[r++]=.5,i[r++]=.5,r=(y+2)*l;const E=1/(s*2),j=1/(n*2),D=p*c;for(let F=0;F<o;++F){const Z=F*l;let W=i[Z],O=i[Z+2];i[r++]=W,i[r++]=-t,i[r++]=O,i[r++]=0,i[r++]=-1,i[r++]=0,i[r++]=W*j+.5,i[r++]=.5-O*j;const K=(F+D)*l;W=i[K],O=i[K+2],i[r++]=W,i[r++]=t,i[r++]=O,i[r++]=0,i[r++]=1,i[r++]=0,i[r++]=W*E+.5,i[r++]=.5-O*E}const Y=y+1,X=y+2,U=X+1;for(let F=0;F<o;++F){const Z=F*2,W=F===o-1?0:Z+2;g[M++]=y,g[M++]=X+W,g[M++]=X+Z,g[M++]=Y,g[M++]=U+Z,g[M++]=U+W}const Q=new q,J=Math.max(s,n);return Q.min.set(-J,-t,-J),Q.max.set(J,t,J),{bounds:Q,vertices:i,indices:g}}static createTorus(s=.5,n=.1,e=30,o=30,c=360){e=Math.floor(e),o=Math.floor(o);const p=(e+1)*(o+1),R=e*o,t=z._generateIndices(p,R*6),a=8,y=new Float32Array(p*a);c=c/180*Math.PI;let m=0;const h=z._tempVec30;for(let x=0;x<=e;x++)for(let u=0;u<=o;u++){const d=u/o*c,l=x/e*Math.PI*2,i=Math.cos(l),M=Math.sin(l),f=Math.cos(d),v=Math.sin(d),I=(s+n*i)*f,P=(s+n*i)*v,S=n*M;y[m++]=I,y[m++]=P,y[m++]=S;const r=s*f,E=s*v;h.set(I-r,P-E,S).normalize(),y[m++]=h.x,y[m++]=h.y,y[m++]=h.z,y[m++]=u/o,y[m++]=x/e}m=0;for(let x=1;x<=e;x++)for(let u=1;u<=o;u++){const d=(o+1)*x+u-1,l=(o+1)*(x-1)+u-1,i=(o+1)*(x-1)+u,M=(o+1)*x+u;t[m++]=d,t[m++]=l,t[m++]=M,t[m++]=l,t[m++]=i,t[m++]=M}const w=new q,g=s+n;return w.min.set(-g,-g,-n),w.max.set(g,g,n),{bounds:w,vertices:y,indices:t}}static createCone(s=.5,n=2,e=20,o=1){e=Math.floor(e),o=Math.floor(o);const c=e+1,p=o+1,R=n*.5,t=n/o,a=c*p,y=e*o,m=a+1+e,h=z._generateIndices(m,y*6+e*3),w=1/c,g=1/e,x=1/o,u=8,d=new Float32Array(m*8);let l=0;const i=Math.PI,M=Math.PI*2,f=s/n;for(let r=0;r<a;++r){const E=r%c,j=r*w|0,D=E*g,Y=j*x,X=i+D*M,U=Math.sin(X),Q=Math.cos(X),J=s-j*s,F=J*U,Z=j*t-R,W=J*Q;let O=r*u;d[O++]=F,d[O++]=Z,d[O++]=W,d[O++]=U,d[O++]=f,d[O++]=Q,d[O++]=D,d[O++]=1-Y}for(let r=0;r<y;++r){const E=r%e,D=(r*g|0)*c+E,Y=D+1,X=D+c,U=X+1;h[l++]=Y,h[l++]=X,h[l++]=D,h[l++]=Y,h[l++]=U,h[l++]=X}let v=a*u;d[v++]=0,d[v++]=-R,d[v++]=0,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=.5,d[v++]=.5,v=(a+1)*u;const I=1/(s*2);for(let r=0;r<e;++r){const E=d[r*u],j=d[r*u+2];d[v++]=E,d[v++]=-R,d[v++]=j,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=E*I+.5,d[v++]=.5-j*I}const P=a+1;for(let r=0;r<e;++r){const E=r,j=r===e-1?0:E+1;h[l++]=a,h[l++]=P+j,h[l++]=P+E}const S=new q;return S.min.set(-s,-R,-s),S.max.set(s,R,s),{bounds:S,vertices:d,indices:h}}static createCapsule(s=.5,n=2,e=6,o=1){e=Math.max(2,Math.floor(e)),o=Math.floor(o);const c=e+1,p=o+1,R=n*.5,t=n/o,a=c*p,y=e*o,m=c*c,h=e*e,w=a+2*m,g=z._generateIndices(w,(y+2*h)*6),x=1/c,u=1/e,d=1/o,l=Math.PI,i=Math.PI*2,M=8,f=new Float32Array(w*M);let v=0;for(let P=0;P<a;++P){const S=P%c,r=P*x|0,E=S*u,j=r*d,D=l+E*i,Y=Math.sin(D),X=Math.cos(D);let U=P*M;f[U++]=s*Y,f[U++]=r*t-R,f[U++]=s*X,f[U++]=Y,f[U++]=0,f[U++]=X,f[U++]=E,f[U++]=1-j}for(let P=0;P<y;++P){const S=P%e,E=(P*u|0)*c+S,j=E+1,D=E+c,Y=D+1;g[v++]=j,g[v++]=D,g[v++]=E,g[v++]=j,g[v++]=Y,g[v++]=D}z._createCapsuleCap(s,n,e,l,i,a,1,f,g,v),z._createCapsuleCap(s,n,e,l,-i,a+m,-1,f,g,v+6*h);const I=new q;return I.min.set(-s,-s-R,-s),I.max.set(s,s+R,s),{bounds:I,vertices:f,indices:g}}static _generateIndices(s,n){let e=null;return s>65535?e=new Uint32Array(n):e=new Uint16Array(n),e}static _createCapsuleCap(s,n,e,o,c,p,R,t,a,y){const m=e+1,h=n*.5*R,w=m*m,g=e*e,x=1/m,u=1/e,d=8;for(let l=0;l<w;++l){const i=l%m,M=l*x|0,f=i*u,v=M*u,I=o+f*c,P=v*Math.PI*.5,S=Math.sin(P),r=s*Math.sin(I)*S,E=s*Math.cos(P)*R+h,j=s*Math.cos(I)*S;let D=(l+p)*d;t[D++]=r,t[D++]=E,t[D++]=j,t[D++]=r,t[D++]=E-h,t[D++]=j,t[D++]=f,t[D++]=v}for(let l=0;l<g;++l){const i=l%e,f=(l*u|0)*m+i+p,v=f+1,I=f+m,P=I+1;a[y++]=v,a[y++]=f,a[y++]=P,a[y++]=f,a[y++]=I,a[y++]=P}}static createSubdivisionSurfaceSphereData(s=.5,n=3){n=Rt.clamp(Math.floor(n),1,6);const e=new Float32Array(3*(6*Math.pow(4,n)+2)),o=new Float32Array(24*Math.pow(4,n));this._subdiveCatmullClark(n,e,o);const c=e.length/3,p=o.length/4,R=c+Math.pow(2,n+1)-1,t=R+16,a=new Float32Array(t*8),y=this._generateIndices(c,p*6);let m=0;const h={};for(let x=0;x<c;x++){let u=3*x,d=e[u],l=e[u+1],i=e[u+2];const M=1/Math.sqrt(d*d+l*l+i*i);if(d*=M,l*=M,i*=M,u=8*x,a[u]=d*s,a[u+1]=l*s,a[u+2]=i*s,a[u+3]=d,a[u+4]=l,a[u+5]=i,a[u+6]=(Math.PI-Math.atan2(i,d))/(2*Math.PI),a[u+7]=Math.acos(l)/Math.PI,a[u+6]===0){const f=8*(c+m++);a.set(a.subarray(u,u+8),f),a[f+6]=1,h[u/8]=f/8}}let w=0;this._spherePoleIdx=0;for(let x=0;x<p;x++){const u=4*x;let d=o[u],l=o[u+1],i=o[u+2],M=o[u+3];const f=8*d,v=8*l,I=8*i,P=8*M;a[f+2]+a[v+2]+a[I+2]<0&&(a[f+6]===0&&(d=h[d]),a[v+6]===0&&(l=h[l]),a[I+6]===0&&(i=h[i]),a[P+6]===0&&(M=h[M])),y[w]=d,y[w+1]=l,y[w+2]=i,this._generateAndReplacePoleUV(y,a,w,R),y[w+3]=d,y[w+4]=i,y[w+5]=M,this._generateAndReplacePoleUV(y,a,w+3,R),w+=6}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:y,vertices:a,bounds:g}}static _generateAndReplacePoleUV(s,n,e,o){const c=n[8*s[e]+7];if(c===0||c===1){const p=8*s[e],R=8*(o+this._spherePoleIdx);n.set(n.subarray(p,p+8),R),n[R+6]=.5*(n[p+6]+n[8*s[e+1]+6]+n[8*s[e+2]+6]-.5),s[e]=o+this._spherePoleIdx++}}static _subdiveCatmullClark(s,n,e){const o=new Map,c=new Array;n.set(this._sphereSeedPositions),e.set(this._sphereSeedCells);for(let p=0;p<s;p++){const R=6*Math.pow(4,p),t=4*R+2;o.clear(),c.length=0;for(let w=0;w<R;w++){const g=c[w]={facePoint:new it,adjacentEdges:new Array(4)};for(let x=0;x<4;x++){const u=3*e[4*w+x];g.facePoint.x+=.25*n[u],g.facePoint.y+=.25*n[u+1],g.facePoint.z+=.25*n[u+2]}for(let x=0;x<4;x++){const u=e[4*w+x],d=e[4*w+(x+1)%4],l=Math.min(u,d)*t+Math.max(u,d);if(!o.has(l)){const v={edgePoint:new it,edgePointIndex:void 0},I=3*u,P=3*d;v.edgePoint.set(.25*(n[I]+n[P]),.25*(n[I+1]+n[P+1]),.25*(n[I+2]+n[P+2])),o.set(l,v)}const i=o.get(l);g.adjacentEdges[x]=i;const M=i.edgePoint,f=g.facePoint;M.x+=.25*f.x,M.y+=.25*f.y,M.z+=.25*f.z}}const a=R+2,y=a+R;let m=0;this._sphereEdgeIdx=0;const h=e.slice(0,4*R);for(let w=0;w<R;w++){const g=c[w];g.facePoint.copyToArray(n,3*(a+w));const x=a+w;let u,d,l;for(let i=0;i<4;i++){const M=h[m++];switch(i){case 0:{const v=g.adjacentEdges[i%4],I=g.adjacentEdges[(i+3)%4];d=this._calculateEdgeIndex(n,v,y),u=this._calculateEdgeIndex(n,I,y),l=u;break}case 1:case 2:{const v=g.adjacentEdges[i%4];u=d,d=this._calculateEdgeIndex(n,v,y);break}case 3:{u=d,d=l;break}}const f=4*(4*w+i);e[f]=M,e[f+1]=d,e[f+2]=x,e[f+3]=u}}}}static _calculateEdgeIndex(s,n,e){if(n.edgePointIndex!==void 0)return n.edgePointIndex;{n.edgePoint.copyToArray(s,3*(e+this._sphereEdgeIdx));const o=e+this._sphereEdgeIdx++;return n.edgePointIndex=o,o}}};A(z,"_tempVec30",new it),A(z,"_sphereSeedPositions",new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1])),A(z,"_sphereSeedCells",new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1])),A(z,"_sphereEdgeIdx",0),A(z,"_spherePoleIdx",0);let k=z;function Ft(){return[new at(ct.Position,0,rt.Vector3,0),new at(ct.Normal,12,rt.Vector3,0),new at(ct.UV,24,rt.Vector2,0)]}function lt(C,s,{vertices:n,indices:e,bounds:o}){const c=new dt(s,mt.VertexBuffer,n,ft.Static),p=new dt(s,mt.IndexBuffer,e,ft.Static);C.setVertexElements(Ft()),C.setIndexBufferBinding(p,e instanceof Uint16Array?yt.UInt16:yt.UInt32),C.setVertexBufferBinding(c,32),C.bounds=o,C.subMesh?C.subMesh.count=e.length:C.addSubMesh(0,e.length)}class St extends It{constructor(s,n,e){super(s),this.engine=n,this.generateData=e}restoreContent(){lt(this.resource,this.engine,this.generateData())}}function Ot(C,s,n){s.resourceManager.addContentRestorer(new St(C,s,n))}function jt(C,s,n){const e=new Pt(C,s);return Ot(e,C,n),lt(e,C,n()),e}var Ut=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,_=(C,s,n,e)=>{for(var o=e>1?void 0:e?zt(s,n):s,c=C.length-1,p;c>=0;c--)(p=C[c])&&(o=(e?p(s,n,o):p(o))||o);return e&&o&&Ut(s,n,o),o},bt=(C=>(C.Sphere="sphere",C.Cuboid="cuboid",C.Plane="plane",C.Cylinder="cylinder",C.Torus="torus",C.Cone="cone",C.Capsule="capsule",C))(bt||{});const gt=C=>C.type==="sphere",ot=C=>C.type==="capsule",st=C=>C.type==="cone",pt=C=>C.type==="cuboid",G=C=>C.type==="cylinder",tt=C=>C.type==="torus",nt=C=>C.type==="plane",N=C=>C._updateData();let H=class extends At{constructor(s){super(s);A(this,"type","sphere");A(this,"sphereRadius",.5);A(this,"sphereStep",3);A(this,"capsuleRadius",.5);A(this,"capsuleHeight",2);A(this,"capsuleRadialSegments",6);A(this,"capsuleHeightSegments",1);A(this,"coneRadius",.5);A(this,"coneHeight",2);A(this,"coneRadialSegment",20);A(this,"coneHeightSegment",1);A(this,"cuboidWidth",1);A(this,"cuboidHeight",1);A(this,"cuboidDepth",1);A(this,"cylinderRadiusTop",.5);A(this,"cylinderRadiusBottom",.5);A(this,"cylinderHeight",2);A(this,"cylinderRadialSegment",20);A(this,"cylinderHeightSegment",1);A(this,"planeWidth",1);A(this,"planeHeight",1);A(this,"planeHorizontalSegments",1);A(this,"planeVerticalSegments",1);A(this,"torusRadius",.5);A(this,"torusTubeRadius",.1);A(this,"torusRadialSegments",30);A(this,"torusTubularSegments",30);A(this,"torusArc",360)}async initByCreation(s,n,e){const c=(typeof(e==null?void 0:e.primitiveType)=="string"?e.primitiveType:"").trim().toLowerCase();return{type:{sphere:"sphere",cube:"cuboid",cuboid:"cuboid",cylinder:"cylinder",plane:"plane",capsule:"capsule",cone:"cone",torus:"torus"}[c]??"sphere"}}async initByMain(s,n){const e=JSON.parse(await s.text()),o=this.engine,c=e.type;for(const y in e)this[y]=e[y];const p=jt(o,c,()=>this._generateDataByType(this.type));this.bindEngineObject(p);const R=new Ht(o,c&&c.charAt(0).toUpperCase()+c.slice(1)),t=R.addComponent(_t);t.mesh=this.engineObject;const a=await this.root.assetStore.getAssetByRef({refId:"0000200"});t.setMaterial(a.engineObject),this.setDragTempEntity(R)}instantiate(){const s=this.root.sceneStore.createEntity(),n=this.getDragTempEntity();return s.initByEngineObject(n.clone()),s}_updateData(){const s=this.engine,n=this._engineObject;lt(n,s,this._generateDataByType(this.type))}_generateDataByType(s){switch(s){case"sphere":return k.createSubdivisionSurfaceSphereData(this.sphereRadius,this.sphereStep);case"capsule":return k.createCapsule(this.capsuleRadius,this.capsuleHeight,this.capsuleRadialSegments,this.capsuleHeightSegments);case"cone":return k.createCone(this.coneRadius,this.coneHeight,this.coneRadialSegment,this.coneHeightSegment);case"cuboid":return k.createCuboid(this.cuboidWidth,this.cuboidHeight,this.cuboidDepth);case"cylinder":return k.createCylinder(this.cylinderRadiusTop,this.cylinderRadiusBottom,this.cylinderHeight,this.cylinderRadialSegment,this.cylinderHeightSegment);case"plane":return k.createPlane(this.planeWidth,this.planeHeight,this.planeHorizontalSegments,this.planeVerticalSegments);case"torus":return k.createTorus(this.torusRadius,this.torusTubeRadius,this.torusRadialSegments,this.torusTubularSegments,this.torusArc);default:return k.createSphere(this.sphereRadius,this.sphereStep)}}};_([B({label:b("asset.primitive-mesh.type.label"),info:b("asset.primitive-mesh.type.info"),type:T.Select,value:"sphere",options:Bt(bt),onChange(C){C._updateData()}}),V()],H.prototype,"type",2);_([B({label:b("asset.primitive-mesh.sphere.radius.label"),info:b("asset.primitive-mesh.sphere.radius.info"),type:T.Number,min:0,dragStep:.1,when:gt,onChange:N}),V()],H.prototype,"sphereRadius",2);_([B({label:b("asset.primitive-mesh.sphere.step.label"),info:b("asset.primitive-mesh.sphere.step.info"),type:T.Number,min:1,dragStep:1,when:gt,onChange:N}),V()],H.prototype,"sphereStep",2);_([B({label:b("asset.primitive-mesh.capsule.radius.label"),info:b("asset.primitive-mesh.capsule.radius.info"),type:T.Number,min:0,dragStep:.1,when:ot,onChange:N}),V()],H.prototype,"capsuleRadius",2);_([B({label:b("asset.primitive-mesh.capsule.height.label"),info:b("asset.primitive-mesh.capsule.height.info"),type:T.Number,min:0,dragStep:.1,when:ot,onChange:N}),V()],H.prototype,"capsuleHeight",2);_([B({label:b("asset.primitive-mesh.capsule.radial-segments.label"),info:b("asset.primitive-mesh.capsule.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:ot,onChange:N}),V()],H.prototype,"capsuleRadialSegments",2);_([B({label:b("asset.primitive-mesh.capsule.height-segments.label"),info:b("asset.primitive-mesh.capsule.height-segments.info"),type:T.Number,min:1,dragStep:1,when:ot,onChange:N}),V()],H.prototype,"capsuleHeightSegments",2);_([B({label:b("asset.primitive-mesh.cone.radius.label"),info:b("asset.primitive-mesh.cone.radius.info"),type:T.Number,min:0,dragStep:.1,when:st,onChange:N}),V()],H.prototype,"coneRadius",2);_([B({label:b("asset.primitive-mesh.cone.height.label"),info:b("asset.primitive-mesh.cone.height.info"),type:T.Number,min:0,dragStep:.1,when:st,onChange:N}),V()],H.prototype,"coneHeight",2);_([B({label:b("asset.primitive-mesh.cone.radial-segments.label"),info:b("asset.primitive-mesh.cone.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:st,onChange:N}),V()],H.prototype,"coneRadialSegment",2);_([B({label:b("asset.primitive-mesh.cone.height-segments.label"),info:b("asset.primitive-mesh.cone.height-segments.info"),type:T.Number,min:1,dragStep:1,when:st,onChange:N}),V()],H.prototype,"coneHeightSegment",2);_([B({label:b("asset.primitive-mesh.cuboid.width.label"),info:b("asset.primitive-mesh.cuboid.width.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidWidth",2);_([B({label:b("asset.primitive-mesh.cuboid.height.label"),info:b("asset.primitive-mesh.cuboid.height.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidHeight",2);_([B({label:b("asset.primitive-mesh.cuboid.depth.label"),info:b("asset.primitive-mesh.cuboid.depth.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidDepth",2);_([B({label:b("asset.primitive-mesh.cylinder.radius-top.label"),info:b("asset.primitive-mesh.cylinder.radius-top.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderRadiusTop",2);_([B({label:b("asset.primitive-mesh.cylinder.radius-bottom.label"),info:b("asset.primitive-mesh.cylinder.radius-bottom.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderRadiusBottom",2);_([B({label:b("asset.primitive-mesh.cylinder.height.label"),info:b("asset.primitive-mesh.cylinder.height.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderHeight",2);_([B({label:b("asset.primitive-mesh.cylinder.radial-segments.label"),info:b("asset.primitive-mesh.cylinder.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:G,onChange:N}),V()],H.prototype,"cylinderRadialSegment",2);_([B({label:b("asset.primitive-mesh.cylinder.height-segments.label"),info:b("asset.primitive-mesh.cylinder.height-segments.info"),type:T.Number,min:1,dragStep:1,when:G,onChange:N}),V()],H.prototype,"cylinderHeightSegment",2);_([B({label:b("asset.primitive-mesh.plane.width.label"),info:b("asset.primitive-mesh.plane.width.info"),type:T.Number,min:0,dragStep:.1,when:nt,onChange:N}),V()],H.prototype,"planeWidth",2);_([B({label:b("asset.primitive-mesh.plane.height.label"),info:b("asset.primitive-mesh.plane.height.info"),type:T.Number,min:0,dragStep:.1,when:nt,onChange:N}),V()],H.prototype,"planeHeight",2);_([B({label:b("asset.primitive-mesh.plane.horizontal-segments.label"),info:b("asset.primitive-mesh.plane.horizontal-segments.info"),type:T.Number,min:1,dragStep:1,when:nt,onChange:N}),V()],H.prototype,"planeHorizontalSegments",2);_([B({label:b("asset.primitive-mesh.plane.vertical-segments.label"),info:b("asset.primitive-mesh.plane.vertical-segments.info"),type:T.Number,min:1,dragStep:1,when:nt,onChange:N}),V()],H.prototype,"planeVerticalSegments",2);_([B({label:b("asset.primitive-mesh.torus.radius.label"),info:b("asset.primitive-mesh.torus.radius.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusRadius",2);_([B({label:b("asset.primitive-mesh.torus.tube-radius.label"),info:b("asset.primitive-mesh.torus.tube-radius.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusTubeRadius",2);_([B({label:b("asset.primitive-mesh.torus.radial-segments.label"),info:b("asset.primitive-mesh.torus.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:tt,onChange:N}),V()],H.prototype,"torusRadialSegments",2);_([B({label:b("asset.primitive-mesh.torus.tubular-segments.label"),info:b("asset.primitive-mesh.torus.tubular-segments.info"),type:T.Number,min:1,dragStep:1,when:tt,onChange:N}),V()],H.prototype,"torusTubularSegments",2);_([B({label:b("asset.primitive-mesh.torus.arc.label"),info:b("asset.primitive-mesh.torus.arc.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusArc",2);H=_([Vt({type:"PrimitiveMesh",label:b("asset.primitive-mesh.title"),loaderType:"PrimitiveMesh",importMenuConfig:{type:Nt.Add},defaultName:"Mesh",dragLayer:Tt.PrimitiveMesh,thumbnail:Dt,async bundle({content:C}){return{content:new Blob([Et(await C.text())])}}})],H);export{H as PrimitiveMesh};
@@ -1 +0,0 @@
1
- import{C as n,w as g,T as A,V as C,x as I,R as h,y as x,t as R,z as y,B as m,F as P,G as E,H as B,I as V}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";var w=(e=>(e.Vector2="Vector2",e.Vector3="Vector3",e.Vector4="Vector4",e.Color="Color",e.Float="Float",e.Texture="Texture",e.Boolean="Boolean",e.Integer="Integer",e))(w||{});function t(e,r){return e.indexOf(r)!==-1}function u(e,r,a){const o=r.engineObject.shaderData;a==="enable"?o.enableMacro(e):o.disableMacro(e)}async function l(e,r,a,o,d){var T;const i=e.engineObject.shaderData;let s;const p=r.toString();switch(o){case n.Slider:case n.Number:case"Float":i.setFloat(p,a);break;case n.Toggle:case n.Boolean:case n.Select:case"Integer":i.setInt(p,Number(a));break;case n.AssetPicker:case"Texture":if(a){const c=await e.root.assetStore.getAssetByRef(a);if(c){const b=c.engineObject;i.setTexture(p,b),d&&u(d,e,"enable")}else i.setTexture(p,null),d&&u(d,e,"disable"),console.error(`${p} in ${e.name} is missing.`)}else i.setTexture(p,null),d&&u(d,e,"disable");break;case n.Vector2:case"Vector2":s=i.getVector2(p),a==null?i.setVector2(p,a):s?(s.x=a.x,s.y=a.y):i.setVector2(p,new V(a.x,a.y));break;case n.Vector3:case"Vector3":s=i.getVector3(p),a==null?i.setVector3(p,a):s?(s.x=a.x,s.y=a.y,s.z=a.z):i.setVector3(p,new B(a.x,a.y,a.z));break;case n.Vector4:case"Vector4":s=i.getVector4(p),a==null?i.setVector4(p,a):s?(s.x=a.x,s.y=a.y,s.z=a.z,s.w=a.w):i.setVector4(p,new C(a.x,a.y,a.z,a.w));break;case n.Color:case"Color":{s=i.getColor(p);let{r:c,g:b,b:S}=a;const{a:_,intensity:f=1}=a;c*=f,b*=f,S*=f,a==null?i.setColor(p,new I(c,b,S,_)):s?(s.r=c,s.g=b,s.b=S,s.a=_):i.setColor(p,new I(c,b,S,_));break}}(T=e.updateThumbnail)==null||T.call(e)}const L=[{prop:"material_IOR",defaultValue:1.5,bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.ior",type:n.Slider,min:1,max:5,dragStep:.01,group:"Base"},engineType:"Float"},{prop:"material_BaseColor",defaultValue:{r:1,g:1,b:1,a:1},bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["Unlit","BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.base-color",type:n.Color,group:"Base"},engineType:"Color"},{prop:"material_BaseTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_BASETEXTURE")},bundleType:"shaderData",when:t.bind(null,["Unlit","BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.base-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Base"},engineType:"Texture"},{prop:"material_Metal",defaultValue:1,bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.metallic",type:n.Slider,min:0,max:1,dragStep:.01,group:"Metal roughness"},engineType:"Float"},{prop:"material_Roughness",defaultValue:1,bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.roughness",type:n.Slider,min:0,max:1,dragStep:.01,group:"Metal roughness"},engineType:"Float"},{prop:"material_RoughnessMetallicTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.roughness-metallic-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Metal roughness"},engineType:"Texture"},{prop:"material_SpecularIntensity",defaultValue:1,bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.pbr-specular-intensity",type:n.Slider,min:0,max:2,dragStep:.01,group:"Specular"},engineType:"Float"},{prop:"material_SpecularColor",defaultValue:{r:1,g:1,b:1,a:1},bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.pbr-specular-color",type:n.Color,group:"Specular"}},{prop:"material_SpecularIntensityTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_SPECULAR_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.pbr-specular-intensity-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Specular"},engineType:"Texture"},{prop:"material_SpecularColorTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_SPECULAR_COLOR_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.pbr-specular-color-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Specular"},engineType:"Texture"},{prop:"material_AnisotropyInfo",defaultValue:{x:1,y:0,z:0},bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Vector3)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.anisotropy-info",type:n.Vector3,group:"Anisotropy",hide:!0},engineType:"Vector3"},{prop:"anisotropy",defaultValue:0,bundleType:"other",async onChange(e,r,a){const o=e.material_AnisotropyInfo;a===0?u("MATERIAL_ENABLE_ANISOTROPY",e,"disable"):u("MATERIAL_ENABLE_ANISOTROPY",e,"enable"),o.z=a,e.material_AnisotropyInfo=o,await l(e,"material_AnisotropyInfo",o,n.Vector3)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.anisotropy",type:n.Slider,min:0,max:1,dragStep:.01,group:"Anisotropy"},setPath:"shaderData.getVector3('material_AnisotropyInfo').z",getPath:"shaderData.getVector3('material_AnisotropyInfo').z",valueType:g.Float},{prop:"anisotropyRotation",defaultValue:0,bundleType:"other",async onChange(e,r,a){const o=e.material_AnisotropyInfo,d=Math.PI/180*a;o.x=Math.cos(d),o.y=Math.sin(d),e.material_AnisotropyInfo=o,await l(e,"material_AnisotropyInfo",o,n.Vector3)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.anisotropy-rotation",type:n.Slider,min:0,max:360,dragStep:1,group:"Anisotropy"}},{prop:"material_AnisotropyTexture",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_ANISOTROPY_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.anisotropy-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Anisotropy"},engineType:"Texture"},{prop:"material_NormalTexture",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_NORMALTEXTURE")},bundleType:"shaderData",when:t.bind(null,["BlinnPhong","PBR","PbrSpecular"]),uiInfo:{label:"shader.material.normal-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Normal"},engineType:"Texture"},{prop:"material_NormalIntensity",defaultValue:1,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["BlinnPhong","PBR","PbrSpecular"]),uiInfo:{label:"shader.material.normal-intensity",type:n.Slider,min:0,max:5,dragStep:.1,group:"Normal"},engineType:"Float"},{prop:"material_EmissiveColor",defaultValue:{r:0,g:0,b:0,a:1,intensity:1},bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.emissive-color",type:n.Color,mode:"hdr",group:"Emissive"}},{prop:"material_EmissiveTexture",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_EMISSIVETEXTURE")},bundleType:"shaderData",when:t.bind(null,["BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.emissive-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Emissive"},engineType:"Texture"},{prop:"material_SpecularColor",defaultValue:{r:1,g:1,b:1,a:1},bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["BlinnPhong"]),uiInfo:{label:"shader.material.specular-color",type:n.Color,group:"Blinn Phong"}},{prop:"material_SpecularTexture",bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_SPECULAR_TEXTURE")},when:t.bind(null,["BlinnPhong"]),uiInfo:{label:"shader.material.specular-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Blinn Phong"},engineType:"Texture"},{prop:"material_Shininess",defaultValue:16,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["BlinnPhong"]),uiInfo:{label:"shader.material.shininess",type:n.Slider,min:0,max:100,dragStep:1,group:"Blinn Phong"},engineType:"Float"},{prop:"material_OcclusionTexture",bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_OCCLUSION_TEXTURE")},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.occlusion-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Occlusion"},engineType:"Texture"},{prop:"material_OcclusionIntensity",defaultValue:1,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.occlusion-intensity",type:n.Slider,min:0,max:5,dragStep:.1,group:"Occlusion"},engineType:"Float"},{prop:"material_OcclusionTextureCoord",defaultValue:A.UV0,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.occlusion-texture-coord",type:n.Select,value:A.UV0,options:[{label:"shader.material.uv.uv0",value:A.UV0},{label:"shader.material.uv.uv1",value:A.UV1}],group:"Occlusion"},engineType:"Float"},{prop:"material_ClearCoat",defaultValue:0,bundleType:"other",async onChange(e,r,a){l(e,r,a,n.Slider),a===0?u("MATERIAL_ENABLE_CLEAR_COAT",e,"disable"):u("MATERIAL_ENABLE_CLEAR_COAT",e,"enable")},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.clearcoat",type:n.Slider,min:0,max:1,dragStep:.01,group:"Clear coat"},engineType:"Float",setPath:"shaderData.setFloat('material_ClearCoat', $value)",getPath:"shaderData.getFloat('material_ClearCoat')",valueType:g.Float},{prop:"material_ClearCoatTexture",bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_CLEAR_COAT_TEXTURE")},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.clear-coat-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Clear coat"},engineType:"Texture"},{prop:"material_ClearCoatRoughness",defaultValue:0,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.clear-coat-roughness",type:n.Slider,min:0,max:1,dragStep:.01,group:"Clear coat"},engineType:"Float"},{prop:"material_ClearCoatRoughnessTexture",bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE")},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.clear-coat-roughness-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Clear coat"},engineType:"Texture"},{prop:"material_ClearCoatNormalTexture",bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")},when:t.bind(null,["PBR","PbrSpecular"]),uiInfo:{label:"shader.material.clear-coat-normal-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Clear coat"},engineType:"Texture"},{prop:"material_IridescenceInfo",defaultValue:{x:0,y:1.3,z:100,w:400},bundleType:"shaderData",async onChange(e,r,a){e.iridescence=a.x,e.iridescenceIOR=a.y,e.iridescenceRange.x=a.z,e.iridescenceRange.y=a.w},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.iridescence",type:n.Vector4,group:"Iridescence",hide:!0},engineType:"Vector4"},{prop:"iridescence",defaultValue:0,bundleType:"other",async onChange(e,r,a){const o=e.engineObject.shaderData.getVector4("material_IridescenceInfo");o?(o.x=a,l(e,"material_IridescenceInfo",o,n.Vector4)):l(e,"material_IridescenceInfo",new C(a,1.3,100,400),n.Vector4),a?u("MATERIAL_ENABLE_IRIDESCENCE",e,"enable"):u("MATERIAL_ENABLE_IRIDESCENCE",e,"disable")},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.iridescence",type:n.Slider,min:0,max:1,dragStep:.01,group:"Iridescence"},setPath:"shaderData.getVector4('material_IridescenceInfo').x",getPath:"shaderData.getVector4('material_IridescenceInfo').x",valueType:g.Float},{prop:"iridescenceIOR",defaultValue:1.3,bundleType:"other",async onChange(e,r,a){const o=e.engineObject.shaderData.getVector4("material_IridescenceInfo");o?(o.y=a,l(e,"material_IridescenceInfo",o,n.Vector4)):l(e,"material_IridescenceInfo",new C(0,a,100,400),n.Vector4)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.iridescence-ior",type:n.Slider,min:1,max:5,dragStep:.01,group:"Iridescence"},setPath:"shaderData.getVector4('material_IridescenceInfo').y",getPath:"shaderData.getVector4('material_IridescenceInfo').y",valueType:g.Float},{prop:"iridescenceRange",defaultValue:{x:100,y:400},bundleType:"other",async onChange(e,r,a){const o=e.engineObject.shaderData.getVector4("material_IridescenceInfo");o?(o.z=a.x,o.w=a.y,l(e,"material_IridescenceInfo",o,n.Vector4)):l(e,"material_IridescenceInfo",new C(0,1.3,a.x,a.y),n.Vector4)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.iridescence-range",type:n.Vector2,group:"Iridescence"},engineType:"Vector2"},{prop:"material_IridescenceThicknessTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.iridescence-thickness-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Iridescence"},engineType:"Texture"},{prop:"material_IridescenceTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_IRIDESCENCE_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.iridescence-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Iridescence"},engineType:"Texture"},{prop:"material_SheenColor",defaultValue:{r:0,g:0,b:0,a:1},bundleType:"shaderData",async onChange(e,r,a){if(e.sheenIntensity===1){const o=e.sheenColor;o.r=a.r,o.g=a.g,o.b=a.b}},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.sheen-color",type:n.Color,group:"Sheen",hide:!0},engineType:"Color"},{prop:"sheenColor",defaultValue:{r:0,g:0,b:0,a:1},bundleType:"other",async onChange(e,r,a){const o=e.engineObject.shaderData.getColor("material_SheenColor"),d=e.sheenIntensity??1,i=a.r*d,s=a.g*d,p=a.b*d;i+s+p>0?u("MATERIAL_ENABLE_SHEEN",e,"enable"):u("MATERIAL_ENABLE_SHEEN",e,"disable"),o?(o.set(i,s,p,a.a),l(e,"material_SheenColor",o,n.Color)):l(e,"material_SheenColor",new I(i,s,p,a.a),n.Color)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.sheen-color",type:n.Color,group:"Sheen"}},{prop:"sheenIntensity",defaultValue:1,bundleType:"other",async onChange(e,r,a){const o=e.engineObject.shaderData.getColor("material_SheenColor"),d=e.sheenColor,i=a,s=d.r*i,p=d.g*i,T=d.b*i,c=d.a;s+p+T>0?u("MATERIAL_ENABLE_SHEEN",e,"enable"):u("MATERIAL_ENABLE_SHEEN",e,"disable"),o?(o.set(s,p,T,c),l(e,"material_SheenColor",o,n.Color)):l(e,"material_SheenColor",new I(s,p,T,c),n.Color)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.sheen-intensity",type:n.Slider,min:0,max:1,dragStep:.01,group:"Sheen"}},{prop:"material_SheenRoughness",defaultValue:0,bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.sheen-roughness",type:n.Slider,min:0,max:1,dragStep:.01,group:"Sheen"},engineType:"Float"},{prop:"material_SheenTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_SHEEN_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.sheen-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Sheen"},engineType:"Texture"},{prop:"material_SheenRoughnessTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.sheen-roughness-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Sheen"},engineType:"Texture"},{prop:"material_Transmission",defaultValue:0,bundleType:"shaderData",async onChange(e,r,a){a?(u("MATERIAL_ENABLE_TRANSMISSION",e,"enable"),e.setRenderQueueType(h.Transparent)):(u("MATERIAL_ENABLE_TRANSMISSION",e,"disable"),e.isTransparent?e.setRenderQueueType(h.Transparent):e.material_AlphaCutoff?e.setRenderQueueType(h.AlphaTest):e.setRenderQueueType(h.Opaque)),l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.transmission",type:n.Slider,min:0,max:1,dragStep:.01,group:"Transmission"},engineType:"Float"},{prop:"material_TransmissionTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_TRANSMISSION_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.transmission-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Transmission"},engineType:"Texture"},{prop:"material_Thickness",defaultValue:0,bundleType:"shaderData",async onChange(e,r,a){a?u("MATERIAL_HAS_THICKNESS",e,"enable"):u("MATERIAL_HAS_THICKNESS",e,"disable"),l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.transmission-thickness",type:n.Slider,min:0,max:5,dragStep:.01,group:"Transmission"},engineType:"Float"},{prop:"material_ThicknessTexture",async onChange(e,r,a){return l(e,r,a,n.AssetPicker,"MATERIAL_HAS_THICKNESS_TEXTURE")},bundleType:"shaderData",when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.transmission-thickness-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Transmission"},engineType:"Texture"},{prop:"refractionMode",defaultValue:x.Planar,bundleType:"other",async onChange(e,r,a){e.engineObject.shaderData.enableMacro("REFRACTION_MODE",a.toString())},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.refraction-mode",type:n.Select,options:R(x),group:"Transmission"}},{prop:"material_AttenuationColor",defaultValue:{r:1,g:1,b:1,a:1},bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.attenuation-color",type:n.Color,group:"Transmission"},engineType:"Color"},{prop:"material_AttenuationDistance",defaultValue:0,bundleType:"shaderData",async onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["PBR"]),uiInfo:{label:"shader.material.attenuation-distance",type:n.Slider,min:0,max:5,dragStep:.01,group:"Transmission"},engineType:"Float"},{prop:"u_lightMapTexture",bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.AssetPicker,"LIGHTMAP_TEXTURE")},when:t.bind(null,["bake-pbr"]),uiInfo:{label:"shader.material.lightmap-texture",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape!=="Cube",group:"Base"},engineType:"Texture"},{prop:"u_lightMapIntensity",defaultValue:1,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when(e){return e==="bake-pbr"},uiInfo:{label:"shader.material.lightmap-intensity",type:n.Slider,min:0,max:10,dragStep:.1,when(e){return e==="bake-pbr"},group:"Base"},engineType:"Float"},{prop:"material_TintColor",defaultValue:{r:1,g:1,b:1,a:1},bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["SkyBox"]),uiInfo:{label:"shader.material.tint-color",type:n.Color,group:"Base"}},{prop:"material_Exposure",defaultValue:1,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["SkyBox","SkyProcedural"]),uiInfo:{label:"shader.material.exposure",type:n.Slider,min:0,max:8,dragStep:.1,group:"Base"},engineType:"Float"},{prop:"material_Rotation",defaultValue:0,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["SkyBox"]),uiInfo:{label:"shader.material.rotation",type:n.Slider,min:0,max:360,dragStep:1,group:"Base"},engineType:"Float"},{prop:"material_CubeTexture",bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.AssetPicker)},when:t.bind(null,["SkyBox"]),uiInfo:{label:"shader.material.texture-cube",type:n.AssetPicker,assetType:"Texture",customFilter:e=>e.shape==="Cube",group:"Base"},engineType:"Texture"},{prop:"sunMode",defaultValue:y.HighQuality,bundleType:"other",async onChange(e,r,a){switch(a){case y.HighQuality:u("MATERIAL_SUN_SIMPLE",e,"disable"),u("MATERIAL_SUN_HIGH_QUALITY",e,"enable");break;case y.Simple:u("MATERIAL_SUN_HIGH_QUALITY",e,"disable"),u("MATERIAL_SUN_SIMPLE",e,"enable");break;case y.None:u("MATERIAL_SUN_HIGH_QUALITY",e,"disable"),u("MATERIAL_SUN_SIMPLE",e,"disable");break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}},when:t.bind(null,["SkyProcedural"]),uiInfo:{label:"shader.material.sun-mode",type:n.Select,options:R(y),group:"Base"}},{prop:"material_SunSize",defaultValue:.04,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["SkyProcedural"]),uiInfo:{label:"shader.material.sun-size",type:n.Slider,min:0,max:1,dragStep:.01,group:"Base"},engineType:"Float"},{prop:"material_SunSizeConvergence",defaultValue:5,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["SkyProcedural"]),uiInfo:{label:"shader.material.sun-size-convergence",type:n.Slider,min:0,max:20,dragStep:.1,group:"Base"},engineType:"Float"},{prop:"material_AtmosphereThickness",defaultValue:1,bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Slider)},when:t.bind(null,["SkyProcedural"]),uiInfo:{label:"shader.material.atmosphere-thickness",type:n.Slider,min:0,max:5,dragStep:.1,group:"Base"},engineType:"Float"},{prop:"material_SkyTint",defaultValue:{r:.21404114048223255,g:.21404114048223255,b:.21404114048223255,a:1},bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["SkyProcedural"]),uiInfo:{label:"shader.material.sky-tint",type:n.Color,group:"Base"},engineType:"Color"},{prop:"material_GroundTint",defaultValue:{r:.11216882039252905,g:.09988709277986121,b:.09520561068319185,a:1},bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Color)},when:t.bind(null,["SkyProcedural"]),uiInfo:{label:"shader.material.ground-tint",type:n.Color,group:"Base"},engineType:"Color"},{prop:"isTransparent",defaultValue:!1,bundleType:"other",async onChange(e,r,a){if(e.setBlendStateEnabled(a),e.setDepthWriteEnabled(!a),a?(e.setRenderQueueType(h.Transparent),u("MATERIAL_IS_TRANSPARENT",e,"enable")):(e.setRenderQueueType(e.material_AlphaCutoff?h.AlphaTest:h.Opaque),u("MATERIAL_IS_TRANSPARENT",e,"disable")),e.material_Transmission>0&&e.setRenderQueueType(h.Transparent),a)l(e,"material_ShadowCasterRenderQueue",h.AlphaTest,n.Number),l(e,"material_DepthOnlyRenderQueue",h.Transparent,n.Number);else{const d=e.material_AlphaCutoff?h.AlphaTest:h.Opaque;l(e,"material_ShadowCasterRenderQueue",d,n.Number),l(e,"material_DepthOnlyRenderQueue",d,n.Number)}},when:t.bind(null,["Unlit","BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.is-transparent",type:n.Toggle,group:"Common"}},{prop:"material_AlphaCutoff",defaultValue:0,bundleType:"shaderData",async onChange(e,r,a){const{shaderData:o}=e.engineObject,d=e.isTransparent;if(a){u("MATERIAL_IS_ALPHA_CUTOFF",e,"enable");const i=d?h.Transparent:h.AlphaTest;e.setRenderQueueType(i),o.setFloat("material_ShadowCasterRenderQueue",h.AlphaTest),o.setFloat("material_DepthOnlyRenderQueue",i)}else{u("MATERIAL_IS_ALPHA_CUTOFF",e,"disable");const i=d?h.Transparent:h.Opaque;e.setRenderQueueType(i);const s=d?h.AlphaTest:h.Opaque;o.setFloat("material_ShadowCasterRenderQueue",s),o.setFloat("material_DepthOnlyRenderQueue",i)}o.setFloat("material_AlphaCutoff",a),e.material_Transmission>0&&e.setRenderQueueType(h.Transparent)},when:t.bind(null,["Unlit","BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.alpha-cutoff",type:n.Slider,min:0,max:1,dragStep:.01,group:"Common"},engineType:"Float"},{prop:"renderFace",defaultValue:m.Front,bundleType:"other",async onChange(e,r,a){if(!["SkyBox","SkyProcedural"].includes(e.engineObject.shader.name))switch(a){case m.Front:e.setCullMode(P.Back);break;case m.Back:e.setCullMode(P.Front);break;case m.Double:e.setCullMode(P.Off);break}},when:t.bind(null,["Unlit","BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.render-face",type:n.Select,options:R(m),group:"Common"}},{prop:"blendMode",defaultValue:E.Normal,bundleType:"other",async onChange(e,r,a){e.setBlendMode(a)},when:t.bind(null,["Unlit","BlinnPhong","PBR","PbrSpecular","Particle","Trail"]),uiInfo:{label:"shader.material.blend-mode",type:n.Select,options:[{label:"shader.material.blend-mode-options.normal",value:E.Normal},{label:"shader.material.blend-mode-options.additive",value:E.Additive}],group:"Common"}},{prop:"material_TilingOffset",defaultValue:{x:1,y:1,z:0,w:0},bundleType:"shaderData",onChange(e,r,a){return l(e,r,a,n.Vector4)},when:t.bind(null,["Unlit","BlinnPhong","PBR","PbrSpecular"]),uiInfo:{label:"shader.material.tiling-offset",type:n.Vector4,group:"Common"},engineType:"Vector4"}];export{w as E,L as b,l as s};
@@ -1 +0,0 @@
1
- var C=Object.defineProperty;var M=(s,t,e)=>t in s?C(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var h=(s,t,e)=>(M(s,typeof t!="symbol"?t+"":t,e),e);import{$ as R,a9 as y,bv as l,j as x,bu as v,bw as S,p as b,C as m,m as f,e as G,n as F}from"./index-0a8702e2.js";import{a as O,A as D}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{A as B}from"./AssetViewer-bc198e16.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";class A{static update(t,e){var o;this.spriteEntity?this.spriteEntity.isActive=!0:this.initScene(t),this.entity=this.spriteEntity;const i=(o=e.engineObject)==null?void 0:o.getColorTexture(0);i&&(this.sprite.texture=i)}static clear(){this.spriteEntity&&(this.spriteEntity.isActive=!1)}static initScene(t){const e=this.spriteEntity=t.createChild("rt-thumbnail");this.spriteRenderer=e.addComponent(R),this.spriteRenderer.sprite=this.sprite=new y(t.engine)}}h(A,"entity"),h(A,"spriteEntity"),h(A,"spriteRenderer"),h(A,"sprite");class j extends B{constructor(){super(...arguments);h(this,"_asset");h(this,"_sprite");h(this,"_onRebuild",()=>{var e;if(this._sprite&&((e=this._asset)!=null&&e.engineObject)){const i=this._asset.engineObject.getColorTexture(0);i&&(this._sprite.texture=i)}})}setViewAsset(e,i){var _;this._asset=e;const o=i.engine,r=i.createChild("rt_preview"),n=(_=e.engineObject)==null?void 0:_.getColorTexture(0),a=new y(o,n),c=r.addComponent(R);c.sprite=a,this._sprite=a,this._entity=r,e.onRebuild(this._onRebuild)}stopViewAsset(){super.stopViewAsset(),this._asset&&this._asset.offRebuild(this._onRebuild),this._asset=null,this._sprite=null}getDescription(e){return`${e.width}x${e.height}`}}var E=Object.defineProperty,V=Object.getOwnPropertyDescriptor,g=(s,t,e,i)=>{for(var o=i>1?void 0:i?V(t,e):t,r=s.length-1,n;r>=0;r--)(n=s[r])&&(o=(i?n(t,e,o):n(o))||o);return i&&o&&E(t,e,o),o};const I=[{label:"R8G8B8A8",value:l.R8G8B8A8},{label:"R8G8B8",value:l.R8G8B8},{label:"R16G16B16A16",value:l.R16G16B16A16},{label:"R32G32B32A32",value:l.R32G32B32A32},{label:"R11G11B10_UFloat",value:l.R11G11B10_UFloat}],w=-1,L=[{label:"None",value:w},{label:"Depth",value:l.Depth},{label:"Depth16",value:l.Depth16},{label:"Depth24",value:l.Depth24},{label:"Depth32",value:l.Depth32},{label:"Depth24Stencil8",value:l.Depth24Stencil8},{label:"Depth32Stencil8",value:l.Depth32Stencil8}],U=[{label:"1",value:1},{label:"2",value:2},{label:"4",value:4},{label:"8",value:8}];let u=class extends x{constructor(){super(...arguments);h(this,"_onRebuildCallbacks",[]);h(this,"width",512);h(this,"height",512);h(this,"colorFormat",l.R8G8B8A8);h(this,"depthFormat",l.Depth);h(this,"antiAliasing",1);h(this,"autoGenerateMipmaps",!0)}registerThumbnail(){}onRebuild(t){this._onRebuildCallbacks.push(t)}offRebuild(t){const e=this._onRebuildCallbacks.indexOf(t);e!==-1&&this._onRebuildCallbacks.splice(e,1)}async initByCreation(){return this.getMainData()}getMainData(){var i;const t={width:this.width,height:this.height,colorFormats:[this.colorFormat],depthFormat:this.depthFormat,antiAliasing:this.antiAliasing,autoGenerateMipmaps:this.autoGenerateMipmaps},e=(i=this.engineObject)==null?void 0:i.getColorTexture(0);return e&&(t.colorTextures=[{isSRGBColorSpace:e.isSRGBColorSpace,mipmap:e.mipmapCount>1,filterMode:e.filterMode,wrapModeU:e.wrapModeU,wrapModeV:e.wrapModeV,anisoLevel:e.anisoLevel}]),JSON.stringify(t)}async initByMain(t){const e=JSON.parse(await t.text());this.width=Math.round(e.width??512),this.height=Math.round(e.height??512);const i=e.colorFormats??[e.colorFormat??l.R8G8B8A8];this.colorFormat=i[0],this.depthFormat=e.depthFormat??l.Depth,this.antiAliasing=e.antiAliasing??1,this.autoGenerateMipmaps=e.autoGenerateMipmaps??!1;const r=(e.colorTextures??(e.colorTexture?[e.colorTexture]:[]))[0],n=this._buildRenderTarget((r==null?void 0:r.mipmap)??!0,r==null?void 0:r.isSRGBColorSpace);await this.bindEngineObject(n);const a=n.getColorTexture(0);a&&r&&(r.filterMode!=null&&(a.filterMode=r.filterMode),r.wrapModeU!=null&&(a.wrapModeU=r.wrapModeU),r.wrapModeV!=null&&(a.wrapModeV=r.wrapModeV),r.anisoLevel!=null&&(a.anisoLevel=r.anisoLevel)),await this._generateSubAssets()}destroy(){this._destroySubAssets(),this.engineObject&&this._replaceCameraRenderTarget(this.engineObject,null),this._onRebuildCallbacks.length=0,this._destroyRenderTarget(),super.destroy()}async _rebuild(){var _;if(!this.engineObject)return;const t=this.engineObject,e=t.getColorTexture(0),i=(_=this._subAssets)==null?void 0:_[0],o=i?i.mipmap??!0:!0,r=i?i.isSRGBColorSpace??this.colorFormat===l.R8G8B8A8:this.colorFormat===l.R8G8B8A8,n=e&&e.format===this.colorFormat&&e.width===this.width&&e.height===this.height&&e.isSRGBColorSpace===r&&o===e.mipmapCount>1;let a;try{a=n?this._buildRenderTargetWithTexture(e):this._buildRenderTarget(o,r)}catch(p){console.warn("Failed to create RenderTarget:",p);return}if(!n&&e){const p=a.getColorTexture(0);p&&(p.filterMode=e.filterMode,p.wrapModeU=e.wrapModeU,p.wrapModeV=e.wrapModeV,p.anisoLevel=e.anisoLevel)}const c=this._replaceCameraRenderTarget(t,a);if(t.destroy(),await this.bindEngineObject(a),n||(e==null||e.destroy(),this._destroySubAssets(),await this._generateSubAssets()),c.length>0){const p=c.map(d=>d.enabled);c.forEach(d=>d.enabled=!0),requestAnimationFrame(()=>{this._onRebuildCallbacks.forEach(d=>d()),c.forEach((d,T)=>d.enabled=p[T])})}else this._onRebuildCallbacks.forEach(p=>p())}_buildRenderTarget(t=!0,e){const{width:i,height:o,colorFormat:r}=this;e===void 0&&(e=r===l.R8G8B8A8);const n=new v(this.engine,i,o,r,t,e);return n.isGCIgnored=!0,this._buildRenderTargetWithTexture(n)}_buildRenderTargetWithTexture(t){const{width:e,height:i,depthFormat:o,antiAliasing:r,autoGenerateMipmaps:n}=this,a=o===w?null:o,c=new S(this.engine,e,i,t,a,r);return c.isGCIgnored=!0,c.autoGenerateMipmaps=n,c}_destroyRenderTarget(){var e;const t=this.engineObject;t&&((e=t.getColorTexture(0))==null||e.destroy(),t.destroy())}_replaceCameraRenderTarget(t,e){const i=this.root.projectStore.currentScene;if(!i)return[];const o=[];for(const r of i.entities.values())for(const n of r.components)if(n.type==="Camera"){const a=n.engineObject;(a==null?void 0:a.renderTarget)===t&&(a.renderTarget=e,o.push(a))}return o}async _generateSubAssets(){const t=this.engineObject,e=[],i=t.getColorTexture(0);if(i){i.name=`${this.name}-color`;const o=await this.root.assetStore.createSubAsset("Texture",i,this.id,"colorTextures[0]");o._editable=!0,e.push(o)}this._subAssets=e}_destroySubAssets(){if(this._subAssets){for(const t of this._subAssets)this.root.assetStore.deleteSubAsset(t.id);this._subAssets=[]}}};g([b({type:m.Number,label:"Width",min:1,max:8192,triggerAfterInit:!1,onChange:s=>{s.width=Math.round(s.width),s._rebuild()}}),f()],u.prototype,"width",2);g([b({type:m.Number,label:"Height",min:1,max:8192,triggerAfterInit:!1,onChange:s=>{s.height=Math.round(s.height),s._rebuild()}}),f()],u.prototype,"height",2);g([b({type:m.Select,label:"Color Format",options:I,triggerAfterInit:!1,onChange:s=>s._rebuild()}),f()],u.prototype,"colorFormat",2);g([b({type:m.Select,label:"Depth Format",options:L,triggerAfterInit:!1,onChange:s=>s._rebuild()}),f()],u.prototype,"depthFormat",2);g([b({type:m.Select,label:"Anti-Aliasing",options:U,triggerAfterInit:!1,onChange:s=>s._rebuild()}),f()],u.prototype,"antiAliasing",2);g([b({type:m.Toggle,label:"Auto Generate Mipmaps",triggerAfterInit:!1,onChange:s=>{const t=s.engineObject;t&&(t.autoGenerateMipmaps=s.autoGenerateMipmaps)}}),f()],u.prototype,"autoGenerateMipmaps",2);u=g([O({type:"RenderTarget",label:G("asset.render-target.title"),extname:"renderTarget",importMenuConfig:{type:D.Add},dragLayer:F.RenderTarget,viewer:j,thumbnail:A,async bundle({content:s}){return{content:s}}})],u);export{u as RenderTargetAsset};
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var p=(s,e,t)=>e in s?l(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>(p(s,typeof e!="symbol"?e+"":e,t),t);import{j as m,o as h,b3 as d,e as u}from"./index-0a8702e2.js";import{a as y,A as f}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";const D={entities:[{id:"1000000",name:"Camera",isActive:!0,position:{x:0,y:0,z:10},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},children:[],isClone:!1,components:[{id:"1000100",class:"Camera",props:{isOrthographic:!1,nearClipPlane:.1,farClipPlane:100,viewport:{x:0,y:0,z:1,w:1}},methods:{}}]},{id:"1000001",name:"DirectLight",isActive:!0,position:{x:0,y:3,z:0},rotation:{x:-45,y:-45,z:0},scale:{x:1,y:1,z:1},children:[],isClone:!1,components:[{id:"1000101",class:"DirectLight",props:{enabled:!0,intensity:.6,color:{r:1,g:1,b:1,a:1}},methods:{}}]}],scene:{background:{mode:0,color:{r:.0157,g:.0157,b:.0157,a:1}},ambient:{},shadow:{},fog:{}}};var v=Object.defineProperty,b=Object.getOwnPropertyDescriptor,S=(s,e,t,n)=>{for(var a=n>1?void 0:n?b(e,t):e,i=s.length-1,r;i>=0;i--)(r=s[i])&&(a=(n?r(e,t,a):r(a))||a);return n&&a&&v(e,t,a),a};let c=class extends m{constructor(e){super(e);o(this,"sceneData",null);h(this)}async initByMain(e,t){this.sceneData=JSON.parse(await e.text())}getMainData(){return JSON.stringify(this.sceneData)}async rename(e){await super.rename(e),await this.root.assetFacade.persistAssetMain(this.id)}saveMainImmediately(){const e=this.root.sceneStore;if(this.id===e.refId){if(e.destroyed){d(this.root.projectStore.id,this.serverId);return}return this.sceneData=e.toJSON(),this.sceneData.name=this.name,super.saveMainImmediately()}else{const t=this.sceneData;if(t&&t.name!==this.name)return t.name=this.name,super.saveMainImmediately()}}async initByCreation(e,t,n){return this.sceneData={name:this._name,...D}}onDoubleClick(){this.root.projectStore.switchScene({scene:this.id})}};c=S([y({type:"Scene",label:u("asset.scene.title"),defaultName:"Scene",extname:"scene",importMenuConfig:{type:f.Add},async bundle(s){return{content:new Blob([s.content],{type:"application/json"})}}})],c);export{c as SceneAsset};
@@ -1,5 +0,0 @@
1
- var C=Object.defineProperty;var j=(s,e,t)=>e in s?C(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var m=(s,e,t)=>(j(s,typeof e!="symbol"?e+"":e,t),t);import{L as D}from"./module-107b7430.js";import{aH as R,aT as w,aJ as x,aD as h,bz as F,n as A,j as v,b0 as O,u as P,m as M,e as b,c9 as $,o as E,ca as d,bl as B,bm as L,p as k,C as U}from"./index-0a8702e2.js";import{u as z,a as _,A as H}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{F as S}from"./index-98982ce2.js";import{F as J}from"./FormItemArray-66be8701.js";import{s as N}from"./SpineSkeletonDataAsset-b64a3ee3.js";const V=R("div",{marginTop:"20px",fontSize:"12px",fontWeight:500,color:"$gray12"}),W=w(function(s){const{asset:{textures:e,textureAtlas:t,missingTexture:r}}=s,{assetStore:o}=z(),[l,a]=x.useState([]),u=x.useMemo(()=>{if(!t)return[];const n=t.pages,i=[];for(let p=0;p<n.length;p+=1){const c=n[p];i.push({name:c.name,regions:c.regions.map(T=>T.name)})}return i},[t]);return x.useEffect(()=>{let n=!1;return Promise.all(e.map(i=>o.getAssetByRef(i))).then(i=>{n||a(i)}).catch(i=>{n||(console.warn("[SpineAtlasInspector] Failed to load atlas textures:",i),a([]))}),()=>{n=!0}},[o,e]),r?h.jsx(V,{children:"Missing atlas texture, please reupload atlas and image files."}):h.jsxs(h.Fragment,{children:[h.jsx(S,{label:"atlas textures",value:""}),l.map((n,i)=>h.jsx(F,{dropLayer:A.Texture,label:"",value:n.name,assets:[],asset:n,onLocate:()=>{var c;const p=(c=e==null?void 0:e[i])==null?void 0:c.refId;p&&o.selectAsset(p)}},n.id)),h.jsx(S,{label:"atlas regions",value:""}),h.jsx(J,{label:"",items:u.map((n,i)=>({removable:!1,children:n.regions.map(c=>h.jsx(S,{label:"",value:c},c)),id:`${i}`,name:n.name}))})]})});var q=Object.defineProperty,G=Object.getOwnPropertyDescriptor,g=(s,e,t,r)=>{for(var o=r>1?void 0:r?G(e,t):e,l=s.length-1,a;l>=0;l--)(a=s[l])&&(o=(r?a(e,t,o):a(o))||o);return r&&o&&q(e,t,o),o};let f=class extends v{constructor(e){super(e);m(this,"_textureAtlas");m(this,"textures",[]);m(this,"atlasText","");m(this,"missingTexture",!1)}get textureAtlas(){return this._textureAtlas}async initByMain(e){this.atlasText=await e.text();const t=this.meta,{textures:r}=t;this.textures=r;const l=(await Promise.all(this.textures.map(n=>this.root.assetStore.getAssetByRef(n)))).map(n=>n==null?void 0:n.engineObject),a=l.some(n=>n==null)||r.length===0;if(this.missingTexture=a,a)return;const u=D.createTextureAtlas(this.atlasText,l);this._textureAtlas=u}};g([O(),P],f.prototype,"textures",2);g([M()],f.prototype,"atlasText",2);g([P],f.prototype,"missingTexture",2);f=g([_({type:"SpineAtlas",label:b("asset.spine-atlas.title"),dragLayer:A.SpineAtlas,customInspector:W,loaderType:"SpineAtlas",preUpload:N,bundle(s){return s.dependencies=$(s.meta,["textures"]),{content:s.content}}})],f);function Q(s){return`// ${s}
2
- float function() {
3
- return 3.1415926;
4
- }
5
- `}var X=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,I=(s,e,t,r)=>{for(var o=r>1?void 0:r?Y(e,t):e,l=s.length-1,a;l>=0;l--)(a=s[l])&&(o=(r?a(e,t,o):a(o))||o);return r&&o&&X(e,t,o),o};function Z(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}let y=class extends v{constructor(e){super(e);m(this,"_shaderSource");E(this)}get includePath(){const e=this.getTempRoutes();return e.push(this._name),e.join("/")}initByCreation(e,t,r){return this._shaderSource=Q(this.name),Promise.resolve(this.getMainData())}getMainData(){return this._shaderSource}async initByMain(e,t){const r=await e.text();this.updateCode(r)}async rename(e){const t=this.includePath;d.unRegisterInclude(t),await super.rename(e),d.registerInclude(this.includePath,this._shaderSource),this.refreshIncludedShaders(t)}async moveTo(e){const t=this.includePath;d.unRegisterInclude(t),await this.moveViaFacade(e),d.registerInclude(this.includePath,this._shaderSource),this.refreshIncludedShaders(t)}updateCode(e,t){const r=this.includePath;d.unRegisterInclude(r),d.registerInclude(r,e),this._shaderSource=e,this.refreshIncludedShaders(void 0,t)}beforeDelete(){this.path&&d.unRegisterInclude(this.path),this.refreshIncludedShaders()}refreshIncludedShaders(e,t=new Set){if(t.has(this.id))return;t.add(this.id);let r;if(e){const a=e.split("/");r=a[a.length-1]}else r=this._name;const o=new RegExp(`#include\\s+"[^"]*${Z(r)}"`),l=Object.values(this.root.assetStore.assets).filter(a=>{if(a.meta.type!=="Shader"&&a.meta.type!=="ShaderChunk")return!1;const u=this.getAssetSource(a);return o.test(u)});for(const a of l){if(t.has(a.id))continue;if(a.meta.type==="ShaderChunk"){const n=a,i=n.getMainData();n.updateCode(typeof i=="string"?i:"",t);continue}const u=a;u.updateCode(u.shaderSource)}}getAssetSource(e){if(e.meta.type==="Shader")return e.shaderSource;if(e.meta.type==="ShaderChunk"){const t=e.getMainData();return typeof t=="string"?t:""}return""}onDoubleClick(){B(this.root.projectStore.id,this.id),L()}};I([k({type:U.Input,label:b("shader.chunk.include-path"),disabled:!0})],y.prototype,"includePath",1);y=I([_({type:"ShaderChunk",label:b("shader.chunk.title"),defaultName:"ShaderChunk.glsl",icon:"shader",extname:"glsl",importMenuConfig:{type:H.Add},bundle({content:s}){return{content:new Blob([s],{type:"text/plain; charset=utf-8"})}}})],y);export{f as S,y as a};
@@ -1 +0,0 @@
1
- var y=Object.defineProperty;var j=(t,e,r)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>(j(t,typeof e!="symbol"?e+"":e,r),r);import{aT as m,b9 as v,aU as b,aD as s,aE as S,aG as d,aH as f,aK as g,aJ as u,aY as k,aV as B,f as F,p as h,C as O,s as R}from"./index-0a8702e2.js";import{u as E}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as I}from"./Component-f923abb1.js";import{c as M}from"./createOnModelChange-b57a0da8.js";import{M as _}from"./MaterialInspector-aec1248b.js";import{M as z}from"./MeshRendererBaseComponent-3a0e09ed.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";import"./IconPointFilled-a304fd34.js";const x=m(v),P=m(({model:t,inspectorConfig:e,onModelChange:r})=>{const{disabled:n,property:o}=e,{t:i}=b();return s.jsxs(s.Fragment,{children:[s.jsx(S,{label:i(e.label),info:i(e.info),fieldCss:{minHeight:"$5"},children:s.jsx(d,{size:"sm",selectable:!0,code:!0,children:null})}),s.jsx(x,{label:" ",disabled:n,value:t[o].min,onChange:a=>{r==null||r(o,{...t[o],min:a})},formEndSlot:s.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.min.label")})}),s.jsx(x,{label:" ",disabled:n,value:t[o].max,onChange:a=>{r==null||r(o,{...t[o],max:a})},formEndSlot:s.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.max.label")})})]})}),T=f("div",{marginLeft:"5px"}),C=f(g,{border:"1px solid $gray6",borderRadius:"$2",padding:"$0_5",color:"$gray11",cursor:"pointer"}),$=m(function(t){const e=t.data,{t:r}=b();return s.jsxs(C,{align:"v",children:[s.jsx("img",{src:e.thumbnailUrl,alt:"Material Thumbnail",width:"20px",height:"20px"}),s.jsxs(T,{children:[r("skinned-mesh-renderer.material.label"),"(",e.name,")"]})]})}),H=m(function(t){const[e,r]=u.useState(null),n=t.data,{assetStore:o,inspectorFacade:i}=E();return u.useEffect(()=>{o.getAssetByRef(n.material).then(a=>{r(a)})},[n.material]),s.jsxs(s.Fragment,{children:[s.jsx(k.List,{model:n,configs:n.formSchema.items,onModelChange:M("component",n.id,i,n)}),e&&s.jsx(B,{nesting:!0,title:s.jsx($,{data:e}),open:n.materialOpen,onOpenChange:a=>{n.setMaterialOpen(a)},children:s.jsx(_,{asset:e})})]})});var V=Object.defineProperty,w=Object.getOwnPropertyDescriptor,p=(t,e,r,n)=>{for(var o=n>1?void 0:n?w(e,r):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=(n?a(e,r,o):a(o))||o);return n&&o&&V(e,r,o),o};let l=class extends z{constructor(e,r){super(e,r);c(this,"rootBone",null);c(this,"localBounds",{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}})}};p([F({getEngineValue:t=>{var e;return(e=t.skin)==null?void 0:e.rootBone}}),h({label:"skinned-mesh-renderer.skin.root-bone.label",info:"skinned-mesh-renderer.skin.root-bone.info",type:O.EntityPicker,disabled:!0})],l.prototype,"rootBone",2);p([h({label:"skinned-mesh-renderer.local-bounds.title",info:"skinned-mesh-renderer.local-bounds.info",customComponent:P,type:"BoundingBox"}),R()],l.prototype,"localBounds",2);l=p([I({type:"SkinnedMeshRenderer",customInspector:H,componentsMenu:{label:"component.renderer.skinned-mesh.title"}})],l);export{l as SkinnedMeshRendererComponent};
@@ -1 +0,0 @@
1
- var F=Object.defineProperty;var S=(e,i,n)=>i in e?F(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n;var a=(e,i,n)=>(S(e,typeof i!="symbol"?i+"":i,n),n);import{S as v,a as B}from"./module-107b7430.js";import{aT as h,b8 as b,e as y,E as N,u as g,p as l,C as f,s as m}from"./index-0a8702e2.js";import{u as k}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as O}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";const P=h(function(e){const{model:i}=e,{inspectorFacade:n}=k();return b({label:y("spine.animation.label"),value:i.animationName,options:i.animationForm,onChange(t){n.componentChange(i.id,"animationName",t)}})}),T=h(function(e){const{model:i}=e,{inspectorFacade:n}=k();return b({label:y("spine.skin.label"),value:i.skinName,options:i.skinForm,onChange(t){n.componentChange(i.id,"skinName",t)}})});var _=Object.defineProperty,j=Object.getOwnPropertyDescriptor,p=(e,i,n,t)=>{for(var o=t>1?void 0:t?j(i,n):i,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(t?u(i,n,o):u(o))||o);return t&&o&&_(i,n,o),o};let s=class extends N{constructor(i,n){super(i,n);a(this,"animationForm",[]);a(this,"skinForm",[]);a(this,"hasInit",!1);a(this,"resource",null);a(this,"loop",!1);a(this,"animationName","none");a(this,"skinName","default");a(this,"priority",0);a(this,"premultipliedAlpha",!1);a(this,"tintBlack",!1)}deserialize(i){const{props:n}=i;if(this._enabled=(n==null?void 0:n.enabled)??!0,n){this.priority=n.priority,this.resource=n.resource,this.premultipliedAlpha=n.premultipliedAlpha,this.tintBlack=n.tintBlack??!1;const{animationName:t,skinName:o,loop:c}=n.defaultConfig;this.animationName=t||"none",this.skinName=o,this.loop=c}super.deserialize(i)}toJSON(){const i=this.animationName==="none"?null:this.animationName;return{id:this.id,class:this.type,props:{enabled:this.enabled,priority:this.priority,resource:this.resource,premultipliedAlpha:this.premultipliedAlpha,tintBlack:this.tintBlack,defaultConfig:{animationName:i,skinName:this.skinName,loop:this.loop}}}}};p([g],s.prototype,"animationForm",2);p([g],s.prototype,"skinForm",2);p([l({label:"spine.resource.label",info:"spine.resource.info",type:f.AssetPicker,assetType:"SpineSkeletonData",onChange:async(e,i,n)=>{const t=e.engineObject;if(n){t.enabled=!0;const{skeletonData:o}=n;if(!o)return;const u=o.animations.map(r=>r.name).map(r=>({label:r,value:r}));u.unshift({label:"none",value:"none"}),e.animationForm=u,e.skinForm=o.skins.map(r=>({label:r.name,value:r.name})),e.hasInit?(e.animationName="none",e.skinName="default"):e.hasInit=!0;const{loop:d,skinName:C}=e,A=e.animationName==="none"?null:e.animationName;t.defaultConfig.animationName=A,t.defaultConfig.skinName=C,t.defaultConfig.loop=d,t.resource=new v(t.engine,o)}else t.enabled=!1,e.animationName="none",e.animationForm.length=0,e.skinForm.length=0,e.premultipliedAlpha=!1,e.tintBlack=!1}}),m()],s.prototype,"resource",2);p([l({label:"spine.loop.label",info:"spine.loop.info",type:f.Toggle,onChange(e,i,n){const{state:t}=e.engineObject;if(t){const o=t.getCurrent(0);o&&(o.loop=n)}}}),m()],s.prototype,"loop",2);p([l({info:"spine.animation.info",customComponent:P,onChange(e,i,n){const{state:t}=e.engineObject;t&&(n==="none"?t.setEmptyAnimation(0,0):t.setAnimation(0,n,e.loop))}}),m()],s.prototype,"animationName",2);p([l({info:"spine.skin.info",customComponent:T,onChange(e,i,n){const{engineObject:{skeleton:t}}=e;t&&n&&(t.setSkinByName(n),t.setSlotsToSetupPose())}}),m()],s.prototype,"skinName",2);p([l({label:"spine.priority.label",info:"spine.priority.info",type:f.Number,bindPath:"priority"}),m()],s.prototype,"priority",2);p([l({label:"spine.premultiplied-alpha.label",info:"spine.premultiplied-alpha.info",type:f.Toggle,bindPath:"premultipliedAlpha"}),m()],s.prototype,"premultipliedAlpha",2);p([l({label:"spine.tint-black.label",info:"spine.tint-black.info",type:f.Toggle,bindPath:"tintBlack"}),m()],s.prototype,"tintBlack",2);s=p([O({type:"SpineAnimationRenderer",componentsMenu:{group:"2D",label:"component.spine-animation.title"}})],s);N.registerCustomEngineComponent("SpineAnimationRenderer",B);export{s as SpineAnimationComponent};
@@ -1 +0,0 @@
1
- var E=Object.defineProperty;var I=(t,s,e)=>s in t?E(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var c=(t,s,e)=>(I(t,typeof s!="symbol"?s+"":s,e),e);import{e as w,aH as j,o as B,S as $,aT as U,aJ as P,aD as A,u as g,J as k,b5 as z,b6 as q,j as V,_ as J,cb as M,p as K,C as L,b0 as W,m as X,n as Y,c9 as H}from"./index-0a8702e2.js";import{b as G,c as Q,T as Z,d as ee,R as te,M as ne,B as se,P as ie,e as ae,C as oe,f as re,a as C,S as T,L as le}from"./module-107b7430.js";import{a as pe,A as ce}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import{A as ue}from"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as me}from"./AssetViewer-bc198e16.js";import{n as he}from"./index-be6bc38a.js";const x=new Map;function de(t){return t??""}function fe(t){return`${t.name}|${t.size}|${t.lastModified}|${t.type}`}function ge(t,s){const{uploadAssetFile:e,assetType:n,parentFolderId:i,assetMeta:a}=s,o=i??t.currentFolderId??"",r=e.main,u=fe(r),l=de(a);return`${o}|${n}|${u}|${l}`}function v(t,s){const e=ge(t,s),n=x.get(e);if(n)return n;const i=t.createAssetByUpload(s).finally(()=>{x.get(e)===i&&x.delete(e)});return x.set(e,i),i}var N=(t=>(t.region="region",t.boundingbox="boundingbox",t.mesh="mesh",t.linkedmesh="linkedmesh",t.path="path",t.point="point",t.clipping="clipping",t.sequence="sequence",t))(N||{});const ye=["region","linkedmesh","mesh"];async function Ae(t,s){const e={uploadFiles:[],usedFiles:[],errors:[]},{atlasRawFiles:n,atlasFound:i}=await we(t,e),a=await Promise.all(n.map(l=>v(s.root.assetFacade,{uploadAssetFile:l,assetType:"SpineAtlas"})));e.usedFiles.push(...n.flatMap(l=>[l.main,...Object.values(l.subFiles)]));const o=await ke(t,e);o.length>0&&!i&&e.errors.push(w("spine.error.no-atlas-file"));const r=o.map(l=>(e.usedFiles.push(l.spineFile),Se(l,a,e)));let u=await Promise.all(r);return u=u.filter(l=>l!==null),e.uploadFiles.push(...u),e}async function we(t,s){const e=[];let n=!1;for(const i in t){const a=t[i];if(a.name.endsWith(".atlas")){n=!0;const r=await be(t,a);if(r.length>0){const u={};r.forEach(l=>u[l.name]=l),e.push({main:a,subFiles:u})}else s.errors.push(w("spine.error.missing-images"))}}return{atlasRawFiles:e,atlasFound:n}}async function ke(t,s){const e=[];for(const n in t){const i=t[n],a=i.name,o=a.split(".")[0];if(a.endsWith(".json"))try{const r=await i.text(),u=JSON.parse(r);u.skeleton&&u.skeleton.spine&&e.push({spineFile:i,spineName:o,isBinary:!1})}catch(r){s.errors.push(b(a,r))}else a.endsWith(".skel")&&e.push({spineFile:i,spineName:o,isBinary:!0})}return e}async function Se(t,s,e){const{spineFile:n}=t,i={type:"SpineSkeletonData",atlas:{refId:null}},a={main:n,meta:null};let o;try{o=await xe(t,s,e)}catch(r){return e.errors.push(r instanceof Error?r.message:b(n.name,r)),null}return s.length===0?null:o?(i.atlas.refId=o.id,a.meta=JSON.stringify(i),a):(e.errors.push(w("spine.error.missing-attachments")),null)}async function xe(t,s,e){const n=await De(t);return await Fe(s,n)}async function De(t){const{spineFile:s,isBinary:e}=t,n=new Set;if(e){const r=await s.arrayBuffer();return _e(r,n),Array.from(n)}const i=await s.text();let a;try{a=JSON.parse(i)}catch(r){throw new Error(b(s.name,r))}return!a||!a.skins?[]:(a.skins.forEach(r=>{if(r.attachments)for(const u in r.attachments){const l=r.attachments[u];for(const y in l){const p=l[y];if(p.type){let h;const f=p.type;try{h=N[f]}catch(F){throw console.warn(w("spine.error.incompatible-version",f)),F}if(!ye.includes(h))continue}if(p.path)n.add(p.path);else if(p.name)n.add(p.name);else if(p.sequence){const h=new G(null).readSequence(p.sequence);if(h)for(let f=0;f<h.regions.length;++f)n.add(h.getPath(y,f));else n.add(y)}else n.add(y)}}}),Array.from(n))}function _e(t,s){new Q(new D(s)).readSkeletonData(new Uint8Array(t))}class D{constructor(s){c(this,"requiredPaths");this.requiredPaths=s}static assignDummyRegion(s){s.region=new Z(new ee("dummy"),"")}newRegionAttachment(s,e,n,i){const a=new te(e,"");return i?this.loadSequence(n,i):(this.requiredPaths.add(n),D.assignDummyRegion(a)),a}newMeshAttachment(s,e,n,i){const a=new ne(e,"");return i?this.loadSequence(n,i):(this.requiredPaths.add(n),D.assignDummyRegion(a)),a}newBoundingBoxAttachment(s,e){return new se(e)}newPathAttachment(s,e){return new ie(e)}newPointAttachment(s,e){return new ae(e)}newClippingAttachment(s,e){return new oe(e)}loadSequence(s,e){const n=e.regions;for(let i=0,a=n.length;i<a;i++){const o=e.getPath(s,i);this.requiredPaths.add(o)}}}async function Fe(t,s){for(let e=0;e<t.length;e+=1){const n=t[e];if(Re(n.textureAtlas,s))return n}return null}async function Re(t,s){for(let e=0;e<s.length;e+=1){const n=s[e];if(!Te(t,n))return!1}return!0}function b(t,s){const e=s instanceof Error?s.message:String(s);return`Failed to parse spine JSON "${t}": ${e}`}function Te(t,s){const e=t.findRegion(s);if(e)return e;const n=s.length;for(const i of t.regions){const a=i.name;if(a.startsWith(s)&&a.substring(n).split("").every(r=>r>="0"&&r<="9"))return i}return null}async function be(t,s){const e=await s.text(),n=new re(e),i=[];return n.pages.forEach(a=>{const o=a.name,r=t[o];if(r)i.push(r);else return null}),i}async function Le(t,s,e){const n=t.main,i=await Pe(t,e);return{main:n,meta:JSON.stringify({textures:i,type:"SpineAtlas"})}}async function Pe(t,s){const e=[];for(const p in t.subFiles){const h=t.subFiles[p];h.name.endsWith(".atlas")||e.push({main:h,type:"Texture"})}const n=[];let i=[],a;const o=s.getAssetFromCurrentFolder();(o==null?void 0:o.length)>0&&(a=o.filter(p=>p.meta.type==="Texture")),a?e.forEach(p=>{const h=a.find(f=>f.name===p.main.name);h?n.push(h.getCurrentRef()):i.push(p)}):i=e;const r=[];i.forEach(p=>{r.push(v(s.root.assetFacade,{uploadAssetFile:p,assetType:"Texture"}))});const l=(await Promise.all(r)).map(p=>p.getCurrentRef());return n.concat(l)}var Ce=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,d=(t,s,e,n)=>{for(var i=n>1?void 0:n?ve(s,e):s,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(s,e,i):o(i))||i);return n&&i&&Ce(s,e,i),i};const Ne=j("div",{position:"absolute",top:8,left:8,display:"grid",gap:"$1",marginTop:"$1 $2",variants:{hasClips:{true:{gridTemplateColumns:"150px 18px 1fr"},false:{gridTemplateColumns:"$4_5 1fr"}}}});class m extends me{constructor(){super();c(this,"_spineAnimationRenderer");c(this,"_animationTrack");c(this,"_updateComponent");c(this,"playing",!1);c(this,"frameTime",0);c(this,"duration",0);c(this,"animationNames",[]);c(this,"skinNames",[]);c(this,"animationIndex",0);c(this,"skinIndex",0);c(this,"_size",{w:0,h:0});c(this,"overridePreviewer",U(({asset:e,viewer:n})=>{const i=e.getViewerRootEntity();return P.useEffect(()=>{this.skinIndex=0},[e]),P.useEffect(()=>{this._spineAnimationRenderer?this.updateViewAsset(e,i):this.setViewAsset(e,i)},[e.skeletonData]),A.jsxs(A.Fragment,{children:[A.jsx(ue,{asset:e,viewer:n}),A.jsx(Oe,{selectedKey:this.skinIndex,clips:this.skinNames,onSelectClip:a=>{this.skinIndex=a,this.changeSkin(this.skinNames[a])}})]})}));B(this)}setViewAsset(e,n){if(!e.skeletonData){this.stopViewAsset();return}this.animationIndex=0,this.duration=0;const i=n.engine,a=e.skeletonData,o=n.createChild("spine-entity"),r=o.addComponent(C);this.animationNames=a.animations.map(R=>R.name),this.animationNames.unshift("none"),this.skinNames=a.skins.map(R=>R.name),this._entity=o,this._spineAnimationRenderer=r,r.resource=new T(i,a);const{width:u,height:l,x:y,y:p}=a;this._size={w:u,h:l};const h=y+u/2,f=p+l/2;o.transform.setPosition(-h/100,-f/100,0);const F=this;this._updateComponent=this._entity.addComponent(class extends ${onUpdate(){F._onUpdate()}})}updateViewAsset(e,n){if(!e.skeletonData){this.stopViewAsset();return}const i=n.engine,a=e.skeletonData;this.animationNames=a.animations.map(o=>o.name),this.animationNames.unshift("none"),this.skinNames=a.skins.map(o=>o.name),this._spineAnimationRenderer.resource=new T(i,a)}getSize(){return{width:this._size.w/100,height:this._size.h/100}}stopViewAsset(){var e;super.stopViewAsset(),this.playing=!1,this.frameTime=0,this.duration=0,this.animationNames=[],this.skinNames=[],this.animationIndex=0,this.skinIndex=0,this._spineAnimationRenderer&&(this._spineAnimationRenderer.enabled=!1),this._spineAnimationRenderer=null,(e=this._updateComponent)==null||e.destroy()}changeSkin(e){const{skeleton:n,state:i}=this._spineAnimationRenderer;n.setSkinByName(e),n.setSlotsToSetupPose(),i.apply(n)}selectAnimation(e){this.animationIndex=e;const n=this.animationNames[e];this.play(n)}play(e){let n;const{state:i}=this._spineAnimationRenderer;e==="none"?n=i.setEmptyAnimation(0,0):n=i.setAnimation(0,e,!0),this._animationTrack=n,this._spineAnimationRenderer.state.timeScale=1,this.playing=!0,this.duration=n.animationEnd}pauseAnimation(){this.pause()}playAnimation(){this._spineAnimationRenderer.state.timeScale=1}pause(){this._spineAnimationRenderer.state.timeScale=0,this.playing=!1}_onUpdate(){if(!this.playing)return;const e=this._animationTrack.trackTime%this.duration;this.frameTime=isNaN(e)?0:e}}d([g],m.prototype,"playing",2);d([g],m.prototype,"frameTime",2);d([g],m.prototype,"duration",2);d([g],m.prototype,"animationNames",2);d([g],m.prototype,"skinNames",2);d([g],m.prototype,"animationIndex",2);d([g],m.prototype,"skinIndex",2);d([k],m.prototype,"changeSkin",1);d([k],m.prototype,"selectAnimation",1);d([k],m.prototype,"play",1);d([k],m.prototype,"pauseAnimation",1);d([k],m.prototype,"playAnimation",1);d([k],m.prototype,"pause",1);d([k],m.prototype,"_onUpdate",1);function Oe({onSelectClip:t,clips:s,selectedKey:e}){return A.jsx(Ne,{hasClips:!!s.length,children:s.length>0&&A.jsx(z,{value:e,onValueChange:t,valueType:"number",size:"xs",sideOffset:8,children:s.map((n,i)=>n?A.jsx(q,{value:i,children:n},i):null)})})}var Ee=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,_=(t,s,e,n)=>{for(var i=n>1?void 0:n?Ie(s,e):s,a=t.length-1,o;a>=0;a--)(o=t[a])&&(i=(n?o(s,e,i):o(i))||i);return n&&i&&Ee(s,e,i),i};let S=class extends V{constructor(s){super(s);c(this,"_delOnSkeletonDel");c(this,"_delOnAtlasDel");c(this,"_hasInit",!1);c(this,"atlas",null);c(this,"skeletonRawData","");c(this,"skeletonData")}async initByMain(s){const e=await s.text();try{JSON.parse(e),this.skeletonRawData=e}catch{this.skeletonRawData=await s.arrayBuffer()}const n=this.meta,{atlas:i}=n;this.atlas=i;const a=await this.root.assetStore.getAssetByRef(i),o=O(this.skeletonRawData,a,!0);o&&this.createDragTempEntity(o)}createDragTempEntity(s){this.skeletonData=s;const e=new J(this.engine),n=e.addComponent(C);n.resource=new T(this.engine,this.skeletonData),this.setDragTempEntity(e)}instantiate(){if(!this.skeletonData)return;const s=this.root.sceneStore.createEntity(),e=this.getDragTempEntity(),{position:n,rotation:i}=e.transform,a={components:[{class:"SpineAnimationRenderer",id:M(),props:{resource:this.getCurrentRef(),priority:0,defaultConfig:{loop:!1,animationName:"none",skinName:"default"}}}],id:s.id,isActive:!0,isClone:!1,name:this.name?this.name:"spine",position:{x:n.x,y:n.y,z:n.z},rotation:{x:i.x,y:i.y,z:i.z},scale:{x:1,y:1,z:1}};return s.initByFile(a),s}};_([K({assetType:"SpineAtlas",label:w("asset.spine-atlas.title"),type:L.AssetPicker,onChange:async(t,s,e)=>{if(t._delOnAtlasDel&&(t._delOnAtlasDel(),t._delOnAtlasDel=null),e){let n=!0;t._hasInit?n=!1:t._hasInit=!0,t.skeletonData=O(t.skeletonRawData,e,n),t.skeletonData&&t.createDragTempEntity(t.skeletonData);const i=()=>{t._delOnSkeletonDel&&t._delOnSkeletonDel(),t._delOnSkeletonDel=null,t.skeletonData=null};e.on("delete",i),t._delOnSkeletonDel=()=>{e.off("delete",i)}}else t.skeletonData=null}}),W()],S.prototype,"atlas",2);_([X()],S.prototype,"skeletonRawData",2);_([g.ref],S.prototype,"skeletonData",2);S=_([pe({type:"SpineSkeletonData",label:w("asset.spine-skeleton-data.title"),loaderType:"Spine",viewer:m,dragLayer:Y.SpineSkeletonData,dragType:"2d",filterUploadFiles:Ae,importMenuConfig:{type:ce.Upload,accept:".json,.atlas,.skel,.png,.jpg,.jpeg,.webp",multiple:!0},bundle(t){return t.dependencies=H(t.meta,["atlas"]),{content:t.content}}})],S);function O(t,s,e){if(!s)return null;try{return le.createSkeletonData(t,s.textureAtlas,.01)}catch{return!e&&he.error(w("spine.error.generate-skeleton-data")),null}}const We=Object.freeze(Object.defineProperty({__proto__:null,get SpineSkeletonDataAsset(){return S}},Symbol.toStringTag,{value:"Module"}));export{S,We as a,Le as s};
@@ -1 +0,0 @@
1
- var f=Object.defineProperty;var c=(e,t,o)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var n=(e,t,o)=>(c(e,typeof t!="symbol"?t+"":t,o),o);import{s as m,aO as h,p as g,C as b,f as u}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as d}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{L as P}from"./LightBaseComponent-fbc3ae49.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var y=Object.defineProperty,v=Object.getOwnPropertyDescriptor,i=(e,t,o,a)=>{for(var p=a>1?void 0:a?v(t,o):t,l=e.length-1,s;l>=0;l--)(s=e[l])&&(p=(a?s(t,o,p):s(p))||p);return a&&p&&y(t,o,p),p};let r=class extends P{constructor(t,o){super(t,o);n(this,"angle",20);n(this,"distance",60);n(this,"penumbra",60)}};i([m(h()),g({type:b.Slider,min:1,max:179,bindPath:"angle",label:"light.spot.angle.label",info:"light.spot.angle.info"}),u({getPath:"angle",getEditorValue:e=>e*180/Math.PI})],r.prototype,"angle",2);i([m(),g({type:b.Number,bindPath:"distance",label:"light.spot.distance.label",info:"light.spot.distance.info"})],r.prototype,"distance",2);i([m(h()),g({type:b.Slider,min:1,max:179,bindPath:"penumbra",label:"light.spot.penumbra.label",info:"light.spot.penumbra.info"}),u({getPath:"penumbra",getEditorValue:e=>e*180/Math.PI})],r.prototype,"penumbra",2);r=i([d({type:"SpotLight",componentsMenu:{group:"light",label:"component.light.spot.title"}})],r);export{r as SpotLightComponent};
@@ -1 +0,0 @@
1
- var fe=Object.defineProperty;var pe=(r,e,t)=>e in r?fe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var p=(r,e,t)=>(pe(r,typeof e!="symbol"?e+"":e,t),t);import{aT as mt,aJ as v,aD as R,aY as zt,by as de,aK as tt,eZ as me,cX as we,$ as wt,a4 as ye,aH as it,aU as Yt,H as Rt,bu as xe,bw as ve,bv as be,bB as Re,x as Se,bA as Ie,cw as Ce,ew as Pe,aM as Te,e_ as _e,eR as Be,e as pt,bz as Qt,n as yt,aG as ke,aI as Fe,I as Zt,j as Me,e$ as Nt,a9 as Ee,_ as Oe,C as O,cb as Ae,aP as je,p as Q,m as Z,f as De,v as Le,J as ze,bV as Ne,cd as He,cc as Ht}from"./index-0a8702e2.js";import{u as $e,F as We,a as qe,A as $t}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{A as Ve}from"./AssetViewer-bc198e16.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Ue}from"./bundlers-9b0d37fc.js";import{b as Je,a as te}from"./TextureAsset-28fedf2a.js";function Ge(r,e){const t={};for(let i=0;i<r.length;i++){const n=r[i],a=e(n);Object.hasOwn(t,a)||(t[a]=[]),t[a].push(n)}return t}function Ke(r,e){const t=[],i=[];for(let n=0;n<r.length;n++){const a=r[n];e(a)?t.push(a):i.push(a)}return[t,i]}const Xe=mt(function(r){const[e,t]=v.useState(null),i=r.asset,{assetStore:n,inspectorFacade:a}=$e(),c=(s,o,g)=>{a.assetChange(s,o,g)};return v.useEffect(()=>{n.getAssetByRef(i.texture).then(s=>{t(s)})},[i.texture]),R.jsxs(R.Fragment,{children:[R.jsx(zt.List,{model:i,configs:i.formSchema.items,onModelChange:(s,o)=>c(i.id,s,o)}),e&&R.jsxs(R.Fragment,{children:[R.jsx(de,{}),R.jsx(tt,{justifyContent:"between",css:{padding:"$2 0"},children:R.jsx(me,{children:"Texture Option"})}),R.jsx(we,{label:"Name",value:e.name,readOnly:!0}),R.jsx(zt.List,{model:e,configs:e.formSchema.items,onModelChange:(s,o)=>c(e.id,s,o)})]})]})});class Ct{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.spriteRenderer.sprite=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("sprite");this.spriteRenderer=t.addComponent(wt)}}p(Ct,"entity"),p(Ct,"spriteRenderer");class Ye extends Ve{constructor(){super()}setViewAsset(e,t){const i=t.createChild("sprite_entity"),n=i.addComponent(wt);n.sprite=e.engineObject,this._entity=i}getDescription(e){var i;const t=(i=e.engineObject)==null?void 0:i.texture;if(t){const{width:n,height:a}=t;return`${n}x${a}`}else return""}}const J=1,Qe=220,Ze=180,St=ye._pixelsPerUnit??100,ti={left:"x",bottom:"y",right:"z",top:"w"},ei={left:{axis:"x",fromStart:!0},right:{axis:"x",fromStart:!1},top:{axis:"y",fromStart:!0},bottom:{axis:"y",fromStart:!1}},ii=[["left","right"],["top","bottom"]],ni={left:"width",right:"width",top:"height",bottom:"height"},ri={left:"right",right:"left",top:"bottom",bottom:"top"},si=it(tt,{width:"220px"}),ai=it("div",{position:"relative",width:"100%",height:"180px",borderRadius:"$2",border:"1px solid $gray6",overflow:"hidden",backgroundImage:"linear-gradient(45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.06) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.06) 75%)",backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px"}),oi=it("div",{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",border:"1px solid $gray9",background:"linear-gradient(135deg, rgba(76, 132, 255, 0.26) 0%, rgba(76, 132, 255, 0.08) 48%, rgba(76, 132, 255, 0.2) 100%)",boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.2)"}),ci=it("canvas",{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",pointerEvents:"none"}),li=it("div",{position:"absolute",borderRadius:"$1",backgroundColor:"rgba(126, 211, 129, 0.1)",pointerEvents:"none"}),Wt=it("div",{position:"absolute",top:0,bottom:0,width:"10px",marginLeft:"-5px",cursor:"ew-resize","&::before":{content:'""',position:"absolute",left:"50%",top:0,bottom:0,borderLeft:"1px dashed $blue9"}}),qt=it("div",{position:"absolute",left:0,right:0,height:"10px",marginTop:"-5px",cursor:"ns-resize","&::before":{content:'""',position:"absolute",top:"50%",left:0,right:0,borderTop:"1px dashed $blue9"}}),hi={flex:1,minWidth:0};function q(r,e,t){return Math.min(t,Math.max(e,r))}function Y(r,e=2){const t=Math.pow(10,e);return Math.round(r*t)/t}function et(r,e=0){return Number.isFinite(r)?r:e}function dt(r,e,t,i){return r=q(et(r),0,t),e=q(et(e),0,t),r+e>t&&(i?e=t-r:r=t-e),[r,e]}function ft(r,e){const[t,i]=dt(r.x,r.z,1,e==="x"),[n,a]=dt(r.y,r.w,1,e==="y");return{x:Y(t,2),y:Y(n,2),z:Y(i,2),w:Y(a,2)}}function Tt(r,e,t,i){const n=Math.max(J,Math.round(et(e,J))),a=Math.max(J,Math.round(et(t,J))),[c,s]=dt(r.left,r.right,n,i==="left"),[o,g]=dt(r.top,r.bottom,a,i==="top");return{left:Math.round(c),bottom:Math.round(g),right:Math.round(s),top:Math.round(o)}}function Vt(r,e,t){const i=ft(r);return Tt({left:i.x*e,bottom:i.y*t,right:i.z*e,top:i.w*t},e,t)}function ui(r,e,t){const i=Tt(r,e,t),n=Math.max(J,e),a=Math.max(J,t),c=Y(q(i.left/n,0,1),2),s=Y(q(i.bottom/a,0,1),2),o=Y(q(i.right/n,0,1-c),2),g=Y(q(i.top/a,0,1-s),2);return{x:c,y:s,z:o,w:g}}function gi(r,e,t,i){const a=Math.max(1,et(t,1)),c=Math.max(1,et(i,1)),s=Math.max(1,r-16*2),o=Math.max(1,e-16*2),g=Math.min(s,o),l=Math.max(a,c),f=g/l;return{width:Math.max(1,a*f),height:Math.max(1,c*f)}}function fi(r,e=!0){const[t,i]=v.useState({width:0,height:0});return v.useLayoutEffect(()=>{if(!e){i({width:0,height:0});return}const n=r.current;if(!n)return;const a=()=>{i({width:n.clientWidth,height:n.clientHeight})};a();const c=new ResizeObserver(a);return c.observe(n),()=>{c.disconnect()}},[r,e]),t}const pi=mt(function(e){var Mt,Et,Ot,At,jt,Dt;const{model:t,inspectorConfig:i,onModelChange:n}=e,{property:a,disabled:c,label:s,info:o}=i,{t:g}=Yt();if(!t||!a)return null;const l={width:t.engineObject.width*St,height:t.engineObject.height*St},f=ft(t[a]??{x:0,y:0,z:0,w:0}),u=Vt(f,l.width,l.height),d=v.useRef(null),m=v.useRef(null),b=v.useRef(null),S=v.useRef(null),w=v.useRef(null),P=v.useRef(null),M=v.useRef(!1),j=v.useRef(!1),$=v.useRef(!1),K=v.useRef(new Rt),E=v.useRef(new Rt),nt=v.useRef(new Rt),[X,rt]=v.useState(!1),[U,H]=v.useState(null),_=fi(d,X),k=v.useMemo(()=>({width:_.width>0?_.width:Qe,height:_.height>0?_.height:Ze}),[_.height,_.width]);$.current=X;const T=v.useMemo(()=>gi(k.width,k.height,l.width,l.height),[l.height,l.width,k.height,k.width]),F=v.useMemo(()=>({left:q(u.left/Math.max(l.width,J),0,1),bottom:q(u.bottom/Math.max(l.height,J),0,1),right:q(u.right/Math.max(l.width,J),0,1),top:q(u.top/Math.max(l.height,J),0,1)}),[u.bottom,u.left,u.right,u.top,l.height,l.width]),W=v.useCallback((h=!1)=>{if(P.current!==null&&(cancelAnimationFrame(P.current),P.current=null),M.current=!1,j.current=!1,!h)return;const y=w.current,x=S.current;if(x){const I=(y==null?void 0:y.canvasCtx)??x.getContext("2d");I==null||I.clearRect(0,0,x.width,x.height)}},[]),ct=v.useCallback(()=>{W();const h=w.current;if(h){if(h.renderTarget){const y=h.renderTarget.getColorTexture(0);y==null||y.destroy(!0),h.renderTarget.destroy(!0),h.renderTarget=null}try{t.engine.sceneManager.removeScene(h.scene)}catch{}h.scene.destroy(),w.current=null,W(!0)}},[t.engine,W]),_t=v.useCallback(()=>{const h=w.current,y=S.current;if(!h||!y)return!1;const x=window.devicePixelRatio||1,I=Math.round(T.width*x),C=Math.round(T.height*x);if(I<=0||C<=0)return!1;if((y.width!==I||y.height!==C)&&(y.width=I,y.height=C),h.renderTarget&&h.renderTarget.width===I&&h.renderTarget.height===C)return h.camera.aspectRatio=I/C,!0;if(h.renderTarget){const st=h.renderTarget.getColorTexture(0);st==null||st.destroy(!0),h.renderTarget.destroy(!0)}const N=new xe(t.engine,I,C,void 0,!1),G=new ve(t.engine,I,C,N,be.Depth,4),bt=new ImageData(new Uint8ClampedArray(I*C*4),I,C);return h.renderTarget=G,h.imageData=bt,h.camera.aspectRatio=I/C,h.camera.renderTarget=G,!0},[T.height,T.width,t.engine]),Bt=v.useCallback(()=>{const h=w.current;if(!h||!h.spriteRenderer.sprite)return;const y=h.spriteRenderer.bounds,x=K.current,I=E.current;y.getCenter(x),y.getExtent(I);const C=h.camera.aspectRatio>0?h.camera.aspectRatio:1,N=Math.max(I.x,l.width*.5,.5),G=Math.max(I.y,l.height*.5,.5);h.camera.isOrthographic=!0,h.camera.orthographicSize=Math.max(G,N/C)/St,h.camera.nearClipPlane=.1,h.camera.farClipPlane=100,h.cameraEntity.transform.setPosition(x.x,x.y,10),nt.current.set(x.x,x.y,0),h.cameraEntity.transform.lookAt(nt.current)},[l.height,l.width]),kt=v.useCallback(()=>{const h=w.current,y=S.current;if(!h||!h.renderTarget||!h.imageData||!y)return;const x=t.engine;if(j.current)return;j.current=!0;try{h.camera.renderTarget=h.renderTarget,x.sceneManager.addScene(h.scene),x.update()}finally{try{x.sceneManager.removeScene(h.scene)}catch{}j.current=!1}h.renderTarget.getColorTexture(0).getPixelBuffer(0,0,h.renderTarget.width,h.renderTarget.height,0,h.imageData.data);const C=h.canvasCtx??y.getContext("2d");C==null||C.putImageData(h.imageData,0,0)},[t.engine]),lt=v.useCallback(()=>{if(w.current)return;const h=S.current;if(!h)return;const y=new Re(t.engine);y.background.solidColor=new Se(0,0,0,0);const x=y.createRootEntity("sprite_border_preview_root"),I=x.createChild("sprite_border_preview_camera"),C=I.addComponent(Ie),G=x.createChild("sprite_border_preview_sprite").addComponent(wt);G.sprite=t.engineObject??null,w.current={scene:y,camera:C,cameraEntity:I,spriteRenderer:G,renderTarget:null,imageData:null,canvasCtx:h.getContext("2d")}},[t.engine,t.engineObject]),Ft=v.useCallback(()=>{M.current||(M.current=!0,P.current=requestAnimationFrame(()=>{if(M.current=!1,P.current=null,!$.current)return;w.current||lt();const h=w.current;h&&(h.spriteRenderer.sprite=t.engineObject??null),_t()&&(Bt(),kt())}))},[_t,Bt,lt,t.engineObject,kt]),ht=v.useCallback((h,y)=>{const x=Tt(h,l.width,l.height,y),I=ui(x,l.width,l.height);t[a]=I;const C=y?ti[y]:void 0;n==null||n(a,I,C)},[t,n,a,l.height,l.width]),re=v.useCallback((h,y)=>{const x=ft(h,y);t[a]=x,n==null||n(a,x,y)},[t,n,a]),se=v.useCallback((h,y)=>{ht({...u,[h]:et(y,0)},h)},[u,ht]),ut=v.useMemo(()=>{const h=y=>x=>{x.preventDefault();const I=m.current,C=document.activeElement;I&&C instanceof HTMLElement&&I.contains(C)&&C.blur(),H(y)};return{left:h("left"),right:h("right"),top:h("top"),bottom:h("bottom")}},[]);v.useEffect(()=>{if(!U)return;const h=ei[U],y=I=>{const C=b.current;if(!C)return;const N=C.getBoundingClientRect();if(N.width<=0||N.height<=0)return;const G=ft(t[a]??{x:0,y:0,z:0,w:0}),bt=Vt(G,l.width,l.height),st=h.axis==="x"?I.clientX:I.clientY,le=h.axis==="x"?N.left:N.top,he=h.axis==="x"?N.right:N.bottom,Lt=h.axis==="x"?N.width:N.height,ue=h.axis==="x"?l.width:l.height,ge=q(h.fromStart?(st-le)/Lt:(he-st)/Lt,0,1);ht({...bt,[U]:ge*ue},U)},x=()=>{H(null)};return window.addEventListener("mousemove",y),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",x)}},[ht,U,t,a,l.height,l.width]),v.useEffect(()=>{if(!X){ct();return}w.current||lt();const h=w.current;h&&(h.spriteRenderer.sprite=t.engineObject??null),Ft()},[ct,lt,X,Ft,T.height,T.width,t.engineObject,t.height,(Mt=t.pivot)==null?void 0:Mt.x,(Et=t.pivot)==null?void 0:Et.y,(Ot=t.region)==null?void 0:Ot.height,(At=t.region)==null?void 0:At.width,(jt=t.region)==null?void 0:jt.x,(Dt=t.region)==null?void 0:Dt.y,t.width]),v.useEffect(()=>()=>{ct()},[ct]);const ae=typeof s=="string"?g(s):s,oe=typeof o=="string"?g(o):o,ce=v.useMemo(()=>({x:"L",y:"B",z:"R",w:"T"}),[]);return R.jsx(Ce,{disabled:c,label:ae,info:oe,min:0,max:1,step:.01,dragStep:.01,value:f,slotMapping:ce,onChange:re,formEndSlot:R.jsx(Pe,{disabled:c,side:"bottom",align:"start",sideOffset:4,onOpenAutoFocus:h=>h.preventDefault(),onOpenChange:h=>{rt(h),h||H(null)},trigger:R.jsx(Te,{variant:"subtle",corner:!0,disabled:c,children:R.jsx(_e,{size:14})}),children:R.jsxs(si,{ref:m,direction:"column",gap:"sm",children:[R.jsx(ai,{ref:d,children:R.jsxs(oi,{ref:b,css:{width:`${T.width}px`,height:`${T.height}px`},children:[R.jsx(ci,{ref:S}),R.jsx(li,{css:{left:`${F.left*100}%`,right:`${F.right*100}%`,top:`${F.top*100}%`,bottom:`${F.bottom*100}%`}}),R.jsx(Wt,{onMouseDown:ut.left,css:{left:`${F.left*100}%`}}),R.jsx(Wt,{onMouseDown:ut.right,css:{left:`${(1-F.right)*100}%`}}),R.jsx(qt,{onMouseDown:ut.top,css:{top:`${F.top*100}%`}}),R.jsx(qt,{onMouseDown:ut.bottom,css:{top:`${(1-F.bottom)*100}%`}})]})}),R.jsx(tt,{direction:"column",gap:"xs",css:{width:"100%"},children:ii.map(([h,y])=>R.jsx(tt,{gap:"sm",align:"v",children:[h,y].map(x=>R.jsx(tt,{direction:"column",css:hi,children:R.jsx(Be,{min:0,max:Math.max(0,l[ni[x]]-u[ri[x]]),dragStep:1,step:1,value:u[x],startSlot:x[0].toUpperCase(),endSlot:"px",onValueChange:I=>se(x,I)})},x))},h))})]})})})});class D{constructor(e=0,t=0,i=0,n=0,a=""){p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"name","");p(this,"isRotated",!1);p(this,"allowRotate");this.x=e,this.y=t,this.width=i,this.height=n,this.name=a}clone(){return new D(this.x,this.y,this.width,this.height,`${this.name}-clone`)}isContainedIn(e){return this.x>=e.x&&this.y>=e.y&&this.x+this.width<=e.x+e.width&&this.y+this.height<=e.y+e.height}static isContainedIn(e,t){return e.isContainedIn(t)}}var L=(r=>(r[r.BestShortSideFit=0]="BestShortSideFit",r[r.BestLongSideFit=1]="BestLongSideFit",r[r.BestAreaFit=2]="BestAreaFit",r[r.BottomLeftRule=3]="BottomLeftRule",r[r.ContactPointRule=4]="ContactPointRule",r))(L||{});class di{constructor(){p(this,"binWidth");p(this,"binHeight");p(this,"allowRotate");p(this,"usedRectangles");p(this,"freeRectangles");this.binWidth=0,this.binHeight=0,this.allowRotate=!1,this.usedRectangles=[],this.freeRectangles=[]}init(e,t,i){this.binWidth=e,this.binHeight=t,this.allowRotate=i||!1,this.usedRectangles.length=0,this.freeRectangles.length=0,this.freeRectangles.push(new D(0,0,e,t))}insert(e,t,i){let n=new D;const a={value:0},c={value:0},s=i||0,o=this.allowRotate;if(!this._canFit(e,t,o))return n;switch(s){case L.BestShortSideFit:n=this._findPositionForNewNodeBestShortSideFit(e,t,a,c,o);break;case L.BottomLeftRule:n=this._findPositionForNewNodeBottomLeft(e,t,a,c,o);break;case L.ContactPointRule:n=this._findPositionForNewNodeContactPoint(e,t,a,o);break;case L.BestLongSideFit:n=this._findPositionForNewNodeBestLongSideFit(e,t,c,a,o);break;case L.BestAreaFit:n=this._findPositionForNewNodeBestAreaFit(e,t,a,c,o);break}return n.height===0||this._placeRectangle(n),n}insert2(e,t){const i=[],n=t||0;for(;e.length>0;){let a=1/0,c=1/0,s=-1,o=new D,g=-1/0;for(let f=0;f<e.length;f++){const u=e[f],d=this._getAllowRotate(u);if(!this._canFit(u.width,u.height,d))continue;const m={value:0},b={value:0},S=this._scoreRectangle(u.width,u.height,n,m,b,d),w=this._getSortKey(u,n);m.value<a||m.value===a&&b.value<c?(a=m.value,c=b.value,o=S,s=f,g=w):s!==-1&&m.value!==1/0&&b.value!==1/0&&m.value===a&&b.value===c&&w>g&&(o=S,s=f,g=w)}if(s===-1)return i;this._placeRectangle(o);const l=e.splice(s,1)[0];l.x=o.x,l.y=o.y,l.isRotated=o.isRotated,i.push(l)}return i}_placeRectangle(e){let t=this.freeRectangles.length;for(let i=0;i<t;i++)this._splitFreeNode(this.freeRectangles[i],e)&&(this.freeRectangles.splice(i,1),i--,t--);this._purgeFreeList(),this._pruneFreeList(),this.usedRectangles.push(e)}_scoreRectangle(e,t,i,n,a,c){let s=new D;switch(n.value=1/0,a.value=1/0,i){case L.BestShortSideFit:s=this._findPositionForNewNodeBestShortSideFit(e,t,n,a,c);break;case L.BottomLeftRule:s=this._findPositionForNewNodeBottomLeft(e,t,n,a,c);break;case L.ContactPointRule:s=this._findPositionForNewNodeContactPoint(e,t,n,c),n.value=-n.value;break;case L.BestLongSideFit:s=this._findPositionForNewNodeBestLongSideFit(e,t,a,n,c);break;case L.BestAreaFit:s=this._findPositionForNewNodeBestAreaFit(e,t,n,a,c);break}return s.height===0&&(n.value=1/0,a.value=1/0),s}_findPositionForNewNodeBottomLeft(e,t,i,n,a){const c=this.freeRectangles,s=new D;i.value=1/0,n.value=1/0;let o,g;for(let l=0;l<c.length;l++)o=c[l],o.width>=e&&o.height>=t&&(g=o.y+t,(g<i.value||g===i.value&&o.x<n.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,i.value=g,n.value=o.x)),a&&o.width>=t&&o.height>=e&&(g=o.y+e,(g<i.value||g===i.value&&o.x<n.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,i.value=g,n.value=o.x));return s}_findPositionForNewNodeBestShortSideFit(e,t,i,n,a){const c=this.freeRectangles,s=new D;i.value=1/0;let o,g,l,f,u;for(let d=0;d<c.length;d++)if(o=c[d],o.width>=e&&o.height>=t&&(g=Math.abs(o.width-e),l=Math.abs(o.height-t),f=Math.min(g,l),u=Math.max(g,l),(f<i.value||f===i.value&&u<n.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,i.value=f,n.value=u)),a&&o.width>=t&&o.height>=e){const m=Math.abs(o.width-t),b=Math.abs(o.height-e),S=Math.min(m,b),w=Math.max(m,b);(S<i.value||S===i.value&&w<n.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,i.value=S,n.value=w)}return s}_findPositionForNewNodeBestLongSideFit(e,t,i,n,a){const c=this.freeRectangles,s=new D;n.value=1/0;let o,g,l,f,u;for(let d=0;d<c.length;d++)o=c[d],o.width>=e&&o.height>=t&&(g=Math.abs(o.width-e),l=Math.abs(o.height-t),f=Math.min(g,l),u=Math.max(g,l),(u<n.value||u===n.value&&f<i.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,i.value=f,n.value=u)),a&&o.width>=t&&o.height>=e&&(g=Math.abs(o.width-t),l=Math.abs(o.height-e),f=Math.min(g,l),u=Math.max(g,l),(u<n.value||u===n.value&&f<i.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,i.value=f,n.value=u));return s}_findPositionForNewNodeBestAreaFit(e,t,i,n,a){const c=this.freeRectangles,s=new D;i.value=1/0;let o,g,l,f,u;for(let d=0;d<c.length;d++)o=c[d],u=o.width*o.height-e*t,o.width>=e&&o.height>=t&&(g=Math.abs(o.width-e),l=Math.abs(o.height-t),f=Math.min(g,l),(u<i.value||u===i.value&&f<n.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,n.value=f,i.value=u)),a&&o.width>=t&&o.height>=e&&(g=Math.abs(o.width-t),l=Math.abs(o.height-e),f=Math.min(g,l),(u<i.value||u===i.value&&f<n.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,n.value=f,i.value=u));return s}_commonIntervalLength(e,t,i,n){return t<i||n<e?0:Math.min(t,n)-Math.max(e,i)}_contactPointScoreNode(e,t,i,n){const a=this.usedRectangles;let c=0;(e===0||e+i===this.binWidth)&&(c+=n),(t===0||t+n===this.binHeight)&&(c+=i);let s;for(let o=0;o<a.length;o++)s=a[o],(s.x===e+i||s.x+s.width===e)&&(c+=this._commonIntervalLength(s.y,s.y+s.height,t,t+n)),(s.y===t+n||s.y+s.height===t)&&(c+=this._commonIntervalLength(s.x,s.x+s.width,e,e+i));return c}_findPositionForNewNodeContactPoint(e,t,i,n){const a=this.freeRectangles,c=new D;i.value=-1;let s,o;for(let g=0;g<a.length;g++)s=a[g],s.width>=e&&s.height>=t&&(o=this._contactPointScoreNode(s.x,s.y,e,t),o>i.value&&(c.x=s.x,c.y=s.y,c.width=e,c.height=t,c.isRotated=!1,i.value=o)),n&&s.width>=t&&s.height>=e&&(o=this._contactPointScoreNode(s.x,s.y,t,e),o>i.value&&(c.x=s.x,c.y=s.y,c.width=t,c.height=e,c.isRotated=!0,i.value=o));return c}_splitFreeNode(e,t){const i=this.freeRectangles;if(t.x>=e.x+e.width||t.x+t.width<=e.x||t.y>=e.y+e.height||t.y+t.height<=e.y)return!1;let n;return t.x<e.x+e.width&&t.x+t.width>e.x&&(t.y>e.y&&t.y<e.y+e.height&&(n=e.clone(),n.height=t.y-n.y,n.width>0&&n.height>0&&i.push(n)),t.y+t.height<e.y+e.height&&(n=e.clone(),n.y=t.y+t.height,n.height=e.y+e.height-(t.y+t.height),n.width>0&&n.height>0&&i.push(n))),t.y<e.y+e.height&&t.y+t.height>e.y&&(t.x>e.x&&t.x<e.x+e.width&&(n=e.clone(),n.width=t.x-n.x,n.width>0&&n.height>0&&i.push(n)),t.x+t.width<e.x+e.width&&(n=e.clone(),n.x=t.x+t.width,n.width=e.x+e.width-(t.x+t.width),n.width>0&&n.height>0&&i.push(n))),!0}_pruneFreeList(){const e=this.freeRectangles;let t=0;for(;t<e.length;){let i=t+1;const n=e[t];for(;i<e.length;){const a=e[i];if(D.isContainedIn(n,a)){e.splice(t,1),t--;break}D.isContainedIn(a,n)&&(e.splice(i,1),i--),i++}t++}}_purgeFreeList(){const e=this.freeRectangles;for(let t=e.length-1;t>=0;t--){const i=e[t];(i.width<=0||i.height<=0)&&e.splice(t,1)}}_canFit(e,t,i){return!!(e<=this.binWidth&&t<=this.binHeight||i&&t<=this.binWidth&&e<=this.binHeight)}_getAllowRotate(e){return typeof e.allowRotate=="boolean"?e.allowRotate:this.allowRotate}_getSortKey(e,t){return t===L.BestAreaFit?e.width*e.height:Math.max(e.width,e.height)}}var B=(r=>(r[r.Success=0]="Success",r[r.NoImage=1]="NoImage",r[r.ImageLoadError=2]="ImageLoadError",r[r.OffscreenBlobError=3]="OffscreenBlobError",r[r.CanvasBlobError=4]="CanvasBlobError",r[r.PackError=5]="PackError",r))(B||{});class mi{constructor(){p(this,"mipmap");p(this,"wrapModeV");p(this,"wrapModeU");p(this,"filterMode");p(this,"anisoLevel");p(this,"version",0);p(this,"format",1);p(this,"atlasItems",[])}}class wi{constructor(){p(this,"id");p(this,"name");p(this,"atlasRotated");p(this,"atlasRegion");p(this,"atlasRegionOffset");p(this,"region");p(this,"pivot");p(this,"border");p(this,"pixelsPerUnit");p(this,"width");p(this,"height")}}class xt{}class yi extends xt{constructor(){super(...arguments);p(this,"canvas");p(this,"context2D")}async parse(t){const i=t.outPut.info=new mi,n=t.option.padding??0,a=t.bins??[];t.outPut.imageFiles=[];const c=i.atlasItems;for(let s=0,o=a.length;s<o;s++){const g=a[s];this.initCanvas(g.width,g.height);const{context2D:l}=this,{rects:f}=g,u=new Array,d={img:"",type:"",width:g.width,height:g.height,sprites:u};for(let b=0,S=f.length;b<S;b++){const w=new wi,P=f[b];w.name=P.name,w.atlasRotated=P.isRotated,w.atlasRegion={x:P.x,y:P.y,w:P.width,h:P.height};const M=this.getItem(t.images,P.name),j=M==null?void 0:M.image;if(j){const $=P.x,K=P.y,E=t.option.allowTrim?M.trimRect:void 0,nt=E?E.x:0,X=E?E.y:0,rt=E?E.w:j.width,U=E?E.h:j.height;if(E){const T=M.sourceWidth??j.width,F=M.sourceHeight??j.height;w.atlasRegionOffset={x:E.x,y:E.y,z:T-E.x-E.w,w:F-E.y-E.h}}let H,_,k;if(P.isRotated){_=U,k=rt;let T;try{T=new OffscreenCanvas(_,k)}catch{T=document.createElement("canvas"),T.width=_,T.height=k}const F=T.getContext("2d");F.translate(_,0),F.rotate(Math.PI/2),F.drawImage(j,nt,X,rt,U,0,0,rt,U),H=T}else _=rt,k=U,H=j;if(P.isRotated?l.drawImage(H,0,0,_,k,$,K,_,k):l.drawImage(H,nt,X,_,k,$,K,_,k),n>0)try{const T=P.isRotated?0:nt,F=P.isRotated?0:X;for(let W=1;W<=n;++W)l.drawImage(H,T,F,_,1,$,K-W,_,1),l.drawImage(H,T,F+k-1,_,1,$,K+k+W-1,_,1),l.drawImage(H,T,F,1,k,$-W,K,1,k),l.drawImage(H,T+_-1,F,1,k,$+_+W-1,K,1,k)}catch(T){console.error(JSON.stringify(T))}}u.push(w)}const m=await this.drawCanvas();if(m)t.outPut.imageFiles.push(m),c.push(d);else return B.CanvasBlobError}return B.Success}getItem(t,i){for(let n=t.length-1;n>=0;n--)if(t[n].name===i)return t[n];return null}initCanvas(t,i){if(this.canvas)this.canvas.width!==t||this.canvas.height!==i?(this.canvas.width=t,this.canvas.height=i):this.context2D.clearRect(0,0,t,i);else{try{this.canvas=new OffscreenCanvas(t,i)}catch{this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=i}this.context2D=this.canvas.getContext("2d",{willReadFrequently:!0})}}async drawCanvas(){return new Promise((t,i)=>{this.canvas instanceof HTMLCanvasElement?this.canvas.toBlob(n=>{n.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert canvas blob to ArrayBuffer"))})},"image/png",1):this.canvas.convertToBlob({type:"image/png",quality:1}).then(n=>{n.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert offscreen blob to ArrayBuffer"))})}).catch(n=>{console.error(JSON.stringify(n)),i(new Error("Failed to convert offscreen canvas to blob"))})})}}class xi extends xt{parse(e){return new Promise((t,i)=>{const{images:n}=e,{width:a,height:c,allowRotate:s,allowTrim:o}=e.option,g=n.length,l=[];for(let f=0;f<g;f++){const u=n[f];let d;const m=u.src;u.image||(m instanceof ArrayBuffer?d=this._loadImageFromBuffer(u):d=this._loadImageFromURL(u),l.push(d))}Promise.all(l).then(f=>{if(!o)for(let u=0,d=f.length;u<d;u++){const m=f[u];if(!(m.width<=a&&m.height<=c||!!s&&m.height<=a&&m.width<=c)){t(B.PackError);return}}t(B.Success)}).catch(f=>{console.error("OptLoadImage:Error",JSON.stringify(f)),i(B.ImageLoadError)})})}_loadImageFromBuffer(e){return new Promise((t,i)=>{const n=e.src,a=new window.Blob([n],{type:e.type}),c=new Image;c.onerror=function(){i(new Error("Failed to load image buffer"))},c.onload=function(){requestAnimationFrame(()=>{c.onload=null,c.onerror=null,c.onabort=null,e.image=c,t(c)})},c.crossOrigin="anonymous",c.src=URL.createObjectURL(a)})}_loadImageFromURL(e){return new Promise((t,i)=>{const n=new Image;n.onerror=function(){i(new Error("Failed to load image buffer"))},n.onload=function(){requestAnimationFrame(()=>{n.onload=null,n.onerror=null,n.onabort=null,e.image=n,t(n)})},n.crossOrigin="anonymous",n.src=e.src})}}const gt=[2048,1024,512,256,128,64,32,16,8,4,2];class vi extends xt{parse(e){const{option:t,images:i}=e,n=t.padding??0,a=!!t.allowRotate,c=t.method??L.BestLongSideFit;let s,o;if(t.square?s=o=Math.min(t.width,t.height):(s=t.width,o=t.height),t.pot){let u=!1,d=!1;for(let m=0,b=gt.length;m<b;++m){const S=gt[m];if(!u&&s>=S&&(s=S,u=!0),!d&&o>=S&&(o=S,d=!0),u&&d)break}}const g=[],l=n*2;for(let u=i.length-1;u>=0;u--){const d=i[u],m=d.image;if(!m)return B.ImageLoadError;const b=t.allowTrim?d.trimRect:void 0,S=b?b.w:m.width,w=b?b.h:m.height;if(!this.checkSizeLegality(S,w,s,o,l,a))return console.log("打包失败,",d.name,"单图尺寸超图集大小"),B.PackError;g.push(new D(0,0,S+l,w+l,d.name))}const f=[];for(;g.length>0;){const u=new di;u.init(s,o,a);const d=u.insert2(g,c);if(d.length===0)return B.PackError;let m=0,b=0;for(let S=0;S<d.length;S++){const w=d[S],P=w.isRotated?w.height:w.width,M=w.isRotated?w.width:w.height,j=w.x+P,$=w.y+M;m=Math.max(m,j),b=Math.max(b,$),n>0&&(w.x+=n,w.y+=n,w.width-=l,w.height-=l)}if(t.square&&(m=b=Math.max(m,b)),t.pot){let S=!1,w=!1;for(let P=gt.length-1;P>=0;--P){const M=gt[P];if(!S&&m<=M&&(m=M,S=!0),!w&&b<=M&&(b=M,w=!0),S&&w)break}}f.push({rects:d,width:m,height:b})}return e.bins=f,B.Success}checkSizeLegality(e,t,i,n,a,c){const s=e+a,o=t+a;return c?s<=i&&o<=n||o<=i&&s<=n:s<=i&&o<=n}}const at=class at extends xt{static _getTrimContext(){let{_trimContext:e}=at;if(!e){let t;try{t=new OffscreenCanvas(1,1)}catch{t=document.createElement("canvas")}const i=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,ctx:i},at._trimContext=e}return e}parse(e){if(!e.option.allowTrim)return B.Success;const{images:t}=e,{canvas:i,ctx:n}=at._getTrimContext();for(let a=0,c=t.length;a<c;a++){const s=t[a],o=s.image;if(!o)continue;const{width:g,height:l}=o;s.sourceWidth=g,s.sourceHeight=l,i.width=g,i.height=l,n.drawImage(o,0,0);const f=n.getImageData(0,0,g,l).data,u=this._getTrimRect(f,g,l);(u.w<g||u.h<l)&&(s.trimRect=u)}return B.Success}_getTrimRect(e,t,i){let n=t,a=0,c=i,s=0;for(let o=0;o<i;o++){const g=o*t*4;for(let l=0;l<t;l++)e[g+l*4+3]>0&&(l<n&&(n=l),l>a&&(a=l),o<c&&(c=o),o>s&&(s=o))}return a<n||s<c?{x:0,y:0,w:1,h:1}:{x:n,y:c,w:a-n+1,h:s-c+1}}};p(at,"_trimContext",null);let Pt=at;const Ut=[new xi,new Pt,new vi,new yi],It={width:1024,height:1024,padding:1,allowRotate:!1,square:!1,pot:!1,method:L.BestLongSideFit};async function ee(r,e){if(r.length===0)return{code:B.NoImage,msg:Jt(B.NoImage)};if(e===void 0)e=It;else{const a=Object.keys(It);for(let c=a.length-1;c>=0;c--){const s=a[c];e[s]===void 0&&(e[s]=It[s])}}const t={};r.sort((a,c)=>c.name.toLowerCase().localeCompare(a.name.toLowerCase()));const i={option:e,images:r,outPut:t};let n=B.Success;for(let a=0;a<Ut.length;a++){const c=await Ut[a].parse(i);if(c!==B.Success){n=c;break}}return t.code=n,t.msg=Jt(n),t}function Jt(r){switch(r){case B.Success:return"打包成功!";case B.NoImage:return"传入图片长度为0.";case B.ImageLoadError:return"图片加载失败.";case B.CanvasBlobError:return"画布 blob 转换失败.";case B.OffscreenBlobError:return"离线画布 blob 转换失败.";case B.PackError:return"图集尺寸限制,打包失败。"}}async function ot(r,e){await r.root.assetFacade.updateAssetProps(r.id,e)}async function bi(r,e){const t=await Promise.all(r.sprites.map(s=>e.getFileById(s.refId)).map(async s=>({...s,mainData:JSON.parse(await s.content.text())}))),[i,n]=Ke(t,s=>!!s.mainData.texture),a=Ge(i,s=>s.mainData.texture.refId);return{packItems:await Promise.all(i.filter(s=>{var g;const o=(g=s.mainData.texture)==null?void 0:g.refId;return o?!!e.getFileById(o):!1}).map(async s=>{const o=s.mainData.texture.refId,l=await(await e.loadFile(o)).arrayBuffer();return{name:o,src:l}})),spriteAssetMap:a,spritesEmpty:n}}async function Ai(r){const e=r.root.assetStore,t=await Promise.all(r.sprites.map(a=>e.getAssetByRef(a))),n=(await Promise.all(t.filter(a=>a&&a.texture).map(a=>e.getAssetByRef(a.texture)))).filter(a=>a).map(a=>({name:a.id,src:a.imageBuffer}));return await ee(n,{padding:r.padding,width:r.maxWidth,height:r.maxHeight})}async function ji(r,e){let t,i=[];const{spriteAssetMap:n,packItems:a,spritesEmpty:c}=await bi(r,e);if(a.length>0?(t=await ee(a,{padding:r.padding,width:r.maxWidth,height:r.maxHeight}),t.code===0?(i=t.info.atlasItems??[],i.forEach(s=>{const{sprites:o}=s;s.sprites=o.flatMap(g=>{const l=n[g.name],{atlasRegion:f,originalSize:u,atlasRotated:d}=g;return l.map(m=>Gt(m,f,u,d))})})):i=[],t.info.atlasItems=i):(t={code:1,msg:pt("sprite.atlas.pack-error.no-sprite")},i=[]),c.length>0){const s=c.map(o=>Gt(o));i.push({img:"",sprites:s})}return t.info&&(t.info.atlasItems=i),t}function Gt(r,e,t=0,i=!1){const n=r.mainData,a=n.region,c=n.pivot,s=n.border,o={name:r.path,atlasRegion:e?{x:e.x,y:e.y,w:e.w,h:e.h}:{x:0,y:0,w:1,h:1},originalSize:t,atlasRotated:i,pivot:{x:c.x,y:c.y},region:{x:a.x,y:a.y,w:a.width,h:a.height},border:{x:s.x,y:s.y,z:s.z,w:s.w},width:n.width,height:n.height};return isNaN(n.width)||(o.width=n.width),isNaN(n.height)||(o.height=n.height),o}function Di(r){const e=[],t=i=>{const n=i.children,a=Object.keys(n);for(let c=a.length-1;c>=0;c--){const s=n[a[c]];s instanceof A?e.push(s):s instanceof We&&t(s)}};return t(r),e}function vt(r,e){const t=e.id,i=r.sprites;for(let n=i.length-1;n>=0;n--)if(i[n].refId===t)return n;return-1}function Li(r,e,t,i,n="#212324",a=15){var S;const{width:c,height:s}=t,{width:o,height:g}=e;let l,f,u,d;i.clearRect(0,0,t.width,t.height),i.fillStyle=n,c/s>o/g?(f=s,l=s/g*o,u=(c-l)/2,d=0,i.fillRect(0,0,u,s),i.fillRect(u+l,0,u,s)):(l=c,f=c/o*g,u=0,d=(s-f)/2,i.fillRect(0,0,c,d),i.fillRect(0,d+f,c,d)),i.drawImage(e,0,0,e.width,e.height,u,d,l,f);const m="Size: "+o+"x"+g+" Usage: "+r+"%";i.font=a+"px Arial";const b=((S=i.measureText(m))==null?void 0:S.width)||a*m.length;i.fillStyle="#000000",i.fillText(m,(c-b)/2,s-a*1/3-2),i.fillStyle="#ffffff",i.fillText(m,(c-b)/2,s-a/2-2)}function zi(r){return r.sprites.length>0}async function Ni(r,e){await ot(r,{texture:e?e.getCurrentRef():null})}async function ie(r,e){const{belongToAtlas:t}=e,i=t==null?void 0:t.refId;if(i&&i!==r.id){const n=await r.root.assetStore.getAssetByRef(t);if(n){const a=n.sprites.filter(c=>c.refId!==e.id);a.length!==n.sprites.length&&await ot(n,{sprites:a})}}if(i!==r.id&&await ot(e,{belongToAtlas:r.getCurrentRef()}),vt(r,e)<0){const n=[...r.sprites,e.getCurrentRef()];await ot(r,{sprites:n})}}async function Kt(r,e){var i;((i=e.belongToAtlas)==null?void 0:i.refId)===r.id&&await ot(e,{belongToAtlas:null});const t=vt(r,e);if(t>=0){const n=r.sprites.filter((a,c)=>c!==t);await ot(r,{sprites:n})}}const Ri=mt(({asset:r,sprite:e})=>{const{assetStore:t}=r.root,i=Object.values(t.assets).filter(n=>n.getMetaConfig().type==="SpriteAtlas");return R.jsx(Qt,{direction:"column",dropLayer:yt.Sprite,assets:i,onSelect:async n=>{await Kt(r,e),await ie(n,e)},onDelete:()=>{Kt(r,e)},onLocate:()=>{r&&r.id&&t.selectAsset(r.id)},asset:r,value:r.name})}),Si=mt(({model:r})=>{const{t:e}=Yt(),{assetStore:t}=r.root;Ii(r);const i=r.belongToAtlas?t.assets[r.belongToAtlas.refId]:null,n=Object.values(t.assets).filter(a=>a.getMetaConfig().type==="SpriteAtlas");return R.jsxs(tt,{fullWidth:!0,css:{padding:"0 $0_5 $1"},children:[R.jsx(ke,{size:"1",css:{marginTop:"$1"},children:e("sprite.atlas.belong-to")}),r.belongToAtlas?R.jsx(Ri,{asset:i,sprite:r},i.id):R.jsx(Qt,{dropLayer:yt.Sprite,assets:n,onSelect:a=>{ie(a,r)},trigger:R.jsx(tt,{align:"h",css:{padding:"$1 $2 $1"},children:R.jsx(Fe,{size:"sm",variant:"solid",css:{padding:"$1 $6"},children:e("sprite.atlas.belong-to")})}),label:"",value:null,asset:null})]})});async function Ii(r){const e=r.root.assetStore,t=r.belongToAtlas,i=t?await e.getAssetByRef(t):null;if(i){vt(i,r)<0&&await r.root.assetFacade.updateAssetProps(i.id,{sprites:[...i.sprites,r.getCurrentRef()]});return}t&&await r.root.assetFacade.updateAssetProps(r.id,{belongToAtlas:null})}var Ci=Object.defineProperty,Pi=Object.getOwnPropertyDescriptor,V=(r,e,t,i)=>{for(var n=i>1?void 0:i?Pi(e,t):e,a=r.length-1,c;a>=0;a--)(c=r[a])&&(n=(i?c(e,t,n):c(n))||n);return i&&n&&Ci(e,t,n),n};const z=new Zt;function ne(r){return r.quickPivot===9}function Xt(r){switch(r){case 0:z.set(.5,.5);break;case 1:z.set(0,1);break;case 2:z.set(.5,1);break;case 3:z.set(1,1);break;case 4:z.set(0,.5);break;case 5:z.set(1,.5);break;case 6:z.set(0,0);break;case 7:{z.set(.5,0);break}case 8:{z.set(1,0);break}}}let A=class extends Me{constructor(e){super(e);p(this,"_delOnTexDel");p(this,"_customWidth");p(this,"_customHeight");p(this,"acceptDragLayer",yt.Texture);p(this,"texture",null);p(this,"width");p(this,"height");p(this,"region",{x:0,y:0,width:1,height:1});p(this,"quickPivot",0);p(this,"pivot",{x:.5,y:.5});p(this,"border",{x:0,y:0,z:0,w:0});p(this,"belongToAtlas",null)}async afterDelete(){this.engineObject.destroy(!0);const{belongToAtlas:e}=this;if(e){const t=await this.root.assetStore.getAssetByRef(e);if(t){const i=vt(t,this);i>-1&&t.sprites.splice(i,1),this.belongToAtlas=null,await this.root.assetFacade.persistAssetMain(t.id)}}this._delOnTexDel&&(this._delOnTexDel(),this._delOnTexDel=null)}getMainData(){const e=this[Nt]??{},t={};return Object.keys(e).forEach(i=>{switch(i){case"width":isNaN(this._customWidth)||(t.width=this._customWidth);break;case"height":isNaN(this._customHeight)||(t.height=this._customHeight);break;default:t[i]=this[i];break}}),JSON.stringify(t)}async initByMain(e){const t=new Ee(this.engine),i=JSON.parse(await e.text());if(isNaN(i.width)||(t.width=this._customWidth=i.width),isNaN(i.height)||(t.height=this._customHeight=i.height),i.texture){const a=await this.root.assetStore.getAssetByRef(i.texture);a&&(await a.ensureReady(),t.texture=a.engineObject)}for(const a in i)this[a]=i[a];this.bindEngineObject(t);const n=new Oe(this.engine);n.addComponent(wt).sprite=t,this.setDragTempEntity(n),await this.applyBoundPathChange("name",O.Input,this.name)}async initByCreation(){const{assetStore:e,assetUIStore:t}=this.root,{pickedAssets:i}=t,n=JSON.parse(this.getMainData());if(i&&i.length===1){const a={refId:i[0]},c=await e.getAssetByRef(a);c instanceof Je?(c.setTextureType(te.Sprite),n.texture=a):c instanceof A&&c.texture&&(n.texture={refId:c.texture.refId})}return n}instantiate(){const e=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:i,rotation:n}=t.transform,a={components:[{class:"SpriteRenderer",id:Ae(),props:{drawMode:0,enabled:!0,flipX:!1,flipY:!1,maskInteraction:0,maskLayer:je.Everything,sprite:this.getCurrentRef()}}],id:e.id,isActive:!0,isClone:!1,name:this.name?"sprite-"+this.name:"sprite",transform:{class:"Transform",props:{position:{x:i.x,y:i.y,z:i.z},rotation:{x:n.x,y:n.y,z:n.z},scale:{x:1,y:1,z:1}}}};return e.initByFile(a),e}initByEngineObject(e){const t=Object.keys(this[Nt]),i=["texture","quickPivot","belongToAtlas"],n=a=>!i.includes(a);t.filter(n).forEach(a=>{const c=e[a];typeof c=="object"?Object.keys(c).forEach(o=>{this[a][o]=c[o]}):this[a]=c}),this.bindEngineObject(e)}async _onDrop(e,t){const i="texture";this.dropping=!1,this.texture=t.getCurrentRef(),this.formSchema.getPropertyConfig(i).onChange(this,i,t),this.updateThumbnail()}};V([Q({info:"sprite.texture.info",label:"sprite.texture.label",type:O.AssetPicker,assetType:"Texture",customFilter:r=>r.isSubAsset===!1,onChange:async(r,e,t)=>{const i=r.engineObject;if(r._delOnTexDel&&(r._delOnTexDel(),r._delOnTexDel=null),await r.applyBoundPathChange("texture",O.AssetPicker,t==null?void 0:t.getCurrentRef()),t){const n=()=>{var a;(a=r._delOnTexDel)==null||a.call(r),r._delOnTexDel=null,r.texture=null,r.applyBoundPathChange("texture",O.AssetPicker,void 0),r.updateThumbnail()};t.on("delete",n),r._delOnTexDel=()=>{t.off("delete",n)}}isNaN(r._customWidth)?r.width=i.width:(r.width=r._customWidth,await r.applyBoundPathChange("width",O.Number,r._customWidth)),isNaN(r._customHeight)?r.height=i.height:(r.height=r._customHeight,await r.applyBoundPathChange("height",O.Number,r._customHeight))}}),Z()],A.prototype,"texture",2);V([Q({label:"sprite.width.label",info:"sprite.width.info",type:O.Number,triggerAfterInit:!1,async onChange(r,e,t){isNaN(t)||(r._customWidth=t,await r.applyBoundPathChange("width",O.Number,t))}}),Z()],A.prototype,"width",2);V([Q({label:"sprite.height.label",info:"sprite.height.info",type:O.Number,triggerAfterInit:!1,async onChange(r,e,t){isNaN(t)||(r._customHeight=t,await r.applyBoundPathChange("height",O.Number,t))}}),Z()],A.prototype,"height",2);V([Q({info:"sprite.region.info",label:"sprite.region.label",type:O.Rect,min:0,max:1,dragStep:.01,onChange(r,e,t){r.applyBoundPathChange("region",O.Rect,t)}}),Z()],A.prototype,"region",2);V([De({setPath:"pivot",getActualEditorValue:r=>(Xt(r),new Zt().copyFrom(z)),getEditorValue:r=>{const{x:e,y:t}=r;return e===.5&&t===.5?0:e===0&&t===1?1:e===.5&&t===1?2:e===1&&t===1?3:e===0&&t===.5?4:e===1&&t===.5?5:e===0&&t===0?6:e===.5&&t===0?7:e===1&&t===0?8:9}}),Q({info:"sprite.quick-pivot.info",label:"sprite.quick-pivot.label",type:O.Select,value:0,options:[{label:"sprite.quick-pivot.center",value:0},{label:"sprite.quick-pivot.top-left",value:1},{label:"sprite.quick-pivot.top",value:2},{label:"sprite.quick-pivot.top-right",value:3},{label:"sprite.quick-pivot.left",value:4},{label:"sprite.quick-pivot.right",value:5},{label:"sprite.quick-pivot.bottom-left",value:6},{label:"sprite.quick-pivot.bottom",value:7},{label:"sprite.quick-pivot.bottom-right",value:8},{label:"sprite.quick-pivot.custom",value:9}],onChange(r,e,t){ne(r)?z.copyFrom(r.pivot):Xt(t),r.pivot.x=z.x,r.pivot.y=z.y,r.applyBoundPathChange("pivot",O.Vector2,z)}}),Z()],A.prototype,"quickPivot",2);V([Q({info:"sprite.pivot.info",label:"sprite.pivot.label",type:O.Vector2,onChange(r,e,t){r.quickPivot===9&&r.applyBoundPathChange("pivot",O.Vector2,t)},when:ne}),Z()],A.prototype,"pivot",2);V([Q({info:"sprite.border.info",label:"sprite.border.label",customComponent:pi,slotMapping:{x:"Left",y:"Down",z:"Right",w:"Up"},onChange(r,e,t){r.applyBoundPathChange("border",O.Vector4,t)}}),Z()],A.prototype,"border",2);V([Q({info:pt("sprite.belong.info"),label:pt("sprite.belong.label"),customComponent:Si}),Z()],A.prototype,"belongToAtlas",2);V([Le()],A.prototype,"getMainData",1);V([ze],A.prototype,"_onDrop",1);A=V([qe({type:"sprite",label:pt("asset.sprite.title"),loaderType:"Sprite",extname:"sprite",importMenuConfig:{type:$t.Upload|$t.Add,tooltip:"支持多选",accept:".png,.jpg,.jpeg,.webp",multiple:!0},viewer:Ye,thumbnail:Ct,defaultName:"Sprite",dragLayer:yt.Sprite,dragType:"2d",preUpload:async(r,e,t,i)=>{const n=r.main.name;if(i)if(i.meta.type==="Texture"){await Ne.assets.update(i.serverId,{file:r.main});return}else throw`Can't overwrite type: ${i.meta.type}, name: ${n}`;const a=await t.root.assetFacade.createAssetByUpload({uploadAssetFile:r,assetType:"Texture"});return a.setTextureType(te.Sprite),new File([JSON.stringify({texture:a.getCurrentRef()})],He(n,Ht(n))+"-spr"+Ht(n))},customInspector:Xe,async bundle({id:r,content:e,path:t},i,n){const a=n.vfs;return{content:new Blob([await Ue(r,await e.text(),t,async c=>{const s=a.getFileById(c);if(!s)return null;const o=s.content??await a.loadFile(s.id);return o?o.text():null})])}}})],A);const Hi=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAsset(){return A}},Symbol.toStringTag,{value:"Module"}));export{A as S,ie as a,ji as b,ee as c,Li as d,Hi as e,Di as g,zi as h,Ai as p,Kt as r,Ni as u};
@@ -1 +0,0 @@
1
- var K=Object.defineProperty;var Q=(e,t,s)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var h=(e,t,s)=>(Q(e,typeof t!="symbol"?t+"":t,s),s);import{aH as V,aJ as k,aD as d,aK as C,aI as B,aT as W,aU as J,bz as H,n as R,dF as X,b8 as Y,cz as Z,cw as ee,aL as te,j as L,cb as se,cd as O,an as j,a0 as y,bu as ae,e as F,dG as _,p as w,C as S,m as x,s as re,J as ie}from"./index-0a8702e2.js";import{F as U,a as oe,A as ne}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{u as z,h as le,d as $,r as pe,S as E,a as D,g as ce,p as de,b as ue}from"./SpriteAsset-9a31ec24.js";import{F as ge}from"./FormItemArray-66be8701.js";import{s as N}from"./utilities-e09052e3.js";import{b as fe}from"./TextureAsset-28fedf2a.js";function he(e,t){const s=new Map;for(let r=0;r<e.length;r++){const a=e[r],i=t(a);s.has(i)||s.set(i,a)}return Array.from(s.values())}const me=V("div",{position:"relative",width:"100%",marginBottom:"$2",aspectRatio:"1/1"}),be=V("div",{position:"absolute",width:"100%",height:"100%",padding:"$1",boxSizing:"border-box","& canvas":{width:"100%",height:"100%",border:"1px solid $grayA4",borderRadius:"$3",overflow:"hidden"}}),ve=k.forwardRef(function(t,s){const{buttonContent:r,onClick:a}=t;return d.jsxs(C,{direction:"column",fullWidth:!0,children:[d.jsx(me,{children:d.jsx(be,{children:d.jsx("canvas",{ref:s,width:"400",height:"400"})})}),r&&d.jsx(C,{align:"h",css:{margin:"$0 auto"},children:d.jsx(B,{size:"sm",variant:"solid",css:{padding:"0 $14"},onClick:a,children:r})})]})});function we(e){let t=!1;return e.textureRef?e.assetStore.getAssetByRef(e.textureRef).then(s=>{t||e.setTextureAsset(s??null)}).catch(()=>{t||e.setTextureAsset(null)}):e.setTextureAsset(null),()=>{t=!0}}function xe(e,t){return new Promise((s,r)=>{const a=new window.Blob([e],{type:t}),i=new window.Image,n=URL.createObjectURL(a);let c=!1;const m=()=>{c||(c=!0,URL.revokeObjectURL(n))};i.crossOrigin="anonymous",i.onerror=()=>{m(),r(new Error("Failed to load image buffer"))},i.onload=()=>{requestAnimationFrame(()=>{m(),s(i)})},i.src=n})}const ye=W(({item:e})=>{const[t,s]=k.useState(null),{assetStore:r}=e.root,{t:a}=J(),i=Object.values(r.assets).filter(n=>!n.isSubAsset&&n.getMetaConfig().type==="Texture");return k.useEffect(()=>we({assetStore:r,textureRef:e.texture,setTextureAsset:s}),[r,e.texture]),d.jsxs(d.Fragment,{children:[d.jsx(H,{dropLayer:R.Sprite,assets:i,onSelect:n=>{z(e,n)},onDelete:()=>{z(e,null)},onLocate:()=>{var n;(n=e.texture)!=null&&n.refId&&r.selectAsset(e.texture.refId)},label:a("sprite.texture.label"),value:t&&t.name,asset:t}),d.jsx(X,{label:a("sprite.region.label"),value:{x:e.region.x,y:e.region.y,width:e.region.width,height:e.region.height},onChange:(n,c)=>{e.root.inspectorFacade.assetChange(e.id,"region",{...e.region,[c]:n[c]})},min:0,max:1}),d.jsx(Y,{label:a("sprite.quick-pivot.label"),value:e.quickPivot,options:[{label:a("sprite.quick-pivot.center"),value:0},{label:a("sprite.quick-pivot.top-left"),value:1},{label:a("sprite.quick-pivot.top"),value:2},{label:a("sprite.quick-pivot.top-right"),value:3},{label:a("sprite.quick-pivot.left"),value:4},{label:a("sprite.quick-pivot.right"),value:5},{label:a("sprite.quick-pivot.bottom-left"),value:6},{label:a("sprite.quick-pivot.bottom"),value:7},{label:a("sprite.quick-pivot.bottom-right"),value:8},{label:a("sprite.quick-pivot.custom"),value:9}],onChange:n=>{e.root.inspectorFacade.assetChange(e.id,"quickPivot",n)}}),e.quickPivot===9&&d.jsx(Z,{label:"",value:{x:0,y:0}}),d.jsx(ee,{label:a("sprite.border.label"),value:{x:e.border.x,y:e.border.y,z:e.border.z,w:e.border.w},onChange:(n,c)=>{e.root.inspectorFacade.assetChange(e.id,"border",{...e.border,[c]:n[c]})},min:0,max:1})]})}),Se=W(({model:e,inspectorConfig:t})=>{const{label:s}=t,r=e.sprites,{assetStore:a}=e.root,i=le(e),{t:n}=J();Ie(e);const c=Object.values(a.assets).filter(o=>{switch(o.getMetaConfig().type){case"sprite":return!r.find(l=>l.refId===o.id);case"Folder":return!0}return!1}),m=k.useRef(null);let u,g;k.useLayoutEffect(()=>{u=m.current,g=u==null?void 0:u.getContext("2d"),e.previewImage&&g&&$(e.usage,e.previewImage,u,g)});async function b(){var o;if(i){if(g){const p=await de(e),l=((o=p.info)==null?void 0:o.atlasItems)??[],I=l.reduce((T,P)=>T+P.sprites.reduce((G,q)=>G+q.width*q.height,0),0),A=l.reduce((T,P)=>T+P.width*P.height,0),M=A>0?Number((I/A*100).toFixed(2)):0;p.code===0?xe(p.imageFiles[0],"image/png").then(T=>{e.replacePreview(T),$(M,T,u,g)}):N({title:n("sprite.atlas.pack-error.title"),description:p.msg})}}else N({title:n("sprite.atlas.pack-error.title"),description:n("sprite.atlas.pack-error.no-sprite")})}return d.jsxs(d.Fragment,{children:[d.jsx(ge,{label:s,items:r.map((o,p)=>{const l=a.assets[o.refId];return{removable:!0,children:d.jsx(ye,{item:l}),id:`${p}`,name:l.getRouteString()}}),onDelete:async o=>{const p=await a.getAssetByRef(r[o.id]);await pe(e,p)}}),d.jsxs(C,{align:"both",direction:"column",children:[d.jsx(H,{assets:c,dropLayer:R.Sprite|R.Folder,customFilter:o=>o instanceof E||o instanceof U,onSelect:o=>{if(o instanceof E)D(e,o);else if(o instanceof U){const p=ce(o);for(let l=p.length-1;l>=0;l--)D(e,p[l])}},trigger:d.jsx(B,{size:"sm",variant:"solid",css:{flex:1},startSlot:d.jsx(te,{}),children:n("sprite.atlas.add-object.label")}),label:n("sprite.atlas.add-sprite"),value:null,asset:null}),d.jsx(B,{size:"sm",variant:"solid",positive:!0,fullWidth:!0,css:{margin:"$1"},onClick:b,children:n("sprite.atlas.pack-preview.label")})]}),i&&d.jsx(ve,{ref:m})]})});async function Ie(e){var a;const t=e.root.assetStore.assets,s=e.sprites,r=[];for(let i=0;i<s.length;i++){const n=s[i],c=t[n.refId];c&&(r.push(n),((a=c.belongToAtlas)==null?void 0:a.refId)!==e.id&&await D(e,c))}r.length!==s.length&&await e.root.assetFacade.updateAssetProps(e.id,{sprites:r})}function Ae(e,t,s,r={}){return{id:e,type:t,version:s.engineVersion??"",extraData:{},dependencies:[],...r}}var Te=Object.defineProperty,je=Object.getOwnPropertyDescriptor,v=(e,t,s,r)=>{for(var a=r>1?void 0:r?je(t,s):t,i=e.length-1,n;i>=0;i--)(n=e[i])&&(a=(r?n(t,s,a):n(a))||a);return r&&a&&Te(t,s,a),a};let f=class extends L{constructor(t){super(t);h(this,"acceptDragLayer",R.Sprite);h(this,"previewTexture2D");h(this,"previewImage");h(this,"usage",0);h(this,"maxWidth",1024);h(this,"maxHeight",1024);h(this,"padding",2);h(this,"allowRotation",!1);h(this,"tightPacking",!1);h(this,"mipmap",!1);h(this,"filterMode",j.Bilinear);h(this,"wrapModeU",y.Repeat);h(this,"wrapModeV",y.Repeat);h(this,"anisoLevel",1);h(this,"sprites",[]);this.setNameByIncrease("SpriteAtlas");const s=this.formSchema;s.addGroup(F("sprite.atlas.packing"),["maxWidth","maxHeight","padding","allowRotation","tightPacking"]),s.addGroup(F("sprite.atlas.export"),["filterMode","wrapModeU","wrapModeV","anisoLevel","mipmap"]),s.addGroup(F("sprite.atlas.list"),["sprites"])}static async updateSubTextureAssets(t,s,r,a,i){var p;const n=t.meta,c=i.vfs,m=t.dependencies||(t.dependencies=[]),u=((p=m[s])==null?void 0:p.ref.refId)??se(),g=O(t.name).split(".")[0];m[s]||(m[s]={key:"atlasItems["+s+"].img",ref:{refId:u}});let b=c.getFileById(u),o;return b?o=b.meta:(o=Ae(u,L.getRegisteredAssetMeta(fe).type,a),i.addFile({name:g+"_image_"+s,assetId:u,url:null,parentId:t.parentId,main:null,meta:o}),b=c.getFileById(u),b.ignoreBundle=!0),o.colorDilate=n.colorDilate??!1,o.filterMode=n.filterMode??j.Bilinear,o.wrapModeU=n.wrapModeU??y.Repeat,o.wrapModeV=n.wrapModeV??y.Repeat,o.anisoLevel=n.anisoLevel??1,o.runtimeOptions=n.runtimeOptions??{},i.updateFile(u,{main:new Blob([r],{type:"image/png"}),meta:o}),await i.bundleSingleFile(b,a),b}replacePreview(t){this.previewImage=t;const s=this.previewTexture2D;this.previewTexture2D=new ae(this.engineObject.engine,t.width,t.height),this.previewTexture2D.setImageSource(t),s&&s.destroy(!0)}async afterDelete(){this.engineObject.destroy(!0);const{sprites:t,id:s}=this,r=this.root.assetStore,i=[...t].map(async n=>{var c;try{const u=await r.getAssetByRef(n);((c=u==null?void 0:u.belongToAtlas)==null?void 0:c.refId)===s&&await this.root.assetFacade.updateAssetProps(u.id,{belongToAtlas:null})}catch(m){console.warn(`[SpriteAtlasAsset] Failed to cleanup sprite relation: ${(n==null?void 0:n.refId)??"unknown"}`,m)}});await Promise.allSettled(i),t.length=0}addSprites(t){const s=he([...this.sprites,...t.map(a=>({refId:a.id}))],a=>a.refId),r=t.map(a=>this.root.assetFacade.updateAssetProps(a.id,{belongToAtlas:{refId:this.id}}));return r.push(this.root.assetFacade.updateAssetProps(this.id,{sprites:s})),Promise.all(r)}async initByMain(t){const{engine:s}=this,r=JSON.parse(await t.text());for(const i in r)this[i]=r[i];const a=new _(s);this.bindEngineObject(a),a.asset=this}async initByCreation(){this.setNameByIncrease("SpriteAtlas");const t=new _(this.engine);return this.bindEngineObject(t),t.asset=this,this.getMainData()}async _onDrop(t,s){this.dropping=!1,!this.sprites.find(r=>r.refId===s.id)&&await this.addSprites([s])}};v([w({info:"sprite.atlas.max-width.info",label:"sprite.atlas.max-width.label",type:S.Input}),x()],f.prototype,"maxWidth",2);v([w({info:"sprite.atlas.max-height.info",label:"sprite.atlas.max-height.label",type:S.Input}),x()],f.prototype,"maxHeight",2);v([w({info:"sprite.atlas.padding.info",label:"sprite.atlas.padding.label",type:S.Number,min:0,max:5,dragStep:1}),x()],f.prototype,"padding",2);v([w({info:"sprite.atlas.rotation.info",label:"sprite.atlas.rotation.label",type:S.Toggle}),x()],f.prototype,"allowRotation",2);v([w({info:"sprite.atlas.tight-packing.info",label:"sprite.atlas.tight-packing.label",type:S.Toggle}),x()],f.prototype,"tightPacking",2);v([w({label:"sprite.atlas.mipmap.label",type:S.Toggle}),x()],f.prototype,"mipmap",2);v([w({label:"sprite.atlas.filter-mode.label",type:S.Select,value:j.Bilinear,options:[{label:"sprite.atlas.filter-mode.point",value:j.Point},{label:"sprite.atlas.filter-mode.bilinear",value:j.Bilinear},{label:"sprite.atlas.filter-mode.trilinear",value:j.Trilinear}]}),x()],f.prototype,"filterMode",2);v([w({label:"sprite.atlas.wrap-mode-u.label",type:S.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:y.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:y.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:y.Mirror}]}),x()],f.prototype,"wrapModeU",2);v([w({label:"sprite.atlas.wrap-mode-v.label",type:S.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:y.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:y.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:y.Mirror}]}),x()],f.prototype,"wrapModeV",2);v([w({label:"sprite.atlas.aniso-level.label",type:S.Slider,dragStep:1,max:16,min:1}),x()],f.prototype,"anisoLevel",2);v([re({type:"methods",key:"addSprite"}),w({label:F("sprite.atlas.sprite-list.label"),customComponent:Se}),x()],f.prototype,"sprites",2);v([ie],f.prototype,"addSprites",1);f=v([oe({type:"SpriteAtlas",label:F("asset.sprite-atlas.title"),loaderType:"SpriteAtlas",extname:"atlas",importMenuConfig:{type:ne.Add},async bundle(e,t,s){var m;const r=s.vfs,a=e.content??await r.loadFile(e.id),i=JSON.parse(await a.text()),n=e.meta,c=e.dependencies||(e.dependencies=[]);if(n.ignorePack){const u=i.atlasItems;for(let g=0,b=u.length;g<b;g++){const o=i.atlasItems[g],p=await fetch(o.img).then(I=>I.arrayBuffer()),l=await f.updateSubTextureAssets(e,g,p,t,s);o.type=l.exportType,o.img="./"+O(l.path)}}else{const u=e.id,g=i.sprites;for(let o=g.length-1;o>=0;o--){const p=g[o].refId,l=r.getFileById(p);if(l){const I=l.content??await r.loadFile(l.id);((m=JSON.parse(await I.text()).belongToAtlas)==null?void 0:m.refId)!==u&&(g.splice(o,1),console.warn("Sprite.belongToAtlas is not equal to this asset."))}else g.splice(o,1),console.warn("SpriteAsset[refId:",p,"] not found")}const b=await ue(i,r);if(b.code===0){const o=b.info;for(const l in o)i[l]=o[l];const p=b.imageFiles;for(let l=0,I=p.length;l<I;l++){const A=await f.updateSubTextureAssets(e,l,p[l],t,s),M=i.atlasItems[l];M.type=A.exportType,M.img="./"+O(A.path)}}else{for(let o=0,p=c.length;o<p;o++){const l=c[o].ref.refId;r.deleteFile(l)}c.length=0}}return delete i.usage,delete i.allowRotation,delete i.maxHeight,delete i.maxWidth,delete i.padding,delete i.sprites,delete i.tightPacking,{content:new Blob([JSON.stringify(i)])}}})],f);const De=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAtlasAsset(){return f}},Symbol.toStringTag,{value:"Module"}));export{f as S,De as a,Ae as c};
@@ -1 +0,0 @@
1
- var f=Object.defineProperty;var y=(e,r,p)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):e[r]=p;var s=(e,r,p)=>(y(e,typeof r!="symbol"?r+"":r,p),p);import{p as d,C as a,s as m,aS as o,E as w}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";var C=Object.defineProperty,P=Object.getOwnPropertyDescriptor,c=(e,r,p,i)=>{for(var t=i>1?void 0:i?P(r,p):r,l=e.length-1,n;l>=0;l--)(n=e[l])&&(t=(i?n(r,p,t):n(t))||t);return i&&t&&C(r,p,t),t};class b extends w{constructor(){super(...arguments);s(this,"sprite",null);s(this,"color",{r:1,g:1,b:1,a:1});s(this,"drawMode",o.Simple)}}c([d({label:"sprite.renderer.sprite.label",info:"sprite.renderer.sprite.info",type:a.AssetPicker,assetType:"sprite",onChange:async(e,r,p)=>{e.sprite=p?p.getCurrentRef():null,await e.applyBoundPathChange("sprite",a.AssetPicker,e.sprite),e.emit("propertychange","sprite",p)}}),m()],b.prototype,"sprite",2);c([d({bindPath:"color",label:"sprite.renderer.color.label",info:"sprite.renderer.color.info",type:a.Color}),m()],b.prototype,"color",2);c([d({label:"sprite.renderer.draw-mode.label",info:"sprite.renderer.draw-mode.info",type:a.Select,bindPath:"drawMode",value:o.Simple,options:[{label:"sprite.renderer.draw-mode.simple",value:o.Simple},{label:"sprite.renderer.draw-mode.sliced",value:o.Sliced},{label:"sprite.renderer.draw-mode.tiled",value:o.Tiled}]}),m()],b.prototype,"drawMode",2);export{b as S};
@@ -1 +0,0 @@
1
- var u=Object.defineProperty;var b=(r,e,t)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>(b(r,typeof e!="symbol"?e+"":e,t),t);import{E as h,aP as f,p as m,C as y,s as c,l as P,g as v}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as C}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var g=Object.defineProperty,S=Object.getOwnPropertyDescriptor,o=(r,e,t,i)=>{for(var p=i>1?void 0:i?S(e,t):e,l=r.length-1,n;l>=0;l--)(n=r[l])&&(p=(i?n(e,t,p):n(p))||p);return i&&p&&g(e,t,p),p};let a=class extends h{constructor(e,t){super(e,t);s(this,"sprite",null);s(this,"alphaCutoff",.5);s(this,"influenceLayers",[f.Everything])}};o([m({label:"sprite.mask.sprite.label",info:"sprite.mask.sprite.info",type:y.AssetPicker,assetType:"sprite",bindPath:"sprite"}),c()],a.prototype,"sprite",2);o([m({label:"sprite.mask.alpha-cutoff.label",info:"sprite.mask.alpha-cutoff.info",dragStep:.01,min:0,max:1,type:y.Slider,bindPath:"alphaCutoff"}),c()],a.prototype,"alphaCutoff",2);o([c(P()),m({label:"sprite.mask.influence-layers.label",info:"sprite.mask.influence-layers.info",type:y.Select,...v([f.Nothing,f.Everything]),bindPath:"influenceLayers"})],a.prototype,"influenceLayers",2);a=o([C({type:"SpriteMask",componentsMenu:{group:"2D",label:"component.sprite-mask.title"}})],a);export{a as SpriteMaskComponent};
@@ -1 +0,0 @@
1
- var x=Object.defineProperty;var M=(i,t,e)=>t in i?x(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>(M(i,typeof t!="symbol"?t+"":t,e),e);import{aH as _,aK as C,aT as S,aU as w,aD as l,b7 as P,aJ as g,aY as y,aV as v,aQ as u,aP as m,C as o,p as c,s as h,l as O,g as I,f as j}from"./index-0a8702e2.js";import{u as R}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as H}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{c as b}from"./createOnModelChange-b57a0da8.js";import{S as k}from"./SpriteBaseComponent-f6f1731f.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";const B=_("div",{marginLeft:"5px"}),Y=_(C,{border:"1px solid $gray6",borderRadius:"$2",padding:"$0_5",color:"$gray11",cursor:"pointer"}),z=S(function(i){const t=i.data,{t:e}=w();return l.jsxs(Y,{align:"v",children:[t.loadingStatus==="loading"&&l.jsx(P,{size:"xs"}),t.loadingStatus==="success"&&l.jsx("img",{src:t.thumbnailUrl,alt:e("sprite.inspector.thumbnail"),width:"20px",height:"20px"}),l.jsxs(B,{children:[e("sprite.inspector.title"),"(",t.name,")"]})]})}),X=S(function(i){const[t,e]=g.useState(null),r=i.data,{assetStore:s,inspectorFacade:n}=R();return g.useEffect(()=>{s.getAssetByRef(r.sprite).then(f=>{e(f)})},[r.sprite]),l.jsxs(l.Fragment,{children:[l.jsx(y.List,{model:r,configs:r.formSchema.items,onModelChange:b("component",r.id,n,r)}),t?l.jsx(v,{nesting:!0,title:l.jsx(z,{data:t}),defaultOpen:!1,children:l.jsx(y.List,{model:t,configs:t.formSchema.items,onModelChange:b("asset",t.id,n,t)})}):null]})});var N=Object.defineProperty,E=Object.getOwnPropertyDescriptor,L=(i,t,e)=>t in i?N(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,d=(i,t,e,r)=>{for(var s=r>1?void 0:r?E(t,e):t,n=i.length-1,f;n>=0;n--)(f=i[n])&&(s=(r?f(t,e,s):f(s))||s);return r&&s&&N(t,e,s),s},T=(i,t,e)=>(L(i,typeof t!="symbol"?t+"":t,e),e);let a=class extends k{constructor(t,e){super(t,e);p(this,"width",0);p(this,"height",0);p(this,"flip",[]);p(this,"maskInteraction",u.None);p(this,"maskLayer",[m.Everything]);p(this,"material",{refId:a._internalSpriteMaterialRefId});p(this,"priority",0);p(this,"_customWidth");p(this,"_customHeight");this.on("propertychange",(r,s)=>{if(r==="sprite"){const n=this.engineObject;isNaN(this._customWidth)?this.width=n.width:(this.width=this._customWidth,this.applyBoundPathChange("width",o.Number,this._customWidth)),isNaN(this._customHeight)?this.height=n.height:(this.height=this._customHeight,this.applyBoundPathChange("height",o.Number,this._customHeight))}})}async applyBoundPathChange(t,e,r){if(t==="flip"){const s=Array.isArray(r)?r:[];await super.applyBoundPathChange("flipX",o.Toggle,s.includes("flipX")),await super.applyBoundPathChange("flipY",o.Toggle,s.includes("flipY"));return}await super.applyBoundPathChange(t,e,r)}deserializeByEngineObject(t){var r;super.deserializeByEngineObject(t);const e=[];t.flipX&&e.push("flipX"),t.flipY&&e.push("flipY"),this.flip=e,(r=this._originValueMap)==null||r.set("flip",[...e])}deserialize(t){super.deserialize(t);const{props:e}=t;e!=null&&e.flipX&&this.flip.push("flipX"),e!=null&&e.flipY&&this.flip.push("flipY"),isNaN(e==null?void 0:e.width)||(this._customWidth=e.width),isNaN(e==null?void 0:e.height)||(this._customHeight=e.height)}toJSON(){const t=super.toJSON(),e=this.flip;return e&&(t.props.flipX=e.indexOf("flipX")!==-1,t.props.flipY=e.indexOf("flipY")!==-1),isNaN(this._customWidth)||(t.props.width=this._customWidth),isNaN(this._customHeight)||(t.props.height=this._customHeight),t}};T(a,"_internalSpriteMaterialRefId","0000203");d([c({label:"sprite.renderer.width.label",info:"sprite.renderer.width.info",type:o.Number,bindPath:"width",triggerAfterInit:!1,onChange(i,t,e){isNaN(e)||(i._customWidth=e)}}),h()],a.prototype,"width",2);d([c({label:"sprite.renderer.height.label",info:"sprite.renderer.height.info",type:o.Number,bindPath:"height",triggerAfterInit:!1,onChange(i,t,e){isNaN(e)||(i._customHeight=e)}}),h()],a.prototype,"height",2);d([c({label:"sprite.renderer.flip.label",info:"sprite.renderer.flip.info",type:o.ToggleGroup,bindPath:"flip",multiple:!0,options:[{label:"sprite.renderer.flip.x",value:"flipX"},{label:"sprite.renderer.flip.y",value:"flipY"}]}),h()],a.prototype,"flip",2);d([c({label:"sprite.renderer.mask-interaction.label",info:"sprite.renderer.mask-interaction.info",type:o.Select,bindPath:"maskInteraction",value:u.None,options:[{label:"sprite.renderer.mask-interaction.none",value:u.None},{label:"sprite.renderer.mask-interaction.visible-inside",value:u.VisibleInsideMask},{label:"sprite.renderer.mask-interaction.visible-outside",value:u.VisibleOutsideMask}]}),h()],a.prototype,"maskInteraction",2);d([h(O()),c({label:"sprite.renderer.mask-layer.label",info:"sprite.renderer.mask-layer.info",type:o.Select,...I([m.Nothing,m.Everything]),bindPath:"maskLayer"}),h()],a.prototype,"maskLayer",2);d([c({label:"sprite.renderer.material.label",info:"sprite.renderer.material.info",type:o.AssetPicker,assetType:"Material",customFilter:i=>{var t;return((t=i.engineObject.shader)==null?void 0:t.name)!=="particle-shader"},onChange:async(i,t,e)=>{const{material:r}=i,s=i.engineObject;if(!r){s.setMaterial(null);return}const{refId:n}=r;n===a._internalSpriteMaterialRefId?s.setMaterial(s.engine._basicResources.spriteDefaultMaterial):e?i.engineObject.setMaterial(e.engineObject):console.error(`Material asset not found: ${r.refId}`)}}),j({engineKey:"setMaterial",getEngineValue:i=>i.getMaterial()}),h({type:"methods",key:"setMaterial",onSerialize:i=>i?[[i]]:void 0,onDeserialize(i){return i?i[0][0]:void 0}})],a.prototype,"material",2);d([c({label:"sprite.renderer.priority.label",info:"sprite.renderer.priority.info",type:o.Number,bindPath:"priority"}),h()],a.prototype,"priority",2);a=d([H({type:"SpriteRenderer",componentsMenu:{group:"2D",label:"component.renderer.sprite.title"},customInspector:X})],a);export{a as SpriteRendererComponent};
@@ -1 +0,0 @@
1
- var c=Object.defineProperty;var x=(r,e,t)=>e in r?c(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>(x(r,typeof e!="symbol"?e+"":e,t),t);import{aQ as p,aP as h,p as l,C as s,s as m,g as f,l as u}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as v}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{T as k}from"./TextBaseComponent-69233798.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var g=Object.defineProperty,P=Object.getOwnPropertyDescriptor,a=(r,e,t,d)=>{for(var i=d>1?void 0:d?P(e,t):e,b=r.length-1,y;b>=0;b--)(y=r[b])&&(i=(d?y(e,t,i):y(i))||i);return d&&i&&g(e,t,i),i};let n=class extends k{constructor(e,t){super(e,t);o(this,"width",0);o(this,"height",0);o(this,"maskInteraction",p.None);o(this,"maskLayer",[h.Layer0]);o(this,"priority",0)}};a([l({label:"text-renderer.width.label",info:"text-renderer.width.info",type:s.Number,bindPath:"width"}),m()],n.prototype,"width",2);a([l({label:"text-renderer.height.label",info:"text-renderer.height.info",type:s.Number,bindPath:"height"}),m()],n.prototype,"height",2);a([l({label:"text-renderer.mask-interaction.label",info:"text-renderer.mask-interaction.info",type:s.Select,bindPath:"maskInteraction",value:p.None,options:[{label:"text-renderer.mask-interaction.none",value:p.None},{label:"text-renderer.mask-interaction.visible-inside",value:p.VisibleInsideMask},{label:"text-renderer.mask-interaction.visible-outside",value:p.VisibleOutsideMask}]}),m()],n.prototype,"maskInteraction",2);a([l({label:"text-renderer.mask-layer.label",info:"text-renderer.mask-layer.info",type:s.Select,bindPath:"maskLayer",...f([h.Nothing,h.Everything])}),m(u())],n.prototype,"maskLayer",2);a([l({label:"text-renderer.priority.label",info:"text-renderer.priority.info",type:s.Number,bindPath:"priority"}),m()],n.prototype,"priority",2);n=a([v({type:"TextRenderer",componentsMenu:{group:"2D",label:"component.text-renderer.title"}})],n);export{n as TextRendererComponent};