@galacean/cli 2.0.0-alpha.24 → 2.0.0-alpha.26

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 (92) hide show
  1. package/dist/cli.bundle.cjs +820 -957
  2. package/dist/preview-client/_static/{Accordion-f938dadf.js → Accordion-2cd014f1.js} +1 -1
  3. package/dist/preview-client/_static/{AmbientLightAsset-e34de607.js → AmbientLightAsset-be9e872c.js} +1 -1
  4. package/dist/preview-client/_static/{AnimationClipAsset-b084da2a.js → AnimationClipAsset-d7b37af0.js} +1 -1
  5. package/dist/preview-client/_static/{AnimatorControllerAsset-6cc04274.js → AnimatorControllerAsset-2716497a.js} +1 -1
  6. package/dist/preview-client/_static/{AnimatorStore-0bc90c37.js → AnimatorStore-883a28ad.js} +1 -1
  7. package/dist/preview-client/_static/{AssetViewer-d2c63b00.js → AssetViewer-3847c058.js} +1 -1
  8. package/dist/preview-client/_static/{AudioAsset-9c715952.js → AudioAsset-c28f33ab.js} +1 -1
  9. package/dist/preview-client/_static/{AudioComponent-80d06ef4.js → AudioComponent-3d6c73ce.js} +1 -1
  10. package/dist/preview-client/_static/{Callout-48e71f13.js → Callout-e2a89f6f.js} +1 -1
  11. package/dist/preview-client/_static/{CameraComponent-9c9db3fb.js → CameraComponent-3dc63451.js} +1 -1
  12. package/dist/preview-client/_static/{Component-b95aa2af.js → Component-0f881fc1.js} +1 -1
  13. package/dist/preview-client/_static/{DirectLight-b0490ef7.js → DirectLight-96dbba47.js} +1 -1
  14. package/dist/preview-client/_static/{FontAsset-6e9c0549.js → FontAsset-d34b5378.js} +1 -1
  15. package/dist/preview-client/_static/{FormItemArray-b2a3d249.js → FormItemArray-b8cda1d2.js} +1 -1
  16. package/dist/preview-client/_static/{GlTFAsset-83e8190e.js → GlTFAsset-5970e707.js} +2 -2
  17. package/dist/preview-client/_static/{IconPlus-172c6c17.js → IconPlus-def01e2b.js} +1 -1
  18. package/dist/preview-client/_static/{IconPointFilled-bad94cf1.js → IconPointFilled-62d3c3b2.js} +1 -1
  19. package/dist/preview-client/_static/{LightBaseComponent-b4854e8a.js → LightBaseComponent-d651a276.js} +1 -1
  20. package/dist/preview-client/_static/{LottieAnimationComponent-efd5da2b.js → LottieAnimationComponent-f10dc558.js} +1 -1
  21. package/dist/preview-client/_static/{MarkdownAsset-b42846c0.js → MarkdownAsset-b2a3fad5.js} +1 -1
  22. package/dist/preview-client/_static/{MaterialAsset-0b9d7eba.js → MaterialAsset-5353c4cb.js} +1 -1
  23. package/dist/preview-client/_static/{MaterialInspector-23ea0240.js → MaterialInspector-8d466d59.js} +1 -1
  24. package/dist/preview-client/_static/{Menu-05c1f0a4.js → Menu-c8e6194b.js} +1 -1
  25. package/dist/preview-client/_static/{MeshAsset-85e99837.js → MeshAsset-c2bf60c5.js} +1 -1
  26. package/dist/preview-client/_static/{MeshRendererBaseComponent-5621d663.js → MeshRendererBaseComponent-fde6b6a5.js} +1 -1
  27. package/dist/preview-client/_static/{MeshRendererComponent-c3c3c683.js → MeshRendererComponent-430774ef.js} +1 -1
  28. package/dist/preview-client/_static/{MeshThumbnail-b1283749.js → MeshThumbnail-07ffa076.js} +1 -1
  29. package/dist/preview-client/_static/ParticleRendererComponent-e106bd8c.js +26 -0
  30. package/dist/preview-client/_static/{PhysicsMaterialAsset-cb9afb6e.js → PhysicsMaterialAsset-a2f73b5c.js} +1 -1
  31. package/dist/preview-client/_static/{PhysicsStore-0a751fa0.js → PhysicsStore-818c2f61.js} +1 -1
  32. package/dist/preview-client/_static/{PointLight-a2bfed75.js → PointLight-add790ea.js} +1 -1
  33. package/dist/preview-client/_static/{PostProcessComponent-040cf521.js → PostProcessComponent-af270a77.js} +1 -1
  34. package/dist/preview-client/_static/{PrefabAsset-265f6f48.js → PrefabAsset-59743dbb.js} +1 -1
  35. package/dist/preview-client/_static/{PrimitiveMesh-70c93e7e.js → PrimitiveMesh-075dda8a.js} +1 -1
  36. package/dist/preview-client/_static/{ReferencedMaterial-831d0583.js → ReferencedMaterial-d11151b5.js} +1 -1
  37. package/dist/preview-client/_static/{RenderTargetAsset-b810caf3.js → RenderTargetAsset-b3cd1c49.js} +1 -1
  38. package/dist/preview-client/_static/{SceneAsset-d05b1a79.js → SceneAsset-08752701.js} +1 -1
  39. package/dist/preview-client/_static/{ShaderAsset-370b6f1c.js → ShaderAsset-a9d667f5.js} +1 -1
  40. package/dist/preview-client/_static/{ShaderChunkAsset-e3487bd1.js → ShaderChunkAsset-e43dde8a.js} +1 -1
  41. package/dist/preview-client/_static/{ShaderUIScriptAsset-ebf57ceb.js → ShaderUIScriptAsset-e1cd0b8b.js} +1 -1
  42. package/dist/preview-client/_static/{SkinnedMeshRendererComponent-ee33da25.js → SkinnedMeshRendererComponent-9756bd5f.js} +1 -1
  43. package/dist/preview-client/_static/{SpineAnimationComponent-12e694e8.js → SpineAnimationComponent-f3e0ff44.js} +1 -1
  44. package/dist/preview-client/_static/{SpineSkeletonDataAsset-0dffbb4d.js → SpineSkeletonDataAsset-43b731f1.js} +1 -1
  45. package/dist/preview-client/_static/{SpotLight-ada565f2.js → SpotLight-649b0e21.js} +1 -1
  46. package/dist/preview-client/_static/{SpriteBaseComponent-3156cb3b.js → SpriteBaseComponent-d2a7ab4c.js} +1 -1
  47. package/dist/preview-client/_static/{SpriteMaskComponent-a32024e1.js → SpriteMaskComponent-2c1cef5e.js} +1 -1
  48. package/dist/preview-client/_static/{SpriteRendererComponent-489486e0.js → SpriteRendererComponent-33b71997.js} +1 -1
  49. package/dist/preview-client/_static/{TextBaseComponent-520dea39.js → TextBaseComponent-9310e0c6.js} +1 -1
  50. package/dist/preview-client/_static/{TextRendererComponent-6be5f80c.js → TextRendererComponent-8dc0d7fb.js} +1 -1
  51. package/dist/preview-client/_static/{TextureAsset-9cd94531.js → TextureAsset-a7ff39b1.js} +1 -1
  52. package/dist/preview-client/_static/{Tooltip-71e5a4e7.js → Tooltip-b5be390f.js} +1 -1
  53. package/dist/preview-client/_static/{TrailRendererComponent-74bf88c0.js → TrailRendererComponent-c4635fab.js} +1 -1
  54. package/dist/preview-client/_static/{TransformBaseComponent-0d241199.js → TransformBaseComponent-1473deaa.js} +1 -1
  55. package/dist/preview-client/_static/{TransformComponent-49d279f5.js → TransformComponent-e544f7ac.js} +1 -1
  56. package/dist/preview-client/_static/{XRReferenceImageAsset-79e78558.js → XRReferenceImageAsset-96f516ba.js} +1 -1
  57. package/dist/preview-client/_static/{audio-5d0ddf55.js → audio-b5fbde34.js} +1 -1
  58. package/dist/preview-client/_static/{createOnModelChange-e65da908.js → createOnModelChange-370b83da.js} +1 -1
  59. package/dist/preview-client/_static/{createReactComponent-cb70ea50.js → createReactComponent-58d9f0dd.js} +1 -1
  60. package/dist/preview-client/_static/{index-7e414715.js → index-05b76766.js} +1 -1
  61. package/dist/preview-client/_static/{index-b13216a9.js → index-0dd5bb36.js} +1 -1
  62. package/dist/preview-client/_static/{index-d00c8bc3.js → index-29c59aff.js} +1 -1
  63. package/dist/preview-client/_static/index-3680d0e0.js +1 -0
  64. package/dist/preview-client/_static/index-42aa3a49.js +1 -0
  65. package/dist/preview-client/_static/index-496f331d.js +1 -0
  66. package/dist/preview-client/_static/{index-46c87b46.js → index-74bcfad9.js} +1 -1
  67. package/dist/preview-client/_static/{index-788e8750.js → index-88650db7.js} +1 -1
  68. package/dist/preview-client/_static/index-9f0122f0.js +1 -0
  69. package/dist/preview-client/_static/{index-b4bde36a.js → index-ab8556cb.js} +3 -3
  70. package/dist/preview-client/_static/{index-e44b357e.js → index-c3dec278.js} +11 -11
  71. package/dist/preview-client/_static/index-c6b7045c.js +1 -0
  72. package/dist/preview-client/_static/index-cdbb2f4d.js +1 -0
  73. package/dist/preview-client/_static/{index-ea7fe254.js → index-da16047f.js} +1 -1
  74. package/dist/preview-client/_static/{index-f7bd6fef.js → index-dd0763bf.js} +1 -1
  75. package/dist/preview-client/_static/index-dddcae01.js +1 -0
  76. package/dist/preview-client/_static/{ktx2-encoder-522fc017.js → ktx2-encoder-db93524f.js} +1 -1
  77. package/dist/preview-client/_static/{module-57b6e417.js → module-ada3dced.js} +1 -1
  78. package/dist/preview-client/_static/{module-5906e0d4.js → module-de7ee724.js} +1 -1
  79. package/dist/preview-client/_static/{module-5547be1c.js → module-ec094ef6.js} +1 -1
  80. package/dist/preview-client/_static/postmen-2853c0e6.js +2 -0
  81. package/dist/preview-client/_static/{shader-data-utils-000170ae.js → shader-data-utils-f0e4f5a3.js} +1 -1
  82. package/dist/preview-client/index.html +1 -1
  83. package/package.json +27 -32
  84. package/dist/preview-client/_static/ParticleRendererComponent-94656239.js +0 -26
  85. package/dist/preview-client/_static/index-0fef73f8.js +0 -1
  86. package/dist/preview-client/_static/index-1e036622.js +0 -1
  87. package/dist/preview-client/_static/index-1fd4207a.js +0 -1
  88. package/dist/preview-client/_static/index-6649d404.js +0 -1
  89. package/dist/preview-client/_static/index-87ef1c72.js +0 -1
  90. package/dist/preview-client/_static/index-d9ee84ce.js +0 -1
  91. package/dist/preview-client/_static/index-debbe073.js +0 -1
  92. package/dist/preview-client/_static/postmen-443b3e5f.js +0 -2
@@ -1 +1 @@
1
- var Le=Object.defineProperty;var qe=(o,e,t)=>e in o?Le(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var C=(o,e,t)=>(qe(o,typeof e!="symbol"?e+"":e,t),t);import{d_ as Ue,d$ as be,e0 as Je,aJ as ge,aK as Ge,av as M,bA as We,q as he,aN as Qe,aw as He,e1 as Xe,C as Ye,bE as Ze,e2 as Ie,e3 as W,e4 as et,e5 as tt,bX as nt,e as J,e6 as Ee,e7 as st,e8 as rt,e9 as ot,ea as it,eb as ct,ec as at,ed as dt,ee as ut,ef as ft,eg as lt,eh as ht,ei as pt,ej as mt,ek as we,el as yt,bV as Pe,em as ne,en as _e,eo as St,ep as bt,eq as gt,er as It,K as Ce,m as Et,aT as wt,x as Pt,aC as ke,n as _t,dL as Ct,es as Rt}from"./index-e44b357e.js";import{T as $t}from"./TaskQueue-05c94a4d.js";import{u as Re,I as vt}from"./index-debbe073.js";import"./postmen-443b3e5f.js";import{A as At}from"./AssetViewer-d2c63b00.js";function Tt(o,e,t){const n=[];function s(r){if(!(r==null||typeof r!="object")){if(Array.isArray(r)){for(const i of r)s(i);return}for(const i of Object.keys(r)){const c=r[i];if(e.includes(i)&&typeof c=="string"&&n.push(c),t){const a=t(i,c);a!==null&&n.push(a)}s(c)}}}return s(o),n}function A(o){return structuredClone(o)}function Q(o,e){const t=o.entities.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source entity "${e}" not found`);return t}function je(o,e){const t=o.components.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source component "${e}" not found`);return t}function oe(o,e,t){if(!t)return;const n=e==="scale"?[1,1,1]:[0,0,0],s=o[e]??n;o[e]=[t.x??s[0],t.y??s[1],t.z??s[2]]}function $e(o,e,t){const n=new Set(e),s=new Set;for(const r of t){if(s.has(r))throw new Error(`Prefab source ${o} id "${r}" is duplicated in the added source tree`);if(n.has(r))throw new Error(`Prefab source ${o} id "${r}" already exists`);s.add(r)}}function xt(o){return o.entities.map(e=>e.id)}function Be(o){return o.components.map(e=>e.id)}function Mt(o){const e=new Set(o.entityIds),t=new Set(o.componentIds);return o.entities.map((n,s)=>{var c,a;const r=o.entityIds[s],i=structuredClone(n);return i.id=r,(c=i.children)!=null&&c.length&&(i.children=i.children.map(d=>{const u=typeof d=="number"?o.entityIds[d]:d;if(!e.has(u))throw new Error(`Prefab added source entity "${r}" 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"?o.componentIds[d]:d;if(!t.has(u))throw new Error(`Prefab added source entity "${r}" component "${String(d)}" is outside added component list`);return u})),i})}function Ot(o){return o.components.map((e,t)=>({...structuredClone(e),id:o.componentIds[t]}))}function Dt(o,e){const t=new Map(o.entities.map(r=>[r.id,r])),n=new Set,s=r=>{if(n.has(r))return;n.add(r);const i=t.get(r);for(const c of(i==null?void 0:i.children)??[])s(c)};return s(e),n}function Ft(o,e,t){var r,i,c;if(!t)return A(o);const n=A(o),s=n.entities[Q(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",(r=t.transform)==null?void 0:r.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(o,e,t){if(!t||Object.keys(t).length===0)return A(o);const n=A(o),s=n.components[je(n,e)];return s.props=Ue(s.props??{},t),n}function jt(o,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(o),e.entityIds),$e("component",Be(o),e.componentIds);const t=A(o),n=t.entities[Q(t,e.parentSourceEntityId)],s=Mt(e),r=Ot(e),i=e.entityIds[0];t.entities.push(...s),t.components.push(...r);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 Bt(o,e){var l;const t=A(o),n=t.entities[Q(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={}),r=[...s.addedEntities??[]],i=Math.max(0,e.index);let c=0,a=r.length;for(let y=0;y<r.length;y+=1)if(r[y].parent===e.parentSourceEntityId){if(c===i){a=y;break}c+=1,a=y+1}const d=structuredClone(e.entity),u=d.id??`${e.instanceSourceEntityId}:added:${r.length}`;return d.id=u,r.splice(a,0,{id:u,parent:e.parentSourceEntityId,entity:d}),s.addedEntities=r,t}function zt(o,e){if(o.root===e)throw new Error("Cannot remove prefab root entity from source");Q(o,e);const t=Dt(o,e),n=new Set;for(const r of o.entities)if(t.has(r.id))for(const i of r.components??[])n.add(i);const s=A(o);return s.entities=s.entities.filter(r=>!t.has(r.id)).map(r=>{const i=structuredClone(r),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(r=>!n.has(r.id)),s}function Nt(o,e,t,n){if(Be(o).includes(t))throw new Error(`Prefab source component id "${t}" already exists`);const s=A(o),r=s.entities[Q(s,e)];return s.components.push({...structuredClone(n),id:t}),r.components=[...r.components??[],t],s}function Vt(o,e){je(o,e);const t=A(o);return t.components=t.components.filter(n=>n.id!==e),t.entities=t.entities.map(n=>{const s=structuredClone(n),r=(s.components??[]).filter(i=>i!==e);return r.length?s.components=r:delete s.components,s}),t}function Kt(o){switch(o.kind){case"add-source-entity":if(o.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(!o.sourceEntityId)throw new Error("Prefab source edit remove-source-entity requires a source entity id");return;case"add-source-component":if(!o.sourceComponentId)throw new Error("Prefab source edit add-source-component requires a source component id");return;case"remove-source-component":if(!o.sourceComponentId)throw new Error("Prefab source edit remove-source-component requires a source component id");return;case"add-nested-instance-entity":if(!o.instanceSourceEntityId)throw new Error("Prefab source edit add-nested-instance-entity requires an instance source entity id");if(!o.parentSourceEntityId)throw new Error("Prefab source edit add-nested-instance-entity requires a parent source entity id");return}}function ve(o,e){return o.length===e.length&&o.every((t,n)=>t===e[n])}function G(o,e,t){const n=new Set(e);for(const s of t)if(!n.has(s))throw new Error(`Prefab source edit expected ${o} id "${s}" to exist`)}function se(o,e,t){const n=new Set(e);for(const s of t)if(n.has(s))throw new Error(`Prefab source edit expected ${o} id "${s}" to be removed`)}function D(o){return o.entities.map(e=>e.id)}function z(o){return o.components.map(e=>e.id)}function ze(o,e){const t=o.entities.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source edit expected entity id "${e}" to exist`);return t}function Lt(o,e){var n;const t=ze(o,e);if(!((n=o.entities[t])!=null&&n.instance))throw new Error(`Prefab source edit expected entity id "${e}" to be an instance entity`)}function Ae(o,e,t){var s,r,i;const n=ze(o,e);return(((i=(r=(s=o.entities[n])==null?void 0:s.instance)==null?void 0:r.overrides)==null?void 0:i.addedEntities)??[]).filter(c=>c.parent===t).length}function F(o,e,t,n,s){if(o!=null){if(Array.isArray(o)){o.forEach((r,i)=>F(r,e,t,`${n}[${i}]`,s));return}if(Je(o)){o.$component===e&&s.push({entityId:t,propPath:n});for(const[r,i]of Object.entries(o))F(i,e,t,`${n}.${r}`,s)}}}function Ne(o,e,t,n,s){var r;F(o.props,e,t,`${n}.props`,s),(r=o.calls)==null||r.forEach((i,c)=>F(i,e,t,`${n}.calls[${c}]`,s))}function Ve(o,e,t,n,s){var r,i,c;(r=o.components)==null||r.forEach((a,d)=>Ne(a,e,t,`${n}.components[${d}]`,s)),(i=o.children)==null||i.forEach((a,d)=>Ve(a,e,t,`${n}.children[${d}]`,s)),Ke((c=o.instance)==null?void 0:c.overrides,e,t,`${n}.instance.overrides`,s)}function Ke(o,e,t,n,s){var r,i,c;(r=o==null?void 0:o.componentProps)==null||r.forEach((a,d)=>F(a.props,e,t,`${n}.componentProps[${d}].props`,s)),(i=o==null?void 0:o.addedComponents)==null||i.forEach((a,d)=>Ne(a.component,e,t,`${n}.addedComponents[${d}].component`,s)),(c=o==null?void 0:o.addedEntities)==null||c.forEach((a,d)=>Ve(a.entity,e,t,`${n}.addedEntities[${d}].entity`,s))}function qt(o,e){var s,r;const t=[],n=new Map;for(const i of o.entities)for(const c of i.components??[])n.set(c,i.id);for(const i of o.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 o.entities)Ke((r=i.instance)==null?void 0:r.overrides,e,i.id,`entities.${i.id}.instance.overrides`,t);return t}function Ut(o,e){const t=qt(o,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(o,e){switch(e.kind){case"add-source-entity":se("entity",D(o),e.sourceEntityIds);return;case"remove-source-entity":G("entity",D(o),[e.sourceEntityId]);return;case"add-source-component":se("component",z(o),[e.sourceComponentId]);return;case"remove-source-component":G("component",z(o),[e.sourceComponentId]),Ut(o,e.sourceComponentId);return;case"add-nested-instance-entity":G("entity",D(o),[e.instanceSourceEntityId]),Lt(o,e.instanceSourceEntityId);return}}function Gt(o,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(o),D(e))||!ve(z(o),z(e)))throw new Error("Prefab source edit add-nested-instance-entity must not change source entity or component ids");const n=Ae(o,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 H(o){Kt(o.intent),be(o.prefabFile),Jt(o.prefabFile,o.intent);const e=o.mutation(o.prefabFile);return be(e),Gt(o.prefabFile,e,o.intent),e}function Wt(o,e){return H({prefabFile:o,intent:{kind:"add-source-entity",sourceEntityIds:e.entityIds},mutation:t=>jt(t,e)})}function Qt(o,e){return H({prefabFile:o,intent:{kind:"add-nested-instance-entity",instanceSourceEntityId:e.instanceSourceEntityId,parentSourceEntityId:e.parentSourceEntityId},mutation:t=>Bt(t,e)})}function Ht(o,e){return H({prefabFile:o,intent:{kind:"remove-source-entity",sourceEntityId:e},mutation:t=>zt(t,e)})}function Xt(o,e){return H({prefabFile:o,intent:{kind:"add-source-component",sourceComponentId:e.sourceComponentId},mutation:t=>Nt(t,e.sourceEntityId,e.sourceComponentId,e.component)})}function Yt(o,e){return H({prefabFile:o,intent:{kind:"remove-source-component",sourceComponentId:e},mutation:t=>Vt(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=ge(({asset:o})=>{const{dependentAssets:e}=o,{configDataStore:t}=Re(),{t:n}=Ge(),s=ge(({dependentAssetInfo:r})=>{const{assetStore:i}=Re(),c=Object.values(i.assets).filter(u=>{const l=u.getMetaConfig().type,y=u.id===r.id,h=u.id===o.id,f=!y&&!h&&!u.isSubAsset;return r.type==="glTF"||r.type==="Prefab"?l==="glTF"||l==="Prefab"&&f:u.getMetaConfig().type===r.type&&f}),a=i.assets[r.id],d=a==null?void 0:a.name;return M.jsx(We,{dropLayer:he.Asset,placeholder:n("prefab.inspector.missed"),assets:c,onSelect:u=>{o.replaceDependentAsset(r,u)},onLocate:()=>{i.selectAsset(r.id)},value:d,asset:a})});return M.jsxs(M.Fragment,{children:[M.jsx(Qe,{title:n("prefab.inspector.basic-info"),defaultOpen:!0,children:t.isBuc&&M.jsx(He,{label:n("prefab.inspector.url")})}),M.jsx(Xe,{label:n("prefab.inspector.dependent-assets"),children:e.map((r,i)=>M.jsx(s,{dependentAssetInfo:r},`${r.id}-${i}`))})]})}),en={asset:{version:"2.0"},root:"defaultPrefab",entities:[{id:"defaultPrefab",name:"prefab"}],components:[]};class tn extends At{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(Ze,this._particles).forEach(c=>{c.generator.stop(!1,Ie.StopEmittingAndClear),c.generator.main.simulationSpeed=1,c.generator.play()})}stopViewAsset(){super.stopViewAsset(),this._particles.forEach(t=>{t.generator.stop(!1,Ie.StopEmittingAndClear)})}}function de(o,e,t){if(Array.isArray(o))return o.map(r=>de(r,e,t));if(!o||typeof o!="object")return o;const n=o,s={};for(const[r,i]of Object.entries(n))s[r]=r==="$ref"&&i===e?t:de(i,e,t);return s}function Te(o,e,t){return de(o,e,t)}function nn(o,e,t,n){const s=e.ref??n(e.id);if(typeof s!="string"||s.length===0)throw new Error(`[SceneV2] Unable to replace prefab asset ref "${e.id}": missing old virtualPath`);const r=n(t);if(typeof r!="string"||r.length===0)throw new Error(`[SceneV2] Unable to replace prefab asset ref "${t}": missing new virtualPath`);let i=Te(o,s,r);return s!==e.id&&(i=Te(i,e.id,r)),i}function sn(o,e){const t=e.entities.findIndex(n=>n.id===e.root);if(!e.entities[t])throw new Error(`Prefab asset "${o}" source root "${e.root}" was not found.`);return t}function k(o,e,t){const n=e.entities[t];if(!n)throw new Error(`Prefab asset "${o}" source entity at index "${t}" was not found.`);return n}function N(o,e,t){var s;const n=(s=e.entities[t])==null?void 0:s.id;if(!n)throw new Error(`Prefab asset "${o}" source entity at index "${t}" is missing a stable source id.`);return n}function rn(o,e,t){var s;const n=(s=e.components[t])==null?void 0:s.id;if(!n)throw new Error(`Prefab asset "${o}" source component at index "${t}" is missing a stable source id.`);return n}function xe(o,e,t){const n=k(o,e,t);if(W(n))return[];const s=(n.children??[]).map(r=>e.entities.findIndex(i=>i.id===r));for(const r of s)if(!e.entities[r])throw new Error(`Prefab asset "${o}" source child index "${r}" on entity "${t}" was not found.`);return s}function Me(o,e,t){const n=k(o,e,t);return W(n)?[]:(n.components??[]).map(s=>{const r=e.components.findIndex(c=>c.id===s),i=e.components[r];if(!i)throw new Error(`Prefab asset "${o}" source component "${s}" was not found.`);return{key:rn(o,e,r),type:i.type,schema:i}})}function Oe(o,e,t,n,s){var a,d;const r=N(o,e,t),i=n.find(u=>u.id===r&&!s.has(u.id));if(i)return i;const c=k(o,e,t);if(!W(c)&&!((d=(a=c.instance)==null?void 0:a.asset)!=null&&d.$ref))throw new Error(`Prefab source child "${r}" cannot be matched to a loaded source entity.`)}function on(o,e,t,n){const s=r=>!t.type||r.type===t.type;if(n){const r=o.find(i=>i.key===n&&!e.has(i.key)&&s(i));if(r)return r}if(t.id){const r=o.find(i=>i.key===t.id&&!e.has(i.key)&&s(i));if(r)return r}}function cn(o,e,t,n){const s=(e==null?void 0:e.components)??[],r=t==null?void 0:t.get(o.key);if(r){const c=s.find(a=>(a==null?void 0:a.id)===r&&!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)!==o.key?!1:!c.type||c.type===o.type});if(i)return i}function an(o){var a,d,u,l,y,h,f,p;const e=k(o.assetId,o.prefabFile,o.sourceIndex),t=N(o.assetId,o.prefabFile,o.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=((y=(l=(u=o.normalized)==null?void 0:u.entities)==null?void 0:l[o.sceneChild.id])==null?void 0:y.instance)??o.sceneChild.instance,r=s==null?void 0:s.bindingId,i=r?(p=(f=(h=o.normalized)==null?void 0:h.prefab)==null?void 0:f.bindings)==null?void 0:p[r]:void 0,c=o.resolveInstanceAsset(n,t);return c?i?i.instanceRootEntityId===o.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 dn(o){var s,r;const t=(r=(s=k(o.assetId,o.prefabFile,o.sourceIndex).instance)==null?void 0:s.asset)==null?void 0:r.$ref;if(typeof t!="string")return;const n=o.resolveInstanceAsset(t,o.sourceEntityId);if(!n)throw new Error(`Prefab source entity "${o.sourceEntityId}" references missing instance asset "${t}".`);if(n.kind!=="Prefab"&&n.kind!=="glTF")throw new Error(`Prefab source entity "${o.sourceEntityId}" references unsupported instance asset "${t}" of type "${String(n.kind)}".`);return n}function un(o,e){var r,i,c,a;if(!(o!=null&&o.id))return;const t=((i=(r=e==null?void 0:e.entities)==null?void 0:r[o.id])==null?void 0:i.instance)??o.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(o,e){return{x:Number((o==null?void 0:o.x)??e.x),y:Number((o==null?void 0:o.y)??e.y),z:Number((o==null?void 0:o.z)??e.z)}}function fn(o,e){const t=o==null?void 0:o.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 ln(o,e,t){const n=o==null?void 0:o.layer;return Array.isArray(n)?t?t(n):e:typeof n=="number"?n:e}function hn(o){var c,a,d,u,l,y,h;const e=(c=o.normalized)==null?void 0:c.components,t=(o.sceneComponentId?e==null?void 0:e[o.sceneComponentId]:void 0)??((a=o.component)!=null&&a.id?e==null?void 0:e[o.component.id]:void 0),n={},s=(t==null?void 0:t.refId)??(typeof((d=o.schema.script)==null?void 0:d.$ref)=="string"?o.resolveSourceAssetRefToDomainId(o.schema.script.$ref,`component "${((u=o.component)==null?void 0:u.id)??o.schema.type}" script`):void 0);s&&(n.refId=s);const r=(t==null?void 0:t.scriptKey)??((l=o.schema.script)==null?void 0:l.key);r&&(n.scriptKey=r);const i=(y=t==null?void 0:t.calls)!=null&&y.length?structuredClone(t.calls):(h=o.schema.calls)!=null&&h.length?o.convertSourceRefsToDomainRefs(structuredClone(o.schema.calls)):void 0;return i!=null&&i.length&&(n.calls=i),n}function pn(o){var e,t;return o.sceneEntityIdBySource.has(o.sourceEntityId)?((t=(e=o.allowMissingSceneComponentSourceKeys)==null?void 0:e.get(o.sourceEntityId))==null?void 0:t.has(o.sourceComponentKey))===!0:!0}function mn(o){const{assetId:e,prefabFile:t,sourceRoot:n,sceneRoot:s,normalized:r}=o,i=[],c=[],a=new Map,d=new Map,u=sn(e,t),l=p=>{var E,P;const m=((P=(E=r==null?void 0:r.entities)==null?void 0:E[p.id])==null?void 0:P.instance)??p.instance;return(m==null?void 0:m.role)==="added"},y=(p,m,E,P)=>{var q,ee,te,U;if(l(E))return;const _=N(e,t,p),I=k(e,t,p),T=W(I);i.push({sceneEntityId:E.id,sourceEntityId:_,role:P}),a.set(_,E.id);const V=Me(e,t,p),Y=E.components??[],R=new Set;for(const b of Y){if(!(b!=null&&b.id)||b.ignoreToJSON)continue;const S=((ee=(q=r==null?void 0:r.components)==null?void 0:q[b.id])==null?void 0:ee.instance)??b.instance;if((S==null?void 0:S.role)==="added")continue;const w=((te=o.sceneSourceComponentKeys)==null?void 0:te.get(b.id))??(S==null?void 0:S.sourceComponentKey),g=on(V,R,b,w);if(!g){if(!T)throw new Error(`Prefab asset "${e}" live scene component "${b.id}" on source entity "${_}" cannot be matched to a prefab source component.`);continue}R.add(g.key),c.push({sceneEntityId:E.id,sceneComponentId:b.id,sourceComponentKey:g.key});const $=d.get(_)??new Map;$.set(g.key,b.id),d.set(_,$)}const B=xe(e,t,p),Z=(m==null?void 0:m.children)??[],x=E.children??[],K=new Set,L=new Set;for(let b=0;b<B.length;b++){const S=B[b],w=N(e,t,S),g=Oe(e,t,S,Z,K);g!=null&&g.id&&K.add(g.id);const $=x.find(v=>{var me,ye,Se;if(L.has(v.id)||l(v))return!1;if(v.id===w||g!=null&&g.id&&v.id===g.id||an({assetId:e,prefabFile:t,sourceIndex:S,sceneChild:v,normalized:r,resolveInstanceAsset:o.resolveInstanceAsset}))return!0;const re=((ye=(me=r==null?void 0:r.entities)==null?void 0:me[v.id])==null?void 0:ye.instance)??v.instance,pe=((Se=o.sceneSourceEntityIds)==null?void 0:Se.get(v.id))??(re==null?void 0:re.sourceEntityId)??v.instanceSourceEntityId;return pe===w||(g==null?void 0:g.id)&&pe===g.id});if(!$){if((U=o.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 "${_}".`)}L.add($.id),y(S,g,$,"linked")}},h={},f=(p,m,E,P)=>{const _=k(e,t,p),I=N(e,t,p),T={},V=Me(e,t,p),Y=new Set;V.forEach(b=>{var $;const S=cn(b,m,d.get(I),Y);if(S!=null&&S.ignoreToJSON)return;S!=null&&S.id&&Y.add(S.id);const w=typeof(S==null?void 0:S.toJSON)=="function"?S.toJSON():b.schema,g=($=d.get(I))==null?void 0:$.get(b.key);if(!g&&!pn({sourceEntityId:I,sourceComponentKey:b.key,sceneEntityIdBySource:a,allowMissingSceneComponentSourceKeys:o.allowMissingSceneComponentSourceKeys}))throw new Error(`Prefab asset "${e}" source component "${b.key}" on source entity "${I}" cannot be matched to live scene component.`);T[b.key]={sceneComponentId:g,type:w.type??(S==null?void 0:S.type),...hn({component:S,schema:w,sceneComponentId:g,normalized:r,resolveSourceAssetRefToDomainId:o.resolveSourceAssetRefToDomainId,convertSourceRefsToDomainRefs:o.convertSourceRefsToDomainRefs}),props:o.collectComponentProps(S,w)}});const R=dn({assetId:e,prefabFile:t,sourceIndex:p,sourceEntityId:I,resolveInstanceAsset:o.resolveInstanceAsset}),B=R==null?void 0:R.kind,Z=et({sourceEntity:_,fallbackSourceEntityId:I,instanceAssetKind:B,bindingSourceRootEntityId:un(m,r)??(R==null?void 0:R.sourceRootEntityId)}),x=tt(_,I,{...typeof Z=="string"?{rootOverrideTarget:Z}:{}}),K=ln(m,x.layer,o.combineLayers),L=(m==null?void 0:m.isLocked)??x.isLocked,q=xe(e,t,p),ee=q.map(b=>N(e,t,b));h[I]={sceneEntityId:a.get(I),parentSourceEntityId:E,childSourceEntityIds:ee,childIndex:P,...B?{instanceAssetKind:B}:{},name:(m==null?void 0:m.name)??x.name,isActive:(m==null?void 0:m.isActive)??x.isActive,...K!==void 0?{layer:K}:{},...L!==void 0?{isLocked:L}:{},transform:fn(m,x.transform),components:T};const te=(m==null?void 0:m.children)??[],U=new Set;q.forEach((b,S)=>{const w=Oe(e,t,b,te,U);w!=null&&w.id&&U.add(w.id),f(b,w,I,S)})};return y(u,n,s,"root"),f(u,n,null,0),{entityMappings:i,componentMappings:c,sourceEntitySnapshots:h}}class yn{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(r){throw this.host.writeSourceFile(n),this.host.syncDependentAssets(),this.host.updateCreateByAddResumeSnapshot(),r}}}var Sn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,X=(o,e,t,n)=>{for(var s=n>1?void 0:n?bn(e,t):e,r=o.length-1,i;r>=0;r--)(i=o[r])&&(s=(n?i(e,t,s):i(s))||s);return n&&s&&Sn(e,t,s),s};const O=Ct("PrefabAsset"),De=new Rt("PrefabAsset"),ue=[0,0,0],fe=[0,0,0],le=[1,1,1];function Fe(o){const e=new Map;for(const[t,n]of o)e.set(n,t);return e}function ce(o,e,t){const n=o??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 gn(o,e){e&&Object.assign(o,{...e.position?{position:ce(o.position,ue,e.position)}:{},...e.rotation?{rotation:ce(o.rotation,fe,e.rotation)}:{},...e.scale?{scale:ce(o.scale,le,e.scale)}:{}})}let j=class extends vt{constructor(e){super(e);C(this,"acceptDragLayer",he.Entity);C(this,"_entityManager");C(this,"_contentQueue",new $t);C(this,"prefabFile",null);C(this,"dependentAssets",[]);C(this,"_skipInitUpdateContent",!1);this._entityManager=new ot(e)}static async createByEntity(e){var t,n,s;if(e.isPrefabSubEntity||e.isGLTFSubEntity){nt.error(J("prefab.error.create-from-sub"));return}Ee()&&st();try{De.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:r}=e.root;await e.root.runInUndoGroup("asset.create",async()=>{const i=await r.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{Ee()&&rt()}}get entityManager(){return this._entityManager}get entities(){var e;return((e=this.prefabFile)==null?void 0:e.entities)??[]}async initByMain(e,t){const{dependentAssets:n}=this.meta;if(this.url=t,this.prefabFile=it(await e.text()),this.dependentAssets=n,this._skipInitUpdateContent){this._skipInitUpdateContent=!1;return}await this._updateContent()}async initByCreation(){return this.prefabFile=en,this._skipInitUpdateContent=!0,this.getMainData()}getMainData(){return ct(this._requirePrefabSourceFile("serializing prefab main data"))}async updateByEntity(e,t=!1,n){De.info("updateByEntity START",{entityName:e.name,entityId:e.id,isGLTFWrap:e.isGLTFWrapEntity,updateInstanceFrom:t});const s=this._serializeRootEntityTreeForSource(e),r=s.entities;if(r[0]){delete r[0].position;const i=r[0].instance?this._resolveNestedInstanceRootOverrideTarget(e):void 0;at(r[0],i)}this.prefabFile={asset:{version:"2.0"},root:s.entityIds[0],entities:r,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 yn({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(r=>kt(r,e,s),n)}async applyAddedEntityOverride(e,t,n,s){const r=this._serializeEntityTreeForSource(n),i=this._resolveSourceChildInsertionIndex(e,t,n);await this._editPrefabSource(c=>Wt(c,{parentSourceEntityId:e,index:i,entities:r.entities,entityIds:r.entityIds,components:r.components,componentIds:r.componentIds}),{...s,structuralDeltaMode:"domain-source-replace"})}async applyNestedInstanceAddedEntityOverride(e,t,n,s,r){const i=this._serializeEntityInlineForSource(s);await this._editPrefabSource(c=>Qt(c,{instanceSourceEntityId:e,parentSourceEntityId:t,index:n,entity:i}),{...r,structuralDeltaMode:"domain-source-replace"})}async applyRemovedEntityOverride(e,t){await this._editPrefabSource(n=>Ht(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}async applyAddedComponentOverride(e,t,n,s){await this._editPrefabSource(r=>Xt(r,{sourceEntityId:e,sourceComponentId:t,component:this._componentSchemaToSourceRefs(n)}),{...s,structuralDeltaMode:"domain-source-replace"})}async applyRemovedComponentOverride(e,t){await this._editPrefabSource(n=>Yt(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}replaceDependentAsset(e,t){const n=this.root.assetStore;this.prefabFile=nn(this.prefabFile,e,t.id,s=>{var r;return(r=n.getAssetVirtualPath)==null?void 0:r.call(n,s)}),e.id=t.id,e.name=t.name,e.type=t.getMetaConfig().type,e.ref=this._createSourceRefCodec().domainToSource(t.id,"replace prefab asset"),this._updateContent()}_createSourceSerializeContext(e=[]){var s,r;const t=this.root.assetStore,n=(r=(s=this.root.domainStore)==null?void 0:s.getNormalizedState)==null?void 0:r.call(s);return new dt(e,i=>{var c;return(c=t.getAssetVirtualPath)==null?void 0:c.call(t,i)},i=>{var a;const c=(a=n==null?void 0:n.components)==null?void 0:a[i];if(c)return{refId:c.refId,scriptKey:c.scriptKey,calls:c.calls}})}_createSourceRefCodec(){const e=this.root.assetStore;return ut({resolveAssetRef:t=>{var n;return(n=e.getAssetVirtualPath)==null?void 0:n.call(e,t)},resolveSourceRef:t=>{var n,s;return(s=(n=e.getAssetByVirtualPath)==null?void 0:n.call(e,t))==null?void 0:s.id},resolveAssetKind:t=>{var s,r,i,c;const n=(c=(i=(r=(s=e.getAssetByVirtualPath)==null?void 0:s.call(e,t))==null?void 0:r.getMetaConfig)==null?void 0:i.call(r))==null?void 0:c.type;return n==="Prefab"||n==="glTF"?n:void 0}})}_convertDomainRefsToSourceRefs(e){return this._createSourceSerializeContext().convertRefs(e)}_convertSourceRefsToDomainRefs(e){const t=this._createSourceRefCodec();return ft(e,n=>t.sourceToDomain(n,"prefab source"))}_componentSchemaToSourceRefs(e){var s,r;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)),(r=n.calls)!=null&&r.length&&(n.calls=t.convertRefs(n.calls)),n}_componentScriptRefToSourceRef(e){var n,s,r;const t=this._createSourceRefCodec();return(r=(s=(n=this.root.assetStore).getAssetByVirtualPath)==null?void 0:s.call(n,e))!=null&&r.id?(lt(e,"prefab script"),e):t.domainToSource(e,"prefab script")}_findSourceComponentModel(e){var n,s;const t=[...((n=this._entityManager)==null?void 0:n.rootEntities)??[]];for(;t.length>0;){const r=t.pop(),i=(s=r==null?void 0:r.components)==null?void 0:s.find(c=>(c==null?void 0:c.id)===e);if(i)return i;t.push(...(r==null?void 0:r.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()),r=ht(n,s),i=pt(n,t,s);return mt(r,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}),r=s.map(c=>c.id),i=this._createSourceSerializeContext(r);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:r,...i}=n,c=structuredClone(i),a=new Map(e.components.map(u=>[u.id,u]));r!=null&&r.length&&(c.components=r.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,...r}=t;return r}_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:r,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??{},r=[...s.entityProps??[]],i=this._resolveNestedInstanceRootOverrideTarget(t),c=r.findIndex(a=>a.target===i);if(c>=0){const a=r[c];r[c]={...n,...a,target:i}}else r.unshift({target:i,...n});e.instance.overrides={...s,entityProps:r}}_resolveNestedInstanceRootOverrideTarget(e){var s,r;const t=this._findInstanceRootBinding(e.id);if(t!=null&&t.sourceRootEntityId)return t.sourceRootEntityId;if(((t==null?void 0:t.assetKind)??((r=(s=this._resolveNestedInstanceAsset(e))==null?void 0:s.getMetaConfig)==null?void 0:r.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 r;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=(r=t.getMetaConfig)==null?void 0:r.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(r=>r.instanceRootEntityId===e)}_resolveNestedInstanceAsset(e){var s,r;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=(r=e.engineObject)==null?void 0:r._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])],r=(d,u)=>d[0]===u[0]&&d[1]===u[1]&&d[2]===u[2],i=s(n.position,ue);r(i,ue)||(e.position=i);const c=s(n.rotation,fe);r(c,fe)||(e.rotation=c);const a=s(n.scale,le);r(a,le)||(e.scale=a)}destroy(){super.destroy(),this.engineObject&&(this.engineObject._root.destroy(),this.engineObject.destroy())}unpackAllInstances(){this._instances.forEach((e,t)=>{const n=e.entities.get(t);n==null||n.unpackPrefab()}),super.unpackAllInstances()}async instantiate(e,t,n){var h;const s=structuredClone(this.prefabFile),r=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=r.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&&gn(c,t);const a=this._assignSceneInstanceIds(s,i,n==null?void 0:n.expectedRootId),d=f=>{var p,m;return(m=(p=this.root.assetStore).getAssetByVirtualPath)==null?void 0:m.call(p,f)},u=await e.hydrateSourceV2LocalEntities(s,{resolveSourceRef:f=>{var m;const p=(m=d(f))==null?void 0:m.id;if(typeof p!="string"||p.length===0)throw new Error(`[SceneV2] Unable to resolve asset ref "${f}" while instantiating prefab "${this.id}". Source-v2 $ref must be a virtualPath, not an editor asset id.`);return p},resolveAssetKind:f=>{var m,E,P;const p=(P=(E=(m=d(f))==null?void 0:m.getMetaConfig)==null?void 0:E.call(m))==null?void 0:P.type;return p==="Prefab"||p==="glTF"?p:void 0},resolvePrefabSourceFile:f=>{var m,E,P,_;const p=(E=(m=this.root.assetStore).getAsset)==null?void 0:E.call(m,f);return((_=(P=p==null?void 0:p.getMetaConfig)==null?void 0:P.call(p))==null?void 0:_.type)==="Prefab"?p.prefabFile:void 0},clearExisting:!1,registerDomain:(n==null?void 0:n.deferDomainBinding)!==!0,deferredInstanceBindings:(n==null?void 0:n.deferredInstanceBindings)??[]}),l=(h=s.entities[i])==null?void 0:h.id,y=(l?e.entities.get(l):void 0)??u[0];if(await this._ensureSourceEntityManagerReady(),y.convertToPrefabRefEntity(),(n==null?void 0:n.deferDomainBinding)!==!0&&e.isDomainScoped&&!this.root.domainStore.state.entities[y.id]&&e.registerEntityTreeInDomain(y,null),this.addInstance(y,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(y,{...n,...a})),y}return this._bindInstantiatedEntity(y,{...n,...a}),y}_assignSceneInstanceIds(e,t,n){const s=new Map;e.entities.forEach((i,c)=>{s.set(i.id,n&&c===t?n:Pe())});const r=new Map;return e.components.forEach(i=>{r.set(i.id,Pe())}),this._remapLocalHydrationIds(e,s,r),{sourceEntityIdBySceneId:Fe(s),sourceComponentKeyBySceneComponentId:Fe(r)}}_remapLocalHydrationIds(e,t,n){const s=r=>{if(Array.isArray(r))return r.map(a=>s(a));if(!r||typeof r!="object")return r;const i=r;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(r=>{var a,d;const i=r.id,c=structuredClone(r);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(r=>{var c;const i=structuredClone(r);return i.id=n.get(r.id)??r.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,r=s.byAssetId[this.id]??[],i=r.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 r){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 y=1;for(const h of r){const f=s.bindings[h];f&&f.sourceRevision>y&&(y=f.sourceRevision)}this.root.prefabFacade.bindExistingInstance({assetId:this.id,instanceRootEntityId:e.id,sourceRevision:y,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[r,i]of Object.entries(t)){const c=i.sceneEntityId??e.sourceToSceneEntity[r];if(!c)continue;const a=n.entities[c];if(!a)continue;const d=`/entities/${ne(c)}`,u=e.overrides.entityProps[r];(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];_e(a.transform[h],f)||s.push({op:"replace",path:`${d}/transform/${h}`,value:f})}const y=e.overrides.componentProps[r]??{};for(const[h,f]of Object.entries(i.components)){const p=f.sceneComponentId;if(!p)continue;const m=n.components[p];if(!m)continue;const E=`${d}/components/${ne(p)}`,P=y[h]??{},_=f.props??{};for(const[I,T]of Object.entries(_)){if(Object.prototype.hasOwnProperty.call(P,I))continue;const V=`${E}/props/${ne(I)}`;_e(m.props[I],T)||s.push({op:Object.prototype.hasOwnProperty.call(m.props,I)?"replace":"add",path:V,value:T})}for(const I of Object.keys(m.props))Object.prototype.hasOwnProperty.call(_,I)||Object.prototype.hasOwnProperty.call(P,I)||s.push({op:"remove",path:`${E}/props/${ne(I)}`})}}this.root.domainStore.applySystem(s)}_collectInstanceMappings(e,t,n){var s,r,i;return mn({assetId:this.id,prefabFile:this._requirePrefabSourceFile(),sourceRoot:e,sceneRoot:t,normalized:(i=(r=(s=this.root)==null?void 0:s.domainStore)==null?void 0:r.getNormalizedState)==null?void 0:i.call(r),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,resolveInstanceAsset:(c,a)=>{var y,h,f,p;const d=(h=(y=this.root.assetStore).getAssetByVirtualPath)==null?void 0:h.call(y,c);if(!d)throw new Error(`Prefab source entity "${a}" references missing instance asset "${c}".`);const u=(p=(f=d.getMetaConfig)==null?void 0:f.call(d))==null?void 0:p.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}:{}}},resolveSourceAssetRefToDomainId:(c,a)=>this._createSourceRefCodec().sourceToDomain(c,a),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,y,h;const s=this._requirePrefabSourceFile(),r=s.entities.findIndex(f=>f.id===e);if(r<0)return t;const i=new Set(((l=s.entities[r])==null?void 0:l.children)??[]);if(i.size===0)return 0;const c=((y=n.parentEntity)==null?void 0:y.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 p=(h=c[f])==null?void 0:h.instanceSourceEntityId;p&&i.has(p)&&(u+=1)}return Math.min(Math.max(u,0),i.size)}_collectSnapshotComponentProps(e,t){return e&&Reflect.ownKeys(St(e)).length>0?this._convertSourceRefsToDomainRefs(bt(e)):this._convertSourceRefsToDomainRefs(structuredClone(t.props??{}))}async replaceInstance(e,t,n){var d,u,l;const s=t.entities.get(e);if(!s)return this._instances.delete(e),null;const r=(d=s==null?void 0:s.engineObject)==null?void 0:d.transform,i=r?{position:{x:r.position.x,y:r.position.y,z:r.position.z},rotation:{x:r.rotation.x,y:r.rotation.y,z:r.rotation.z},scale:{x:r.scale.x,y:r.scale.y,z:r.scale.z}}:void 0,c=(l=(u=s.root.domainStore.getNormalizedState().entities[e])==null?void 0:u.instance)==null?void 0:l.bindingId,a=await this.instantiate(t,n!=null&&n.resetRootTransform?void 0:i,{...n!=null&&n.undoable?{undoable:!0}:{},expectedBindingId:c});return a.convertToPrefabRefEntity(),n!=null&&n.structuralDeltaMode?t.replaceEntity(e,a,{structuralDeltaMode:n.structuralDeltaMode}):t.replaceEntity(e,a),a}_refreshTrackedInstanceBindings(e){for(const[t,n]of Array.from(this._instances)){const s=n.entities.get(t);if(!s){this._instances.delete(t);continue}this._bindInstantiatedEntity(s,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,r=Array.from(s.selectedKeys);if(r.length>1)for(let i=0;i<r.length;i++)j.createByEntity(n.getEntityModel(r[i]));else gt({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(r[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 r of n){const i=t.state.prefab.bindings[r];i&&i.sourceRevision>s&&(s=i.sourceRevision)}e.updatePrefabContent(this.id,s+1)}_collectEntitySubtree(e,t={}){const n=[],s=(r,i=!1)=>{if(n.push(r),!(this._isNestedInstanceRootForSource(r)&&!(i&&t.materializeRootPrefabInstance)))for(const a of r.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 Tt(this.prefabFile,["$ref"])){if(typeof s!="string"||s===this.id)continue;const r=(n=t.getAssetByVirtualPath)==null?void 0:n.call(t,s);if(!r)throw new Error(`[SceneV2] Unable to resolve prefab asset ref "${s}" while collecting dependencies`);r.id!==this.id&&e.add(r)}return e}_syncDependentAssetsFromPrefabFile(){const e=this.root.assetStore;this.dependentAssets=Array.from(this._collectDependentAssetsFromPrefabFile(),t=>({id:t.id,name:t.name,type:t.getMetaConfig().type,ref:(()=>{var s;const n=(s=e.getAssetVirtualPath)==null?void 0:s.call(e,t.id);if(typeof n!="string"||n.length===0)throw new Error(`[SceneV2] Unable to serialize prefab dependency ref "${t.id}": missing virtualPath`);return n})()}))}_updateContent(e){return this._contentQueue.enqueue(async()=>{try{await this._updateContentInternal(e)}catch(t){if(t instanceof Error&&t.message==="cancelled")return;throw O.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 r=this.engineObject;if(r){this.root.assetStore.engineObjectToAssetMap.delete(r);try{r.destroy()}catch(a){O.warn("failed to destroy oldEngineObject:",a)}}const i=new It(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")),O.error(`The prefab which id is ${this.id} is broken, use default prefab instead.`)),c.engineObject||(O.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",()=>{O.error(`The prefab which id is ${this.id} is broken.`),this._updateContent().catch(a=>{O.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;await Promise.all(Array.from(this._instances,([u,l])=>{var h,f;const y=(f=(h=l.root.domainStore.getNormalizedState().entities[u])==null?void 0:h.instance)==null?void 0:f.bindingId;return this.replaceInstance(u,l,{...d??{},resetRootTransform:y!==void 0&&a.has(y),...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){O.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)})}};X([Et()],j.prototype,"prefabFile",2);X([wt(),Pt],j.prototype,"dependentAssets",2);X([ke],j.prototype,"replaceDependentAsset",1);X([ke],j.prototype,"_onDrop",1);j=X([_t({type:"Prefab",label:J("asset.prefab.title"),extname:"prefab",dragLayer:he.Prefab,customInspector:Zt,viewer:tn,thumbnail:ae,async bundle(o){return{content:new Blob([o.content],{type:"application/json"})}}})],j);export{j as PrefabAsset};
1
+ var Le=Object.defineProperty;var qe=(o,e,t)=>e in o?Le(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var C=(o,e,t)=>(qe(o,typeof e!="symbol"?e+"":e,t),t);import{d_ as Ue,d$ as be,e0 as Je,aJ as Ie,aK as Ge,av as M,bA as We,q as he,aN as Qe,aw as He,e1 as Xe,C as Ye,bE as Ze,e2 as ge,e3 as W,e4 as et,e5 as tt,bX as nt,e as J,e6 as Ee,e7 as st,e8 as rt,e9 as ot,ea as it,eb as ct,ec as at,ed as dt,ee as ut,ef as ft,eg as lt,eh as ht,ei as pt,ej as mt,ek as we,el as yt,bV as Pe,em as ne,en as _e,eo as St,ep as bt,eq as It,er as gt,K as Ce,m as Et,aT as wt,x as Pt,aC as ke,n as _t,dL as Ct,es as Rt}from"./index-c3dec278.js";import{T as $t}from"./TaskQueue-05c94a4d.js";import{u as Re,I as vt}from"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";import{A as At}from"./AssetViewer-3847c058.js";function Tt(o,e,t){const n=[];function s(r){if(!(r==null||typeof r!="object")){if(Array.isArray(r)){for(const i of r)s(i);return}for(const i of Object.keys(r)){const c=r[i];if(e.includes(i)&&typeof c=="string"&&n.push(c),t){const a=t(i,c);a!==null&&n.push(a)}s(c)}}}return s(o),n}function A(o){return structuredClone(o)}function Q(o,e){const t=o.entities.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source entity "${e}" not found`);return t}function je(o,e){const t=o.components.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source component "${e}" not found`);return t}function oe(o,e,t){if(!t)return;const n=e==="scale"?[1,1,1]:[0,0,0],s=o[e]??n;o[e]=[t.x??s[0],t.y??s[1],t.z??s[2]]}function $e(o,e,t){const n=new Set(e),s=new Set;for(const r of t){if(s.has(r))throw new Error(`Prefab source ${o} id "${r}" is duplicated in the added source tree`);if(n.has(r))throw new Error(`Prefab source ${o} id "${r}" already exists`);s.add(r)}}function xt(o){return o.entities.map(e=>e.id)}function Be(o){return o.components.map(e=>e.id)}function Mt(o){const e=new Set(o.entityIds),t=new Set(o.componentIds);return o.entities.map((n,s)=>{var c,a;const r=o.entityIds[s],i=structuredClone(n);return i.id=r,(c=i.children)!=null&&c.length&&(i.children=i.children.map(d=>{const u=typeof d=="number"?o.entityIds[d]:d;if(!e.has(u))throw new Error(`Prefab added source entity "${r}" 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"?o.componentIds[d]:d;if(!t.has(u))throw new Error(`Prefab added source entity "${r}" component "${String(d)}" is outside added component list`);return u})),i})}function Ot(o){return o.components.map((e,t)=>({...structuredClone(e),id:o.componentIds[t]}))}function Dt(o,e){const t=new Map(o.entities.map(r=>[r.id,r])),n=new Set,s=r=>{if(n.has(r))return;n.add(r);const i=t.get(r);for(const c of(i==null?void 0:i.children)??[])s(c)};return s(e),n}function Ft(o,e,t){var r,i,c;if(!t)return A(o);const n=A(o),s=n.entities[Q(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",(r=t.transform)==null?void 0:r.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(o,e,t){if(!t||Object.keys(t).length===0)return A(o);const n=A(o),s=n.components[je(n,e)];return s.props=Ue(s.props??{},t),n}function jt(o,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(o),e.entityIds),$e("component",Be(o),e.componentIds);const t=A(o),n=t.entities[Q(t,e.parentSourceEntityId)],s=Mt(e),r=Ot(e),i=e.entityIds[0];t.entities.push(...s),t.components.push(...r);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 Bt(o,e){var p;const t=A(o),n=t.entities[Q(t,e.instanceSourceEntityId)];if(!n.instance)throw new Error(`Prefab source entity "${e.instanceSourceEntityId}" is not an instance entity`);const s=(p=n.instance).overrides??(p.overrides={}),r=[...s.addedEntities??[]],i=Math.max(0,e.index);let c=0,a=r.length;for(let y=0;y<r.length;y+=1)if(r[y].parent===e.parentSourceEntityId){if(c===i){a=y;break}c+=1,a=y+1}const d=structuredClone(e.entity),u=d.id??`${e.instanceSourceEntityId}:added:${r.length}`;return d.id=u,r.splice(a,0,{id:u,parent:e.parentSourceEntityId,entity:d}),s.addedEntities=r,t}function zt(o,e){if(o.root===e)throw new Error("Cannot remove prefab root entity from source");Q(o,e);const t=Dt(o,e),n=new Set;for(const r of o.entities)if(t.has(r.id))for(const i of r.components??[])n.add(i);const s=A(o);return s.entities=s.entities.filter(r=>!t.has(r.id)).map(r=>{const i=structuredClone(r),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(r=>!n.has(r.id)),s}function Nt(o,e,t,n){if(Be(o).includes(t))throw new Error(`Prefab source component id "${t}" already exists`);const s=A(o),r=s.entities[Q(s,e)];return s.components.push({...structuredClone(n),id:t}),r.components=[...r.components??[],t],s}function Vt(o,e){je(o,e);const t=A(o);return t.components=t.components.filter(n=>n.id!==e),t.entities=t.entities.map(n=>{const s=structuredClone(n),r=(s.components??[]).filter(i=>i!==e);return r.length?s.components=r:delete s.components,s}),t}function Kt(o){switch(o.kind){case"add-source-entity":if(o.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(!o.sourceEntityId)throw new Error("Prefab source edit remove-source-entity requires a source entity id");return;case"add-source-component":if(!o.sourceComponentId)throw new Error("Prefab source edit add-source-component requires a source component id");return;case"remove-source-component":if(!o.sourceComponentId)throw new Error("Prefab source edit remove-source-component requires a source component id");return;case"add-nested-instance-entity":if(!o.instanceSourceEntityId)throw new Error("Prefab source edit add-nested-instance-entity requires an instance source entity id");if(!o.parentSourceEntityId)throw new Error("Prefab source edit add-nested-instance-entity requires a parent source entity id");return}}function ve(o,e){return o.length===e.length&&o.every((t,n)=>t===e[n])}function G(o,e,t){const n=new Set(e);for(const s of t)if(!n.has(s))throw new Error(`Prefab source edit expected ${o} id "${s}" to exist`)}function se(o,e,t){const n=new Set(e);for(const s of t)if(n.has(s))throw new Error(`Prefab source edit expected ${o} id "${s}" to be removed`)}function D(o){return o.entities.map(e=>e.id)}function z(o){return o.components.map(e=>e.id)}function ze(o,e){const t=o.entities.findIndex(n=>n.id===e);if(t<0)throw new Error(`Prefab source edit expected entity id "${e}" to exist`);return t}function Lt(o,e){var n;const t=ze(o,e);if(!((n=o.entities[t])!=null&&n.instance))throw new Error(`Prefab source edit expected entity id "${e}" to be an instance entity`)}function Ae(o,e,t){var s,r,i;const n=ze(o,e);return(((i=(r=(s=o.entities[n])==null?void 0:s.instance)==null?void 0:r.overrides)==null?void 0:i.addedEntities)??[]).filter(c=>c.parent===t).length}function F(o,e,t,n,s){if(o!=null){if(Array.isArray(o)){o.forEach((r,i)=>F(r,e,t,`${n}[${i}]`,s));return}if(Je(o)){o.$component===e&&s.push({entityId:t,propPath:n});for(const[r,i]of Object.entries(o))F(i,e,t,`${n}.${r}`,s)}}}function Ne(o,e,t,n,s){var r;F(o.props,e,t,`${n}.props`,s),(r=o.calls)==null||r.forEach((i,c)=>F(i,e,t,`${n}.calls[${c}]`,s))}function Ve(o,e,t,n,s){var r,i,c;(r=o.components)==null||r.forEach((a,d)=>Ne(a,e,t,`${n}.components[${d}]`,s)),(i=o.children)==null||i.forEach((a,d)=>Ve(a,e,t,`${n}.children[${d}]`,s)),Ke((c=o.instance)==null?void 0:c.overrides,e,t,`${n}.instance.overrides`,s)}function Ke(o,e,t,n,s){var r,i,c;(r=o==null?void 0:o.componentProps)==null||r.forEach((a,d)=>F(a.props,e,t,`${n}.componentProps[${d}].props`,s)),(i=o==null?void 0:o.addedComponents)==null||i.forEach((a,d)=>Ne(a.component,e,t,`${n}.addedComponents[${d}].component`,s)),(c=o==null?void 0:o.addedEntities)==null||c.forEach((a,d)=>Ve(a.entity,e,t,`${n}.addedEntities[${d}].entity`,s))}function qt(o,e){var s,r;const t=[],n=new Map;for(const i of o.entities)for(const c of i.components??[])n.set(c,i.id);for(const i of o.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 o.entities)Ke((r=i.instance)==null?void 0:r.overrides,e,i.id,`entities.${i.id}.instance.overrides`,t);return t}function Ut(o,e){const t=qt(o,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(o,e){switch(e.kind){case"add-source-entity":se("entity",D(o),e.sourceEntityIds);return;case"remove-source-entity":G("entity",D(o),[e.sourceEntityId]);return;case"add-source-component":se("component",z(o),[e.sourceComponentId]);return;case"remove-source-component":G("component",z(o),[e.sourceComponentId]),Ut(o,e.sourceComponentId);return;case"add-nested-instance-entity":G("entity",D(o),[e.instanceSourceEntityId]),Lt(o,e.instanceSourceEntityId);return}}function Gt(o,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(o),D(e))||!ve(z(o),z(e)))throw new Error("Prefab source edit add-nested-instance-entity must not change source entity or component ids");const n=Ae(o,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 H(o){Kt(o.intent),be(o.prefabFile),Jt(o.prefabFile,o.intent);const e=o.mutation(o.prefabFile);return be(e),Gt(o.prefabFile,e,o.intent),e}function Wt(o,e){return H({prefabFile:o,intent:{kind:"add-source-entity",sourceEntityIds:e.entityIds},mutation:t=>jt(t,e)})}function Qt(o,e){return H({prefabFile:o,intent:{kind:"add-nested-instance-entity",instanceSourceEntityId:e.instanceSourceEntityId,parentSourceEntityId:e.parentSourceEntityId},mutation:t=>Bt(t,e)})}function Ht(o,e){return H({prefabFile:o,intent:{kind:"remove-source-entity",sourceEntityId:e},mutation:t=>zt(t,e)})}function Xt(o,e){return H({prefabFile:o,intent:{kind:"add-source-component",sourceComponentId:e.sourceComponentId},mutation:t=>Nt(t,e.sourceEntityId,e.sourceComponentId,e.component)})}function Yt(o,e){return H({prefabFile:o,intent:{kind:"remove-source-component",sourceComponentId:e},mutation:t=>Vt(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=Ie(({asset:o})=>{const{dependentAssets:e}=o,{configDataStore:t}=Re(),{t:n}=Ge(),s=Ie(({dependentAssetInfo:r})=>{const{assetStore:i}=Re(),c=Object.values(i.assets).filter(u=>{const p=u.getMetaConfig().type,y=u.id===r.id,l=u.id===o.id,f=!y&&!l&&!u.isSubAsset;return r.type==="glTF"||r.type==="Prefab"?p==="glTF"||p==="Prefab"&&f:u.getMetaConfig().type===r.type&&f}),a=i.assets[r.id],d=a==null?void 0:a.name;return M.jsx(We,{dropLayer:he.Asset,placeholder:n("prefab.inspector.missed"),assets:c,onSelect:u=>{o.replaceDependentAsset(r,u)},onLocate:()=>{i.selectAsset(r.id)},value:d,asset:a})});return M.jsxs(M.Fragment,{children:[M.jsx(Qe,{title:n("prefab.inspector.basic-info"),defaultOpen:!0,children:t.isBuc&&M.jsx(He,{label:n("prefab.inspector.url")})}),M.jsx(Xe,{label:n("prefab.inspector.dependent-assets"),children:e.map((r,i)=>M.jsx(s,{dependentAssetInfo:r},`${r.id}-${i}`))})]})}),en={asset:{version:"2.0"},root:"defaultPrefab",entities:[{id:"defaultPrefab",name:"prefab"}],components:[]};class tn extends At{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(Ze,this._particles).forEach(c=>{c.generator.stop(!1,ge.StopEmittingAndClear),c.generator.main.simulationSpeed=1,c.generator.play()})}stopViewAsset(){super.stopViewAsset(),this._particles.forEach(t=>{t.generator.stop(!1,ge.StopEmittingAndClear)})}}function de(o,e,t){if(Array.isArray(o))return o.map(r=>de(r,e,t));if(!o||typeof o!="object")return o;const n=o,s={};for(const[r,i]of Object.entries(n))s[r]=r==="$ref"&&i===e?t:de(i,e,t);return s}function Te(o,e,t){return de(o,e,t)}function nn(o,e,t,n){const s=e.ref??n(e.id);if(typeof s!="string"||s.length===0)throw new Error(`[SceneV2] Unable to replace prefab asset ref "${e.id}": missing old virtualPath`);const r=n(t);if(typeof r!="string"||r.length===0)throw new Error(`[SceneV2] Unable to replace prefab asset ref "${t}": missing new virtualPath`);let i=Te(o,s,r);return s!==e.id&&(i=Te(i,e.id,r)),i}function sn(o,e){const t=e.entities.findIndex(n=>n.id===e.root);if(!e.entities[t])throw new Error(`Prefab asset "${o}" source root "${e.root}" was not found.`);return t}function k(o,e,t){const n=e.entities[t];if(!n)throw new Error(`Prefab asset "${o}" source entity at index "${t}" was not found.`);return n}function N(o,e,t){var s;const n=(s=e.entities[t])==null?void 0:s.id;if(!n)throw new Error(`Prefab asset "${o}" source entity at index "${t}" is missing a stable source id.`);return n}function rn(o,e,t){var s;const n=(s=e.components[t])==null?void 0:s.id;if(!n)throw new Error(`Prefab asset "${o}" source component at index "${t}" is missing a stable source id.`);return n}function xe(o,e,t){const n=k(o,e,t);if(W(n))return[];const s=(n.children??[]).map(r=>e.entities.findIndex(i=>i.id===r));for(const r of s)if(!e.entities[r])throw new Error(`Prefab asset "${o}" source child index "${r}" on entity "${t}" was not found.`);return s}function Me(o,e,t){const n=k(o,e,t);return W(n)?[]:(n.components??[]).map(s=>{const r=e.components.findIndex(c=>c.id===s),i=e.components[r];if(!i)throw new Error(`Prefab asset "${o}" source component "${s}" was not found.`);return{key:rn(o,e,r),type:i.type,schema:i}})}function Oe(o,e,t,n,s){var a,d;const r=N(o,e,t),i=n.find(u=>u.id===r&&!s.has(u.id));if(i)return i;const c=k(o,e,t);if(!W(c)&&!((d=(a=c.instance)==null?void 0:a.asset)!=null&&d.$ref))throw new Error(`Prefab source child "${r}" cannot be matched to a loaded source entity.`)}function on(o,e,t,n){const s=r=>!t.type||r.type===t.type;if(n){const r=o.find(i=>i.key===n&&!e.has(i.key)&&s(i));if(r)return r}if(t.id){const r=o.find(i=>i.key===t.id&&!e.has(i.key)&&s(i));if(r)return r}}function cn(o,e,t,n){const s=(e==null?void 0:e.components)??[],r=t==null?void 0:t.get(o.key);if(r){const c=s.find(a=>(a==null?void 0:a.id)===r&&!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)!==o.key?!1:!c.type||c.type===o.type});if(i)return i}function an(o){var a,d,u,p,y,l,f,h;const e=k(o.assetId,o.prefabFile,o.sourceIndex),t=N(o.assetId,o.prefabFile,o.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=((y=(p=(u=o.normalized)==null?void 0:u.entities)==null?void 0:p[o.sceneChild.id])==null?void 0:y.instance)??o.sceneChild.instance,r=s==null?void 0:s.bindingId,i=r?(h=(f=(l=o.normalized)==null?void 0:l.prefab)==null?void 0:f.bindings)==null?void 0:h[r]:void 0,c=o.resolveInstanceAsset(n,t);return c?i?i.instanceRootEntityId===o.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 dn(o){var s,r;const t=(r=(s=k(o.assetId,o.prefabFile,o.sourceIndex).instance)==null?void 0:s.asset)==null?void 0:r.$ref;if(typeof t!="string")return;const n=o.resolveInstanceAsset(t,o.sourceEntityId);if(!n)throw new Error(`Prefab source entity "${o.sourceEntityId}" references missing instance asset "${t}".`);if(n.kind!=="Prefab"&&n.kind!=="glTF")throw new Error(`Prefab source entity "${o.sourceEntityId}" references unsupported instance asset "${t}" of type "${String(n.kind)}".`);return n}function un(o,e){var r,i,c,a;if(!(o!=null&&o.id))return;const t=((i=(r=e==null?void 0:e.entities)==null?void 0:r[o.id])==null?void 0:i.instance)??o.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(o,e){return{x:Number((o==null?void 0:o.x)??e.x),y:Number((o==null?void 0:o.y)??e.y),z:Number((o==null?void 0:o.z)??e.z)}}function fn(o,e){const t=o==null?void 0:o.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 ln(o,e,t){const n=o==null?void 0:o.layer;return Array.isArray(n)?t?t(n):e:typeof n=="number"?n:e}function hn(o){var c,a,d,u,p,y,l;const e=(c=o.normalized)==null?void 0:c.components,t=(o.sceneComponentId?e==null?void 0:e[o.sceneComponentId]:void 0)??((a=o.component)!=null&&a.id?e==null?void 0:e[o.component.id]:void 0),n={},s=(t==null?void 0:t.refId)??(typeof((d=o.schema.script)==null?void 0:d.$ref)=="string"?o.resolveSourceAssetRefToDomainId(o.schema.script.$ref,`component "${((u=o.component)==null?void 0:u.id)??o.schema.type}" script`):void 0);s&&(n.refId=s);const r=(t==null?void 0:t.scriptKey)??((p=o.schema.script)==null?void 0:p.key);r&&(n.scriptKey=r);const i=(y=t==null?void 0:t.calls)!=null&&y.length?structuredClone(t.calls):(l=o.schema.calls)!=null&&l.length?o.convertSourceRefsToDomainRefs(structuredClone(o.schema.calls)):void 0;return i!=null&&i.length&&(n.calls=i),n}function pn(o){var e,t;return o.sceneEntityIdBySource.has(o.sourceEntityId)?((t=(e=o.allowMissingSceneComponentSourceKeys)==null?void 0:e.get(o.sourceEntityId))==null?void 0:t.has(o.sourceComponentKey))===!0:!0}function mn(o){const{assetId:e,prefabFile:t,sourceRoot:n,sceneRoot:s,normalized:r}=o,i=[],c=[],a=new Map,d=new Map,u=sn(e,t),p=h=>{var E,P;const m=((P=(E=r==null?void 0:r.entities)==null?void 0:E[h.id])==null?void 0:P.instance)??h.instance;return(m==null?void 0:m.role)==="added"},y=(h,m,E,P)=>{var q,ee,te,U;if(p(E))return;const _=N(e,t,h),g=k(e,t,h),T=W(g);i.push({sceneEntityId:E.id,sourceEntityId:_,role:P}),a.set(_,E.id);const V=Me(e,t,h),Y=E.components??[],R=new Set;for(const b of Y){if(!(b!=null&&b.id)||b.ignoreToJSON)continue;const S=((ee=(q=r==null?void 0:r.components)==null?void 0:q[b.id])==null?void 0:ee.instance)??b.instance;if((S==null?void 0:S.role)==="added")continue;const w=((te=o.sceneSourceComponentKeys)==null?void 0:te.get(b.id))??(S==null?void 0:S.sourceComponentKey),I=on(V,R,b,w);if(!I){if(!T)throw new Error(`Prefab asset "${e}" live scene component "${b.id}" on source entity "${_}" cannot be matched to a prefab source component.`);continue}R.add(I.key),c.push({sceneEntityId:E.id,sceneComponentId:b.id,sourceComponentKey:I.key});const $=d.get(_)??new Map;$.set(I.key,b.id),d.set(_,$)}const B=xe(e,t,h),Z=(m==null?void 0:m.children)??[],x=E.children??[],K=new Set,L=new Set;for(let b=0;b<B.length;b++){const S=B[b],w=N(e,t,S),I=Oe(e,t,S,Z,K);I!=null&&I.id&&K.add(I.id);const $=x.find(v=>{var me,ye,Se;if(L.has(v.id)||p(v))return!1;if(v.id===w||I!=null&&I.id&&v.id===I.id||an({assetId:e,prefabFile:t,sourceIndex:S,sceneChild:v,normalized:r,resolveInstanceAsset:o.resolveInstanceAsset}))return!0;const re=((ye=(me=r==null?void 0:r.entities)==null?void 0:me[v.id])==null?void 0:ye.instance)??v.instance,pe=((Se=o.sceneSourceEntityIds)==null?void 0:Se.get(v.id))??(re==null?void 0:re.sourceEntityId)??v.instanceSourceEntityId;return pe===w||(I==null?void 0:I.id)&&pe===I.id});if(!$){if((U=o.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 "${_}".`)}L.add($.id),y(S,I,$,"linked")}},l={},f=(h,m,E,P)=>{const _=k(e,t,h),g=N(e,t,h),T={},V=Me(e,t,h),Y=new Set;V.forEach(b=>{var $;const S=cn(b,m,d.get(g),Y);if(S!=null&&S.ignoreToJSON)return;S!=null&&S.id&&Y.add(S.id);const w=typeof(S==null?void 0:S.toJSON)=="function"?S.toJSON():b.schema,I=($=d.get(g))==null?void 0:$.get(b.key);if(!I&&!pn({sourceEntityId:g,sourceComponentKey:b.key,sceneEntityIdBySource:a,allowMissingSceneComponentSourceKeys:o.allowMissingSceneComponentSourceKeys}))throw new Error(`Prefab asset "${e}" source component "${b.key}" on source entity "${g}" cannot be matched to live scene component.`);T[b.key]={sceneComponentId:I,type:w.type??(S==null?void 0:S.type),...hn({component:S,schema:w,sceneComponentId:I,normalized:r,resolveSourceAssetRefToDomainId:o.resolveSourceAssetRefToDomainId,convertSourceRefsToDomainRefs:o.convertSourceRefsToDomainRefs}),props:o.collectComponentProps(S,w)}});const R=dn({assetId:e,prefabFile:t,sourceIndex:h,sourceEntityId:g,resolveInstanceAsset:o.resolveInstanceAsset}),B=R==null?void 0:R.kind,Z=et({sourceEntity:_,fallbackSourceEntityId:g,instanceAssetKind:B,bindingSourceRootEntityId:un(m,r)??(R==null?void 0:R.sourceRootEntityId)}),x=tt(_,g,{...typeof Z=="string"?{rootOverrideTarget:Z}:{}}),K=ln(m,x.layer,o.combineLayers),L=(m==null?void 0:m.isLocked)??x.isLocked,q=xe(e,t,h),ee=q.map(b=>N(e,t,b));l[g]={sceneEntityId:a.get(g),parentSourceEntityId:E,childSourceEntityIds:ee,childIndex:P,...B?{instanceAssetKind:B}:{},name:(m==null?void 0:m.name)??x.name,isActive:(m==null?void 0:m.isActive)??x.isActive,...K!==void 0?{layer:K}:{},...L!==void 0?{isLocked:L}:{},transform:fn(m,x.transform),components:T};const te=(m==null?void 0:m.children)??[],U=new Set;q.forEach((b,S)=>{const w=Oe(e,t,b,te,U);w!=null&&w.id&&U.add(w.id),f(b,w,g,S)})};return y(u,n,s,"root"),f(u,n,null,0),{entityMappings:i,componentMappings:c,sourceEntitySnapshots:l}}class yn{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(r){throw this.host.writeSourceFile(n),this.host.syncDependentAssets(),this.host.updateCreateByAddResumeSnapshot(),r}}}var Sn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,X=(o,e,t,n)=>{for(var s=n>1?void 0:n?bn(e,t):e,r=o.length-1,i;r>=0;r--)(i=o[r])&&(s=(n?i(e,t,s):i(s))||s);return n&&s&&Sn(e,t,s),s};const O=Ct("PrefabAsset"),De=new Rt("PrefabAsset"),ue=[0,0,0],fe=[0,0,0],le=[1,1,1];function Fe(o){const e=new Map;for(const[t,n]of o)e.set(n,t);return e}function ce(o,e,t){const n=o??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 In(o,e){e&&Object.assign(o,{...e.position?{position:ce(o.position,ue,e.position)}:{},...e.rotation?{rotation:ce(o.rotation,fe,e.rotation)}:{},...e.scale?{scale:ce(o.scale,le,e.scale)}:{}})}let j=class extends vt{constructor(e){super(e);C(this,"acceptDragLayer",he.Entity);C(this,"_entityManager");C(this,"_contentQueue",new $t);C(this,"prefabFile",null);C(this,"dependentAssets",[]);C(this,"_skipInitUpdateContent",!1);this._entityManager=new ot(e)}static async createByEntity(e){var t,n,s;if(e.isPrefabSubEntity||e.isGLTFSubEntity){nt.error(J("prefab.error.create-from-sub"));return}Ee()&&st();try{De.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:r}=e.root;await e.root.runInUndoGroup("asset.create",async()=>{const i=await r.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{Ee()&&rt()}}get entityManager(){return this._entityManager}get entities(){var e;return((e=this.prefabFile)==null?void 0:e.entities)??[]}async initByMain(e,t){const{dependentAssets:n}=this.meta;if(this.url=t,this.prefabFile=it(await e.text()),this.dependentAssets=n,this._skipInitUpdateContent){this._skipInitUpdateContent=!1;return}await this._updateContent()}async initByCreation(){return this.prefabFile=en,this._skipInitUpdateContent=!0,this.getMainData()}getMainData(){return ct(this._requirePrefabSourceFile("serializing prefab main data"))}async updateByEntity(e,t=!1,n){De.info("updateByEntity START",{entityName:e.name,entityId:e.id,isGLTFWrap:e.isGLTFWrapEntity,updateInstanceFrom:t});const s=this._serializeRootEntityTreeForSource(e),r=s.entities;if(r[0]){delete r[0].position;const i=r[0].instance?this._resolveNestedInstanceRootOverrideTarget(e):void 0;at(r[0],i)}this.prefabFile={asset:{version:"2.0"},root:s.entityIds[0],entities:r,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 yn({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(r=>kt(r,e,s),n)}async applyAddedEntityOverride(e,t,n,s){const r=this._serializeEntityTreeForSource(n),i=this._resolveSourceChildInsertionIndex(e,t,n);await this._editPrefabSource(c=>Wt(c,{parentSourceEntityId:e,index:i,entities:r.entities,entityIds:r.entityIds,components:r.components,componentIds:r.componentIds}),{...s,structuralDeltaMode:"domain-source-replace"})}async applyNestedInstanceAddedEntityOverride(e,t,n,s,r){const i=this._serializeEntityInlineForSource(s);await this._editPrefabSource(c=>Qt(c,{instanceSourceEntityId:e,parentSourceEntityId:t,index:n,entity:i}),{...r,structuralDeltaMode:"domain-source-replace"})}async applyRemovedEntityOverride(e,t){await this._editPrefabSource(n=>Ht(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}async applyAddedComponentOverride(e,t,n,s){await this._editPrefabSource(r=>Xt(r,{sourceEntityId:e,sourceComponentId:t,component:this._componentSchemaToSourceRefs(n)}),{...s,structuralDeltaMode:"domain-source-replace"})}async applyRemovedComponentOverride(e,t){await this._editPrefabSource(n=>Yt(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}replaceDependentAsset(e,t){const n=this.root.assetStore;this.prefabFile=nn(this.prefabFile,e,t.id,s=>{var r;return(r=n.getAssetVirtualPath)==null?void 0:r.call(n,s)}),e.id=t.id,e.name=t.name,e.type=t.getMetaConfig().type,e.ref=this._createSourceRefCodec().domainToSource(t.id,"replace prefab asset"),this._updateContent()}_createSourceSerializeContext(e=[]){var s,r;const t=this.root.assetStore,n=(r=(s=this.root.domainStore)==null?void 0:s.getNormalizedState)==null?void 0:r.call(s);return new dt(e,i=>{var c;return(c=t.getAssetVirtualPath)==null?void 0:c.call(t,i)},i=>{var a;const c=(a=n==null?void 0:n.components)==null?void 0:a[i];if(c)return{refId:c.refId,scriptKey:c.scriptKey,calls:c.calls}})}_createSourceRefCodec(){const e=this.root.assetStore;return ut({resolveAssetRef:t=>{var n;return(n=e.getAssetVirtualPath)==null?void 0:n.call(e,t)},resolveSourceRef:t=>{var n,s;return(s=(n=e.getAssetByVirtualPath)==null?void 0:n.call(e,t))==null?void 0:s.id},resolveAssetKind:t=>{var s,r,i,c;const n=(c=(i=(r=(s=e.getAssetByVirtualPath)==null?void 0:s.call(e,t))==null?void 0:r.getMetaConfig)==null?void 0:i.call(r))==null?void 0:c.type;return n==="Prefab"||n==="glTF"?n:void 0}})}_convertDomainRefsToSourceRefs(e){return this._createSourceSerializeContext().convertRefs(e)}_convertSourceRefsToDomainRefs(e){const t=this._createSourceRefCodec();return ft(e,n=>t.sourceToDomain(n,"prefab source"))}_componentSchemaToSourceRefs(e){var s,r;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)),(r=n.calls)!=null&&r.length&&(n.calls=t.convertRefs(n.calls)),n}_componentScriptRefToSourceRef(e){var n,s,r;const t=this._createSourceRefCodec();return(r=(s=(n=this.root.assetStore).getAssetByVirtualPath)==null?void 0:s.call(n,e))!=null&&r.id?(lt(e,"prefab script"),e):t.domainToSource(e,"prefab script")}_findSourceComponentModel(e){var n,s;const t=[...((n=this._entityManager)==null?void 0:n.rootEntities)??[]];for(;t.length>0;){const r=t.pop(),i=(s=r==null?void 0:r.components)==null?void 0:s.find(c=>(c==null?void 0:c.id)===e);if(i)return i;t.push(...(r==null?void 0:r.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()),r=ht(n,s),i=pt(n,t,s);return mt(r,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}),r=s.map(c=>c.id),i=this._createSourceSerializeContext(r);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:r,...i}=n,c=structuredClone(i),a=new Map(e.components.map(u=>[u.id,u]));r!=null&&r.length&&(c.components=r.map(u=>{const p=a.get(u);if(!p)throw new Error(`Prefab source added entity tree is missing component "${String(u)}"`);return structuredClone(p)}));const d=new Map(e.entities.map((u,p)=>[u.id,p]));return s!=null&&s.length&&(c.children=s.map(u=>{const p=d.get(u);if(p===void 0)throw new Error(`Prefab source added entity tree is missing child "${String(u)}"`);return this._sourceEntityTreeToInlineEntity(e,p)})),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,...r}=t;return r}_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:r,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??{},r=[...s.entityProps??[]],i=this._resolveNestedInstanceRootOverrideTarget(t),c=r.findIndex(a=>a.target===i);if(c>=0){const a=r[c];r[c]={...n,...a,target:i}}else r.unshift({target:i,...n});e.instance.overrides={...s,entityProps:r}}_resolveNestedInstanceRootOverrideTarget(e){var s,r;const t=this._findInstanceRootBinding(e.id);if(t!=null&&t.sourceRootEntityId)return t.sourceRootEntityId;if(((t==null?void 0:t.assetKind)??((r=(s=this._resolveNestedInstanceAsset(e))==null?void 0:s.getMetaConfig)==null?void 0:r.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 r;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=(r=t.getMetaConfig)==null?void 0:r.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(r=>r.instanceRootEntityId===e)}_resolveNestedInstanceAsset(e){var s,r;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=(r=e.engineObject)==null?void 0:r._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])],r=(d,u)=>d[0]===u[0]&&d[1]===u[1]&&d[2]===u[2],i=s(n.position,ue);r(i,ue)||(e.position=i);const c=s(n.rotation,fe);r(c,fe)||(e.rotation=c);const a=s(n.scale,le);r(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 r=(n=e.getEntityModel)==null?void 0:n.call(e,s);r==null||r.unpackPrefab()}super.unpackAllInstances()}async instantiate(e,t,n){var l;const s=structuredClone(this.prefabFile),r=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=r.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&&In(c,t);const a=this._assignSceneInstanceIds(s,i,n==null?void 0:n.expectedRootId),d=f=>{var h,m;return(m=(h=this.root.assetStore).getAssetByVirtualPath)==null?void 0:m.call(h,f)},u=await e.hydrateSourceV2LocalEntities(s,{resolveSourceRef:f=>{var m;const h=(m=d(f))==null?void 0:m.id;if(typeof h!="string"||h.length===0)throw new Error(`[SceneV2] Unable to resolve asset ref "${f}" while instantiating prefab "${this.id}". Source-v2 $ref must be a virtualPath, not an editor asset id.`);return h},resolveAssetKind:f=>{var m,E,P;const h=(P=(E=(m=d(f))==null?void 0:m.getMetaConfig)==null?void 0:E.call(m))==null?void 0:P.type;return h==="Prefab"||h==="glTF"?h:void 0},resolvePrefabSourceFile:f=>{var m,E,P,_;const h=(E=(m=this.root.assetStore).getAsset)==null?void 0:E.call(m,f);return((_=(P=h==null?void 0:h.getMetaConfig)==null?void 0:P.call(h))==null?void 0:_.type)==="Prefab"?h.prefabFile:void 0},clearExisting:!1,registerDomain:(n==null?void 0:n.deferDomainBinding)!==!0,deferredInstanceBindings:(n==null?void 0:n.deferredInstanceBindings)??[]}),p=(l=s.entities[i])==null?void 0:l.id,y=(p?e.entities.get(p):void 0)??u[0];if(await this._ensureSourceEntityManagerReady(),y.convertToPrefabRefEntity(),(n==null?void 0:n.deferDomainBinding)!==!0&&e.isDomainScoped&&!this.root.domainStore.state.entities[y.id]&&e.registerEntityTreeInDomain(y,null),this.addInstance(y,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(y,{...n,...a})),y}return this._bindInstantiatedEntity(y,{...n,...a}),y}_assignSceneInstanceIds(e,t,n){const s=new Map;e.entities.forEach((i,c)=>{s.set(i.id,n&&c===t?n:Pe())});const r=new Map;return e.components.forEach(i=>{r.set(i.id,Pe())}),this._remapLocalHydrationIds(e,s,r),{sourceEntityIdBySceneId:Fe(s),sourceComponentKeyBySceneComponentId:Fe(r)}}_remapLocalHydrationIds(e,t,n){const s=r=>{if(Array.isArray(r))return r.map(a=>s(a));if(!r||typeof r!="object")return r;const i=r;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(r=>{var a,d;const i=r.id,c=structuredClone(r);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(r=>{var c;const i=structuredClone(r);return i.id=n.get(r.id)??r.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,r=s.byAssetId[this.id]??[],i=r.map(l=>s.bindings[l]).find(l=>(l==null?void 0:l.instanceRootEntityId)===e.id||(t==null?void 0:t.expectedBindingId)===(l==null?void 0:l.id)),c=i?new Set(Object.keys(i.overrides.removedEntities??{})):void 0,a=i?new Map(Object.entries(i.overrides.removedComponents??{}).map(([l,f])=>[l,new Set(Object.keys(f??{}))])):void 0,{entityMappings:d,componentMappings:u,sourceEntitySnapshots:p}=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 l of r){const f=s.bindings[l];if((f==null?void 0:f.instanceRootEntityId)===e.id||(t==null?void 0:t.expectedBindingId)===l){t!=null&&t.syncPreservedInstanceState&&this._syncPreservedInstanceStateFromSource(f,p),this.root.prefabFacade.updateBindingSourceBaseline({assetId:this.id,bindingId:l,instanceRootEntityId:e.id,sourceRevision:f.sourceRevision,entityMappings:d,componentMappings:u,sourceEntitySnapshots:p});return}}let y=1;for(const l of r){const f=s.bindings[l];f&&f.sourceRevision>y&&(y=f.sourceRevision)}this.root.prefabFacade.bindExistingInstance({assetId:this.id,instanceRootEntityId:e.id,sourceRevision:y,entityMappings:d,componentMappings:u,sourceEntitySnapshots:p,undoable:(t==null?void 0:t.undoable)===!0})}_syncPreservedInstanceStateFromSource(e,t){const n=this.root.domainStore.getNormalizedState(),s=[];for(const[r,i]of Object.entries(t)){const c=i.sceneEntityId??e.sourceToSceneEntity[r];if(!c)continue;const a=n.entities[c];if(!a)continue;const d=`/entities/${ne(c)}`,u=e.overrides.entityProps[r];(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 p=u==null?void 0:u.transform;for(const l of["position","rotation","scale"]){if((p==null?void 0:p[l])!==void 0)continue;const f=i.transform[l];_e(a.transform[l],f)||s.push({op:"replace",path:`${d}/transform/${l}`,value:f})}const y=e.overrides.componentProps[r]??{};for(const[l,f]of Object.entries(i.components)){const h=f.sceneComponentId;if(!h)continue;const m=n.components[h];if(!m)continue;const E=`${d}/components/${ne(h)}`,P=y[l]??{},_=f.props??{};for(const[g,T]of Object.entries(_)){if(Object.prototype.hasOwnProperty.call(P,g))continue;const V=`${E}/props/${ne(g)}`;_e(m.props[g],T)||s.push({op:Object.prototype.hasOwnProperty.call(m.props,g)?"replace":"add",path:V,value:T})}for(const g of Object.keys(m.props))Object.prototype.hasOwnProperty.call(_,g)||Object.prototype.hasOwnProperty.call(P,g)||s.push({op:"remove",path:`${E}/props/${ne(g)}`})}}this.root.domainStore.applySystem(s)}_collectInstanceMappings(e,t,n){var s,r,i;return mn({assetId:this.id,prefabFile:this._requirePrefabSourceFile(),sourceRoot:e,sceneRoot:t,normalized:(i=(r=(s=this.root)==null?void 0:s.domainStore)==null?void 0:r.getNormalizedState)==null?void 0:i.call(r),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,resolveInstanceAsset:(c,a)=>{var y,l,f,h;const d=(l=(y=this.root.assetStore).getAssetByVirtualPath)==null?void 0:l.call(y,c);if(!d)throw new Error(`Prefab source entity "${a}" references missing instance asset "${c}".`);const u=(h=(f=d.getMetaConfig)==null?void 0:f.call(d))==null?void 0:h.type;if(u!=="Prefab"&&u!=="glTF")throw new Error(`Prefab source entity "${a}" references unsupported instance asset "${c}" of type "${String(u)}".`);const p=d.prefabFile;return{id:d.id,kind:u,...u==="Prefab"&&typeof(p==null?void 0:p.root)=="string"?{sourceRootEntityId:p.root}:{}}},resolveSourceAssetRefToDomainId:(c,a)=>this._createSourceRefCodec().sourceToDomain(c,a),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 p,y,l;const s=this._requirePrefabSourceFile(),r=s.entities.findIndex(f=>f.id===e);if(r<0)return t;const i=new Set(((p=s.entities[r])==null?void 0:p.children)??[]);if(i.size===0)return 0;const c=((y=n.parentEntity)==null?void 0:y.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 h=(l=c[f])==null?void 0:l.instanceSourceEntityId;h&&i.has(h)&&(u+=1)}return Math.min(Math.max(u,0),i.size)}_collectSnapshotComponentProps(e,t){return e&&Reflect.ownKeys(St(e)).length>0?this._convertSourceRefsToDomainRefs(bt(e)):this._convertSourceRefsToDomainRefs(structuredClone(t.props??{}))}async replaceInstance(e,t,n){var d,u,p;const s=t.entities.get(e);if(!s)return null;const r=(d=s==null?void 0:s.engineObject)==null?void 0:d.transform,i=r?{position:{x:r.position.x,y:r.position.y,z:r.position.z},rotation:{x:r.rotation.x,y:r.rotation.y,z:r.rotation.z},scale:{x:r.scale.x,y:r.scale.y,z:r.scale.z}}:void 0,c=(p=(u=s.root.domainStore.getNormalizedState().entities[e])==null?void 0:u.instance)==null?void 0:p.bindingId,a=await this.instantiate(t,n!=null&&n.resetRootTransform?void 0:i,{...n!=null&&n.undoable?{undoable:!0}:{},expectedBindingId:c});return a.convertToPrefabRefEntity(),n!=null&&n.structuralDeltaMode?t.replaceEntity(e,a,{structuralDeltaMode:n.structuralDeltaMode}):t.replaceEntity(e,a),a}_refreshTrackedInstanceBindings(e){var s;const t=this.root.sceneStore,n=this._queryInstanceEntityIdsFromDomain();for(const r of n){const i=(s=t.getEntityModel)==null?void 0:s.call(t,r);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,r=Array.from(s.selectedKeys);if(r.length>1)for(let i=0;i<r.length;i++)j.createByEntity(n.getEntityModel(r[i]));else It({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(r[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 r of n){const i=t.state.prefab.bindings[r];i&&i.sourceRevision>s&&(s=i.sourceRevision)}e.updatePrefabContent(this.id,s+1)}_collectEntitySubtree(e,t={}){const n=[],s=(r,i=!1)=>{if(n.push(r),!(this._isNestedInstanceRootForSource(r)&&!(i&&t.materializeRootPrefabInstance)))for(const a of r.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 Tt(this.prefabFile,["$ref"])){if(typeof s!="string"||s===this.id)continue;const r=(n=t.getAssetByVirtualPath)==null?void 0:n.call(t,s);if(!r)throw new Error(`[SceneV2] Unable to resolve prefab asset ref "${s}" while collecting dependencies`);r.id!==this.id&&e.add(r)}return e}_syncDependentAssetsFromPrefabFile(){const e=this.root.assetStore;this.dependentAssets=Array.from(this._collectDependentAssetsFromPrefabFile(),t=>({id:t.id,name:t.name,type:t.getMetaConfig().type,ref:(()=>{var s;const n=(s=e.getAssetVirtualPath)==null?void 0:s.call(e,t.id);if(typeof n!="string"||n.length===0)throw new Error(`[SceneV2] Unable to serialize prefab dependency ref "${t.id}": missing virtualPath`);return n})()}))}_updateContent(e){return this._contentQueue.enqueue(async()=>{try{await this._updateContentInternal(e)}catch(t){if(t instanceof Error&&t.message==="cancelled")return;throw O.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 r=this.engineObject;if(r){this.root.assetStore.engineObjectToAssetMap.delete(r);try{r.destroy()}catch(a){O.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")),O.error(`The prefab which id is ${this.id} is broken, use default prefab instead.`)),c.engineObject||(O.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",()=>{O.error(`The prefab which id is ${this.id} is broken.`),this._updateContent().catch(a=>{O.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,p=this._queryInstanceEntityIdsFromDomain();await Promise.all(p.map(y=>{var f,h;const l=(h=(f=this.root.domainStore.getNormalizedState().entities[y])==null?void 0:f.instance)==null?void 0:h.bindingId;return this.replaceInstance(y,u,{...d??{},resetRootTransform:l!==void 0&&a.has(l),...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){O.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)})}};X([Et()],j.prototype,"prefabFile",2);X([wt(),Pt],j.prototype,"dependentAssets",2);X([ke],j.prototype,"replaceDependentAsset",1);X([ke],j.prototype,"_onDrop",1);j=X([_t({type:"Prefab",label:J("asset.prefab.title"),extname:"prefab",dragLayer:he.Prefab,customInspector:Zt,viewer:tn,thumbnail:ae,async bundle(o){return{content:new Blob([o.content],{type:"application/json"})}}})],j);export{j 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-e44b357e.js";import"./index-debbe073.js";import"./postmen-443b3e5f.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Dt}from"./bundlers-9b0d37fc.js";import{M as Et}from"./MeshThumbnail-b1283749.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,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-c3dec278.js";import"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Dt}from"./bundlers-9b0d37fc.js";import{M as Et}from"./MeshThumbnail-07ffa076.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-e44b357e.js";import{M as h}from"./MaterialInspector-23ea0240.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,av as t,aL as d,aM as c,aN as g}from"./index-c3dec278.js";import{M as h}from"./MaterialInspector-8d466d59.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 +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-e44b357e.js";import"./index-debbe073.js";import"./postmen-443b3e5f.js";import{A as B}from"./AssetViewer-d2c63b00.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,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-c3dec278.js";import"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";import{A as B}from"./AssetViewer-3847c058.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 +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,aW as u,aX as d,aY as f,aZ as y,n as D,e as S,o as v}from"./index-e44b357e.js";import"./index-debbe073.js";import"./postmen-443b3e5f.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,a)=>{for(var n=a>1?void 0:a?w(e,s):e,i=t.length-1,r;i>=0;i--)(r=t[i])&&(n=(a?r(e,s,n):r(n))||n);return a&&n&&g(e,s,n),n};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(){var s;const e=this.root.sceneStore;if(this.id===e.refId){if(e.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()}else if((s=this.sceneData)!=null&&s.scene&&this.sceneData.scene.name!==this.name)return this.sceneData.scene.name=this.name,super.saveMainImmediately()}async initByCreation(e,s,a){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
+ 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,aW as u,aX as d,aY as f,aZ as y,n as D,e as S,o as v}from"./index-c3dec278.js";import"./index-cdbb2f4d.js";import"./postmen-2853c0e6.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,a)=>{for(var n=a>1?void 0:a?w(e,s):e,i=t.length-1,r;i>=0;i--)(r=t[i])&&(n=(a?r(e,s,n):r(n))||n);return a&&n&&g(e,s,n),n};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(){var s;const e=this.root.sceneStore;if(this.id===e.refId){if(e.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()}else if((s=this.sceneData)!=null&&s.scene&&this.sceneData.scene.name!==this.name)return this.sceneData.scene.name=this.name,super.saveMainImmediately()}async initByCreation(e,s,a){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 Dr=Object.defineProperty;var Vr=(e,c,i)=>c in e?Dr(e,c,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[c]=i;var Ae=(e,c,i)=>(Vr(e,typeof c!="symbol"?c+"":c,i),i);import{dM as Fr,b3 as Ke,dN as Gr,dO as Br,ag as Tr,dP as kr,dQ as Ur,a2 as Wr,a1 as Nr,af as zr,dR as Hr,dS as rr,dT as dr,dU as jr,aH as qr,aJ as Xr,av as Je,e as ht,C as ue,dV as wr,aO as Qr,b1 as vr,b2 as ir,j as Yr,u as $r,ae as Nt,dW as Jr,F as ar,ai as nr,V as sr,bX as Zr,aT as Kr,x as ei,c2 as ti,n as ri,o as ii,dX as ai,dY as ni,dZ as si}from"./index-e44b357e.js";import"./index-debbe073.js";import"./postmen-443b3e5f.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Re,t as oi,g as ci,i as li,E as or,b as ui,l as pi}from"./ShaderUIScriptAsset-ebf57ceb.js";import{E as de,s as hi}from"./shader-data-utils-000170ae.js";import{I as fi}from"./IconPointFilled-bad94cf1.js";import{F as _i}from"./index-7e414715.js";function di(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 vi(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=vi(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 Dr=Object.defineProperty;var Vr=(e,c,i)=>c in e?Dr(e,c,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[c]=i;var Ae=(e,c,i)=>(Vr(e,typeof c!="symbol"?c+"":c,i),i);import{dM as Fr,b3 as Ke,dN as Gr,dO as Br,ag as Tr,dP as kr,dQ as Ur,a2 as Wr,a1 as Nr,af as zr,dR as Hr,dS as rr,dT as dr,dU as jr,aH as qr,aJ as Xr,av as Je,e as ht,C as ue,dV as wr,aO as Qr,b1 as vr,b2 as ir,j as Yr,u as $r,ae as Nt,dW as Jr,F as ar,ai as nr,V as sr,bX as Zr,aT as Kr,x as ei,c2 as ti,n as ri,o as ii,dX as ai,dY as ni,dZ as si}from"./index-c3dec278.js";import"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Re,t as oi,g as ci,i as li,E as or,b as ui,l as pi}from"./ShaderUIScriptAsset-e1cd0b8b.js";import{E as de,s as hi}from"./shader-data-utils-f0e4f5a3.js";import{I as fi}from"./IconPointFilled-62d3c3b2.js";import{F as _i}from"./index-05b76766.js";function di(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 vi(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=vi(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 mi(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 Gr(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 Si(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||!Si(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
 
@@ -1,4 +1,4 @@
1
- var ni=Object.defineProperty;var ai=(n,e,t)=>e in n?ni(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>(ai(n,typeof e!="symbol"?e+"":e,t),t);import{aJ as ut,aM as b,av as y,aO as ve,bz as ri,aI as tt,g8 as oi,cl as li,N as Nt,W as ci,aH as it,aK as Rt,ai as Wt,a_ as Fe,by as pi,a$ as hi,gw as ui,b3 as di,co as fi,dh as ke,f4 as gi,aL as mi,eW as yi,e as P,bA as jt,q as et,ay as wi,aP as _t,F as De,j as ot,gx as be,$ as xi,K as Ee,C as R,bV as Pt,aA as vi,p as M,m as E,f as bi,v as Si,aC as Bt,n as Ct,o as Mt,bR as Le,c7 as Ii,bZ as gt,bY as Se,gy as Ri,bk as Ci,dk as _i,eq as Ie,ad as Q,T as D,gz as Re,s as Pi,f6 as Ht,aN as Mi,bX as Jt,b_ as Gt,u as $e,S as Ti,x as yt,aT as dt,bW as Ai,dX as pt,ae as ji,dY as Bi,dZ as Oi}from"./index-e44b357e.js";import{L as Zt}from"./module-5547be1c.js";import{u as re,F as Qt,r as te}from"./index-debbe073.js";import"./postmen-443b3e5f.js";import{c as Ne}from"./createReactComponent-cb70ea50.js";import{I as ze}from"./IconPlus-172c6c17.js";import{A as Ue}from"./AssetViewer-d2c63b00.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Fi}from"./bundlers-9b0d37fc.js";import{b as Ve,a as qe,c as ki}from"./TextureAsset-9cd94531.js";import"./GlTFAsset-83e8190e.js";import"./MaterialAsset-0b9d7eba.js";import"./MeshAsset-85e99837.js";import"./AnimatorControllerAsset-6cc04274.js";import"./AnimationClipAsset-b084da2a.js";import"./AmbientLightAsset-e34de607.js";import{L as Di}from"./module-57b6e417.js";import{s as Ei}from"./SpineSkeletonDataAsset-0dffbb4d.js";import"./FontAsset-6e9c0549.js";import"./SceneAsset-d05b1a79.js";import"./ShaderAsset-370b6f1c.js";import{l as Li}from"./ShaderUIScriptAsset-ebf57ceb.js";import"./PrimitiveMesh-70c93e7e.js";import"./XRReferenceImageAsset-79e78558.js";import"./PrefabAsset-265f6f48.js";import"./PhysicsMaterialAsset-cb9afb6e.js";import"./RenderTargetAsset-b810caf3.js";import"./AudioAsset-9c715952.js";import"./index-ea7fe254.js";import"./MarkdownAsset-b42846c0.js";import{F as We}from"./FormItemArray-b2a3d249.js";import{F as Kt}from"./index-7e414715.js";function $i(n,e){const t={};for(let i=0;i<n.length;i++){const s=n[i],a=e(s);Object.hasOwn(t,a)||(t[a]=[]),t[a].push(s)}return t}function Ni(n,e){const t=[],i=[];for(let s=0;s<n.length;s++){const a=n[s];e(a)?t.push(a):i.push(a)}return[t,i]}function zi(n,e){const t=new Map;for(let i=0;i<n.length;i++){const s=n[i],a=e(s);t.has(a)||t.set(a,s)}return Array.from(t.values())}/**
1
+ var ni=Object.defineProperty;var ai=(n,e,t)=>e in n?ni(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>(ai(n,typeof e!="symbol"?e+"":e,t),t);import{aJ as ut,aM as b,av as y,aO as ve,bz as ri,aI as tt,g9 as oi,cl as li,N as Nt,W as ci,aH as it,aK as Rt,ai as Wt,a_ as Fe,by as pi,a$ as hi,gs as ui,b3 as di,co as fi,dh as ke,f4 as gi,aL as mi,eW as yi,e as P,bA as jt,q as et,ay as wi,aP as _t,F as De,j as ot,gt as be,$ as xi,K as Ee,C as R,bV as Pt,aA as vi,p as M,m as E,f as bi,v as Si,aC as Bt,n as Ct,o as Mt,bR as Le,c7 as Ii,bZ as gt,bY as Se,gu as Ri,bk as Ci,dk as _i,eq as Ie,ad as Q,T as D,gv as Re,s as Pi,f6 as Ht,aN as Mi,bX as Jt,b_ as Gt,u as $e,S as Ti,x as yt,aT as dt,bW as Ai,dX as pt,ae as ji,dY as Bi,dZ as Oi}from"./index-c3dec278.js";import{L as Zt}from"./module-ec094ef6.js";import{u as re,F as Qt,r as te}from"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";import{c as Ne}from"./createReactComponent-58d9f0dd.js";import{I as ze}from"./IconPlus-def01e2b.js";import{A as Ue}from"./AssetViewer-3847c058.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Fi}from"./bundlers-9b0d37fc.js";import{b as Ve,a as qe,c as ki}from"./TextureAsset-a7ff39b1.js";import"./GlTFAsset-5970e707.js";import"./MaterialAsset-5353c4cb.js";import"./MeshAsset-c2bf60c5.js";import"./AnimatorControllerAsset-2716497a.js";import"./AnimationClipAsset-d7b37af0.js";import"./AmbientLightAsset-be9e872c.js";import{L as Di}from"./module-ada3dced.js";import{s as Ei}from"./SpineSkeletonDataAsset-43b731f1.js";import"./FontAsset-d34b5378.js";import"./SceneAsset-08752701.js";import"./ShaderAsset-a9d667f5.js";import{l as Li}from"./ShaderUIScriptAsset-e1cd0b8b.js";import"./PrimitiveMesh-075dda8a.js";import"./XRReferenceImageAsset-96f516ba.js";import"./PrefabAsset-59743dbb.js";import"./PhysicsMaterialAsset-a2f73b5c.js";import"./RenderTargetAsset-b3cd1c49.js";import"./AudioAsset-c28f33ab.js";import"./index-da16047f.js";import"./MarkdownAsset-b2a3fad5.js";import{F as We}from"./FormItemArray-b8cda1d2.js";import{F as Kt}from"./index-05b76766.js";function $i(n,e){const t={};for(let i=0;i<n.length;i++){const s=n[i],a=e(s);Object.hasOwn(t,a)||(t[a]=[]),t[a].push(s)}return t}function Ni(n,e){const t=[],i=[];for(let s=0;s<n.length;s++){const a=n[s];e(a)?t.push(a):i.push(a)}return[t,i]}function zi(n,e){const t=new Map;for(let i=0;i<n.length;i++){const s=n[i],a=e(s);t.has(a)||t.set(a,s)}return Array.from(t.values())}/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
@@ -1,4 +1,4 @@
1
- var N=Object.defineProperty;var B=(t,a,e)=>a in t?N(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var d=(t,a,e)=>(B(t,typeof a!="symbol"?a+"":a,e),e);import{eB as w,bX as S,e as R,dJ as x,aJ as H,C as T,av as A,dV as I,j as Q,u as k,x as X,aT as U,p as $,c2 as j,n as V,q as G,o as q,dY as z,dZ as W,eC as Y,dU as K,dW as J}from"./index-e44b357e.js";import"./index-debbe073.js";import"./postmen-443b3e5f.js";function Z(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}const E="galacean-local-ide-config";function ee(t,a){const e=t.trim().replace(/^["'`]+|["'`]+$/g,"").replace(/\\/g,"/").replace(/\/{2,}/g,"/").replace(/\/+$/,"");if(!e)return p("empty",e);if(/[\r\n\t]/.test(e))return p("embedded-newline",e);if(/(^|\/)[a-z][a-z0-9+.-]*:\/\//i.test(e))return p("embedded-url",e);if(e.startsWith("~"))return p("tilde",e);if(!e.startsWith("/")&&!/^[A-Za-z]:\//.test(e))return p("not-absolute",e);if(/[<>"|?*]/.test(e))return p("illegal-chars",e);const r=e.split("/").filter(Boolean);return r.includes("..")||r.includes(".")?p("parent-segment",e):a?r[r.length-1]!==a?{kind:"error",reason:"tail-mismatch",normalized:e,expectedTail:a}:{kind:"ok",normalized:e}:p("no-binding",e)}function p(t,a){return{kind:"error",reason:t,normalized:a}}function ae(t){try{const a=localStorage.getItem(E);if(!a)return null;const e=JSON.parse(a);if(!e||typeof e.workspacePath!="string"||typeof e.ide!="string")return null;if(!e.workspacePath.trim())return localStorage.removeItem(E),null;const r=ee(e.workspacePath,t??null);return r.kind==="error"&&r.reason!=="no-binding"?(localStorage.removeItem(E),null):e}catch{return null}}function te(t){const a=t.replace(/\\/g,"/");return/^[A-Za-z]:\//.test(a)?`/${a}`:a}function re(t,a){switch(t){case"vscode":return`vscode://file${a}`;case"cursor":return`cursor://file${a}`;case"webstorm":return`webstorm://open?file=${encodeURIComponent(a)}`}}function v(t,a,e="",r=""){const s=[a.replace(/[\\/]+$/,""),e,r].filter(Boolean).join("/");return re(t,te(s))}function D(t){const a=document.createElement("a");a.href=t,a.style.display="none",document.body.appendChild(a),a.click(),a.remove()}function se(t,a,e){const{ide:r,workspacePath:s}=t,n=v(r,s,a,e);if(r==="webstorm"){D(n);return}D(v(r,s,a)),setTimeout(()=>D(n),800)}async function ne(t,a,e){const r=a.projectStore.localWorkspaceSync,s=ae(r==null?void 0:r.directoryName);if(!s||!(r!=null&&r.directoryHandle)){e();return}const n=a.projectStore.id,o=w(t);if(!await r.hasSyncedFile(o)){const h=(u,M)=>R(`asset.local-workspace-sync.${u}`,M),m=S.loading(h("syncing"));try{if(!await r.syncEditorAssetsToLocal()||!await r.hasSyncedFile(o)){S.error(r.errorMessage||h("failed"),{id:m}),e();return}S.success(h("success",[r.directoryName||h("local-workspace")]),{id:m})}catch(u){S.error(u instanceof Error?u.message:h("failed"),{id:m}),e();return}}se(s,n,o)}const oe=t=>{const{type:a="esm",varName:e,namedExports:r=null,defaultExport:s=!0}=typeof t=="string"?{varName:t}:t;return{type:a,varName:e,namedExports:r,defaultExport:s}},ie=t=>`module.exports = ${t};`,le=(t,a,e)=>{const r=e?[`export default ${t};`]:[];if(a&&a.length){const s=[...new Set(a)].join(", ");r.push(`const { ${s} } = ${t};`),r.push(`export { ${s} };`)}return r.join(`
1
+ var N=Object.defineProperty;var B=(t,a,e)=>a in t?N(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var d=(t,a,e)=>(B(t,typeof a!="symbol"?a+"":a,e),e);import{eB as w,bX as S,e as R,dJ as x,aJ as H,C as T,av as A,dV as I,j as Q,u as k,x as X,aT as U,p as $,c2 as j,n as V,q as G,o as q,dY as z,dZ as W,eC as Y,dU as K,dW as J}from"./index-c3dec278.js";import"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";function Z(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}const E="galacean-local-ide-config";function ee(t,a){const e=t.trim().replace(/^["'`]+|["'`]+$/g,"").replace(/\\/g,"/").replace(/\/{2,}/g,"/").replace(/\/+$/,"");if(!e)return p("empty",e);if(/[\r\n\t]/.test(e))return p("embedded-newline",e);if(/(^|\/)[a-z][a-z0-9+.-]*:\/\//i.test(e))return p("embedded-url",e);if(e.startsWith("~"))return p("tilde",e);if(!e.startsWith("/")&&!/^[A-Za-z]:\//.test(e))return p("not-absolute",e);if(/[<>"|?*]/.test(e))return p("illegal-chars",e);const r=e.split("/").filter(Boolean);return r.includes("..")||r.includes(".")?p("parent-segment",e):a?r[r.length-1]!==a?{kind:"error",reason:"tail-mismatch",normalized:e,expectedTail:a}:{kind:"ok",normalized:e}:p("no-binding",e)}function p(t,a){return{kind:"error",reason:t,normalized:a}}function ae(t){try{const a=localStorage.getItem(E);if(!a)return null;const e=JSON.parse(a);if(!e||typeof e.workspacePath!="string"||typeof e.ide!="string")return null;if(!e.workspacePath.trim())return localStorage.removeItem(E),null;const r=ee(e.workspacePath,t??null);return r.kind==="error"&&r.reason!=="no-binding"?(localStorage.removeItem(E),null):e}catch{return null}}function te(t){const a=t.replace(/\\/g,"/");return/^[A-Za-z]:\//.test(a)?`/${a}`:a}function re(t,a){switch(t){case"vscode":return`vscode://file${a}`;case"cursor":return`cursor://file${a}`;case"webstorm":return`webstorm://open?file=${encodeURIComponent(a)}`}}function v(t,a,e="",r=""){const s=[a.replace(/[\\/]+$/,""),e,r].filter(Boolean).join("/");return re(t,te(s))}function D(t){const a=document.createElement("a");a.href=t,a.style.display="none",document.body.appendChild(a),a.click(),a.remove()}function se(t,a,e){const{ide:r,workspacePath:s}=t,n=v(r,s,a,e);if(r==="webstorm"){D(n);return}D(v(r,s,a)),setTimeout(()=>D(n),800)}async function ne(t,a,e){const r=a.projectStore.localWorkspaceSync,s=ae(r==null?void 0:r.directoryName);if(!s||!(r!=null&&r.directoryHandle)){e();return}const n=a.projectStore.id,o=w(t);if(!await r.hasSyncedFile(o)){const h=(u,M)=>R(`asset.local-workspace-sync.${u}`,M),m=S.loading(h("syncing"));try{if(!await r.syncEditorAssetsToLocal()||!await r.hasSyncedFile(o)){S.error(r.errorMessage||h("failed"),{id:m}),e();return}S.success(h("success",[r.directoryName||h("local-workspace")]),{id:m})}catch(u){S.error(u instanceof Error?u.message:h("failed"),{id:m}),e();return}}se(s,n,o)}const oe=t=>{const{type:a="esm",varName:e,namedExports:r=null,defaultExport:s=!0}=typeof t=="string"?{varName:t}:t;return{type:a,varName:e,namedExports:r,defaultExport:s}},ie=t=>`module.exports = ${t};`,le=(t,a,e)=>{const r=e?[`export default ${t};`]:[];if(a&&a.length){const s=[...new Set(a)].join(", ");r.push(`const { ${s} } = ${t};`),r.push(`export { ${s} };`)}return r.join(`
2
2
  `)},de=t=>{const{type:a,varName:e,namedExports:r,defaultExport:s}=t;switch(a){case"esm":return le(e,r,s);case"cjs":return ie(e)}},f="global-externals",ce=t=>{const{modulePathFilter:a,getModuleInfo:e}=t;return{name:f,setup(r){r.onResolve({filter:a},s=>({path:s.path,namespace:f})),r.onLoad({filter:/.*/,namespace:f},s=>{const n=s.path,o=oe(e(n));return{contents:de(o)}})}}},he=t=>{const a={modulePathFilter:new RegExp(`^(?:${Object.keys(t).join("|")})$`),getModuleInfo:e=>t[e]};return ce(a)},ue=async t=>x(()=>import(t),[]);async function pe(t,a=ue){const e=URL.createObjectURL(new Blob([t],{type:"application/javascript"}));try{return await a(e)}finally{URL.revokeObjectURL(e)}}var c=(t=>(t.Default="default",t.ShaderUI="shader_ui",t.StateMachine="state_machine",t))(c||{});const C=`
3
3
  this.onPropertyChanged("isTransparent", (material, isTransparent) => {
4
4
  const shaderData = material.shaderData;
@@ -1 +1 @@
1
- var y=Object.defineProperty;var j=(s,e,r)=>e in s?y(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var c=(s,e,r)=>(j(s,typeof e!="symbol"?e+"":e,r),r);import{aJ as m,bm as v,aK as b,av as t,aw as S,ay as d,aH as f,aI as g,aM as u,aO as k,aN as B,f as O,p as h,C as F,s as R}from"./index-e44b357e.js";import{u as I}from"./index-debbe073.js";import{c as M}from"./Component-b95aa2af.js";import"./postmen-443b3e5f.js";import{c as E}from"./createOnModelChange-e65da908.js";import{M as _}from"./MaterialInspector-23ea0240.js";import{M as z}from"./MeshRendererBaseComponent-5621d663.js";import"./IconPointFilled-bad94cf1.js";import"./createReactComponent-cb70ea50.js";const x=m(v),P=m(({model:s,inspectorConfig:e,onModelChange:r})=>{const{disabled:n,property:o}=e,{t:i}=b();return t.jsxs(t.Fragment,{children:[t.jsx(S,{label:i(e.label),info:i(e.info),fieldCss:{minHeight:"$5"},children:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:null})}),t.jsx(x,{label:" ",disabled:n,value:s[o].min,onChange:a=>{r==null||r(o,{...s[o],min:a})},formEndSlot:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.min.label")})}),t.jsx(x,{label:" ",disabled:n,value:s[o].max,onChange:a=>{r==null||r(o,{...s[o],max:a})},formEndSlot:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.max.label")})})]})}),C=f("div",{marginLeft:"5px"}),T=f(g,{border:"1px solid $gray6",borderRadius:"$2",padding:"$0_5",color:"$gray11",cursor:"pointer"}),$=m(function(s){const e=s.data,{t:r}=b();return t.jsxs(T,{align:"v",children:[t.jsx("img",{src:e.thumbnailUrl,alt:"Material Thumbnail",width:"20px",height:"20px"}),t.jsxs(C,{children:[r("skinned-mesh-renderer.material.label"),"(",e.name,")"]})]})}),w=m(function(s){const[e,r]=u.useState(null),n=s.data,{assetStore:o,inspectorFacade:i}=I();return u.useEffect(()=>{o.getAssetByRef(n.material).then(a=>{r(a)})},[n.material]),t.jsxs(t.Fragment,{children:[t.jsx(k.List,{model:n,configs:n.formSchema.items,onModelChange:E("component",n.id,i,n)}),e&&t.jsx(B,{nesting:!0,title:t.jsx($,{data:e}),open:n.materialOpen,onOpenChange:a=>{n.setMaterialOpen(a)},children:t.jsx(_,{asset:e})})]})});var H=Object.defineProperty,V=Object.getOwnPropertyDescriptor,p=(s,e,r,n)=>{for(var o=n>1?void 0:n?V(e,r):e,i=s.length-1,a;i>=0;i--)(a=s[i])&&(o=(n?a(e,r,o):a(o))||o);return n&&o&&H(e,r,o),o};let l=class extends z{constructor(e,r){super(e,r);c(this,"rootBone",null);c(this,"localBounds",{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}})}};p([O({getEngineValue:s=>{var e;return(e=s.skin)==null?void 0:e.rootBone}}),h({label:"skinned-mesh-renderer.skin.root-bone.label",info:"skinned-mesh-renderer.skin.root-bone.info",type:F.EntityPicker,disabled:!0})],l.prototype,"rootBone",2);p([h({label:"skinned-mesh-renderer.local-bounds.title",info:"skinned-mesh-renderer.local-bounds.info",customComponent:P,type:"BoundingBox"}),R()],l.prototype,"localBounds",2);l=p([M({type:"SkinnedMeshRenderer",customInspector:w,componentsMenu:{label:"component.renderer.skinned-mesh.title"}})],l);export{l as SkinnedMeshRendererComponent};
1
+ var y=Object.defineProperty;var j=(s,e,r)=>e in s?y(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var c=(s,e,r)=>(j(s,typeof e!="symbol"?e+"":e,r),r);import{aJ as m,bm as v,aK as b,av as t,aw as S,ay as d,aH as f,aI as g,aM as u,aO as k,aN as B,f as O,p as h,C as F,s as R}from"./index-c3dec278.js";import{u as I}from"./index-cdbb2f4d.js";import{c as M}from"./Component-0f881fc1.js";import"./postmen-2853c0e6.js";import{c as E}from"./createOnModelChange-370b83da.js";import{M as _}from"./MaterialInspector-8d466d59.js";import{M as z}from"./MeshRendererBaseComponent-fde6b6a5.js";import"./IconPointFilled-62d3c3b2.js";import"./createReactComponent-58d9f0dd.js";const x=m(v),P=m(({model:s,inspectorConfig:e,onModelChange:r})=>{const{disabled:n,property:o}=e,{t:i}=b();return t.jsxs(t.Fragment,{children:[t.jsx(S,{label:i(e.label),info:i(e.info),fieldCss:{minHeight:"$5"},children:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:null})}),t.jsx(x,{label:" ",disabled:n,value:s[o].min,onChange:a=>{r==null||r(o,{...s[o],min:a})},formEndSlot:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.min.label")})}),t.jsx(x,{label:" ",disabled:n,value:s[o].max,onChange:a=>{r==null||r(o,{...s[o],max:a})},formEndSlot:t.jsx(d,{size:"sm",selectable:!0,code:!0,children:i("skinned-mesh-renderer.local-bounds.max.label")})})]})}),C=f("div",{marginLeft:"5px"}),T=f(g,{border:"1px solid $gray6",borderRadius:"$2",padding:"$0_5",color:"$gray11",cursor:"pointer"}),$=m(function(s){const e=s.data,{t:r}=b();return t.jsxs(T,{align:"v",children:[t.jsx("img",{src:e.thumbnailUrl,alt:"Material Thumbnail",width:"20px",height:"20px"}),t.jsxs(C,{children:[r("skinned-mesh-renderer.material.label"),"(",e.name,")"]})]})}),w=m(function(s){const[e,r]=u.useState(null),n=s.data,{assetStore:o,inspectorFacade:i}=I();return u.useEffect(()=>{o.getAssetByRef(n.material).then(a=>{r(a)})},[n.material]),t.jsxs(t.Fragment,{children:[t.jsx(k.List,{model:n,configs:n.formSchema.items,onModelChange:E("component",n.id,i,n)}),e&&t.jsx(B,{nesting:!0,title:t.jsx($,{data:e}),open:n.materialOpen,onOpenChange:a=>{n.setMaterialOpen(a)},children:t.jsx(_,{asset:e})})]})});var H=Object.defineProperty,V=Object.getOwnPropertyDescriptor,p=(s,e,r,n)=>{for(var o=n>1?void 0:n?V(e,r):e,i=s.length-1,a;i>=0;i--)(a=s[i])&&(o=(n?a(e,r,o):a(o))||o);return n&&o&&H(e,r,o),o};let l=class extends z{constructor(e,r){super(e,r);c(this,"rootBone",null);c(this,"localBounds",{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}})}};p([O({getEngineValue:s=>{var e;return(e=s.skin)==null?void 0:e.rootBone}}),h({label:"skinned-mesh-renderer.skin.root-bone.label",info:"skinned-mesh-renderer.skin.root-bone.info",type:F.EntityPicker,disabled:!0})],l.prototype,"rootBone",2);p([h({label:"skinned-mesh-renderer.local-bounds.title",info:"skinned-mesh-renderer.local-bounds.info",customComponent:P,type:"BoundingBox"}),R()],l.prototype,"localBounds",2);l=p([M({type:"SkinnedMeshRenderer",customInspector:w,componentsMenu:{label:"component.renderer.skinned-mesh.title"}})],l);export{l as SkinnedMeshRendererComponent};