@galacean/cli 2.0.0-alpha.27 → 2.0.0-alpha.28

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 (96) hide show
  1. package/dist/cli.bundle.cjs +51489 -14885
  2. package/dist/preview-client/_static/{Accordion-4afac60c.js → Accordion-6f002a96.js} +1 -1
  3. package/dist/preview-client/_static/{AmbientLightAsset-3825f3bf.js → AmbientLightAsset-57a59fc2.js} +2 -2
  4. package/dist/preview-client/_static/{AnimationClipAsset-660ecb36.js → AnimationClipAsset-0a1f63eb.js} +1 -1
  5. package/dist/preview-client/_static/{AnimatorControllerAsset-dcf11a9d.js → AnimatorControllerAsset-9192e596.js} +1 -1
  6. package/dist/preview-client/_static/{AnimatorStore-aa58d85c.js → AnimatorStore-484b10cf.js} +1 -1
  7. package/dist/preview-client/_static/{AssetViewer-8338dfe1.js → AssetViewer-9f395efb.js} +1 -1
  8. package/dist/preview-client/_static/{AudioAsset-6e607154.js → AudioAsset-0ea4ba7b.js} +1 -1
  9. package/dist/preview-client/_static/{AudioComponent-b70cc31e.js → AudioComponent-9bf5944c.js} +1 -1
  10. package/dist/preview-client/_static/{Callout-155c30df.js → Callout-45631a14.js} +1 -1
  11. package/dist/preview-client/_static/{CameraComponent-76bc9102.js → CameraComponent-039457d1.js} +1 -1
  12. package/dist/preview-client/_static/{Component-398551a0.js → Component-c3c0c167.js} +1 -1
  13. package/dist/preview-client/_static/{DirectLight-50653e81.js → DirectLight-7b1f4b9f.js} +1 -1
  14. package/dist/preview-client/_static/{FontAsset-dc385d41.js → FontAsset-10273d05.js} +2 -2
  15. package/dist/preview-client/_static/{FormItemArray-9ca61884.js → FormItemArray-9d4196d8.js} +2 -2
  16. package/dist/preview-client/_static/{GlTFAsset-d2ee4f95.js → GlTFAsset-917bf1ee.js} +5 -5
  17. package/dist/preview-client/_static/{IconPlus-b3ed4c04.js → IconPlus-2bfc60da.js} +1 -1
  18. package/dist/preview-client/_static/{IconPointFilled-3ba6d082.js → IconPointFilled-192e99c9.js} +1 -1
  19. package/dist/preview-client/_static/{LightBaseComponent-4cfc9f48.js → LightBaseComponent-948d3192.js} +1 -1
  20. package/dist/preview-client/_static/{LottieAnimationComponent-aeb555ea.js → LottieAnimationComponent-da226765.js} +1 -1
  21. package/dist/preview-client/_static/{MarkdownAsset-02477e7c.js → MarkdownAsset-602f93bf.js} +1 -1
  22. package/dist/preview-client/_static/MaterialAsset-aa93db51.js +1 -0
  23. package/dist/preview-client/_static/{MaterialInspector-3fb471d9.js → MaterialInspector-45e208c7.js} +1 -1
  24. package/dist/preview-client/_static/Menu-beacc39d.js +17 -0
  25. package/dist/preview-client/_static/MeshAsset-585f4b18.js +1 -0
  26. package/dist/preview-client/_static/{MeshRendererBaseComponent-cd8b743b.js → MeshRendererBaseComponent-0bc9f5b3.js} +1 -1
  27. package/dist/preview-client/_static/{MeshRendererComponent-17a7fc72.js → MeshRendererComponent-84208d23.js} +1 -1
  28. package/dist/preview-client/_static/{MeshThumbnail-8c20ee92.js → MeshThumbnail-9bbe01dc.js} +1 -1
  29. package/dist/preview-client/_static/ParticleRendererComponent-f3ac8d1b.js +26 -0
  30. package/dist/preview-client/_static/{PhysicsMaterialAsset-e0491877.js → PhysicsMaterialAsset-2dd013f8.js} +1 -1
  31. package/dist/preview-client/_static/{PhysicsStore-ab32886e.js → PhysicsStore-fcb01282.js} +1 -1
  32. package/dist/preview-client/_static/{PointLight-97975350.js → PointLight-d9ace100.js} +1 -1
  33. package/dist/preview-client/_static/{PostProcessComponent-9590ec29.js → PostProcessComponent-2b5255d9.js} +3 -3
  34. package/dist/preview-client/_static/PrefabAsset-8c923465.js +1 -0
  35. package/dist/preview-client/_static/{PrimitiveMesh-0492d482.js → PrimitiveMesh-fde624a6.js} +1 -1
  36. package/dist/preview-client/_static/{ReferencedMaterial-49a7cbcc.js → ReferencedMaterial-890492a2.js} +1 -1
  37. package/dist/preview-client/_static/{RenderTargetAsset-dc1f9494.js → RenderTargetAsset-bf38a725.js} +1 -1
  38. package/dist/preview-client/_static/SceneAsset-7a9dbdd8.js +1 -0
  39. package/dist/preview-client/_static/{ShaderAsset-f4eead79.js → ShaderAsset-2f2c1e95.js} +1 -1
  40. package/dist/preview-client/_static/{ShaderChunkAsset-4bea2733.js → ShaderChunkAsset-a3ff3959.js} +2 -2
  41. package/dist/preview-client/_static/{ShaderUIScriptAsset-3c731f3b.js → ShaderUIScriptAsset-d3a2d680.js} +2 -2
  42. package/dist/preview-client/_static/{SkinnedMeshRendererComponent-e0f9b133.js → SkinnedMeshRendererComponent-96740600.js} +1 -1
  43. package/dist/preview-client/_static/{SpineAnimationComponent-1e1655fd.js → SpineAnimationComponent-3d4eec48.js} +1 -1
  44. package/dist/preview-client/_static/{SpineSkeletonDataAsset-afb4afae.js → SpineSkeletonDataAsset-a8598103.js} +1 -1
  45. package/dist/preview-client/_static/{SpotLight-69f361c9.js → SpotLight-680a6e17.js} +1 -1
  46. package/dist/preview-client/_static/{SpriteBaseComponent-2c2454ea.js → SpriteBaseComponent-96a500d7.js} +1 -1
  47. package/dist/preview-client/_static/{SpriteMaskComponent-a7ebcc50.js → SpriteMaskComponent-58c35ea2.js} +1 -1
  48. package/dist/preview-client/_static/{SpriteRendererComponent-f7604c68.js → SpriteRendererComponent-5c89f7dd.js} +1 -1
  49. package/dist/preview-client/_static/{TextBaseComponent-cd7ad9f7.js → TextBaseComponent-248ea222.js} +3 -3
  50. package/dist/preview-client/_static/{TextRendererComponent-a5357d52.js → TextRendererComponent-78458825.js} +1 -1
  51. package/dist/preview-client/_static/{TextureAsset-ff089b5a.js → TextureAsset-bf69040b.js} +4 -4
  52. package/dist/preview-client/_static/Tooltip-0268ffac.js +1 -0
  53. package/dist/preview-client/_static/{TrailRendererComponent-cdefa368.js → TrailRendererComponent-838e0118.js} +1 -1
  54. package/dist/preview-client/_static/{TransformBaseComponent-d26ff236.js → TransformBaseComponent-c92aa259.js} +1 -1
  55. package/dist/preview-client/_static/{TransformComponent-4ec4b7b5.js → TransformComponent-d28b4035.js} +1 -1
  56. package/dist/preview-client/_static/{XRReferenceImageAsset-ff82ab30.js → XRReferenceImageAsset-16071f5c.js} +1 -1
  57. package/dist/preview-client/_static/{audio-0a013eb6.js → audio-1d573775.js} +1 -1
  58. package/dist/preview-client/_static/{createOnModelChange-89f572a6.js → createOnModelChange-38471bb6.js} +1 -1
  59. package/dist/preview-client/_static/{createReactComponent-baa41397.js → createReactComponent-3e49f864.js} +1 -1
  60. package/dist/preview-client/_static/index-0a57ae09.js +1 -0
  61. package/dist/preview-client/_static/{index-a0afef01.js → index-1d0ae2e4.js} +1 -1
  62. package/dist/preview-client/_static/{index-5e4dedda.js → index-1fa3ba70.js} +1 -1
  63. package/dist/preview-client/_static/index-2c567b8d.js +1 -0
  64. package/dist/preview-client/_static/{index-29916a80.js → index-2f54d4c9.js} +1 -1
  65. package/dist/preview-client/_static/{index-70967035.js → index-4084db44.js} +1 -1
  66. package/dist/preview-client/_static/index-5c27dafa.js +1 -0
  67. package/dist/preview-client/_static/{index-8784a43a.js → index-65c6af4a.js} +3 -3
  68. package/dist/preview-client/_static/{index-cd09e78a.js → index-68806c86.js} +1 -1
  69. package/dist/preview-client/_static/{index-c8ed2a45.js → index-8a22fe59.js} +1 -1
  70. package/dist/preview-client/_static/{index-d1484803.js → index-9e3daa94.js} +1 -1
  71. package/dist/preview-client/_static/index-bdda02cf.js +1 -0
  72. package/dist/preview-client/_static/index-c88f78ce.js +1 -0
  73. package/dist/preview-client/_static/{index-4845b67c.js → index-ce381b62.js} +3 -3
  74. package/dist/preview-client/_static/{index-b126bb6b.js → index-d497fb6d.js} +219 -180
  75. package/dist/preview-client/_static/index-e4fb05d8.js +1 -0
  76. package/dist/preview-client/_static/{ktx2-encoder-8498815e.js → ktx2-encoder-772f6c33.js} +1 -1
  77. package/dist/preview-client/_static/{module-83a57161.js → module-136992e3.js} +1 -1
  78. package/dist/preview-client/_static/{module-113ac03a.js → module-1470d524.js} +1 -1
  79. package/dist/preview-client/_static/{module-8efda49c.js → module-77c2ea8c.js} +1 -1
  80. package/dist/preview-client/_static/{postmen-3b48c572.js → postmen-0413c689.js} +1 -1
  81. package/dist/preview-client/_static/{shader-data-utils-c90e48b8.js → shader-data-utils-e38a959d.js} +1 -1
  82. package/dist/preview-client/index.html +1 -1
  83. package/package.json +1 -1
  84. package/dist/preview-client/_static/MaterialAsset-8f3b3302.js +0 -1
  85. package/dist/preview-client/_static/Menu-36c201c0.js +0 -17
  86. package/dist/preview-client/_static/MeshAsset-3ddf1ac6.js +0 -1
  87. package/dist/preview-client/_static/ParticleRendererComponent-1834a159.js +0 -26
  88. package/dist/preview-client/_static/PrefabAsset-2f94de73.js +0 -1
  89. package/dist/preview-client/_static/SceneAsset-c3bb667f.js +0 -1
  90. package/dist/preview-client/_static/Tooltip-1bcb87b5.js +0 -1
  91. package/dist/preview-client/_static/index-0086cabc.js +0 -1
  92. package/dist/preview-client/_static/index-253f9e13.js +0 -1
  93. package/dist/preview-client/_static/index-8234e4e2.js +0 -1
  94. package/dist/preview-client/_static/index-94594d06.js +0 -1
  95. package/dist/preview-client/_static/index-ad57c6c8.js +0 -1
  96. package/dist/preview-client/_static/index-f7fcda86.js +0 -1
@@ -1 +1 @@
1
- var pe=Object.defineProperty;var de=(o,e,t)=>e in o?pe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(de(o,typeof e!="symbol"?e+"":e,t),t);import{aJ as j,aK as z,av as l,bm as X,cn as P,bk as se,eF as I,ds as re,bA as ye,q as me,cC as K,eG as $,eH as G,eI as L,eJ as J,bI as N,f as he,aE as ue,s as y,p as m,e as r,E as ae,eK as W,eL as S,eM as B,C as h,eN as Y,eO as fe,eP as Z,e2 as le,eQ as be,eR as ge,bq as Ce,cA as Q,bs as xe,bt as Se}from"./index-b126bb6b.js";import{r as H}from"./index-c8ed2a45.js";import{c as F}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{F as Pe}from"./FormItemArray-9ca61884.js";const je={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 ve(o){const e={};return Object.keys(o.props).forEach(t=>{je[o.class].includes(t)&&(e[t]=o.props[t])}),e}const ze=async(o,e,t)=>{const i=o.engineObject,n=i.shapes;if(n.length===t.length&&t.every((s,a)=>Oe(s.class,n[a]))){for(let s=0;s<t.length;s++)await k(n[s],t[s]),ee(n[s],t[s]);return}i.clearShapes();for(let s=0;s<t.length;s++){const a=t[s],d=_e(a);await k(d,a),ee(d,a),i.addShape(d)}};async function k(o,e){const t=e.props.material;if(t!=null&&t.refId)try{const i=await H.assetStore.getAssetByRef(t);i!=null&&i.engineObject&&(o.material=i.engineObject)}catch(i){console.error(i)}}function Oe(o,e){switch(o){case"BoxColliderShape":return e instanceof J;case"CapsuleColliderShape":return e instanceof L;case"PlaneColliderShape":return e instanceof G;case"SphereColliderShape":return e instanceof $;default:return!1}}function _e(o){switch(o.class){case"BoxColliderShape":return new J;case"CapsuleColliderShape":return new L;case"PlaneColliderShape":return new G;case"SphereColliderShape":return new $}}function ee(o,e){const t=e.props;if(o instanceof J&&t.size){const s=o.size;s.copyFrom(t.size),o.size=s}else o instanceof L?(t.radius!==void 0&&(o.radius=t.radius),t.height!==void 0&&(o.height=t.height),t.upAxis!==void 0&&(o.upAxis=t.upAxis)):o instanceof $&&t.radius!==void 0&&(o.radius=t.radius);o.isTrigger=t.isTrigger;const i=o.position;i.copyFrom(t.position),o.position=i;const n=o.rotation;n.copyFrom(t.rotation),o.rotation=n}const De=o=>o.map(e=>{if(e instanceof J)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 L)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 G)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 $)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}}}}),Ae=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(X,{label:t("physics.shape.box.size.title"),info:t("physics.shape.box.size.info"),min:0,value:{x:o.props.size.x,y:o.props.size.y,z:o.props.size.z},onChange:(i,n)=>{const s=i==null?void 0:i[n];typeof s=="number"&&e(a=>{a.props.size={...a.props.size,[n]:s}})}})})}),Te=j(()=>l.jsx(l.Fragment,{})),we=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(P,{label:t("physics.shape.sphere.radius.title"),info:t("physics.shape.sphere.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}})})}),Me=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsxs(l.Fragment,{children:[l.jsx(P,{label:t("physics.shape.capsule.radius.title"),info:t("physics.shape.capsule.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}}),l.jsx(P,{label:t("physics.shape.capsule.height.title"),info:t("physics.shape.capsule.height.info"),value:o.props.height,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.height=i})}}),l.jsx(se,{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:o.props.upAxis,onChange:i=>{e(n=>{n.props.upAxis=i})}})]})}),Fe={BoxColliderShape:Ae,CapsuleColliderShape:Me,PlaneColliderShape:Te,SphereColliderShape:we},q={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}}}},Ve=j(({item:o,onItemChange:e})=>{var d;const{t}=z(),i=Fe[o.class],n=H.assetStore,s=Object.values(n.assets).filter(c=>c.getMetaConfig().type==="PhysicsMaterial"),a=n.assets[(d=o.props.material)==null?void 0:d.refId];return l.jsxs(l.Fragment,{children:[l.jsx(re,{label:t("physics.collider.trigger.title"),info:t("physics.collider.trigger.info"),value:o.props.isTrigger,onChange:c=>{e(f=>{f.props.isTrigger=c})}}),l.jsx(ye,{label:t("physics.collider.material.title"),info:t("physics.collider.material.info"),dropLayer:me.PhysicsMaterial,value:a==null?void 0:a.name,assets:s,onSelect:c=>{e(f=>{f.props.material=c.getCurrentRef()})},onLocate:()=>{a&&a.id&&n.selectAsset(a.id)}}),l.jsx(i,{item:o,onItemChange:e}),l.jsx(X,{label:t("physics.collider.local-position.title"),info:t("physics.collider.local-position.info"),value:{x:o.props.position.x,y:o.props.position.y,z:o.props.position.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.position={...b.props.position,[f]:u}})}}),l.jsx(X,{label:t("physics.collider.rotation.title"),info:t("physics.collider.rotation.info"),value:{x:o.props.rotation.x,y:o.props.rotation.y,z:o.props.rotation.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.rotation={...b.props.rotation,[f]:u}})}})]})}),Be=j(({collider:o,item:e,index:t,onModelChange:i})=>{const{t:n}=z(),s=[{label:n("physics.shape.box.title"),value:"BoxColliderShape"},{label:n("physics.shape.capsule.title"),value:"CapsuleColliderShape"}];o.engineObject instanceof K||(s.push({label:n("physics.shape.plane.title"),value:"PlaneColliderShape"}),s.push({label:n("physics.shape.sphere.title"),value:"SphereColliderShape"}));const d=c=>{const f=o.colliderShapes,u=N(f),b=u[t];b&&(c(b),i==null||i("colliderShapes",u))};return l.jsxs(l.Fragment,{children:[l.jsx(se,{label:n("physics.shape.type.title"),info:n("physics.shape.type.info"),value:e.class,options:s,onChange:c=>{q[c].class!==e.class&&d(u=>{Object.assign(u,N(q[c]))})}}),l.jsx(Ve,{item:e,onItemChange:d})]})}),Ee=j(({model:o,inspectorConfig:e,onModelChange:t})=>{const{label:i}=e,n=o.colliderShapes,{t:s}=z(),a=d=>{const c=N(n);d(c),t==null||t("colliderShapes",c)};return l.jsx(Pe,{label:i,items:n.map((d,c)=>({removable:!0,children:l.jsx(Be,{collider:o,item:d,index:c,onModelChange:t}),id:`${c}`,name:s("physics.shape.item-name",{index:c})})),addable:!0,onAdd:()=>{a(d=>{d.push(N(q.BoxColliderShape))})},onDelete:d=>{a(c=>{c.splice(+d.id,1)})},addItemText:s("physics.shape.add")})});var Ie=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ne(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ie(e,t,n),n};class R extends ae{constructor(){super(...arguments);p(this,"colliderShapes",[])}}$e([he({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:ue.Object,getEngineValue:o=>o.shapes,getEditorValue:De}),y({type:"methods",key:"colliderShapes",canonicalizeToProps:!0,onSerialize:o=>o.map(e=>({$type:e.class,...ve(e)})),onDeserialize:o=>o.map(e=>{const{$type:t,...i}=e;return{class:t,props:i}})}),m({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Ee,onChange:ze})],R.prototype,"colliderShapes",2);var Le=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Re=(o,e,t,i)=>{for(var n=i>1?void 0:i?Je(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Le(e,t,n),n};let te=class extends R{constructor(o,e){super(o,e)}};te=Re([F({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],te);const ie=o=>Object.keys(S).filter(e=>(o&S[e])!==0).map(e=>String(S[e])),Xe=j(({model:o,onModelChange:e})=>{const t=n=>{const a=n.map(d=>parseInt(d)).reduce((d,c)=>d|c,S.None);e==null||e("constraints",a)},{t:i}=z();return l.jsxs(l.Fragment,{children:[l.jsx(W,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:t}),l.jsx(W,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:t})]})});var Ke=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,C=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ye(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ke(e,t,n),n};let g=class extends R{constructor(e,t){super(e,t);p(this,"isKinematic",!1);p(this,"collisionDetectionMode",B.Discrete);p(this,"constraints",S.None);p(this,"mass",1);p(this,"useGravity",!0);p(this,"linearDamping",0);p(this,"angularDamping",.05);p(this,"automaticCenterOfMass",!0);p(this,"centerOfMass",{x:0,y:0,z:0});p(this,"automaticInertiaTensor",!0);p(this,"inertiaTensor",{x:1,y:1,z:1});p(this,"linearVelocity",{x:0,y:0,z:0});p(this,"angularVelocity",{x:0,y:0,z:0});p(this,"maxAngularVelocity",100);p(this,"maxDepenetrationVelocity",10000000331813535e16);p(this,"sleepThreshold",.005);p(this,"solverIterations",4)}onEnabled(){this._applyEditorRuntimeState()}onInitComplete(){this._applyEditorRuntimeState()}rebindEngineObject(e){super.rebindEngineObject(e),this._applyEditorRuntimeState()}_applyEditorRuntimeState(){this.applyBoundPathChange("enabled",h.Toggle,!1)}};C([y(),m({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:h.Boolean,bindPath:"isKinematic"})],g.prototype,"isKinematic",2);C([y(),m({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:h.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:B.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:B.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:B.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:B.ContinuousSpeculative}]})],g.prototype,"collisionDetectionMode",2);C([y(),m({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:Xe,bindPath:"constraints"})],g.prototype,"constraints",2);C([y(),m({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:h.Number})],g.prototype,"mass",2);C([y(),m({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:h.Boolean})],g.prototype,"useGravity",2);C([y(),m({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:h.Number})],g.prototype,"linearDamping",2);C([y(),m({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:h.Number})],g.prototype,"angularDamping",2);C([y(),m({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.centerOfMass;o.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticCenterOfMass",2);C([y(),m({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:h.Vector3,bindPath:"centerOfMass",when:o=>!o.automaticCenterOfMass})],g.prototype,"centerOfMass",2);C([y(),m({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.inertiaTensor;o.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticInertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:h.Vector3,bindPath:"inertiaTensor",when:o=>!o.automaticInertiaTensor})],g.prototype,"inertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:h.Vector3,bindPath:"linearVelocity"})],g.prototype,"linearVelocity",2);C([y(),m({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:h.Vector3,bindPath:"angularVelocity"})],g.prototype,"angularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:h.Number})],g.prototype,"maxAngularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:h.Number})],g.prototype,"maxDepenetrationVelocity",2);C([y(),m({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:h.Number})],g.prototype,"sleepThreshold",2);C([y(),m({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:h.Slider})],g.prototype,"solverIterations",2);g=C([F({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],g);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,E=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ge(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&qe(e,t,n),n};let M=class extends R{constructor(e,t){super(e,t);p(this,"stepOffset",.5);p(this,"upDirection",{x:0,y:1,z:0});p(this,"slopeLimit",45);p(this,"nonWalkableMode",Y.PreventClimbing)}async bindEngineObject(e){await super.bindEngineObject(e),e.enabled=!1}rebindEngineObject(e){super.rebindEngineObject(e),e.enabled=!1}};E([y(),m({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:h.Number})],M.prototype,"stepOffset",2);E([y(),m({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:h.Vector3,bindPath:"upDirection"})],M.prototype,"upDirection",2);E([y(),m({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:h.Number})],M.prototype,"slopeLimit",2);E([y(),m({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:h.Select,options:[{label:r("physics.character.non-walkable-mode.prevent-climbing"),value:Y.PreventClimbing},{label:r("physics.character.non-walkable-mode.prevent-climbing-and-force-sliding"),value:Y.PreventClimbingAndForceSliding}]})],M.prototype,"nonWalkableMode",2);M=E([F({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],M);const Ze=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,disabled:a,info:d}=e,{ownerId:c}=t[n]||{},f=c&&o.model.root.sceneStore.getEntityModel(c),u=O=>{const _=O?H.sceneStore.getEntityModel(O):null,U=(_==null?void 0:_.getComponentByTypeName("DynamicCollider"))||(_==null?void 0:_.getComponentByTypeName("StaticCollider")),ce=U?{ownerId:O,componentId:U.id}:null;i==null||i(n,ce)},{t:b}=z(),x=Array.from(t.root.sceneStore.iterateEntityModels(),([,O])=>O);return l.jsx(l.Fragment,{children:l.jsx(fe,{label:b(s),info:b(d),entities:x,value:c,disabled:a,customFilter:O=>{let _=null;return t.entityModelId!==O.id&&(_=O.getComponentByTypeName("DynamicCollider")||O.getComponentByTypeName("StaticCollider")),_},displayValue:f==null?void 0:f.name,placeholder:b("physics.collider-picker.placeholder"),onSelect:u,onLocate:()=>{o.model.root.sceneStore.selectEntity(c)},onDelete:()=>{u(null)}})})});var He=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,A=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ue(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&He(e,t,n),n};class v extends ae{constructor(){super(...arguments);p(this,"connectedCollider",null);p(this,"anchor",{x:0,y:0,z:0});p(this,"automaticConnectedAnchor",!0);p(this,"connectedAnchor",{x:0,y:0,z:0});p(this,"breakForce",Number.MAX_VALUE);p(this,"breakTorque",Number.MAX_VALUE);p(this,"massScale",1);p(this,"connectedMassScale",1)}async applyBoundPathChange(t,i,n){var s,a;if(t==="connectedCollider"){const d=n,c=((a=(s=this.root.sceneStore.getEntityModel(d==null?void 0:d.ownerId))==null?void 0:s.getComponentById(d==null?void 0:d.componentId))==null?void 0:a.engineObject)??null;await super.applyBoundPathChange(t,i,c);return}await super.applyBoundPathChange(t,i,n)}}A([y(),m({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:Ze,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);A([y(),m({label:r("physics.joint.anchor.title"),type:h.Vector3,bindPath:"anchor",onChange(o,e,t){if(o.automaticConnectedAnchor){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);A([y(),m({label:r("physics.joint.automatic-connected-anchor.title"),type:h.Boolean,bindPath:"automaticConnectedAnchor",onChange(o,e,t){if(t){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);A([y(),m({label:r("physics.joint.connected-anchor.title"),type:h.Vector3,bindPath:"connectedAnchor",when:o=>!o.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);A([y(),m({label:r("physics.joint.break-force.title"),type:h.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);A([y(),m({label:r("physics.joint.break-torque.title"),type:h.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);A([y(),m({label:r("physics.joint.mass-scale.title"),type:h.Number,bindPath:"massScale"})],v.prototype,"massScale",2);A([y(),m({label:r("physics.joint.connected-mass-scale.title"),type:h.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var We=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,ke=(o,e,t,i)=>{for(var n=i>1?void 0:i?Qe(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&We(e,t,n),n};let oe=class extends v{constructor(o,e){super(o,e)}};oe=ke([F({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],oe);const et=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useLimits,c=t.useSpring,f=t[n],u=f.props,{t:b}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:b(s),info:b(a),children:[l.jsx(P,{label:b("physics.joint-limits.min"),value:u.min,onChange:x=>{u.max<x&&(u.max=x),u.min=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.max"),value:u.max,onChange:x=>{x<u.min&&(x=u.min),u.max=x,i(n,f)}}),c?l.jsxs(l.Fragment,{children:[l.jsx(P,{label:b("physics.joint-limits.stiffness"),value:u.stiffness,onChange:x=>{u.stiffness=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.damping"),value:u.damping,onChange:x=>{u.damping=x,i(n,f)}})]}):l.jsx(P,{label:b("physics.joint-limits.contact-distance"),value:u.contactDistance,onChange:x=>{u.contactDistance=x,i(n,f)}})]}):null})}),tt=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useMotor,c=t[n],f=c.props,{t:u}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:u(s),info:u(a),children:[l.jsx(P,{label:u("physics.joint-motor.target-velocity"),value:f.targetVelocity,onChange:b=>{f.targetVelocity=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.force-limit"),value:f.forceLimit,onChange:b=>{f.forceLimit=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.gear-ratio"),value:f.gearRatio,onChange:b=>{f.gearRatio=b,i(n,c)}}),l.jsx(re,{label:u("physics.joint-motor.free-spin"),value:f.freeSpin,onChange:b=>{f.freeSpin=b,i(n,c)}})]}):null})});var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,w=(o,e,t,i)=>{for(var n=i>1?void 0:i?ot(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&it(e,t,n),n};let D=class extends v{constructor(e,t){super(e,t);p(this,"axis",{x:1,y:0,z:0});p(this,"useLimits",!1);p(this,"useSpring",!1);p(this,"limits",{class:"JointLimits",props:{max:0,min:0,contactDistance:-1,stiffness:0,damping:0}});p(this,"useMotor",!1);p(this,"motor",{class:"JointMotor",props:{targetVelocity:0,forceLimit:Number.MAX_VALUE,gearRatio:1,freeSpin:!1}})}async applyBoundPathChange(e,t,i){if(e==="limits"){const n=this._buildLimitsFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}if(e==="motor"){const n=this._buildMotorFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}await super.applyBoundPathChange(e,t,i)}_buildLimitsFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new be;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 ge;return i.targetVelocity=t.targetVelocity,i.forceLimit=t.forceLimit,i.gearRatio=t.gearRatio,i.freeSpin=t.freeSpin,i}};w([y(),m({label:r("physics.hinge-joint.axis.title"),type:h.Vector3,bindPath:"axis"})],D.prototype,"axis",2);w([y(),m({label:r("physics.hinge-joint.use-limits.title"),type:h.Boolean,bindPath:"useLimits"})],D.prototype,"useLimits",2);w([y(),m({label:r("physics.hinge-joint.use-spring.title"),type:h.Boolean,bindPath:"useSpring"})],D.prototype,"useSpring",2);w([y(),m({label:r("physics.hinge-joint.limits.title"),customComponent:et,bindPath:"limits"})],D.prototype,"limits",2);w([y(),m({label:r("physics.hinge-joint.use-motor.title"),type:h.Boolean,bindPath:"useMotor"})],D.prototype,"useMotor",2);w([y(),m({label:r("physics.hinge-joint.motor.title"),customComponent:tt,bindPath:"motor"})],D.prototype,"motor",2);D=w([F({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],D);var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,V=(o,e,t,i)=>{for(var n=i>1?void 0:i?st(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&nt(e,t,n),n};let T=class extends v{constructor(e,t){super(e,t);p(this,"spring",10);p(this,"damper",.2);p(this,"minDistance",0);p(this,"maxDistance",0);p(this,"tolerance",.025)}};V([y(),m({label:r("physics.spring-joint.spring.title"),type:h.Number,bindPath:"spring"})],T.prototype,"spring",2);V([y(),m({label:r("physics.spring-joint.damper.title"),type:h.Number,bindPath:"damper"})],T.prototype,"damper",2);V([y(),m({label:r("physics.spring-joint.min-distance.title"),type:h.Number,bindPath:"minDistance"})],T.prototype,"minDistance",2);V([y(),m({label:r("physics.spring-joint.max-distance.title"),type:h.Number,bindPath:"maxDistance"})],T.prototype,"maxDistance",2);V([y(),m({label:r("physics.spring-joint.tolerance.title"),type:h.Number,bindPath:"tolerance"})],T.prototype,"tolerance",2);T=V([F({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],T);class rt extends Ce{constructor(){super(...arguments);p(this,"_isPlaying",!1)}onPlay(t){this._isPlaying=t,this._toggleAll(t)}onAddComponent(t){!this._isPlaying&&(t instanceof Q||t instanceof K)&&(t.enabled=!1)}_toggleAll(t){var a;const i=(a=this.engine.sceneManager.activeScene)==null?void 0:a.rootEntities;if(!i)return;const n=[],s=[];i.forEach(d=>{d.getComponentsIncludeChildren(Q,n),d.getComponentsIncludeChildren(K,s)}),n.forEach(d=>{d.enabled=t}),s.forEach(d=>{d.enabled=t})}}var at=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,ct=(o,e,t,i)=>{for(var n=i>1?void 0:i?lt(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&at(e,t,n),n};let ne=class{constructor(){p(this,"script")}init(){this.script=xe.addScript(rt)}};ne=ct([Se({type:"physicsStore"})],ne);export{M as C,g as D,oe as F,D as H,ne as P,te as S,T as a};
1
+ var pe=Object.defineProperty;var de=(o,e,t)=>e in o?pe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(de(o,typeof e!="symbol"?e+"":e,t),t);import{aJ as j,aK as z,aL as l,bn as X,cq as P,bl as se,eH as I,dt as re,bC as ye,q as me,cF as K,eI as L,eJ as Z,eK as $,eL as J,bL as N,f as he,aE as ue,s as y,p as m,e as r,E as ae,eM as W,eN as S,eO as B,C as h,eP as Y,eQ as fe,eR as G,e3 as le,eS as be,eT as ge,br as Ce,cD as Q,bt as xe,bu as Se}from"./index-d497fb6d.js";import{r as H}from"./index-8a22fe59.js";import{c as F}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";import{F as Pe}from"./FormItemArray-9d4196d8.js";const je={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 ve(o){const e={};return Object.keys(o.props).forEach(t=>{je[o.class].includes(t)&&(e[t]=o.props[t])}),e}const ze=async(o,e,t)=>{const i=o.engineObject,n=i.shapes;if(n.length===t.length&&t.every((s,a)=>Oe(s.class,n[a]))){for(let s=0;s<t.length;s++)await k(n[s],t[s]),ee(n[s],t[s]);return}i.clearShapes();for(let s=0;s<t.length;s++){const a=t[s],d=_e(a);await k(d,a),ee(d,a),i.addShape(d)}};async function k(o,e){const t=e.props.material;if(t!=null&&t.refId)try{const i=await H.assetStore.getAssetByRef(t);i!=null&&i.engineObject&&(o.material=i.engineObject)}catch(i){console.error(i)}}function Oe(o,e){switch(o){case"BoxColliderShape":return e instanceof J;case"CapsuleColliderShape":return e instanceof $;case"PlaneColliderShape":return e instanceof Z;case"SphereColliderShape":return e instanceof L;default:return!1}}function _e(o){switch(o.class){case"BoxColliderShape":return new J;case"CapsuleColliderShape":return new $;case"PlaneColliderShape":return new Z;case"SphereColliderShape":return new L}}function ee(o,e){const t=e.props;if(o instanceof J&&t.size){const s=o.size;s.copyFrom(t.size),o.size=s}else o instanceof $?(t.radius!==void 0&&(o.radius=t.radius),t.height!==void 0&&(o.height=t.height),t.upAxis!==void 0&&(o.upAxis=t.upAxis)):o instanceof L&&t.radius!==void 0&&(o.radius=t.radius);o.isTrigger=t.isTrigger;const i=o.position;i.copyFrom(t.position),o.position=i;const n=o.rotation;n.copyFrom(t.rotation),o.rotation=n}const De=o=>o.map(e=>{if(e instanceof J)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 $)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 Z)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 L)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}}}}),Te=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(X,{label:t("physics.shape.box.size.title"),info:t("physics.shape.box.size.info"),min:0,value:{x:o.props.size.x,y:o.props.size.y,z:o.props.size.z},onChange:(i,n)=>{const s=i==null?void 0:i[n];typeof s=="number"&&e(a=>{a.props.size={...a.props.size,[n]:s}})}})})}),we=j(()=>l.jsx(l.Fragment,{})),Me=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(P,{label:t("physics.shape.sphere.radius.title"),info:t("physics.shape.sphere.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}})})}),Ae=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsxs(l.Fragment,{children:[l.jsx(P,{label:t("physics.shape.capsule.radius.title"),info:t("physics.shape.capsule.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}}),l.jsx(P,{label:t("physics.shape.capsule.height.title"),info:t("physics.shape.capsule.height.info"),value:o.props.height,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.height=i})}}),l.jsx(se,{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:o.props.upAxis,onChange:i=>{e(n=>{n.props.upAxis=i})}})]})}),Fe={BoxColliderShape:Te,CapsuleColliderShape:Ae,PlaneColliderShape:we,SphereColliderShape:Me},q={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}}}},Ve=j(({item:o,onItemChange:e})=>{var d;const{t}=z(),i=Fe[o.class],n=H.assetStore,s=Object.values(n.assets).filter(c=>c.getMetaConfig().type==="PhysicsMaterial"),a=n.assets[(d=o.props.material)==null?void 0:d.refId];return l.jsxs(l.Fragment,{children:[l.jsx(re,{label:t("physics.collider.trigger.title"),info:t("physics.collider.trigger.info"),value:o.props.isTrigger,onChange:c=>{e(f=>{f.props.isTrigger=c})}}),l.jsx(ye,{label:t("physics.collider.material.title"),info:t("physics.collider.material.info"),dropLayer:me.PhysicsMaterial,value:a==null?void 0:a.name,assets:s,onSelect:c=>{e(f=>{f.props.material=c.getCurrentRef()})},onLocate:()=>{a&&a.id&&n.selectAsset(a.id)}}),l.jsx(i,{item:o,onItemChange:e}),l.jsx(X,{label:t("physics.collider.local-position.title"),info:t("physics.collider.local-position.info"),value:{x:o.props.position.x,y:o.props.position.y,z:o.props.position.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.position={...b.props.position,[f]:u}})}}),l.jsx(X,{label:t("physics.collider.rotation.title"),info:t("physics.collider.rotation.info"),value:{x:o.props.rotation.x,y:o.props.rotation.y,z:o.props.rotation.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.rotation={...b.props.rotation,[f]:u}})}})]})}),Be=j(({collider:o,item:e,index:t,onModelChange:i})=>{const{t:n}=z(),s=[{label:n("physics.shape.box.title"),value:"BoxColliderShape"},{label:n("physics.shape.capsule.title"),value:"CapsuleColliderShape"}];o.engineObject instanceof K||(s.push({label:n("physics.shape.plane.title"),value:"PlaneColliderShape"}),s.push({label:n("physics.shape.sphere.title"),value:"SphereColliderShape"}));const d=c=>{const f=o.colliderShapes,u=N(f),b=u[t];b&&(c(b),i==null||i("colliderShapes",u))};return l.jsxs(l.Fragment,{children:[l.jsx(se,{label:n("physics.shape.type.title"),info:n("physics.shape.type.info"),value:e.class,options:s,onChange:c=>{q[c].class!==e.class&&d(u=>{Object.assign(u,N(q[c]))})}}),l.jsx(Ve,{item:e,onItemChange:d})]})}),Ee=j(({model:o,inspectorConfig:e,onModelChange:t})=>{const{label:i}=e,n=o.colliderShapes,{t:s}=z(),a=d=>{const c=N(n);d(c),t==null||t("colliderShapes",c)};return l.jsx(Pe,{label:i,items:n.map((d,c)=>({removable:!0,children:l.jsx(Be,{collider:o,item:d,index:c,onModelChange:t}),id:`${c}`,name:s("physics.shape.item-name",{index:c})})),addable:!0,onAdd:()=>{a(d=>{d.push(N(q.BoxColliderShape))})},onDelete:d=>{a(c=>{c.splice(+d.id,1)})},addItemText:s("physics.shape.add")})});var Ie=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Le=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ne(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ie(e,t,n),n};class R extends ae{constructor(){super(...arguments);p(this,"colliderShapes",[])}}Le([he({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:ue.Object,getEngineValue:o=>o.shapes,getEditorValue:De}),y({type:"methods",key:"colliderShapes",canonicalizeToProps:!0,onSerialize:o=>o.map(e=>({$type:e.class,...ve(e)})),onDeserialize:o=>o.map(e=>{const{$type:t,...i}=e;return{class:t,props:i}})}),m({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Ee,onChange:ze})],R.prototype,"colliderShapes",2);var $e=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Re=(o,e,t,i)=>{for(var n=i>1?void 0:i?Je(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&$e(e,t,n),n};let te=class extends R{constructor(o,e){super(o,e)}};te=Re([F({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],te);const ie=o=>Object.keys(S).filter(e=>(o&S[e])!==0).map(e=>String(S[e])),Xe=j(({model:o,onModelChange:e})=>{const t=n=>{const a=n.map(d=>parseInt(d)).reduce((d,c)=>d|c,S.None);e==null||e("constraints",a)},{t:i}=z();return l.jsxs(l.Fragment,{children:[l.jsx(W,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:t}),l.jsx(W,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:t})]})});var Ke=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,C=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ye(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ke(e,t,n),n};let g=class extends R{constructor(e,t){super(e,t);p(this,"isKinematic",!1);p(this,"collisionDetectionMode",B.Discrete);p(this,"constraints",S.None);p(this,"mass",1);p(this,"useGravity",!0);p(this,"linearDamping",0);p(this,"angularDamping",.05);p(this,"automaticCenterOfMass",!0);p(this,"centerOfMass",{x:0,y:0,z:0});p(this,"automaticInertiaTensor",!0);p(this,"inertiaTensor",{x:1,y:1,z:1});p(this,"linearVelocity",{x:0,y:0,z:0});p(this,"angularVelocity",{x:0,y:0,z:0});p(this,"maxAngularVelocity",100);p(this,"maxDepenetrationVelocity",10000000331813535e16);p(this,"sleepThreshold",.005);p(this,"solverIterations",4)}onEnabled(){this._applyEditorRuntimeState()}onInitComplete(){this._applyEditorRuntimeState()}rebindEngineObject(e){super.rebindEngineObject(e),this._applyEditorRuntimeState()}_applyEditorRuntimeState(){this.applyBoundPathChange("enabled",h.Toggle,!1)}};C([y(),m({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:h.Boolean,bindPath:"isKinematic"})],g.prototype,"isKinematic",2);C([y(),m({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:h.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:B.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:B.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:B.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:B.ContinuousSpeculative}]})],g.prototype,"collisionDetectionMode",2);C([y(),m({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:Xe,bindPath:"constraints"})],g.prototype,"constraints",2);C([y(),m({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:h.Number})],g.prototype,"mass",2);C([y(),m({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:h.Boolean})],g.prototype,"useGravity",2);C([y(),m({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:h.Number})],g.prototype,"linearDamping",2);C([y(),m({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:h.Number})],g.prototype,"angularDamping",2);C([y(),m({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.centerOfMass;o.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticCenterOfMass",2);C([y(),m({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:h.Vector3,bindPath:"centerOfMass",when:o=>!o.automaticCenterOfMass})],g.prototype,"centerOfMass",2);C([y(),m({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.inertiaTensor;o.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticInertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:h.Vector3,bindPath:"inertiaTensor",when:o=>!o.automaticInertiaTensor})],g.prototype,"inertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:h.Vector3,bindPath:"linearVelocity"})],g.prototype,"linearVelocity",2);C([y(),m({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:h.Vector3,bindPath:"angularVelocity"})],g.prototype,"angularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:h.Number})],g.prototype,"maxAngularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:h.Number})],g.prototype,"maxDepenetrationVelocity",2);C([y(),m({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:h.Number})],g.prototype,"sleepThreshold",2);C([y(),m({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:h.Slider})],g.prototype,"solverIterations",2);g=C([F({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],g);var qe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,E=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ze(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&qe(e,t,n),n};let A=class extends R{constructor(e,t){super(e,t);p(this,"stepOffset",.5);p(this,"upDirection",{x:0,y:1,z:0});p(this,"slopeLimit",45);p(this,"nonWalkableMode",Y.PreventClimbing)}async bindEngineObject(e){await super.bindEngineObject(e),e.enabled=!1}rebindEngineObject(e){super.rebindEngineObject(e),e.enabled=!1}};E([y(),m({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:h.Number})],A.prototype,"stepOffset",2);E([y(),m({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:h.Vector3,bindPath:"upDirection"})],A.prototype,"upDirection",2);E([y(),m({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:h.Number})],A.prototype,"slopeLimit",2);E([y(),m({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:h.Select,options:[{label:r("physics.character.non-walkable-mode.prevent-climbing"),value:Y.PreventClimbing},{label:r("physics.character.non-walkable-mode.prevent-climbing-and-force-sliding"),value:Y.PreventClimbingAndForceSliding}]})],A.prototype,"nonWalkableMode",2);A=E([F({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],A);const Ge=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,disabled:a,info:d}=e,{ownerId:c}=t[n]||{},f=c&&o.model.root.sceneStore.getEntityModel(c),u=O=>{const _=O?H.sceneStore.getEntityModel(O):null,U=(_==null?void 0:_.getComponentByTypeName("DynamicCollider"))||(_==null?void 0:_.getComponentByTypeName("StaticCollider")),ce=U?{ownerId:O,componentId:U.id}:null;i==null||i(n,ce)},{t:b}=z(),x=Array.from(t.root.sceneStore.iterateEntityModels(),([,O])=>O);return l.jsx(l.Fragment,{children:l.jsx(fe,{label:b(s),info:b(d),entities:x,value:c,disabled:a,customFilter:O=>{let _=null;return t.entityModelId!==O.id&&(_=O.getComponentByTypeName("DynamicCollider")||O.getComponentByTypeName("StaticCollider")),_},displayValue:f==null?void 0:f.name,placeholder:b("physics.collider-picker.placeholder"),onSelect:u,onLocate:()=>{o.model.root.sceneStore.selectEntity(c)},onDelete:()=>{u(null)}})})});var He=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,T=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ue(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&He(e,t,n),n};class v extends ae{constructor(){super(...arguments);p(this,"connectedCollider",null);p(this,"anchor",{x:0,y:0,z:0});p(this,"automaticConnectedAnchor",!0);p(this,"connectedAnchor",{x:0,y:0,z:0});p(this,"breakForce",Number.MAX_VALUE);p(this,"breakTorque",Number.MAX_VALUE);p(this,"massScale",1);p(this,"connectedMassScale",1)}async applyBoundPathChange(t,i,n){var s,a;if(t==="connectedCollider"){const d=n,c=((a=(s=this.root.sceneStore.getEntityModel(d==null?void 0:d.ownerId))==null?void 0:s.getComponentById(d==null?void 0:d.componentId))==null?void 0:a.engineObject)??null;await super.applyBoundPathChange(t,i,c);return}await super.applyBoundPathChange(t,i,n)}}T([y(),m({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:Ge,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);T([y(),m({label:r("physics.joint.anchor.title"),type:h.Vector3,bindPath:"anchor",onChange(o,e,t){if(o.automaticConnectedAnchor){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);T([y(),m({label:r("physics.joint.automatic-connected-anchor.title"),type:h.Boolean,bindPath:"automaticConnectedAnchor",onChange(o,e,t){if(t){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);T([y(),m({label:r("physics.joint.connected-anchor.title"),type:h.Vector3,bindPath:"connectedAnchor",when:o=>!o.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);T([y(),m({label:r("physics.joint.break-force.title"),type:h.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);T([y(),m({label:r("physics.joint.break-torque.title"),type:h.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);T([y(),m({label:r("physics.joint.mass-scale.title"),type:h.Number,bindPath:"massScale"})],v.prototype,"massScale",2);T([y(),m({label:r("physics.joint.connected-mass-scale.title"),type:h.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var We=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,ke=(o,e,t,i)=>{for(var n=i>1?void 0:i?Qe(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&We(e,t,n),n};let oe=class extends v{constructor(o,e){super(o,e)}};oe=ke([F({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],oe);const et=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useLimits,c=t.useSpring,f=t[n],u=f.props,{t:b}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:b(s),info:b(a),children:[l.jsx(P,{label:b("physics.joint-limits.min"),value:u.min,onChange:x=>{u.max<x&&(u.max=x),u.min=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.max"),value:u.max,onChange:x=>{x<u.min&&(x=u.min),u.max=x,i(n,f)}}),c?l.jsxs(l.Fragment,{children:[l.jsx(P,{label:b("physics.joint-limits.stiffness"),value:u.stiffness,onChange:x=>{u.stiffness=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.damping"),value:u.damping,onChange:x=>{u.damping=x,i(n,f)}})]}):l.jsx(P,{label:b("physics.joint-limits.contact-distance"),value:u.contactDistance,onChange:x=>{u.contactDistance=x,i(n,f)}})]}):null})}),tt=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useMotor,c=t[n],f=c.props,{t:u}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:u(s),info:u(a),children:[l.jsx(P,{label:u("physics.joint-motor.target-velocity"),value:f.targetVelocity,onChange:b=>{f.targetVelocity=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.force-limit"),value:f.forceLimit,onChange:b=>{f.forceLimit=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.gear-ratio"),value:f.gearRatio,onChange:b=>{f.gearRatio=b,i(n,c)}}),l.jsx(re,{label:u("physics.joint-motor.free-spin"),value:f.freeSpin,onChange:b=>{f.freeSpin=b,i(n,c)}})]}):null})});var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,M=(o,e,t,i)=>{for(var n=i>1?void 0:i?ot(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&it(e,t,n),n};let D=class extends v{constructor(e,t){super(e,t);p(this,"axis",{x:1,y:0,z:0});p(this,"useLimits",!1);p(this,"useSpring",!1);p(this,"limits",{class:"JointLimits",props:{max:0,min:0,contactDistance:-1,stiffness:0,damping:0}});p(this,"useMotor",!1);p(this,"motor",{class:"JointMotor",props:{targetVelocity:0,forceLimit:Number.MAX_VALUE,gearRatio:1,freeSpin:!1}})}async applyBoundPathChange(e,t,i){if(e==="limits"){const n=this._buildLimitsFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}if(e==="motor"){const n=this._buildMotorFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}await super.applyBoundPathChange(e,t,i)}_buildLimitsFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new be;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 ge;return i.targetVelocity=t.targetVelocity,i.forceLimit=t.forceLimit,i.gearRatio=t.gearRatio,i.freeSpin=t.freeSpin,i}};M([y(),m({label:r("physics.hinge-joint.axis.title"),type:h.Vector3,bindPath:"axis"})],D.prototype,"axis",2);M([y(),m({label:r("physics.hinge-joint.use-limits.title"),type:h.Boolean,bindPath:"useLimits"})],D.prototype,"useLimits",2);M([y(),m({label:r("physics.hinge-joint.use-spring.title"),type:h.Boolean,bindPath:"useSpring"})],D.prototype,"useSpring",2);M([y(),m({label:r("physics.hinge-joint.limits.title"),customComponent:et,bindPath:"limits"})],D.prototype,"limits",2);M([y(),m({label:r("physics.hinge-joint.use-motor.title"),type:h.Boolean,bindPath:"useMotor"})],D.prototype,"useMotor",2);M([y(),m({label:r("physics.hinge-joint.motor.title"),customComponent:tt,bindPath:"motor"})],D.prototype,"motor",2);D=M([F({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],D);var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,V=(o,e,t,i)=>{for(var n=i>1?void 0:i?st(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&nt(e,t,n),n};let w=class extends v{constructor(e,t){super(e,t);p(this,"spring",10);p(this,"damper",.2);p(this,"minDistance",0);p(this,"maxDistance",0);p(this,"tolerance",.025)}};V([y(),m({label:r("physics.spring-joint.spring.title"),type:h.Number,bindPath:"spring"})],w.prototype,"spring",2);V([y(),m({label:r("physics.spring-joint.damper.title"),type:h.Number,bindPath:"damper"})],w.prototype,"damper",2);V([y(),m({label:r("physics.spring-joint.min-distance.title"),type:h.Number,bindPath:"minDistance"})],w.prototype,"minDistance",2);V([y(),m({label:r("physics.spring-joint.max-distance.title"),type:h.Number,bindPath:"maxDistance"})],w.prototype,"maxDistance",2);V([y(),m({label:r("physics.spring-joint.tolerance.title"),type:h.Number,bindPath:"tolerance"})],w.prototype,"tolerance",2);w=V([F({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],w);class rt extends Ce{constructor(){super(...arguments);p(this,"_isPlaying",!1)}onPlay(t){this._isPlaying=t,this._toggleAll(t)}onAddComponent(t){!this._isPlaying&&(t instanceof Q||t instanceof K)&&(t.enabled=!1)}_toggleAll(t){var a;const i=(a=this.engine.sceneManager.activeScene)==null?void 0:a.rootEntities;if(!i)return;const n=[],s=[];i.forEach(d=>{d.getComponentsIncludeChildren(Q,n),d.getComponentsIncludeChildren(K,s)}),n.forEach(d=>{d.enabled=t}),s.forEach(d=>{d.enabled=t})}}var at=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,ct=(o,e,t,i)=>{for(var n=i>1?void 0:i?lt(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&at(e,t,n),n};let ne=class{constructor(){p(this,"script")}init(){this.script=xe.addScript(rt)}};ne=ct([Se({type:"physicsStore"})],ne);export{A as C,g as D,oe as F,D as H,ne as P,te as S,w as a};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var c=(o,t,e)=>t in o?m(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var a=(o,t,e)=>(c(o,typeof t!="symbol"?t+"":t,e),e);import{s as f,p as h,C as g}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import{c as b}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{L as u}from"./LightBaseComponent-4cfc9f48.js";var P=Object.defineProperty,d=Object.getOwnPropertyDescriptor,l=(o,t,e,p)=>{for(var n=p>1?void 0:p?d(t,e):t,i=o.length-1,r;i>=0;i--)(r=o[i])&&(n=(p?r(t,e,n):r(n))||n);return p&&n&&P(t,e,n),n};let s=class extends u{constructor(t,e){super(t,e);a(this,"distance",60)}};l([f(),h({type:g.Number,bindPath:"distance",label:"light.point.distance.label",info:"light.point.distance.info"})],s.prototype,"distance",2);s=l([b({type:"PointLight",componentsMenu:{group:"light",label:"component.light.point.title"}})],s);export{s as PointLightComponent};
1
+ var m=Object.defineProperty;var c=(o,t,e)=>t in o?m(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var a=(o,t,e)=>(c(o,typeof t!="symbol"?t+"":t,e),e);import{s as f,p as h,C as g}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import{c as b}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";import{L as u}from"./LightBaseComponent-948d3192.js";var P=Object.defineProperty,d=Object.getOwnPropertyDescriptor,l=(o,t,e,p)=>{for(var n=p>1?void 0:p?d(t,e):t,i=o.length-1,r;i>=0;i--)(r=o[i])&&(n=(p?r(t,e,n):r(n))||n);return p&&n&&P(t,e,n),n};let s=class extends u{constructor(t,e){super(t,e);a(this,"distance",60)}};l([f(),h({type:g.Number,bindPath:"distance",label:"light.point.distance.label",info:"light.point.distance.info"})],s.prototype,"distance",2);s=l([b({type:"PointLight",componentsMenu:{group:"light",label:"component.light.point.title"}})],s);export{s as PointLightComponent};
@@ -1,11 +1,11 @@
1
- var R=Object.defineProperty;var $=(e,s,o)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o;var x=(e,s,o)=>($(e,typeof s!="symbol"?s+"":s,o),o);import{aM as _,av as l,aP as q,e as u,aw as G,aI as w,df as J,aL as A,aJ as N,dg as z,dh as Q,di as W,dj as H,bm as K,dk as U,dl as X,dm as Y,bA as Z,q as ee,dn as te,dp as se,dq as oe,bk as re,t as ne,dr as ae,ds as ce,dt as le,cn as ie,du as fe,dv as pe,bI as me,E as ue,a as T,s as C,p as k,C as D,l as be,g as de}from"./index-b126bb6b.js";import{u as he}from"./index-c8ed2a45.js";import{c as ye}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{I as ge}from"./IconPlus-b3ed4c04.js";import{D as Pe,M as je}from"./Menu-36c201c0.js";import{c as B}from"./createReactComponent-baa41397.js";import{A as xe,a as Ee}from"./Accordion-4afac60c.js";/**
1
+ var R=Object.defineProperty;var $=(e,s,o)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o;var x=(e,s,o)=>($(e,typeof s!="symbol"?s+"":s,o),o);import{aN as _,aL as l,aQ as q,e as u,aw as G,aI as w,dg as Q,aM as N,aJ as A,dh as z,di as J,dj as W,dk as H,bn as K,dl as U,dm as X,dn as Y,bC as Z,q as ee,dp as te,dq as se,dr as oe,bl as re,t as ne,ds as ae,dt as ce,du as le,cq as ie,dv as fe,dw as pe,bL as me,E as ue,a as T,s as C,p as k,C as D,l as be,g as de}from"./index-d497fb6d.js";import{u as he}from"./index-8a22fe59.js";import{c as ye}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";import{I as ge}from"./IconPlus-2bfc60da.js";import{D as je,M as Pe}from"./Menu-beacc39d.js";import{c as L}from"./createReactComponent-3e49f864.js";import{A as xe,a as Ee}from"./Accordion-6f002a96.js";/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */var Ce=B("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]);/**
6
+ */var Ce=L("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]);/**
7
7
  * @license @tabler/icons-react v3.24.0 - MIT
8
8
  *
9
9
  * This source code is licensed under the MIT license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */var ke=B("outline","trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);function Ie(e){const{renameable:s,onDelete:o,removable:a,checkable:c,defaultChecked:r,onCheckedChange:t}=e;return l.jsxs(w,{align:"v",css:{flex:1,justifyContent:"space-between"},children:[l.jsxs(w,{children:[c&&l.jsx(J,{style:{marginRight:"5px"},checked:r,onCheckedChange:t,onClick:n=>n.stopPropagation()}),l.jsx("span",{children:e.title})]}),l.jsxs(w,{gap:"xxs",children:[s&&l.jsx(A,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),o&&o()},children:l.jsx(Ce,{size:"14px"})}),a&&l.jsx(A,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),o&&o()},children:l.jsx(ke,{size:"14px"})})]})]})}const O={TonemappingEffect:"post-process.effects.tone-mapping.title",BloomEffect:"post-process.effects.bloom.title"};function ve(e){const{label:s,info:o,items:a=[],menuItems:c=[],onClickMenu:r,onDelete:t,addItemText:n="Add Item",defaultValue:f,onCheckedChange:p}=e,b=i=>()=>{t&&t(i)},P=_.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(ge,{size:"12px"}),String(u(n))]});return l.jsxs(G,{label:u(s),info:o,direction:"column",children:[a.length&&l.jsx(xe,{type:"multiple",defaultValue:f??P,"data-state":"closed",children:a.map(i=>l.jsx(Ee,{value:`${i.id}`,title:l.jsx(Ie,{title:u(O[i.name]),onDelete:b(i),removable:i.removable,renameable:i.renameable,checkable:i.checkable,defaultChecked:i.defaultChecked,onCheckedChange:I=>{p&&p(I,i)}}),arrow:!!i.children,children:i.children&&l.jsx(w,{direction:"column",children:i.children})},i.name))}),l.jsx(Pe,{trigger:j,children:c.map(i=>l.jsx(je,{name:u(O[i.name]),onClick:()=>{r&&r(i)}},i.id))})]})}const y={TonemappingEffect:{constructor:fe},BloomEffect:{constructor:pe,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=N(({item:e,effectIndex:s,effect:o,onParameterChange:a})=>{const{assetStore:c}=he();return o?l.jsx(l.Fragment,{children:e.parameters.map((r,t)=>{var b,P,j,i,I,F,M,S,V;const{name:n,value:f}=r,p=o[n];if(!(p instanceof z))return null;switch(p.constructor){case le:return l.jsx(ie,{label:u(((b=d[n])==null?void 0:b.label)??n),min:p.min,max:p.max,value:Number(f),dragStep:.01,onChange:m=>{a(s,t,m)}},t);case ae:return l.jsx(ce,{label:u(((P=d[n])==null?void 0:P.label)??n),value:!!f,onChange:m=>{a(s,t,m)}},t);case oe:return l.jsx(re,{label:u(((j=d[n])==null?void 0:j.label)??n),options:ne(p.enumType,void 0,m=>u(`post-process.effects.options.${m.toLocaleLowerCase()}`)),value:f,onChange:m=>{a(s,t,m)}},t);case te:return l.jsx(se,{label:u(((i=d[n])==null?void 0:i.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case Y:{const m=c.assets,v=m[(I=r.value)==null?void 0:I.refId],L=Object.values(m).filter(h=>h.getMetaConfig().type==="Texture"&&!h.isSubAsset);return l.jsx(Z,{label:u(((F=d[n])==null?void 0:F.label)??n),dropLayer:ee.Texture,assets:L,asset:v,value:v==null?void 0:v.name,placeholder:u("texture.select-texture"),onSelect:h=>{a(s,t,h.getCurrentRef())},onLocate:()=>{var h;c.selectAsset((h=r.value)==null?void 0:h.refId)},onDelete:()=>{a(s,t,null)}},t)}case U:return l.jsx(X,{label:u(((M=d[n])==null?void 0:M.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case H:return l.jsx(K,{label:u(((S=d[n])==null?void 0:S.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case Q:return l.jsx(W,{label:u(((V=d[n])==null?void 0:V.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);default:return null}})}):null}),De=N(({model:e,onModelChange:s})=>{const o=e.effects,a=r=>{const t=me(o);r(t),s==null||s("effects",t)},c=(r,t,n)=>{a(f=>{var b;const p=f[r];(b=p==null?void 0:p.parameters)!=null&&b[t]&&(p.parameters[t]={...p.parameters[t],value:n})})};return l.jsx(ve,{label:u("post-process.effects.title"),addItemText:u("post-process.effects.add"),menuItems:Object.keys(y).map(r=>({id:r,name:r})),onClickMenu:r=>{const t=r.name;a(n=>{n.some(f=>f.name===t)||n.push({name:t,enabled:!0,parameters:[]})})},onCheckedChange:(r,t)=>{a(n=>{const f=n[Number(t.id)];f&&(f.enabled=r)})},onDelete:r=>{a(t=>{t.splice(Number(r.id),1)})},items:o.map((r,t)=>{var p;const n=(p=y[r.name])==null?void 0:p.constructor,f=n?e.engineObject.getEffect(n):null;return{children:l.jsx(we,{item:r,effectIndex:t,effect:f,onParameterChange:c}),id:String(t),name:r.name,removable:!0,checkable:!0,defaultChecked:r.enabled}})})});function Te(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,s,o){if(o.parameters.length>0)return;const a=y[e].defaultValue??{},c=[];for(const r in s){const t=s[r];if(!(t instanceof z))continue;const n=a[r];n!==void 0&&(t.value=n),c.push({name:r,value:Te(n??t.value)??null})}o.parameters=c}async function Fe(e,s,o){var a;if(o!=null&&o.refId){const c=await e.root.assetStore.getAssetByRef(o);s.value=(c==null?void 0:c.engineObject)??null;return}if((a=s.value)!=null&&a.copyFrom&&o&&typeof o=="object"){s.value.copyFrom(o);return}s.value=o}async function Me(e,s){const o=e.engineObject,a=new Set;for(let c=0;c<s.length;c++){const r=s[c],{name:t,enabled:n}=r;if(!y[t])continue;const f=y[t].constructor;a.add(f);let p=o.getEffect(f);if(p||(p=o.addEffect(f)),!!p){ze(t,p,r),p.enabled=n;for(let b=0;b<r.parameters.length;b++){const{name:P,value:j}=r.parameters[b],i=p[P];i instanceof z&&await Fe(e,i,j)}}}for(const c of Object.keys(y)){const r=y[c].constructor;a.has(r)||o.getEffect(r)&&o.removeEffect(r)}}function Se(e){return e.map(s=>{const o={$type:s.name,enabled:s.enabled};for(const a of s.parameters)o[a.name]={value:a.value};return o})}function Ve(e){return e.map(s=>{const o=s,{$type:a,enabled:c,...r}=o,t=Object.entries(r).map(([n,f])=>({name:n,value:f.value}));return{name:a,enabled:c??!0,parameters:t}})}var Ae=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,E=(e,s,o,a)=>{for(var c=a>1?void 0:a?Oe(s,o):s,r=e.length-1,t;r>=0;r--)(t=e[r])&&(c=(a?t(s,o,c):t(c))||c);return a&&c&&Ae(s,o,c),c};let g=class extends ue{constructor(s,o){super(s,o);x(this,"isGlobal",!0);x(this,"blendDistance",0);x(this,"priority",0);x(this,"layer",[T.Layer0]);x(this,"effects",[])}};E([C(),k({label:"post-process.global.title",info:"post-process.global.info",type:D.Toggle,bindPath:"isGlobal"})],g.prototype,"isGlobal",2);E([C(),k({label:"post-process.blend-distance.title",info:"post-process.blend-distance.info",type:D.Number,bindPath:"blendDistance",min:0,dragStep:.01,when:e=>!e.isGlobal})],g.prototype,"blendDistance",2);E([C(),k({label:"post-process.priority.title",info:"post-process.priority.info",type:D.Number,bindPath:"priority",dragStep:1})],g.prototype,"priority",2);E([C(be()),k({label:"post-process.layer.title",info:"post-process.layer.info",type:D.Select,...de([T.Nothing,T.Everything]),bindPath:"layer"})],g.prototype,"layer",2);E([C({onSerialize:Se,onDeserialize:Ve}),k({customComponent:De,onChange:async(e,s,o)=>{await Me(e,o)}})],g.prototype,"effects",2);g=E([ye({type:"PostProcess",componentsMenu:{label:"component.post-process.title"}})],g);export{g as P};
11
+ */var ke=L("outline","trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);function Ie(e){const{renameable:s,onDelete:o,removable:a,checkable:c,defaultChecked:r,onCheckedChange:t}=e;return l.jsxs(w,{align:"v",css:{flex:1,justifyContent:"space-between"},children:[l.jsxs(w,{children:[c&&l.jsx(Q,{style:{marginRight:"5px"},checked:r,onCheckedChange:t,onClick:n=>n.stopPropagation()}),l.jsx("span",{children:e.title})]}),l.jsxs(w,{gap:"xxs",children:[s&&l.jsx(N,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),o&&o()},children:l.jsx(Ce,{size:"14px"})}),a&&l.jsx(N,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:n=>{n.preventDefault(),n.stopPropagation(),o&&o()},children:l.jsx(ke,{size:"14px"})})]})]})}const O={TonemappingEffect:"post-process.effects.tone-mapping.title",BloomEffect:"post-process.effects.bloom.title"};function ve(e){const{label:s,info:o,items:a=[],menuItems:c=[],onClickMenu:r,onDelete:t,addItemText:n="Add Item",defaultValue:f,onCheckedChange:p}=e,b=i=>()=>{t&&t(i)},j=_.useMemo(()=>a.length?a.map(i=>`${i.id}`):[],[a]),P=l.jsxs(q,{size:"sm",variant:"soft",css:{width:"100%",marginTop:"$1","& > svg":{marginRight:"$1"}},children:[l.jsx(ge,{size:"12px"}),String(u(n))]});return l.jsxs(G,{label:u(s),info:o,direction:"column",children:[a.length&&l.jsx(xe,{type:"multiple",defaultValue:f??j,"data-state":"closed",children:a.map(i=>l.jsx(Ee,{value:`${i.id}`,title:l.jsx(Ie,{title:u(O[i.name]),onDelete:b(i),removable:i.removable,renameable:i.renameable,checkable:i.checkable,defaultChecked:i.defaultChecked,onCheckedChange:I=>{p&&p(I,i)}}),arrow:!!i.children,children:i.children&&l.jsx(w,{direction:"column",children:i.children})},i.name))}),l.jsx(je,{trigger:P,children:c.map(i=>l.jsx(Pe,{name:u(O[i.name]),onClick:()=>{r&&r(i)}},i.id))})]})}const y={TonemappingEffect:{constructor:fe},BloomEffect:{constructor:pe,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=A(({item:e,effectIndex:s,effect:o,onParameterChange:a})=>{const{assetStore:c}=he();return o?l.jsx(l.Fragment,{children:e.parameters.map((r,t)=>{var b,j,P,i,I,F,M,S,V;const{name:n,value:f}=r,p=o[n];if(!(p instanceof z))return null;switch(p.constructor){case le:return l.jsx(ie,{label:u(((b=d[n])==null?void 0:b.label)??n),min:p.min,max:p.max,value:Number(f),dragStep:.01,onChange:m=>{a(s,t,m)}},t);case ae:return l.jsx(ce,{label:u(((j=d[n])==null?void 0:j.label)??n),value:!!f,onChange:m=>{a(s,t,m)}},t);case oe:return l.jsx(re,{label:u(((P=d[n])==null?void 0:P.label)??n),options:ne(p.enumType,void 0,m=>u(`post-process.effects.options.${m.toLocaleLowerCase()}`)),value:f,onChange:m=>{a(s,t,m)}},t);case te:return l.jsx(se,{label:u(((i=d[n])==null?void 0:i.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case Y:{const m=c.assets,v=m[(I=r.value)==null?void 0:I.refId],B=Object.values(m).filter(h=>h.getMetaConfig().type==="Texture"&&!h.isSubAsset);return l.jsx(Z,{label:u(((F=d[n])==null?void 0:F.label)??n),dropLayer:ee.Texture,assets:B,asset:v,value:v==null?void 0:v.name,placeholder:u("texture.select-texture"),onSelect:h=>{a(s,t,h.getCurrentRef())},onLocate:()=>{var h;c.selectAsset((h=r.value)==null?void 0:h.refId)},onDelete:()=>{a(s,t,null)}},t)}case U:return l.jsx(X,{label:u(((M=d[n])==null?void 0:M.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case H:return l.jsx(K,{label:u(((S=d[n])==null?void 0:S.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);case J:return l.jsx(W,{label:u(((V=d[n])==null?void 0:V.label)??n),value:f,onChange:m=>{a(s,t,m)}},t);default:return null}})}):null}),De=A(({model:e,onModelChange:s})=>{const o=e.effects,a=r=>{const t=me(o);r(t),s==null||s("effects",t)},c=(r,t,n)=>{a(f=>{var b;const p=f[r];(b=p==null?void 0:p.parameters)!=null&&b[t]&&(p.parameters[t]={...p.parameters[t],value:n})})};return l.jsx(ve,{label:u("post-process.effects.title"),addItemText:u("post-process.effects.add"),menuItems:Object.keys(y).map(r=>({id:r,name:r})),onClickMenu:r=>{const t=r.name;a(n=>{n.some(f=>f.name===t)||n.push({name:t,enabled:!0,parameters:[]})})},onCheckedChange:(r,t)=>{a(n=>{const f=n[Number(t.id)];f&&(f.enabled=r)})},onDelete:r=>{a(t=>{t.splice(Number(r.id),1)})},items:o.map((r,t)=>{var p;const n=(p=y[r.name])==null?void 0:p.constructor,f=n?e.engineObject.getEffect(n):null;return{children:l.jsx(we,{item:r,effectIndex:t,effect:f,onParameterChange:c}),id:String(t),name:r.name,removable:!0,checkable:!0,defaultChecked:r.enabled}})})});function Te(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,s,o){if(o.parameters.length>0)return;const a=y[e].defaultValue??{},c=[];for(const r in s){const t=s[r];if(!(t instanceof z))continue;const n=a[r];n!==void 0&&(t.value=n),c.push({name:r,value:Te(n??t.value)??null})}o.parameters=c}async function Fe(e,s,o){var a;if(o!=null&&o.refId){const c=await e.root.assetStore.getAssetByRef(o);s.value=(c==null?void 0:c.engineObject)??null;return}if((a=s.value)!=null&&a.copyFrom&&o&&typeof o=="object"){s.value.copyFrom(o);return}s.value=o}async function Me(e,s){const o=e.engineObject,a=new Set;for(let c=0;c<s.length;c++){const r=s[c],{name:t,enabled:n}=r;if(!y[t])continue;const f=y[t].constructor;a.add(f);let p=o.getEffect(f);if(p||(p=o.addEffect(f)),!!p){ze(t,p,r),p.enabled=n;for(let b=0;b<r.parameters.length;b++){const{name:j,value:P}=r.parameters[b],i=p[j];i instanceof z&&await Fe(e,i,P)}}}for(const c of Object.keys(y)){const r=y[c].constructor;a.has(r)||o.getEffect(r)&&o.removeEffect(r)}}function Se(e){return e.map(s=>{const o={$type:s.name,enabled:s.enabled};for(const a of s.parameters)o[a.name]={value:a.value};return o})}function Ve(e){return e.map(s=>{const o=s,{$type:a,enabled:c,...r}=o,t=Object.entries(r).map(([n,f])=>({name:n,value:f.value}));return{name:a,enabled:c??!0,parameters:t}})}var Ne=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,E=(e,s,o,a)=>{for(var c=a>1?void 0:a?Oe(s,o):s,r=e.length-1,t;r>=0;r--)(t=e[r])&&(c=(a?t(s,o,c):t(c))||c);return a&&c&&Ne(s,o,c),c};let g=class extends ue{constructor(s,o){super(s,o);x(this,"isGlobal",!0);x(this,"blendDistance",0);x(this,"priority",0);x(this,"layer",[T.Layer0]);x(this,"effects",[])}};E([C(),k({label:"post-process.global.title",info:"post-process.global.info",type:D.Toggle,bindPath:"isGlobal"})],g.prototype,"isGlobal",2);E([C(),k({label:"post-process.blend-distance.title",info:"post-process.blend-distance.info",type:D.Number,bindPath:"blendDistance",min:0,dragStep:.01,when:e=>!e.isGlobal})],g.prototype,"blendDistance",2);E([C(),k({label:"post-process.priority.title",info:"post-process.priority.info",type:D.Number,bindPath:"priority",dragStep:1})],g.prototype,"priority",2);E([C(be()),k({label:"post-process.layer.title",info:"post-process.layer.info",type:D.Select,...de([T.Nothing,T.Everything]),bindPath:"layer"})],g.prototype,"layer",2);E([C({onSerialize:Se,onDeserialize:Ve}),k({customComponent:De,onChange:async(e,s,o)=>{await Me(e,o)}})],g.prototype,"effects",2);g=E([ye({type:"PostProcess",componentsMenu:{label:"component.post-process.title"}})],g);export{g as P};
@@ -0,0 +1 @@
1
+ var Le=Object.defineProperty;var Ve=(r,e,t)=>e in r?Le(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var C=(r,e,t)=>(Ve(r,typeof e!="symbol"?e+"":e,t),t);import{e0 as qe,e1 as Ie,e2 as Ue,aJ as be,aK as Je,aL as O,bC as Ge,q as he,aO as We,aw as He,e3 as Qe,C as Ye,bH as Xe,e4 as Ee,e5 as Ze,e6 as W,e7 as et,e8 as tt,e9 as nt,b_ as st,e as J,ea as ge,eb as rt,ec as ot,ed as it,ee as ct,ef as at,eg as dt,eh as ut,ei as ft,ej as lt,ek as ht,el as pt,em as mt,en as we,eo as yt,bY as _e,ep as ne,eq as Pe,er as St,es as It,et as bt,eu as Et,ev as gt,K as Ce,m as wt,aU as _t,x as Pt,aC as Fe,n as Ct,dN as Rt,ew as $t}from"./index-d497fb6d.js";import{T as vt}from"./TaskQueue-05c94a4d.js";import{u as Re,I as At}from"./index-8a22fe59.js";import"./postmen-0413c689.js";import{A as Tt}from"./AssetViewer-9f395efb.js";function A(r){return structuredClone(r)}function H(r,e){const t=r.entities.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source entity "${e}" not found`);return t}function ke(r,e){const t=r.components.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source component "${e}" not found`);return t}function oe(r,e,t){if(!t)return;const n=e==="scale"?[1,1,1]:[0,0,0],s=r[e]??n;r[e]=[t.x??s[0],t.y??s[1],t.z??s[2]]}function $e(r,e,t){const n=new Set(e),s=new Set;for(const o of t){if(s.has(o))throw new Error(`Prefab source ${r} id "${o}" is duplicated in the added source tree`);if(n.has(o))throw new Error(`Prefab source ${r} id "${o}" already exists`);s.add(o)}}function xt(r){return r.entities.map(e=>e.id)}function Ne(r){return r.components.map(e=>e.id)}function Ot(r){const e=new Set(r.entityIds),t=new Set(r.componentIds);return r.entities.map((n,s)=>{var c,a;const o=r.entityIds[s],i=structuredClone(n);return i.id=o,(c=i.children)!=null&&c.length&&(i.children=i.children.map(d=>{const u=typeof d=="number"?r.entityIds[d]:d;if(!e.has(u))throw new Error(`Prefab added source entity "${o}" child "${String(d)}" is outside added entity tree`);return u})),(a=i.components)!=null&&a.length&&(i.components=i.components.map(d=>{const u=typeof d=="number"?r.componentIds[d]:d;if(!t.has(u))throw new Error(`Prefab added source entity "${o}" component "${String(d)}" is outside added component list`);return u})),i})}function Mt(r){return r.components.map((e,t)=>({...structuredClone(e),id:r.componentIds[t]}))}function Dt(r,e){const t=new Map(r.entities.map(o=>[o.id,o])),n=new Set,s=o=>{if(n.has(o))return;n.add(o);const i=t.get(o);for(const c of(i==null?void 0:i.children)??[])s(c)};return s(e),n}function Ft(r,e,t){var o,i,c;if(!t)return A(r);const n=A(r),s=n.entities[H(n,e)];return t.name!==void 0&&(s.name=t.name),t.isActive!==void 0&&(t.isActive?delete s.isActive:s.isActive=!1),t.layer!==void 0&&(t.layer===0?delete s.layer:s.layer=t.layer),t.isLocked!==void 0&&(t.isLocked?s.isLocked=!0:delete s.isLocked),oe(s,"position",(o=t.transform)==null?void 0:o.position),oe(s,"rotation",(i=t.transform)==null?void 0:i.rotation),oe(s,"scale",(c=t.transform)==null?void 0:c.scale),n}function kt(r,e,t){if(!t||Object.keys(t).length===0)return A(r);const n=A(r),s=n.components[ke(n,e)];return s.props=qe(s.props??{},t),n}function Nt(r,e){if(e.entities.length===0||e.entities.length!==e.entityIds.length)throw new Error("Prefab added entity tree must include matching entities and entityIds");if(e.components.length!==e.componentIds.length)throw new Error("Prefab added entity tree must include matching components and componentIds");$e("entity",xt(r),e.entityIds),$e("component",Ne(r),e.componentIds);const t=A(r),n=t.entities[H(t,e.parentSourceEntityId)],s=Ot(e),o=Mt(e),i=e.entityIds[0];t.entities.push(...s),t.components.push(...o);const c=[...n.children??[]],a=Math.min(Math.max(e.index,0),c.length);return c.splice(a,0,i),n.children=c,t}function jt(r,e){var l;const t=A(r),n=t.entities[H(t,e.instanceSourceEntityId)];if(!n.instance)throw new Error(`Prefab source entity "${e.instanceSourceEntityId}" is not an instance entity`);const s=(l=n.instance).overrides??(l.overrides={}),o=[...s.addedEntities??[]],i=Math.max(0,e.index);let c=0,a=o.length;for(let m=0;m<o.length;m+=1)if(o[m].parent===e.parentSourceEntityId){if(c===i){a=m;break}c+=1,a=m+1}const d=structuredClone(e.entity),u=d.id??`${e.instanceSourceEntityId}:added:${o.length}`;return d.id=u,o.splice(a,0,{id:u,parent:e.parentSourceEntityId,entity:d}),s.addedEntities=o,t}function zt(r,e){if(r.root===e)throw new Error("Cannot remove prefab root entity from source");H(r,e);const t=Dt(r,e),n=new Set;for(const o of r.entities)if(t.has(o.id))for(const i of o.components??[])n.add(i);const s=A(r);return s.entities=s.entities.filter(o=>!t.has(o.id)).map(o=>{const i=structuredClone(o),c=(i.children??[]).filter(d=>!t.has(d)),a=(i.components??[]).filter(d=>!n.has(d));return c.length?i.children=c:delete i.children,a.length?i.components=a:delete i.components,i}),s.components=s.components.filter(o=>!n.has(o.id)),s}function Bt(r,e,t,n){if(Ne(r).includes(t))throw new Error(`Prefab source component id "${t}" already exists`);const s=A(r),o=s.entities[H(s,e)];return s.components.push({...structuredClone(n),id:t}),o.components=[...o.components??[],t],s}function Kt(r,e){ke(r,e);const t=A(r);return t.components=t.components.filter(n=>n.id!==e),t.entities=t.entities.map(n=>{const s=structuredClone(n),o=(s.components??[]).filter(i=>i!==e);return o.length?s.components=o:delete s.components,s}),t}function Lt(r){switch(r.kind){case"add-source-entity":if(r.sourceEntityIds.length===0)throw new Error("Prefab source edit add-source-entity requires at least one source entity id");return;case"remove-source-entity":if(!r.sourceEntityId)throw new Error("Prefab source edit remove-source-entity requires a source entity id");return;case"add-source-component":if(!r.sourceComponentId)throw new Error("Prefab source edit add-source-component requires a source component id");return;case"remove-source-component":if(!r.sourceComponentId)throw new Error("Prefab source edit remove-source-component requires a source component id");return;case"add-nested-instance-entity":if(!r.instanceSourceEntityId)throw new Error("Prefab source edit add-nested-instance-entity requires an instance source entity id");if(!r.parentSourceEntityId)throw new Error("Prefab source edit add-nested-instance-entity requires a parent source entity id");return}}function ve(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}function G(r,e,t){const n=new Set(e);for(const s of t)if(!n.has(s))throw new Error(`Prefab source edit expected ${r} id "${s}" to exist`)}function se(r,e,t){const n=new Set(e);for(const s of t)if(n.has(s))throw new Error(`Prefab source edit expected ${r} id "${s}" to be removed`)}function D(r){return r.entities.map(e=>e.id)}function z(r){return r.components.map(e=>e.id)}function je(r,e){const t=r.entities.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source edit expected entity id "${e}" to exist`);return t}function Vt(r,e){var n;const t=je(r,e);if(!((n=r.entities[t])!=null&&n.instance))throw new Error(`Prefab source edit expected entity id "${e}" to be an instance entity`)}function Ae(r,e,t){var s,o,i;const n=je(r,e);return(((i=(o=(s=r.entities[n])==null?void 0:s.instance)==null?void 0:o.overrides)==null?void 0:i.addedEntities)??[]).filter(c=>c.parent===t).length}function F(r,e,t,n,s){if(r!=null){if(Array.isArray(r)){r.forEach((o,i)=>F(o,e,t,`${n}[${i}]`,s));return}if(Ue(r)){r.$component===e&&s.push({entityId:t,propPath:n});for(const[o,i]of Object.entries(r))F(i,e,t,`${n}.${o}`,s)}}}function ze(r,e,t,n,s){var o;F(r.props,e,t,`${n}.props`,s),(o=r.calls)==null||o.forEach((i,c)=>F(i,e,t,`${n}.calls[${c}]`,s))}function Be(r,e,t,n,s){var o,i,c;(o=r.components)==null||o.forEach((a,d)=>ze(a,e,t,`${n}.components[${d}]`,s)),(i=r.children)==null||i.forEach((a,d)=>Be(a,e,t,`${n}.children[${d}]`,s)),Ke((c=r.instance)==null?void 0:c.overrides,e,t,`${n}.instance.overrides`,s)}function Ke(r,e,t,n,s){var o,i,c;(o=r==null?void 0:r.componentProps)==null||o.forEach((a,d)=>F(a.props,e,t,`${n}.componentProps[${d}].props`,s)),(i=r==null?void 0:r.addedComponents)==null||i.forEach((a,d)=>ze(a.component,e,t,`${n}.addedComponents[${d}].component`,s)),(c=r==null?void 0:r.addedEntities)==null||c.forEach((a,d)=>Be(a.entity,e,t,`${n}.addedEntities[${d}].entity`,s))}function qt(r,e){var s,o;const t=[],n=new Map;for(const i of r.entities)for(const c of i.components??[])n.set(c,i.id);for(const i of r.components){if(i.id===e)continue;const c=n.get(i.id)??"<unowned>";F(i.props,e,c,`components.${i.id}.props`,t),(s=i.calls)==null||s.forEach((a,d)=>F(a,e,c,`components.${i.id}.calls[${d}]`,t))}for(const i of r.entities)Ke((o=i.instance)==null?void 0:o.overrides,e,i.id,`entities.${i.id}.instance.overrides`,t);return t}function Ut(r,e){const t=qt(r,e);if(t.length!==0)throw new Error(`Cannot remove component "${e}": it is referenced by $component bindings in ${t.map(n=>`entity "${n.entityId}" prop "${n.propPath}"`).join(", ")}. Remove the bindings first.`)}function Jt(r,e){switch(e.kind){case"add-source-entity":se("entity",D(r),e.sourceEntityIds);return;case"remove-source-entity":G("entity",D(r),[e.sourceEntityId]);return;case"add-source-component":se("component",z(r),[e.sourceComponentId]);return;case"remove-source-component":G("component",z(r),[e.sourceComponentId]),Ut(r,e.sourceComponentId);return;case"add-nested-instance-entity":G("entity",D(r),[e.instanceSourceEntityId]),Vt(r,e.instanceSourceEntityId);return}}function Gt(r,e,t){switch(t.kind){case"add-source-entity":G("entity",D(e),t.sourceEntityIds);return;case"remove-source-entity":se("entity",D(e),[t.sourceEntityId]);return;case"add-source-component":G("component",z(e),[t.sourceComponentId]);return;case"remove-source-component":se("component",z(e),[t.sourceComponentId]);return;case"add-nested-instance-entity":{if(!ve(D(r),D(e))||!ve(z(r),z(e)))throw new Error("Prefab source edit add-nested-instance-entity must not change source entity or component ids");const n=Ae(r,t.instanceSourceEntityId,t.parentSourceEntityId);if(Ae(e,t.instanceSourceEntityId,t.parentSourceEntityId)!==n+1)throw new Error(`Prefab source edit expected nested added entity count under "${t.parentSourceEntityId}" to increase by 1`);return}}}function Q(r){Lt(r.intent),Ie(r.prefabFile),Jt(r.prefabFile,r.intent);const e=r.mutation(r.prefabFile);return Ie(e),Gt(r.prefabFile,e,r.intent),e}function Wt(r,e){return Q({prefabFile:r,intent:{kind:"add-source-entity",sourceEntityIds:e.entityIds},mutation:t=>Nt(t,e)})}function Ht(r,e){return Q({prefabFile:r,intent:{kind:"add-nested-instance-entity",instanceSourceEntityId:e.instanceSourceEntityId,parentSourceEntityId:e.parentSourceEntityId},mutation:t=>jt(t,e)})}function Qt(r,e){return Q({prefabFile:r,intent:{kind:"remove-source-entity",sourceEntityId:e},mutation:t=>zt(t,e)})}function Yt(r,e){return Q({prefabFile:r,intent:{kind:"add-source-component",sourceComponentId:e.sourceComponentId},mutation:t=>Bt(t,e.sourceEntityId,e.sourceComponentId,e.component)})}function Xt(r,e){return Q({prefabFile:r,intent:{kind:"remove-source-component",sourceComponentId:e},mutation:t=>Kt(t,e)})}class ae{static update(e,t){!this.entity&&(this.entity=e.createChild("prefab"));const n=this.tempCloneEntity=t.instantiateEngineObject();this.entity.addChild(n)}static clear(){var e;(e=this.entity)==null||e.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy(),this.tempCloneEntity=null}}C(ae,"entity"),C(ae,"tempCloneEntity");const Zt=be(({asset:r})=>{const{dependentAssets:e}=r,{configDataStore:t}=Re(),{t:n}=Je(),s=be(({dependentAssetInfo:o})=>{const{assetStore:i}=Re(),c=Object.values(i.assets).filter(u=>{const l=u.getMetaConfig().type,m=u.id===o.id,h=u.id===r.id,f=!m&&!h&&!u.isSubAsset;return o.type==="glTF"||o.type==="Prefab"?l==="glTF"||l==="Prefab"&&f:u.getMetaConfig().type===o.type&&f}),a=i.assets[o.id],d=a==null?void 0:a.name;return O.jsx(Ge,{dropLayer:he.Asset,placeholder:n("prefab.inspector.missed"),assets:c,onSelect:u=>{r.replaceDependentAsset(o,u)},onLocate:()=>{i.selectAsset(o.id)},value:d,asset:a})});return O.jsxs(O.Fragment,{children:[O.jsx(We,{title:n("prefab.inspector.basic-info"),defaultOpen:!0,children:t.isBuc&&O.jsx(He,{label:n("prefab.inspector.url")})}),O.jsx(Qe,{label:n("prefab.inspector.dependent-assets"),children:e.map((o,i)=>O.jsx(s,{dependentAssetInfo:o},`${o.id}-${i}`))})]})}),en={asset:{version:"2.0"},root:"defaultPrefab",entities:[{id:"defaultPrefab",name:"prefab"}],components:[]};class tn extends Tt{constructor(){super(...arguments);C(this,"_animators",[]);C(this,"_particles",[])}setViewAsset(t,n){const s=t.entityManager.rootEntities[0];this._entity=s.engineObject,n.addChild(this._entity),s.getComponentsIncludeChildren("Animator",this._animators).forEach(c=>{c.applyBoundPathChange("enabled",Ye.Toggle,c.enabled)}),this._entity.getComponentsIncludeChildren(Xe,this._particles).forEach(c=>{c.generator.stop(!1,Ee.StopEmittingAndClear),c.generator.main.simulationSpeed=1,c.generator.play()})}stopViewAsset(){super.stopViewAsset(),this._particles.forEach(t=>{t.generator.stop(!1,Ee.StopEmittingAndClear)})}}const nn=new Set(["$ref","refId"]);function de(r,e,t){if(Array.isArray(r))return r.map(o=>de(o,e,t));if(!r||typeof r!="object")return r;const n=r,s={};for(const[o,i]of Object.entries(n))s[o]=nn.has(o)&&i===e?t:de(i,e,t);return s}function sn(r,e,t){return de(r,e,t)}function rn(r,e,t){const n=Ze(t);if(typeof e.id!="string"||e.id.length===0)throw new Error(`[SceneV2] Unable to replace prefab asset ref "${e.id}": missing old asset id`);return sn(r,e.id,n)}function on(r,e){const t=e.entities.findIndex(n=>n.id===e.root);if(!e.entities[t])throw new Error(`Prefab asset "${r}" source root "${e.root}" was not found.`);return t}function k(r,e,t){const n=e.entities[t];if(!n)throw new Error(`Prefab asset "${r}" source entity at index "${t}" was not found.`);return n}function B(r,e,t){var s;const n=(s=e.entities[t])==null?void 0:s.id;if(!n)throw new Error(`Prefab asset "${r}" source entity at index "${t}" is missing a stable source id.`);return n}function cn(r,e,t){var s;const n=(s=e.components[t])==null?void 0:s.id;if(!n)throw new Error(`Prefab asset "${r}" source component at index "${t}" is missing a stable source id.`);return n}function Te(r,e,t){const n=k(r,e,t);if(W(n))return[];const s=(n.children??[]).map(o=>e.entities.findIndex(i=>i.id===o));for(const o of s)if(!e.entities[o])throw new Error(`Prefab asset "${r}" source child index "${o}" on entity "${t}" was not found.`);return s}function xe(r,e,t){const n=k(r,e,t);return W(n)?[]:(n.components??[]).map(s=>{const o=e.components.findIndex(c=>c.id===s),i=e.components[o];if(!i)throw new Error(`Prefab asset "${r}" source component "${s}" was not found.`);return{key:cn(r,e,o),type:i.type,schema:i}})}function Oe(r,e,t,n,s){var a,d;const o=B(r,e,t),i=n.find(u=>u.id===o&&!s.has(u.id));if(i)return i;const c=k(r,e,t);if(!W(c)&&!((d=(a=c.instance)==null?void 0:a.asset)!=null&&d.$ref))throw new Error(`Prefab source child "${o}" cannot be matched to a loaded source entity.`)}function an(r,e,t,n){const s=o=>!t.type||o.type===t.type;if(n){const o=r.find(i=>i.key===n&&!e.has(i.key)&&s(i));if(o)return o}if(t.id){const o=r.find(i=>i.key===t.id&&!e.has(i.key)&&s(i));if(o)return o}}function dn(r,e,t,n){const s=(e==null?void 0:e.components)??[],o=t==null?void 0:t.get(r.key);if(o){const c=s.find(a=>(a==null?void 0:a.id)===o&&!a.ignoreToJSON);if(c)return c}const i=s.find(c=>{var d;return!(c!=null&&c.id)||n.has(c.id)||c.ignoreToJSON||((d=c.instance)==null?void 0:d.sourceComponentKey)!==r.key?!1:!c.type||c.type===r.type});if(i)return i}function un(r){var a,d,u,l,m,h,f,y;const e=k(r.assetId,r.prefabFile,r.sourceIndex),t=B(r.assetId,r.prefabFile,r.sourceIndex),n=(d=(a=e==null?void 0:e.instance)==null?void 0:a.asset)==null?void 0:d.$ref;if(!n||!W(e))return!1;const s=((m=(l=(u=r.normalized)==null?void 0:u.entities)==null?void 0:l[r.sceneChild.id])==null?void 0:m.instance)??r.sceneChild.instance,o=s==null?void 0:s.bindingId,i=o?(y=(f=(h=r.normalized)==null?void 0:h.prefab)==null?void 0:f.bindings)==null?void 0:y[o]:void 0,c=r.resolveInstanceAsset(n,t);return c?i?i.instanceRootEntityId===r.sceneChild.id&&i.assetId===c.id&&i.assetKind===c.kind:(s==null?void 0:s.assetId)===c.id&&(s==null?void 0:s.assetKind)===c.kind&&(!(s!=null&&s.role)||s.role==="root"):!1}function fn(r){var s,o;const t=(o=(s=k(r.assetId,r.prefabFile,r.sourceIndex).instance)==null?void 0:s.asset)==null?void 0:o.$ref;if(typeof t!="string")return;const n=r.resolveInstanceAsset(t,r.sourceEntityId);if(!n)throw new Error(`Prefab source entity "${r.sourceEntityId}" references missing instance asset "${t}".`);if(n.kind!=="Prefab"&&n.kind!=="glTF")throw new Error(`Prefab source entity "${r.sourceEntityId}" references unsupported instance asset "${t}" of type "${String(n.kind)}".`);return n}function ln(r,e){var o,i,c,a;if(!(r!=null&&r.id))return;const t=((i=(o=e==null?void 0:e.entities)==null?void 0:o[r.id])==null?void 0:i.instance)??r.instance,n=t==null?void 0:t.bindingId,s=n?(a=(c=e==null?void 0:e.prefab)==null?void 0:c.bindings)==null?void 0:a[n]:void 0;return typeof(s==null?void 0:s.sourceRootEntityId)=="string"?s.sourceRootEntityId:void 0}function ie(r,e){return{x:Number((r==null?void 0:r.x)??e.x),y:Number((r==null?void 0:r.y)??e.y),z:Number((r==null?void 0:r.z)??e.z)}}function hn(r,e){const t=r==null?void 0:r.transform;return{position:t!=null&&t.position?ie(t.position,{x:0,y:0,z:0}):e.position,rotation:t!=null&&t.rotation?ie(t.rotation,{x:0,y:0,z:0}):e.rotation,scale:t!=null&&t.scale?ie(t.scale,{x:1,y:1,z:1}):e.scale}}function pn(r,e,t){const n=r==null?void 0:r.layer;return Array.isArray(n)?t?t(n):e:typeof n=="number"?n:e}function mn(r){var c,a,d,u,l,m;const e=(c=r.normalized)==null?void 0:c.components,t=(r.sceneComponentId?e==null?void 0:e[r.sceneComponentId]:void 0)??((a=r.component)!=null&&a.id?e==null?void 0:e[r.component.id]:void 0),n={},s=(t==null?void 0:t.refId)??(typeof((d=r.schema.script)==null?void 0:d.$ref)=="string"?nt(r.schema.script.$ref):void 0);s&&(n.refId=s);const o=(t==null?void 0:t.scriptKey)??((u=r.schema.script)==null?void 0:u.key);o&&(n.scriptKey=o);const i=(l=t==null?void 0:t.calls)!=null&&l.length?structuredClone(t.calls):(m=r.schema.calls)!=null&&m.length?r.convertSourceRefsToDomainRefs(structuredClone(r.schema.calls)):void 0;return i!=null&&i.length&&(n.calls=i),n}function yn(r){var e,t;return r.sceneEntityIdBySource.has(r.sourceEntityId)?((t=(e=r.allowMissingSceneComponentSourceKeys)==null?void 0:e.get(r.sourceEntityId))==null?void 0:t.has(r.sourceComponentKey))===!0:!0}function Sn(r){const{assetId:e,prefabFile:t,sourceRoot:n,sceneRoot:s,normalized:o}=r,i=[],c=[],a=new Map,d=new Map,u=on(e,t),l=y=>{var b,_;const p=((_=(b=o==null?void 0:o.entities)==null?void 0:b[y.id])==null?void 0:_.instance)??y.instance;return(p==null?void 0:p.role)==="added"},m=(y,p,b,_)=>{var q,ee,te,U;if(l(b))return;const P=B(e,t,y),g=k(e,t,y),T=W(g);i.push({sceneEntityId:b.id,sourceEntityId:P,role:_}),a.set(P,b.id);const K=xe(e,t,y),X=b.components??[],R=new Set;for(const I of X){if(!(I!=null&&I.id)||I.ignoreToJSON)continue;const S=((ee=(q=o==null?void 0:o.components)==null?void 0:q[I.id])==null?void 0:ee.instance)??I.instance;if((S==null?void 0:S.role)==="added")continue;const w=((te=r.sceneSourceComponentKeys)==null?void 0:te.get(I.id))??(S==null?void 0:S.sourceComponentKey),E=an(K,R,I,w);if(!E){if(!T)throw new Error(`Prefab asset "${e}" live scene component "${I.id}" on source entity "${P}" cannot be matched to a prefab source component.`);continue}R.add(E.key),c.push({sceneEntityId:b.id,sceneComponentId:I.id,sourceComponentKey:E.key});const $=d.get(P)??new Map;$.set(E.key,I.id),d.set(P,$)}const j=Te(e,t,y),Z=(p==null?void 0:p.children)??[],x=b.children??[],L=new Set,V=new Set;for(let I=0;I<j.length;I++){const S=j[I],w=B(e,t,S),E=Oe(e,t,S,Z,L);E!=null&&E.id&&L.add(E.id);const $=x.find(v=>{var me,ye,Se;if(V.has(v.id)||l(v))return!1;if(v.id===w||E!=null&&E.id&&v.id===E.id||un({assetId:e,prefabFile:t,sourceIndex:S,sceneChild:v,normalized:o,resolveInstanceAsset:r.resolveInstanceAsset}))return!0;const re=((ye=(me=o==null?void 0:o.entities)==null?void 0:me[v.id])==null?void 0:ye.instance)??v.instance,pe=((Se=r.sceneSourceEntityIds)==null?void 0:Se.get(v.id))??(re==null?void 0:re.sourceEntityId)??v.instanceSourceEntityId;return pe===w||(E==null?void 0:E.id)&&pe===E.id});if(!$){if((U=r.allowMissingSceneChildSourceIds)!=null&&U.has(w))continue;throw new Error(`Prefab asset "${e}" source child "${w}" cannot be matched to live scene child under source entity "${P}".`)}V.add($.id),m(S,E,$,"linked")}},h={},f=(y,p,b,_)=>{const P=k(e,t,y),g=B(e,t,y),T={},K=xe(e,t,y),X=new Set;K.forEach(I=>{var $;const S=dn(I,p,d.get(g),X);if(S!=null&&S.ignoreToJSON)return;S!=null&&S.id&&X.add(S.id);const w=typeof(S==null?void 0:S.toJSON)=="function"?S.toJSON():I.schema,E=($=d.get(g))==null?void 0:$.get(I.key);if(!E&&!yn({sourceEntityId:g,sourceComponentKey:I.key,sceneEntityIdBySource:a,allowMissingSceneComponentSourceKeys:r.allowMissingSceneComponentSourceKeys}))throw new Error(`Prefab asset "${e}" source component "${I.key}" on source entity "${g}" cannot be matched to live scene component.`);T[I.key]={sceneComponentId:E,type:w.type??(S==null?void 0:S.type),...mn({component:S,schema:w,sceneComponentId:E,normalized:o,convertSourceRefsToDomainRefs:r.convertSourceRefsToDomainRefs}),props:r.collectComponentProps(S,w)}});const R=fn({assetId:e,prefabFile:t,sourceIndex:y,sourceEntityId:g,resolveInstanceAsset:r.resolveInstanceAsset}),j=R==null?void 0:R.kind,Z=et({sourceEntity:P,fallbackSourceEntityId:g,instanceAssetKind:j,bindingSourceRootEntityId:ln(p,o)??(R==null?void 0:R.sourceRootEntityId)}),x=tt(P,g,{...typeof Z=="string"?{rootOverrideTarget:Z}:{},resolveInstanceAssetDisplayName:r.resolveInstanceAssetDisplayName}),L=pn(p,x.layer,r.combineLayers),V=(p==null?void 0:p.isLocked)??x.isLocked,q=Te(e,t,y),ee=q.map(I=>B(e,t,I));h[g]={sceneEntityId:a.get(g),parentSourceEntityId:b,childSourceEntityIds:ee,childIndex:_,...j?{instanceAssetKind:j}:{},name:(p==null?void 0:p.name)??x.name,isActive:(p==null?void 0:p.isActive)??x.isActive,...L!==void 0?{layer:L}:{},...V!==void 0?{isLocked:V}:{},transform:hn(p,x.transform),components:T};const te=(p==null?void 0:p.children)??[],U=new Set;q.forEach((I,S)=>{const w=Oe(e,t,I,te,U);w!=null&&w.id&&U.add(w.id),f(I,w,g,S)})};return m(u,n,s,"root"),f(u,n,null,0),{entityMappings:i,componentMappings:c,sourceEntitySnapshots:h}}class In{constructor(e){this.host=e}async apply(e,t){const n=this.host.readSourceFile(),s=e(n);try{if(this.host.writeSourceFile(s),this.host.syncDependentAssets(),this.host.updateCreateByAddResumeSnapshot(),(t==null?void 0:t.refresh)===!1)return;await this.host.refreshContent((t==null?void 0:t.structuralDeltaMode)==="domain-source-replace"?{structuralDeltaMode:"domain-source-replace"}:void 0)}catch(o){throw this.host.writeSourceFile(n),this.host.syncDependentAssets(),this.host.updateCreateByAddResumeSnapshot(),o}}}var bn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Y=(r,e,t,n)=>{for(var s=n>1?void 0:n?En(e,t):e,o=r.length-1,i;o>=0;o--)(i=r[o])&&(s=(n?i(e,t,s):i(s))||s);return n&&s&&bn(e,t,s),s};const M=Rt("PrefabAsset"),Me=new $t("PrefabAsset");function gn(r){if(!Array.isArray(r))return null;const e=new Set(["id","name","type"]),t=[];for(const n of r){if(!n||typeof n!="object")return null;const s=n;if(!Object.keys(s).every(o=>e.has(o))||typeof s.id!="string"||typeof s.name!="string"||typeof s.type!="string")return null;t.push({id:s.id,name:s.name,type:s.type})}return t}const ue=[0,0,0],fe=[0,0,0],le=[1,1,1];function De(r){const e=new Map;for(const[t,n]of r)e.set(n,t);return e}function ce(r,e,t){const n=r??e;return[(t==null?void 0:t.x)??n[0],(t==null?void 0:t.y)??n[1],(t==null?void 0:t.z)??n[2]]}function wn(r,e){e&&Object.assign(r,{...e.position?{position:ce(r.position,ue,e.position)}:{},...e.rotation?{rotation:ce(r.rotation,fe,e.rotation)}:{},...e.scale?{scale:ce(r.scale,le,e.scale)}:{}})}let N=class extends At{constructor(e){super(e);C(this,"acceptDragLayer",he.Entity);C(this,"_entityManager");C(this,"_contentQueue",new vt);C(this,"prefabFile",null);C(this,"dependentAssets",[]);C(this,"_skipInitUpdateContent",!1);this._entityManager=new it(e)}static async createByEntity(e){var t,n,s;if(e.isPrefabSubEntity||e.isGLTFSubEntity){st.error(J("prefab.error.create-from-sub"));return}ge()&&rt();try{Me.info("createByEntity START",{entityName:e.name,entityId:e.id,isGLTFWrap:e.isGLTFWrapEntity,childCount:(t=e.children)==null?void 0:t.length,childNames:(n=e.children)==null?void 0:n.map(i=>i.name),hasGLTFChild:(s=e.children)==null?void 0:s.some(i=>i.isGLTFRefEntity)});const{assetFacade:o}=e.root;await e.root.runInUndoGroup("asset.create",async()=>{const i=await o.createAssetByAdd({assetType:"Prefab",name:e.name});await i.updateByEntity(e,!1,{undoable:!0,replaceInstances:!1}),i.addInstance(e,{undoable:!0}),i._bindInstantiatedEntity(e,{undoable:!0})})}finally{ge()&&ot()}}get entityManager(){return this._entityManager}get entities(){var e;return((e=this.prefabFile)==null?void 0:e.entities)??[]}async initByMain(e,t){const n=gn(this.meta.dependentAssets);if(this.url=t,this.prefabFile=ct(await e.text()),n?this.dependentAssets=n:this._syncDependentAssetsFromPrefabFile(),this._skipInitUpdateContent){this._skipInitUpdateContent=!1;return}await this._updateContent()}async initByCreation(){return this.prefabFile=en,this._skipInitUpdateContent=!0,this.getMainData()}getMainData(){return at(this._requirePrefabSourceFile("serializing prefab main data"))}async updateByEntity(e,t=!1,n){Me.info("updateByEntity START",{entityName:e.name,entityId:e.id,isGLTFWrap:e.isGLTFWrapEntity,updateInstanceFrom:t});const s=this._serializeRootEntityTreeForSource(e),o=s.entities;if(o[0]){delete o[0].position;const i=o[0].instance?this._resolveNestedInstanceRootOverrideTarget(e):void 0;dt(o[0],i)}this.prefabFile={asset:{version:"2.0"},root:s.entityIds[0],entities:o,components:s.components},this._syncDependentAssetsFromPrefabFile(),this._updateCreateByAddResumeSnapshot(),t&&this.addInstance(e),await this._updateContent({...n!=null&&n.undoable?{undoable:!0}:{},...(n==null?void 0:n.replaceInstances)===!1?{replaceInstances:!1}:{}})}async refreshFromData(e){await this._updateContent(e)}async _editPrefabSource(e,t){await new In({readSourceFile:()=>this.prefabFile,writeSourceFile:n=>{this.prefabFile=n},syncDependentAssets:()=>this._syncDependentAssetsFromPrefabFile(),updateCreateByAddResumeSnapshot:()=>this._updateCreateByAddResumeSnapshot(),refreshContent:n=>this._updateContent(n)}).apply(e,t)}async applyEntityPropsOverride(e,t,n){await this._editPrefabSource(s=>Ft(s,e,t),n)}async applyComponentPropsOverride(e,t,n){const s=t?this._componentPropsOverrideToSourcePatch(e,t):void 0;await this._editPrefabSource(o=>kt(o,e,s),n)}async applyAddedEntityOverride(e,t,n,s){const o=this._serializeEntityTreeForSource(n),i=this._resolveSourceChildInsertionIndex(e,t,n);await this._editPrefabSource(c=>Wt(c,{parentSourceEntityId:e,index:i,entities:o.entities,entityIds:o.entityIds,components:o.components,componentIds:o.componentIds}),{...s,structuralDeltaMode:"domain-source-replace"})}async applyNestedInstanceAddedEntityOverride(e,t,n,s,o){const i=this._serializeEntityInlineForSource(s);await this._editPrefabSource(c=>Ht(c,{instanceSourceEntityId:e,parentSourceEntityId:t,index:n,entity:i}),{...o,structuralDeltaMode:"domain-source-replace"})}async applyRemovedEntityOverride(e,t){await this._editPrefabSource(n=>Qt(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}async applyAddedComponentOverride(e,t,n,s){await this._editPrefabSource(o=>Yt(o,{sourceEntityId:e,sourceComponentId:t,component:this._componentSchemaToSourceRefs(n)}),{...s,structuralDeltaMode:"domain-source-replace"})}async applyRemovedComponentOverride(e,t){await this._editPrefabSource(n=>Xt(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}replaceDependentAsset(e,t){this.prefabFile=rn(this.prefabFile,e,t.id),e.id=t.id,e.name=t.name,e.type=t.getMetaConfig().type,this._updateContent()}_createSourceSerializeContext(e=[]){var n,s;const t=(s=(n=this.root.domainStore)==null?void 0:n.getNormalizedState)==null?void 0:s.call(n);return new ut(e,o=>{var c;const i=(c=t==null?void 0:t.components)==null?void 0:c[o];if(i)return{refId:i.refId,scriptKey:i.scriptKey,calls:i.calls}})}_createSourceRefCodec(){const e=this.root.assetStore;return ft({resolveAssetKind:t=>{var s,o,i,c;const n=(c=(i=(o=(s=e.assets)==null?void 0:s[t])==null?void 0:o.getMetaConfig)==null?void 0:i.call(o))==null?void 0:c.type;return n==="Prefab"||n==="glTF"?n:void 0}})}_convertDomainRefsToSourceRefs(e){return this._createSourceSerializeContext().convertRefs(e)}_convertSourceRefsToDomainRefs(e){return lt(e)}_componentSchemaToSourceRefs(e){var s,o;const t=this._createSourceSerializeContext(),n=structuredClone(e);return(s=n.script)!=null&&s.$ref&&(n.script={$ref:this._componentScriptRefToSourceRef(n.script.$ref),...n.script.key?{key:n.script.key}:{}}),n.props&&(n.props=t.convertRefs(n.props)),(o=n.calls)!=null&&o.length&&(n.calls=t.convertRefs(n.calls)),n}_componentScriptRefToSourceRef(e){return this._createSourceRefCodec().domainToSource(e,"prefab script")}_findSourceComponentModel(e){var n,s;const t=[...((n=this._entityManager)==null?void 0:n.rootEntities)??[]];for(;t.length>0;){const o=t.pop(),i=(s=o==null?void 0:o.components)==null?void 0:s.find(c=>(c==null?void 0:c.id)===e);if(i)return i;t.push(...(o==null?void 0:o.children)??[])}}_componentPropsOverrideToSourcePatch(e,t){const n=this._findSourceComponentModel(e);if(!n||typeof n.toJSON!="function")return this._convertDomainRefsToSourceRefs(t);const s=c=>this._componentSchemaToSourceRefs(c.toJSON()),o=ht(n,s),i=pt(n,t,s);return mt(o,i)}_serializeEntityTreeForSource(e,t={}){const n=t.materializeRootPrefabInstance?null:this._serializeNestedInstanceRootEntityForSource(e);if(n)return{entities:[n],entityIds:[e.id],components:[],componentIds:[]};const s=this._collectEntitySubtree(e,{materializeRootPrefabInstance:t.materializeRootPrefabInstance}),o=s.map(c=>c.id),i=this._createSourceSerializeContext(o);return{entities:s.map((c,a)=>a===0&&t.materializeRootPrefabInstance?c.toV2(i,!0):this._serializeNestedInstanceRootEntityForSource(c)??c.toV2(i,!0)),entityIds:i.entityIds,components:i.components,componentIds:i.componentIds}}_serializeRootEntityTreeForSource(e){const t=this._serializeNestedInstanceRootInlineForSource(e);return t?{entities:[t],entityIds:[e.id],components:[],componentIds:[]}:this._serializeEntityTreeForSource(e)}_sourceEntityTreeToInlineEntity(e,t=0){const n=e.entities[t];if(!n)throw new Error(`Prefab source added entity tree is missing entity index ${t}`);const{children:s,components:o,...i}=n,c=structuredClone(i),a=new Map(e.components.map(u=>[u.id,u]));o!=null&&o.length&&(c.components=o.map(u=>{const l=a.get(u);if(!l)throw new Error(`Prefab source added entity tree is missing component "${String(u)}"`);return structuredClone(l)}));const d=new Map(e.entities.map((u,l)=>[u.id,l]));return s!=null&&s.length&&(c.children=s.map(u=>{const l=d.get(u);if(l===void 0)throw new Error(`Prefab source added entity tree is missing child "${String(u)}"`);return this._sourceEntityTreeToInlineEntity(e,l)})),c}_serializeEntityInlineForSource(e){const t=this._serializeNestedInstanceRootInlineForSource(e);return t||this._sourceEntityTreeToInlineEntity(this._serializeEntityTreeForSource(e))}_serializeNestedInstanceRootEntityForSource(e){const t=this._resolveNestedInstanceAssetRef(e);if(!t)return null;const n=this._serializeNestedInstanceRootFromEntityModel(e,t);if(n)return n;const s={id:e.id,instance:{asset:t}};return this._mergeEntitySourcePropsIntoInstanceOverrides(s,e),s}_serializeNestedInstanceRootInlineForSource(e){const t=this._serializeNestedInstanceRootEntityForSource(e);if(!t)return null;const{children:n,components:s,...o}=t;return o}_serializeNestedInstanceRootFromEntityModel(e,t){if(typeof e.toV2!="function")return null;const n=this._createSourceSerializeContext([e.id]),s=e.toV2(n,!1);if(!s.instance)return null;const{children:o,components:i,...c}=structuredClone(s);return c.instance={...c.instance,asset:{...c.instance.asset??{},$ref:t.$ref}},this._mergeEntitySourcePropsIntoInstanceOverrides(c,e),c}_mergeEntitySourcePropsIntoInstanceOverrides(e,t){if(!e.instance)return;const n={};if(this._writeEntitySourceProps(n,t),Object.keys(n).length===0)return;const s=e.instance.overrides??{},o=[...s.entityProps??[]],i=this._resolveNestedInstanceRootOverrideTarget(t),c=o.findIndex(a=>a.target===i);if(c>=0){const a=o[c];o[c]={...n,...a,target:i}}else o.unshift({target:i,...n});e.instance.overrides={...s,entityProps:o}}_resolveNestedInstanceRootOverrideTarget(e){var s,o;const t=this._findInstanceRootBinding(e.id);if(t!=null&&t.sourceRootEntityId)return t.sourceRootEntityId;if(((t==null?void 0:t.assetKind)??((o=(s=this._resolveNestedInstanceAsset(e))==null?void 0:s.getMetaConfig)==null?void 0:o.call(s).type))==="glTF")return"root";throw new Error(`Cannot serialize nested instance "${e.id}": missing source root entity id for instance overrides.`)}_resolveNestedInstanceAssetRef(e){var o;if(!this._isNestedInstanceRootForSource(e))return null;const t=this._resolveNestedInstanceAsset(e);if(!t)throw new Error(`Cannot serialize nested instance "${e.id}": source asset is not registered.`);const n=(o=t.getMetaConfig)==null?void 0:o.call(t).type;if(n!=="Prefab"&&n!=="glTF")throw new Error(`Cannot serialize nested instance "${e.id}": asset "${t.id}" is type "${n}".`);return{$ref:this._createSourceRefCodec().domainToSource(t.id,`nested instance "${e.id}"`)}}_isNestedInstanceRootForSource(e){var n;const t=this._findInstanceRootBinding(e.id);return(t==null?void 0:t.assetKind)==="Prefab"||(t==null?void 0:t.assetKind)==="glTF"?!0:!!(e.isGLTFRefEntity&&!((n=e.parentEntity)!=null&&n.isGLTFRefEntity))}_findInstanceRootBinding(e){var t,n,s;return Object.values(((s=(n=(t=this.root.domainStore)==null?void 0:t.state)==null?void 0:n.prefab)==null?void 0:s.bindings)??{}).find(o=>o.instanceRootEntityId===e)}_resolveNestedInstanceAsset(e){var s,o;const t=this._findInstanceRootBinding(e.id);if((t==null?void 0:t.assetKind)==="Prefab"||(t==null?void 0:t.assetKind)==="glTF")return(s=this.root.assetStore.assets)==null?void 0:s[t.assetId];const n=(o=e.engineObject)==null?void 0:o._templateResource;if(n)return this.root.assetStore.engineObjectToAssetMap.get(n)}_writeEntitySourceProps(e,t){t.name&&(e.name=t.name),t.isActive===!1&&(e.isActive=!1),t.isLocked&&(e.isLocked=!0);const n=t.layer,s=Array.isArray(n)?we(n):typeof n=="number"?n:0;s!==0&&(e.layer=s),this._writeEntityTransformTuples(e,t)}_writeEntityTransformTuples(e,t){const n=t.transform;if(!n)return;const s=(d,u)=>[Number((d==null?void 0:d.x)??u[0]),Number((d==null?void 0:d.y)??u[1]),Number((d==null?void 0:d.z)??u[2])],o=(d,u)=>d[0]===u[0]&&d[1]===u[1]&&d[2]===u[2],i=s(n.position,ue);o(i,ue)||(e.position=i);const c=s(n.rotation,fe);o(c,fe)||(e.rotation=c);const a=s(n.scale,le);o(a,le)||(e.scale=a)}destroy(){super.destroy(),this.engineObject&&(this.engineObject._root.destroy(),this.engineObject.destroy())}unpackAllInstances(){var n;const e=this.root.sceneStore,t=this._queryInstanceEntityIdsFromDomain();for(const s of t){const o=(n=e.getEntityModel)==null?void 0:n.call(e,s);o==null||o.unpackPrefab()}super.unpackAllInstances()}async instantiate(e,t,n){var m;const s=structuredClone(this.prefabFile),o=yt(s);if(typeof s.root!="string")throw new Error(`Prefab asset "${this.id}" source root must be a stable source entity id.`);const i=o.entityIndexById.get(s.root);if(i===void 0)throw new Error(`Prefab asset "${this.id}" source root "${s.root}" was not indexed.`);const c=s.entities[i];c&&wn(c,t);const a=this._assignSceneInstanceIds(s,i,n==null?void 0:n.expectedRootId),d=await e.hydrateSourceV2LocalEntities(s,{resolveAssetKind:h=>{var y,p,b,_;const f=(_=(b=(p=(y=this.root.assetStore.assets)==null?void 0:y[h])==null?void 0:p.getMetaConfig)==null?void 0:b.call(p))==null?void 0:_.type;return f==="Prefab"||f==="glTF"?f:void 0},resolveInstanceAssetDisplayName:h=>{var f,y;return(y=(f=this.root.assetStore.assets)==null?void 0:f[h])==null?void 0:y.name},resolvePrefabSourceFile:h=>{var y,p,b,_;const f=(p=(y=this.root.assetStore).getAsset)==null?void 0:p.call(y,h);return((_=(b=f==null?void 0:f.getMetaConfig)==null?void 0:b.call(f))==null?void 0:_.type)==="Prefab"?f.prefabFile:void 0},clearExisting:!1,registerDomain:(n==null?void 0:n.deferDomainBinding)!==!0,deferredInstanceBindings:(n==null?void 0:n.deferredInstanceBindings)??[]}),u=(m=s.entities[i])==null?void 0:m.id,l=(u?e.entities.get(u):void 0)??d[0];if(await this._ensureSourceEntityManagerReady(),l.convertToPrefabRefEntity(),(n==null?void 0:n.deferDomainBinding)!==!0&&e.isDomainScoped&&!this.root.domainStore.state.entities[l.id]&&e.registerEntityTreeInDomain(l,null),this.addInstance(l,n),n!=null&&n.deferDomainBinding){if(!n.deferredInstanceBindings)throw new Error(`PrefabAsset "${this.id}" cannot defer domain binding without a deferred binding queue.`);return n.deferredInstanceBindings.push(()=>this._bindInstantiatedEntity(l,{...n,...a})),l}return this._bindInstantiatedEntity(l,{...n,...a}),l}_assignSceneInstanceIds(e,t,n){const s=new Map;e.entities.forEach((i,c)=>{s.set(i.id,n&&c===t?n:_e())});const o=new Map;return e.components.forEach(i=>{o.set(i.id,_e())}),this._remapLocalHydrationIds(e,s,o),{sourceEntityIdBySceneId:De(s),sourceComponentKeyBySceneComponentId:De(o)}}_remapLocalHydrationIds(e,t,n){const s=o=>{if(Array.isArray(o))return o.map(a=>s(a));if(!o||typeof o!="object")return o;const i=o;if(typeof i.$entity=="string")return{$entity:t.get(i.$entity)??i.$entity};if(typeof i.$component=="string")return{$component:n.get(i.$component)??i.$component};const c={};for(const[a,d]of Object.entries(i))c[a]=s(d);return c};e.root=t.get(e.root)??e.root,e.entities=e.entities.map(o=>{var a,d;const i=o.id,c=structuredClone(o);return c.id=t.get(i)??i,(a=c.children)!=null&&a.length&&(c.children=c.children.map(u=>t.get(u)??u)),(d=c.components)!=null&&d.length&&(c.components=c.components.map(u=>n.get(u)??u)),c}),e.components=e.components.map(o=>{var c;const i=structuredClone(o);return i.id=n.get(o.id)??o.id,i.props&&(i.props=s(i.props)),(c=i.calls)!=null&&c.length&&(i.calls=s(i.calls)),i})}async _ensureSourceEntityManagerReady(){if(!this._entityManager.rootEntities[0]&&(await this._entityManager.init(this),!this._entityManager.rootEntities[0]))throw new Error(`PrefabAsset "${this.id}" has no source root entity after source initialization.`)}_updateCreateByAddResumeSnapshot(){const e=this.getMainData(),t=this.getMetaData(),n=this.name??"Prefab";if(typeof e!="string"||e.length===0)throw new Error(`[PrefabAsset] ${n} (${this.id}) cannot update create-by-add resume snapshot without serialized main data.`);const s=new Blob([e],{type:"application/json"});this.root.assetStore.updateCreateByAddResumeSnapshot(this.id,{assetName:n,serializedMeta:JSON.stringify(t),mainBlob:s})}_bindInstantiatedEntity(e,t){if(e.entityManager&&!e.entityManager.isDomainScoped)return;const n=this._entityManager.rootEntities[0];if(!n)return;const{prefab:s}=this.root.domainStore.state,o=s.byAssetId[this.id]??[],i=o.map(h=>s.bindings[h]).find(h=>(h==null?void 0:h.instanceRootEntityId)===e.id||(t==null?void 0:t.expectedBindingId)===(h==null?void 0:h.id)),c=i?new Set(Object.keys(i.overrides.removedEntities??{})):void 0,a=i?new Map(Object.entries(i.overrides.removedComponents??{}).map(([h,f])=>[h,new Set(Object.keys(f??{}))])):void 0,{entityMappings:d,componentMappings:u,sourceEntitySnapshots:l}=this._collectInstanceMappings(n,e,c!=null&&c.size||a!=null&&a.size?{...t,...c!=null&&c.size?{allowMissingSceneChildSourceIds:c}:{},...a!=null&&a.size?{allowMissingSceneComponentSourceKeys:a}:{}}:t);if(!d.length)return;for(const h of o){const f=s.bindings[h];if((f==null?void 0:f.instanceRootEntityId)===e.id||(t==null?void 0:t.expectedBindingId)===h){t!=null&&t.syncPreservedInstanceState&&this._syncPreservedInstanceStateFromSource(f,l),this.root.prefabFacade.updateBindingSourceBaseline({assetId:this.id,bindingId:h,instanceRootEntityId:e.id,sourceRevision:f.sourceRevision,entityMappings:d,componentMappings:u,sourceEntitySnapshots:l});return}}let m=1;for(const h of o){const f=s.bindings[h];f&&f.sourceRevision>m&&(m=f.sourceRevision)}this.root.prefabFacade.bindExistingInstance({assetId:this.id,instanceRootEntityId:e.id,sourceRevision:m,entityMappings:d,componentMappings:u,sourceEntitySnapshots:l,undoable:(t==null?void 0:t.undoable)===!0})}_syncPreservedInstanceStateFromSource(e,t){const n=this.root.domainStore.getNormalizedState(),s=[];for(const[o,i]of Object.entries(t)){const c=i.sceneEntityId??e.sourceToSceneEntity[o];if(!c)continue;const a=n.entities[c];if(!a)continue;const d=`/entities/${ne(c)}`,u=e.overrides.entityProps[o];(u==null?void 0:u.name)===void 0&&i.name!==void 0&&a.name!==i.name&&s.push({op:"replace",path:`${d}/name`,value:i.name}),(u==null?void 0:u.isActive)===void 0&&i.isActive!==void 0&&a.isActive!==i.isActive&&s.push({op:"replace",path:`${d}/isActive`,value:i.isActive}),(u==null?void 0:u.layer)===void 0&&(i.layer===void 0?a.layer!==void 0&&s.push({op:"remove",path:`${d}/layer`}):a.layer!==i.layer&&s.push({op:a.layer===void 0?"add":"replace",path:`${d}/layer`,value:i.layer}));const l=u==null?void 0:u.transform;for(const h of["position","rotation","scale"]){if((l==null?void 0:l[h])!==void 0)continue;const f=i.transform[h];Pe(a.transform[h],f)||s.push({op:"replace",path:`${d}/transform/${h}`,value:f})}const m=e.overrides.componentProps[o]??{};for(const[h,f]of Object.entries(i.components)){const y=f.sceneComponentId;if(!y)continue;const p=n.components[y];if(!p)continue;const b=`${d}/components/${ne(y)}`,_=m[h]??{},P=f.props??{};for(const[g,T]of Object.entries(P)){if(Object.prototype.hasOwnProperty.call(_,g))continue;const K=`${b}/props/${ne(g)}`;Pe(p.props[g],T)||s.push({op:Object.prototype.hasOwnProperty.call(p.props,g)?"replace":"add",path:K,value:T})}for(const g of Object.keys(p.props))Object.prototype.hasOwnProperty.call(P,g)||Object.prototype.hasOwnProperty.call(_,g)||s.push({op:"remove",path:`${b}/props/${ne(g)}`})}}this.root.domainStore.applySystem(s)}_collectInstanceMappings(e,t,n){var s,o,i;return Sn({assetId:this.id,prefabFile:this._requirePrefabSourceFile(),sourceRoot:e,sceneRoot:t,normalized:(i=(o=(s=this.root)==null?void 0:s.domainStore)==null?void 0:o.getNormalizedState)==null?void 0:i.call(o),sceneSourceEntityIds:n==null?void 0:n.sourceEntityIdBySceneId,sceneSourceComponentKeys:n==null?void 0:n.sourceComponentKeyBySceneComponentId,allowMissingSceneChildSourceIds:n==null?void 0:n.allowMissingSceneChildSourceIds,allowMissingSceneComponentSourceKeys:n==null?void 0:n.allowMissingSceneComponentSourceKeys,resolveInstanceAssetDisplayName:c=>{var a,d;return(d=(a=this.root.assetStore.assets)==null?void 0:a[c])==null?void 0:d.name},resolveInstanceAsset:(c,a)=>{var m,h,f;const d=(m=this.root.assetStore.assets)==null?void 0:m[c];if(!d)throw new Error(`Prefab source entity "${a}" references missing instance asset "${c}".`);const u=(f=(h=d.getMetaConfig)==null?void 0:h.call(d))==null?void 0:f.type;if(u!=="Prefab"&&u!=="glTF")throw new Error(`Prefab source entity "${a}" references unsupported instance asset "${c}" of type "${String(u)}".`);const l=d.prefabFile;return{id:d.id,kind:u,...u==="Prefab"&&typeof(l==null?void 0:l.root)=="string"?{sourceRootEntityId:l.root}:{}}},convertSourceRefsToDomainRefs:c=>this._convertSourceRefsToDomainRefs(c),collectComponentProps:(c,a)=>this._collectSnapshotComponentProps(c,a),combineLayers:c=>we(c)})}_requirePrefabSourceFile(e="using prefab source file"){const t=this.prefabFile;if(!t)throw new Error(`Prefab asset "${this.id}" has no source file while ${e}.`);if(!Array.isArray(t.entities))throw new Error(`Prefab asset "${this.id}" source file is missing entity anchors.`);return t}_resolveSourceChildInsertionIndex(e,t,n){var l,m,h;const s=this._requirePrefabSourceFile(),o=s.entities.findIndex(f=>f.id===e);if(o<0)return t;const i=new Set(((l=s.entities[o])==null?void 0:l.children)??[]);if(i.size===0)return 0;const c=((m=n.parentEntity)==null?void 0:m.children)??[],a=c.findIndex(f=>f.id===n.id),d=a>=0?a:Math.min(Math.max(t,0),c.length);let u=0;for(let f=0;f<d;f+=1){const y=(h=c[f])==null?void 0:h.instanceSourceEntityId;y&&i.has(y)&&(u+=1)}return Math.min(Math.max(u,0),i.size)}_collectSnapshotComponentProps(e,t){return e&&Reflect.ownKeys(St(e)).length>0?this._convertSourceRefsToDomainRefs(It(e)):this._convertSourceRefsToDomainRefs(structuredClone(t.props??{}))}async replaceInstance(e,t,n){var h,f,y,p;const s=t.entities.get(e);if(!s)return null;const o=(h=s==null?void 0:s.engineObject)==null?void 0:h.transform,i=o?{position:{x:o.position.x,y:o.position.y,z:o.position.z},rotation:{x:o.rotation.x,y:o.rotation.y,z:o.rotation.z},scale:{x:o.scale.x,y:o.scale.y,z:o.scale.z}}:void 0,c=(y=(f=s.root.domainStore.getNormalizedState().entities[e])==null?void 0:f.instance)==null?void 0:y.bindingId,a=[],d=await this.instantiate(t,n!=null&&n.resetRootTransform?void 0:i,{...n!=null&&n.undoable?{undoable:!0}:{},expectedBindingId:c,deferDomainBinding:!0,deferredInstanceBindings:a});d.convertToPrefabRefEntity();const u=((p=t.root)==null?void 0:p.domainStore)??s.root.domainStore,l=t.entities.get(e),m=u.getNormalizedState().entities[e];return!l||!(m!=null&&m.instance)?(d.destroy(),null):(t.isDomainScoped&&!u.state.entities[d.id]&&t.registerEntityTreeInDomain(d,null,void 0,{...i&&!(n!=null&&n.resetRootTransform)?{transform:i}:{},deferInstanceBinding:!0}),a.splice(0).forEach(b=>b()),n!=null&&n.structuralDeltaMode?t.replaceEntity(e,d,{structuralDeltaMode:n.structuralDeltaMode}):t.replaceEntity(e,d),d)}_refreshTrackedInstanceBindings(e){var s;const t=this.root.sceneStore,n=this._queryInstanceEntityIdsFromDomain();for(const o of n){const i=(s=t.getEntityModel)==null?void 0:s.call(t,o);i&&this._bindInstantiatedEntity(i,e)}}_instantiateEngineObject(){return this.engineObject.instantiate()}_onDrop(e,t){if(!t||t.id===this.id)return;this.dropping=!1;const{sceneStore:n,sceneUIStore:s}=this.root,o=Array.from(s.selectedKeys);if(o.length>1)for(let i=0;i<o.length;i++)N.createByEntity(n.getEntityModel(o[i]));else bt({title:J("prefab.replace.title").toString(),description:J("prefab.replace.description",{name:this.name}).toString(),confirmText:J("prefab.replace.confirm").toString(),onConfirm:()=>{const i=n.getEntityModel(o[0]);this.updateByEntity(i,!0)}})}_rebaseInstanceRevisions(){const{prefabFacade:e,domainStore:t}=this.root,n=t.state.prefab.byAssetId[this.id];if(!n||n.length===0)return;let s=0;for(const o of n){const i=t.state.prefab.bindings[o];i&&i.sourceRevision>s&&(s=i.sourceRevision)}e.updatePrefabContent(this.id,s+1)}_collectEntitySubtree(e,t={}){const n=[],s=(o,i=!1)=>{if(n.push(o),!(this._isNestedInstanceRootForSource(o)&&!(i&&t.materializeRootPrefabInstance)))for(const a of o.children)a.prefabEntityRemoved||s(a)};return s(e,!0),n}_collectDependentAssetsFromPrefabFile(){var n;const e=new Set,t=this.root.assetStore;for(const s of Et(this.prefabFile,{currentAssetId:this.id})){const o=(n=t.assets)==null?void 0:n[s];if(!o)throw new Error(`[SceneV2] Unable to resolve prefab asset ref "${s}" while collecting dependencies`);o.id!==this.id&&e.add(o)}return e}_syncDependentAssetsFromPrefabFile(){this.root.assetStore,this.dependentAssets=Array.from(this._collectDependentAssetsFromPrefabFile(),e=>({id:e.id,name:e.name,type:e.getMetaConfig().type}))}_updateContent(e){return this._contentQueue.enqueue(async()=>{try{await this._updateContentInternal(e)}catch(t){if(t instanceof Error&&t.message==="cancelled")return;throw M.error("_updateContent failed:",t),t}})}async _updateContentInternal(e){const{url:t,dependentAssets:n}=this,s=(e==null?void 0:e.persist)!==!1;await Promise.all(n.map(a=>this.root.assetStore.getAssetByRef({refId:a.id}))),await this._entityManager.init(this);const o=this.engineObject;if(o){this.root.assetStore.engineObjectToAssetMap.delete(o);try{o.destroy()}catch(a){M.warn("failed to destroy oldEngineObject:",a)}}const i=new gt(this.engine,t);this.bindEngineObject(i),this.root.assetStore.engineObjectToAssetMap.set(i,this);let c=this._entityManager.rootEntities[0];if(c||(c=this._entityManager.createEntity("prefab","defaultPrefab"),c.bindEngineObject(new Ce(this.engine,"prefab")),M.error(`The prefab which id is ${this.id} is broken, use default prefab instead.`)),c.engineObject||(M.warn("rootEntity engineObject is null, binding new Entity"),c.bindEngineObject(new Ce(this.engine,"prefab"))),this._markAsTemplate(c),i._root=c.engineObject,c.once("delete",()=>{M.error(`The prefab which id is ${this.id} is broken.`),this._updateContent().catch(a=>{M.error(`Failed to rebuild broken prefab which id is ${this.id}.`,a)})}),this._updateDragTempEntity(),this.updateThumbnail(),s&&(this.root.assetFacade.persistAssetMeta(this.id),this.root.assetFacade.persistAssetMain(this.id)),(e==null?void 0:e.replaceInstances)!==!1){const a=new Set((e==null?void 0:e.resetRootTransformBindingIds)??[]),d=e!=null&&e.undoable?{undoable:!0}:void 0,u=this.root.sceneStore,l=this._queryInstanceEntityIdsFromDomain();await Promise.all(l.map(m=>{var f,y;const h=(y=(f=this.root.domainStore.getNormalizedState().entities[m])==null?void 0:f.instance)==null?void 0:y.bindingId;return this.replaceInstance(m,u,{...d??{},resetRootTransform:h!==void 0&&a.has(h),...e!=null&&e.structuralDeltaMode?{structuralDeltaMode:e.structuralDeltaMode}:{}})}))}else{const a={...e!=null&&e.undoable?{undoable:!0}:{},syncPreservedInstanceState:!0};this._refreshTrackedInstanceBindings(a)}this._rebaseInstanceRevisions()}_markAsTemplate(e){const t=e.engineObject;if(!t){M.warn("_markAsTemplate: engineObject is null",{prefabId:this.id,entityModelId:e.id});return}const n=t;n._templateResource||n._markAsTemplate(this.engineObject),e.selfChildren.forEach(s=>{this._markAsTemplate(s)})}};Y([wt()],N.prototype,"prefabFile",2);Y([_t(),Pt],N.prototype,"dependentAssets",2);Y([Fe],N.prototype,"replaceDependentAsset",1);Y([Fe],N.prototype,"_onDrop",1);N=Y([Ct({type:"Prefab",label:J("asset.prefab.title"),extname:"prefab",dragLayer:he.Prefab,customInspector:Zt,viewer:tn,thumbnail:ae,async bundle(r){return{content:new Blob([r.content],{type:"application/json"})}}})],N);export{N as PrefabAsset};
@@ -1 +1 @@
1
- var wt=Object.defineProperty;var Mt=(M,s,i)=>s in M?wt(M,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):M[s]=i;var A=(M,s,i)=>(Mt(M,typeof s!="symbol"?s+"":s,i),i);import{ai as rt,B as q,bu as Rt,a5 as ut,a6 as dt,a7 as mt,a9 as ft,a3 as G,bv as tt,a4 as et,bw as Pt,j as It,bx as At,K as Ht,y as Vt,p as _,e as b,C as B,t as _t,m as N,n as Bt,o as Nt,q as Tt}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Dt}from"./bundlers-9b0d37fc.js";import{M as Et}from"./MeshThumbnail-8c20ee92.js";const z=class z{static createSphere(s=.5,i=18){i=Math.max(2,Math.floor(i));const o=i+1,e=o*o,c=i*i,l=z._generateIndices(e,c*6),R=Math.PI,t=R*2,a=1/o,y=1/i,m=8,h=new Float32Array(e*m);for(let x=0;x<e;++x){const u=x%o,d=x*a|0,p=u*y,n=d*y,w=p*t,f=n*R,v=Math.sin(f),I=-s*Math.cos(w)*v,P=s*Math.cos(f),S=s*Math.sin(w)*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++]=p,h[r++]=n}let C=0;for(let x=0;x<c;++x){const u=x%i,p=(x*y|0)*o+u,n=p+1,w=p+o,f=w+1;l[C++]=n,l[C++]=p,l[C++]=f,l[C++]=p,l[C++]=w,l[C++]=f}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:l,vertices:h,bounds:g}}static createCuboid(s=1,i=1,o=1){const e=s/2,c=i/2,l=o/2,R=8,t=new Float32Array(24*R);t[0]=-e,t[1]=c,t[2]=-l,t[6]=0,t[7]=0,t[8]=e,t[9]=c,t[10]=-l,t[14]=1,t[15]=0,t[16]=e,t[17]=c,t[18]=l,t[22]=1,t[23]=1,t[24]=-e,t[25]=c,t[26]=l,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]=-e,t[33]=-c,t[34]=-l,t[38]=0,t[39]=1,t[40]=e,t[41]=-c,t[42]=-l,t[46]=1,t[47]=1,t[48]=e,t[49]=-c,t[50]=l,t[54]=1,t[55]=0,t[56]=-e,t[57]=-c,t[58]=l,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]=-e,t[65]=c,t[66]=-l,t[70]=0,t[71]=0,t[72]=-e,t[73]=c,t[74]=l,t[78]=1,t[79]=0,t[80]=-e,t[81]=-c,t[82]=l,t[86]=1,t[87]=1,t[88]=-e,t[89]=-c,t[90]=-l,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]=e,t[97]=c,t[98]=-l,t[102]=1,t[103]=0,t[104]=e,t[105]=c,t[106]=l,t[110]=0,t[111]=0,t[112]=e,t[113]=-c,t[114]=l,t[118]=0,t[119]=1,t[120]=e,t[121]=-c,t[122]=-l,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]=-e,t[129]=c,t[130]=l,t[134]=0,t[135]=0,t[136]=e,t[137]=c,t[138]=l,t[142]=1,t[143]=0,t[144]=e,t[145]=-c,t[146]=l,t[150]=1,t[151]=1,t[152]=-e,t[153]=-c,t[154]=l,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]=-e,t[161]=c,t[162]=-l,t[166]=1,t[167]=0,t[168]=e,t[169]=c,t[170]=-l,t[174]=0,t[175]=0,t[176]=e,t[177]=-c,t[178]=-l,t[182]=0,t[183]=1,t[184]=-e,t[185]=-c,t[186]=-l,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(-e,-c,-l),y.max.set(e,c,l),{vertices:t,bounds:y,indices:a}}static createPlane(s=1,i=1,o=1,e=1){o=Math.max(1,Math.floor(o)),e=Math.max(1,Math.floor(e));const c=o+1,l=e+1,R=s/2,t=i/2,a=s/o,y=i/e,m=c*l,h=e*o,C=z._generateIndices(m,h*6),g=1/c,x=1/o,u=1/e,d=8,p=new Float32Array(m*d);for(let f=0;f<m;++f){const v=f%c,I=f*g|0;let P=f*d;p[P++]=v*a-R,p[P++]=0,p[P++]=I*y-t,p[P++]=0,p[P++]=1,p[P++]=0,p[P++]=v*x,p[P++]=I*u}let n=0;for(let f=0;f<h;++f){const v=f%o,P=(f*x|0)*c+v,S=P+1,r=P+c,D=r+1;C[n++]=P,C[n++]=r,C[n++]=S,C[n++]=r,C[n++]=D,C[n++]=S}const w=new q;return w.min.set(-R,0,-t),w.max.set(R,0,t),{bounds:w,vertices:p,indices:C}}static createCylinder(s=.5,i=.5,o=2,e=20,c=1){e=Math.floor(e),c=Math.floor(c);const l=e+1,R=c+1,t=o*.5,a=o/c,y=l*R,m=e*c,h=e*2,C=y+2+h,g=z._generateIndices(C,m*6+h*3),x=1/l,u=1/e,d=1/c,p=8,n=new Float32Array(C*p);let w=0;const f=Math.PI,v=Math.PI*2,I=i-s,P=I/o,S=I/c;for(let F=0;F<y;++F){const Z=F%l,W=F*x|0,O=Z*u,J=W*d,$=f+O*v,nt=Math.sin($),pt=Math.cos($),ht=i-W*S,xt=ht*nt,vt=W*a-t,Ct=ht*pt;let L=F*p;n[L++]=xt,n[L++]=vt,n[L++]=Ct,n[L++]=nt,n[L++]=P,n[L++]=pt,n[L++]=O,n[L++]=1-J}for(let F=0;F<m;++F){const Z=F%e,O=(F*u|0)*l+Z,J=O+1,$=O+l,nt=$+1;g[w++]=J,g[w++]=$,g[w++]=O,g[w++]=J,g[w++]=nt,g[w++]=$}let r=y*p;n[r++]=0,n[r++]=-t,n[r++]=0,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=.5,n[r++]=.5,n[r++]=0,n[r++]=t,n[r++]=0,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=.5,n[r++]=.5,r=(y+2)*p;const D=1/(s*2),j=1/(i*2),E=l*c;for(let F=0;F<e;++F){const Z=F*p;let W=n[Z],O=n[Z+2];n[r++]=W,n[r++]=-t,n[r++]=O,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=W*j+.5,n[r++]=.5-O*j;const J=(F+E)*p;W=n[J],O=n[J+2],n[r++]=W,n[r++]=t,n[r++]=O,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=W*D+.5,n[r++]=.5-O*D}const Y=y+1,X=y+2,U=X+1;for(let F=0;F<e;++F){const Z=F*2,W=F===e-1?0:Z+2;g[w++]=y,g[w++]=X+W,g[w++]=X+Z,g[w++]=Y,g[w++]=U+Z,g[w++]=U+W}const Q=new q,K=Math.max(s,i);return Q.min.set(-K,-t,-K),Q.max.set(K,t,K),{bounds:Q,vertices:n,indices:g}}static createTorus(s=.5,i=.1,o=30,e=30,c=360){o=Math.floor(o),e=Math.floor(e);const l=(o+1)*(e+1),R=o*e,t=z._generateIndices(l,R*6),a=8,y=new Float32Array(l*a);c=c/180*Math.PI;let m=0;const h=z._tempVec30;for(let x=0;x<=o;x++)for(let u=0;u<=e;u++){const d=u/e*c,p=x/o*Math.PI*2,n=Math.cos(p),w=Math.sin(p),f=Math.cos(d),v=Math.sin(d),I=(s+i*n)*f,P=(s+i*n)*v,S=i*w;y[m++]=I,y[m++]=P,y[m++]=S;const r=s*f,D=s*v;h.set(I-r,P-D,S).normalize(),y[m++]=h.x,y[m++]=h.y,y[m++]=h.z,y[m++]=u/e,y[m++]=x/o}m=0;for(let x=1;x<=o;x++)for(let u=1;u<=e;u++){const d=(e+1)*x+u-1,p=(e+1)*(x-1)+u-1,n=(e+1)*(x-1)+u,w=(e+1)*x+u;t[m++]=d,t[m++]=p,t[m++]=w,t[m++]=p,t[m++]=n,t[m++]=w}const C=new q,g=s+i;return C.min.set(-g,-g,-i),C.max.set(g,g,i),{bounds:C,vertices:y,indices:t}}static createCone(s=.5,i=2,o=20,e=1){o=Math.floor(o),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=a+1+o,h=z._generateIndices(m,y*6+o*3),C=1/c,g=1/o,x=1/e,u=8,d=new Float32Array(m*8);let p=0;const n=Math.PI,w=Math.PI*2,f=s/i;for(let r=0;r<a;++r){const D=r%c,j=r*C|0,E=D*g,Y=j*x,X=n+E*w,U=Math.sin(X),Q=Math.cos(X),K=s-j*s,F=K*U,Z=j*t-R,W=K*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++]=E,d[O++]=1-Y}for(let r=0;r<y;++r){const D=r%o,E=(r*g|0)*c+D,Y=E+1,X=E+c,U=X+1;h[p++]=Y,h[p++]=X,h[p++]=E,h[p++]=Y,h[p++]=U,h[p++]=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<o;++r){const D=d[r*u],j=d[r*u+2];d[v++]=D,d[v++]=-R,d[v++]=j,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=D*I+.5,d[v++]=.5-j*I}const P=a+1;for(let r=0;r<o;++r){const D=r,j=r===o-1?0:D+1;h[p++]=a,h[p++]=P+j,h[p++]=P+D}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,i=2,o=6,e=1){o=Math.max(2,Math.floor(o)),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=c*c,h=o*o,C=a+2*m,g=z._generateIndices(C,(y+2*h)*6),x=1/c,u=1/o,d=1/e,p=Math.PI,n=Math.PI*2,w=8,f=new Float32Array(C*w);let v=0;for(let P=0;P<a;++P){const S=P%c,r=P*x|0,D=S*u,j=r*d,E=p+D*n,Y=Math.sin(E),X=Math.cos(E);let U=P*w;f[U++]=s*Y,f[U++]=r*t-R,f[U++]=s*X,f[U++]=Y,f[U++]=0,f[U++]=X,f[U++]=D,f[U++]=1-j}for(let P=0;P<y;++P){const S=P%o,D=(P*u|0)*c+S,j=D+1,E=D+c,Y=E+1;g[v++]=j,g[v++]=E,g[v++]=D,g[v++]=j,g[v++]=Y,g[v++]=E}z._createCapsuleCap(s,i,o,p,n,a,1,f,g,v),z._createCapsuleCap(s,i,o,p,-n,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,i){let o=null;return s>65535?o=new Uint32Array(i):o=new Uint16Array(i),o}static _createCapsuleCap(s,i,o,e,c,l,R,t,a,y){const m=o+1,h=i*.5*R,C=m*m,g=o*o,x=1/m,u=1/o,d=8;for(let p=0;p<C;++p){const n=p%m,w=p*x|0,f=n*u,v=w*u,I=e+f*c,P=v*Math.PI*.5,S=Math.sin(P),r=s*Math.sin(I)*S,D=s*Math.cos(P)*R+h,j=s*Math.cos(I)*S;let E=(p+l)*d;t[E++]=r,t[E++]=D,t[E++]=j,t[E++]=r,t[E++]=D-h,t[E++]=j,t[E++]=f,t[E++]=v}for(let p=0;p<g;++p){const n=p%o,f=(p*u|0)*m+n+l,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,i=3){i=Rt.clamp(Math.floor(i),1,6);const o=new Float32Array(3*(6*Math.pow(4,i)+2)),e=new Float32Array(24*Math.pow(4,i));this._subdiveCatmullClark(i,o,e);const c=o.length/3,l=e.length/4,R=c+Math.pow(2,i+1)-1,t=R+16,a=new Float32Array(t*8),y=this._generateIndices(c,l*6);let m=0;const h={};for(let x=0;x<c;x++){let u=3*x,d=o[u],p=o[u+1],n=o[u+2];const w=1/Math.sqrt(d*d+p*p+n*n);if(d*=w,p*=w,n*=w,u=8*x,a[u]=d*s,a[u+1]=p*s,a[u+2]=n*s,a[u+3]=d,a[u+4]=p,a[u+5]=n,a[u+6]=(Math.PI-Math.atan2(n,d))/(2*Math.PI),a[u+7]=Math.acos(p)/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 C=0;this._spherePoleIdx=0;for(let x=0;x<l;x++){const u=4*x;let d=e[u],p=e[u+1],n=e[u+2],w=e[u+3];const f=8*d,v=8*p,I=8*n,P=8*w;a[f+2]+a[v+2]+a[I+2]<0&&(a[f+6]===0&&(d=h[d]),a[v+6]===0&&(p=h[p]),a[I+6]===0&&(n=h[n]),a[P+6]===0&&(w=h[w])),y[C]=d,y[C+1]=p,y[C+2]=n,this._generateAndReplacePoleUV(y,a,C,R),y[C+3]=d,y[C+4]=n,y[C+5]=w,this._generateAndReplacePoleUV(y,a,C+3,R),C+=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,i,o,e){const c=i[8*s[o]+7];if(c===0||c===1){const l=8*s[o],R=8*(e+this._spherePoleIdx);i.set(i.subarray(l,l+8),R),i[R+6]=.5*(i[l+6]+i[8*s[o+1]+6]+i[8*s[o+2]+6]-.5),s[o]=e+this._spherePoleIdx++}}static _subdiveCatmullClark(s,i,o){const e=new Map,c=new Array;i.set(this._sphereSeedPositions),o.set(this._sphereSeedCells);for(let l=0;l<s;l++){const R=6*Math.pow(4,l),t=4*R+2;e.clear(),c.length=0;for(let C=0;C<R;C++){const g=c[C]={facePoint:new rt,adjacentEdges:new Array(4)};for(let x=0;x<4;x++){const u=3*o[4*C+x];g.facePoint.x+=.25*i[u],g.facePoint.y+=.25*i[u+1],g.facePoint.z+=.25*i[u+2]}for(let x=0;x<4;x++){const u=o[4*C+x],d=o[4*C+(x+1)%4],p=Math.min(u,d)*t+Math.max(u,d);if(!e.has(p)){const v={edgePoint:new rt,edgePointIndex:void 0},I=3*u,P=3*d;v.edgePoint.set(.25*(i[I]+i[P]),.25*(i[I+1]+i[P+1]),.25*(i[I+2]+i[P+2])),e.set(p,v)}const n=e.get(p);g.adjacentEdges[x]=n;const w=n.edgePoint,f=g.facePoint;w.x+=.25*f.x,w.y+=.25*f.y,w.z+=.25*f.z}}const a=R+2,y=a+R;let m=0;this._sphereEdgeIdx=0;const h=o.slice(0,4*R);for(let C=0;C<R;C++){const g=c[C];g.facePoint.copyToArray(i,3*(a+C));const x=a+C;let u,d,p;for(let n=0;n<4;n++){const w=h[m++];switch(n){case 0:{const v=g.adjacentEdges[n%4],I=g.adjacentEdges[(n+3)%4];d=this._calculateEdgeIndex(i,v,y),u=this._calculateEdgeIndex(i,I,y),p=u;break}case 1:case 2:{const v=g.adjacentEdges[n%4];u=d,d=this._calculateEdgeIndex(i,v,y);break}case 3:{u=d,d=p;break}}const f=4*(4*C+n);o[f]=w,o[f+1]=d,o[f+2]=x,o[f+3]=u}}}}static _calculateEdgeIndex(s,i,o){if(i.edgePointIndex!==void 0)return i.edgePointIndex;{i.edgePoint.copyToArray(s,3*(o+this._sphereEdgeIdx));const e=o+this._sphereEdgeIdx++;return i.edgePointIndex=e,e}}};A(z,"_tempVec30",new rt),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 G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]}function yt(M,s,{vertices:i,indices:o,bounds:e}){const c=new ut(s,dt.VertexBuffer,i,mt.Static),l=new ut(s,dt.IndexBuffer,o,mt.Static);M.setVertexElements(Ft()),M.setIndexBufferBinding(l,o instanceof Uint16Array?ft.UInt16:ft.UInt32),M.setVertexBufferBinding(c,32),M.bounds=e,M.subMesh?M.subMesh.count=o.length:M.addSubMesh(0,o.length)}class St extends Pt{constructor(s,i,o){super(s),this.engine=i,this.generateData=o}restoreContent(){yt(this.resource,this.engine,this.generateData())}}function Ot(M,s,i){s.resourceManager.addContentRestorer(new St(M,s,i))}var jt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,V=(M,s,i,o)=>{for(var e=o>1?void 0:o?Ut(s,i):s,c=M.length-1,l;c>=0;c--)(l=M[c])&&(e=(o?l(s,i,e):l(e))||e);return o&&e&&jt(s,i,e),e},bt=(M=>(M.Sphere="sphere",M.Cuboid="cuboid",M.Plane="plane",M.Cylinder="cylinder",M.Torus="torus",M.Cone="cone",M.Capsule="capsule",M))(bt||{});const gt=M=>M.type==="sphere",it=M=>M.type==="capsule",at=M=>M.type==="cone",lt=M=>M.type==="cuboid",ot=M=>M.type==="cylinder",st=M=>M.type==="torus",ct=M=>M.type==="plane",T=M=>M._updateData();let H=class extends It{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,i,o){const c=(typeof(o==null?void 0:o.primitiveType)=="string"?o.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,i){const o=JSON.parse(await s.text()),e=this.engine,c=o.type,l=new At(e,c);l.setVertexElements([new G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]);for(const y in o)this[y]=o[y];this.bindEngineObject(l),Ot(l,e,()=>this._generateDataByType(this.type)),this._updateData();const R=new Ht(e,c&&c.charAt(0).toUpperCase()+c.slice(1)),t=R.addComponent(Vt);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(),i=this.getDragTempEntity();return s.initByEngineObject(i.clone()),s}_updateData(){const s=this.engine,i=this._engineObject;yt(i,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)}}};V([_({label:b("asset.primitive-mesh.type.label"),info:b("asset.primitive-mesh.type.info"),type:B.Select,value:"sphere",options:_t(bt),onChange(M){M._updateData()}}),N()],H.prototype,"type",2);V([_({label:b("asset.primitive-mesh.sphere.radius.label"),info:b("asset.primitive-mesh.sphere.radius.info"),type:B.Number,min:0,dragStep:.1,when:gt,onChange:T}),N()],H.prototype,"sphereRadius",2);V([_({label:b("asset.primitive-mesh.sphere.step.label"),info:b("asset.primitive-mesh.sphere.step.info"),type:B.Number,min:1,dragStep:1,when:gt,onChange:T}),N()],H.prototype,"sphereStep",2);V([_({label:b("asset.primitive-mesh.capsule.radius.label"),info:b("asset.primitive-mesh.capsule.radius.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleRadius",2);V([_({label:b("asset.primitive-mesh.capsule.height.label"),info:b("asset.primitive-mesh.capsule.height.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleHeight",2);V([_({label:b("asset.primitive-mesh.capsule.radial-segments.label"),info:b("asset.primitive-mesh.capsule.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleRadialSegments",2);V([_({label:b("asset.primitive-mesh.capsule.height-segments.label"),info:b("asset.primitive-mesh.capsule.height-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleHeightSegments",2);V([_({label:b("asset.primitive-mesh.cone.radius.label"),info:b("asset.primitive-mesh.cone.radius.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneRadius",2);V([_({label:b("asset.primitive-mesh.cone.height.label"),info:b("asset.primitive-mesh.cone.height.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneHeight",2);V([_({label:b("asset.primitive-mesh.cone.radial-segments.label"),info:b("asset.primitive-mesh.cone.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneRadialSegment",2);V([_({label:b("asset.primitive-mesh.cone.height-segments.label"),info:b("asset.primitive-mesh.cone.height-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneHeightSegment",2);V([_({label:b("asset.primitive-mesh.cuboid.width.label"),info:b("asset.primitive-mesh.cuboid.width.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidWidth",2);V([_({label:b("asset.primitive-mesh.cuboid.height.label"),info:b("asset.primitive-mesh.cuboid.height.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidHeight",2);V([_({label:b("asset.primitive-mesh.cuboid.depth.label"),info:b("asset.primitive-mesh.cuboid.depth.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidDepth",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-top.label"),info:b("asset.primitive-mesh.cylinder.radius-top.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusTop",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-bottom.label"),info:b("asset.primitive-mesh.cylinder.radius-bottom.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusBottom",2);V([_({label:b("asset.primitive-mesh.cylinder.height.label"),info:b("asset.primitive-mesh.cylinder.height.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeight",2);V([_({label:b("asset.primitive-mesh.cylinder.radial-segments.label"),info:b("asset.primitive-mesh.cylinder.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadialSegment",2);V([_({label:b("asset.primitive-mesh.cylinder.height-segments.label"),info:b("asset.primitive-mesh.cylinder.height-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeightSegment",2);V([_({label:b("asset.primitive-mesh.plane.width.label"),info:b("asset.primitive-mesh.plane.width.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeWidth",2);V([_({label:b("asset.primitive-mesh.plane.height.label"),info:b("asset.primitive-mesh.plane.height.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeHeight",2);V([_({label:b("asset.primitive-mesh.plane.horizontal-segments.label"),info:b("asset.primitive-mesh.plane.horizontal-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeHorizontalSegments",2);V([_({label:b("asset.primitive-mesh.plane.vertical-segments.label"),info:b("asset.primitive-mesh.plane.vertical-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeVerticalSegments",2);V([_({label:b("asset.primitive-mesh.torus.radius.label"),info:b("asset.primitive-mesh.torus.radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusRadius",2);V([_({label:b("asset.primitive-mesh.torus.tube-radius.label"),info:b("asset.primitive-mesh.torus.tube-radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusTubeRadius",2);V([_({label:b("asset.primitive-mesh.torus.radial-segments.label"),info:b("asset.primitive-mesh.torus.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusRadialSegments",2);V([_({label:b("asset.primitive-mesh.torus.tubular-segments.label"),info:b("asset.primitive-mesh.torus.tubular-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusTubularSegments",2);V([_({label:b("asset.primitive-mesh.torus.arc.label"),info:b("asset.primitive-mesh.torus.arc.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusArc",2);H=V([Bt({type:"PrimitiveMesh",label:b("asset.primitive-mesh.title"),loaderType:"PrimitiveMesh",importMenuConfig:{type:Nt.Add},defaultName:"Mesh",dragLayer:Tt.PrimitiveMesh,thumbnail:Et,async bundle({content:M}){return{content:new Blob([Dt(await M.text())])}}})],H);export{H as PrimitiveMesh};
1
+ var wt=Object.defineProperty;var Mt=(M,s,i)=>s in M?wt(M,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):M[s]=i;var A=(M,s,i)=>(Mt(M,typeof s!="symbol"?s+"":s,i),i);import{ai as rt,B as q,bv as Rt,a5 as ut,a6 as dt,a7 as mt,a9 as ft,a3 as G,bw as tt,a4 as et,bx as Pt,j as It,by as At,K as Ht,y as Vt,p as _,e as b,C as B,t as _t,m as N,n as Bt,o as Nt,q as Tt}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Dt}from"./bundlers-9b0d37fc.js";import{M as Et}from"./MeshThumbnail-9bbe01dc.js";const z=class z{static createSphere(s=.5,i=18){i=Math.max(2,Math.floor(i));const o=i+1,e=o*o,c=i*i,l=z._generateIndices(e,c*6),R=Math.PI,t=R*2,a=1/o,y=1/i,m=8,h=new Float32Array(e*m);for(let x=0;x<e;++x){const u=x%o,d=x*a|0,p=u*y,n=d*y,w=p*t,f=n*R,v=Math.sin(f),I=-s*Math.cos(w)*v,P=s*Math.cos(f),S=s*Math.sin(w)*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++]=p,h[r++]=n}let C=0;for(let x=0;x<c;++x){const u=x%i,p=(x*y|0)*o+u,n=p+1,w=p+o,f=w+1;l[C++]=n,l[C++]=p,l[C++]=f,l[C++]=p,l[C++]=w,l[C++]=f}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:l,vertices:h,bounds:g}}static createCuboid(s=1,i=1,o=1){const e=s/2,c=i/2,l=o/2,R=8,t=new Float32Array(24*R);t[0]=-e,t[1]=c,t[2]=-l,t[6]=0,t[7]=0,t[8]=e,t[9]=c,t[10]=-l,t[14]=1,t[15]=0,t[16]=e,t[17]=c,t[18]=l,t[22]=1,t[23]=1,t[24]=-e,t[25]=c,t[26]=l,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]=-e,t[33]=-c,t[34]=-l,t[38]=0,t[39]=1,t[40]=e,t[41]=-c,t[42]=-l,t[46]=1,t[47]=1,t[48]=e,t[49]=-c,t[50]=l,t[54]=1,t[55]=0,t[56]=-e,t[57]=-c,t[58]=l,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]=-e,t[65]=c,t[66]=-l,t[70]=0,t[71]=0,t[72]=-e,t[73]=c,t[74]=l,t[78]=1,t[79]=0,t[80]=-e,t[81]=-c,t[82]=l,t[86]=1,t[87]=1,t[88]=-e,t[89]=-c,t[90]=-l,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]=e,t[97]=c,t[98]=-l,t[102]=1,t[103]=0,t[104]=e,t[105]=c,t[106]=l,t[110]=0,t[111]=0,t[112]=e,t[113]=-c,t[114]=l,t[118]=0,t[119]=1,t[120]=e,t[121]=-c,t[122]=-l,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]=-e,t[129]=c,t[130]=l,t[134]=0,t[135]=0,t[136]=e,t[137]=c,t[138]=l,t[142]=1,t[143]=0,t[144]=e,t[145]=-c,t[146]=l,t[150]=1,t[151]=1,t[152]=-e,t[153]=-c,t[154]=l,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]=-e,t[161]=c,t[162]=-l,t[166]=1,t[167]=0,t[168]=e,t[169]=c,t[170]=-l,t[174]=0,t[175]=0,t[176]=e,t[177]=-c,t[178]=-l,t[182]=0,t[183]=1,t[184]=-e,t[185]=-c,t[186]=-l,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(-e,-c,-l),y.max.set(e,c,l),{vertices:t,bounds:y,indices:a}}static createPlane(s=1,i=1,o=1,e=1){o=Math.max(1,Math.floor(o)),e=Math.max(1,Math.floor(e));const c=o+1,l=e+1,R=s/2,t=i/2,a=s/o,y=i/e,m=c*l,h=e*o,C=z._generateIndices(m,h*6),g=1/c,x=1/o,u=1/e,d=8,p=new Float32Array(m*d);for(let f=0;f<m;++f){const v=f%c,I=f*g|0;let P=f*d;p[P++]=v*a-R,p[P++]=0,p[P++]=I*y-t,p[P++]=0,p[P++]=1,p[P++]=0,p[P++]=v*x,p[P++]=I*u}let n=0;for(let f=0;f<h;++f){const v=f%o,P=(f*x|0)*c+v,S=P+1,r=P+c,D=r+1;C[n++]=P,C[n++]=r,C[n++]=S,C[n++]=r,C[n++]=D,C[n++]=S}const w=new q;return w.min.set(-R,0,-t),w.max.set(R,0,t),{bounds:w,vertices:p,indices:C}}static createCylinder(s=.5,i=.5,o=2,e=20,c=1){e=Math.floor(e),c=Math.floor(c);const l=e+1,R=c+1,t=o*.5,a=o/c,y=l*R,m=e*c,h=e*2,C=y+2+h,g=z._generateIndices(C,m*6+h*3),x=1/l,u=1/e,d=1/c,p=8,n=new Float32Array(C*p);let w=0;const f=Math.PI,v=Math.PI*2,I=i-s,P=I/o,S=I/c;for(let F=0;F<y;++F){const Z=F%l,W=F*x|0,O=Z*u,J=W*d,$=f+O*v,nt=Math.sin($),pt=Math.cos($),ht=i-W*S,xt=ht*nt,vt=W*a-t,Ct=ht*pt;let L=F*p;n[L++]=xt,n[L++]=vt,n[L++]=Ct,n[L++]=nt,n[L++]=P,n[L++]=pt,n[L++]=O,n[L++]=1-J}for(let F=0;F<m;++F){const Z=F%e,O=(F*u|0)*l+Z,J=O+1,$=O+l,nt=$+1;g[w++]=J,g[w++]=$,g[w++]=O,g[w++]=J,g[w++]=nt,g[w++]=$}let r=y*p;n[r++]=0,n[r++]=-t,n[r++]=0,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=.5,n[r++]=.5,n[r++]=0,n[r++]=t,n[r++]=0,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=.5,n[r++]=.5,r=(y+2)*p;const D=1/(s*2),j=1/(i*2),E=l*c;for(let F=0;F<e;++F){const Z=F*p;let W=n[Z],O=n[Z+2];n[r++]=W,n[r++]=-t,n[r++]=O,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=W*j+.5,n[r++]=.5-O*j;const J=(F+E)*p;W=n[J],O=n[J+2],n[r++]=W,n[r++]=t,n[r++]=O,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=W*D+.5,n[r++]=.5-O*D}const Y=y+1,X=y+2,U=X+1;for(let F=0;F<e;++F){const Z=F*2,W=F===e-1?0:Z+2;g[w++]=y,g[w++]=X+W,g[w++]=X+Z,g[w++]=Y,g[w++]=U+Z,g[w++]=U+W}const Q=new q,K=Math.max(s,i);return Q.min.set(-K,-t,-K),Q.max.set(K,t,K),{bounds:Q,vertices:n,indices:g}}static createTorus(s=.5,i=.1,o=30,e=30,c=360){o=Math.floor(o),e=Math.floor(e);const l=(o+1)*(e+1),R=o*e,t=z._generateIndices(l,R*6),a=8,y=new Float32Array(l*a);c=c/180*Math.PI;let m=0;const h=z._tempVec30;for(let x=0;x<=o;x++)for(let u=0;u<=e;u++){const d=u/e*c,p=x/o*Math.PI*2,n=Math.cos(p),w=Math.sin(p),f=Math.cos(d),v=Math.sin(d),I=(s+i*n)*f,P=(s+i*n)*v,S=i*w;y[m++]=I,y[m++]=P,y[m++]=S;const r=s*f,D=s*v;h.set(I-r,P-D,S).normalize(),y[m++]=h.x,y[m++]=h.y,y[m++]=h.z,y[m++]=u/e,y[m++]=x/o}m=0;for(let x=1;x<=o;x++)for(let u=1;u<=e;u++){const d=(e+1)*x+u-1,p=(e+1)*(x-1)+u-1,n=(e+1)*(x-1)+u,w=(e+1)*x+u;t[m++]=d,t[m++]=p,t[m++]=w,t[m++]=p,t[m++]=n,t[m++]=w}const C=new q,g=s+i;return C.min.set(-g,-g,-i),C.max.set(g,g,i),{bounds:C,vertices:y,indices:t}}static createCone(s=.5,i=2,o=20,e=1){o=Math.floor(o),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=a+1+o,h=z._generateIndices(m,y*6+o*3),C=1/c,g=1/o,x=1/e,u=8,d=new Float32Array(m*8);let p=0;const n=Math.PI,w=Math.PI*2,f=s/i;for(let r=0;r<a;++r){const D=r%c,j=r*C|0,E=D*g,Y=j*x,X=n+E*w,U=Math.sin(X),Q=Math.cos(X),K=s-j*s,F=K*U,Z=j*t-R,W=K*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++]=E,d[O++]=1-Y}for(let r=0;r<y;++r){const D=r%o,E=(r*g|0)*c+D,Y=E+1,X=E+c,U=X+1;h[p++]=Y,h[p++]=X,h[p++]=E,h[p++]=Y,h[p++]=U,h[p++]=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<o;++r){const D=d[r*u],j=d[r*u+2];d[v++]=D,d[v++]=-R,d[v++]=j,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=D*I+.5,d[v++]=.5-j*I}const P=a+1;for(let r=0;r<o;++r){const D=r,j=r===o-1?0:D+1;h[p++]=a,h[p++]=P+j,h[p++]=P+D}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,i=2,o=6,e=1){o=Math.max(2,Math.floor(o)),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=c*c,h=o*o,C=a+2*m,g=z._generateIndices(C,(y+2*h)*6),x=1/c,u=1/o,d=1/e,p=Math.PI,n=Math.PI*2,w=8,f=new Float32Array(C*w);let v=0;for(let P=0;P<a;++P){const S=P%c,r=P*x|0,D=S*u,j=r*d,E=p+D*n,Y=Math.sin(E),X=Math.cos(E);let U=P*w;f[U++]=s*Y,f[U++]=r*t-R,f[U++]=s*X,f[U++]=Y,f[U++]=0,f[U++]=X,f[U++]=D,f[U++]=1-j}for(let P=0;P<y;++P){const S=P%o,D=(P*u|0)*c+S,j=D+1,E=D+c,Y=E+1;g[v++]=j,g[v++]=E,g[v++]=D,g[v++]=j,g[v++]=Y,g[v++]=E}z._createCapsuleCap(s,i,o,p,n,a,1,f,g,v),z._createCapsuleCap(s,i,o,p,-n,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,i){let o=null;return s>65535?o=new Uint32Array(i):o=new Uint16Array(i),o}static _createCapsuleCap(s,i,o,e,c,l,R,t,a,y){const m=o+1,h=i*.5*R,C=m*m,g=o*o,x=1/m,u=1/o,d=8;for(let p=0;p<C;++p){const n=p%m,w=p*x|0,f=n*u,v=w*u,I=e+f*c,P=v*Math.PI*.5,S=Math.sin(P),r=s*Math.sin(I)*S,D=s*Math.cos(P)*R+h,j=s*Math.cos(I)*S;let E=(p+l)*d;t[E++]=r,t[E++]=D,t[E++]=j,t[E++]=r,t[E++]=D-h,t[E++]=j,t[E++]=f,t[E++]=v}for(let p=0;p<g;++p){const n=p%o,f=(p*u|0)*m+n+l,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,i=3){i=Rt.clamp(Math.floor(i),1,6);const o=new Float32Array(3*(6*Math.pow(4,i)+2)),e=new Float32Array(24*Math.pow(4,i));this._subdiveCatmullClark(i,o,e);const c=o.length/3,l=e.length/4,R=c+Math.pow(2,i+1)-1,t=R+16,a=new Float32Array(t*8),y=this._generateIndices(c,l*6);let m=0;const h={};for(let x=0;x<c;x++){let u=3*x,d=o[u],p=o[u+1],n=o[u+2];const w=1/Math.sqrt(d*d+p*p+n*n);if(d*=w,p*=w,n*=w,u=8*x,a[u]=d*s,a[u+1]=p*s,a[u+2]=n*s,a[u+3]=d,a[u+4]=p,a[u+5]=n,a[u+6]=(Math.PI-Math.atan2(n,d))/(2*Math.PI),a[u+7]=Math.acos(p)/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 C=0;this._spherePoleIdx=0;for(let x=0;x<l;x++){const u=4*x;let d=e[u],p=e[u+1],n=e[u+2],w=e[u+3];const f=8*d,v=8*p,I=8*n,P=8*w;a[f+2]+a[v+2]+a[I+2]<0&&(a[f+6]===0&&(d=h[d]),a[v+6]===0&&(p=h[p]),a[I+6]===0&&(n=h[n]),a[P+6]===0&&(w=h[w])),y[C]=d,y[C+1]=p,y[C+2]=n,this._generateAndReplacePoleUV(y,a,C,R),y[C+3]=d,y[C+4]=n,y[C+5]=w,this._generateAndReplacePoleUV(y,a,C+3,R),C+=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,i,o,e){const c=i[8*s[o]+7];if(c===0||c===1){const l=8*s[o],R=8*(e+this._spherePoleIdx);i.set(i.subarray(l,l+8),R),i[R+6]=.5*(i[l+6]+i[8*s[o+1]+6]+i[8*s[o+2]+6]-.5),s[o]=e+this._spherePoleIdx++}}static _subdiveCatmullClark(s,i,o){const e=new Map,c=new Array;i.set(this._sphereSeedPositions),o.set(this._sphereSeedCells);for(let l=0;l<s;l++){const R=6*Math.pow(4,l),t=4*R+2;e.clear(),c.length=0;for(let C=0;C<R;C++){const g=c[C]={facePoint:new rt,adjacentEdges:new Array(4)};for(let x=0;x<4;x++){const u=3*o[4*C+x];g.facePoint.x+=.25*i[u],g.facePoint.y+=.25*i[u+1],g.facePoint.z+=.25*i[u+2]}for(let x=0;x<4;x++){const u=o[4*C+x],d=o[4*C+(x+1)%4],p=Math.min(u,d)*t+Math.max(u,d);if(!e.has(p)){const v={edgePoint:new rt,edgePointIndex:void 0},I=3*u,P=3*d;v.edgePoint.set(.25*(i[I]+i[P]),.25*(i[I+1]+i[P+1]),.25*(i[I+2]+i[P+2])),e.set(p,v)}const n=e.get(p);g.adjacentEdges[x]=n;const w=n.edgePoint,f=g.facePoint;w.x+=.25*f.x,w.y+=.25*f.y,w.z+=.25*f.z}}const a=R+2,y=a+R;let m=0;this._sphereEdgeIdx=0;const h=o.slice(0,4*R);for(let C=0;C<R;C++){const g=c[C];g.facePoint.copyToArray(i,3*(a+C));const x=a+C;let u,d,p;for(let n=0;n<4;n++){const w=h[m++];switch(n){case 0:{const v=g.adjacentEdges[n%4],I=g.adjacentEdges[(n+3)%4];d=this._calculateEdgeIndex(i,v,y),u=this._calculateEdgeIndex(i,I,y),p=u;break}case 1:case 2:{const v=g.adjacentEdges[n%4];u=d,d=this._calculateEdgeIndex(i,v,y);break}case 3:{u=d,d=p;break}}const f=4*(4*C+n);o[f]=w,o[f+1]=d,o[f+2]=x,o[f+3]=u}}}}static _calculateEdgeIndex(s,i,o){if(i.edgePointIndex!==void 0)return i.edgePointIndex;{i.edgePoint.copyToArray(s,3*(o+this._sphereEdgeIdx));const e=o+this._sphereEdgeIdx++;return i.edgePointIndex=e,e}}};A(z,"_tempVec30",new rt),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 G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]}function yt(M,s,{vertices:i,indices:o,bounds:e}){const c=new ut(s,dt.VertexBuffer,i,mt.Static),l=new ut(s,dt.IndexBuffer,o,mt.Static);M.setVertexElements(Ft()),M.setIndexBufferBinding(l,o instanceof Uint16Array?ft.UInt16:ft.UInt32),M.setVertexBufferBinding(c,32),M.bounds=e,M.subMesh?M.subMesh.count=o.length:M.addSubMesh(0,o.length)}class St extends Pt{constructor(s,i,o){super(s),this.engine=i,this.generateData=o}restoreContent(){yt(this.resource,this.engine,this.generateData())}}function Ot(M,s,i){s.resourceManager.addContentRestorer(new St(M,s,i))}var jt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,V=(M,s,i,o)=>{for(var e=o>1?void 0:o?Ut(s,i):s,c=M.length-1,l;c>=0;c--)(l=M[c])&&(e=(o?l(s,i,e):l(e))||e);return o&&e&&jt(s,i,e),e},bt=(M=>(M.Sphere="sphere",M.Cuboid="cuboid",M.Plane="plane",M.Cylinder="cylinder",M.Torus="torus",M.Cone="cone",M.Capsule="capsule",M))(bt||{});const gt=M=>M.type==="sphere",it=M=>M.type==="capsule",at=M=>M.type==="cone",lt=M=>M.type==="cuboid",ot=M=>M.type==="cylinder",st=M=>M.type==="torus",ct=M=>M.type==="plane",T=M=>M._updateData();let H=class extends It{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,i,o){const c=(typeof(o==null?void 0:o.primitiveType)=="string"?o.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,i){const o=JSON.parse(await s.text()),e=this.engine,c=o.type,l=new At(e,c);l.setVertexElements([new G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]);for(const y in o)this[y]=o[y];this.bindEngineObject(l),Ot(l,e,()=>this._generateDataByType(this.type)),this._updateData();const R=new Ht(e,c&&c.charAt(0).toUpperCase()+c.slice(1)),t=R.addComponent(Vt);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(),i=this.getDragTempEntity();return s.initByEngineObject(i.clone()),s}_updateData(){const s=this.engine,i=this._engineObject;yt(i,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)}}};V([_({label:b("asset.primitive-mesh.type.label"),info:b("asset.primitive-mesh.type.info"),type:B.Select,value:"sphere",options:_t(bt),onChange(M){M._updateData()}}),N()],H.prototype,"type",2);V([_({label:b("asset.primitive-mesh.sphere.radius.label"),info:b("asset.primitive-mesh.sphere.radius.info"),type:B.Number,min:0,dragStep:.1,when:gt,onChange:T}),N()],H.prototype,"sphereRadius",2);V([_({label:b("asset.primitive-mesh.sphere.step.label"),info:b("asset.primitive-mesh.sphere.step.info"),type:B.Number,min:1,dragStep:1,when:gt,onChange:T}),N()],H.prototype,"sphereStep",2);V([_({label:b("asset.primitive-mesh.capsule.radius.label"),info:b("asset.primitive-mesh.capsule.radius.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleRadius",2);V([_({label:b("asset.primitive-mesh.capsule.height.label"),info:b("asset.primitive-mesh.capsule.height.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleHeight",2);V([_({label:b("asset.primitive-mesh.capsule.radial-segments.label"),info:b("asset.primitive-mesh.capsule.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleRadialSegments",2);V([_({label:b("asset.primitive-mesh.capsule.height-segments.label"),info:b("asset.primitive-mesh.capsule.height-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleHeightSegments",2);V([_({label:b("asset.primitive-mesh.cone.radius.label"),info:b("asset.primitive-mesh.cone.radius.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneRadius",2);V([_({label:b("asset.primitive-mesh.cone.height.label"),info:b("asset.primitive-mesh.cone.height.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneHeight",2);V([_({label:b("asset.primitive-mesh.cone.radial-segments.label"),info:b("asset.primitive-mesh.cone.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneRadialSegment",2);V([_({label:b("asset.primitive-mesh.cone.height-segments.label"),info:b("asset.primitive-mesh.cone.height-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneHeightSegment",2);V([_({label:b("asset.primitive-mesh.cuboid.width.label"),info:b("asset.primitive-mesh.cuboid.width.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidWidth",2);V([_({label:b("asset.primitive-mesh.cuboid.height.label"),info:b("asset.primitive-mesh.cuboid.height.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidHeight",2);V([_({label:b("asset.primitive-mesh.cuboid.depth.label"),info:b("asset.primitive-mesh.cuboid.depth.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidDepth",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-top.label"),info:b("asset.primitive-mesh.cylinder.radius-top.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusTop",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-bottom.label"),info:b("asset.primitive-mesh.cylinder.radius-bottom.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusBottom",2);V([_({label:b("asset.primitive-mesh.cylinder.height.label"),info:b("asset.primitive-mesh.cylinder.height.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeight",2);V([_({label:b("asset.primitive-mesh.cylinder.radial-segments.label"),info:b("asset.primitive-mesh.cylinder.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadialSegment",2);V([_({label:b("asset.primitive-mesh.cylinder.height-segments.label"),info:b("asset.primitive-mesh.cylinder.height-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeightSegment",2);V([_({label:b("asset.primitive-mesh.plane.width.label"),info:b("asset.primitive-mesh.plane.width.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeWidth",2);V([_({label:b("asset.primitive-mesh.plane.height.label"),info:b("asset.primitive-mesh.plane.height.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeHeight",2);V([_({label:b("asset.primitive-mesh.plane.horizontal-segments.label"),info:b("asset.primitive-mesh.plane.horizontal-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeHorizontalSegments",2);V([_({label:b("asset.primitive-mesh.plane.vertical-segments.label"),info:b("asset.primitive-mesh.plane.vertical-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeVerticalSegments",2);V([_({label:b("asset.primitive-mesh.torus.radius.label"),info:b("asset.primitive-mesh.torus.radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusRadius",2);V([_({label:b("asset.primitive-mesh.torus.tube-radius.label"),info:b("asset.primitive-mesh.torus.tube-radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusTubeRadius",2);V([_({label:b("asset.primitive-mesh.torus.radial-segments.label"),info:b("asset.primitive-mesh.torus.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusRadialSegments",2);V([_({label:b("asset.primitive-mesh.torus.tubular-segments.label"),info:b("asset.primitive-mesh.torus.tubular-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusTubularSegments",2);V([_({label:b("asset.primitive-mesh.torus.arc.label"),info:b("asset.primitive-mesh.torus.arc.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusArc",2);H=V([Bt({type:"PrimitiveMesh",label:b("asset.primitive-mesh.title"),loaderType:"PrimitiveMesh",importMenuConfig:{type:Nt.Add},defaultName:"Mesh",dragLayer:Tt.PrimitiveMesh,thumbnail:Et,async bundle({content:M}){return{content:new Blob([Dt(await M.text())])}}})],H);export{H as PrimitiveMesh};
@@ -1 +1 @@
1
- import{aH as n,aI as s,aJ as o,aK as i,av as t,aL as d,aM as c,aN as g}from"./index-b126bb6b.js";import{M as h}from"./MaterialInspector-3fb471d9.js";const m=n("div",{marginLeft:"5px"}),u=n(s,{borderRadius:"$3",padding:"$1_5",marginLeft:"-$1_5",marginRight:"-$0_5",marginBottom:"$1",color:"$gray11",cursor:"pointer",backgroundColor:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:"$grayA3"},variants:{open:{true:{boxShadow:"inset 0 0 0 1px $colors$grayA3",backgroundColor:"$grayA5","&:hover":{backgroundColor:"$grayA5"}}}}});function x(r){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...r,children:t.jsx("path",{fill:"currentColor",d:"m12 17.4l-3.9 3.9q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7l3.875-3.875q.575-.575 1.425-.575t1.425.575L17.3 19.9q.275.275.275.7t-.275.7t-.7.275t-.7-.275zm0-10.8l3.9-3.9q.275-.275.7-.275t.7.275t.275.7t-.275.7l-3.875 3.875Q12.85 8.55 12 8.55t-1.425-.575L6.7 4.1q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275z"})})}function p(r){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...r,children:t.jsx("path",{fill:"currentColor",d:"m12 19.15l3.875-3.875q.3-.3.7-.3t.7.3t.3.713t-.3.712l-3.85 3.875q-.575.575-1.425.575t-1.425-.575L6.7 16.7q-.3-.3-.288-.712t.313-.713t.713-.3t.712.3zm0-14.3L8.15 8.7q-.3.3-.7.288t-.7-.288q-.3-.3-.312-.712t.287-.713l3.85-3.85Q11.15 2.85 12 2.85t1.425.575l3.85 3.85q.3.3.288.713t-.313.712q-.3.275-.7.288t-.7-.288z"})})}const b=o(function(e){const{t:a}=i();return t.jsxs(u,{align:"v",justifyContent:"between",open:e.open,children:[t.jsxs(s,{align:"v",gap:"xs",children:[t.jsx("img",{src:e.thumbnailUrl,alt:a("mesh-renderer.material.thumbnail"),width:"20px",height:"20px"}),t.jsxs(m,{children:[a("mesh-renderer.material.title"),"(",e.name,")"]})]}),t.jsx(d,{size:"xs",variant:"subtle",children:e.open?t.jsx(x,{}):t.jsx(p,{})})]})}),w=r=>{const{materialAsset:e}=r,[a,l]=c.useState(!1);return t.jsx(g,{nesting:!0,title:t.jsx(b,{open:a,thumbnailUrl:e.thumbnailUrl,name:e.name}),defaultOpen:!1,open:a,onOpenChange:l,children:t.jsx(h,{asset:e})})};export{w as R};
1
+ import{aH as n,aI as s,aJ as o,aK as i,aL as t,aM as d,aN as c,aO as g}from"./index-d497fb6d.js";import{M as h}from"./MaterialInspector-45e208c7.js";const m=n("div",{marginLeft:"5px"}),u=n(s,{borderRadius:"$3",padding:"$1_5",marginLeft:"-$1_5",marginRight:"-$0_5",marginBottom:"$1",color:"$gray11",cursor:"pointer",backgroundColor:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:"$grayA3"},variants:{open:{true:{boxShadow:"inset 0 0 0 1px $colors$grayA3",backgroundColor:"$grayA5","&:hover":{backgroundColor:"$grayA5"}}}}});function x(r){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...r,children:t.jsx("path",{fill:"currentColor",d:"m12 17.4l-3.9 3.9q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7l3.875-3.875q.575-.575 1.425-.575t1.425.575L17.3 19.9q.275.275.275.7t-.275.7t-.7.275t-.7-.275zm0-10.8l3.9-3.9q.275-.275.7-.275t.7.275t.275.7t-.275.7l-3.875 3.875Q12.85 8.55 12 8.55t-1.425-.575L6.7 4.1q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275z"})})}function p(r){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...r,children:t.jsx("path",{fill:"currentColor",d:"m12 19.15l3.875-3.875q.3-.3.7-.3t.7.3t.3.713t-.3.712l-3.85 3.875q-.575.575-1.425.575t-1.425-.575L6.7 16.7q-.3-.3-.288-.712t.313-.713t.713-.3t.712.3zm0-14.3L8.15 8.7q-.3.3-.7.288t-.7-.288q-.3-.3-.312-.712t.287-.713l3.85-3.85Q11.15 2.85 12 2.85t1.425.575l3.85 3.85q.3.3.288.713t-.313.712q-.3.275-.7.288t-.7-.288z"})})}const b=o(function(e){const{t:a}=i();return t.jsxs(u,{align:"v",justifyContent:"between",open:e.open,children:[t.jsxs(s,{align:"v",gap:"xs",children:[t.jsx("img",{src:e.thumbnailUrl,alt:a("mesh-renderer.material.thumbnail"),width:"20px",height:"20px"}),t.jsxs(m,{children:[a("mesh-renderer.material.title"),"(",e.name,")"]})]}),t.jsx(d,{size:"xs",variant:"subtle",children:e.open?t.jsx(x,{}):t.jsx(p,{})})]})}),f=r=>{const{materialAsset:e}=r,[a,l]=c.useState(!1);return t.jsx(g,{nesting:!0,title:t.jsx(b,{open:a,thumbnailUrl:e.thumbnailUrl,name:e.name}),defaultOpen:!1,open:a,onOpenChange:l,children:t.jsx(h,{asset:e})})};export{f as R};
@@ -1 +1 @@
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{N as R,$ as y,a$ as l,j as x,a_ as v,by as S,p as b,C as m,m as f,n as G,e as F,o as O,q as D}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import{A as B}from"./AssetViewer-8338dfe1.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([G({type:"RenderTarget",label:F("asset.render-target.title"),extname:"renderTarget",importMenuConfig:{type:O.Add},dragLayer:D.RenderTarget,viewer:j,thumbnail:A,async bundle({content:s}){return{content:s}}})],u);export{u as RenderTargetAsset};
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{N as R,$ as y,b0 as l,j as x,a$ as v,bz as S,p as b,C as m,m as f,n as G,e as F,o as O,q as D}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";import{A as B}from"./AssetViewer-9f395efb.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([G({type:"RenderTarget",label:F("asset.render-target.title"),extname:"renderTarget",importMenuConfig:{type:O.Add},dragLayer:D.RenderTarget,viewer:j,thumbnail:A,async bundle({content:s}){return{content:s}}})],u);export{u as RenderTargetAsset};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var l=(t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>(l(t,typeof e!="symbol"?e+"":e,s),s);import{j as m,u as h,aX as u,aY as d,aZ as f,a_ as y,n as D,e as S,o as v}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";function b(t){const e={asset:{version:"2.0",generator:"Galacean Editor"},scene:{rootEntities:["1000000","1000001"],background:{mode:0,color:{r:.0157,g:.0157,b:.0157,a:1}},ambient:{},shadow:{},fog:{}},entities:[{id:"1000000",name:"Camera",position:[0,0,10],components:["1000100"]},{id:"1000001",name:"DirectLight",position:[0,3,0],rotation:[-45,-45,0],components:["1000101"]}],components:[{id:"1000100",type:"Camera",props:{isOrthographic:!1,nearClipPlane:.1,farClipPlane:100,viewport:{x:0,y:0,z:1,w:1}}},{id:"1000101",type:"DirectLight",props:{enabled:!0,intensity:.6,color:{r:1,g:1,b:1,a:1}}}]};return t!==void 0&&(e.scene.name=t),e}var g=Object.defineProperty,w=Object.getOwnPropertyDescriptor,C=(t,e,s,n)=>{for(var a=n>1?void 0:n?w(e,s):e,i=t.length-1,r;i>=0;i--)(r=t[i])&&(a=(n?r(e,s,a):r(a))||a);return n&&a&&g(e,s,a),a};let c=class extends m{constructor(e){super(e);o(this,"sceneData",null);h(this)}async initByMain(e,s){this.sceneData=u(await e.text())}getMainData(){return d(this.sceneData)}async rename(e){await super.rename(e),await this.root.assetFacade.persistAssetMain(this.id)}saveMainImmediately(e){var n;const s=this.root.sceneStore;if(this.id===s.refId){if(s.destroyed){f(this.root.projectStore.id,this.serverId);return}const a=y(this.root,this.id);return this.sceneData=a,this.sceneData.scene&&(this.sceneData.scene.name=this.name),super.saveMainImmediately(e)}else if((n=this.sceneData)!=null&&n.scene&&this.sceneData.scene.name!==this.name)return this.sceneData.scene.name=this.name,super.saveMainImmediately(e)}async initByCreation(e,s,n){return this.sceneData=b(this._name)}onDoubleClick(){this.root.projectStore.switchScene({scene:this.id})}};c=C([D({type:"Scene",label:S("asset.scene.title"),defaultName:"Scene",extname:"scene",importMenuConfig:{type:v.Add},async bundle(t){return{content:new Blob([t.content],{type:"application/json"})}}})],c);export{c as SceneAsset};
@@ -1,4 +1,4 @@
1
- var Vr=Object.defineProperty;var Fr=(e,c,i)=>c in e?Vr(e,c,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[c]=i;var Ae=(e,c,i)=>(Fr(e,typeof c!="symbol"?c+"":c,i),i);import{dN as Gr,b3 as Ke,dO as Br,dP as Tr,ag as kr,dQ as Ur,dR as Wr,a2 as Nr,a1 as zr,af as Hr,dS as jr,dT as rr,dU as dr,dV as qr,aH as Xr,aJ as wr,av as Je,e as ht,C as ue,dW as Qr,aO as Yr,b1 as vr,b2 as ir,j as $r,u as Jr,ae as Nt,dX as Zr,F as ar,ai as nr,V as sr,bX as Kr,aT as ei,x as ti,c2 as ri,n as ii,o as ai,dY as ni,dZ as si,d_ as oi}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Re,t as ci,g as li,i as ui,E as or,b as pi,l as hi}from"./ShaderUIScriptAsset-3c731f3b.js";import{E as de,s as fi}from"./shader-data-utils-c90e48b8.js";import{I as _i}from"./IconPointFilled-3ba6d082.js";import{F as di}from"./index-cd09e78a.js";function vi(e,c){const{precompile:i,platformTarget:t=0,basePathForIncludeKey:r}=c,n=i(e,t,r);return JSON.stringify(n)}function R(e,c){return c!=null&&typeof Symbol<"u"&&c[Symbol.hasInstance]?!!c[Symbol.hasInstance](e):e instanceof c}function tt(e,c){return tt=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},tt(e,c)}function D(e,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(c&&c.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),c&&tt(e,c)}function cr(e,c){for(var i=0;i<c.length;i++){var t=c[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function be(e,c,i){return c&&cr(e.prototype,c),i&&cr(e,i),e}function lr(e,c){(c==null||c>e.length)&&(c=e.length);for(var i=0,t=new Array(c);i<c;i++)t[i]=e[i];return t}function mi(e,c){if(e){if(typeof e=="string")return lr(e,c);var i=Object.prototype.toString.call(e).slice(8,-1);if(i==="Object"&&e.constructor&&(i=e.constructor.name),i==="Map"||i==="Set")return Array.from(i);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return lr(e,c)}}function Y(e,c){var i=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=mi(e))||c&&e&&typeof e.length=="number"){i&&(e=i);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1
+ var Vr=Object.defineProperty;var Fr=(e,c,i)=>c in e?Vr(e,c,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[c]=i;var Ae=(e,c,i)=>(Fr(e,typeof c!="symbol"?c+"":c,i),i);import{dO as Gr,b4 as Ke,dP as Br,dQ as Tr,ag as kr,dR as Ur,dS as Wr,a2 as Nr,a1 as zr,af as Hr,dT as jr,dU as rr,dV as dr,dW as qr,aH as Xr,aJ as wr,aL as Je,e as ht,C as ue,dX as Qr,aP as Yr,b2 as vr,b3 as ir,j as $r,u as Jr,ae as Nt,dY as Zr,F as ar,ai as nr,V as sr,b_ as Kr,aU as ei,x as ti,c5 as ri,n as ii,o as ai,dZ as ni,d_ as si,d$ as oi}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Re,t as ci,g as li,i as ui,E as or,b as pi,l as hi}from"./ShaderUIScriptAsset-d3a2d680.js";import{E as de,s as fi}from"./shader-data-utils-e38a959d.js";import{I as _i}from"./IconPointFilled-192e99c9.js";import{F as di}from"./index-68806c86.js";function vi(e,c){const{precompile:i,platformTarget:t=0,basePathForIncludeKey:r}=c,n=i(e,t,r);return JSON.stringify(n)}function R(e,c){return c!=null&&typeof Symbol<"u"&&c[Symbol.hasInstance]?!!c[Symbol.hasInstance](e):e instanceof c}function tt(e,c){return tt=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},tt(e,c)}function D(e,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(c&&c.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),c&&tt(e,c)}function cr(e,c){for(var i=0;i<c.length;i++){var t=c[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function be(e,c,i){return c&&cr(e.prototype,c),i&&cr(e,i),e}function lr(e,c){(c==null||c>e.length)&&(c=e.length);for(var i=0,t=new Array(c);i<c;i++)t[i]=e[i];return t}function mi(e,c){if(e){if(typeof e=="string")return lr(e,c);var i=Object.prototype.toString.call(e).slice(8,-1);if(i==="Object"&&e.constructor&&(i=e.constructor.name),i==="Map"||i==="Set")return Array.from(i);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return lr(e,c)}}function Y(e,c){var i=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=mi(e))||c&&e&&typeof e.length=="number"){i&&(e=i);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B(e,c,i,t){var r=arguments.length,n=r<3?c:t===null?t=Object.getOwnPropertyDescriptor(c,i):t,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,c,i,t);else for(var l=e.length-1;l>=0;l--)(s=e[l])&&(n=(r<3?s(n):r>3?s(c,i,n):s(c,i))||n);return r>3&&n&&Object.defineProperty(c,i,n),n}function Si(e,c){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},t,r,n,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=l(0),s.throw=l(1),s.return=l(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(_){return function(S){return u([_,S])}}function u(_){if(t)throw new TypeError("Generator is already executing.");for(;s&&(s=0,_[0]&&(i=0)),i;)try{if(t=1,r&&(n=_[0]&2?r.return:_[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,_[1])).done)return n;switch(r=0,n&&(_=[_[0]&2,n.value]),_[0]){case 0:case 1:n=_;break;case 4:return i.label++,{value:_[1],done:!1};case 5:i.label++,r=_[1],_=[0];continue;case 7:_=i.ops.pop(),i.trys.pop();continue;default:if(n=i.trys,!(n=n.length>0&&n[n.length-1])&&(_[0]===6||_[0]===2)){i=0;continue}if(_[0]===3&&(!n||_[1]>n[0]&&_[1]<n[3])){i.label=_[1];break}if(_[0]===6&&i.label<n[1]){i.label=n[1],n=_;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(_);break}n[2]&&i.ops.pop(),i.trys.pop();continue}_=c.call(e,i)}catch(S){_=[6,S],r=0}finally{t=n=0}if(_[0]&5)throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}}var mr=function(){function e(){}var c=e.prototype;return c.set=function(t,r){this.start=t,this.end=r},c.dispose=function(){this.start.dispose(),this.end.dispose()},e}(),Sr=function(){function e(){}var c=e.prototype;return c.set=function(t){this.index=t},c.dispose=function(){this.index=0},e}(),h=function(e){return e[e.ID=1e3]="ID",e[e.FLOAT_CONSTANT=1001]="FLOAT_CONSTANT",e[e.INT_CONSTANT=1002]="INT_CONSTANT",e[e.STRING_CONST=1003]="STRING_CONST",e[e.LEFT_OP=1004]="LEFT_OP",e[e.RIGHT_OP=1005]="RIGHT_OP",e[e.INC_OP=1006]="INC_OP",e[e.DEC_OP=1007]="DEC_OP",e[e.LE_OP=1008]="LE_OP",e[e.GE_OP=1009]="GE_OP",e[e.EQ_OP=1010]="EQ_OP",e[e.NE_OP=1011]="NE_OP",e[e.AND_OP=1012]="AND_OP",e[e.OR_OP=1013]="OR_OP",e[e.XOR_OP=1014]="XOR_OP",e[e.MUL_ASSIGN=1015]="MUL_ASSIGN",e[e.DIV_ASSIGN=1016]="DIV_ASSIGN",e[e.ADD_ASSIGN=1017]="ADD_ASSIGN",e[e.SUB_ASSIGN=1018]="SUB_ASSIGN",e[e.MOD_ASSIGN=1019]="MOD_ASSIGN",e[e.LEFT_ASSIGN=1020]="LEFT_ASSIGN",e[e.RIGHT_ASSIGN=1021]="RIGHT_ASSIGN",e[e.AND_ASSIGN=1022]="AND_ASSIGN",e[e.XOR_ASSIGN=1023]="XOR_ASSIGN",e[e.OR_ASSIGN=1024]="OR_ASSIGN",e[e.LEFT_PAREN=1025]="LEFT_PAREN",e[e.RIGHT_PAREN=1026]="RIGHT_PAREN",e[e.LEFT_BRACKET=1027]="LEFT_BRACKET",e[e.RIGHT_BRACKET=1028]="RIGHT_BRACKET",e[e.LEFT_BRACE=1029]="LEFT_BRACE",e[e.RIGHT_BRACE=1030]="RIGHT_BRACE",e[e.DOT=1031]="DOT",e[e.COMMA=1032]="COMMA",e[e.COLON=1033]="COLON",e[e.EQUAL=1034]="EQUAL",e[e.SEMICOLON=1035]="SEMICOLON",e[e.BANG=1036]="BANG",e[e.DASH=1037]="DASH",e[e.TILDE=1038]="TILDE",e[e.PLUS=1039]="PLUS",e[e.STAR=1040]="STAR",e[e.SLASH=1041]="SLASH",e[e.PERCENT=1042]="PERCENT",e[e.LEFT_ANGLE=1043]="LEFT_ANGLE",e[e.RIGHT_ANGLE=1044]="RIGHT_ANGLE",e[e.VERTICAL_BAR=1045]="VERTICAL_BAR",e[e.CARET=1046]="CARET",e[e.AMPERSAND=1047]="AMPERSAND",e[e.QUESTION=1048]="QUESTION",e[e.NotWord=1049]="NotWord",e[e.EPSILON=1998]="EPSILON",e[e.EOF=1999]="EOF",e}({}),_e=3e3,a=function(e){return e[e.CONST=0]="CONST",e[e.BOOL=1]="BOOL",e[e.FLOAT=2]="FLOAT",e[e.DOUBLE=3]="DOUBLE",e[e.INT=4]="INT",e[e.UINT=5]="UINT",e[e.BREAK=6]="BREAK",e[e.CONTINUE=7]="CONTINUE",e[e.DO=8]="DO",e[e.ELSE=9]="ELSE",e[e.FOR=10]="FOR",e[e.IF=11]="IF",e[e.WHILE=12]="WHILE",e[e.DISCARD=13]="DISCARD",e[e.RETURN=14]="RETURN",e[e.BVEC2=15]="BVEC2",e[e.BVEC3=16]="BVEC3",e[e.BVEC4=17]="BVEC4",e[e.IVEC2=18]="IVEC2",e[e.IVEC3=19]="IVEC3",e[e.IVEC4=20]="IVEC4",e[e.UVEC2=21]="UVEC2",e[e.UVEC3=22]="UVEC3",e[e.UVEC4=23]="UVEC4",e[e.VEC2=24]="VEC2",e[e.VEC3=25]="VEC3",e[e.VEC4=26]="VEC4",e[e.VEC4_ARRAY=27]="VEC4_ARRAY",e[e.MAT2=28]="MAT2",e[e.MAT3=29]="MAT3",e[e.MAT4=30]="MAT4",e[e.MAT2X3=31]="MAT2X3",e[e.MAT2X4=32]="MAT2X4",e[e.MAT3X2=33]="MAT3X2",e[e.MAT3X4=34]="MAT3X4",e[e.MAT4X2=35]="MAT4X2",e[e.MAT4X3=36]="MAT4X3",e[e.IN=37]="IN",e[e.OUT=38]="OUT",e[e.INOUT=39]="INOUT",e[e.CENTROID=40]="CENTROID",e[e.SAMPLER2D=41]="SAMPLER2D",e[e.SAMPLER3D=42]="SAMPLER3D",e[e.SAMPLER_CUBE=43]="SAMPLER_CUBE",e[e.SAMPLER2D_SHADOW=44]="SAMPLER2D_SHADOW",e[e.SAMPLER_CUBE_SHADOW=45]="SAMPLER_CUBE_SHADOW",e[e.SAMPLER2D_ARRAY=46]="SAMPLER2D_ARRAY",e[e.SAMPLER2D_ARRAY_SHADOW=47]="SAMPLER2D_ARRAY_SHADOW",e[e.I_SAMPLER2D=48]="I_SAMPLER2D",e[e.I_SAMPLER3D=49]="I_SAMPLER3D",e[e.I_SAMPLER_CUBE=50]="I_SAMPLER_CUBE",e[e.I_SAMPLER2D_ARRAY=51]="I_SAMPLER2D_ARRAY",e[e.U_SAMPLER2D=52]="U_SAMPLER2D",e[e.U_SAMPLER3D=53]="U_SAMPLER3D",e[e.U_SAMPLER_CUBE=54]="U_SAMPLER_CUBE",e[e.U_SAMPLER2D_ARRAY=55]="U_SAMPLER2D_ARRAY",e[e.STRUCT=56]="STRUCT",e[e.LAYOUT=57]="LAYOUT",e[e.LOCATION=58]="LOCATION",e[e.VOID=59]="VOID",e[e.PRECISION=60]="PRECISION",e[e.PRECISE=61]="PRECISE",e[e.HIGHP=62]="HIGHP",e[e.MEDIUMP=63]="MEDIUMP",e[e.LOWP=64]="LOWP",e[e.INVARIANT=65]="INVARIANT",e[e.SMOOTH=66]="SMOOTH",e[e.FLAT=67]="FLAT",e[e.NOPERSPECTIVE=68]="NOPERSPECTIVE",e[e.True=69]="True",e[e.False=70]="False",e[e.LeftBrace=71]="LeftBrace",e[e.RightBrace=72]="RightBrace",e[e.Equal=73]="Equal",e[e.BitwiseOr=74]="BitwiseOr",e[e.GSRenderQueueType=75]="GSRenderQueueType",e[e.GSBlendState=76]="GSBlendState",e[e.GSDepthState=77]="GSDepthState",e[e.GSStencilState=78]="GSStencilState",e[e.GSRasterState=79]="GSRasterState",e[e.GSEditorProperties=80]="GSEditorProperties",e[e.GSEditorMacros=81]="GSEditorMacros",e[e.GSEditor=82]="GSEditor",e[e.GSTags=83]="GSTags",e[e.GSVertexShader=84]="GSVertexShader",e[e.GSFragmentShader=85]="GSFragmentShader",e[e.GSSubShader=86]="GSSubShader",e[e.GSPass=87]="GSPass",e[e.GSBlendFactor=88]="GSBlendFactor",e[e.GSBlendOperation=89]="GSBlendOperation",e[e.GSBool=90]="GSBool",e[e.GSNumber=91]="GSNumber",e[e.GSColor=92]="GSColor",e[e.GSCompareFunction=93]="GSCompareFunction",e[e.GSStencilOperation=94]="GSStencilOperation",e[e.GSCullMode=95]="GSCullMode",e[e.GSColorWriteMask=96]="GSColorWriteMask",e[e.GSUsePass=97]="GSUsePass",e[e.MACRO_IF=98]="MACRO_IF",e[e.MACRO_IFDEF=99]="MACRO_IFDEF",e[e.MACRO_IFNDEF=100]="MACRO_IFNDEF",e[e.MACRO_ELSE=101]="MACRO_ELSE",e[e.MACRO_ELIF=102]="MACRO_ELIF",e[e.MACRO_ENDIF=103]="MACRO_ENDIF",e[e.MACRO_UNDEF=104]="MACRO_UNDEF",e[e.MACRO_DEFINE_EXPRESSION=105]="MACRO_DEFINE_EXPRESSION",e[e.MACRO_CONDITIONAL_EXPRESSION=106]="MACRO_CONDITIONAL_EXPRESSION",e[e.MACRO_CALL=107]="MACRO_CALL",e[e.MACRO_DEFINE=108]="MACRO_DEFINE",e[e.MACRO_DEFINE_END=109]="MACRO_DEFINE_END",e[e.MACRO_DEFINE_PARAMS=110]="MACRO_DEFINE_PARAMS",e}({}),xe=function(){function e(){}return e.createObjectPool=function(i){var t=new Br(i);return e._shaderCompilerObjectPoolSet.push(t),t},e.clearAllShaderCompilerObjectPool=function(){for(var i=0,t=e._shaderCompilerObjectPoolSet.length;i<t;i++)e._shaderCompilerObjectPoolSet[i].clear()},e.createGSError=function(i,t,r,n,s){console.error(i);var l=new Error(i);return l.name=t,l},e}();xe._shaderCompilerObjectPoolSet=[];var Xt=[],w=function(){function e(){this.branch=Xt}var c=e.prototype;return c.set=function(t,r,n){if(this.type=t,this.lexeme=r,this.branch=Xt,n)if(R(n,mr))this.location=n;else{var s=Ce.createPosition(n.index+r.length);this.location=Ce.createRange(n,s)}},c.dispose=function(){},e}();w.pool=xe.createObjectPool(w);var wt=new w;wt.set(h.EOF,"/EOF");var o=function(e){return e[e.START=2e3]="START",e[e.gs_shader_program=2001]="gs_shader_program",e[e.global_declaration=2002]="global_declaration",e[e.variable_declaration=2003]="variable_declaration",e[e.variable_declaration_list=2004]="variable_declaration_list",e[e.variable_declaration_statement=2005]="variable_declaration_statement",e[e.array_specifier_list=2006]="array_specifier_list",e[e.array_specifier=2007]="array_specifier",e[e.ext_builtin_type_specifier_nonarray=2008]="ext_builtin_type_specifier_nonarray",e[e.precision_specifier=2009]="precision_specifier",e[e.variable_identifier=2010]="variable_identifier",e[e.variable_identifier_node=2011]="variable_identifier_node",e[e.primary_expression=2012]="primary_expression",e[e.postfix_expression=2013]="postfix_expression",e[e.integer_expression=2014]="integer_expression",e[e.function_call=2015]="function_call",e[e.function_call_generic=2016]="function_call_generic",e[e.function_call_header_no_parameters=2017]="function_call_header_no_parameters",e[e.function_call_header_with_parameters=2018]="function_call_header_with_parameters",e[e.function_call_parameter_list=2019]="function_call_parameter_list",e[e.function_call_header=2020]="function_call_header",e[e.function_identifier=2021]="function_identifier",e[e.constructor_identifier=2022]="constructor_identifier",e[e.unary_expression=2023]="unary_expression",e[e.unary_operator=2024]="unary_operator",e[e.multiplicative_expression=2025]="multiplicative_expression",e[e.additive_expression=2026]="additive_expression",e[e.shift_expression=2027]="shift_expression",e[e.relational_expression=2028]="relational_expression",e[e.equality_expression=2029]="equality_expression",e[e.and_expression=2030]="and_expression",e[e.inclusive_or_expression=2031]="inclusive_or_expression",e[e.exclusive_or_expression=2032]="exclusive_or_expression",e[e.logical_and_expression=2033]="logical_and_expression",e[e.logical_xor_expression=2034]="logical_xor_expression",e[e.logical_or_expression=2035]="logical_or_expression",e[e.conditional_expression=2036]="conditional_expression",e[e.assignment_expression=2037]="assignment_expression",e[e.assignment_operator=2038]="assignment_operator",e[e.expression=2039]="expression",e[e.integer_constant_expression=2040]="integer_constant_expression",e[e.integer_constant_expression_operator=2041]="integer_constant_expression_operator",e[e.declaration=2042]="declaration",e[e.function_prototype=2043]="function_prototype",e[e.function_declarator=2044]="function_declarator",e[e.function_header_with_parameters=2045]="function_header_with_parameters",e[e.function_header=2046]="function_header",e[e.function_parameter_list=2047]="function_parameter_list",e[e.parameter_declarator=2048]="parameter_declarator",e[e.parameter_declaration=2049]="parameter_declaration",e[e.parameter_qualifier=2050]="parameter_qualifier",e[e.parameter_type_specifier=2051]="parameter_type_specifier",e[e.init_declarator_list=2052]="init_declarator_list",e[e.single_declaration=2053]="single_declaration",e[e.fully_specified_type=2054]="fully_specified_type",e[e.type_qualifier=2055]="type_qualifier",e[e.single_type_qualifier=2056]="single_type_qualifier",e[e.storage_qualifier=2057]="storage_qualifier",e[e.precision_qualifier=2058]="precision_qualifier",e[e.interpolation_qualifier=2059]="interpolation_qualifier",e[e.invariant_qualifier=2060]="invariant_qualifier",e[e.type_specifier=2061]="type_specifier",e[e.type_specifier_nonarray=2062]="type_specifier_nonarray",e[e.type_specifier_no_prec=2063]="type_specifier_no_prec",e[e.basic_type=2064]="basic_type",e[e.struct_specifier=2065]="struct_specifier",e[e.struct_declaration_list=2066]="struct_declaration_list",e[e.struct_declaration=2067]="struct_declaration",e[e.layout_qualifier=2068]="layout_qualifier",e[e.struct_declarator_list=2069]="struct_declarator_list",e[e.struct_declarator=2070]="struct_declarator",e[e.identifier_list=2071]="identifier_list",e[e.decl_identifier=2072]="decl_identifier",e[e.initializer=2073]="initializer",e[e.initializer_list=2074]="initializer_list",e[e.declaration_statement=2075]="declaration_statement",e[e.simple_statement=2076]="simple_statement",e[e.compound_statement_no_scope=2077]="compound_statement_no_scope",e[e.statement_with_scope=2078]="statement_with_scope",e[e.compound_statement=2079]="compound_statement",e[e.statement=2080]="statement",e[e.statement_list=2081]="statement_list",e[e.iteration_statement_no_new_scope=2082]="iteration_statement_no_new_scope",e[e.expression_statement=2083]="expression_statement",e[e.selection_statement=2084]="selection_statement",e[e.selection_rest_statement=2085]="selection_rest_statement",e[e.condition=2086]="condition",e[e.conditionopt=2087]="conditionopt",e[e.iteration_statement=2088]="iteration_statement",e[e.for_init_statement=2089]="for_init_statement",e[e.for_rest_statement=2090]="for_rest_statement",e[e.jump_statement=2091]="jump_statement",e[e.external_declaration=2092]="external_declaration",e[e.function_definition=2093]="function_definition",e[e.field_selection=2094]="field_selection",e[e.bool_constant=2095]="bool_constant",e[e.function_identifier_node=2096]="function_identifier_node",e[e.typename_identifier_node=2097]="typename_identifier_node",e[e.scope_brace=2098]="scope_brace",e[e.scope_end_brace=2099]="scope_end_brace",e[e.macro_undef=2100]="macro_undef",e[e.macro_push_context=2101]="macro_push_context",e[e.macro_pop_context=2102]="macro_pop_context",e[e.macro_elif_expression=2103]="macro_elif_expression",e[e.macro_else_expression=2104]="macro_else_expression",e[e.global_macro_if_statement=2105]="global_macro_if_statement",e[e.global_macro_declaration=2106]="global_macro_declaration",e[e.global_macro_branch=2107]="global_macro_branch",e[e.macro_struct_declaration=2108]="macro_struct_declaration",e[e.macro_struct_branch=2109]="macro_struct_branch",e[e.macro_if_statement=2110]="macro_if_statement",e[e.macro_branch=2111]="macro_branch",e[e.macro_param_case_list=2112]="macro_param_case_list",e[e.macro_param_block=2113]="macro_param_block",e[e.macro_parameter_branch=2114]="macro_parameter_branch",e[e.macro_call_arg_case_list=2115]="macro_call_arg_case_list",e[e.macro_call_arg_block=2116]="macro_call_arg_block",e[e.macro_call_arg_branch=2117]="macro_call_arg_branch",e[e.macro_call_symbol=2118]="macro_call_symbol",e[e.macro_call_function=2119]="macro_call_function",e[e.macro_define=2120]="macro_define",e[e._ignore=2121]="_ignore",e}({}),Be=function(){function e(){}return e.unwrapNodeByType=function(i,t){var r=i.children[0];if(!R(r,w))return r.nt===t?r:e.unwrapNodeByType(r,t)},e.parseMacroParamList=function(i){var t=i.replace(/^\s*\(\s*|\s*\)\s*$/g,"");return t?t.split(",").map(function(r){return r.trim()}).filter(Boolean):[]},e.unwrapBareIdentifier=function(i,t){for(var r=i;;){if(R(r,P.VariableIdentifier))return r;if(t.allowParens&&R(r,P.PrimaryExpression)&&r.children.length===3){var n=r.children[1];if(!R(n,G))return;r=n;continue}if(R(r,P.ExpressionAstNode)&&r.children.length===1){var s=r.children[0];if(!R(s,G))return;r=s;continue}return}},e.extractDirectIdentLexeme=function(i){var t=e.unwrapBareIdentifier(i,{allowParens:!0});if(!t)return null;var r=t.children[0];return R(r,w)?r.lexeme:null},e.isTerminal=function(i){return i<o.START},e}();function gr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(gr=function(){return!!e})()}function Ne(e,c,i){return gr()?Ne=Reflect.construct:Ne=function(r,n,s){var l=[null];l.push.apply(l,n);var u=Function.bind.apply(r,l),_=new u;return s&&tt(_,s.prototype),_},Ne.apply(null,arguments)}function Qt(e){return Qt=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Qt(e)}function gi(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Yt(e){var c=typeof Map=="function"?new Map:void 0;return Yt=function(i){if(i===null||!gi(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof c<"u"){if(c.has(i))return c.get(i);c.set(i,t)}function t(){return Ne(i,arguments,Qt(this).constructor)}return t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),tt(t,i)},Yt(e)}var Cr=function(e){D(c,e);function c(t,r,n,s,l){var u;return u=e.call(this,r)||this,u.location=n,u.source=s,u.file=l,u.name=t,u}var i=c.prototype;return i.toString=function(){var r=this,n=r.message,s=r.location,l=r.source;if(!l)return n;R(s,Sr)||(s.start,s.end),l.split(`
3
3
  `);var u=this.name+": "+n+`
4
4