@galacean/cli 2.0.0-alpha.26 → 2.0.0-alpha.27
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 +671 -777
- package/dist/preview-client/_static/{Accordion-2cd014f1.js → Accordion-4afac60c.js} +1 -1
- package/dist/preview-client/_static/{AmbientLightAsset-be9e872c.js → AmbientLightAsset-3825f3bf.js} +2 -2
- package/dist/preview-client/_static/{AnimationClipAsset-d7b37af0.js → AnimationClipAsset-660ecb36.js} +1 -1
- package/dist/preview-client/_static/{AnimatorControllerAsset-2716497a.js → AnimatorControllerAsset-dcf11a9d.js} +1 -1
- package/dist/preview-client/_static/{AnimatorStore-883a28ad.js → AnimatorStore-aa58d85c.js} +1 -1
- package/dist/preview-client/_static/{AssetViewer-3847c058.js → AssetViewer-8338dfe1.js} +1 -1
- package/dist/preview-client/_static/{AudioAsset-c28f33ab.js → AudioAsset-6e607154.js} +1 -1
- package/dist/preview-client/_static/{AudioComponent-3d6c73ce.js → AudioComponent-b70cc31e.js} +1 -1
- package/dist/preview-client/_static/{Callout-e2a89f6f.js → Callout-155c30df.js} +1 -1
- package/dist/preview-client/_static/{CameraComponent-3dc63451.js → CameraComponent-76bc9102.js} +1 -1
- package/dist/preview-client/_static/{Component-0f881fc1.js → Component-398551a0.js} +1 -1
- package/dist/preview-client/_static/{DirectLight-96dbba47.js → DirectLight-50653e81.js} +1 -1
- package/dist/preview-client/_static/{FontAsset-d34b5378.js → FontAsset-dc385d41.js} +1 -1
- package/dist/preview-client/_static/{FormItemArray-b8cda1d2.js → FormItemArray-9ca61884.js} +1 -1
- package/dist/preview-client/_static/{GlTFAsset-5970e707.js → GlTFAsset-d2ee4f95.js} +1 -1
- package/dist/preview-client/_static/{IconPlus-def01e2b.js → IconPlus-b3ed4c04.js} +1 -1
- package/dist/preview-client/_static/{IconPointFilled-62d3c3b2.js → IconPointFilled-3ba6d082.js} +1 -1
- package/dist/preview-client/_static/{LightBaseComponent-d651a276.js → LightBaseComponent-4cfc9f48.js} +1 -1
- package/dist/preview-client/_static/{LottieAnimationComponent-f10dc558.js → LottieAnimationComponent-aeb555ea.js} +1 -1
- package/dist/preview-client/_static/{MarkdownAsset-b2a3fad5.js → MarkdownAsset-02477e7c.js} +1 -1
- package/dist/preview-client/_static/{MaterialAsset-5353c4cb.js → MaterialAsset-8f3b3302.js} +1 -1
- package/dist/preview-client/_static/{MaterialInspector-8d466d59.js → MaterialInspector-3fb471d9.js} +1 -1
- package/dist/preview-client/_static/{Menu-c8e6194b.js → Menu-36c201c0.js} +1 -1
- package/dist/preview-client/_static/{MeshAsset-c2bf60c5.js → MeshAsset-3ddf1ac6.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererBaseComponent-fde6b6a5.js → MeshRendererBaseComponent-cd8b743b.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererComponent-430774ef.js → MeshRendererComponent-17a7fc72.js} +1 -1
- package/dist/preview-client/_static/{MeshThumbnail-07ffa076.js → MeshThumbnail-8c20ee92.js} +1 -1
- package/dist/preview-client/_static/{ParticleRendererComponent-e106bd8c.js → ParticleRendererComponent-1834a159.js} +3 -3
- package/dist/preview-client/_static/{PhysicsMaterialAsset-a2f73b5c.js → PhysicsMaterialAsset-e0491877.js} +1 -1
- package/dist/preview-client/_static/{PhysicsStore-818c2f61.js → PhysicsStore-ab32886e.js} +1 -1
- package/dist/preview-client/_static/{PointLight-add790ea.js → PointLight-97975350.js} +1 -1
- package/dist/preview-client/_static/{PostProcessComponent-af270a77.js → PostProcessComponent-9590ec29.js} +1 -1
- package/dist/preview-client/_static/PrefabAsset-2f94de73.js +1 -0
- package/dist/preview-client/_static/{PrimitiveMesh-075dda8a.js → PrimitiveMesh-0492d482.js} +1 -1
- package/dist/preview-client/_static/{ReferencedMaterial-d11151b5.js → ReferencedMaterial-49a7cbcc.js} +1 -1
- package/dist/preview-client/_static/{RenderTargetAsset-b3cd1c49.js → RenderTargetAsset-dc1f9494.js} +1 -1
- package/dist/preview-client/_static/{SceneAsset-08752701.js → SceneAsset-c3bb667f.js} +1 -1
- package/dist/preview-client/_static/{ShaderAsset-a9d667f5.js → ShaderAsset-f4eead79.js} +12 -12
- package/dist/preview-client/_static/{ShaderChunkAsset-e43dde8a.js → ShaderChunkAsset-4bea2733.js} +2 -2
- package/dist/preview-client/_static/{ShaderUIScriptAsset-e1cd0b8b.js → ShaderUIScriptAsset-3c731f3b.js} +2 -2
- package/dist/preview-client/_static/{SkinnedMeshRendererComponent-9756bd5f.js → SkinnedMeshRendererComponent-e0f9b133.js} +1 -1
- package/dist/preview-client/_static/{SpineAnimationComponent-f3e0ff44.js → SpineAnimationComponent-1e1655fd.js} +1 -1
- package/dist/preview-client/_static/{SpineSkeletonDataAsset-43b731f1.js → SpineSkeletonDataAsset-afb4afae.js} +1 -1
- package/dist/preview-client/_static/{SpotLight-649b0e21.js → SpotLight-69f361c9.js} +1 -1
- package/dist/preview-client/_static/{SpriteBaseComponent-d2a7ab4c.js → SpriteBaseComponent-2c2454ea.js} +1 -1
- package/dist/preview-client/_static/{SpriteMaskComponent-2c1cef5e.js → SpriteMaskComponent-a7ebcc50.js} +1 -1
- package/dist/preview-client/_static/{SpriteRendererComponent-33b71997.js → SpriteRendererComponent-f7604c68.js} +1 -1
- package/dist/preview-client/_static/{TextBaseComponent-9310e0c6.js → TextBaseComponent-cd7ad9f7.js} +1 -1
- package/dist/preview-client/_static/{TextRendererComponent-8dc0d7fb.js → TextRendererComponent-a5357d52.js} +1 -1
- package/dist/preview-client/_static/{TextureAsset-a7ff39b1.js → TextureAsset-ff089b5a.js} +1 -1
- package/dist/preview-client/_static/{Tooltip-b5be390f.js → Tooltip-1bcb87b5.js} +1 -1
- package/dist/preview-client/_static/{TrailRendererComponent-c4635fab.js → TrailRendererComponent-cdefa368.js} +1 -1
- package/dist/preview-client/_static/{TransformBaseComponent-1473deaa.js → TransformBaseComponent-d26ff236.js} +1 -1
- package/dist/preview-client/_static/{TransformComponent-e544f7ac.js → TransformComponent-4ec4b7b5.js} +1 -1
- package/dist/preview-client/_static/{XRReferenceImageAsset-96f516ba.js → XRReferenceImageAsset-ff82ab30.js} +1 -1
- package/dist/preview-client/_static/{audio-b5fbde34.js → audio-0a013eb6.js} +1 -1
- package/dist/preview-client/_static/{createOnModelChange-370b83da.js → createOnModelChange-89f572a6.js} +1 -1
- package/dist/preview-client/_static/{createReactComponent-58d9f0dd.js → createReactComponent-baa41397.js} +1 -1
- package/dist/preview-client/_static/index-0086cabc.js +1 -0
- package/dist/preview-client/_static/index-253f9e13.js +1 -0
- package/dist/preview-client/_static/{index-da16047f.js → index-29916a80.js} +1 -1
- package/dist/preview-client/_static/{index-ab8556cb.js → index-4845b67c.js} +3 -3
- package/dist/preview-client/_static/{index-dd0763bf.js → index-5e4dedda.js} +1 -1
- package/dist/preview-client/_static/{index-0dd5bb36.js → index-70967035.js} +1 -1
- package/dist/preview-client/_static/index-8234e4e2.js +1 -0
- package/dist/preview-client/_static/{index-88650db7.js → index-8784a43a.js} +1 -1
- package/dist/preview-client/_static/index-94594d06.js +1 -0
- package/dist/preview-client/_static/{index-74bcfad9.js → index-a0afef01.js} +1 -1
- package/dist/preview-client/_static/index-ad57c6c8.js +1 -0
- package/dist/preview-client/_static/{index-c3dec278.js → index-b126bb6b.js} +72 -72
- package/dist/preview-client/_static/{index-cdbb2f4d.js → index-c8ed2a45.js} +1 -1
- package/dist/preview-client/_static/{index-05b76766.js → index-cd09e78a.js} +1 -1
- package/dist/preview-client/_static/index-d1484803.js +1 -0
- package/dist/preview-client/_static/index-f7fcda86.js +1 -0
- package/dist/preview-client/_static/{ktx2-encoder-db93524f.js → ktx2-encoder-8498815e.js} +1 -1
- package/dist/preview-client/_static/{module-ada3dced.js → module-113ac03a.js} +1 -1
- package/dist/preview-client/_static/{module-ec094ef6.js → module-83a57161.js} +1 -1
- package/dist/preview-client/_static/{module-de7ee724.js → module-8efda49c.js} +1 -1
- package/dist/preview-client/_static/{postmen-2853c0e6.js → postmen-3b48c572.js} +2 -2
- package/dist/preview-client/_static/{shader-data-utils-f0e4f5a3.js → shader-data-utils-c90e48b8.js} +1 -1
- package/dist/preview-client/index.html +1 -1
- package/package.json +29 -24
- package/dist/preview-client/_static/PrefabAsset-59743dbb.js +0 -1
- package/dist/preview-client/_static/index-29c59aff.js +0 -1
- package/dist/preview-client/_static/index-3680d0e0.js +0 -1
- package/dist/preview-client/_static/index-42aa3a49.js +0 -1
- package/dist/preview-client/_static/index-496f331d.js +0 -1
- package/dist/preview-client/_static/index-9f0122f0.js +0 -1
- package/dist/preview-client/_static/index-c6b7045c.js +0 -1
- package/dist/preview-client/_static/index-dddcae01.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var pe=Object.defineProperty;var de=(o,e,t)=>e in o?pe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(de(o,typeof e!="symbol"?e+"":e,t),t);import{aJ as j,aK as z,av as l,bm as X,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-c3dec278.js";import{r as H}from"./index-cdbb2f4d.js";import{c as F}from"./Component-0f881fc1.js";import"./postmen-2853c0e6.js";import{F as Pe}from"./FormItemArray-b8cda1d2.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,cn as P,bk as se,eF as I,ds as re,bA as ye,q as me,cC as K,eG as $,eH as G,eI as L,eJ as J,bI as N,f as he,aE as ue,s as y,p as m,e as r,E as ae,eK as W,eL as S,eM as B,C as h,eN as Y,eO as fe,eP as Z,e2 as le,eQ as be,eR as ge,bq as Ce,cA as Q,bs as xe,bt as Se}from"./index-b126bb6b.js";import{r as H}from"./index-c8ed2a45.js";import{c as F}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{F as Pe}from"./FormItemArray-9ca61884.js";const je={BoxColliderShape:["size","isTrigger","position","rotation","material"],CapsuleColliderShape:["radius","height","upAxis","isTrigger","position","rotation","material"],PlaneColliderShape:["isTrigger","position","rotation","material"],SphereColliderShape:["radius","isTrigger","position","rotation","material"]};function ve(o){const e={};return Object.keys(o.props).forEach(t=>{je[o.class].includes(t)&&(e[t]=o.props[t])}),e}const ze=async(o,e,t)=>{const i=o.engineObject,n=i.shapes;if(n.length===t.length&&t.every((s,a)=>Oe(s.class,n[a]))){for(let s=0;s<t.length;s++)await k(n[s],t[s]),ee(n[s],t[s]);return}i.clearShapes();for(let s=0;s<t.length;s++){const a=t[s],d=_e(a);await k(d,a),ee(d,a),i.addShape(d)}};async function k(o,e){const t=e.props.material;if(t!=null&&t.refId)try{const i=await H.assetStore.getAssetByRef(t);i!=null&&i.engineObject&&(o.material=i.engineObject)}catch(i){console.error(i)}}function Oe(o,e){switch(o){case"BoxColliderShape":return e instanceof J;case"CapsuleColliderShape":return e instanceof L;case"PlaneColliderShape":return e instanceof G;case"SphereColliderShape":return e instanceof $;default:return!1}}function _e(o){switch(o.class){case"BoxColliderShape":return new J;case"CapsuleColliderShape":return new L;case"PlaneColliderShape":return new G;case"SphereColliderShape":return new $}}function ee(o,e){const t=e.props;if(o instanceof J&&t.size){const s=o.size;s.copyFrom(t.size),o.size=s}else o instanceof L?(t.radius!==void 0&&(o.radius=t.radius),t.height!==void 0&&(o.height=t.height),t.upAxis!==void 0&&(o.upAxis=t.upAxis)):o instanceof $&&t.radius!==void 0&&(o.radius=t.radius);o.isTrigger=t.isTrigger;const i=o.position;i.copyFrom(t.position),o.position=i;const n=o.rotation;n.copyFrom(t.rotation),o.rotation=n}const De=o=>o.map(e=>{if(e instanceof J)return{class:"BoxColliderShape",props:{isTrigger:e.isTrigger,size:{x:e.size.x,y:e.size.y,z:e.size.z},position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof L)return{class:"CapsuleColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,height:e.height,upAxis:e.upAxis,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof G)return{class:"PlaneColliderShape",props:{isTrigger:e.isTrigger,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}};if(e instanceof $)return{class:"SphereColliderShape",props:{isTrigger:e.isTrigger,radius:e.radius,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z}}}}),Ae=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(X,{label:t("physics.shape.box.size.title"),info:t("physics.shape.box.size.info"),min:0,value:{x:o.props.size.x,y:o.props.size.y,z:o.props.size.z},onChange:(i,n)=>{const s=i==null?void 0:i[n];typeof s=="number"&&e(a=>{a.props.size={...a.props.size,[n]:s}})}})})}),Te=j(()=>l.jsx(l.Fragment,{})),we=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsx(l.Fragment,{children:l.jsx(P,{label:t("physics.shape.sphere.radius.title"),info:t("physics.shape.sphere.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}})})}),Me=j(({item:o,onItemChange:e})=>{const{t}=z();return l.jsxs(l.Fragment,{children:[l.jsx(P,{label:t("physics.shape.capsule.radius.title"),info:t("physics.shape.capsule.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.radius=i})}}),l.jsx(P,{label:t("physics.shape.capsule.height.title"),info:t("physics.shape.capsule.height.info"),value:o.props.height,min:0,onChange:i=>{typeof i=="number"&&e(n=>{n.props.height=i})}}),l.jsx(se,{label:t("physics.shape.capsule.up-axis.title"),info:t("physics.shape.capsule.up-axis.info"),options:[{label:"X",value:I.X},{label:"Y",value:I.Y},{label:"Z",value:I.Z}],value:o.props.upAxis,onChange:i=>{e(n=>{n.props.upAxis=i})}})]})}),Fe={BoxColliderShape:Ae,CapsuleColliderShape:Me,PlaneColliderShape:Te,SphereColliderShape:we},q={BoxColliderShape:{class:"BoxColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},size:{x:1,y:1,z:1},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},CapsuleColliderShape:{class:"CapsuleColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,height:2,upAxis:I.Y,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},PlaneColliderShape:{class:"PlaneColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},SphereColliderShape:{class:"SphereColliderShape",props:{isTrigger:!1,material:{refId:"0000401"},radius:.5,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}}},Ve=j(({item:o,onItemChange:e})=>{var d;const{t}=z(),i=Fe[o.class],n=H.assetStore,s=Object.values(n.assets).filter(c=>c.getMetaConfig().type==="PhysicsMaterial"),a=n.assets[(d=o.props.material)==null?void 0:d.refId];return l.jsxs(l.Fragment,{children:[l.jsx(re,{label:t("physics.collider.trigger.title"),info:t("physics.collider.trigger.info"),value:o.props.isTrigger,onChange:c=>{e(f=>{f.props.isTrigger=c})}}),l.jsx(ye,{label:t("physics.collider.material.title"),info:t("physics.collider.material.info"),dropLayer:me.PhysicsMaterial,value:a==null?void 0:a.name,assets:s,onSelect:c=>{e(f=>{f.props.material=c.getCurrentRef()})},onLocate:()=>{a&&a.id&&n.selectAsset(a.id)}}),l.jsx(i,{item:o,onItemChange:e}),l.jsx(X,{label:t("physics.collider.local-position.title"),info:t("physics.collider.local-position.info"),value:{x:o.props.position.x,y:o.props.position.y,z:o.props.position.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.position={...b.props.position,[f]:u}})}}),l.jsx(X,{label:t("physics.collider.rotation.title"),info:t("physics.collider.rotation.info"),value:{x:o.props.rotation.x,y:o.props.rotation.y,z:o.props.rotation.z},onChange:(c,f)=>{const u=c==null?void 0:c[f];typeof u=="number"&&e(b=>{b.props.rotation={...b.props.rotation,[f]:u}})}})]})}),Be=j(({collider:o,item:e,index:t,onModelChange:i})=>{const{t:n}=z(),s=[{label:n("physics.shape.box.title"),value:"BoxColliderShape"},{label:n("physics.shape.capsule.title"),value:"CapsuleColliderShape"}];o.engineObject instanceof K||(s.push({label:n("physics.shape.plane.title"),value:"PlaneColliderShape"}),s.push({label:n("physics.shape.sphere.title"),value:"SphereColliderShape"}));const d=c=>{const f=o.colliderShapes,u=N(f),b=u[t];b&&(c(b),i==null||i("colliderShapes",u))};return l.jsxs(l.Fragment,{children:[l.jsx(se,{label:n("physics.shape.type.title"),info:n("physics.shape.type.info"),value:e.class,options:s,onChange:c=>{q[c].class!==e.class&&d(u=>{Object.assign(u,N(q[c]))})}}),l.jsx(Ve,{item:e,onItemChange:d})]})}),Ee=j(({model:o,inspectorConfig:e,onModelChange:t})=>{const{label:i}=e,n=o.colliderShapes,{t:s}=z(),a=d=>{const c=N(n);d(c),t==null||t("colliderShapes",c)};return l.jsx(Pe,{label:i,items:n.map((d,c)=>({removable:!0,children:l.jsx(Be,{collider:o,item:d,index:c,onModelChange:t}),id:`${c}`,name:s("physics.shape.item-name",{index:c})})),addable:!0,onAdd:()=>{a(d=>{d.push(N(q.BoxColliderShape))})},onDelete:d=>{a(c=>{c.splice(+d.id,1)})},addItemText:s("physics.shape.add")})});var Ie=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ne(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ie(e,t,n),n};class R extends ae{constructor(){super(...arguments);p(this,"colliderShapes",[])}}$e([he({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:ue.Object,getEngineValue:o=>o.shapes,getEditorValue:De}),y({type:"methods",key:"colliderShapes",canonicalizeToProps:!0,onSerialize:o=>o.map(e=>({$type:e.class,...ve(e)})),onDeserialize:o=>o.map(e=>{const{$type:t,...i}=e;return{class:t,props:i}})}),m({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Ee,onChange:ze})],R.prototype,"colliderShapes",2);var Le=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Re=(o,e,t,i)=>{for(var n=i>1?void 0:i?Je(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Le(e,t,n),n};let te=class extends R{constructor(o,e){super(o,e)}};te=Re([F({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],te);const ie=o=>Object.keys(S).filter(e=>(o&S[e])!==0).map(e=>String(S[e])),Xe=j(({model:o,onModelChange:e})=>{const t=n=>{const a=n.map(d=>parseInt(d)).reduce((d,c)=>d|c,S.None);e==null||e("constraints",a)},{t:i}=z();return l.jsxs(l.Fragment,{children:[l.jsx(W,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:t}),l.jsx(W,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:ie(o.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:t})]})});var Ke=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,C=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ye(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ke(e,t,n),n};let g=class extends R{constructor(e,t){super(e,t);p(this,"isKinematic",!1);p(this,"collisionDetectionMode",B.Discrete);p(this,"constraints",S.None);p(this,"mass",1);p(this,"useGravity",!0);p(this,"linearDamping",0);p(this,"angularDamping",.05);p(this,"automaticCenterOfMass",!0);p(this,"centerOfMass",{x:0,y:0,z:0});p(this,"automaticInertiaTensor",!0);p(this,"inertiaTensor",{x:1,y:1,z:1});p(this,"linearVelocity",{x:0,y:0,z:0});p(this,"angularVelocity",{x:0,y:0,z:0});p(this,"maxAngularVelocity",100);p(this,"maxDepenetrationVelocity",10000000331813535e16);p(this,"sleepThreshold",.005);p(this,"solverIterations",4)}onEnabled(){this._applyEditorRuntimeState()}onInitComplete(){this._applyEditorRuntimeState()}rebindEngineObject(e){super.rebindEngineObject(e),this._applyEditorRuntimeState()}_applyEditorRuntimeState(){this.applyBoundPathChange("enabled",h.Toggle,!1)}};C([y(),m({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:h.Boolean,bindPath:"isKinematic"})],g.prototype,"isKinematic",2);C([y(),m({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:h.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:B.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:B.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:B.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:B.ContinuousSpeculative}]})],g.prototype,"collisionDetectionMode",2);C([y(),m({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:Xe,bindPath:"constraints"})],g.prototype,"constraints",2);C([y(),m({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:h.Number})],g.prototype,"mass",2);C([y(),m({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:h.Boolean})],g.prototype,"useGravity",2);C([y(),m({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:h.Number})],g.prototype,"linearDamping",2);C([y(),m({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:h.Number})],g.prototype,"angularDamping",2);C([y(),m({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.centerOfMass;o.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticCenterOfMass",2);C([y(),m({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:h.Vector3,bindPath:"centerOfMass",when:o=>!o.automaticCenterOfMass})],g.prototype,"centerOfMass",2);C([y(),m({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:h.Boolean,onChange:(o,e,t)=>{if(t){const i=o.engineObject.inertiaTensor;o.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticInertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:h.Vector3,bindPath:"inertiaTensor",when:o=>!o.automaticInertiaTensor})],g.prototype,"inertiaTensor",2);C([y(),m({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:h.Vector3,bindPath:"linearVelocity"})],g.prototype,"linearVelocity",2);C([y(),m({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:h.Vector3,bindPath:"angularVelocity"})],g.prototype,"angularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:h.Number})],g.prototype,"maxAngularVelocity",2);C([y(),m({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:h.Number})],g.prototype,"maxDepenetrationVelocity",2);C([y(),m({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:h.Number})],g.prototype,"sleepThreshold",2);C([y(),m({label:r("physics.dynamic-collider.solver-iterations.title"),info:r("physics.dynamic-collider.solver-iterations.info"),bindPath:"solverIterations",min:0,max:10,dragStep:1,type:h.Slider})],g.prototype,"solverIterations",2);g=C([F({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],g);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,E=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ge(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&qe(e,t,n),n};let M=class extends R{constructor(e,t){super(e,t);p(this,"stepOffset",.5);p(this,"upDirection",{x:0,y:1,z:0});p(this,"slopeLimit",45);p(this,"nonWalkableMode",Y.PreventClimbing)}async bindEngineObject(e){await super.bindEngineObject(e),e.enabled=!1}rebindEngineObject(e){super.rebindEngineObject(e),e.enabled=!1}};E([y(),m({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:h.Number})],M.prototype,"stepOffset",2);E([y(),m({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:h.Vector3,bindPath:"upDirection"})],M.prototype,"upDirection",2);E([y(),m({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:h.Number})],M.prototype,"slopeLimit",2);E([y(),m({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:h.Select,options:[{label:r("physics.character.non-walkable-mode.prevent-climbing"),value:Y.PreventClimbing},{label:r("physics.character.non-walkable-mode.prevent-climbing-and-force-sliding"),value:Y.PreventClimbingAndForceSliding}]})],M.prototype,"nonWalkableMode",2);M=E([F({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],M);const Ze=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,disabled:a,info:d}=e,{ownerId:c}=t[n]||{},f=c&&o.model.root.sceneStore.getEntityModel(c),u=O=>{const _=O?H.sceneStore.getEntityModel(O):null,U=(_==null?void 0:_.getComponentByTypeName("DynamicCollider"))||(_==null?void 0:_.getComponentByTypeName("StaticCollider")),ce=U?{ownerId:O,componentId:U.id}:null;i==null||i(n,ce)},{t:b}=z(),x=Array.from(t.root.sceneStore.iterateEntityModels(),([,O])=>O);return l.jsx(l.Fragment,{children:l.jsx(fe,{label:b(s),info:b(d),entities:x,value:c,disabled:a,customFilter:O=>{let _=null;return t.entityModelId!==O.id&&(_=O.getComponentByTypeName("DynamicCollider")||O.getComponentByTypeName("StaticCollider")),_},displayValue:f==null?void 0:f.name,placeholder:b("physics.collider-picker.placeholder"),onSelect:u,onLocate:()=>{o.model.root.sceneStore.selectEntity(c)},onDelete:()=>{u(null)}})})});var He=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,A=(o,e,t,i)=>{for(var n=i>1?void 0:i?Ue(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&He(e,t,n),n};class v extends ae{constructor(){super(...arguments);p(this,"connectedCollider",null);p(this,"anchor",{x:0,y:0,z:0});p(this,"automaticConnectedAnchor",!0);p(this,"connectedAnchor",{x:0,y:0,z:0});p(this,"breakForce",Number.MAX_VALUE);p(this,"breakTorque",Number.MAX_VALUE);p(this,"massScale",1);p(this,"connectedMassScale",1)}async applyBoundPathChange(t,i,n){var s,a;if(t==="connectedCollider"){const d=n,c=((a=(s=this.root.sceneStore.getEntityModel(d==null?void 0:d.ownerId))==null?void 0:s.getComponentById(d==null?void 0:d.componentId))==null?void 0:a.engineObject)??null;await super.applyBoundPathChange(t,i,c);return}await super.applyBoundPathChange(t,i,n)}}A([y(),m({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:Ze,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);A([y(),m({label:r("physics.joint.anchor.title"),type:h.Vector3,bindPath:"anchor",onChange(o,e,t){if(o.automaticConnectedAnchor){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);A([y(),m({label:r("physics.joint.automatic-connected-anchor.title"),type:h.Boolean,bindPath:"automaticConnectedAnchor",onChange(o,e,t){if(t){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);A([y(),m({label:r("physics.joint.connected-anchor.title"),type:h.Vector3,bindPath:"connectedAnchor",when:o=>!o.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);A([y(),m({label:r("physics.joint.break-force.title"),type:h.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);A([y(),m({label:r("physics.joint.break-torque.title"),type:h.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);A([y(),m({label:r("physics.joint.mass-scale.title"),type:h.Number,bindPath:"massScale"})],v.prototype,"massScale",2);A([y(),m({label:r("physics.joint.connected-mass-scale.title"),type:h.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var We=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,ke=(o,e,t,i)=>{for(var n=i>1?void 0:i?Qe(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&We(e,t,n),n};let oe=class extends v{constructor(o,e){super(o,e)}};oe=ke([F({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],oe);const et=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useLimits,c=t.useSpring,f=t[n],u=f.props,{t:b}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:b(s),info:b(a),children:[l.jsx(P,{label:b("physics.joint-limits.min"),value:u.min,onChange:x=>{u.max<x&&(u.max=x),u.min=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.max"),value:u.max,onChange:x=>{x<u.min&&(x=u.min),u.max=x,i(n,f)}}),c?l.jsxs(l.Fragment,{children:[l.jsx(P,{label:b("physics.joint-limits.stiffness"),value:u.stiffness,onChange:x=>{u.stiffness=x,i(n,f)}}),l.jsx(P,{label:b("physics.joint-limits.damping"),value:u.damping,onChange:x=>{u.damping=x,i(n,f)}})]}):l.jsx(P,{label:b("physics.joint-limits.contact-distance"),value:u.contactDistance,onChange:x=>{u.contactDistance=x,i(n,f)}})]}):null})}),tt=j(o=>{const{inspectorConfig:e,model:t,onModelChange:i}=o,{property:n,label:s,info:a}=e,d=t.useMotor,c=t[n],f=c.props,{t:u}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(le,{label:u(s),info:u(a),children:[l.jsx(P,{label:u("physics.joint-motor.target-velocity"),value:f.targetVelocity,onChange:b=>{f.targetVelocity=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.force-limit"),value:f.forceLimit,onChange:b=>{f.forceLimit=b,i(n,c)}}),l.jsx(P,{label:u("physics.joint-motor.gear-ratio"),value:f.gearRatio,onChange:b=>{f.gearRatio=b,i(n,c)}}),l.jsx(re,{label:u("physics.joint-motor.free-spin"),value:f.freeSpin,onChange:b=>{f.freeSpin=b,i(n,c)}})]}):null})});var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,w=(o,e,t,i)=>{for(var n=i>1?void 0:i?ot(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&it(e,t,n),n};let D=class extends v{constructor(e,t){super(e,t);p(this,"axis",{x:1,y:0,z:0});p(this,"useLimits",!1);p(this,"useSpring",!1);p(this,"limits",{class:"JointLimits",props:{max:0,min:0,contactDistance:-1,stiffness:0,damping:0}});p(this,"useMotor",!1);p(this,"motor",{class:"JointMotor",props:{targetVelocity:0,forceLimit:Number.MAX_VALUE,gearRatio:1,freeSpin:!1}})}async applyBoundPathChange(e,t,i){if(e==="limits"){const n=this._buildLimitsFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}if(e==="motor"){const n=this._buildMotorFromModel(i);if(!n)return;await super.applyBoundPathChange(e,t,n);return}await super.applyBoundPathChange(e,t,i)}_buildLimitsFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new be;return i.max=t.max,i.min=t.min,i.contactDistance=t.contactDistance,i.stiffness=t.stiffness,i.damping=t.damping,i}_buildMotorFromModel(e){const t=e==null?void 0:e.props;if(!t)return null;const i=new ge;return i.targetVelocity=t.targetVelocity,i.forceLimit=t.forceLimit,i.gearRatio=t.gearRatio,i.freeSpin=t.freeSpin,i}};w([y(),m({label:r("physics.hinge-joint.axis.title"),type:h.Vector3,bindPath:"axis"})],D.prototype,"axis",2);w([y(),m({label:r("physics.hinge-joint.use-limits.title"),type:h.Boolean,bindPath:"useLimits"})],D.prototype,"useLimits",2);w([y(),m({label:r("physics.hinge-joint.use-spring.title"),type:h.Boolean,bindPath:"useSpring"})],D.prototype,"useSpring",2);w([y(),m({label:r("physics.hinge-joint.limits.title"),customComponent:et,bindPath:"limits"})],D.prototype,"limits",2);w([y(),m({label:r("physics.hinge-joint.use-motor.title"),type:h.Boolean,bindPath:"useMotor"})],D.prototype,"useMotor",2);w([y(),m({label:r("physics.hinge-joint.motor.title"),customComponent:tt,bindPath:"motor"})],D.prototype,"motor",2);D=w([F({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],D);var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,V=(o,e,t,i)=>{for(var n=i>1?void 0:i?st(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&nt(e,t,n),n};let T=class extends v{constructor(e,t){super(e,t);p(this,"spring",10);p(this,"damper",.2);p(this,"minDistance",0);p(this,"maxDistance",0);p(this,"tolerance",.025)}};V([y(),m({label:r("physics.spring-joint.spring.title"),type:h.Number,bindPath:"spring"})],T.prototype,"spring",2);V([y(),m({label:r("physics.spring-joint.damper.title"),type:h.Number,bindPath:"damper"})],T.prototype,"damper",2);V([y(),m({label:r("physics.spring-joint.min-distance.title"),type:h.Number,bindPath:"minDistance"})],T.prototype,"minDistance",2);V([y(),m({label:r("physics.spring-joint.max-distance.title"),type:h.Number,bindPath:"maxDistance"})],T.prototype,"maxDistance",2);V([y(),m({label:r("physics.spring-joint.tolerance.title"),type:h.Number,bindPath:"tolerance"})],T.prototype,"tolerance",2);T=V([F({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:Z.AutoAdd}})],T);class rt extends Ce{constructor(){super(...arguments);p(this,"_isPlaying",!1)}onPlay(t){this._isPlaying=t,this._toggleAll(t)}onAddComponent(t){!this._isPlaying&&(t instanceof Q||t instanceof K)&&(t.enabled=!1)}_toggleAll(t){var a;const i=(a=this.engine.sceneManager.activeScene)==null?void 0:a.rootEntities;if(!i)return;const n=[],s=[];i.forEach(d=>{d.getComponentsIncludeChildren(Q,n),d.getComponentsIncludeChildren(K,s)}),n.forEach(d=>{d.enabled=t}),s.forEach(d=>{d.enabled=t})}}var at=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,ct=(o,e,t,i)=>{for(var n=i>1?void 0:i?lt(e,t):e,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&at(e,t,n),n};let ne=class{constructor(){p(this,"script")}init(){this.script=xe.addScript(rt)}};ne=ct([Se({type:"physicsStore"})],ne);export{M as C,g as D,oe as F,D as H,ne as P,te as S,T as a};
|
|
@@ -1 +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-b126bb6b.js";import"./index-c8ed2a45.js";import{c as b}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{L as u}from"./LightBaseComponent-4cfc9f48.js";var P=Object.defineProperty,d=Object.getOwnPropertyDescriptor,l=(o,t,e,p)=>{for(var n=p>1?void 0:p?d(t,e):t,i=o.length-1,r;i>=0;i--)(r=o[i])&&(n=(p?r(t,e,n):r(n))||n);return p&&n&&P(t,e,n),n};let s=class extends u{constructor(t,e){super(t,e);a(this,"distance",60)}};l([f(),h({type:g.Number,bindPath:"distance",label:"light.point.distance.label",info:"light.point.distance.info"})],s.prototype,"distance",2);s=l([b({type:"PointLight",componentsMenu:{group:"light",label:"component.light.point.title"}})],s);export{s as PointLightComponent};
|
|
@@ -1,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,
|
|
1
|
+
var R=Object.defineProperty;var $=(e,s,o)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o;var x=(e,s,o)=>($(e,typeof s!="symbol"?s+"":s,o),o);import{aM as _,av as l,aP as q,e as u,aw as G,aI as w,df as J,aL as A,aJ as N,dg as z,dh as Q,di as W,dj as H,bm as K,dk as U,dl as X,dm as Y,bA as Z,q as ee,dn as te,dp as se,dq as oe,bk as re,t as ne,dr as ae,ds as ce,dt as le,cn as ie,du as fe,dv as pe,bI as me,E as ue,a as T,s as C,p as k,C as D,l as be,g as de}from"./index-b126bb6b.js";import{u as he}from"./index-c8ed2a45.js";import{c as ye}from"./Component-398551a0.js";import"./postmen-3b48c572.js";import{I as ge}from"./IconPlus-b3ed4c04.js";import{D as Pe,M as je}from"./Menu-36c201c0.js";import{c as B}from"./createReactComponent-baa41397.js";import{A as xe,a as Ee}from"./Accordion-4afac60c.js";/**
|
|
2
2
|
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -0,0 +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,e0 as be,e1 as Je,aJ as Ie,aK as Ge,av as O,bA as We,q as he,aN as Qe,aw as He,e2 as Xe,C as Ye,bE as Ze,e3 as Ee,e4 as et,e5 as W,e6 as tt,e7 as nt,e8 as st,bX as rt,e as J,e9 as ge,ea as ot,eb as it,ec as ct,ed as at,ee as dt,ef as ut,eg as ft,eh as lt,ei as ht,ej as pt,ek as mt,el as yt,em as we,en as St,bV as _e,eo as ne,ep as Pe,eq as bt,er as It,es as Et,et as gt,K as Ce,m as wt,aT as _t,x as Pt,aC as ke,n as Ct,dM as Rt,eu as $t}from"./index-b126bb6b.js";import{T as vt}from"./TaskQueue-05c94a4d.js";import{u as Re,I as Tt}from"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import{A as At}from"./AssetViewer-8338dfe1.js";function xt(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 T(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 Ot(o){return o.entities.map(e=>e.id)}function ze(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 Ft(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 kt(o,e,t){var r,i,c;if(!t)return T(o);const n=T(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 jt(o,e,t){if(!t||Object.keys(t).length===0)return T(o);const n=T(o),s=n.components[je(n,e)];return s.props=Ue(s.props??{},t),n}function zt(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",Ot(o),e.entityIds),$e("component",ze(o),e.componentIds);const t=T(o),n=t.entities[Q(t,e.parentSourceEntityId)],s=Mt(e),r=Ft(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=T(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 m=0;m<r.length;m+=1)if(r[m].parent===e.parentSourceEntityId){if(c===i){a=m;break}c+=1,a=m+1}const d=structuredClone(e.entity),u=d.id??`${e.instanceSourceEntityId}:added:${r.length}`;return d.id=u,r.splice(a,0,{id:u,parent:e.parentSourceEntityId,entity:d}),s.addedEntities=r,t}function Nt(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=T(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 Kt(o,e,t,n){if(ze(o).includes(t))throw new Error(`Prefab source component id "${t}" already exists`);const s=T(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=T(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 Lt(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 F(o){return o.entities.map(e=>e.id)}function B(o){return o.components.map(e=>e.id)}function Be(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 qt(o,e){var n;const t=Be(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 Te(o,e,t){var s,r,i;const n=Be(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 D(o,e,t,n,s){if(o!=null){if(Array.isArray(o)){o.forEach((r,i)=>D(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))D(i,e,t,`${n}.${r}`,s)}}}function Ne(o,e,t,n,s){var r;D(o.props,e,t,`${n}.props`,s),(r=o.calls)==null||r.forEach((i,c)=>D(i,e,t,`${n}.calls[${c}]`,s))}function Ke(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)=>Ke(a,e,t,`${n}.children[${d}]`,s)),Ve((c=o.instance)==null?void 0:c.overrides,e,t,`${n}.instance.overrides`,s)}function Ve(o,e,t,n,s){var r,i,c;(r=o==null?void 0:o.componentProps)==null||r.forEach((a,d)=>D(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)=>Ke(a.entity,e,t,`${n}.addedEntities[${d}].entity`,s))}function Ut(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>";D(i.props,e,c,`components.${i.id}.props`,t),(s=i.calls)==null||s.forEach((a,d)=>D(a,e,c,`components.${i.id}.calls[${d}]`,t))}for(const i of o.entities)Ve((r=i.instance)==null?void 0:r.overrides,e,i.id,`entities.${i.id}.instance.overrides`,t);return t}function Jt(o,e){const t=Ut(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 Gt(o,e){switch(e.kind){case"add-source-entity":se("entity",F(o),e.sourceEntityIds);return;case"remove-source-entity":G("entity",F(o),[e.sourceEntityId]);return;case"add-source-component":se("component",B(o),[e.sourceComponentId]);return;case"remove-source-component":G("component",B(o),[e.sourceComponentId]),Jt(o,e.sourceComponentId);return;case"add-nested-instance-entity":G("entity",F(o),[e.instanceSourceEntityId]),qt(o,e.instanceSourceEntityId);return}}function Wt(o,e,t){switch(t.kind){case"add-source-entity":G("entity",F(e),t.sourceEntityIds);return;case"remove-source-entity":se("entity",F(e),[t.sourceEntityId]);return;case"add-source-component":G("component",B(e),[t.sourceComponentId]);return;case"remove-source-component":se("component",B(e),[t.sourceComponentId]);return;case"add-nested-instance-entity":{if(!ve(F(o),F(e))||!ve(B(o),B(e)))throw new Error("Prefab source edit add-nested-instance-entity must not change source entity or component ids");const n=Te(o,t.instanceSourceEntityId,t.parentSourceEntityId);if(Te(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){Lt(o.intent),be(o.prefabFile),Gt(o.prefabFile,o.intent);const e=o.mutation(o.prefabFile);return be(e),Wt(o.prefabFile,e,o.intent),e}function Qt(o,e){return H({prefabFile:o,intent:{kind:"add-source-entity",sourceEntityIds:e.entityIds},mutation:t=>zt(t,e)})}function Ht(o,e){return H({prefabFile:o,intent:{kind:"add-nested-instance-entity",instanceSourceEntityId:e.instanceSourceEntityId,parentSourceEntityId:e.parentSourceEntityId},mutation:t=>Bt(t,e)})}function Xt(o,e){return H({prefabFile:o,intent:{kind:"remove-source-entity",sourceEntityId:e},mutation:t=>Nt(t,e)})}function Yt(o,e){return H({prefabFile:o,intent:{kind:"add-source-component",sourceComponentId:e.sourceComponentId},mutation:t=>Kt(t,e.sourceEntityId,e.sourceComponentId,e.component)})}function Zt(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 en=Ie(({asset:o})=>{const{dependentAssets:e}=o,{configDataStore:t}=Re(),{t:n}=Ge(),s=Ie(({dependentAssetInfo:r})=>{const{assetStore:i}=Re(),c=Object.values(i.assets).filter(u=>{const l=u.getMetaConfig().type,m=u.id===r.id,h=u.id===o.id,f=!m&&!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 O.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 O.jsxs(O.Fragment,{children:[O.jsx(Qe,{title:n("prefab.inspector.basic-info"),defaultOpen:!0,children:t.isBuc&&O.jsx(He,{label:n("prefab.inspector.url")})}),O.jsx(Xe,{label:n("prefab.inspector.dependent-assets"),children:e.map((r,i)=>O.jsx(s,{dependentAssetInfo:r},`${r.id}-${i}`))})]})}),tn={asset:{version:"2.0"},root:"defaultPrefab",entities:[{id:"defaultPrefab",name:"prefab"}],components:[]};class nn 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,Ee.StopEmittingAndClear),c.generator.main.simulationSpeed=1,c.generator.play()})}stopViewAsset(){super.stopViewAsset(),this._particles.forEach(t=>{t.generator.stop(!1,Ee.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 Ae(o,e,t){return de(o,e,t)}function sn(o,e,t){const n=et(t),s=e.ref??e.id;if(typeof s!="string"||s.length===0)throw new Error(`[SceneV2] Unable to replace prefab asset ref "${e.id}": missing old source ref`);let r=Ae(o,s,n);return s!==e.id&&(r=Ae(r,e.id,n)),r}function rn(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 on(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 Oe(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:on(o,e,r),type:i.type,schema:i}})}function Me(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 cn(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 an(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 dn(o){var a,d,u,l,m,h,f,y;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=((m=(l=(u=o.normalized)==null?void 0:u.entities)==null?void 0:l[o.sceneChild.id])==null?void 0:m.instance)??o.sceneChild.instance,r=s==null?void 0:s.bindingId,i=r?(y=(f=(h=o.normalized)==null?void 0:h.prefab)==null?void 0:f.bindings)==null?void 0:y[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 un(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 fn(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 ln(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 hn(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 pn(o){var c,a,d,u,l,m;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"?st(o.schema.script.$ref):void 0);s&&(n.refId=s);const r=(t==null?void 0:t.scriptKey)??((u=o.schema.script)==null?void 0:u.key);r&&(n.scriptKey=r);const i=(l=t==null?void 0:t.calls)!=null&&l.length?structuredClone(t.calls):(m=o.schema.calls)!=null&&m.length?o.convertSourceRefsToDomainRefs(structuredClone(o.schema.calls)):void 0;return i!=null&&i.length&&(n.calls=i),n}function mn(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 yn(o){const{assetId:e,prefabFile:t,sourceRoot:n,sceneRoot:s,normalized:r}=o,i=[],c=[],a=new Map,d=new Map,u=rn(e,t),l=y=>{var I,_;const p=((_=(I=r==null?void 0:r.entities)==null?void 0:I[y.id])==null?void 0:_.instance)??y.instance;return(p==null?void 0:p.role)==="added"},m=(y,p,I,_)=>{var q,ee,te,U;if(l(I))return;const P=N(e,t,y),g=k(e,t,y),A=W(g);i.push({sceneEntityId:I.id,sourceEntityId:P,role:_}),a.set(P,I.id);const K=Oe(e,t,y),Y=I.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),E=cn(K,R,b,w);if(!E){if(!A)throw new Error(`Prefab asset "${e}" live scene component "${b.id}" on source entity "${P}" cannot be matched to a prefab source component.`);continue}R.add(E.key),c.push({sceneEntityId:I.id,sceneComponentId:b.id,sourceComponentKey:E.key});const $=d.get(P)??new Map;$.set(E.key,b.id),d.set(P,$)}const z=xe(e,t,y),Z=(p==null?void 0:p.children)??[],x=I.children??[],V=new Set,L=new Set;for(let b=0;b<z.length;b++){const S=z[b],w=N(e,t,S),E=Me(e,t,S,Z,V);E!=null&&E.id&&V.add(E.id);const $=x.find(v=>{var me,ye,Se;if(L.has(v.id)||l(v))return!1;if(v.id===w||E!=null&&E.id&&v.id===E.id||dn({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||(E==null?void 0:E.id)&&pe===E.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 "${P}".`)}L.add($.id),m(S,E,$,"linked")}},h={},f=(y,p,I,_)=>{const P=k(e,t,y),g=N(e,t,y),A={},K=Oe(e,t,y),Y=new Set;K.forEach(b=>{var $;const S=an(b,p,d.get(g),Y);if(S!=null&&S.ignoreToJSON)return;S!=null&&S.id&&Y.add(S.id);const w=typeof(S==null?void 0:S.toJSON)=="function"?S.toJSON():b.schema,E=($=d.get(g))==null?void 0:$.get(b.key);if(!E&&!mn({sourceEntityId:g,sourceComponentKey:b.key,sceneEntityIdBySource:a,allowMissingSceneComponentSourceKeys:o.allowMissingSceneComponentSourceKeys}))throw new Error(`Prefab asset "${e}" source component "${b.key}" on source entity "${g}" cannot be matched to live scene component.`);A[b.key]={sceneComponentId:E,type:w.type??(S==null?void 0:S.type),...pn({component:S,schema:w,sceneComponentId:E,normalized:r,convertSourceRefsToDomainRefs:o.convertSourceRefsToDomainRefs}),props:o.collectComponentProps(S,w)}});const R=un({assetId:e,prefabFile:t,sourceIndex:y,sourceEntityId:g,resolveInstanceAsset:o.resolveInstanceAsset}),z=R==null?void 0:R.kind,Z=tt({sourceEntity:P,fallbackSourceEntityId:g,instanceAssetKind:z,bindingSourceRootEntityId:fn(p,r)??(R==null?void 0:R.sourceRootEntityId)}),x=nt(P,g,{...typeof Z=="string"?{rootOverrideTarget:Z}:{}}),V=hn(p,x.layer,o.combineLayers),L=(p==null?void 0:p.isLocked)??x.isLocked,q=xe(e,t,y),ee=q.map(b=>N(e,t,b));h[g]={sceneEntityId:a.get(g),parentSourceEntityId:I,childSourceEntityIds:ee,childIndex:_,...z?{instanceAssetKind:z}:{},name:(p==null?void 0:p.name)??x.name,isActive:(p==null?void 0:p.isActive)??x.isActive,...V!==void 0?{layer:V}:{},...L!==void 0?{isLocked:L}:{},transform:ln(p,x.transform),components:A};const te=(p==null?void 0:p.children)??[],U=new Set;q.forEach((b,S)=>{const w=Me(e,t,b,te,U);w!=null&&w.id&&U.add(w.id),f(b,w,g,S)})};return m(u,n,s,"root"),f(u,n,null,0),{entityMappings:i,componentMappings:c,sourceEntitySnapshots:h}}class Sn{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 bn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,X=(o,e,t,n)=>{for(var s=n>1?void 0:n?In(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&&bn(e,t,s),s};const M=Rt("PrefabAsset"),Fe=new $t("PrefabAsset"),ue=[0,0,0],fe=[0,0,0],le=[1,1,1];function De(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 En(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 Tt{constructor(e){super(e);C(this,"acceptDragLayer",he.Entity);C(this,"_entityManager");C(this,"_contentQueue",new vt);C(this,"prefabFile",null);C(this,"dependentAssets",[]);C(this,"_skipInitUpdateContent",!1);this._entityManager=new ct(e)}static async createByEntity(e){var t,n,s;if(e.isPrefabSubEntity||e.isGLTFSubEntity){rt.error(J("prefab.error.create-from-sub"));return}ge()&&ot();try{Fe.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{ge()&&it()}}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=at(await e.text()),this.dependentAssets=n,this._skipInitUpdateContent){this._skipInitUpdateContent=!1;return}await this._updateContent()}async initByCreation(){return this.prefabFile=tn,this._skipInitUpdateContent=!0,this.getMainData()}getMainData(){return dt(this._requirePrefabSourceFile("serializing prefab main data"))}async updateByEntity(e,t=!1,n){Fe.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;ut(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 Sn({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=>kt(s,e,t),n)}async applyComponentPropsOverride(e,t,n){const s=t?this._componentPropsOverrideToSourcePatch(e,t):void 0;await this._editPrefabSource(r=>jt(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=>Qt(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=>Ht(c,{instanceSourceEntityId:e,parentSourceEntityId:t,index:n,entity:i}),{...r,structuralDeltaMode:"domain-source-replace"})}async applyRemovedEntityOverride(e,t){await this._editPrefabSource(n=>Xt(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}async applyAddedComponentOverride(e,t,n,s){await this._editPrefabSource(r=>Yt(r,{sourceEntityId:e,sourceComponentId:t,component:this._componentSchemaToSourceRefs(n)}),{...s,structuralDeltaMode:"domain-source-replace"})}async applyRemovedComponentOverride(e,t){await this._editPrefabSource(n=>Zt(n,e),{...t,structuralDeltaMode:"domain-source-replace"})}replaceDependentAsset(e,t){this.prefabFile=sn(this.prefabFile,e,t.id),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 n,s;const t=(s=(n=this.root.domainStore)==null?void 0:n.getNormalizedState)==null?void 0:s.call(n);return new ft(e,r=>{var c;const i=(c=t==null?void 0:t.components)==null?void 0:c[r];if(i)return{refId:i.refId,scriptKey:i.scriptKey,calls:i.calls}})}_createSourceRefCodec(){const e=this.root.assetStore;return lt({resolveAssetKind:t=>{var s,r,i,c;const n=(c=(i=(r=(s=e.assets)==null?void 0:s[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){return ht(e)}_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){return this._createSourceRefCodec().domainToSource(e,"prefab script")}_findSourceComponentModel(e){var n,s;const t=[...((n=this._entityManager)==null?void 0:n.rootEntities)??[]];for(;t.length>0;){const 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=pt(n,s),i=mt(n,t,s);return yt(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(){var n;const e=this.root.sceneStore,t=this._queryInstanceEntityIdsFromDomain();for(const s of t){const r=(n=e.getEntityModel)==null?void 0:n.call(e,s);r==null||r.unpackPrefab()}super.unpackAllInstances()}async instantiate(e,t,n){var m;const s=structuredClone(this.prefabFile),r=St(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&&En(c,t);const a=this._assignSceneInstanceIds(s,i,n==null?void 0:n.expectedRootId),d=await e.hydrateSourceV2LocalEntities(s,{resolveAssetKind:h=>{var y,p,I,_;const f=(_=(I=(p=(y=this.root.assetStore.assets)==null?void 0:y[h])==null?void 0:p.getMetaConfig)==null?void 0:I.call(p))==null?void 0:_.type;return f==="Prefab"||f==="glTF"?f:void 0},resolvePrefabSourceFile:h=>{var y,p,I,_;const f=(p=(y=this.root.assetStore).getAsset)==null?void 0:p.call(y,h);return((_=(I=f==null?void 0:f.getMetaConfig)==null?void 0:I.call(f))==null?void 0:_.type)==="Prefab"?f.prefabFile:void 0},clearExisting:!1,registerDomain:(n==null?void 0:n.deferDomainBinding)!==!0,deferredInstanceBindings:(n==null?void 0:n.deferredInstanceBindings)??[]}),u=(m=s.entities[i])==null?void 0:m.id,l=(u?e.entities.get(u):void 0)??d[0];if(await this._ensureSourceEntityManagerReady(),l.convertToPrefabRefEntity(),(n==null?void 0:n.deferDomainBinding)!==!0&&e.isDomainScoped&&!this.root.domainStore.state.entities[l.id]&&e.registerEntityTreeInDomain(l,null),this.addInstance(l,n),n!=null&&n.deferDomainBinding){if(!n.deferredInstanceBindings)throw new Error(`PrefabAsset "${this.id}" cannot defer domain binding without a deferred binding queue.`);return n.deferredInstanceBindings.push(()=>this._bindInstantiatedEntity(l,{...n,...a})),l}return this._bindInstantiatedEntity(l,{...n,...a}),l}_assignSceneInstanceIds(e,t,n){const s=new Map;e.entities.forEach((i,c)=>{s.set(i.id,n&&c===t?n:_e())});const r=new Map;return e.components.forEach(i=>{r.set(i.id,_e())}),this._remapLocalHydrationIds(e,s,r),{sourceEntityIdBySceneId:De(s),sourceComponentKeyBySceneComponentId:De(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 m=1;for(const h of r){const f=s.bindings[h];f&&f.sourceRevision>m&&(m=f.sourceRevision)}this.root.prefabFacade.bindExistingInstance({assetId:this.id,instanceRootEntityId:e.id,sourceRevision:m,entityMappings:d,componentMappings:u,sourceEntitySnapshots:l,undoable:(t==null?void 0:t.undoable)===!0})}_syncPreservedInstanceStateFromSource(e,t){const n=this.root.domainStore.getNormalizedState(),s=[];for(const[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];Pe(a.transform[h],f)||s.push({op:"replace",path:`${d}/transform/${h}`,value:f})}const m=e.overrides.componentProps[r]??{};for(const[h,f]of Object.entries(i.components)){const y=f.sceneComponentId;if(!y)continue;const p=n.components[y];if(!p)continue;const I=`${d}/components/${ne(y)}`,_=m[h]??{},P=f.props??{};for(const[g,A]of Object.entries(P)){if(Object.prototype.hasOwnProperty.call(_,g))continue;const K=`${I}/props/${ne(g)}`;Pe(p.props[g],A)||s.push({op:Object.prototype.hasOwnProperty.call(p.props,g)?"replace":"add",path:K,value:A})}for(const g of Object.keys(p.props))Object.prototype.hasOwnProperty.call(P,g)||Object.prototype.hasOwnProperty.call(_,g)||s.push({op:"remove",path:`${I}/props/${ne(g)}`})}}this.root.domainStore.applySystem(s)}_collectInstanceMappings(e,t,n){var s,r,i;return yn({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 m,h,f;const d=(m=this.root.assetStore.assets)==null?void 0:m[c];if(!d)throw new Error(`Prefab source entity "${a}" references missing instance asset "${c}".`);const u=(f=(h=d.getMetaConfig)==null?void 0:h.call(d))==null?void 0:f.type;if(u!=="Prefab"&&u!=="glTF")throw new Error(`Prefab source entity "${a}" references unsupported instance asset "${c}" of type "${String(u)}".`);const l=d.prefabFile;return{id:d.id,kind:u,...u==="Prefab"&&typeof(l==null?void 0:l.root)=="string"?{sourceRootEntityId:l.root}:{}}},convertSourceRefsToDomainRefs:c=>this._convertSourceRefsToDomainRefs(c),collectComponentProps:(c,a)=>this._collectSnapshotComponentProps(c,a),combineLayers:c=>we(c)})}_requirePrefabSourceFile(e="using prefab source file"){const t=this.prefabFile;if(!t)throw new Error(`Prefab asset "${this.id}" has no source file while ${e}.`);if(!Array.isArray(t.entities))throw new Error(`Prefab asset "${this.id}" source file is missing entity anchors.`);return t}_resolveSourceChildInsertionIndex(e,t,n){var l,m,h;const s=this._requirePrefabSourceFile(),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=((m=n.parentEntity)==null?void 0:m.children)??[],a=c.findIndex(f=>f.id===n.id),d=a>=0?a:Math.min(Math.max(t,0),c.length);let u=0;for(let f=0;f<d;f+=1){const y=(h=c[f])==null?void 0:h.instanceSourceEntityId;y&&i.has(y)&&(u+=1)}return Math.min(Math.max(u,0),i.size)}_collectSnapshotComponentProps(e,t){return e&&Reflect.ownKeys(bt(e)).length>0?this._convertSourceRefsToDomainRefs(It(e)):this._convertSourceRefsToDomainRefs(structuredClone(t.props??{}))}async replaceInstance(e,t,n){var h,f,y,p;const s=t.entities.get(e);if(!s)return null;const r=(h=s==null?void 0:s.engineObject)==null?void 0:h.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=(y=(f=s.root.domainStore.getNormalizedState().entities[e])==null?void 0:f.instance)==null?void 0:y.bindingId,a=[],d=await this.instantiate(t,n!=null&&n.resetRootTransform?void 0:i,{...n!=null&&n.undoable?{undoable:!0}:{},expectedBindingId:c,deferDomainBinding:!0,deferredInstanceBindings:a});d.convertToPrefabRefEntity();const u=((p=t.root)==null?void 0:p.domainStore)??s.root.domainStore,l=t.entities.get(e),m=u.getNormalizedState().entities[e];return!l||!(m!=null&&m.instance)?(d.destroy(),null):(t.isDomainScoped&&!u.state.entities[d.id]&&t.registerEntityTreeInDomain(d,null,void 0,{...i&&!(n!=null&&n.resetRootTransform)?{transform:i}:{},deferInstanceBinding:!0}),a.splice(0).forEach(I=>I()),n!=null&&n.structuralDeltaMode?t.replaceEntity(e,d,{structuralDeltaMode:n.structuralDeltaMode}):t.replaceEntity(e,d),d)}_refreshTrackedInstanceBindings(e){var s;const t=this.root.sceneStore,n=this._queryInstanceEntityIdsFromDomain();for(const r of n){const i=(s=t.getEntityModel)==null?void 0:s.call(t,r);i&&this._bindInstantiatedEntity(i,e)}}_instantiateEngineObject(){return this.engineObject.instantiate()}_onDrop(e,t){if(!t||t.id===this.id)return;this.dropping=!1;const{sceneStore:n,sceneUIStore:s}=this.root,r=Array.from(s.selectedKeys);if(r.length>1)for(let i=0;i<r.length;i++)j.createByEntity(n.getEntityModel(r[i]));else Et({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 xt(this.prefabFile,["$ref"])){if(typeof s!="string"||s===this.id)continue;const r=(n=t.assets)==null?void 0:n[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(){this.root.assetStore,this.dependentAssets=Array.from(this._collectDependentAssetsFromPrefabFile(),e=>({id:e.id,name:e.name,type:e.getMetaConfig().type,ref:e.id}))}_updateContent(e){return this._contentQueue.enqueue(async()=>{try{await this._updateContentInternal(e)}catch(t){if(t instanceof Error&&t.message==="cancelled")return;throw M.error("_updateContent failed:",t),t}})}async _updateContentInternal(e){const{url:t,dependentAssets:n}=this,s=(e==null?void 0:e.persist)!==!1;await Promise.all(n.map(a=>this.root.assetStore.getAssetByRef({refId:a.id}))),await this._entityManager.init(this);const r=this.engineObject;if(r){this.root.assetStore.engineObjectToAssetMap.delete(r);try{r.destroy()}catch(a){M.warn("failed to destroy oldEngineObject:",a)}}const i=new gt(this.engine,t);this.bindEngineObject(i),this.root.assetStore.engineObjectToAssetMap.set(i,this);let c=this._entityManager.rootEntities[0];if(c||(c=this._entityManager.createEntity("prefab","defaultPrefab"),c.bindEngineObject(new Ce(this.engine,"prefab")),M.error(`The prefab which id is ${this.id} is broken, use default prefab instead.`)),c.engineObject||(M.warn("rootEntity engineObject is null, binding new Entity"),c.bindEngineObject(new Ce(this.engine,"prefab"))),this._markAsTemplate(c),i._root=c.engineObject,c.once("delete",()=>{M.error(`The prefab which id is ${this.id} is broken.`),this._updateContent().catch(a=>{M.error(`Failed to rebuild broken prefab which id is ${this.id}.`,a)})}),this._updateDragTempEntity(),this.updateThumbnail(),s&&(this.root.assetFacade.persistAssetMeta(this.id),this.root.assetFacade.persistAssetMain(this.id)),(e==null?void 0:e.replaceInstances)!==!1){const a=new Set((e==null?void 0:e.resetRootTransformBindingIds)??[]),d=e!=null&&e.undoable?{undoable:!0}:void 0,u=this.root.sceneStore,l=this._queryInstanceEntityIdsFromDomain();await Promise.all(l.map(m=>{var f,y;const h=(y=(f=this.root.domainStore.getNormalizedState().entities[m])==null?void 0:f.instance)==null?void 0:y.bindingId;return this.replaceInstance(m,u,{...d??{},resetRootTransform:h!==void 0&&a.has(h),...e!=null&&e.structuralDeltaMode?{structuralDeltaMode:e.structuralDeltaMode}:{}})}))}else{const a={...e!=null&&e.undoable?{undoable:!0}:{},syncPreservedInstanceState:!0};this._refreshTrackedInstanceBindings(a)}this._rebaseInstanceRevisions()}_markAsTemplate(e){const t=e.engineObject;if(!t){M.warn("_markAsTemplate: engineObject is null",{prefabId:this.id,entityModelId:e.id});return}const n=t;n._templateResource||n._markAsTemplate(this.engineObject),e.selfChildren.forEach(s=>{this._markAsTemplate(s)})}};X([wt()],j.prototype,"prefabFile",2);X([_t(),Pt],j.prototype,"dependentAssets",2);X([ke],j.prototype,"replaceDependentAsset",1);X([ke],j.prototype,"_onDrop",1);j=X([Ct({type:"Prefab",label:J("asset.prefab.title"),extname:"prefab",dragLayer:he.Prefab,customInspector:en,viewer:nn,thumbnail:ae,async bundle(o){return{content:new Blob([o.content],{type:"application/json"})}}})],j);export{j as PrefabAsset};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var wt=Object.defineProperty;var Mt=(M,s,i)=>s in M?wt(M,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):M[s]=i;var A=(M,s,i)=>(Mt(M,typeof s!="symbol"?s+"":s,i),i);import{ai as rt,B as q,bu as Rt,a5 as ut,a6 as dt,a7 as mt,a9 as ft,a3 as G,bv as tt,a4 as et,bw as Pt,j as It,bx as At,K as Ht,y as Vt,p as _,e as b,C as B,t as _t,m as N,n as Bt,o as Nt,q as Tt}from"./index-c3dec278.js";import"./index-cdbb2f4d.js";import"./postmen-2853c0e6.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Dt}from"./bundlers-9b0d37fc.js";import{M as Et}from"./MeshThumbnail-07ffa076.js";const z=class z{static createSphere(s=.5,i=18){i=Math.max(2,Math.floor(i));const o=i+1,e=o*o,c=i*i,l=z._generateIndices(e,c*6),R=Math.PI,t=R*2,a=1/o,y=1/i,m=8,h=new Float32Array(e*m);for(let x=0;x<e;++x){const u=x%o,d=x*a|0,p=u*y,n=d*y,w=p*t,f=n*R,v=Math.sin(f),I=-s*Math.cos(w)*v,P=s*Math.cos(f),S=s*Math.sin(w)*v;let r=x*m;h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=p,h[r++]=n}let C=0;for(let x=0;x<c;++x){const u=x%i,p=(x*y|0)*o+u,n=p+1,w=p+o,f=w+1;l[C++]=n,l[C++]=p,l[C++]=f,l[C++]=p,l[C++]=w,l[C++]=f}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:l,vertices:h,bounds:g}}static createCuboid(s=1,i=1,o=1){const e=s/2,c=i/2,l=o/2,R=8,t=new Float32Array(24*R);t[0]=-e,t[1]=c,t[2]=-l,t[6]=0,t[7]=0,t[8]=e,t[9]=c,t[10]=-l,t[14]=1,t[15]=0,t[16]=e,t[17]=c,t[18]=l,t[22]=1,t[23]=1,t[24]=-e,t[25]=c,t[26]=l,t[30]=0,t[31]=1;for(let m=0;m<4;m++){let h=R*m+3;t[h++]=0,t[h++]=1,t[h++]=0}t[32]=-e,t[33]=-c,t[34]=-l,t[38]=0,t[39]=1,t[40]=e,t[41]=-c,t[42]=-l,t[46]=1,t[47]=1,t[48]=e,t[49]=-c,t[50]=l,t[54]=1,t[55]=0,t[56]=-e,t[57]=-c,t[58]=l,t[62]=0,t[63]=0;for(let m=0;m<4;m++){let h=R*m+35;t[h++]=0,t[h++]=-1,t[h++]=0}t[64]=-e,t[65]=c,t[66]=-l,t[70]=0,t[71]=0,t[72]=-e,t[73]=c,t[74]=l,t[78]=1,t[79]=0,t[80]=-e,t[81]=-c,t[82]=l,t[86]=1,t[87]=1,t[88]=-e,t[89]=-c,t[90]=-l,t[94]=0,t[95]=1;for(let m=0;m<4;m++){let h=R*m+67;t[h++]=-1,t[h++]=0,t[h++]=0}t[96]=e,t[97]=c,t[98]=-l,t[102]=1,t[103]=0,t[104]=e,t[105]=c,t[106]=l,t[110]=0,t[111]=0,t[112]=e,t[113]=-c,t[114]=l,t[118]=0,t[119]=1,t[120]=e,t[121]=-c,t[122]=-l,t[126]=1,t[127]=1;for(let m=0;m<4;m++){let h=R*m+99;t[h++]=1,t[h++]=0,t[h++]=0}t[128]=-e,t[129]=c,t[130]=l,t[134]=0,t[135]=0,t[136]=e,t[137]=c,t[138]=l,t[142]=1,t[143]=0,t[144]=e,t[145]=-c,t[146]=l,t[150]=1,t[151]=1,t[152]=-e,t[153]=-c,t[154]=l,t[158]=0,t[159]=1;for(let m=0;m<4;m++){let h=R*m+131;t[h++]=0,t[h++]=0,t[h++]=1}t[160]=-e,t[161]=c,t[162]=-l,t[166]=1,t[167]=0,t[168]=e,t[169]=c,t[170]=-l,t[174]=0,t[175]=0,t[176]=e,t[177]=-c,t[178]=-l,t[182]=0,t[183]=1,t[184]=-e,t[185]=-c,t[186]=-l,t[190]=1,t[191]=1;for(let m=0;m<4;m++){let h=R*m+163;t[h++]=0,t[h++]=0,t[h++]=-1}const a=new Uint16Array(36);a[0]=0,a[1]=2,a[2]=1,a[3]=2,a[4]=0,a[5]=3,a[6]=4,a[7]=6,a[8]=7,a[9]=6,a[10]=4,a[11]=5,a[12]=8,a[13]=10,a[14]=9,a[15]=10,a[16]=8,a[17]=11,a[18]=12,a[19]=14,a[20]=15,a[21]=14,a[22]=12,a[23]=13,a[24]=16,a[25]=18,a[26]=17,a[27]=18,a[28]=16,a[29]=19,a[30]=20,a[31]=22,a[32]=23,a[33]=22,a[34]=20,a[35]=21;const y=new q;return y.min.set(-e,-c,-l),y.max.set(e,c,l),{vertices:t,bounds:y,indices:a}}static createPlane(s=1,i=1,o=1,e=1){o=Math.max(1,Math.floor(o)),e=Math.max(1,Math.floor(e));const c=o+1,l=e+1,R=s/2,t=i/2,a=s/o,y=i/e,m=c*l,h=e*o,C=z._generateIndices(m,h*6),g=1/c,x=1/o,u=1/e,d=8,p=new Float32Array(m*d);for(let f=0;f<m;++f){const v=f%c,I=f*g|0;let P=f*d;p[P++]=v*a-R,p[P++]=0,p[P++]=I*y-t,p[P++]=0,p[P++]=1,p[P++]=0,p[P++]=v*x,p[P++]=I*u}let n=0;for(let f=0;f<h;++f){const v=f%o,P=(f*x|0)*c+v,S=P+1,r=P+c,D=r+1;C[n++]=P,C[n++]=r,C[n++]=S,C[n++]=r,C[n++]=D,C[n++]=S}const w=new q;return w.min.set(-R,0,-t),w.max.set(R,0,t),{bounds:w,vertices:p,indices:C}}static createCylinder(s=.5,i=.5,o=2,e=20,c=1){e=Math.floor(e),c=Math.floor(c);const l=e+1,R=c+1,t=o*.5,a=o/c,y=l*R,m=e*c,h=e*2,C=y+2+h,g=z._generateIndices(C,m*6+h*3),x=1/l,u=1/e,d=1/c,p=8,n=new Float32Array(C*p);let w=0;const f=Math.PI,v=Math.PI*2,I=i-s,P=I/o,S=I/c;for(let F=0;F<y;++F){const Z=F%l,W=F*x|0,O=Z*u,J=W*d,$=f+O*v,nt=Math.sin($),pt=Math.cos($),ht=i-W*S,xt=ht*nt,vt=W*a-t,Ct=ht*pt;let L=F*p;n[L++]=xt,n[L++]=vt,n[L++]=Ct,n[L++]=nt,n[L++]=P,n[L++]=pt,n[L++]=O,n[L++]=1-J}for(let F=0;F<m;++F){const Z=F%e,O=(F*u|0)*l+Z,J=O+1,$=O+l,nt=$+1;g[w++]=J,g[w++]=$,g[w++]=O,g[w++]=J,g[w++]=nt,g[w++]=$}let r=y*p;n[r++]=0,n[r++]=-t,n[r++]=0,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=.5,n[r++]=.5,n[r++]=0,n[r++]=t,n[r++]=0,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=.5,n[r++]=.5,r=(y+2)*p;const D=1/(s*2),j=1/(i*2),E=l*c;for(let F=0;F<e;++F){const Z=F*p;let W=n[Z],O=n[Z+2];n[r++]=W,n[r++]=-t,n[r++]=O,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=W*j+.5,n[r++]=.5-O*j;const J=(F+E)*p;W=n[J],O=n[J+2],n[r++]=W,n[r++]=t,n[r++]=O,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=W*D+.5,n[r++]=.5-O*D}const Y=y+1,X=y+2,U=X+1;for(let F=0;F<e;++F){const Z=F*2,W=F===e-1?0:Z+2;g[w++]=y,g[w++]=X+W,g[w++]=X+Z,g[w++]=Y,g[w++]=U+Z,g[w++]=U+W}const Q=new q,K=Math.max(s,i);return Q.min.set(-K,-t,-K),Q.max.set(K,t,K),{bounds:Q,vertices:n,indices:g}}static createTorus(s=.5,i=.1,o=30,e=30,c=360){o=Math.floor(o),e=Math.floor(e);const l=(o+1)*(e+1),R=o*e,t=z._generateIndices(l,R*6),a=8,y=new Float32Array(l*a);c=c/180*Math.PI;let m=0;const h=z._tempVec30;for(let x=0;x<=o;x++)for(let u=0;u<=e;u++){const d=u/e*c,p=x/o*Math.PI*2,n=Math.cos(p),w=Math.sin(p),f=Math.cos(d),v=Math.sin(d),I=(s+i*n)*f,P=(s+i*n)*v,S=i*w;y[m++]=I,y[m++]=P,y[m++]=S;const r=s*f,D=s*v;h.set(I-r,P-D,S).normalize(),y[m++]=h.x,y[m++]=h.y,y[m++]=h.z,y[m++]=u/e,y[m++]=x/o}m=0;for(let x=1;x<=o;x++)for(let u=1;u<=e;u++){const d=(e+1)*x+u-1,p=(e+1)*(x-1)+u-1,n=(e+1)*(x-1)+u,w=(e+1)*x+u;t[m++]=d,t[m++]=p,t[m++]=w,t[m++]=p,t[m++]=n,t[m++]=w}const C=new q,g=s+i;return C.min.set(-g,-g,-i),C.max.set(g,g,i),{bounds:C,vertices:y,indices:t}}static createCone(s=.5,i=2,o=20,e=1){o=Math.floor(o),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=a+1+o,h=z._generateIndices(m,y*6+o*3),C=1/c,g=1/o,x=1/e,u=8,d=new Float32Array(m*8);let p=0;const n=Math.PI,w=Math.PI*2,f=s/i;for(let r=0;r<a;++r){const D=r%c,j=r*C|0,E=D*g,Y=j*x,X=n+E*w,U=Math.sin(X),Q=Math.cos(X),K=s-j*s,F=K*U,Z=j*t-R,W=K*Q;let O=r*u;d[O++]=F,d[O++]=Z,d[O++]=W,d[O++]=U,d[O++]=f,d[O++]=Q,d[O++]=E,d[O++]=1-Y}for(let r=0;r<y;++r){const D=r%o,E=(r*g|0)*c+D,Y=E+1,X=E+c,U=X+1;h[p++]=Y,h[p++]=X,h[p++]=E,h[p++]=Y,h[p++]=U,h[p++]=X}let v=a*u;d[v++]=0,d[v++]=-R,d[v++]=0,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=.5,d[v++]=.5,v=(a+1)*u;const I=1/(s*2);for(let r=0;r<o;++r){const D=d[r*u],j=d[r*u+2];d[v++]=D,d[v++]=-R,d[v++]=j,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=D*I+.5,d[v++]=.5-j*I}const P=a+1;for(let r=0;r<o;++r){const D=r,j=r===o-1?0:D+1;h[p++]=a,h[p++]=P+j,h[p++]=P+D}const S=new q;return S.min.set(-s,-R,-s),S.max.set(s,R,s),{bounds:S,vertices:d,indices:h}}static createCapsule(s=.5,i=2,o=6,e=1){o=Math.max(2,Math.floor(o)),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=c*c,h=o*o,C=a+2*m,g=z._generateIndices(C,(y+2*h)*6),x=1/c,u=1/o,d=1/e,p=Math.PI,n=Math.PI*2,w=8,f=new Float32Array(C*w);let v=0;for(let P=0;P<a;++P){const S=P%c,r=P*x|0,D=S*u,j=r*d,E=p+D*n,Y=Math.sin(E),X=Math.cos(E);let U=P*w;f[U++]=s*Y,f[U++]=r*t-R,f[U++]=s*X,f[U++]=Y,f[U++]=0,f[U++]=X,f[U++]=D,f[U++]=1-j}for(let P=0;P<y;++P){const S=P%o,D=(P*u|0)*c+S,j=D+1,E=D+c,Y=E+1;g[v++]=j,g[v++]=E,g[v++]=D,g[v++]=j,g[v++]=Y,g[v++]=E}z._createCapsuleCap(s,i,o,p,n,a,1,f,g,v),z._createCapsuleCap(s,i,o,p,-n,a+m,-1,f,g,v+6*h);const I=new q;return I.min.set(-s,-s-R,-s),I.max.set(s,s+R,s),{bounds:I,vertices:f,indices:g}}static _generateIndices(s,i){let o=null;return s>65535?o=new Uint32Array(i):o=new Uint16Array(i),o}static _createCapsuleCap(s,i,o,e,c,l,R,t,a,y){const m=o+1,h=i*.5*R,C=m*m,g=o*o,x=1/m,u=1/o,d=8;for(let p=0;p<C;++p){const n=p%m,w=p*x|0,f=n*u,v=w*u,I=e+f*c,P=v*Math.PI*.5,S=Math.sin(P),r=s*Math.sin(I)*S,D=s*Math.cos(P)*R+h,j=s*Math.cos(I)*S;let E=(p+l)*d;t[E++]=r,t[E++]=D,t[E++]=j,t[E++]=r,t[E++]=D-h,t[E++]=j,t[E++]=f,t[E++]=v}for(let p=0;p<g;++p){const n=p%o,f=(p*u|0)*m+n+l,v=f+1,I=f+m,P=I+1;a[y++]=v,a[y++]=f,a[y++]=P,a[y++]=f,a[y++]=I,a[y++]=P}}static createSubdivisionSurfaceSphereData(s=.5,i=3){i=Rt.clamp(Math.floor(i),1,6);const o=new Float32Array(3*(6*Math.pow(4,i)+2)),e=new Float32Array(24*Math.pow(4,i));this._subdiveCatmullClark(i,o,e);const c=o.length/3,l=e.length/4,R=c+Math.pow(2,i+1)-1,t=R+16,a=new Float32Array(t*8),y=this._generateIndices(c,l*6);let m=0;const h={};for(let x=0;x<c;x++){let u=3*x,d=o[u],p=o[u+1],n=o[u+2];const w=1/Math.sqrt(d*d+p*p+n*n);if(d*=w,p*=w,n*=w,u=8*x,a[u]=d*s,a[u+1]=p*s,a[u+2]=n*s,a[u+3]=d,a[u+4]=p,a[u+5]=n,a[u+6]=(Math.PI-Math.atan2(n,d))/(2*Math.PI),a[u+7]=Math.acos(p)/Math.PI,a[u+6]===0){const f=8*(c+m++);a.set(a.subarray(u,u+8),f),a[f+6]=1,h[u/8]=f/8}}let C=0;this._spherePoleIdx=0;for(let x=0;x<l;x++){const u=4*x;let d=e[u],p=e[u+1],n=e[u+2],w=e[u+3];const f=8*d,v=8*p,I=8*n,P=8*w;a[f+2]+a[v+2]+a[I+2]<0&&(a[f+6]===0&&(d=h[d]),a[v+6]===0&&(p=h[p]),a[I+6]===0&&(n=h[n]),a[P+6]===0&&(w=h[w])),y[C]=d,y[C+1]=p,y[C+2]=n,this._generateAndReplacePoleUV(y,a,C,R),y[C+3]=d,y[C+4]=n,y[C+5]=w,this._generateAndReplacePoleUV(y,a,C+3,R),C+=6}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:y,vertices:a,bounds:g}}static _generateAndReplacePoleUV(s,i,o,e){const c=i[8*s[o]+7];if(c===0||c===1){const l=8*s[o],R=8*(e+this._spherePoleIdx);i.set(i.subarray(l,l+8),R),i[R+6]=.5*(i[l+6]+i[8*s[o+1]+6]+i[8*s[o+2]+6]-.5),s[o]=e+this._spherePoleIdx++}}static _subdiveCatmullClark(s,i,o){const e=new Map,c=new Array;i.set(this._sphereSeedPositions),o.set(this._sphereSeedCells);for(let l=0;l<s;l++){const R=6*Math.pow(4,l),t=4*R+2;e.clear(),c.length=0;for(let C=0;C<R;C++){const g=c[C]={facePoint:new rt,adjacentEdges:new Array(4)};for(let x=0;x<4;x++){const u=3*o[4*C+x];g.facePoint.x+=.25*i[u],g.facePoint.y+=.25*i[u+1],g.facePoint.z+=.25*i[u+2]}for(let x=0;x<4;x++){const u=o[4*C+x],d=o[4*C+(x+1)%4],p=Math.min(u,d)*t+Math.max(u,d);if(!e.has(p)){const v={edgePoint:new rt,edgePointIndex:void 0},I=3*u,P=3*d;v.edgePoint.set(.25*(i[I]+i[P]),.25*(i[I+1]+i[P+1]),.25*(i[I+2]+i[P+2])),e.set(p,v)}const n=e.get(p);g.adjacentEdges[x]=n;const w=n.edgePoint,f=g.facePoint;w.x+=.25*f.x,w.y+=.25*f.y,w.z+=.25*f.z}}const a=R+2,y=a+R;let m=0;this._sphereEdgeIdx=0;const h=o.slice(0,4*R);for(let C=0;C<R;C++){const g=c[C];g.facePoint.copyToArray(i,3*(a+C));const x=a+C;let u,d,p;for(let n=0;n<4;n++){const w=h[m++];switch(n){case 0:{const v=g.adjacentEdges[n%4],I=g.adjacentEdges[(n+3)%4];d=this._calculateEdgeIndex(i,v,y),u=this._calculateEdgeIndex(i,I,y),p=u;break}case 1:case 2:{const v=g.adjacentEdges[n%4];u=d,d=this._calculateEdgeIndex(i,v,y);break}case 3:{u=d,d=p;break}}const f=4*(4*C+n);o[f]=w,o[f+1]=d,o[f+2]=x,o[f+3]=u}}}}static _calculateEdgeIndex(s,i,o){if(i.edgePointIndex!==void 0)return i.edgePointIndex;{i.edgePoint.copyToArray(s,3*(o+this._sphereEdgeIdx));const e=o+this._sphereEdgeIdx++;return i.edgePointIndex=e,e}}};A(z,"_tempVec30",new rt),A(z,"_sphereSeedPositions",new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1])),A(z,"_sphereSeedCells",new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1])),A(z,"_sphereEdgeIdx",0),A(z,"_spherePoleIdx",0);let k=z;function Ft(){return[new G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]}function yt(M,s,{vertices:i,indices:o,bounds:e}){const c=new ut(s,dt.VertexBuffer,i,mt.Static),l=new ut(s,dt.IndexBuffer,o,mt.Static);M.setVertexElements(Ft()),M.setIndexBufferBinding(l,o instanceof Uint16Array?ft.UInt16:ft.UInt32),M.setVertexBufferBinding(c,32),M.bounds=e,M.subMesh?M.subMesh.count=o.length:M.addSubMesh(0,o.length)}class St extends Pt{constructor(s,i,o){super(s),this.engine=i,this.generateData=o}restoreContent(){yt(this.resource,this.engine,this.generateData())}}function Ot(M,s,i){s.resourceManager.addContentRestorer(new St(M,s,i))}var jt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,V=(M,s,i,o)=>{for(var e=o>1?void 0:o?Ut(s,i):s,c=M.length-1,l;c>=0;c--)(l=M[c])&&(e=(o?l(s,i,e):l(e))||e);return o&&e&&jt(s,i,e),e},bt=(M=>(M.Sphere="sphere",M.Cuboid="cuboid",M.Plane="plane",M.Cylinder="cylinder",M.Torus="torus",M.Cone="cone",M.Capsule="capsule",M))(bt||{});const gt=M=>M.type==="sphere",it=M=>M.type==="capsule",at=M=>M.type==="cone",lt=M=>M.type==="cuboid",ot=M=>M.type==="cylinder",st=M=>M.type==="torus",ct=M=>M.type==="plane",T=M=>M._updateData();let H=class extends It{constructor(s){super(s);A(this,"type","sphere");A(this,"sphereRadius",.5);A(this,"sphereStep",3);A(this,"capsuleRadius",.5);A(this,"capsuleHeight",2);A(this,"capsuleRadialSegments",6);A(this,"capsuleHeightSegments",1);A(this,"coneRadius",.5);A(this,"coneHeight",2);A(this,"coneRadialSegment",20);A(this,"coneHeightSegment",1);A(this,"cuboidWidth",1);A(this,"cuboidHeight",1);A(this,"cuboidDepth",1);A(this,"cylinderRadiusTop",.5);A(this,"cylinderRadiusBottom",.5);A(this,"cylinderHeight",2);A(this,"cylinderRadialSegment",20);A(this,"cylinderHeightSegment",1);A(this,"planeWidth",1);A(this,"planeHeight",1);A(this,"planeHorizontalSegments",1);A(this,"planeVerticalSegments",1);A(this,"torusRadius",.5);A(this,"torusTubeRadius",.1);A(this,"torusRadialSegments",30);A(this,"torusTubularSegments",30);A(this,"torusArc",360)}async initByCreation(s,i,o){const c=(typeof(o==null?void 0:o.primitiveType)=="string"?o.primitiveType:"").trim().toLowerCase();return{type:{sphere:"sphere",cube:"cuboid",cuboid:"cuboid",cylinder:"cylinder",plane:"plane",capsule:"capsule",cone:"cone",torus:"torus"}[c]??"sphere"}}async initByMain(s,i){const o=JSON.parse(await s.text()),e=this.engine,c=o.type,l=new At(e,c);l.setVertexElements([new G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]);for(const y in o)this[y]=o[y];this.bindEngineObject(l),Ot(l,e,()=>this._generateDataByType(this.type)),this._updateData();const R=new Ht(e,c&&c.charAt(0).toUpperCase()+c.slice(1)),t=R.addComponent(Vt);t.mesh=this.engineObject;const a=await this.root.assetStore.getAssetByRef({refId:"0000200"});t.setMaterial(a.engineObject),this.setDragTempEntity(R)}instantiate(){const s=this.root.sceneStore.createEntity(),i=this.getDragTempEntity();return s.initByEngineObject(i.clone()),s}_updateData(){const s=this.engine,i=this._engineObject;yt(i,s,this._generateDataByType(this.type))}_generateDataByType(s){switch(s){case"sphere":return k.createSubdivisionSurfaceSphereData(this.sphereRadius,this.sphereStep);case"capsule":return k.createCapsule(this.capsuleRadius,this.capsuleHeight,this.capsuleRadialSegments,this.capsuleHeightSegments);case"cone":return k.createCone(this.coneRadius,this.coneHeight,this.coneRadialSegment,this.coneHeightSegment);case"cuboid":return k.createCuboid(this.cuboidWidth,this.cuboidHeight,this.cuboidDepth);case"cylinder":return k.createCylinder(this.cylinderRadiusTop,this.cylinderRadiusBottom,this.cylinderHeight,this.cylinderRadialSegment,this.cylinderHeightSegment);case"plane":return k.createPlane(this.planeWidth,this.planeHeight,this.planeHorizontalSegments,this.planeVerticalSegments);case"torus":return k.createTorus(this.torusRadius,this.torusTubeRadius,this.torusRadialSegments,this.torusTubularSegments,this.torusArc);default:return k.createSphere(this.sphereRadius,this.sphereStep)}}};V([_({label:b("asset.primitive-mesh.type.label"),info:b("asset.primitive-mesh.type.info"),type:B.Select,value:"sphere",options:_t(bt),onChange(M){M._updateData()}}),N()],H.prototype,"type",2);V([_({label:b("asset.primitive-mesh.sphere.radius.label"),info:b("asset.primitive-mesh.sphere.radius.info"),type:B.Number,min:0,dragStep:.1,when:gt,onChange:T}),N()],H.prototype,"sphereRadius",2);V([_({label:b("asset.primitive-mesh.sphere.step.label"),info:b("asset.primitive-mesh.sphere.step.info"),type:B.Number,min:1,dragStep:1,when:gt,onChange:T}),N()],H.prototype,"sphereStep",2);V([_({label:b("asset.primitive-mesh.capsule.radius.label"),info:b("asset.primitive-mesh.capsule.radius.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleRadius",2);V([_({label:b("asset.primitive-mesh.capsule.height.label"),info:b("asset.primitive-mesh.capsule.height.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleHeight",2);V([_({label:b("asset.primitive-mesh.capsule.radial-segments.label"),info:b("asset.primitive-mesh.capsule.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleRadialSegments",2);V([_({label:b("asset.primitive-mesh.capsule.height-segments.label"),info:b("asset.primitive-mesh.capsule.height-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleHeightSegments",2);V([_({label:b("asset.primitive-mesh.cone.radius.label"),info:b("asset.primitive-mesh.cone.radius.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneRadius",2);V([_({label:b("asset.primitive-mesh.cone.height.label"),info:b("asset.primitive-mesh.cone.height.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneHeight",2);V([_({label:b("asset.primitive-mesh.cone.radial-segments.label"),info:b("asset.primitive-mesh.cone.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneRadialSegment",2);V([_({label:b("asset.primitive-mesh.cone.height-segments.label"),info:b("asset.primitive-mesh.cone.height-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneHeightSegment",2);V([_({label:b("asset.primitive-mesh.cuboid.width.label"),info:b("asset.primitive-mesh.cuboid.width.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidWidth",2);V([_({label:b("asset.primitive-mesh.cuboid.height.label"),info:b("asset.primitive-mesh.cuboid.height.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidHeight",2);V([_({label:b("asset.primitive-mesh.cuboid.depth.label"),info:b("asset.primitive-mesh.cuboid.depth.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidDepth",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-top.label"),info:b("asset.primitive-mesh.cylinder.radius-top.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusTop",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-bottom.label"),info:b("asset.primitive-mesh.cylinder.radius-bottom.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusBottom",2);V([_({label:b("asset.primitive-mesh.cylinder.height.label"),info:b("asset.primitive-mesh.cylinder.height.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeight",2);V([_({label:b("asset.primitive-mesh.cylinder.radial-segments.label"),info:b("asset.primitive-mesh.cylinder.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadialSegment",2);V([_({label:b("asset.primitive-mesh.cylinder.height-segments.label"),info:b("asset.primitive-mesh.cylinder.height-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeightSegment",2);V([_({label:b("asset.primitive-mesh.plane.width.label"),info:b("asset.primitive-mesh.plane.width.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeWidth",2);V([_({label:b("asset.primitive-mesh.plane.height.label"),info:b("asset.primitive-mesh.plane.height.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeHeight",2);V([_({label:b("asset.primitive-mesh.plane.horizontal-segments.label"),info:b("asset.primitive-mesh.plane.horizontal-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeHorizontalSegments",2);V([_({label:b("asset.primitive-mesh.plane.vertical-segments.label"),info:b("asset.primitive-mesh.plane.vertical-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeVerticalSegments",2);V([_({label:b("asset.primitive-mesh.torus.radius.label"),info:b("asset.primitive-mesh.torus.radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusRadius",2);V([_({label:b("asset.primitive-mesh.torus.tube-radius.label"),info:b("asset.primitive-mesh.torus.tube-radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusTubeRadius",2);V([_({label:b("asset.primitive-mesh.torus.radial-segments.label"),info:b("asset.primitive-mesh.torus.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusRadialSegments",2);V([_({label:b("asset.primitive-mesh.torus.tubular-segments.label"),info:b("asset.primitive-mesh.torus.tubular-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusTubularSegments",2);V([_({label:b("asset.primitive-mesh.torus.arc.label"),info:b("asset.primitive-mesh.torus.arc.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusArc",2);H=V([Bt({type:"PrimitiveMesh",label:b("asset.primitive-mesh.title"),loaderType:"PrimitiveMesh",importMenuConfig:{type:Nt.Add},defaultName:"Mesh",dragLayer:Tt.PrimitiveMesh,thumbnail:Et,async bundle({content:M}){return{content:new Blob([Dt(await M.text())])}}})],H);export{H as PrimitiveMesh};
|
|
1
|
+
var wt=Object.defineProperty;var Mt=(M,s,i)=>s in M?wt(M,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):M[s]=i;var A=(M,s,i)=>(Mt(M,typeof s!="symbol"?s+"":s,i),i);import{ai as rt,B as q,bu as Rt,a5 as ut,a6 as dt,a7 as mt,a9 as ft,a3 as G,bv as tt,a4 as et,bw as Pt,j as It,bx as At,K as Ht,y as Vt,p as _,e as b,C as B,t as _t,m as N,n as Bt,o as Nt,q as Tt}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Dt}from"./bundlers-9b0d37fc.js";import{M as Et}from"./MeshThumbnail-8c20ee92.js";const z=class z{static createSphere(s=.5,i=18){i=Math.max(2,Math.floor(i));const o=i+1,e=o*o,c=i*i,l=z._generateIndices(e,c*6),R=Math.PI,t=R*2,a=1/o,y=1/i,m=8,h=new Float32Array(e*m);for(let x=0;x<e;++x){const u=x%o,d=x*a|0,p=u*y,n=d*y,w=p*t,f=n*R,v=Math.sin(f),I=-s*Math.cos(w)*v,P=s*Math.cos(f),S=s*Math.sin(w)*v;let r=x*m;h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=p,h[r++]=n}let C=0;for(let x=0;x<c;++x){const u=x%i,p=(x*y|0)*o+u,n=p+1,w=p+o,f=w+1;l[C++]=n,l[C++]=p,l[C++]=f,l[C++]=p,l[C++]=w,l[C++]=f}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:l,vertices:h,bounds:g}}static createCuboid(s=1,i=1,o=1){const e=s/2,c=i/2,l=o/2,R=8,t=new Float32Array(24*R);t[0]=-e,t[1]=c,t[2]=-l,t[6]=0,t[7]=0,t[8]=e,t[9]=c,t[10]=-l,t[14]=1,t[15]=0,t[16]=e,t[17]=c,t[18]=l,t[22]=1,t[23]=1,t[24]=-e,t[25]=c,t[26]=l,t[30]=0,t[31]=1;for(let m=0;m<4;m++){let h=R*m+3;t[h++]=0,t[h++]=1,t[h++]=0}t[32]=-e,t[33]=-c,t[34]=-l,t[38]=0,t[39]=1,t[40]=e,t[41]=-c,t[42]=-l,t[46]=1,t[47]=1,t[48]=e,t[49]=-c,t[50]=l,t[54]=1,t[55]=0,t[56]=-e,t[57]=-c,t[58]=l,t[62]=0,t[63]=0;for(let m=0;m<4;m++){let h=R*m+35;t[h++]=0,t[h++]=-1,t[h++]=0}t[64]=-e,t[65]=c,t[66]=-l,t[70]=0,t[71]=0,t[72]=-e,t[73]=c,t[74]=l,t[78]=1,t[79]=0,t[80]=-e,t[81]=-c,t[82]=l,t[86]=1,t[87]=1,t[88]=-e,t[89]=-c,t[90]=-l,t[94]=0,t[95]=1;for(let m=0;m<4;m++){let h=R*m+67;t[h++]=-1,t[h++]=0,t[h++]=0}t[96]=e,t[97]=c,t[98]=-l,t[102]=1,t[103]=0,t[104]=e,t[105]=c,t[106]=l,t[110]=0,t[111]=0,t[112]=e,t[113]=-c,t[114]=l,t[118]=0,t[119]=1,t[120]=e,t[121]=-c,t[122]=-l,t[126]=1,t[127]=1;for(let m=0;m<4;m++){let h=R*m+99;t[h++]=1,t[h++]=0,t[h++]=0}t[128]=-e,t[129]=c,t[130]=l,t[134]=0,t[135]=0,t[136]=e,t[137]=c,t[138]=l,t[142]=1,t[143]=0,t[144]=e,t[145]=-c,t[146]=l,t[150]=1,t[151]=1,t[152]=-e,t[153]=-c,t[154]=l,t[158]=0,t[159]=1;for(let m=0;m<4;m++){let h=R*m+131;t[h++]=0,t[h++]=0,t[h++]=1}t[160]=-e,t[161]=c,t[162]=-l,t[166]=1,t[167]=0,t[168]=e,t[169]=c,t[170]=-l,t[174]=0,t[175]=0,t[176]=e,t[177]=-c,t[178]=-l,t[182]=0,t[183]=1,t[184]=-e,t[185]=-c,t[186]=-l,t[190]=1,t[191]=1;for(let m=0;m<4;m++){let h=R*m+163;t[h++]=0,t[h++]=0,t[h++]=-1}const a=new Uint16Array(36);a[0]=0,a[1]=2,a[2]=1,a[3]=2,a[4]=0,a[5]=3,a[6]=4,a[7]=6,a[8]=7,a[9]=6,a[10]=4,a[11]=5,a[12]=8,a[13]=10,a[14]=9,a[15]=10,a[16]=8,a[17]=11,a[18]=12,a[19]=14,a[20]=15,a[21]=14,a[22]=12,a[23]=13,a[24]=16,a[25]=18,a[26]=17,a[27]=18,a[28]=16,a[29]=19,a[30]=20,a[31]=22,a[32]=23,a[33]=22,a[34]=20,a[35]=21;const y=new q;return y.min.set(-e,-c,-l),y.max.set(e,c,l),{vertices:t,bounds:y,indices:a}}static createPlane(s=1,i=1,o=1,e=1){o=Math.max(1,Math.floor(o)),e=Math.max(1,Math.floor(e));const c=o+1,l=e+1,R=s/2,t=i/2,a=s/o,y=i/e,m=c*l,h=e*o,C=z._generateIndices(m,h*6),g=1/c,x=1/o,u=1/e,d=8,p=new Float32Array(m*d);for(let f=0;f<m;++f){const v=f%c,I=f*g|0;let P=f*d;p[P++]=v*a-R,p[P++]=0,p[P++]=I*y-t,p[P++]=0,p[P++]=1,p[P++]=0,p[P++]=v*x,p[P++]=I*u}let n=0;for(let f=0;f<h;++f){const v=f%o,P=(f*x|0)*c+v,S=P+1,r=P+c,D=r+1;C[n++]=P,C[n++]=r,C[n++]=S,C[n++]=r,C[n++]=D,C[n++]=S}const w=new q;return w.min.set(-R,0,-t),w.max.set(R,0,t),{bounds:w,vertices:p,indices:C}}static createCylinder(s=.5,i=.5,o=2,e=20,c=1){e=Math.floor(e),c=Math.floor(c);const l=e+1,R=c+1,t=o*.5,a=o/c,y=l*R,m=e*c,h=e*2,C=y+2+h,g=z._generateIndices(C,m*6+h*3),x=1/l,u=1/e,d=1/c,p=8,n=new Float32Array(C*p);let w=0;const f=Math.PI,v=Math.PI*2,I=i-s,P=I/o,S=I/c;for(let F=0;F<y;++F){const Z=F%l,W=F*x|0,O=Z*u,J=W*d,$=f+O*v,nt=Math.sin($),pt=Math.cos($),ht=i-W*S,xt=ht*nt,vt=W*a-t,Ct=ht*pt;let L=F*p;n[L++]=xt,n[L++]=vt,n[L++]=Ct,n[L++]=nt,n[L++]=P,n[L++]=pt,n[L++]=O,n[L++]=1-J}for(let F=0;F<m;++F){const Z=F%e,O=(F*u|0)*l+Z,J=O+1,$=O+l,nt=$+1;g[w++]=J,g[w++]=$,g[w++]=O,g[w++]=J,g[w++]=nt,g[w++]=$}let r=y*p;n[r++]=0,n[r++]=-t,n[r++]=0,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=.5,n[r++]=.5,n[r++]=0,n[r++]=t,n[r++]=0,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=.5,n[r++]=.5,r=(y+2)*p;const D=1/(s*2),j=1/(i*2),E=l*c;for(let F=0;F<e;++F){const Z=F*p;let W=n[Z],O=n[Z+2];n[r++]=W,n[r++]=-t,n[r++]=O,n[r++]=0,n[r++]=-1,n[r++]=0,n[r++]=W*j+.5,n[r++]=.5-O*j;const J=(F+E)*p;W=n[J],O=n[J+2],n[r++]=W,n[r++]=t,n[r++]=O,n[r++]=0,n[r++]=1,n[r++]=0,n[r++]=W*D+.5,n[r++]=.5-O*D}const Y=y+1,X=y+2,U=X+1;for(let F=0;F<e;++F){const Z=F*2,W=F===e-1?0:Z+2;g[w++]=y,g[w++]=X+W,g[w++]=X+Z,g[w++]=Y,g[w++]=U+Z,g[w++]=U+W}const Q=new q,K=Math.max(s,i);return Q.min.set(-K,-t,-K),Q.max.set(K,t,K),{bounds:Q,vertices:n,indices:g}}static createTorus(s=.5,i=.1,o=30,e=30,c=360){o=Math.floor(o),e=Math.floor(e);const l=(o+1)*(e+1),R=o*e,t=z._generateIndices(l,R*6),a=8,y=new Float32Array(l*a);c=c/180*Math.PI;let m=0;const h=z._tempVec30;for(let x=0;x<=o;x++)for(let u=0;u<=e;u++){const d=u/e*c,p=x/o*Math.PI*2,n=Math.cos(p),w=Math.sin(p),f=Math.cos(d),v=Math.sin(d),I=(s+i*n)*f,P=(s+i*n)*v,S=i*w;y[m++]=I,y[m++]=P,y[m++]=S;const r=s*f,D=s*v;h.set(I-r,P-D,S).normalize(),y[m++]=h.x,y[m++]=h.y,y[m++]=h.z,y[m++]=u/e,y[m++]=x/o}m=0;for(let x=1;x<=o;x++)for(let u=1;u<=e;u++){const d=(e+1)*x+u-1,p=(e+1)*(x-1)+u-1,n=(e+1)*(x-1)+u,w=(e+1)*x+u;t[m++]=d,t[m++]=p,t[m++]=w,t[m++]=p,t[m++]=n,t[m++]=w}const C=new q,g=s+i;return C.min.set(-g,-g,-i),C.max.set(g,g,i),{bounds:C,vertices:y,indices:t}}static createCone(s=.5,i=2,o=20,e=1){o=Math.floor(o),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=a+1+o,h=z._generateIndices(m,y*6+o*3),C=1/c,g=1/o,x=1/e,u=8,d=new Float32Array(m*8);let p=0;const n=Math.PI,w=Math.PI*2,f=s/i;for(let r=0;r<a;++r){const D=r%c,j=r*C|0,E=D*g,Y=j*x,X=n+E*w,U=Math.sin(X),Q=Math.cos(X),K=s-j*s,F=K*U,Z=j*t-R,W=K*Q;let O=r*u;d[O++]=F,d[O++]=Z,d[O++]=W,d[O++]=U,d[O++]=f,d[O++]=Q,d[O++]=E,d[O++]=1-Y}for(let r=0;r<y;++r){const D=r%o,E=(r*g|0)*c+D,Y=E+1,X=E+c,U=X+1;h[p++]=Y,h[p++]=X,h[p++]=E,h[p++]=Y,h[p++]=U,h[p++]=X}let v=a*u;d[v++]=0,d[v++]=-R,d[v++]=0,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=.5,d[v++]=.5,v=(a+1)*u;const I=1/(s*2);for(let r=0;r<o;++r){const D=d[r*u],j=d[r*u+2];d[v++]=D,d[v++]=-R,d[v++]=j,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=D*I+.5,d[v++]=.5-j*I}const P=a+1;for(let r=0;r<o;++r){const D=r,j=r===o-1?0:D+1;h[p++]=a,h[p++]=P+j,h[p++]=P+D}const S=new q;return S.min.set(-s,-R,-s),S.max.set(s,R,s),{bounds:S,vertices:d,indices:h}}static createCapsule(s=.5,i=2,o=6,e=1){o=Math.max(2,Math.floor(o)),e=Math.floor(e);const c=o+1,l=e+1,R=i*.5,t=i/e,a=c*l,y=o*e,m=c*c,h=o*o,C=a+2*m,g=z._generateIndices(C,(y+2*h)*6),x=1/c,u=1/o,d=1/e,p=Math.PI,n=Math.PI*2,w=8,f=new Float32Array(C*w);let v=0;for(let P=0;P<a;++P){const S=P%c,r=P*x|0,D=S*u,j=r*d,E=p+D*n,Y=Math.sin(E),X=Math.cos(E);let U=P*w;f[U++]=s*Y,f[U++]=r*t-R,f[U++]=s*X,f[U++]=Y,f[U++]=0,f[U++]=X,f[U++]=D,f[U++]=1-j}for(let P=0;P<y;++P){const S=P%o,D=(P*u|0)*c+S,j=D+1,E=D+c,Y=E+1;g[v++]=j,g[v++]=E,g[v++]=D,g[v++]=j,g[v++]=Y,g[v++]=E}z._createCapsuleCap(s,i,o,p,n,a,1,f,g,v),z._createCapsuleCap(s,i,o,p,-n,a+m,-1,f,g,v+6*h);const I=new q;return I.min.set(-s,-s-R,-s),I.max.set(s,s+R,s),{bounds:I,vertices:f,indices:g}}static _generateIndices(s,i){let o=null;return s>65535?o=new Uint32Array(i):o=new Uint16Array(i),o}static _createCapsuleCap(s,i,o,e,c,l,R,t,a,y){const m=o+1,h=i*.5*R,C=m*m,g=o*o,x=1/m,u=1/o,d=8;for(let p=0;p<C;++p){const n=p%m,w=p*x|0,f=n*u,v=w*u,I=e+f*c,P=v*Math.PI*.5,S=Math.sin(P),r=s*Math.sin(I)*S,D=s*Math.cos(P)*R+h,j=s*Math.cos(I)*S;let E=(p+l)*d;t[E++]=r,t[E++]=D,t[E++]=j,t[E++]=r,t[E++]=D-h,t[E++]=j,t[E++]=f,t[E++]=v}for(let p=0;p<g;++p){const n=p%o,f=(p*u|0)*m+n+l,v=f+1,I=f+m,P=I+1;a[y++]=v,a[y++]=f,a[y++]=P,a[y++]=f,a[y++]=I,a[y++]=P}}static createSubdivisionSurfaceSphereData(s=.5,i=3){i=Rt.clamp(Math.floor(i),1,6);const o=new Float32Array(3*(6*Math.pow(4,i)+2)),e=new Float32Array(24*Math.pow(4,i));this._subdiveCatmullClark(i,o,e);const c=o.length/3,l=e.length/4,R=c+Math.pow(2,i+1)-1,t=R+16,a=new Float32Array(t*8),y=this._generateIndices(c,l*6);let m=0;const h={};for(let x=0;x<c;x++){let u=3*x,d=o[u],p=o[u+1],n=o[u+2];const w=1/Math.sqrt(d*d+p*p+n*n);if(d*=w,p*=w,n*=w,u=8*x,a[u]=d*s,a[u+1]=p*s,a[u+2]=n*s,a[u+3]=d,a[u+4]=p,a[u+5]=n,a[u+6]=(Math.PI-Math.atan2(n,d))/(2*Math.PI),a[u+7]=Math.acos(p)/Math.PI,a[u+6]===0){const f=8*(c+m++);a.set(a.subarray(u,u+8),f),a[f+6]=1,h[u/8]=f/8}}let C=0;this._spherePoleIdx=0;for(let x=0;x<l;x++){const u=4*x;let d=e[u],p=e[u+1],n=e[u+2],w=e[u+3];const f=8*d,v=8*p,I=8*n,P=8*w;a[f+2]+a[v+2]+a[I+2]<0&&(a[f+6]===0&&(d=h[d]),a[v+6]===0&&(p=h[p]),a[I+6]===0&&(n=h[n]),a[P+6]===0&&(w=h[w])),y[C]=d,y[C+1]=p,y[C+2]=n,this._generateAndReplacePoleUV(y,a,C,R),y[C+3]=d,y[C+4]=n,y[C+5]=w,this._generateAndReplacePoleUV(y,a,C+3,R),C+=6}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:y,vertices:a,bounds:g}}static _generateAndReplacePoleUV(s,i,o,e){const c=i[8*s[o]+7];if(c===0||c===1){const l=8*s[o],R=8*(e+this._spherePoleIdx);i.set(i.subarray(l,l+8),R),i[R+6]=.5*(i[l+6]+i[8*s[o+1]+6]+i[8*s[o+2]+6]-.5),s[o]=e+this._spherePoleIdx++}}static _subdiveCatmullClark(s,i,o){const e=new Map,c=new Array;i.set(this._sphereSeedPositions),o.set(this._sphereSeedCells);for(let l=0;l<s;l++){const R=6*Math.pow(4,l),t=4*R+2;e.clear(),c.length=0;for(let C=0;C<R;C++){const g=c[C]={facePoint:new rt,adjacentEdges:new Array(4)};for(let x=0;x<4;x++){const u=3*o[4*C+x];g.facePoint.x+=.25*i[u],g.facePoint.y+=.25*i[u+1],g.facePoint.z+=.25*i[u+2]}for(let x=0;x<4;x++){const u=o[4*C+x],d=o[4*C+(x+1)%4],p=Math.min(u,d)*t+Math.max(u,d);if(!e.has(p)){const v={edgePoint:new rt,edgePointIndex:void 0},I=3*u,P=3*d;v.edgePoint.set(.25*(i[I]+i[P]),.25*(i[I+1]+i[P+1]),.25*(i[I+2]+i[P+2])),e.set(p,v)}const n=e.get(p);g.adjacentEdges[x]=n;const w=n.edgePoint,f=g.facePoint;w.x+=.25*f.x,w.y+=.25*f.y,w.z+=.25*f.z}}const a=R+2,y=a+R;let m=0;this._sphereEdgeIdx=0;const h=o.slice(0,4*R);for(let C=0;C<R;C++){const g=c[C];g.facePoint.copyToArray(i,3*(a+C));const x=a+C;let u,d,p;for(let n=0;n<4;n++){const w=h[m++];switch(n){case 0:{const v=g.adjacentEdges[n%4],I=g.adjacentEdges[(n+3)%4];d=this._calculateEdgeIndex(i,v,y),u=this._calculateEdgeIndex(i,I,y),p=u;break}case 1:case 2:{const v=g.adjacentEdges[n%4];u=d,d=this._calculateEdgeIndex(i,v,y);break}case 3:{u=d,d=p;break}}const f=4*(4*C+n);o[f]=w,o[f+1]=d,o[f+2]=x,o[f+3]=u}}}}static _calculateEdgeIndex(s,i,o){if(i.edgePointIndex!==void 0)return i.edgePointIndex;{i.edgePoint.copyToArray(s,3*(o+this._sphereEdgeIdx));const e=o+this._sphereEdgeIdx++;return i.edgePointIndex=e,e}}};A(z,"_tempVec30",new rt),A(z,"_sphereSeedPositions",new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1])),A(z,"_sphereSeedCells",new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1])),A(z,"_sphereEdgeIdx",0),A(z,"_spherePoleIdx",0);let k=z;function Ft(){return[new G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]}function yt(M,s,{vertices:i,indices:o,bounds:e}){const c=new ut(s,dt.VertexBuffer,i,mt.Static),l=new ut(s,dt.IndexBuffer,o,mt.Static);M.setVertexElements(Ft()),M.setIndexBufferBinding(l,o instanceof Uint16Array?ft.UInt16:ft.UInt32),M.setVertexBufferBinding(c,32),M.bounds=e,M.subMesh?M.subMesh.count=o.length:M.addSubMesh(0,o.length)}class St extends Pt{constructor(s,i,o){super(s),this.engine=i,this.generateData=o}restoreContent(){yt(this.resource,this.engine,this.generateData())}}function Ot(M,s,i){s.resourceManager.addContentRestorer(new St(M,s,i))}var jt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,V=(M,s,i,o)=>{for(var e=o>1?void 0:o?Ut(s,i):s,c=M.length-1,l;c>=0;c--)(l=M[c])&&(e=(o?l(s,i,e):l(e))||e);return o&&e&&jt(s,i,e),e},bt=(M=>(M.Sphere="sphere",M.Cuboid="cuboid",M.Plane="plane",M.Cylinder="cylinder",M.Torus="torus",M.Cone="cone",M.Capsule="capsule",M))(bt||{});const gt=M=>M.type==="sphere",it=M=>M.type==="capsule",at=M=>M.type==="cone",lt=M=>M.type==="cuboid",ot=M=>M.type==="cylinder",st=M=>M.type==="torus",ct=M=>M.type==="plane",T=M=>M._updateData();let H=class extends It{constructor(s){super(s);A(this,"type","sphere");A(this,"sphereRadius",.5);A(this,"sphereStep",3);A(this,"capsuleRadius",.5);A(this,"capsuleHeight",2);A(this,"capsuleRadialSegments",6);A(this,"capsuleHeightSegments",1);A(this,"coneRadius",.5);A(this,"coneHeight",2);A(this,"coneRadialSegment",20);A(this,"coneHeightSegment",1);A(this,"cuboidWidth",1);A(this,"cuboidHeight",1);A(this,"cuboidDepth",1);A(this,"cylinderRadiusTop",.5);A(this,"cylinderRadiusBottom",.5);A(this,"cylinderHeight",2);A(this,"cylinderRadialSegment",20);A(this,"cylinderHeightSegment",1);A(this,"planeWidth",1);A(this,"planeHeight",1);A(this,"planeHorizontalSegments",1);A(this,"planeVerticalSegments",1);A(this,"torusRadius",.5);A(this,"torusTubeRadius",.1);A(this,"torusRadialSegments",30);A(this,"torusTubularSegments",30);A(this,"torusArc",360)}async initByCreation(s,i,o){const c=(typeof(o==null?void 0:o.primitiveType)=="string"?o.primitiveType:"").trim().toLowerCase();return{type:{sphere:"sphere",cube:"cuboid",cuboid:"cuboid",cylinder:"cylinder",plane:"plane",capsule:"capsule",cone:"cone",torus:"torus"}[c]??"sphere"}}async initByMain(s,i){const o=JSON.parse(await s.text()),e=this.engine,c=o.type,l=new At(e,c);l.setVertexElements([new G(tt.Position,0,et.Vector3,0),new G(tt.Normal,12,et.Vector3,0),new G(tt.UV,24,et.Vector2,0)]);for(const y in o)this[y]=o[y];this.bindEngineObject(l),Ot(l,e,()=>this._generateDataByType(this.type)),this._updateData();const R=new Ht(e,c&&c.charAt(0).toUpperCase()+c.slice(1)),t=R.addComponent(Vt);t.mesh=this.engineObject;const a=await this.root.assetStore.getAssetByRef({refId:"0000200"});t.setMaterial(a.engineObject),this.setDragTempEntity(R)}instantiate(){const s=this.root.sceneStore.createEntity(),i=this.getDragTempEntity();return s.initByEngineObject(i.clone()),s}_updateData(){const s=this.engine,i=this._engineObject;yt(i,s,this._generateDataByType(this.type))}_generateDataByType(s){switch(s){case"sphere":return k.createSubdivisionSurfaceSphereData(this.sphereRadius,this.sphereStep);case"capsule":return k.createCapsule(this.capsuleRadius,this.capsuleHeight,this.capsuleRadialSegments,this.capsuleHeightSegments);case"cone":return k.createCone(this.coneRadius,this.coneHeight,this.coneRadialSegment,this.coneHeightSegment);case"cuboid":return k.createCuboid(this.cuboidWidth,this.cuboidHeight,this.cuboidDepth);case"cylinder":return k.createCylinder(this.cylinderRadiusTop,this.cylinderRadiusBottom,this.cylinderHeight,this.cylinderRadialSegment,this.cylinderHeightSegment);case"plane":return k.createPlane(this.planeWidth,this.planeHeight,this.planeHorizontalSegments,this.planeVerticalSegments);case"torus":return k.createTorus(this.torusRadius,this.torusTubeRadius,this.torusRadialSegments,this.torusTubularSegments,this.torusArc);default:return k.createSphere(this.sphereRadius,this.sphereStep)}}};V([_({label:b("asset.primitive-mesh.type.label"),info:b("asset.primitive-mesh.type.info"),type:B.Select,value:"sphere",options:_t(bt),onChange(M){M._updateData()}}),N()],H.prototype,"type",2);V([_({label:b("asset.primitive-mesh.sphere.radius.label"),info:b("asset.primitive-mesh.sphere.radius.info"),type:B.Number,min:0,dragStep:.1,when:gt,onChange:T}),N()],H.prototype,"sphereRadius",2);V([_({label:b("asset.primitive-mesh.sphere.step.label"),info:b("asset.primitive-mesh.sphere.step.info"),type:B.Number,min:1,dragStep:1,when:gt,onChange:T}),N()],H.prototype,"sphereStep",2);V([_({label:b("asset.primitive-mesh.capsule.radius.label"),info:b("asset.primitive-mesh.capsule.radius.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleRadius",2);V([_({label:b("asset.primitive-mesh.capsule.height.label"),info:b("asset.primitive-mesh.capsule.height.info"),type:B.Number,min:0,dragStep:.1,when:it,onChange:T}),N()],H.prototype,"capsuleHeight",2);V([_({label:b("asset.primitive-mesh.capsule.radial-segments.label"),info:b("asset.primitive-mesh.capsule.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleRadialSegments",2);V([_({label:b("asset.primitive-mesh.capsule.height-segments.label"),info:b("asset.primitive-mesh.capsule.height-segments.info"),type:B.Number,min:1,dragStep:1,when:it,onChange:T}),N()],H.prototype,"capsuleHeightSegments",2);V([_({label:b("asset.primitive-mesh.cone.radius.label"),info:b("asset.primitive-mesh.cone.radius.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneRadius",2);V([_({label:b("asset.primitive-mesh.cone.height.label"),info:b("asset.primitive-mesh.cone.height.info"),type:B.Number,min:0,dragStep:.1,when:at,onChange:T}),N()],H.prototype,"coneHeight",2);V([_({label:b("asset.primitive-mesh.cone.radial-segments.label"),info:b("asset.primitive-mesh.cone.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneRadialSegment",2);V([_({label:b("asset.primitive-mesh.cone.height-segments.label"),info:b("asset.primitive-mesh.cone.height-segments.info"),type:B.Number,min:1,dragStep:1,when:at,onChange:T}),N()],H.prototype,"coneHeightSegment",2);V([_({label:b("asset.primitive-mesh.cuboid.width.label"),info:b("asset.primitive-mesh.cuboid.width.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidWidth",2);V([_({label:b("asset.primitive-mesh.cuboid.height.label"),info:b("asset.primitive-mesh.cuboid.height.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidHeight",2);V([_({label:b("asset.primitive-mesh.cuboid.depth.label"),info:b("asset.primitive-mesh.cuboid.depth.info"),type:B.Number,min:0,dragStep:.1,when:lt,onChange:T}),N()],H.prototype,"cuboidDepth",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-top.label"),info:b("asset.primitive-mesh.cylinder.radius-top.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusTop",2);V([_({label:b("asset.primitive-mesh.cylinder.radius-bottom.label"),info:b("asset.primitive-mesh.cylinder.radius-bottom.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadiusBottom",2);V([_({label:b("asset.primitive-mesh.cylinder.height.label"),info:b("asset.primitive-mesh.cylinder.height.info"),type:B.Number,min:0,dragStep:.1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeight",2);V([_({label:b("asset.primitive-mesh.cylinder.radial-segments.label"),info:b("asset.primitive-mesh.cylinder.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderRadialSegment",2);V([_({label:b("asset.primitive-mesh.cylinder.height-segments.label"),info:b("asset.primitive-mesh.cylinder.height-segments.info"),type:B.Number,min:1,dragStep:1,when:ot,onChange:T}),N()],H.prototype,"cylinderHeightSegment",2);V([_({label:b("asset.primitive-mesh.plane.width.label"),info:b("asset.primitive-mesh.plane.width.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeWidth",2);V([_({label:b("asset.primitive-mesh.plane.height.label"),info:b("asset.primitive-mesh.plane.height.info"),type:B.Number,min:0,dragStep:.1,when:ct,onChange:T}),N()],H.prototype,"planeHeight",2);V([_({label:b("asset.primitive-mesh.plane.horizontal-segments.label"),info:b("asset.primitive-mesh.plane.horizontal-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeHorizontalSegments",2);V([_({label:b("asset.primitive-mesh.plane.vertical-segments.label"),info:b("asset.primitive-mesh.plane.vertical-segments.info"),type:B.Number,min:1,dragStep:1,when:ct,onChange:T}),N()],H.prototype,"planeVerticalSegments",2);V([_({label:b("asset.primitive-mesh.torus.radius.label"),info:b("asset.primitive-mesh.torus.radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusRadius",2);V([_({label:b("asset.primitive-mesh.torus.tube-radius.label"),info:b("asset.primitive-mesh.torus.tube-radius.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusTubeRadius",2);V([_({label:b("asset.primitive-mesh.torus.radial-segments.label"),info:b("asset.primitive-mesh.torus.radial-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusRadialSegments",2);V([_({label:b("asset.primitive-mesh.torus.tubular-segments.label"),info:b("asset.primitive-mesh.torus.tubular-segments.info"),type:B.Number,min:1,dragStep:1,when:st,onChange:T}),N()],H.prototype,"torusTubularSegments",2);V([_({label:b("asset.primitive-mesh.torus.arc.label"),info:b("asset.primitive-mesh.torus.arc.info"),type:B.Number,min:0,dragStep:.1,when:st,onChange:T}),N()],H.prototype,"torusArc",2);H=V([Bt({type:"PrimitiveMesh",label:b("asset.primitive-mesh.title"),loaderType:"PrimitiveMesh",importMenuConfig:{type:Nt.Add},defaultName:"Mesh",dragLayer:Tt.PrimitiveMesh,thumbnail:Et,async bundle({content:M}){return{content:new Blob([Dt(await M.text())])}}})],H);export{H as PrimitiveMesh};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aH as n,aI as s,aJ as o,aK as i,av as t,aL as d,aM as c,aN as g}from"./index-
|
|
1
|
+
import{aH as n,aI as s,aJ as o,aK as i,av as t,aL as d,aM as c,aN as g}from"./index-b126bb6b.js";import{M as h}from"./MaterialInspector-3fb471d9.js";const m=n("div",{marginLeft:"5px"}),u=n(s,{borderRadius:"$3",padding:"$1_5",marginLeft:"-$1_5",marginRight:"-$0_5",marginBottom:"$1",color:"$gray11",cursor:"pointer",backgroundColor:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:"$grayA3"},variants:{open:{true:{boxShadow:"inset 0 0 0 1px $colors$grayA3",backgroundColor:"$grayA5","&:hover":{backgroundColor:"$grayA5"}}}}});function x(r){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...r,children:t.jsx("path",{fill:"currentColor",d:"m12 17.4l-3.9 3.9q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7l3.875-3.875q.575-.575 1.425-.575t1.425.575L17.3 19.9q.275.275.275.7t-.275.7t-.7.275t-.7-.275zm0-10.8l3.9-3.9q.275-.275.7-.275t.7.275t.275.7t-.275.7l-3.875 3.875Q12.85 8.55 12 8.55t-1.425-.575L6.7 4.1q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275z"})})}function p(r){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...r,children:t.jsx("path",{fill:"currentColor",d:"m12 19.15l3.875-3.875q.3-.3.7-.3t.7.3t.3.713t-.3.712l-3.85 3.875q-.575.575-1.425.575t-1.425-.575L6.7 16.7q-.3-.3-.288-.712t.313-.713t.713-.3t.712.3zm0-14.3L8.15 8.7q-.3.3-.7.288t-.7-.288q-.3-.3-.312-.712t.287-.713l3.85-3.85Q11.15 2.85 12 2.85t1.425.575l3.85 3.85q.3.3.288.713t-.313.712q-.3.275-.7.288t-.7-.288z"})})}const b=o(function(e){const{t:a}=i();return t.jsxs(u,{align:"v",justifyContent:"between",open:e.open,children:[t.jsxs(s,{align:"v",gap:"xs",children:[t.jsx("img",{src:e.thumbnailUrl,alt:a("mesh-renderer.material.thumbnail"),width:"20px",height:"20px"}),t.jsxs(m,{children:[a("mesh-renderer.material.title"),"(",e.name,")"]})]}),t.jsx(d,{size:"xs",variant:"subtle",children:e.open?t.jsx(x,{}):t.jsx(p,{})})]})}),w=r=>{const{materialAsset:e}=r,[a,l]=c.useState(!1);return t.jsx(g,{nesting:!0,title:t.jsx(b,{open:a,thumbnailUrl:e.thumbnailUrl,name:e.name}),defaultOpen:!1,open:a,onOpenChange:l,children:t.jsx(h,{asset:e})})};export{w as R};
|
package/dist/preview-client/_static/{RenderTargetAsset-b3cd1c49.js → RenderTargetAsset-dc1f9494.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
var C=Object.defineProperty;var M=(s,t,e)=>t in s?C(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var h=(s,t,e)=>(M(s,typeof t!="symbol"?t+"":t,e),e);import{N as R,$ as y,a$ as l,j as x,a_ as v,by as S,p as b,C as m,m as f,n as G,e as F,o as O,q as D}from"./index-
|
|
1
|
+
var C=Object.defineProperty;var M=(s,t,e)=>t in s?C(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var h=(s,t,e)=>(M(s,typeof t!="symbol"?t+"":t,e),e);import{N as R,$ as y,a$ as l,j as x,a_ as v,by as S,p as b,C as m,m as f,n as G,e as F,o as O,q as D}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import{A as B}from"./AssetViewer-8338dfe1.js";class A{static update(t,e){var o;this.spriteEntity?this.spriteEntity.isActive=!0:this.initScene(t),this.entity=this.spriteEntity;const i=(o=e.engineObject)==null?void 0:o.getColorTexture(0);i&&(this.sprite.texture=i)}static clear(){this.spriteEntity&&(this.spriteEntity.isActive=!1)}static initScene(t){const e=this.spriteEntity=t.createChild("rt-thumbnail");this.spriteRenderer=e.addComponent(R),this.spriteRenderer.sprite=this.sprite=new y(t.engine)}}h(A,"entity"),h(A,"spriteEntity"),h(A,"spriteRenderer"),h(A,"sprite");class j extends B{constructor(){super(...arguments);h(this,"_asset");h(this,"_sprite");h(this,"_onRebuild",()=>{var e;if(this._sprite&&((e=this._asset)!=null&&e.engineObject)){const i=this._asset.engineObject.getColorTexture(0);i&&(this._sprite.texture=i)}})}setViewAsset(e,i){var _;this._asset=e;const o=i.engine,r=i.createChild("rt_preview"),n=(_=e.engineObject)==null?void 0:_.getColorTexture(0),a=new y(o,n),c=r.addComponent(R);c.sprite=a,this._sprite=a,this._entity=r,e.onRebuild(this._onRebuild)}stopViewAsset(){super.stopViewAsset(),this._asset&&this._asset.offRebuild(this._onRebuild),this._asset=null,this._sprite=null}getDescription(e){return`${e.width}x${e.height}`}}var E=Object.defineProperty,V=Object.getOwnPropertyDescriptor,g=(s,t,e,i)=>{for(var o=i>1?void 0:i?V(t,e):t,r=s.length-1,n;r>=0;r--)(n=s[r])&&(o=(i?n(t,e,o):n(o))||o);return i&&o&&E(t,e,o),o};const I=[{label:"R8G8B8A8",value:l.R8G8B8A8},{label:"R8G8B8",value:l.R8G8B8},{label:"R16G16B16A16",value:l.R16G16B16A16},{label:"R32G32B32A32",value:l.R32G32B32A32},{label:"R11G11B10_UFloat",value:l.R11G11B10_UFloat}],w=-1,L=[{label:"None",value:w},{label:"Depth",value:l.Depth},{label:"Depth16",value:l.Depth16},{label:"Depth24",value:l.Depth24},{label:"Depth32",value:l.Depth32},{label:"Depth24Stencil8",value:l.Depth24Stencil8},{label:"Depth32Stencil8",value:l.Depth32Stencil8}],U=[{label:"1",value:1},{label:"2",value:2},{label:"4",value:4},{label:"8",value:8}];let u=class extends x{constructor(){super(...arguments);h(this,"_onRebuildCallbacks",[]);h(this,"width",512);h(this,"height",512);h(this,"colorFormat",l.R8G8B8A8);h(this,"depthFormat",l.Depth);h(this,"antiAliasing",1);h(this,"autoGenerateMipmaps",!0)}registerThumbnail(){}onRebuild(t){this._onRebuildCallbacks.push(t)}offRebuild(t){const e=this._onRebuildCallbacks.indexOf(t);e!==-1&&this._onRebuildCallbacks.splice(e,1)}async initByCreation(){return this.getMainData()}getMainData(){var i;const t={width:this.width,height:this.height,colorFormats:[this.colorFormat],depthFormat:this.depthFormat,antiAliasing:this.antiAliasing,autoGenerateMipmaps:this.autoGenerateMipmaps},e=(i=this.engineObject)==null?void 0:i.getColorTexture(0);return e&&(t.colorTextures=[{isSRGBColorSpace:e.isSRGBColorSpace,mipmap:e.mipmapCount>1,filterMode:e.filterMode,wrapModeU:e.wrapModeU,wrapModeV:e.wrapModeV,anisoLevel:e.anisoLevel}]),JSON.stringify(t)}async initByMain(t){const e=JSON.parse(await t.text());this.width=Math.round(e.width??512),this.height=Math.round(e.height??512);const i=e.colorFormats??[e.colorFormat??l.R8G8B8A8];this.colorFormat=i[0],this.depthFormat=e.depthFormat??l.Depth,this.antiAliasing=e.antiAliasing??1,this.autoGenerateMipmaps=e.autoGenerateMipmaps??!1;const r=(e.colorTextures??(e.colorTexture?[e.colorTexture]:[]))[0],n=this._buildRenderTarget((r==null?void 0:r.mipmap)??!0,r==null?void 0:r.isSRGBColorSpace);await this.bindEngineObject(n);const a=n.getColorTexture(0);a&&r&&(r.filterMode!=null&&(a.filterMode=r.filterMode),r.wrapModeU!=null&&(a.wrapModeU=r.wrapModeU),r.wrapModeV!=null&&(a.wrapModeV=r.wrapModeV),r.anisoLevel!=null&&(a.anisoLevel=r.anisoLevel)),await this._generateSubAssets()}destroy(){this._destroySubAssets(),this.engineObject&&this._replaceCameraRenderTarget(this.engineObject,null),this._onRebuildCallbacks.length=0,this._destroyRenderTarget(),super.destroy()}async _rebuild(){var _;if(!this.engineObject)return;const t=this.engineObject,e=t.getColorTexture(0),i=(_=this._subAssets)==null?void 0:_[0],o=i?i.mipmap??!0:!0,r=i?i.isSRGBColorSpace??this.colorFormat===l.R8G8B8A8:this.colorFormat===l.R8G8B8A8,n=e&&e.format===this.colorFormat&&e.width===this.width&&e.height===this.height&&e.isSRGBColorSpace===r&&o===e.mipmapCount>1;let a;try{a=n?this._buildRenderTargetWithTexture(e):this._buildRenderTarget(o,r)}catch(p){console.warn("Failed to create RenderTarget:",p);return}if(!n&&e){const p=a.getColorTexture(0);p&&(p.filterMode=e.filterMode,p.wrapModeU=e.wrapModeU,p.wrapModeV=e.wrapModeV,p.anisoLevel=e.anisoLevel)}const c=this._replaceCameraRenderTarget(t,a);if(t.destroy(),await this.bindEngineObject(a),n||(e==null||e.destroy(),this._destroySubAssets(),await this._generateSubAssets()),c.length>0){const p=c.map(d=>d.enabled);c.forEach(d=>d.enabled=!0),requestAnimationFrame(()=>{this._onRebuildCallbacks.forEach(d=>d()),c.forEach((d,T)=>d.enabled=p[T])})}else this._onRebuildCallbacks.forEach(p=>p())}_buildRenderTarget(t=!0,e){const{width:i,height:o,colorFormat:r}=this;e===void 0&&(e=r===l.R8G8B8A8);const n=new v(this.engine,i,o,r,t,e);return n.isGCIgnored=!0,this._buildRenderTargetWithTexture(n)}_buildRenderTargetWithTexture(t){const{width:e,height:i,depthFormat:o,antiAliasing:r,autoGenerateMipmaps:n}=this,a=o===w?null:o,c=new S(this.engine,e,i,t,a,r);return c.isGCIgnored=!0,c.autoGenerateMipmaps=n,c}_destroyRenderTarget(){var e;const t=this.engineObject;t&&((e=t.getColorTexture(0))==null||e.destroy(),t.destroy())}_replaceCameraRenderTarget(t,e){const i=this.root.projectStore.currentScene;if(!i)return[];const o=[];for(const r of i.entities.values())for(const n of r.components)if(n.type==="Camera"){const a=n.engineObject;(a==null?void 0:a.renderTarget)===t&&(a.renderTarget=e,o.push(a))}return o}async _generateSubAssets(){const t=this.engineObject,e=[],i=t.getColorTexture(0);if(i){i.name=`${this.name}-color`;const o=await this.root.assetStore.createSubAsset("Texture",i,this.id,"colorTextures[0]");o._editable=!0,e.push(o)}this._subAssets=e}_destroySubAssets(){if(this._subAssets){for(const t of this._subAssets)this.root.assetStore.deleteSubAsset(t.id);this._subAssets=[]}}};g([b({type:m.Number,label:"Width",min:1,max:8192,triggerAfterInit:!1,onChange:s=>{s.width=Math.round(s.width),s._rebuild()}}),f()],u.prototype,"width",2);g([b({type:m.Number,label:"Height",min:1,max:8192,triggerAfterInit:!1,onChange:s=>{s.height=Math.round(s.height),s._rebuild()}}),f()],u.prototype,"height",2);g([b({type:m.Select,label:"Color Format",options:I,triggerAfterInit:!1,onChange:s=>s._rebuild()}),f()],u.prototype,"colorFormat",2);g([b({type:m.Select,label:"Depth Format",options:L,triggerAfterInit:!1,onChange:s=>s._rebuild()}),f()],u.prototype,"depthFormat",2);g([b({type:m.Select,label:"Anti-Aliasing",options:U,triggerAfterInit:!1,onChange:s=>s._rebuild()}),f()],u.prototype,"antiAliasing",2);g([b({type:m.Toggle,label:"Auto Generate Mipmaps",triggerAfterInit:!1,onChange:s=>{const t=s.engineObject;t&&(t.autoGenerateMipmaps=s.autoGenerateMipmaps)}}),f()],u.prototype,"autoGenerateMipmaps",2);u=g([G({type:"RenderTarget",label:F("asset.render-target.title"),extname:"renderTarget",importMenuConfig:{type:O.Add},dragLayer:D.RenderTarget,viewer:j,thumbnail:A,async bundle({content:s}){return{content:s}}})],u);export{u as RenderTargetAsset};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var l=(t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>(l(t,typeof e!="symbol"?e+"":e,s),s);import{j as m,u as h,aW as u,aX as d,aY as f,aZ as y,n as D,e as S,o as v}from"./index-
|
|
1
|
+
var p=Object.defineProperty;var l=(t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>(l(t,typeof e!="symbol"?e+"":e,s),s);import{j as m,u as h,aW as u,aX as d,aY as f,aZ as y,n as D,e as S,o as v}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";function b(t){const e={asset:{version:"2.0",generator:"Galacean Editor"},scene:{rootEntities:["1000000","1000001"],background:{mode:0,color:{r:.0157,g:.0157,b:.0157,a:1}},ambient:{},shadow:{},fog:{}},entities:[{id:"1000000",name:"Camera",position:[0,0,10],components:["1000100"]},{id:"1000001",name:"DirectLight",position:[0,3,0],rotation:[-45,-45,0],components:["1000101"]}],components:[{id:"1000100",type:"Camera",props:{isOrthographic:!1,nearClipPlane:.1,farClipPlane:100,viewport:{x:0,y:0,z:1,w:1}}},{id:"1000101",type:"DirectLight",props:{enabled:!0,intensity:.6,color:{r:1,g:1,b:1,a:1}}}]};return t!==void 0&&(e.scene.name=t),e}var g=Object.defineProperty,w=Object.getOwnPropertyDescriptor,C=(t,e,s,a)=>{for(var n=a>1?void 0:a?w(e,s):e,i=t.length-1,r;i>=0;i--)(r=t[i])&&(n=(a?r(e,s,n):r(n))||n);return a&&n&&g(e,s,n),n};let c=class extends m{constructor(e){super(e);o(this,"sceneData",null);h(this)}async initByMain(e,s){this.sceneData=u(await e.text())}getMainData(){return d(this.sceneData)}async rename(e){await super.rename(e),await this.root.assetFacade.persistAssetMain(this.id)}saveMainImmediately(){var s;const e=this.root.sceneStore;if(this.id===e.refId){if(e.destroyed){f(this.root.projectStore.id,this.serverId);return}const a=y(this.root,this.id);return this.sceneData=a,this.sceneData.scene&&(this.sceneData.scene.name=this.name),super.saveMainImmediately()}else if((s=this.sceneData)!=null&&s.scene&&this.sceneData.scene.name!==this.name)return this.sceneData.scene.name=this.name,super.saveMainImmediately()}async initByCreation(e,s,a){return this.sceneData=b(this._name)}onDoubleClick(){this.root.projectStore.switchScene({scene:this.id})}};c=C([D({type:"Scene",label:S("asset.scene.title"),defaultName:"Scene",extname:"scene",importMenuConfig:{type:v.Add},async bundle(t){return{content:new Blob([t.content],{type:"application/json"})}}})],c);export{c as SceneAsset};
|