@galacean/cli 2.0.0-alpha.21 → 2.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.bundle.cjs +32853 -32387
- package/dist/preview-client/_static/{Accordion-b106eaf3.js → Accordion-75b7b34e.js} +1 -1
- package/dist/preview-client/_static/{AmbientLightAsset-6b2d168c.js → AmbientLightAsset-02786385.js} +1 -1
- package/dist/preview-client/_static/{AnimationClipAsset-a5d290cc.js → AnimationClipAsset-f96e0e56.js} +1 -1
- package/dist/preview-client/_static/{AnimatorControllerAsset-616578b4.js → AnimatorControllerAsset-23cceb12.js} +1 -1
- package/dist/preview-client/_static/{AnimatorStore-bc865a7e.js → AnimatorStore-48d2c14c.js} +1 -1
- package/dist/preview-client/_static/{AssetViewer-1a9f3cad.js → AssetViewer-1073ddb5.js} +1 -1
- package/dist/preview-client/_static/{AudioAsset-24b03bc3.js → AudioAsset-6218f2bb.js} +1 -1
- package/dist/preview-client/_static/{AudioComponent-060f13a6.js → AudioComponent-16766db8.js} +1 -1
- package/dist/preview-client/_static/{Callout-c8b9b055.js → Callout-312ada1c.js} +1 -1
- package/dist/preview-client/_static/{CameraComponent-33b1918d.js → CameraComponent-c919c2dd.js} +1 -1
- package/dist/preview-client/_static/{Component-3cb422ab.js → Component-6d1e73e5.js} +1 -1
- package/dist/preview-client/_static/{DirectLight-072d3047.js → DirectLight-166a628d.js} +1 -1
- package/dist/preview-client/_static/{FontAsset-1e1118c1.js → FontAsset-8367aad9.js} +1 -1
- package/dist/preview-client/_static/{FormItemArray-f1283fce.js → FormItemArray-53c58844.js} +1 -1
- package/dist/preview-client/_static/{GlTFAsset-dc68541e.js → GlTFAsset-5c8e7813.js} +1 -1
- package/dist/preview-client/_static/{IconPlus-99d7bb90.js → IconPlus-5fbc029e.js} +1 -1
- package/dist/preview-client/_static/{IconPointFilled-f8224625.js → IconPointFilled-dbf63b5c.js} +1 -1
- package/dist/preview-client/_static/{LightBaseComponent-b610e42a.js → LightBaseComponent-545c5ee8.js} +1 -1
- package/dist/preview-client/_static/{LottieAnimationComponent-b70c2426.js → LottieAnimationComponent-4db5a6c2.js} +1 -1
- package/dist/preview-client/_static/{MarkdownAsset-2a4a1d10.js → MarkdownAsset-58491579.js} +1 -1
- package/dist/preview-client/_static/{MaterialAsset-dfaa82d9.js → MaterialAsset-c83c7d3d.js} +1 -1
- package/dist/preview-client/_static/{MaterialInspector-21fc5b67.js → MaterialInspector-237b6a5e.js} +1 -1
- package/dist/preview-client/_static/{Menu-62cee67e.js → Menu-a427d272.js} +1 -1
- package/dist/preview-client/_static/{MeshAsset-07529e4e.js → MeshAsset-1c11d7ab.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererBaseComponent-2af8db12.js → MeshRendererBaseComponent-8fd1f0df.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererComponent-d9df7d58.js → MeshRendererComponent-082c1a1a.js} +1 -1
- package/dist/preview-client/_static/{MeshThumbnail-bd30617c.js → MeshThumbnail-d8ee2674.js} +1 -1
- package/dist/preview-client/_static/{ParticleRendererComponent-8729cfbf.js → ParticleRendererComponent-ff12cdb1.js} +1 -1
- package/dist/preview-client/_static/{PhysicsMaterialAsset-e9abb944.js → PhysicsMaterialAsset-7e86c718.js} +1 -1
- package/dist/preview-client/_static/{PhysicsStore-96164e4e.js → PhysicsStore-66a9a461.js} +1 -1
- package/dist/preview-client/_static/{PointLight-76172b61.js → PointLight-a9992e50.js} +1 -1
- package/dist/preview-client/_static/{PostProcessComponent-83f23ced.js → PostProcessComponent-c17ac553.js} +1 -1
- package/dist/preview-client/_static/{PrefabAsset-4bac196b.js → PrefabAsset-a6750aec.js} +1 -1
- package/dist/preview-client/_static/{PrimitiveMesh-9ff7dbc1.js → PrimitiveMesh-388f3f36.js} +1 -1
- package/dist/preview-client/_static/{ReferencedMaterial-27ba90e2.js → ReferencedMaterial-f7ea80fb.js} +1 -1
- package/dist/preview-client/_static/{RenderTargetAsset-e112b8ca.js → RenderTargetAsset-c48990a4.js} +1 -1
- package/dist/preview-client/_static/{SceneAsset-a39f097a.js → SceneAsset-1e802e29.js} +1 -1
- package/dist/preview-client/_static/{ShaderAsset-068b4b97.js → ShaderAsset-256afb00.js} +1 -1
- package/dist/preview-client/_static/{ShaderChunkAsset-bdb39acc.js → ShaderChunkAsset-a42443fc.js} +1 -1
- package/dist/preview-client/_static/{ShaderUIScriptAsset-0c11d0ed.js → ShaderUIScriptAsset-5acb02f5.js} +1 -1
- package/dist/preview-client/_static/{SkinnedMeshRendererComponent-5e58927a.js → SkinnedMeshRendererComponent-934c055b.js} +1 -1
- package/dist/preview-client/_static/{SpineAnimationComponent-1ae4feaa.js → SpineAnimationComponent-b04ba1ee.js} +1 -1
- package/dist/preview-client/_static/{SpineSkeletonDataAsset-284f5f4d.js → SpineSkeletonDataAsset-fff17383.js} +1 -1
- package/dist/preview-client/_static/{SpotLight-1a8af1d4.js → SpotLight-617d8957.js} +1 -1
- package/dist/preview-client/_static/{SpriteBaseComponent-fd82e43b.js → SpriteBaseComponent-062cb4f8.js} +1 -1
- package/dist/preview-client/_static/{SpriteMaskComponent-eab0faf7.js → SpriteMaskComponent-43ae2b1f.js} +1 -1
- package/dist/preview-client/_static/{SpriteRendererComponent-1496fc43.js → SpriteRendererComponent-4f52910c.js} +1 -1
- package/dist/preview-client/_static/{TextBaseComponent-7d2db29c.js → TextBaseComponent-bd7ed8ee.js} +1 -1
- package/dist/preview-client/_static/{TextRendererComponent-88494abb.js → TextRendererComponent-8db74598.js} +1 -1
- package/dist/preview-client/_static/{TextureAsset-7172cc65.js → TextureAsset-d88af413.js} +1 -1
- package/dist/preview-client/_static/{Tooltip-9ce2e9d6.js → Tooltip-3bc02b10.js} +1 -1
- package/dist/preview-client/_static/{TrailRendererComponent-4443baab.js → TrailRendererComponent-42a58f1d.js} +1 -1
- package/dist/preview-client/_static/{TransformBaseComponent-ca2fa45d.js → TransformBaseComponent-77478ccb.js} +1 -1
- package/dist/preview-client/_static/{TransformComponent-683b5e9c.js → TransformComponent-0f395b08.js} +1 -1
- package/dist/preview-client/_static/{XRReferenceImageAsset-823e47cd.js → XRReferenceImageAsset-d6d8e59c.js} +1 -1
- package/dist/preview-client/_static/{audio-10d03160.js → audio-d14900e2.js} +1 -1
- package/dist/preview-client/_static/{createOnModelChange-73358d10.js → createOnModelChange-c010a049.js} +1 -1
- package/dist/preview-client/_static/{createReactComponent-fcd6848b.js → createReactComponent-d9f8b1af.js} +1 -1
- package/dist/preview-client/_static/{index-4cde6efd.js → index-071c0532.js} +1 -1
- package/dist/preview-client/_static/index-1c260f88.js +1 -0
- package/dist/preview-client/_static/{index-0a53aaef.js → index-365736f7.js} +1 -1
- package/dist/preview-client/_static/{index-03b6134d.js → index-3660a664.js} +6 -6
- package/dist/preview-client/_static/index-44137d7e.js +1 -0
- package/dist/preview-client/_static/{index-5392907c.js → index-4e7bb453.js} +3 -3
- package/dist/preview-client/_static/index-5ae70b23.js +1 -0
- package/dist/preview-client/_static/{index-2274eaf1.js → index-75e7d483.js} +1 -1
- package/dist/preview-client/_static/{index-7e5ce9d9.js → index-8e169cc2.js} +1 -1
- package/dist/preview-client/_static/{index-2202e8e4.js → index-9feced3c.js} +1 -1
- package/dist/preview-client/_static/index-be42fc1e.js +1 -0
- package/dist/preview-client/_static/index-cfa0dccc.js +1 -0
- package/dist/preview-client/_static/{index-19f5510d.js → index-eb74362c.js} +1 -1
- package/dist/preview-client/_static/{index-8d2f0997.js → index-f165015e.js} +1 -1
- package/dist/preview-client/_static/index-f3d42be3.js +1 -0
- package/dist/preview-client/_static/{index-4ac10da2.js → index-f4d91eb4.js} +1 -1
- package/dist/preview-client/_static/{ktx2-encoder-4cac07f2.js → ktx2-encoder-e9b1c83a.js} +1 -1
- package/dist/preview-client/_static/{module-03df665c.js → module-1c91b4e1.js} +1 -1
- package/dist/preview-client/_static/{module-101126a2.js → module-4a37a616.js} +1 -1
- package/dist/preview-client/_static/{module-5fa1eae0.js → module-81a206c0.js} +1 -1
- package/dist/preview-client/_static/postmen-c7605b45.js +2 -0
- package/dist/preview-client/_static/{shader-data-utils-d59bc4f5.js → shader-data-utils-6ef12596.js} +1 -1
- package/dist/preview-client/index.html +1 -1
- package/package.json +1 -1
- package/dist/preview-client/_static/index-0a683358.js +0 -1
- package/dist/preview-client/_static/index-6f3c991c.js +0 -1
- package/dist/preview-client/_static/index-a2c9fc83.js +0 -1
- package/dist/preview-client/_static/index-c216bbcf.js +0 -1
- package/dist/preview-client/_static/index-f06b751f.js +0 -1
- package/dist/preview-client/_static/index-f4a0b8dd.js +0 -1
- package/dist/preview-client/_static/postmen-9e6354af.js +0 -2
package/dist/preview-client/_static/{MaterialInspector-21fc5b67.js → MaterialInspector-237b6a5e.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
var E=Object.defineProperty;var L=(d,e,t)=>e in d?E(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var j=(d,e,t)=>(L(d,typeof e!="symbol"?e+"":e,t),t);import{aH as x,aP as N,aJ as S,aM as $,av as s,aI as M,C as n,b7 as V,aw as F,bz as B,aO as f,aK as A,bA as z,e as O}from"./index-
|
|
1
|
+
var E=Object.defineProperty;var L=(d,e,t)=>e in d?E(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var j=(d,e,t)=>(L(d,typeof e!="symbol"?e+"":e,t),t);import{aH as x,aP as N,aJ as S,aM as $,av as s,aI as M,C as n,b7 as V,aw as F,bz as B,aO as f,aK as A,bA as z,e as O}from"./index-3660a664.js";import{u as T}from"./index-365736f7.js";import"./postmen-c7605b45.js";import{I as W}from"./IconPointFilled-dbf63b5c.js";const H=x(W,{marginRight:"-$1",variants:{checked:{true:{color:"$green10"}}}}),J=x(N,{width:"100%",border:"none",position:"relative",whiteSpace:"pre-wrap",boxShadow:"$2","& > svg":{marginRight:"$1"}});function b(d){return S(function(t){const{inspectorConfig:r,macroConfig:c,...p}=t,{model:i}=p;let{models:g}=p;const{checked:u,onSwitch:h}=c,{type:m,...a}=r,[o,l]=$.useState(u);$.useEffect(()=>{l(u)},[u]),g=g||[i];const R=()=>{const I=!o;if(h)for(const k of g)h(I,k);l(I)},v=r.label;return s.jsxs(M,{direction:"column",fullWidth:!0,children:[m!==n.Null&&o&&V.createElement(d,{...p,inspectorConfig:{...a,type:m}}),s.jsx(F,{label:o?"":v,children:s.jsx(J,{size:"sm",variant:"subtle",startSlot:s.jsx(H,{size:"12px",checked:o}),onClick:R,children:o?"Enabled ":"Disabled"})})]})})}const K=x(M),U=x(B,{backgroundColor:"$gray1",height:"2px !important"});function q(d){const{inspectorConfig:e,models:t,onModelChange:r,model:c,macroConfig:p}=d,{type:i,property:g,info:u}=e,{t:h}=A(),m=!c&&t&&t.length>1;if(m&&!t.find(y=>e.when?e.when(y):!0)||e.when&&!e.when(c))return null;const a=p?w.getRegisteredMacroComponent(i):w.getRegisteredComponent(i);if(!a)return console.warn(`缺少${i}类型的组件`),null;let o=e.disabled;!m&&c.getEditable&&(o=c.getEditable(e.property)===!1);const l=typeof e.label=="string"?h(e.label):e.label;let R=e.options;R&&(R=R.map(y=>({label:typeof y.label=="string"?h(y.label):y.label,value:y.value})));const v={...e,label:l,info:u,options:R,disabled:o},{triggerAfterInit:I,customComponent:k,...P}=v;return s.jsx(a,{inspectorConfig:P,macroConfig:p,models:t,model:c,onModelChange:r},g)}const C=class C{static registerComponent(e,t){this.components[e]=t}static getRegisteredComponent(e){return C.components[e]}static getRegisteredMacroComponent(e){return C.macroComponents[e]}};j(C,"components",f.getRegisteredComponents()),j(C,"macroComponents",{[n.Color]:b(f.getRegisteredComponent(n.Color)),[n.Vector4]:b(f.getRegisteredComponent(n.Vector4)),[n.Vector3]:b(f.getRegisteredComponent(n.Vector3)),[n.Vector2]:b(f.getRegisteredComponent(n.Vector2)),[n.Number]:b(f.getRegisteredComponent(n.Number)),[n.AssetPicker]:b(f.getRegisteredComponent(n.AssetPicker)),[n.Boolean]:b(f.getRegisteredComponent(n.Boolean)),[n.Null]:b(f.getRegisteredComponent(n.Null))}),j(C,"Item",S(q)),j(C,"List",S(function(t){const{configs:r,models:c,css:p,onModelChange:i,model:g,children:u,fullWidth:h=!1,withSeparator:m}=t;return r!=null&&r.length&&r.sort((a,o)=>{const l=a.priority??0;return(o.priority??0)-l}),r?s.jsxs(K,{css:p,className:"shader-inspector-form",fullWidth:h,children:[r.map(a=>s.jsxs($.Fragment,{children:[s.jsx(C.Item,{inspectorConfig:a,macroConfig:a.macroConfig,model:g,models:c,onModelChange:i},a.property),m&&s.jsx(U,{})]},a.property)),u]}):null}));let w=C;const G=x("div",{backgroundColor:"$appBg",width:"100%"}),Q=x("div",{backgroundColor:"$panelBg",borderRadius:"0 0 $2 $2",overflow:"hidden",paddingBottom:"$1"}),X=x("div",{width:"100%",backgroundColor:"$gray3",paddingBottom:"$0_5"}),Y=x(B,{backgroundColor:"$appBg",height:"2px !important"}),Z=d=>{var a;const{asset:e}=d,t=e.formConfig,{assetStore:r,inspectorFacade:c}=T(),{i18n:p}=A(),i=r.getAsset(e.shaderRef.refId),g=i==null?void 0:i.name,u=Object.values(r.assets).filter(o=>o.meta.type==="Shader"&&o.meta.utility!=="error"),h=()=>{r.selectAsset(e.shaderRef.refId)},m=(o,l)=>{c.assetChange(e.id,o,l)};if(t.root)for(const o of t.root){const l=o.comments;l&&(o.info=l[p.language]??l.default??void 0)}return s.jsxs(G,{children:[s.jsx(X,{children:s.jsx(z,{label:O("asset.shader.title"),assets:u,disabled:!!(i!=null&&i.isSubAsset)||e.isSubAsset||!e.getEditable(),value:g,dropLayer:0,onSelect:async o=>{await e.bindShaderAsset(o,e._getMainData()),await c.assetChanges(e.id,{shaderRef:e.shaderRef,shader:e.shader})},onLocate:h})}),((a=t.root)==null?void 0:a.length)>0&&s.jsx(Q,{children:s.jsx(w.List,{model:e,onModelChange:m,configs:t.root,withSeparator:!1})}),s.jsx(Y,{}),s.jsx(w.List,{model:e,onModelChange:m,configs:Object.values(t.groups)})]})},ne=S(Z);export{ne as M};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f0 as Or,av as i,aH as T,aM as a,
|
|
1
|
+
import{f0 as Or,av as i,aH as T,aM as a,gA as dt,ev as Nc,b7 as pe,gB as $c,gC as Oc,gD as Dc,gE as jc,gF as Lc,gG as kc,gH as Fc,gI as Uc,gJ as Gc,gK as Kc,d3 as k,d5 as me,ba as Ne,b8 as $e,bd as ee,gL as ln,gM as Dr,gN as Bc,gO as Wc,gP as Vc,gQ as Hc,b9 as U,d2 as jr,bc as F,bb as y,d4 as xt,d6 as Lr,d7 as Mt,gR as kr,gS as Fr,gT as Ur,gU as J,gV as Gr,gW as Kr,gX as Br,gY as Wr,gZ as Vr,g_ as Hr,b4 as dn,b5 as fn,d8 as wt,g$ as Oe,d9 as Yr,da as ge,h0 as pn,db as Xr,h1 as mn,dc as zr,dd as St,h2 as Yc,h3 as $t,h4 as Ot,h5 as Dt,h6 as Re,h7 as nr,h8 as jt,h9 as Lt,ha as kt,hb as Ft,hc as Ut,hd as rr,bi as Xc,he as zc}from"./index-3660a664.js";/**
|
|
2
2
|
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E=Object.defineProperty;var U=(n,e,t)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e,t)=>(U(n,typeof e!="symbol"?e+"":e,t),t);import{bN as v,bO as g,bw as T,a4 as i,bP as u,av as c,aN as b,y as f,bQ as p,j as x,n as C,e as V,q as N}from"./index-
|
|
1
|
+
var E=Object.defineProperty;var U=(n,e,t)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e,t)=>(U(n,typeof e!="symbol"?e+"":e,t),t);import{bN as v,bO as g,bw as T,a4 as i,bP as u,av as c,aN as b,y as f,bQ as p,j as x,n as C,e as V,q as N}from"./index-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.js";import{F as d}from"./index-75e7d483.js";import{M as m}from"./MeshThumbnail-d8ee2674.js";import{A as M}from"./AssetViewer-1073ddb5.js";import{e as A}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";class O{static createMesh(e,t){const s=new v(e);return O.setMeshData(s,t),s}static setMeshData(e,t){var s,r;return e.setPositions([...t.positions]),e.setNormals(t.normals),e.setUVs(t.uvs),t.uv1&&e.setUVs(t.uv1,1),t.uv2&&e.setUVs(t.uv2,2),t.uv3&&e.setUVs(t.uv3,3),t.uv4&&e.setUVs(t.uv4,4),t.uv5&&e.setUVs(t.uv5,5),t.uv6&&e.setUVs(t.uv6,6),t.uv7&&e.setUVs(t.uv7,7),t.bounds?(e.bounds.min.copyFrom(t.bounds.min),e.bounds.max.copyFrom(t.bounds.max)):O.calculateBounds(t.positions,e.bounds),(s=t.blendShapes)==null||s.forEach(o=>{const l=new g(o.name);o.frames.forEach(a=>{l.addFrame(a.weight,a.positions,a.normals,a.uvs)}),e.addBlendShape(l)}),(r=t.subMeshes)==null||r.forEach(o=>{e.addSubMesh(o)}),t.indices&&(t.positions.length<=65535?e.setIndices(new Uint16Array(t.indices)):e.setIndices(new Uint32Array(t.indices))),e.uploadData(!1),e}static calculateBounds(e,t){const{min:s,max:r}=t,o=e.length;s.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let l=0;l<o;l++){const a=e[l];s.x=Math.min(a.x,s.x),s.y=Math.min(a.y,s.y),s.z=Math.min(a.z,s.z),r.x=Math.max(a.x,r.x),r.y=Math.max(a.y,r.y),r.z=Math.max(a.z,r.z)}}}class R extends T{constructor(e,t){super(e),this.meshData=t}restoreContent(){O.setMeshData(this.resource,this.meshData)}}var y=(n=>(n.POSITION="Position",n.NORMAL="Normal",n.COLOR_0="Color",n.TANGENT="Tangent",n.WEIGHTS_0="BoneWeight",n.JOINTS_0="BoneIndex",n.TEXCOORD_0="UV",n.TEXCOORD_1="UV1",n.TEXCOORD_2="UV2",n.TEXCOORD_3="UV3",n.TEXCOORD_4="UV4",n.TEXCOORD_5="UV5",n.TEXCOORD_6="UV6",n.TEXCOORD_7="UV7",n))(y||{});const X=["POSITION","NORMAL","COLOR_0","TANGENT","WEIGHTS_0","JOINTS_0","TEXCOORD_0","TEXCOORD_1","TEXCOORD_2","TEXCOORD_3","TEXCOORD_4","TEXCOORD_5","TEXCOORD_6","TEXCOORD_7"],L={[i.Float]:"4 bytes",[i.Vector2]:"8 bytes",[i.Vector3]:"12 bytes",[i.Vector4]:"16 bytes",[i.Byte4]:"4 bytes",[i.UByte4]:"4 bytes",[i.NormalizedByte4]:"4 bytes",[i.NormalizedUByte4]:"4 bytes",[i.NormalizedShort2]:"4 bytes",[i.NormalizedShort4]:"8 bytes",[i.Short2]:"4 bytes",[i.UShort2]:"4 bytes",[i.NormalizedUShort2]:"4 bytes",[i.Short4]:"8 bytes",[i.UShort4]:"8 bytes",[i.NormalizedUShort4]:"8 bytes"};u.Triangles+"",u.TriangleStrip+"",u.TriangleFan+"",u.LineLoop+"",u.LineStrip+"",u.Lines+"",u.Points+"";function w(n){switch(n.topology){case u.Triangles:return`${n.count/3} triangles`;case u.TriangleFan:case u.TriangleStrip:return`${n.count-2} triangles`;case u.Lines:return`${n.count/2} lines`;case u.LineStrip:return`${n.count-1} lines`;case u.LineLoop:return`${n.count} lines`;case u.Points:return`${n.count} points`}}function I(n){if(n instanceof Uint8Array)return"Uint8";if(n instanceof Uint16Array)return"Uint16";if(n instanceof Uint32Array)return"Uint32"}const S=n=>{const e=n.asset.engineObject,t=e.vertexCount,s=e.getIndices(),r=e.subMeshes;return c.jsxs(c.Fragment,{children:[c.jsx(b,{title:`Vertices: ${t}`,defaultOpen:!0,children:X.map(o=>e.vertexElements.find(l=>l.semantic===o)).filter(o=>o!=null).map(o=>c.jsx(d,{label:y[o.attribute],value:`${i[o.format]} (${L[o.format]})`},o.attribute))}),s?c.jsx(b,{title:`Indices: ${s.length}`,defaultOpen:!0,children:c.jsx(d,{label:"Format",value:I(s)})}):null,c.jsx(b,{title:`SubMesh: ${r.length}`,defaultOpen:!0,children:r.map((o,l)=>c.jsx(d,{label:`# ${l}`,value:w(o)},l))})]})};class j extends M{setViewAsset(e,t){const s=t.createChild("mesh_entity"),r=s.addComponent(f);r.mesh=e.engineObject;const o=new p(e.engine);o.baseColor.set(.5,.5,.5,1),r.setMaterial(o),this._entity=s}}var B=Object.defineProperty,F=Object.getOwnPropertyDescriptor,z=(n,e,t,s)=>{for(var r=s>1?void 0:s?F(e,t):e,o=n.length-1,l;o>=0;o--)(l=n[o])&&(r=(s?l(e,t,r):l(r))||r);return s&&r&&B(e,t,r),r};let h=class extends x{constructor(e){super(e);_(this,"meshData",null)}beforeDelete(){return null}afterDelete(){return null}async initByMain(e){const{engine:t}=this,s=JSON.parse(await e.text());this.meshData=s;const r=new v(t);O.setMeshData(r,s),t.resourceManager.addContentRestorer(new R(r,s)),this.bindEngineObject(r),this._releaseMeshCache()}initByEngineObject(e){this.bindEngineObject(e),this._name=e.name,this.meshData={positions:[],subMeshes:[]}}_releaseMeshCache(){const e=this.engineObject;e._verticesUint8=null,e._indices=null,e._verticesFloat32=null,e._positions=null,e._tangents=null,e._normals=null,e._colors=null,e._uv=null,e._uv1=null,e._uv2=null,e._uv3=null,e._uv4=null,e._uv5=null,e._uv6=null,e._uv7=null}};h=z([C({type:"Mesh",label:V("asset.mesh.title"),icon:{},loaderType:"Mesh",extname:"mesh",customInspector:S,viewer:j,thumbnail:m,dragLayer:N.Mesh,async bundle({content:n}){const e=JSON.parse(await n.text()),t=A(e,{type:"Mesh",name:"mesh"});return{content:new Blob([t])}}})],h);export{h as MeshAsset};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var c=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>(c(r,typeof e!="symbol"?e+"":e,t),t);import{p as n,C as d,s as p,f as v,aE as P,E as b,v as y,x as u,aC as w}from"./index-
|
|
1
|
+
var f=Object.defineProperty;var c=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>(c(r,typeof e!="symbol"?e+"":e,t),t);import{p as n,C as d,s as p,f as v,aE as P,E as b,v as y,x as u,aC as w}from"./index-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.js";var M=Object.defineProperty,O=Object.getOwnPropertyDescriptor,i=(r,e,t,l)=>{for(var a=l>1?void 0:l?O(e,t):e,h=r.length-1,m;h>=0;h--)(m=r[h])&&(a=(l?m(e,t,a):m(a))||a);return l&&a&&M(e,t,a),a};class o extends b{constructor(){super(...arguments);s(this,"mesh",null);s(this,"material",{refId:"0000200"});s(this,"receiveShadows",!0);s(this,"castShadows",!0);s(this,"priority",0);s(this,"materialOpen",!1)}setMaterialOpen(t){this.materialOpen=t}}i([n({type:d.AssetPicker,assetType:["Mesh"],label:"mesh-renderer.mesh.title",info:"mesh-renderer.mesh.info",bindPath:"mesh"}),p()],o.prototype,"mesh",2);i([n({type:d.AssetPicker,assetType:"Material",label:"mesh-renderer.material.title",info:"mesh-renderer.material.info",customFilter:r=>{var e;return((e=r.engineObject.shader)==null?void 0:e.name)!=="Effect/Particle"}}),v({engineKey:"setMaterial",setPath:"setMaterial()",getPath:"getMaterial()",valueType:P.ReferResource,getEngineValue:r=>r.getMaterial()}),p()],o.prototype,"material",2);i([n({label:"mesh-renderer.receive-shadows.title",info:"mesh-renderer.receive-shadows.info",bindPath:"receiveShadows"}),y(),p()],o.prototype,"receiveShadows",2);i([n({label:"mesh-renderer.cast-shadows.title",info:"mesh-renderer.cast-shadows.info",bindPath:"castShadows"}),y(),p()],o.prototype,"castShadows",2);i([n({label:"mesh-renderer.priority.title",info:"mesh-renderer.priority.info",bindPath:"priority"}),p()],o.prototype,"priority",2);i([u],o.prototype,"materialOpen",2);i([w],o.prototype,"setMaterialOpen",1);export{o as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aJ as l,aM as c,av as m,aO as f,p as h}from"./index-
|
|
1
|
+
import{aJ as l,aM as c,av as m,aO as f,p as h}from"./index-3660a664.js";import{u as d}from"./index-365736f7.js";import{c as u}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.js";import{c as M}from"./createOnModelChange-c010a049.js";import{R}from"./ReferencedMaterial-f7ea80fb.js";import{M as v}from"./MeshRendererBaseComponent-8fd1f0df.js";import"./MaterialInspector-237b6a5e.js";import"./IconPointFilled-dbf63b5c.js";import"./createReactComponent-d9f8b1af.js";const x=l(function(o){const[r,s]=c.useState(null),e=o.data,{assetStore:t,inspectorFacade:n}=d();return c.useEffect(()=>{t.getAssetByRef(e.material).then(a=>{s(a)})},[e.material]),m.jsxs(m.Fragment,{children:[m.jsx(f.List,{model:e,configs:e.formSchema.items,onModelChange:M("component",e.id,n,e)}),r&&m.jsx(R,{materialAsset:r})]})});var C=Object.defineProperty,j=Object.getOwnPropertyDescriptor,i=(o,r,s,e)=>{for(var t=e>1?void 0:e?j(r,s):r,n=o.length-1,a;n>=0;n--)(a=o[n])&&(t=(e?a(r,s,t):a(t))||t);return e&&t&&C(r,s,t),t};let p=class extends v{constructor(o,r){super(o,r)}};i([h({assetType:["PrimitiveMesh","Mesh"]})],p.prototype,"mesh",2);p=i([u({type:"MeshRenderer",customInspector:x,componentsMenu:{label:"component.renderer.mesh.title"}})],p);export{p as MeshRendererComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=Object.defineProperty;var c=(i,e,t)=>e in i?r(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(c(i,typeof e!="symbol"?e+"":e,t),t);import{y as h,z as o,R as d}from"./index-
|
|
1
|
+
var r=Object.defineProperty;var c=(i,e,t)=>e in i?r(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(c(i,typeof e!="symbol"?e+"":e,t),t);import{y as h,z as o,R as d}from"./index-3660a664.js";class a{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.meshRenderer.mesh=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("mesh");t.transform.setRotation(16,-47.4,-16.7),this.meshRenderer=t.addComponent(h);const s=new o(e.engine);s.baseColor.set(.7,.7,.7,1),s.metallic=0,s.renderFace=d.Double,this.meshRenderer.setMaterial(s)}}n(a,"entity"),n(a,"meshRenderer");export{a as M};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ea=Object.defineProperty;var ta=(a,e,t)=>e in a?ea(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var S=(a,e,t)=>(ta(a,typeof e!="symbol"?e+"":e,t),t);import{bB as Ve,b8 as Ee,av as l,aw as ae,b7 as we,cb as ve,bT as lt,bU as je,cc as ie,ca as le,eW as me,aJ as X,aM as F,aO as aa,aK as K,bm as ze,cm as ee,bk as ct,fa as Ce,fb as de,bA as ra,bX as na,bI as _,fc as sa,bD as At,fd as oa,fe as ia,ff as la,fg as ca,fh as pa,fi as q,aH as ua,fj as ma,aI as Vt,aL as Ct,fk as da,fl as fa,fm as fe,dr as ha,c8 as Te,c9 as Le,c5 as ge,ce as Ot,b3 as Et,cf as wt,f7 as ya,E as ba,C as R,fn as W,fo as D,fp as be,bl as va,e as m,x as J,f as A,aE as ga,p as C,s as O}from"./index-
|
|
1
|
+
var ea=Object.defineProperty;var ta=(a,e,t)=>e in a?ea(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var S=(a,e,t)=>(ta(a,typeof e!="symbol"?e+"":e,t),t);import{bB as Ve,b8 as Ee,av as l,aw as ae,b7 as we,cb as ve,bT as lt,bU as je,cc as ie,ca as le,eW as me,aJ as X,aM as F,aO as aa,aK as K,bm as ze,cm as ee,bk as ct,fa as Ce,fb as de,bA as ra,bX as na,bI as _,fc as sa,bD as At,fd as oa,fe as ia,ff as la,fg as ca,fh as pa,fi as q,aH as ua,fj as ma,aI as Vt,aL as Ct,fk as da,fl as fa,fm as fe,dr as ha,c8 as Te,c9 as Le,c5 as ge,ce as Ot,b3 as Et,cf as wt,f7 as ya,E as ba,C as R,fn as W,fo as D,fp as be,bl as va,e as m,x as J,f as A,aE as ga,p as C,s as O}from"./index-3660a664.js";import{u as It}from"./index-365736f7.js";import{c as xa}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.js";import{c as Sa}from"./createOnModelChange-c010a049.js";import{R as Pa}from"./ReferencedMaterial-f7ea80fb.js";import"./TextureAsset-d88af413.js";import"./GlTFAsset-5c8e7813.js";import"./MaterialAsset-c83c7d3d.js";import{MeshAsset as Ma}from"./MeshAsset-1c11d7ab.js";import"./AnimatorControllerAsset-23cceb12.js";import"./AnimationClipAsset-f96e0e56.js";import{I as za}from"./ShaderChunkAsset-a42443fc.js";import"./AmbientLightAsset-02786385.js";import"./SpineSkeletonDataAsset-fff17383.js";import"./FontAsset-8367aad9.js";import"./SceneAsset-1e802e29.js";import"./ShaderAsset-256afb00.js";import"./PrimitiveMesh-388f3f36.js";import"./XRReferenceImageAsset-d6d8e59c.js";import"./PrefabAsset-a6750aec.js";import"./PhysicsMaterialAsset-7e86c718.js";import"./RenderTargetAsset-c48990a4.js";import"./AudioAsset-6218f2bb.js";import"./index-eb74362c.js";import"./MarkdownAsset-58491579.js";import{I as Ca}from"./IconPlus-5fbc029e.js";import{B as rt}from"./index-8e169cc2.js";import{c as Oa}from"./createReactComponent-d9f8b1af.js";import"./MaterialInspector-237b6a5e.js";import"./IconPointFilled-dbf63b5c.js";import"./ktx2-encoder-e9b1c83a.js";import"./TaskQueue-05c94a4d.js";import"./ktx-parse.modern-6c9f771f.js";import"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import"./Tooltip-3bc02b10.js";import"./AssetViewer-1073ddb5.js";import"./glTFIO-45ff9a17.js";import"./shader-data-utils-6ef12596.js";import"./index-75e7d483.js";import"./MeshThumbnail-d8ee2674.js";import"./bundlers-9b0d37fc.js";import"./module-4a37a616.js";import"./module-81a206c0.js";import"./ShaderUIScriptAsset-5acb02f5.js";import"./FormItemArray-53c58844.js";import"./Accordion-75b7b34e.js";import"./module-1c91b4e1.js";import"./Menu-a427d272.js";/**
|
|
2
2
|
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var M=(t,i,e)=>i in t?y(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e;var r=(t,i,e)=>(M(t,typeof i!="symbol"?i+"":i,e),e);import{j as h,P as a,k as d,p as l,C as b,m,n as v,e as C,o as F,q as P}from"./index-
|
|
1
|
+
var y=Object.defineProperty;var M=(t,i,e)=>i in t?y(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e;var r=(t,i,e)=>(M(t,typeof i!="symbol"?i+"":i,e),e);import{j as h,P as a,k as d,p as l,C as b,m,n as v,e as C,o as F,q as P}from"./index-3660a664.js";import"./index-365736f7.js";import"./postmen-c7605b45.js";var f=Object.defineProperty,g=Object.getOwnPropertyDescriptor,c=(t,i,e,n)=>{for(var o=n>1?void 0:n?g(i,e):i,p=t.length-1,u;p>=0;p--)(u=t[p])&&(o=(n?u(i,e,o):u(o))||o);return n&&o&&f(i,e,o),o};let s=class extends h{constructor(i){super(i);r(this,"dynamicFriction",.6);r(this,"staticFriction",.6);r(this,"bounciness",0);r(this,"frictionCombine",a.Average);r(this,"bounceCombine",a.Average)}async initByMain(i){const e=JSON.parse(await i.text()),n=new d;n.dynamicFriction=this.dynamicFriction=e.dynamicFriction,n.staticFriction=this.staticFriction=e.staticFriction,n.bounciness=this.bounciness=e.bounciness,n.frictionCombine=this.frictionCombine=e.frictionCombine,n.bounceCombine=this.bounceCombine=e.bounceCombine,this.bindEngineObject(n)}async initByCreation(){return this.getMainData()}destroy(){var i;super.destroy(),(i=this.engineObject)==null||i.destroy()}};c([l({type:b.Number,label:"DynamicFriction",bindPath:"dynamicFriction"}),m()],s.prototype,"dynamicFriction",2);c([l({type:b.Number,label:"StaticFriction",bindPath:"staticFriction"}),m()],s.prototype,"staticFriction",2);c([l({type:b.Number,min:0,max:1,label:"Bounciness",bindPath:"bounciness"}),m()],s.prototype,"bounciness",2);c([l({type:b.Select,label:"FrictionCombine",bindPath:"frictionCombine",options:[{label:"Average",value:a.Average},{label:"Minimum",value:a.Minimum},{label:"Multiply",value:a.Multiply},{label:"Maximum",value:a.Maximum}]}),m()],s.prototype,"frictionCombine",2);c([l({type:b.Select,label:"BounceCombine",bindPath:"bounceCombine",options:[{label:"Average",value:a.Average},{label:"Minimum",value:a.Minimum},{label:"Multiply",value:a.Multiply},{label:"Maximum",value:a.Maximum}]}),m()],s.prototype,"bounceCombine",2);s=c([v({type:"PhysicsMaterial",label:C("asset.physics-material.title"),extname:"physMat",importMenuConfig:{type:F.Add},dragLayer:P.PhysicsMaterial,async bundle({content:t}){return{content:t}}})],s);export{s as PhysicsMaterialAsset};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var pe=Object.defineProperty;var de=(o,e,t)=>e in o?pe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(de(o,typeof e!="symbol"?e+"":e,t),t);import{aJ as j,aK as z,av as l,bm as X,cm as P,bk as se,eD as I,dr as re,bA as ye,q as me,cB as K,eE as $,eF as G,eG as L,eH as J,bI as N,f as he,aE as ue,s as y,p as m,e as r,E as ae,eI as W,eJ as S,eK as B,C as h,eL as Y,eM as fe,eN as Z,e1 as le,eO as be,eP as ge,bq as Ce,cz as Q,bs as xe,bt as Se}from"./index-03b6134d.js";import{r as H}from"./index-0a53aaef.js";import{c as F}from"./Component-3cb422ab.js";import"./postmen-9e6354af.js";import{F as Pe}from"./FormItemArray-f1283fce.js";const je={BoxColliderShape:["size","isTrigger","position","rotation","material"],CapsuleColliderShape:["radius","height","upAxis","isTrigger","position","rotation","material"],PlaneColliderShape:["isTrigger","position","rotation","material"],SphereColliderShape:["radius","isTrigger","position","rotation","material"]};function ve(o){const e={};return Object.keys(o.props).forEach(t=>{je[o.class].includes(t)&&(e[t]=o.props[t])}),e}const ze=async(o,e,t)=>{const i=o.engineObject,n=i.shapes;if(n.length===t.length&&t.every((s,a)=>Oe(s.class,n[a]))){for(let s=0;s<t.length;s++)await k(n[s],t[s]),ee(n[s],t[s]);return}i.clearShapes();for(let s=0;s<t.length;s++){const a=t[s],d=_e(a);await k(d,a),ee(d,a),i.addShape(d)}};async function k(o,e){const t=e.props.material;if(t!=null&&t.refId)try{const i=await H.assetStore.getAssetByRef(t);i!=null&&i.engineObject&&(o.material=i.engineObject)}catch(i){console.error(i)}}function Oe(o,e){switch(o){case"BoxColliderShape":return e instanceof J;case"CapsuleColliderShape":return e instanceof L;case"PlaneColliderShape":return e instanceof G;case"SphereColliderShape":return e instanceof $;default:return!1}}function _e(o){switch(o.class){case"BoxColliderShape":return new J;case"CapsuleColliderShape":return new L;case"PlaneColliderShape":return new G;case"SphereColliderShape":return new $}}function ee(o,e){const t=e.props;if(o instanceof J&&t.size){const s=o.size;s.copyFrom(t.size),o.size=s}else o instanceof L?(t.radius!==void 0&&(o.radius=t.radius),t.height!==void 0&&(o.height=t.height),t.upAxis!==void 0&&(o.upAxis=t.upAxis)):o instanceof $&&t.radius!==void 0&&(o.radius=t.radius);o.isTrigger=t.isTrigger;const i=o.position;i.copyFrom(t.position),o.position=i;const n=o.rotation;n.copyFrom(t.rotation),o.rotation=n}const De=o=>o.map(e=>{if(e instanceof J)return{class:"BoxColliderShape",props:{isTrigger:e.isTrigger,size:{x:e.size.x,y:e.size.y,z:e.size.z},position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof L)return{class:"CapsuleColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,height:e.height,upAxis:e.upAxis,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof G)return{class:"PlaneColliderShape",props:{isTrigger:e.isTrigger,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof $)return{class:"SphereColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}}}),Te=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(X,{label:t("physics.shape.box.size.title"),info:t("physics.shape.box.size.info"),min:0,value:{x:o.props.size.x,y:o.props.size.y,z:o.props.size.z},onChange:(i,n)=>{const s=i==null?void 0:i[n];typeof s=="number"&&e(a=>{a.props.size={...a.props.size,[n]:s}})}})})}),we=j(()=>l.jsx(l.Fragment,{})),Ae=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(P,{label:t("physics.shape.sphere.radius.title"),info:t("physics.shape.sphere.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}})})}),Me=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsxs(l.Fragment,{children:[l.jsx(P,{label:t("physics.shape.capsule.radius.title"),info:t("physics.shape.capsule.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}}),l.jsx(P,{label:t("physics.shape.capsule.height.title"),info:t("physics.shape.capsule.height.info"),value:o.props.height,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.height=i})}}),l.jsx(se,{label:t("physics.shape.capsule.up-axis.title"),info:t("physics.shape.capsule.up-axis.info"),options:[{label:"X",value:I.X},{label:"Y",value:I.Y},{label:"Z",value:I.Z}],value:o.props.upAxis,onChange:i=>{e(n=>{n.props.upAxis=i})}})]})}),Fe={BoxColliderShape:Te,CapsuleColliderShape:Me,PlaneColliderShape:we,SphereColliderShape:Ae},q={BoxColliderShape:{class:"BoxColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},size:{x:1,y:1,z:1},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},CapsuleColliderShape:{class:"CapsuleColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,height:2,upAxis:I.Y,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},PlaneColliderShape:{class:"PlaneColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},SphereColliderShape:{class:"SphereColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}}},Ve=j(({item:o,onItemChange:e})=>{var d;const{t}=z(),i=Fe[o.class],n=H.assetStore,s=Object.values(n.assets).filter(c=>c.getMetaConfig().type==="PhysicsMaterial"),a=n.assets[(d=o.props.material)==null?void 0:d.refId];return l.jsxs(l.Fragment,{children:[l.jsx(re,{label:t("physics.collider.trigger.title"),info:t("physics.collider.trigger.info"),value:o.props.isTrigger,onChange:c=>{e(f=>{f.props.isTrigger=c})}}),l.jsx(ye,{label:t("physics.collider.material.title"),info:t("physics.collider.material.info"),dropLayer:me.PhysicsMaterial,value:a==null?void 0:a.name,assets:s,onSelect:c=>{e(f=>{f.props.material=c.getCurrentRef()})},onLocate:()=>{a&&a.id&&n.selectAsset(a.id)}}),l.jsx(i,{item:o,onItemChange:e}),l.jsx(X,{label:t("physics.collider.local-position.title"),info:t("physics.collider.local-position.info"),value:{x:o.props.position.x,y:o.props.position.y,z:o.props.position.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.position={...b.props.position,[f]:u}})}}),l.jsx(X,{label:t("physics.collider.rotation.title"),info:t("physics.collider.rotation.info"),value:{x:o.props.rotation.x,y:o.props.rotation.y,z:o.props.rotation.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.rotation={...b.props.rotation,[f]:u}})}})]})}),Be=j(({collider:o,item:e,index:t,onModelChange:i})=>{const{t:n}=z(),s=[{label:n("physics.shape.box.title"),value:"BoxColliderShape"},{label:n("physics.shape.capsule.title"),value:"CapsuleColliderShape"}];o.engineObject instanceof K||(s.push({label:n("physics.shape.plane.title"),value:"PlaneColliderShape"}),s.push({label:n("physics.shape.sphere.title"),value:"SphereColliderShape"}));const d=c=>{const f=o.colliderShapes,u=N(f),b=u[t];b&&(c(b),i==null||i("colliderShapes",u))};return l.jsxs(l.Fragment,{children:[l.jsx(se,{label:n("physics.shape.type.title"),info:n("physics.shape.type.info"),value:e.class,options:s,onChange:c=>{q[c].class!==e.class&&d(u=>{Object.assign(u,N(q[c]))})}}),l.jsx(Ve,{item:e,onItemChange:d})]})}),Ee=j(({model:o,inspectorConfig:e,onModelChange:t})=>{const{label:i}=e,n=o.colliderShapes,{t:s}=z(),a=d=>{const c=N(n);d(c),t==null||t("colliderShapes",c)};return l.jsx(Pe,{label:i,items:n.map((d,c)=>({removable:!0,children:l.jsx(Be,{collider:o,item:d,index:c,onModelChange:t}),id:`${c}`,name:s("physics.shape.item-name",{index:c})})),addable:!0,onAdd:()=>{a(d=>{d.push(N(q.BoxColliderShape))})},onDelete:d=>{a(c=>{c.splice(+d.id,1)})},addItemText:s("physics.shape.add")})});var Ie=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ne(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ie(e,t,n),n};class R extends ae{constructor(){super(...arguments);p(this,"colliderShapes",[])}}$e([he({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:ue.Object,getEngineValue:o=>o.shapes,getEditorValue:De}),y({type:"methods",key:"colliderShapes",canonicalizeToProps:!0,onSerialize:o=>o.map(e=>({$type:e.class,...ve(e)})),onDeserialize:o=>o.map(e=>{const{$type:t,...i}=e;return{class:t,props:i}})}),m({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Ee,onChange:ze})],R.prototype,"colliderShapes",2);var Le=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Re=(o,e,t,i)=>{for(var n=i>1?void 0:i?Je(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Le(e,t,n),n};let te=class extends R{constructor(o,e){super(o,e)}};te=Re([F({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],te);const ie=o=>Object.keys(S).filter(e=>(o&S[e])!==0).map(e=>String(S[e])),Xe=j(({model:o,onModelChange:e})=>{const t=n=>{const a=n.map(d=>parseInt(d)).reduce((d,c)=>d|c,S.None);e==null||e("constraints",a)},{t:i}=z();return l.jsxs(l.Fragment,{children:[l.jsx(W,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:t}),l.jsx(W,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:t})]})});var Ke=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,C=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ye(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ke(e,t,n),n};let g=class extends R{constructor(e,t){super(e,t);p(this,"isKinematic",!1);p(this,"collisionDetectionMode",B.Discrete);p(this,"constraints",S.None);p(this,"mass",1);p(this,"useGravity",!0);p(this,"linearDamping",0);p(this,"angularDamping",.05);p(this,"automaticCenterOfMass",!0);p(this,"centerOfMass",{x:0,y:0,z:0});p(this,"automaticInertiaTensor",!0);p(this,"inertiaTensor",{x:1,y:1,z:1});p(this,"linearVelocity",{x:0,y:0,z:0});p(this,"angularVelocity",{x:0,y:0,z:0});p(this,"maxAngularVelocity",100);p(this,"maxDepenetrationVelocity",10000000331813535e16);p(this,"sleepThreshold",.005);p(this,"solverIterations",4)}onEnabled(){this._applyEditorRuntimeState()}onInitComplete(){this._applyEditorRuntimeState()}rebindEngineObject(e){super.rebindEngineObject(e),this._applyEditorRuntimeState()}_applyEditorRuntimeState(){this.applyBoundPathChange("enabled",h.Toggle,!1)}};C([y(),m({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:h.Boolean,bindPath:"isKinematic"})],g.prototype,"isKinematic",2);C([y(),m({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:h.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:B.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:B.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:B.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:B.ContinuousSpeculative}]})],g.prototype,"collisionDetectionMode",2);C([y(),m({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:Xe,bindPath:"constraints"})],g.prototype,"constraints",2);C([y(),m({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:h.Number})],g.prototype,"mass",2);C([y(),m({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:h.Boolean})],g.prototype,"useGravity",2);C([y(),m({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:h.Number})],g.prototype,"linearDamping",2);C([y(),m({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:h.Number})],g.prototype,"angularDamping",2);C([y(),m({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.centerOfMass;o.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticCenterOfMass",2);C([y(),m({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:h.Vector3,bindPath:"centerOfMass",when:o=>!o.automaticCenterOfMass})],g.prototype,"centerOfMass",2);C([y(),m({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.inertiaTensor;o.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticInertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:h.Vector3,bindPath:"inertiaTensor",when:o=>!o.automaticInertiaTensor})],g.prototype,"inertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:h.Vector3,bindPath:"linearVelocity"})],g.prototype,"linearVelocity",2);C([y(),m({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:h.Vector3,bindPath:"angularVelocity"})],g.prototype,"angularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:h.Number})],g.prototype,"maxAngularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:h.Number})],g.prototype,"maxDepenetrationVelocity",2);C([y(),m({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:h.Number})],g.prototype,"sleepThreshold",2);C([y(),m({label:r("physics.dynamic-collider.solver-iterations.title"),info:r("physics.dynamic-collider.solver-iterations.info"),bindPath:"solverIterations",min:0,max:10,dragStep:1,type:h.Slider})],g.prototype,"solverIterations",2);g=C([F({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],g);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,E=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ge(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&qe(e,t,n),n};let M=class extends R{constructor(e,t){super(e,t);p(this,"stepOffset",.5);p(this,"upDirection",{x:0,y:1,z:0});p(this,"slopeLimit",45);p(this,"nonWalkableMode",Y.PreventClimbing)}async bindEngineObject(e){await super.bindEngineObject(e),e.enabled=!1}rebindEngineObject(e){super.rebindEngineObject(e),e.enabled=!1}};E([y(),m({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:h.Number})],M.prototype,"stepOffset",2);E([y(),m({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:h.Vector3,bindPath:"upDirection"})],M.prototype,"upDirection",2);E([y(),m({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:h.Number})],M.prototype,"slopeLimit",2);E([y(),m({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:h.Select,options:[{label:r("physics.character.non-walkable-mode.prevent-climbing"),value:Y.PreventClimbing},{label:r("physics.character.non-walkable-mode.prevent-climbing-and-force-sliding"),value:Y.PreventClimbingAndForceSliding}]})],M.prototype,"nonWalkableMode",2);M=E([F({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],M);const Ze=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,disabled:a,info:d}=e,{ownerId:c}=t[n]||{},f=c&&o.model.root.sceneStore.getEntityModel(c),u=O=>{const _=O?H.sceneStore.getEntityModel(O):null,U=(_==null?void 0:_.getComponentByTypeName("DynamicCollider"))||(_==null?void 0:_.getComponentByTypeName("StaticCollider")),ce=U?{ownerId:O,componentId:U.id}:null;i==null||i(n,ce)},{t:b}=z(),x=Array.from(t.root.sceneStore.iterateEntityModels(),([,O])=>O);return l.jsx(l.Fragment,{children:l.jsx(fe,{label:b(s),info:b(d),entities:x,value:c,disabled:a,customFilter:O=>{let _=null;return t.entityModelId!==O.id&&(_=O.getComponentByTypeName("DynamicCollider")||O.getComponentByTypeName("StaticCollider")),_},displayValue:f==null?void 0:f.name,placeholder:b("physics.collider-picker.placeholder"),onSelect:u,onLocate:()=>{o.model.root.sceneStore.selectEntity(c)},onDelete:()=>{u(null)}})})});var He=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,T=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ue(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&He(e,t,n),n};class v extends ae{constructor(){super(...arguments);p(this,"connectedCollider",null);p(this,"anchor",{x:0,y:0,z:0});p(this,"automaticConnectedAnchor",!0);p(this,"connectedAnchor",{x:0,y:0,z:0});p(this,"breakForce",Number.MAX_VALUE);p(this,"breakTorque",Number.MAX_VALUE);p(this,"massScale",1);p(this,"connectedMassScale",1)}async applyBoundPathChange(t,i,n){var s,a;if(t==="connectedCollider"){const d=n,c=((a=(s=this.root.sceneStore.getEntityModel(d==null?void 0:d.ownerId))==null?void 0:s.getComponentById(d==null?void 0:d.componentId))==null?void 0:a.engineObject)??null;await super.applyBoundPathChange(t,i,c);return}await super.applyBoundPathChange(t,i,n)}}T([y(),m({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:Ze,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);T([y(),m({label:r("physics.joint.anchor.title"),type:h.Vector3,bindPath:"anchor",onChange(o,e,t){if(o.automaticConnectedAnchor){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);T([y(),m({label:r("physics.joint.automatic-connected-anchor.title"),type:h.Boolean,bindPath:"automaticConnectedAnchor",onChange(o,e,t){if(t){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);T([y(),m({label:r("physics.joint.connected-anchor.title"),type:h.Vector3,bindPath:"connectedAnchor",when:o=>!o.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);T([y(),m({label:r("physics.joint.break-force.title"),type:h.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);T([y(),m({label:r("physics.joint.break-torque.title"),type:h.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);T([y(),m({label:r("physics.joint.mass-scale.title"),type:h.Number,bindPath:"massScale"})],v.prototype,"massScale",2);T([y(),m({label:r("physics.joint.connected-mass-scale.title"),type:h.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var We=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,ke=(o,e,t,i)=>{for(var n=i>1?void 0:i?Qe(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&We(e,t,n),n};let oe=class extends v{constructor(o,e){super(o,e)}};oe=ke([F({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],oe);const et=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useLimits,c=t.useSpring,f=t[n],u=f.props,{t:b}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:b(s),info:b(a),children:[l.jsx(P,{label:b("physics.joint-limits.min"),value:u.min,onChange:x=>{u.max<x&&(u.max=x),u.min=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.max"),value:u.max,onChange:x=>{x<u.min&&(x=u.min),u.max=x,i(n,f)}}),c?l.jsxs(l.Fragment,{children:[l.jsx(P,{label:b("physics.joint-limits.stiffness"),value:u.stiffness,onChange:x=>{u.stiffness=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.damping"),value:u.damping,onChange:x=>{u.damping=x,i(n,f)}})]}):l.jsx(P,{label:b("physics.joint-limits.contact-distance"),value:u.contactDistance,onChange:x=>{u.contactDistance=x,i(n,f)}})]}):null})}),tt=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useMotor,c=t[n],f=c.props,{t:u}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:u(s),info:u(a),children:[l.jsx(P,{label:u("physics.joint-motor.target-velocity"),value:f.targetVelocity,onChange:b=>{f.targetVelocity=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.force-limit"),value:f.forceLimit,onChange:b=>{f.forceLimit=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.gear-ratio"),value:f.gearRatio,onChange:b=>{f.gearRatio=b,i(n,c)}}),l.jsx(re,{label:u("physics.joint-motor.free-spin"),value:f.freeSpin,onChange:b=>{f.freeSpin=b,i(n,c)}})]}):null})});var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,A=(o,e,t,i)=>{for(var n=i>1?void 0:i?ot(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&it(e,t,n),n};let D=class extends v{constructor(e,t){super(e,t);p(this,"axis",{x:1,y:0,z:0});p(this,"useLimits",!1);p(this,"useSpring",!1);p(this,"limits",{class:"JointLimits",props:{max:0,min:0,contactDistance:-1,stiffness:0,damping:0}});p(this,"useMotor",!1);p(this,"motor",{class:"JointMotor",props:{targetVelocity:0,forceLimit:Number.MAX_VALUE,gearRatio:1,freeSpin:!1}})}async applyBoundPathChange(e,t,i){if(e==="limits"){const n=this._buildLimitsFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}if(e==="motor"){const n=this._buildMotorFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}await super.applyBoundPathChange(e,t,i)}_buildLimitsFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new be;return i.max=t.max,i.min=t.min,i.contactDistance=t.contactDistance,i.stiffness=t.stiffness,i.damping=t.damping,i}_buildMotorFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new ge;return i.targetVelocity=t.targetVelocity,i.forceLimit=t.forceLimit,i.gearRatio=t.gearRatio,i.freeSpin=t.freeSpin,i}};A([y(),m({label:r("physics.hinge-joint.axis.title"),type:h.Vector3,bindPath:"axis"})],D.prototype,"axis",2);A([y(),m({label:r("physics.hinge-joint.use-limits.title"),type:h.Boolean,bindPath:"useLimits"})],D.prototype,"useLimits",2);A([y(),m({label:r("physics.hinge-joint.use-spring.title"),type:h.Boolean,bindPath:"useSpring"})],D.prototype,"useSpring",2);A([y(),m({label:r("physics.hinge-joint.limits.title"),customComponent:et,bindPath:"limits"})],D.prototype,"limits",2);A([y(),m({label:r("physics.hinge-joint.use-motor.title"),type:h.Boolean,bindPath:"useMotor"})],D.prototype,"useMotor",2);A([y(),m({label:r("physics.hinge-joint.motor.title"),customComponent:tt,bindPath:"motor"})],D.prototype,"motor",2);D=A([F({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],D);var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,V=(o,e,t,i)=>{for(var n=i>1?void 0:i?st(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&nt(e,t,n),n};let w=class extends v{constructor(e,t){super(e,t);p(this,"spring",10);p(this,"damper",.2);p(this,"minDistance",0);p(this,"maxDistance",0);p(this,"tolerance",.025)}};V([y(),m({label:r("physics.spring-joint.spring.title"),type:h.Number,bindPath:"spring"})],w.prototype,"spring",2);V([y(),m({label:r("physics.spring-joint.damper.title"),type:h.Number,bindPath:"damper"})],w.prototype,"damper",2);V([y(),m({label:r("physics.spring-joint.min-distance.title"),type:h.Number,bindPath:"minDistance"})],w.prototype,"minDistance",2);V([y(),m({label:r("physics.spring-joint.max-distance.title"),type:h.Number,bindPath:"maxDistance"})],w.prototype,"maxDistance",2);V([y(),m({label:r("physics.spring-joint.tolerance.title"),type:h.Number,bindPath:"tolerance"})],w.prototype,"tolerance",2);w=V([F({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],w);class rt extends Ce{constructor(){super(...arguments);p(this,"_isPlaying",!1)}onPlay(t){this._isPlaying=t,this._toggleAll(t)}onAddComponent(t){!this._isPlaying&&(t instanceof Q||t instanceof K)&&(t.enabled=!1)}_toggleAll(t){var a;const i=(a=this.engine.sceneManager.activeScene)==null?void 0:a.rootEntities;if(!i)return;const n=[],s=[];i.forEach(d=>{d.getComponentsIncludeChildren(Q,n),d.getComponentsIncludeChildren(K,s)}),n.forEach(d=>{d.enabled=t}),s.forEach(d=>{d.enabled=t})}}var at=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,ct=(o,e,t,i)=>{for(var n=i>1?void 0:i?lt(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&at(e,t,n),n};let ne=class{constructor(){p(this,"script")}init(){this.script=xe.addScript(rt)}};ne=ct([Se({type:"physicsStore"})],ne);export{M as C,g as D,oe as F,D as H,ne as P,te as S,w as a};
|
|
1
|
+
var pe=Object.defineProperty;var de=(o,e,t)=>e in o?pe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(de(o,typeof e!="symbol"?e+"":e,t),t);import{aJ as j,aK as z,av as l,bm as X,cm as P,bk as se,eD as I,dr as re,bA as ye,q as me,cB as K,eE as $,eF as G,eG as L,eH as J,bI as N,f as he,aE as ue,s as y,p as m,e as r,E as ae,eI as W,eJ as S,eK as B,C as h,eL as Y,eM as fe,eN as Z,e1 as le,eO as be,eP as ge,bq as Ce,cz as Q,bs as xe,bt as Se}from"./index-3660a664.js";import{r as H}from"./index-365736f7.js";import{c as F}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.js";import{F as Pe}from"./FormItemArray-53c58844.js";const je={BoxColliderShape:["size","isTrigger","position","rotation","material"],CapsuleColliderShape:["radius","height","upAxis","isTrigger","position","rotation","material"],PlaneColliderShape:["isTrigger","position","rotation","material"],SphereColliderShape:["radius","isTrigger","position","rotation","material"]};function ve(o){const e={};return Object.keys(o.props).forEach(t=>{je[o.class].includes(t)&&(e[t]=o.props[t])}),e}const ze=async(o,e,t)=>{const i=o.engineObject,n=i.shapes;if(n.length===t.length&&t.every((s,a)=>Oe(s.class,n[a]))){for(let s=0;s<t.length;s++)await k(n[s],t[s]),ee(n[s],t[s]);return}i.clearShapes();for(let s=0;s<t.length;s++){const a=t[s],d=_e(a);await k(d,a),ee(d,a),i.addShape(d)}};async function k(o,e){const t=e.props.material;if(t!=null&&t.refId)try{const i=await H.assetStore.getAssetByRef(t);i!=null&&i.engineObject&&(o.material=i.engineObject)}catch(i){console.error(i)}}function Oe(o,e){switch(o){case"BoxColliderShape":return e instanceof J;case"CapsuleColliderShape":return e instanceof L;case"PlaneColliderShape":return e instanceof G;case"SphereColliderShape":return e instanceof $;default:return!1}}function _e(o){switch(o.class){case"BoxColliderShape":return new J;case"CapsuleColliderShape":return new L;case"PlaneColliderShape":return new G;case"SphereColliderShape":return new $}}function ee(o,e){const t=e.props;if(o instanceof J&&t.size){const s=o.size;s.copyFrom(t.size),o.size=s}else o instanceof L?(t.radius!==void 0&&(o.radius=t.radius),t.height!==void 0&&(o.height=t.height),t.upAxis!==void 0&&(o.upAxis=t.upAxis)):o instanceof $&&t.radius!==void 0&&(o.radius=t.radius);o.isTrigger=t.isTrigger;const i=o.position;i.copyFrom(t.position),o.position=i;const n=o.rotation;n.copyFrom(t.rotation),o.rotation=n}const De=o=>o.map(e=>{if(e instanceof J)return{class:"BoxColliderShape",props:{isTrigger:e.isTrigger,size:{x:e.size.x,y:e.size.y,z:e.size.z},position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof L)return{class:"CapsuleColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,height:e.height,upAxis:e.upAxis,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof G)return{class:"PlaneColliderShape",props:{isTrigger:e.isTrigger,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof $)return{class:"SphereColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}}}),Te=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(X,{label:t("physics.shape.box.size.title"),info:t("physics.shape.box.size.info"),min:0,value:{x:o.props.size.x,y:o.props.size.y,z:o.props.size.z},onChange:(i,n)=>{const s=i==null?void 0:i[n];typeof s=="number"&&e(a=>{a.props.size={...a.props.size,[n]:s}})}})})}),we=j(()=>l.jsx(l.Fragment,{})),Ae=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(P,{label:t("physics.shape.sphere.radius.title"),info:t("physics.shape.sphere.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}})})}),Me=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsxs(l.Fragment,{children:[l.jsx(P,{label:t("physics.shape.capsule.radius.title"),info:t("physics.shape.capsule.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}}),l.jsx(P,{label:t("physics.shape.capsule.height.title"),info:t("physics.shape.capsule.height.info"),value:o.props.height,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.height=i})}}),l.jsx(se,{label:t("physics.shape.capsule.up-axis.title"),info:t("physics.shape.capsule.up-axis.info"),options:[{label:"X",value:I.X},{label:"Y",value:I.Y},{label:"Z",value:I.Z}],value:o.props.upAxis,onChange:i=>{e(n=>{n.props.upAxis=i})}})]})}),Fe={BoxColliderShape:Te,CapsuleColliderShape:Me,PlaneColliderShape:we,SphereColliderShape:Ae},q={BoxColliderShape:{class:"BoxColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},size:{x:1,y:1,z:1},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},CapsuleColliderShape:{class:"CapsuleColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,height:2,upAxis:I.Y,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},PlaneColliderShape:{class:"PlaneColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},SphereColliderShape:{class:"SphereColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}}},Ve=j(({item:o,onItemChange:e})=>{var d;const{t}=z(),i=Fe[o.class],n=H.assetStore,s=Object.values(n.assets).filter(c=>c.getMetaConfig().type==="PhysicsMaterial"),a=n.assets[(d=o.props.material)==null?void 0:d.refId];return l.jsxs(l.Fragment,{children:[l.jsx(re,{label:t("physics.collider.trigger.title"),info:t("physics.collider.trigger.info"),value:o.props.isTrigger,onChange:c=>{e(f=>{f.props.isTrigger=c})}}),l.jsx(ye,{label:t("physics.collider.material.title"),info:t("physics.collider.material.info"),dropLayer:me.PhysicsMaterial,value:a==null?void 0:a.name,assets:s,onSelect:c=>{e(f=>{f.props.material=c.getCurrentRef()})},onLocate:()=>{a&&a.id&&n.selectAsset(a.id)}}),l.jsx(i,{item:o,onItemChange:e}),l.jsx(X,{label:t("physics.collider.local-position.title"),info:t("physics.collider.local-position.info"),value:{x:o.props.position.x,y:o.props.position.y,z:o.props.position.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.position={...b.props.position,[f]:u}})}}),l.jsx(X,{label:t("physics.collider.rotation.title"),info:t("physics.collider.rotation.info"),value:{x:o.props.rotation.x,y:o.props.rotation.y,z:o.props.rotation.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.rotation={...b.props.rotation,[f]:u}})}})]})}),Be=j(({collider:o,item:e,index:t,onModelChange:i})=>{const{t:n}=z(),s=[{label:n("physics.shape.box.title"),value:"BoxColliderShape"},{label:n("physics.shape.capsule.title"),value:"CapsuleColliderShape"}];o.engineObject instanceof K||(s.push({label:n("physics.shape.plane.title"),value:"PlaneColliderShape"}),s.push({label:n("physics.shape.sphere.title"),value:"SphereColliderShape"}));const d=c=>{const f=o.colliderShapes,u=N(f),b=u[t];b&&(c(b),i==null||i("colliderShapes",u))};return l.jsxs(l.Fragment,{children:[l.jsx(se,{label:n("physics.shape.type.title"),info:n("physics.shape.type.info"),value:e.class,options:s,onChange:c=>{q[c].class!==e.class&&d(u=>{Object.assign(u,N(q[c]))})}}),l.jsx(Ve,{item:e,onItemChange:d})]})}),Ee=j(({model:o,inspectorConfig:e,onModelChange:t})=>{const{label:i}=e,n=o.colliderShapes,{t:s}=z(),a=d=>{const c=N(n);d(c),t==null||t("colliderShapes",c)};return l.jsx(Pe,{label:i,items:n.map((d,c)=>({removable:!0,children:l.jsx(Be,{collider:o,item:d,index:c,onModelChange:t}),id:`${c}`,name:s("physics.shape.item-name",{index:c})})),addable:!0,onAdd:()=>{a(d=>{d.push(N(q.BoxColliderShape))})},onDelete:d=>{a(c=>{c.splice(+d.id,1)})},addItemText:s("physics.shape.add")})});var Ie=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ne(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ie(e,t,n),n};class R extends ae{constructor(){super(...arguments);p(this,"colliderShapes",[])}}$e([he({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:ue.Object,getEngineValue:o=>o.shapes,getEditorValue:De}),y({type:"methods",key:"colliderShapes",canonicalizeToProps:!0,onSerialize:o=>o.map(e=>({$type:e.class,...ve(e)})),onDeserialize:o=>o.map(e=>{const{$type:t,...i}=e;return{class:t,props:i}})}),m({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Ee,onChange:ze})],R.prototype,"colliderShapes",2);var Le=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Re=(o,e,t,i)=>{for(var n=i>1?void 0:i?Je(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Le(e,t,n),n};let te=class extends R{constructor(o,e){super(o,e)}};te=Re([F({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],te);const ie=o=>Object.keys(S).filter(e=>(o&S[e])!==0).map(e=>String(S[e])),Xe=j(({model:o,onModelChange:e})=>{const t=n=>{const a=n.map(d=>parseInt(d)).reduce((d,c)=>d|c,S.None);e==null||e("constraints",a)},{t:i}=z();return l.jsxs(l.Fragment,{children:[l.jsx(W,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:t}),l.jsx(W,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:t})]})});var Ke=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,C=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ye(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ke(e,t,n),n};let g=class extends R{constructor(e,t){super(e,t);p(this,"isKinematic",!1);p(this,"collisionDetectionMode",B.Discrete);p(this,"constraints",S.None);p(this,"mass",1);p(this,"useGravity",!0);p(this,"linearDamping",0);p(this,"angularDamping",.05);p(this,"automaticCenterOfMass",!0);p(this,"centerOfMass",{x:0,y:0,z:0});p(this,"automaticInertiaTensor",!0);p(this,"inertiaTensor",{x:1,y:1,z:1});p(this,"linearVelocity",{x:0,y:0,z:0});p(this,"angularVelocity",{x:0,y:0,z:0});p(this,"maxAngularVelocity",100);p(this,"maxDepenetrationVelocity",10000000331813535e16);p(this,"sleepThreshold",.005);p(this,"solverIterations",4)}onEnabled(){this._applyEditorRuntimeState()}onInitComplete(){this._applyEditorRuntimeState()}rebindEngineObject(e){super.rebindEngineObject(e),this._applyEditorRuntimeState()}_applyEditorRuntimeState(){this.applyBoundPathChange("enabled",h.Toggle,!1)}};C([y(),m({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:h.Boolean,bindPath:"isKinematic"})],g.prototype,"isKinematic",2);C([y(),m({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:h.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:B.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:B.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:B.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:B.ContinuousSpeculative}]})],g.prototype,"collisionDetectionMode",2);C([y(),m({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:Xe,bindPath:"constraints"})],g.prototype,"constraints",2);C([y(),m({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:h.Number})],g.prototype,"mass",2);C([y(),m({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:h.Boolean})],g.prototype,"useGravity",2);C([y(),m({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:h.Number})],g.prototype,"linearDamping",2);C([y(),m({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:h.Number})],g.prototype,"angularDamping",2);C([y(),m({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.centerOfMass;o.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticCenterOfMass",2);C([y(),m({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:h.Vector3,bindPath:"centerOfMass",when:o=>!o.automaticCenterOfMass})],g.prototype,"centerOfMass",2);C([y(),m({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.inertiaTensor;o.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticInertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:h.Vector3,bindPath:"inertiaTensor",when:o=>!o.automaticInertiaTensor})],g.prototype,"inertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:h.Vector3,bindPath:"linearVelocity"})],g.prototype,"linearVelocity",2);C([y(),m({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:h.Vector3,bindPath:"angularVelocity"})],g.prototype,"angularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:h.Number})],g.prototype,"maxAngularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:h.Number})],g.prototype,"maxDepenetrationVelocity",2);C([y(),m({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:h.Number})],g.prototype,"sleepThreshold",2);C([y(),m({label:r("physics.dynamic-collider.solver-iterations.title"),info:r("physics.dynamic-collider.solver-iterations.info"),bindPath:"solverIterations",min:0,max:10,dragStep:1,type:h.Slider})],g.prototype,"solverIterations",2);g=C([F({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],g);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,E=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ge(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&qe(e,t,n),n};let M=class extends R{constructor(e,t){super(e,t);p(this,"stepOffset",.5);p(this,"upDirection",{x:0,y:1,z:0});p(this,"slopeLimit",45);p(this,"nonWalkableMode",Y.PreventClimbing)}async bindEngineObject(e){await super.bindEngineObject(e),e.enabled=!1}rebindEngineObject(e){super.rebindEngineObject(e),e.enabled=!1}};E([y(),m({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:h.Number})],M.prototype,"stepOffset",2);E([y(),m({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:h.Vector3,bindPath:"upDirection"})],M.prototype,"upDirection",2);E([y(),m({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:h.Number})],M.prototype,"slopeLimit",2);E([y(),m({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:h.Select,options:[{label:r("physics.character.non-walkable-mode.prevent-climbing"),value:Y.PreventClimbing},{label:r("physics.character.non-walkable-mode.prevent-climbing-and-force-sliding"),value:Y.PreventClimbingAndForceSliding}]})],M.prototype,"nonWalkableMode",2);M=E([F({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],M);const Ze=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,disabled:a,info:d}=e,{ownerId:c}=t[n]||{},f=c&&o.model.root.sceneStore.getEntityModel(c),u=O=>{const _=O?H.sceneStore.getEntityModel(O):null,U=(_==null?void 0:_.getComponentByTypeName("DynamicCollider"))||(_==null?void 0:_.getComponentByTypeName("StaticCollider")),ce=U?{ownerId:O,componentId:U.id}:null;i==null||i(n,ce)},{t:b}=z(),x=Array.from(t.root.sceneStore.iterateEntityModels(),([,O])=>O);return l.jsx(l.Fragment,{children:l.jsx(fe,{label:b(s),info:b(d),entities:x,value:c,disabled:a,customFilter:O=>{let _=null;return t.entityModelId!==O.id&&(_=O.getComponentByTypeName("DynamicCollider")||O.getComponentByTypeName("StaticCollider")),_},displayValue:f==null?void 0:f.name,placeholder:b("physics.collider-picker.placeholder"),onSelect:u,onLocate:()=>{o.model.root.sceneStore.selectEntity(c)},onDelete:()=>{u(null)}})})});var He=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,T=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ue(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&He(e,t,n),n};class v extends ae{constructor(){super(...arguments);p(this,"connectedCollider",null);p(this,"anchor",{x:0,y:0,z:0});p(this,"automaticConnectedAnchor",!0);p(this,"connectedAnchor",{x:0,y:0,z:0});p(this,"breakForce",Number.MAX_VALUE);p(this,"breakTorque",Number.MAX_VALUE);p(this,"massScale",1);p(this,"connectedMassScale",1)}async applyBoundPathChange(t,i,n){var s,a;if(t==="connectedCollider"){const d=n,c=((a=(s=this.root.sceneStore.getEntityModel(d==null?void 0:d.ownerId))==null?void 0:s.getComponentById(d==null?void 0:d.componentId))==null?void 0:a.engineObject)??null;await super.applyBoundPathChange(t,i,c);return}await super.applyBoundPathChange(t,i,n)}}T([y(),m({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:Ze,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);T([y(),m({label:r("physics.joint.anchor.title"),type:h.Vector3,bindPath:"anchor",onChange(o,e,t){if(o.automaticConnectedAnchor){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);T([y(),m({label:r("physics.joint.automatic-connected-anchor.title"),type:h.Boolean,bindPath:"automaticConnectedAnchor",onChange(o,e,t){if(t){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);T([y(),m({label:r("physics.joint.connected-anchor.title"),type:h.Vector3,bindPath:"connectedAnchor",when:o=>!o.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);T([y(),m({label:r("physics.joint.break-force.title"),type:h.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);T([y(),m({label:r("physics.joint.break-torque.title"),type:h.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);T([y(),m({label:r("physics.joint.mass-scale.title"),type:h.Number,bindPath:"massScale"})],v.prototype,"massScale",2);T([y(),m({label:r("physics.joint.connected-mass-scale.title"),type:h.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var We=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,ke=(o,e,t,i)=>{for(var n=i>1?void 0:i?Qe(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&We(e,t,n),n};let oe=class extends v{constructor(o,e){super(o,e)}};oe=ke([F({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],oe);const et=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useLimits,c=t.useSpring,f=t[n],u=f.props,{t:b}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:b(s),info:b(a),children:[l.jsx(P,{label:b("physics.joint-limits.min"),value:u.min,onChange:x=>{u.max<x&&(u.max=x),u.min=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.max"),value:u.max,onChange:x=>{x<u.min&&(x=u.min),u.max=x,i(n,f)}}),c?l.jsxs(l.Fragment,{children:[l.jsx(P,{label:b("physics.joint-limits.stiffness"),value:u.stiffness,onChange:x=>{u.stiffness=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.damping"),value:u.damping,onChange:x=>{u.damping=x,i(n,f)}})]}):l.jsx(P,{label:b("physics.joint-limits.contact-distance"),value:u.contactDistance,onChange:x=>{u.contactDistance=x,i(n,f)}})]}):null})}),tt=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useMotor,c=t[n],f=c.props,{t:u}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:u(s),info:u(a),children:[l.jsx(P,{label:u("physics.joint-motor.target-velocity"),value:f.targetVelocity,onChange:b=>{f.targetVelocity=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.force-limit"),value:f.forceLimit,onChange:b=>{f.forceLimit=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.gear-ratio"),value:f.gearRatio,onChange:b=>{f.gearRatio=b,i(n,c)}}),l.jsx(re,{label:u("physics.joint-motor.free-spin"),value:f.freeSpin,onChange:b=>{f.freeSpin=b,i(n,c)}})]}):null})});var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,A=(o,e,t,i)=>{for(var n=i>1?void 0:i?ot(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&it(e,t,n),n};let D=class extends v{constructor(e,t){super(e,t);p(this,"axis",{x:1,y:0,z:0});p(this,"useLimits",!1);p(this,"useSpring",!1);p(this,"limits",{class:"JointLimits",props:{max:0,min:0,contactDistance:-1,stiffness:0,damping:0}});p(this,"useMotor",!1);p(this,"motor",{class:"JointMotor",props:{targetVelocity:0,forceLimit:Number.MAX_VALUE,gearRatio:1,freeSpin:!1}})}async applyBoundPathChange(e,t,i){if(e==="limits"){const n=this._buildLimitsFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}if(e==="motor"){const n=this._buildMotorFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}await super.applyBoundPathChange(e,t,i)}_buildLimitsFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new be;return i.max=t.max,i.min=t.min,i.contactDistance=t.contactDistance,i.stiffness=t.stiffness,i.damping=t.damping,i}_buildMotorFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new ge;return i.targetVelocity=t.targetVelocity,i.forceLimit=t.forceLimit,i.gearRatio=t.gearRatio,i.freeSpin=t.freeSpin,i}};A([y(),m({label:r("physics.hinge-joint.axis.title"),type:h.Vector3,bindPath:"axis"})],D.prototype,"axis",2);A([y(),m({label:r("physics.hinge-joint.use-limits.title"),type:h.Boolean,bindPath:"useLimits"})],D.prototype,"useLimits",2);A([y(),m({label:r("physics.hinge-joint.use-spring.title"),type:h.Boolean,bindPath:"useSpring"})],D.prototype,"useSpring",2);A([y(),m({label:r("physics.hinge-joint.limits.title"),customComponent:et,bindPath:"limits"})],D.prototype,"limits",2);A([y(),m({label:r("physics.hinge-joint.use-motor.title"),type:h.Boolean,bindPath:"useMotor"})],D.prototype,"useMotor",2);A([y(),m({label:r("physics.hinge-joint.motor.title"),customComponent:tt,bindPath:"motor"})],D.prototype,"motor",2);D=A([F({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],D);var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,V=(o,e,t,i)=>{for(var n=i>1?void 0:i?st(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&nt(e,t,n),n};let w=class extends v{constructor(e,t){super(e,t);p(this,"spring",10);p(this,"damper",.2);p(this,"minDistance",0);p(this,"maxDistance",0);p(this,"tolerance",.025)}};V([y(),m({label:r("physics.spring-joint.spring.title"),type:h.Number,bindPath:"spring"})],w.prototype,"spring",2);V([y(),m({label:r("physics.spring-joint.damper.title"),type:h.Number,bindPath:"damper"})],w.prototype,"damper",2);V([y(),m({label:r("physics.spring-joint.min-distance.title"),type:h.Number,bindPath:"minDistance"})],w.prototype,"minDistance",2);V([y(),m({label:r("physics.spring-joint.max-distance.title"),type:h.Number,bindPath:"maxDistance"})],w.prototype,"maxDistance",2);V([y(),m({label:r("physics.spring-joint.tolerance.title"),type:h.Number,bindPath:"tolerance"})],w.prototype,"tolerance",2);w=V([F({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],w);class rt extends Ce{constructor(){super(...arguments);p(this,"_isPlaying",!1)}onPlay(t){this._isPlaying=t,this._toggleAll(t)}onAddComponent(t){!this._isPlaying&&(t instanceof Q||t instanceof K)&&(t.enabled=!1)}_toggleAll(t){var a;const i=(a=this.engine.sceneManager.activeScene)==null?void 0:a.rootEntities;if(!i)return;const n=[],s=[];i.forEach(d=>{d.getComponentsIncludeChildren(Q,n),d.getComponentsIncludeChildren(K,s)}),n.forEach(d=>{d.enabled=t}),s.forEach(d=>{d.enabled=t})}}var at=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,ct=(o,e,t,i)=>{for(var n=i>1?void 0:i?lt(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&at(e,t,n),n};let ne=class{constructor(){p(this,"script")}init(){this.script=xe.addScript(rt)}};ne=ct([Se({type:"physicsStore"})],ne);export{M as C,g as D,oe as F,D as H,ne as P,te as S,w as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var m=Object.defineProperty;var c=(o,t,e)=>t in o?m(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var a=(o,t,e)=>(c(o,typeof t!="symbol"?t+"":t,e),e);import{s as f,p as h,C as g}from"./index-
|
|
1
|
+
var m=Object.defineProperty;var c=(o,t,e)=>t in o?m(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var a=(o,t,e)=>(c(o,typeof t!="symbol"?t+"":t,e),e);import{s as f,p as h,C as g}from"./index-3660a664.js";import"./index-365736f7.js";import{c as b}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.js";import{L as u}from"./LightBaseComponent-545c5ee8.js";var P=Object.defineProperty,d=Object.getOwnPropertyDescriptor,l=(o,t,e,p)=>{for(var n=p>1?void 0:p?d(t,e):t,i=o.length-1,r;i>=0;i--)(r=o[i])&&(n=(p?r(t,e,n):r(n))||n);return p&&n&&P(t,e,n),n};let s=class extends u{constructor(t,e){super(t,e);a(this,"distance",60)}};l([f(),h({type:g.Number,bindPath:"distance",label:"light.point.distance.label",info:"light.point.distance.info"})],s.prototype,"distance",2);s=l([b({type:"PointLight",componentsMenu:{group:"light",label:"component.light.point.title"}})],s);export{s as PointLightComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var R=Object.defineProperty;var $=(e,s,o)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o;var x=(e,s,o)=>($(e,typeof s!="symbol"?s+"":s,o),o);import{aM as _,av as l,aP as q,e as u,aw as G,aI as w,de as J,aL as A,aJ as N,df as z,dg as Q,dh as W,di as H,bm as K,dj as U,dk as X,dl as Y,bA as Z,q as ee,dm as te,dn as se,dp as oe,bk as re,t as ne,dq as ae,dr as ce,ds as le,cm as ie,dt as fe,du as pe,bI as me,E as ue,a as T,s as C,p as k,C as D,l as be,g as de}from"./index-
|
|
1
|
+
var R=Object.defineProperty;var $=(e,s,o)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o;var x=(e,s,o)=>($(e,typeof s!="symbol"?s+"":s,o),o);import{aM as _,av as l,aP as q,e as u,aw as G,aI as w,de as J,aL as A,aJ as N,df as z,dg as Q,dh as W,di as H,bm as K,dj as U,dk as X,dl as Y,bA as Z,q as ee,dm as te,dn as se,dp as oe,bk as re,t as ne,dq as ae,dr as ce,ds as le,cm as ie,dt as fe,du as pe,bI as me,E as ue,a as T,s as C,p as k,C as D,l as be,g as de}from"./index-3660a664.js";import{u as he}from"./index-365736f7.js";import{c as ye}from"./Component-6d1e73e5.js";import"./postmen-c7605b45.js";import{I as ge}from"./IconPlus-5fbc029e.js";import{D as Pe,M as je}from"./Menu-a427d272.js";import{c as B}from"./createReactComponent-d9f8b1af.js";import{A as xe,a as Ee}from"./Accordion-75b7b34e.js";/**
|
|
2
2
|
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -1 +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-03b6134d.js";import{T as $t}from"./TaskQueue-05c94a4d.js";import{u as Re,I as vt}from"./index-0a53aaef.js";import"./postmen-9e6354af.js";import{A as At}from"./AssetViewer-1a9f3cad.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 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-3660a664.js";import{T as $t}from"./TaskQueue-05c94a4d.js";import{u as Re,I as vt}from"./index-365736f7.js";import"./postmen-c7605b45.js";import{A as At}from"./AssetViewer-1073ddb5.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};
|