@galacean/cli 2.0.0-alpha.14 → 2.0.0-alpha.15
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 +24 -9
- package/dist/viewport-client/_static/{Accordion-3d330bc6.js → Accordion-930aedee.js} +1 -1
- package/dist/viewport-client/_static/{AmbientLightAsset-bdbc4e1d.js → AmbientLightAsset-f9c1eb91.js} +1 -1
- package/dist/viewport-client/_static/{AnimationClipAsset-9167378a.js → AnimationClipAsset-61699477.js} +1 -1
- package/dist/viewport-client/_static/{AnimatorControllerAsset-21dc6332.js → AnimatorControllerAsset-1c05f4db.js} +1 -1
- package/dist/viewport-client/_static/{AnimatorStore-18d3c551.js → AnimatorStore-6a3679e5.js} +1 -1
- package/dist/viewport-client/_static/{AssetViewer-64cd01fa.js → AssetViewer-0ce46fa1.js} +1 -1
- package/dist/viewport-client/_static/{AudioAsset-0c828c80.js → AudioAsset-5127eeec.js} +1 -1
- package/dist/viewport-client/_static/{AudioComponent-fbff3825.js → AudioComponent-18a3e59f.js} +1 -1
- package/dist/viewport-client/_static/{Callout-ba7e2adf.js → Callout-b6ac1af7.js} +1 -1
- package/dist/viewport-client/_static/{CameraComponent-74975570.js → CameraComponent-0a115258.js} +1 -1
- package/dist/viewport-client/_static/{Component-ed7aa0ab.js → Component-746be670.js} +1 -1
- package/dist/viewport-client/_static/{DirectLight-b884e7db.js → DirectLight-4c53e9f6.js} +1 -1
- package/dist/viewport-client/_static/{FontAsset-d1ced18d.js → FontAsset-a3a92f7d.js} +1 -1
- package/dist/viewport-client/_static/{FormItemArray-6d69acd4.js → FormItemArray-a2f72cf1.js} +1 -1
- package/dist/viewport-client/_static/{GlTFAsset-2723b84a.js → GlTFAsset-5f37feef.js} +1 -1
- package/dist/viewport-client/_static/{IconEdit-ab77303f.js → IconEdit-2c768a0a.js} +1 -1
- package/dist/viewport-client/_static/{IconPointFilled-811fc660.js → IconPointFilled-209638e2.js} +1 -1
- package/dist/viewport-client/_static/{LightBaseComponent-12dc27d1.js → LightBaseComponent-51d498ea.js} +1 -1
- package/dist/viewport-client/_static/{LottieAnimationComponent-c48c5eb5.js → LottieAnimationComponent-bff0244b.js} +1 -1
- package/dist/viewport-client/_static/{LottieAsset-3692580d.js → LottieAsset-9d3ef507.js} +1 -1
- package/dist/viewport-client/_static/{MarkdownAsset-bcb90be4.js → MarkdownAsset-a17933fb.js} +1 -1
- package/dist/viewport-client/_static/{MaterialAsset-6ef9b4ed.js → MaterialAsset-3b56ac00.js} +1 -1
- package/dist/viewport-client/_static/{MaterialInspector-e8242674.js → MaterialInspector-a36197f2.js} +1 -1
- package/dist/viewport-client/_static/{Menu-0b8da92f.js → Menu-0a7dbec0.js} +1 -1
- package/dist/viewport-client/_static/{MeshAsset-ca9305e5.js → MeshAsset-2cf47eb2.js} +1 -1
- package/dist/viewport-client/_static/{MeshRendererBaseComponent-9efd3943.js → MeshRendererBaseComponent-4a3af376.js} +1 -1
- package/dist/viewport-client/_static/{MeshRendererComponent-c9a03641.js → MeshRendererComponent-ac4c3954.js} +1 -1
- package/dist/viewport-client/_static/{MeshThumbnail-ab28b3b8.js → MeshThumbnail-25cd4a13.js} +1 -1
- package/dist/viewport-client/_static/{ParticleRendererComponent-96947c1d.js → ParticleRendererComponent-0a470dee.js} +1 -1
- package/dist/viewport-client/_static/{PhysicsMaterialAsset-4a1e5ea3.js → PhysicsMaterialAsset-d87d35aa.js} +1 -1
- package/dist/viewport-client/_static/{PhysicsStore-33cac578.js → PhysicsStore-c283b2be.js} +1 -1
- package/dist/viewport-client/_static/{PointLight-fd514526.js → PointLight-b7de209f.js} +1 -1
- package/dist/viewport-client/_static/{PostProcessComponent-d0ea27a4.js → PostProcessComponent-d4c9ef58.js} +1 -1
- package/dist/viewport-client/_static/{PrefabAsset-9179b95c.js → PrefabAsset-d0c0cd25.js} +1 -1
- package/dist/viewport-client/_static/{PrimitiveMesh-0572a073.js → PrimitiveMesh-35092ad0.js} +1 -1
- package/dist/viewport-client/_static/{ProxyConfigs-3a5fd860.js → ProxyConfigs-ad92ebc7.js} +1 -1
- package/dist/viewport-client/_static/{ReferencedMaterial-5773c9d2.js → ReferencedMaterial-800a1955.js} +1 -1
- package/dist/viewport-client/_static/{RenderTargetAsset-ab6e06d2.js → RenderTargetAsset-a003f9f5.js} +1 -1
- package/dist/viewport-client/_static/{SceneAsset-385fa837.js → SceneAsset-87f2ea92.js} +1 -1
- package/dist/viewport-client/_static/{ShaderAsset-f4514b03.js → ShaderAsset-98ce1f70.js} +1 -1
- package/dist/viewport-client/_static/{ShaderChunkAsset-34116f2c.js → ShaderChunkAsset-e9072307.js} +1 -1
- package/dist/viewport-client/_static/{ShaderUIScriptAsset-fc503291.js → ShaderUIScriptAsset-ac824e68.js} +1 -1
- package/dist/viewport-client/_static/{SkinnedMeshRendererComponent-494ad439.js → SkinnedMeshRendererComponent-5f34bf46.js} +1 -1
- package/dist/viewport-client/_static/{SpineAnimationComponent-3918d7b5.js → SpineAnimationComponent-7c5db747.js} +1 -1
- package/dist/viewport-client/_static/{SpineSkeletonDataAsset-27244892.js → SpineSkeletonDataAsset-5b202ba0.js} +1 -1
- package/dist/viewport-client/_static/{SpotLight-f9972dc0.js → SpotLight-2b4e593e.js} +1 -1
- package/dist/viewport-client/_static/{SpriteAsset-558ffca8.js → SpriteAsset-4e895da5.js} +1 -1
- package/dist/viewport-client/_static/{SpriteAtlasAsset-cdc34386.js → SpriteAtlasAsset-c2894c12.js} +1 -1
- package/dist/viewport-client/_static/{SpriteBaseComponent-3edafa31.js → SpriteBaseComponent-a75e84c1.js} +1 -1
- package/dist/viewport-client/_static/{SpriteMaskComponent-de2e5231.js → SpriteMaskComponent-a31f3384.js} +1 -1
- package/dist/viewport-client/_static/{SpriteRendererComponent-e999e735.js → SpriteRendererComponent-c2123918.js} +1 -1
- package/dist/viewport-client/_static/{TextBaseComponent-ce1402c3.js → TextBaseComponent-95846acf.js} +1 -1
- package/dist/viewport-client/_static/{TextRendererComponent-f7c0deae.js → TextRendererComponent-429cf17b.js} +1 -1
- package/dist/viewport-client/_static/{TextureAsset-39fb07fe.js → TextureAsset-93475ade.js} +2 -2
- package/dist/viewport-client/_static/{Tooltip-82063435.js → Tooltip-dfde37c6.js} +1 -1
- package/dist/viewport-client/_static/{TrailRendererComponent-37f5c981.js → TrailRendererComponent-112b1618.js} +1 -1
- package/dist/viewport-client/_static/{TransformBaseComponent-713d57e9.js → TransformBaseComponent-a8050787.js} +1 -1
- package/dist/viewport-client/_static/{TransformComponent-40a57948.js → TransformComponent-c95e25c2.js} +1 -1
- package/dist/viewport-client/_static/{XRReferenceImageAsset-2f6ff226.js → XRReferenceImageAsset-dbf129aa.js} +1 -1
- package/dist/viewport-client/_static/{audio-7120ec91.js → audio-10589bb4.js} +1 -1
- package/dist/viewport-client/_static/index-010da0b3.js +1 -0
- package/dist/viewport-client/_static/{index-fbe040bf.js → index-07bbf729.js} +1 -1
- package/dist/viewport-client/_static/{index-aec7e708.js → index-1e23212d.js} +4 -4
- package/dist/viewport-client/_static/{index-f2cb64af.js → index-2cdbb69f.js} +1 -1
- package/dist/viewport-client/_static/{index-7834b582.js → index-31b7a6d3.js} +1 -1
- package/dist/viewport-client/_static/index-3439012b.js +1 -0
- package/dist/viewport-client/_static/{index-c63c9606.js → index-48760ac4.js} +1 -1
- package/dist/viewport-client/_static/index-65a103b6.js +1 -0
- package/dist/viewport-client/_static/{index-bfe6f30e.js → index-77b1de5c.js} +1 -1
- package/dist/viewport-client/_static/{index-e8a45e82.js → index-92830754.js} +1 -1
- package/dist/viewport-client/_static/{index-7917f782.js → index-93eab932.js} +1 -1
- package/dist/viewport-client/_static/{index-7acd49d2.js → index-b259cf2e.js} +1 -1
- package/dist/viewport-client/_static/{index-74130ff3.js → index-b2e1cba4.js} +1 -1
- package/dist/viewport-client/_static/index-b7bf2586.js +1 -0
- package/dist/viewport-client/_static/{index-78269e76.js → index-c20fc198.js} +1 -1
- package/dist/viewport-client/_static/index-dc62ba4b.js +1 -0
- package/dist/viewport-client/_static/index-ea9ea505.js +1 -0
- package/dist/viewport-client/_static/{ktx2-encoder-53b21bdc.js → ktx2-encoder-075abd75.js} +1 -1
- package/dist/viewport-client/_static/{module-8816772d.js → module-251ecc50.js} +1 -1
- package/dist/viewport-client/_static/{module-ffeaf99f.js → module-498119f3.js} +1 -1
- package/dist/viewport-client/_static/{module-220b3921.js → module-c6e2d190.js} +1 -1
- package/dist/viewport-client/_static/postmen-9e1e15bd.js +1 -0
- package/dist/viewport-client/index.html +1 -1
- package/package.json +1 -1
- package/dist/viewport-client/_static/index-483b5738.js +0 -1
- package/dist/viewport-client/_static/index-9d3917da.js +0 -1
- package/dist/viewport-client/_static/index-a9b2675e.js +0 -1
- package/dist/viewport-client/_static/index-b5582401.js +0 -1
- package/dist/viewport-client/_static/index-cd1fee9d.js +0 -1
- package/dist/viewport-client/_static/index-e73ceaed.js +0 -1
- package/dist/viewport-client/_static/postmen-2f47f6bb.js +0 -1
package/dist/viewport-client/_static/{MaterialAsset-6ef9b4ed.js → MaterialAsset-3b56ac00.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
var z=Object.defineProperty;var K=(p,e,t)=>e in p?z(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var l=(p,e,t)=>(K(p,typeof e!="symbol"?e+"":e,t),t);import{O as V,bX as L,ct as k,cu as G,N as Q,K as H,V as U,B as q,cv as f,j as J,q as N,cw as v,I as M,u as W,cx as x,J as I,ab as b,ac as O,cy as Y,C as P,cz as E,cA as X,z as S,cr as Z,e as w,bQ as ee,_ as te,ao as ae,ap as re,H as B,a8 as se,Q as ne,x as $,aL as m,n as ie,o as oe}from"./index-aec7e708.js";import"./index-e8a45e82.js";import{M as he}from"./MaterialInspector-e8242674.js";import{A as pe}from"./AssetViewer-64cd01fa.js";import{E as y,s as F,b as C}from"./ProxyConfigs-3a5fd860.js";async function de(p){var e;if(p.shaderRef)try{const t=await p.assetStore.getAssetByRef(p.shaderRef);if(!t||t===p.nextShaderAsset)return;(e=t.removeReferencedMaterial)==null||e.call(t,p.material)}catch{}}class ce extends pe{constructor(){super(...arguments);l(this,"_sphereRenderer",null);l(this,"_particleRenderer",null);l(this,"_asset",null);l(this,"_shaderReactionDisposer",null);l(this,"onShaderChange",()=>{const{_asset:t}=this;t.engineObject.shader.name==="particle-shader"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(t.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(t.engineObject))})}setViewAsset(t,a){if(!(t instanceof u))return;const n=a.createChild("material");this._asset=t;const r=this._sphereRenderer=n.createChild("mat").addComponent(V);r.mesh=L.createSphere(a.engine,1,32,!0);const o=this._particleRenderer=n.createChild("pat").addComponent(k);o.generator.main.duration=1e3,o.generator.main.startSpeed.constant=0,this._entity=n,a.addChild(this._entity),this.onShaderChange(),this._shaderReactionDisposer=G(()=>{var i,d;return(d=(i=this._asset)==null?void 0:i.shaderRef)==null?void 0:d.refId},()=>{this.onShaderChange()})}stopViewAsset(){var t;super.stopViewAsset(),(t=this._shaderReactionDisposer)==null||t.call(this),this._shaderReactionDisposer=null,this._asset=null}}class D{static update(e,t){if(!(t instanceof u))return;const a=t.engineObject;if(!a||!a.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(e),a.shader.name==="particle-shader"?(this.sphereRenderer.entity.isActive=!1,this.particleRenderer.entity.isActive=!0,this.particleRenderer.setMaterial(a),this.particleRenderer.generator._playTime=5):(this.particleRenderer.entity.isActive=!1,this.sphereRenderer.entity.isActive=!0,this.sphereRenderer.setMaterial(a))}static clear(){var e,t;(e=this.sphereRenderer)!=null&&e.entity&&(this.sphereRenderer.entity.isActive=!1),(t=this.particleRenderer)!=null&&t.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(e){const t=this.entity=e.createChild("material"),a=this.sphereRenderer=t.createChild("mat").addComponent(V);a.mesh=L.createSphere(e.engine,2,64,!0),this.particleRenderer=t.createChild("pat").addComponent(k),this.particleRenderer.bounds.max.set(.5,.5,.5),this.particleRenderer.bounds.min.set(-.5,-.5,-.5)}}l(D,"entity",null),l(D,"sphereRenderer",null),l(D,"particleRenderer",null);function j(p){return p instanceof Q?{x:p.x,y:p.y}:p instanceof H?{x:p.x,y:p.y,z:p.z}:p instanceof U?{x:p.x,y:p.y,z:p.z,w:p.w}:p instanceof q?{r:p.r,g:p.g,b:p.b,a:p.a}:p}function le(p){switch(p){case f.Color:return"Color";case f.Float:return"Float";case f.Int:return"Integer";case f.Matrix:return"Matrix";case f.Texture:return"Texture";case f.TextureArray:return"TextureArray";case f.Vector2:return"Vector2";case f.Vector3:return"Vector3";case f.Vector4:return"Vector4"}}var ue=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,g=(p,e,t,a)=>{for(var n=a>1?void 0:a?fe(e,t):e,r=p.length-1,o;r>=0;r--)(o=p[r])&&(n=(a?o(e,t,n):o(n))||n);return a&&n&&ue(e,t,n),n};let u=class extends J{constructor(e){super(e);l(this,"acceptDragLayer",N.Texture);l(this,"shaderRef",{refId:null});l(this,"shaderDataKeys",new Set);l(this,"formConfig",null);l(this,"_autoSaveSuppressed",!1);W(this),x(this,{proxyConfigs:[]})}static initBuiltinMaterial(e,t){e.shader=t;const a=e.shaderData;switch(a.disableMacro("MATERIAL_NEED_WORLD_POS"),a.disableMacro("MATERIAL_OMIT_NORMAL"),a.disableMacro("MATERIAL_NEED_TILING_OFFSET"),a.disableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.depthState.compareFunction=v.Less,t.name){case"unlit":a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"pbr-specular":case"pbr":case"bake-pbr":case"blinn-phong":a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"skybox":e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"SkyProcedural":a.enableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"particle-shader":a.enableMacro("MATERIAL_OMIT_NORMAL");break}}setAutoSaveSuppressed(e){this._autoSaveSuppressed=e}setRenderQueueType(e){this.engineObject.renderState.renderQueueType=e}setBlendStateEnabled(e){this.engineObject.renderState.blendState.targetBlendState.enabled=e}setDepthWriteEnabled(e){this.engineObject.renderState.depthState.writeEnabled=e}setCullMode(e){this.engineObject.renderState.rasterState.cullMode=e}setBlendMode(e){const t=this.engineObject.renderState.blendState.targetBlendState;switch(e){case I.Normal:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.OneMinusSourceAlpha,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break;case I.Additive:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.One,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break}}bindShaderAsset(e,t){for(const a of this.shaderDataKeys)this.removePropertyChangeListener(a);return this.shaderDataKeys.clear(),e.onReady().then(async()=>{var n;if(e.shaderScriptRefId){const r=this.root.assetStore.assets[e.shaderScriptRefId.refId];this.isInitCompleted&&(r==null||r.onShaderChange(this._engineObject),t=this._getMainData())}const a=e.properties?Y(e.properties):[];e.isBuiltinShader()&&u.initBuiltinMaterial(this.engineObject,e.engineObject),t=t||this._getMainData(),await this._proxyShaderProps(a,t,this.isInitCompleted),this.refreshFormConfig(a,t),this.refreshAnimatableProperties(a),de({assetStore:this.root.assetStore,shaderRef:this.shaderRef,nextShaderAsset:e,material:this}),e.addReferencedMaterial(this),this.shaderRef={refId:e.id},await this.applyBoundPathChange("shader",P.AssetPicker,this.shaderRef),(n=this.updateThumbnail)==null||n.call(this)})}async _proxyShaderProps(e,t,a=!0){var o;this.proxyConfigs=e;const n=(o=this.extraData)==null?void 0:o.disabledMacros,r=e.map(async i=>{var d;if(this.proxySetter(i),this._virualShaderProps(e),i.bundleType==="macro"){const s=i.macroInfo,h=t.macros.find(c=>c.name===i.prop);if(!E(this,i.prop)){let c;h!=null?(c=h.value,s&&(s.checked=!0)):n!=null&&n.includes(i.prop)?(c=void 0,s&&(s.checked=!1)):c=i.defaultValue,x(this,{[i.prop]:c})}if(a)if(h){const c=h.value??i.defaultValue;c==null?s==null||s.onSwitch(!0,this):await i.onChange(this,i.prop,c)}else!(n!=null&&n.includes(i.prop))&&(s!=null&&s.checked)&&(s==null||s.onSwitch(!0,this))}else{const s=t.shaderData[i.prop];let h=s?s.value:this[i.prop]??i.defaultValue;if(h!=null&&h.refId&&!this.root.assetStore.assets[h.refId]&&(h=void 0),((d=i.uiInfo)==null?void 0:d.type)===y.Color)if(i.uiInfo.mode==="hdr"){const c=h.intensity??1;c!==0&&(h.r/=c,h.g/=c,h.b/=c),h.intensity=c}else h.intensity=1;E(this,i.prop)||x(this,{[i.prop]:h}),a&&this.notifyPropertyChange(i.prop,!1)}});await Promise.all(r)}proxySetter(e){const{prop:t,onChange:a,bundleType:n}=e,r=async(o,i)=>{var s;const d=this._engineObject.shaderData;n==="macro"?d.enableMacro(t,o):await F(this,t,o,e.engineType??((s=e.uiInfo)==null?void 0:s.type)),await a(this,t,o),i!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(t,r),this.shaderDataKeys.add(t)}_virualShaderProps(e){const t=this;e.forEach(a=>{X(t,a.prop)})}refreshFormConfig(e,t){var n,r,o,i,d;const a={root:[],groups:{}};if(t){for(const s of e)if(!((n=s.uiInfo)!=null&&n.hide)){if((r=s.uiInfo)!=null&&r.group){if((o=s.uiInfo)!=null&&o.group){let h=a.groups[s.uiInfo.group];h||(h={type:P.Group,property:s.uiInfo.group,children:[]},a.groups[s.uiInfo.group]=h);const c=s.uiInfo;c.property=s.prop,s.macroInfo&&(c.macroConfig=s.macroInfo),h.children.push(c)}}else{const h=s.uiInfo;h.property=s.prop,s.macroInfo&&(h.macroConfig=s.macroInfo),a.root.push(h)}s.bundleType==="macro"?this[s.prop]=((i=t.macros.find(h=>h.name===s.prop))==null?void 0:i.value)??s.defaultValue:this[s.prop]=((d=t.shaderData[s.prop])==null?void 0:d.value)??s.defaultValue}}this.formConfig=a}refreshAnimatableProperties(e){var t,a,n;this._additionAnimatableProperties.length=0;for(const r of e){if(!r.uiInfo||r.uiInfo.hide||r.bundleType==="macro")continue;let o={};if((r.setPath||r.getPath||r.valueType||r.interpolationType)&&(o={setPath:r.setPath,getPath:r.getPath,valueType:r.valueType,interpolationType:r.interpolationType}),!o.setPath&&!o.getPath&&r.engineType&&(r.bundleType==="shaderData"||!r.bundleType))switch(r.engineType){case y.Float:o={setPath:`shaderData.setFloat('${r.prop}', $value)`,getPath:`shaderData.getFloat('${r.prop}')`,valueType:S.Float};break;case y.Integer:o={setPath:`shaderData.setInt('${r.prop}', $value)`,getPath:`shaderData.getInt('${r.prop}')`,valueType:S.Float,interpolationType:Z.Step};break;case y.Vector2:o={setPath:`shaderData.getVector2('${r.prop}')`,getPath:`shaderData.getVector2('${r.prop}')`,valueType:S.Vector2};break;case y.Vector3:o={setPath:`shaderData.getVector3('${r.prop}')`,getPath:`shaderData.getVector3('${r.prop}')`,valueType:S.Vector3};break;case y.Vector4:o={setPath:`shaderData.getVector4('${r.prop}')`,getPath:`shaderData.getVector4('${r.prop}')`,valueType:S.Vector4};break;case y.Color:o={setPath:`shaderData.getColor('${r.prop}')`,getPath:`shaderData.getColor('${r.prop}')`,valueType:S.Color};break;case y.Boolean:o={setPath:`shaderData.setBoolean('${r.prop}', $value)`,getPath:`shaderData.getBoolean('${r.prop}')`,valueType:S.Boolean};break;case y.Texture:o={setPath:`shaderData.setTexture('${r.prop}', $value)`,getPath:`shaderData.getTexture('${r.prop}')`,valueType:S.ReferResource};break}if(!o.setPath&&!o.getPath){if(r.bundleType==="other")continue;continue}this._additionAnimatableProperties.push({property:r.prop,label:(t=r.uiInfo)!=null&&t.label?w(r.uiInfo.label):r.prop,type:(a=r.uiInfo)==null?void 0:a.type,propertyProxyConfig:o}),(n=r.uiInfo)!=null&&n.label&&(o.label=w(r.uiInfo.label)),ee(this,r.prop,o)}}async initByMain(e){var c;const t=JSON.parse(await e.text());this.shaderRef=t.shaderRef;const a=t.shaderData,n=t.macros,r=t.renderState;if(!t.shaderRef)throw"invalid material";const o=new te(this.engine);this.setDragTempEntity(o);const i=await this.root.assetStore.getAssetByRef(t.shaderRef),d=i.engineObject??ae.find("unlit"),s=new re(this.engine,d);this.bindEngineObject(s);const h=s.shaderData;if(n)for(const R of n)h.enableMacro(R.name,R.value);if(a)for(const R in a){const _=a[R];let A=_.value;if(_.type===y.Color){A={..._.value};const T=_.value.intensity??1;T!==0&&(A.r/=T,A.g/=T,A.b/=T)}F(this,R,A,_.type)}r&&this._parseProperty(s,"renderState",r),await this.bindShaderAsset(i,t),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",P.Input,this.name),this._checkSchemaOnInit(t,i)}_checkSchemaOnInit(e,t){e.shader!==t.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(e){const t=this;this.bindEngineObject(e),t.shader=e.shader.name,t._name=e.name??"";const n=Object.values(this.root.assetStore.assets).filter(d=>d.meta.type==="Shader"&&!!d.meta.builtinShaderName).find(d=>d.meta.builtinShaderName===e.shader.name);switch(this.shaderRef={refId:n.id},t.isTransparent=e.renderState.blendState.targetBlendState.enabled,t.alphaCutoff=e.shaderData.getFloat("material_AlphaCutoff"),e.renderState.rasterState.cullMode){case M.Back:t.renderFace=B.Front;break;case M.Front:t.renderFace=B.Back;break;case M.Off:t.renderFace=B.Double;break}t.blendMode=e.renderState.blendState.targetBlendState.destinationColorBlendFactor===b.One?I.Additive:I.Normal;const r=e.shaderData;r.getProperties().forEach(d=>{const s=r.getPropertyValue(d);if(s instanceof se){const h=this.root.assetStore.engineObjectToAssetMap.get(s);this[d.name]=h==null?void 0:h.getCurrentRef()}else this[d.name]=j(s)});const i=this._getMainData();this._proxyShaderProps(C,i,!1),this.bindShaderAsset(n,i)}afterDelete(){var e;(e=this.engineObject)==null||e.destroy(!0)}rename(e){return this.root.assetFacade.persistAssetMain(this.id),super.rename(e)}_getMainData(e){var i,d;const t=[],a=(e??this.engineObject).shaderData;a.getMacros(t);const n=t.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h}),r=[],o={};a.getProperties(r);for(const s of r){let h;if(s.type===f.Texture||s.type===f.TextureArray)h=this[s.name];else{const c=a.getPropertyValue(s);h=j(c),((i=this[s.name])==null?void 0:i.intensity)!=null&&(h.intensity=(d=this[s.name])==null?void 0:d.intensity)}h!=null&&(o[s.name]={type:le(s.type),value:h})}return{name:this.name,shader:this.engineObject.shader.name,macros:n,renderState:this.engineObject.renderState,shaderData:o,shaderRef:this.shaderRef}}getMainData(){return JSON.stringify(this._getMainData())}async initByCreation(){var o;const e=new ne(this.engine),t=[];e.shaderData.getMacros(t);const a=t.map(({name:i,value:d})=>d===void 0?{name:i}:{name:i,value:d});this.bindEngineObject(e);const n={};for(const i of C)i.defaultValue&&(n[i.prop]={value:i.defaultValue,type:i.engineType??((o=i.uiInfo)==null?void 0:o.type)});const r={shaderData:n,shaderRef:{refId:"0000501"},name:this.name,shader:e.shader.name,macros:a,renderState:e.renderState};return this._proxyShaderProps(C,r,!1),r}async onSubAssetEdit(){var n;const e=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(e.engineObject),await e.applyBoundPathChange("name",P.Input,e.name),e.initByEngineObject(e.engineObject),e.updateThumbnail(),await this.root.assetFacade.persistAssetMain(e.id);const t=await this.root.assetStore.getAssetByRef({refId:this.mainId}),a=((n=t.engineObject.materials)==null?void 0:n.indexOf(this._engineObject))??-1;a>=0&&await t.replaceMaterial(a,e.getCurrentRef()),this.root.assetStore.selectAsset(e.id)}saveMainImmediately(){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately().then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}_parseProperty(e,t,a){if(typeof a=="object")for(const n in a)this._parseProperty(e[t],n,a[n]);else e[t]=a}async _onDrop(e,t){const a="material_BaseTexture";if(a in this){const n=t.getCurrentRef();this[a]=n;const r=C.find(o=>o.prop===a);r&&await r.onChange(this,a,n),await this.root.assetFacade.persistAssetMain(this.id)}this.dropping=!1}async onDropToViewport(){const{sceneStore:e,sceneUIStore:t}=this.root,a=t.hoveredEntityId;if(a){const n=e.entities.get(a);if(n){const r=n.getComponentByTypeName("MeshRenderer"),o=n.getComponentByTypeName("SkinnedMeshRenderer"),i=r||o;i&&this.root.componentFacade.updateComponent(n.id,i.id,{material:this.getCurrentRef()})}}this.root.projectStore.currentViewport.viewport.onDrop()}};g([$],u.prototype,"shaderRef",2);g([$.ref],u.prototype,"formConfig",2);g([m],u.prototype,"bindShaderAsset",1);g([m],u.prototype,"_proxyShaderProps",1);g([m],u.prototype,"proxySetter",1);g([m],u.prototype,"_virualShaderProps",1);g([m],u.prototype,"refreshAnimatableProperties",1);g([m],u.prototype,"_onDrop",1);u=g([ie({type:"Material",label:w("asset.material.title"),loaderType:"Material",extname:"mat",importMenuConfig:{type:oe.Add},customInspector:he,viewer:ce,thumbnail:D,dragLayer:N.Material})],u);const _e=Object.freeze(Object.defineProperty({__proto__:null,get MaterialAsset(){return u}},Symbol.toStringTag,{value:"Module"}));export{u as M,ce as a,_e as b};
|
|
1
|
+
var z=Object.defineProperty;var K=(p,e,t)=>e in p?z(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var l=(p,e,t)=>(K(p,typeof e!="symbol"?e+"":e,t),t);import{O as V,bX as L,ct as k,cu as G,N as Q,K as H,V as U,B as q,cv as f,j as J,q as N,cw as v,I as M,u as W,cx as x,J as I,ab as b,ac as O,cy as Y,C as P,cz as E,cA as X,z as S,cr as Z,e as w,bQ as ee,_ as te,ao as ae,ap as re,H as B,a8 as se,Q as ne,x as $,aL as m,n as ie,o as oe}from"./index-1e23212d.js";import"./index-92830754.js";import{M as he}from"./MaterialInspector-a36197f2.js";import{A as pe}from"./AssetViewer-0ce46fa1.js";import{E as y,s as F,b as C}from"./ProxyConfigs-ad92ebc7.js";async function de(p){var e;if(p.shaderRef)try{const t=await p.assetStore.getAssetByRef(p.shaderRef);if(!t||t===p.nextShaderAsset)return;(e=t.removeReferencedMaterial)==null||e.call(t,p.material)}catch{}}class ce extends pe{constructor(){super(...arguments);l(this,"_sphereRenderer",null);l(this,"_particleRenderer",null);l(this,"_asset",null);l(this,"_shaderReactionDisposer",null);l(this,"onShaderChange",()=>{const{_asset:t}=this;t.engineObject.shader.name==="particle-shader"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(t.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(t.engineObject))})}setViewAsset(t,a){if(!(t instanceof u))return;const n=a.createChild("material");this._asset=t;const r=this._sphereRenderer=n.createChild("mat").addComponent(V);r.mesh=L.createSphere(a.engine,1,32,!0);const o=this._particleRenderer=n.createChild("pat").addComponent(k);o.generator.main.duration=1e3,o.generator.main.startSpeed.constant=0,this._entity=n,a.addChild(this._entity),this.onShaderChange(),this._shaderReactionDisposer=G(()=>{var i,d;return(d=(i=this._asset)==null?void 0:i.shaderRef)==null?void 0:d.refId},()=>{this.onShaderChange()})}stopViewAsset(){var t;super.stopViewAsset(),(t=this._shaderReactionDisposer)==null||t.call(this),this._shaderReactionDisposer=null,this._asset=null}}class D{static update(e,t){if(!(t instanceof u))return;const a=t.engineObject;if(!a||!a.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(e),a.shader.name==="particle-shader"?(this.sphereRenderer.entity.isActive=!1,this.particleRenderer.entity.isActive=!0,this.particleRenderer.setMaterial(a),this.particleRenderer.generator._playTime=5):(this.particleRenderer.entity.isActive=!1,this.sphereRenderer.entity.isActive=!0,this.sphereRenderer.setMaterial(a))}static clear(){var e,t;(e=this.sphereRenderer)!=null&&e.entity&&(this.sphereRenderer.entity.isActive=!1),(t=this.particleRenderer)!=null&&t.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(e){const t=this.entity=e.createChild("material"),a=this.sphereRenderer=t.createChild("mat").addComponent(V);a.mesh=L.createSphere(e.engine,2,64,!0),this.particleRenderer=t.createChild("pat").addComponent(k),this.particleRenderer.bounds.max.set(.5,.5,.5),this.particleRenderer.bounds.min.set(-.5,-.5,-.5)}}l(D,"entity",null),l(D,"sphereRenderer",null),l(D,"particleRenderer",null);function j(p){return p instanceof Q?{x:p.x,y:p.y}:p instanceof H?{x:p.x,y:p.y,z:p.z}:p instanceof U?{x:p.x,y:p.y,z:p.z,w:p.w}:p instanceof q?{r:p.r,g:p.g,b:p.b,a:p.a}:p}function le(p){switch(p){case f.Color:return"Color";case f.Float:return"Float";case f.Int:return"Integer";case f.Matrix:return"Matrix";case f.Texture:return"Texture";case f.TextureArray:return"TextureArray";case f.Vector2:return"Vector2";case f.Vector3:return"Vector3";case f.Vector4:return"Vector4"}}var ue=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,g=(p,e,t,a)=>{for(var n=a>1?void 0:a?fe(e,t):e,r=p.length-1,o;r>=0;r--)(o=p[r])&&(n=(a?o(e,t,n):o(n))||n);return a&&n&&ue(e,t,n),n};let u=class extends J{constructor(e){super(e);l(this,"acceptDragLayer",N.Texture);l(this,"shaderRef",{refId:null});l(this,"shaderDataKeys",new Set);l(this,"formConfig",null);l(this,"_autoSaveSuppressed",!1);W(this),x(this,{proxyConfigs:[]})}static initBuiltinMaterial(e,t){e.shader=t;const a=e.shaderData;switch(a.disableMacro("MATERIAL_NEED_WORLD_POS"),a.disableMacro("MATERIAL_OMIT_NORMAL"),a.disableMacro("MATERIAL_NEED_TILING_OFFSET"),a.disableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.depthState.compareFunction=v.Less,t.name){case"unlit":a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"pbr-specular":case"pbr":case"bake-pbr":case"blinn-phong":a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"skybox":e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"SkyProcedural":a.enableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"particle-shader":a.enableMacro("MATERIAL_OMIT_NORMAL");break}}setAutoSaveSuppressed(e){this._autoSaveSuppressed=e}setRenderQueueType(e){this.engineObject.renderState.renderQueueType=e}setBlendStateEnabled(e){this.engineObject.renderState.blendState.targetBlendState.enabled=e}setDepthWriteEnabled(e){this.engineObject.renderState.depthState.writeEnabled=e}setCullMode(e){this.engineObject.renderState.rasterState.cullMode=e}setBlendMode(e){const t=this.engineObject.renderState.blendState.targetBlendState;switch(e){case I.Normal:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.OneMinusSourceAlpha,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break;case I.Additive:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.One,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break}}bindShaderAsset(e,t){for(const a of this.shaderDataKeys)this.removePropertyChangeListener(a);return this.shaderDataKeys.clear(),e.onReady().then(async()=>{var n;if(e.shaderScriptRefId){const r=this.root.assetStore.assets[e.shaderScriptRefId.refId];this.isInitCompleted&&(r==null||r.onShaderChange(this._engineObject),t=this._getMainData())}const a=e.properties?Y(e.properties):[];e.isBuiltinShader()&&u.initBuiltinMaterial(this.engineObject,e.engineObject),t=t||this._getMainData(),await this._proxyShaderProps(a,t,this.isInitCompleted),this.refreshFormConfig(a,t),this.refreshAnimatableProperties(a),de({assetStore:this.root.assetStore,shaderRef:this.shaderRef,nextShaderAsset:e,material:this}),e.addReferencedMaterial(this),this.shaderRef={refId:e.id},await this.applyBoundPathChange("shader",P.AssetPicker,this.shaderRef),(n=this.updateThumbnail)==null||n.call(this)})}async _proxyShaderProps(e,t,a=!0){var o;this.proxyConfigs=e;const n=(o=this.extraData)==null?void 0:o.disabledMacros,r=e.map(async i=>{var d;if(this.proxySetter(i),this._virualShaderProps(e),i.bundleType==="macro"){const s=i.macroInfo,h=t.macros.find(c=>c.name===i.prop);if(!E(this,i.prop)){let c;h!=null?(c=h.value,s&&(s.checked=!0)):n!=null&&n.includes(i.prop)?(c=void 0,s&&(s.checked=!1)):c=i.defaultValue,x(this,{[i.prop]:c})}if(a)if(h){const c=h.value??i.defaultValue;c==null?s==null||s.onSwitch(!0,this):await i.onChange(this,i.prop,c)}else!(n!=null&&n.includes(i.prop))&&(s!=null&&s.checked)&&(s==null||s.onSwitch(!0,this))}else{const s=t.shaderData[i.prop];let h=s?s.value:this[i.prop]??i.defaultValue;if(h!=null&&h.refId&&!this.root.assetStore.assets[h.refId]&&(h=void 0),((d=i.uiInfo)==null?void 0:d.type)===y.Color)if(i.uiInfo.mode==="hdr"){const c=h.intensity??1;c!==0&&(h.r/=c,h.g/=c,h.b/=c),h.intensity=c}else h.intensity=1;E(this,i.prop)||x(this,{[i.prop]:h}),a&&this.notifyPropertyChange(i.prop,!1)}});await Promise.all(r)}proxySetter(e){const{prop:t,onChange:a,bundleType:n}=e,r=async(o,i)=>{var s;const d=this._engineObject.shaderData;n==="macro"?d.enableMacro(t,o):await F(this,t,o,e.engineType??((s=e.uiInfo)==null?void 0:s.type)),await a(this,t,o),i!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(t,r),this.shaderDataKeys.add(t)}_virualShaderProps(e){const t=this;e.forEach(a=>{X(t,a.prop)})}refreshFormConfig(e,t){var n,r,o,i,d;const a={root:[],groups:{}};if(t){for(const s of e)if(!((n=s.uiInfo)!=null&&n.hide)){if((r=s.uiInfo)!=null&&r.group){if((o=s.uiInfo)!=null&&o.group){let h=a.groups[s.uiInfo.group];h||(h={type:P.Group,property:s.uiInfo.group,children:[]},a.groups[s.uiInfo.group]=h);const c=s.uiInfo;c.property=s.prop,s.macroInfo&&(c.macroConfig=s.macroInfo),h.children.push(c)}}else{const h=s.uiInfo;h.property=s.prop,s.macroInfo&&(h.macroConfig=s.macroInfo),a.root.push(h)}s.bundleType==="macro"?this[s.prop]=((i=t.macros.find(h=>h.name===s.prop))==null?void 0:i.value)??s.defaultValue:this[s.prop]=((d=t.shaderData[s.prop])==null?void 0:d.value)??s.defaultValue}}this.formConfig=a}refreshAnimatableProperties(e){var t,a,n;this._additionAnimatableProperties.length=0;for(const r of e){if(!r.uiInfo||r.uiInfo.hide||r.bundleType==="macro")continue;let o={};if((r.setPath||r.getPath||r.valueType||r.interpolationType)&&(o={setPath:r.setPath,getPath:r.getPath,valueType:r.valueType,interpolationType:r.interpolationType}),!o.setPath&&!o.getPath&&r.engineType&&(r.bundleType==="shaderData"||!r.bundleType))switch(r.engineType){case y.Float:o={setPath:`shaderData.setFloat('${r.prop}', $value)`,getPath:`shaderData.getFloat('${r.prop}')`,valueType:S.Float};break;case y.Integer:o={setPath:`shaderData.setInt('${r.prop}', $value)`,getPath:`shaderData.getInt('${r.prop}')`,valueType:S.Float,interpolationType:Z.Step};break;case y.Vector2:o={setPath:`shaderData.getVector2('${r.prop}')`,getPath:`shaderData.getVector2('${r.prop}')`,valueType:S.Vector2};break;case y.Vector3:o={setPath:`shaderData.getVector3('${r.prop}')`,getPath:`shaderData.getVector3('${r.prop}')`,valueType:S.Vector3};break;case y.Vector4:o={setPath:`shaderData.getVector4('${r.prop}')`,getPath:`shaderData.getVector4('${r.prop}')`,valueType:S.Vector4};break;case y.Color:o={setPath:`shaderData.getColor('${r.prop}')`,getPath:`shaderData.getColor('${r.prop}')`,valueType:S.Color};break;case y.Boolean:o={setPath:`shaderData.setBoolean('${r.prop}', $value)`,getPath:`shaderData.getBoolean('${r.prop}')`,valueType:S.Boolean};break;case y.Texture:o={setPath:`shaderData.setTexture('${r.prop}', $value)`,getPath:`shaderData.getTexture('${r.prop}')`,valueType:S.ReferResource};break}if(!o.setPath&&!o.getPath){if(r.bundleType==="other")continue;continue}this._additionAnimatableProperties.push({property:r.prop,label:(t=r.uiInfo)!=null&&t.label?w(r.uiInfo.label):r.prop,type:(a=r.uiInfo)==null?void 0:a.type,propertyProxyConfig:o}),(n=r.uiInfo)!=null&&n.label&&(o.label=w(r.uiInfo.label)),ee(this,r.prop,o)}}async initByMain(e){var c;const t=JSON.parse(await e.text());this.shaderRef=t.shaderRef;const a=t.shaderData,n=t.macros,r=t.renderState;if(!t.shaderRef)throw"invalid material";const o=new te(this.engine);this.setDragTempEntity(o);const i=await this.root.assetStore.getAssetByRef(t.shaderRef),d=i.engineObject??ae.find("unlit"),s=new re(this.engine,d);this.bindEngineObject(s);const h=s.shaderData;if(n)for(const R of n)h.enableMacro(R.name,R.value);if(a)for(const R in a){const _=a[R];let A=_.value;if(_.type===y.Color){A={..._.value};const T=_.value.intensity??1;T!==0&&(A.r/=T,A.g/=T,A.b/=T)}F(this,R,A,_.type)}r&&this._parseProperty(s,"renderState",r),await this.bindShaderAsset(i,t),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",P.Input,this.name),this._checkSchemaOnInit(t,i)}_checkSchemaOnInit(e,t){e.shader!==t.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(e){const t=this;this.bindEngineObject(e),t.shader=e.shader.name,t._name=e.name??"";const n=Object.values(this.root.assetStore.assets).filter(d=>d.meta.type==="Shader"&&!!d.meta.builtinShaderName).find(d=>d.meta.builtinShaderName===e.shader.name);switch(this.shaderRef={refId:n.id},t.isTransparent=e.renderState.blendState.targetBlendState.enabled,t.alphaCutoff=e.shaderData.getFloat("material_AlphaCutoff"),e.renderState.rasterState.cullMode){case M.Back:t.renderFace=B.Front;break;case M.Front:t.renderFace=B.Back;break;case M.Off:t.renderFace=B.Double;break}t.blendMode=e.renderState.blendState.targetBlendState.destinationColorBlendFactor===b.One?I.Additive:I.Normal;const r=e.shaderData;r.getProperties().forEach(d=>{const s=r.getPropertyValue(d);if(s instanceof se){const h=this.root.assetStore.engineObjectToAssetMap.get(s);this[d.name]=h==null?void 0:h.getCurrentRef()}else this[d.name]=j(s)});const i=this._getMainData();this._proxyShaderProps(C,i,!1),this.bindShaderAsset(n,i)}afterDelete(){var e;(e=this.engineObject)==null||e.destroy(!0)}rename(e){return this.root.assetFacade.persistAssetMain(this.id),super.rename(e)}_getMainData(e){var i,d;const t=[],a=(e??this.engineObject).shaderData;a.getMacros(t);const n=t.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h}),r=[],o={};a.getProperties(r);for(const s of r){let h;if(s.type===f.Texture||s.type===f.TextureArray)h=this[s.name];else{const c=a.getPropertyValue(s);h=j(c),((i=this[s.name])==null?void 0:i.intensity)!=null&&(h.intensity=(d=this[s.name])==null?void 0:d.intensity)}h!=null&&(o[s.name]={type:le(s.type),value:h})}return{name:this.name,shader:this.engineObject.shader.name,macros:n,renderState:this.engineObject.renderState,shaderData:o,shaderRef:this.shaderRef}}getMainData(){return JSON.stringify(this._getMainData())}async initByCreation(){var o;const e=new ne(this.engine),t=[];e.shaderData.getMacros(t);const a=t.map(({name:i,value:d})=>d===void 0?{name:i}:{name:i,value:d});this.bindEngineObject(e);const n={};for(const i of C)i.defaultValue&&(n[i.prop]={value:i.defaultValue,type:i.engineType??((o=i.uiInfo)==null?void 0:o.type)});const r={shaderData:n,shaderRef:{refId:"0000501"},name:this.name,shader:e.shader.name,macros:a,renderState:e.renderState};return this._proxyShaderProps(C,r,!1),r}async onSubAssetEdit(){var n;const e=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(e.engineObject),await e.applyBoundPathChange("name",P.Input,e.name),e.initByEngineObject(e.engineObject),e.updateThumbnail(),await this.root.assetFacade.persistAssetMain(e.id);const t=await this.root.assetStore.getAssetByRef({refId:this.mainId}),a=((n=t.engineObject.materials)==null?void 0:n.indexOf(this._engineObject))??-1;a>=0&&await t.replaceMaterial(a,e.getCurrentRef()),this.root.assetStore.selectAsset(e.id)}saveMainImmediately(){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately().then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}_parseProperty(e,t,a){if(typeof a=="object")for(const n in a)this._parseProperty(e[t],n,a[n]);else e[t]=a}async _onDrop(e,t){const a="material_BaseTexture";if(a in this){const n=t.getCurrentRef();this[a]=n;const r=C.find(o=>o.prop===a);r&&await r.onChange(this,a,n),await this.root.assetFacade.persistAssetMain(this.id)}this.dropping=!1}async onDropToViewport(){const{sceneStore:e,sceneUIStore:t}=this.root,a=t.hoveredEntityId;if(a){const n=e.entities.get(a);if(n){const r=n.getComponentByTypeName("MeshRenderer"),o=n.getComponentByTypeName("SkinnedMeshRenderer"),i=r||o;i&&this.root.componentFacade.updateComponent(n.id,i.id,{material:this.getCurrentRef()})}}this.root.projectStore.currentViewport.viewport.onDrop()}};g([$],u.prototype,"shaderRef",2);g([$.ref],u.prototype,"formConfig",2);g([m],u.prototype,"bindShaderAsset",1);g([m],u.prototype,"_proxyShaderProps",1);g([m],u.prototype,"proxySetter",1);g([m],u.prototype,"_virualShaderProps",1);g([m],u.prototype,"refreshAnimatableProperties",1);g([m],u.prototype,"_onDrop",1);u=g([ie({type:"Material",label:w("asset.material.title"),loaderType:"Material",extname:"mat",importMenuConfig:{type:oe.Add},customInspector:he,viewer:ce,thumbnail:D,dragLayer:N.Material})],u);const _e=Object.freeze(Object.defineProperty({__proto__:null,get MaterialAsset(){return u}},Symbol.toStringTag,{value:"Module"}));export{u as M,ce as a,_e as b};
|
package/dist/viewport-client/_static/{MaterialInspector-e8242674.js → MaterialInspector-a36197f2.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
var L=Object.defineProperty;var A=(d,e,t)=>e in d?L(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var S=(d,e,t)=>(A(d,typeof e!="symbol"?e+"":e,t),t);import{aO as x,aX as N,aQ as j,aU as $,aS as s,aP as M,C as n,bL as V,aD as F,bM as B,aW as f,aR as P,bN as W,e as O}from"./index-
|
|
1
|
+
var L=Object.defineProperty;var A=(d,e,t)=>e in d?L(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var S=(d,e,t)=>(A(d,typeof e!="symbol"?e+"":e,t),t);import{aO as x,aX as N,aQ as j,aU as $,aS as s,aP as M,C as n,bL as V,aD as F,bM as B,aW as f,aR as P,bN as W,e as O}from"./index-1e23212d.js";import{u as T}from"./index-92830754.js";import{I as z}from"./IconPointFilled-209638e2.js";const U=x(z,{marginRight:"-$1",variants:{checked:{true:{color:"$green10"}}}}),Q=x(N,{width:"100%",border:"none",position:"relative",whiteSpace:"pre-wrap",boxShadow:"$2","& > svg":{marginRight:"$1"}});function b(d){return j(function(t){const{inspectorConfig:r,macroConfig:c,...p}=t,{model:i}=p;let{models:g}=p;const{checked:u,onSwitch:h}=c,{type:m,...a}=r,[o,l]=$.useState(u);$.useEffect(()=>{l(u)},[u]),g=g||[i];const R=()=>{const I=!o;if(h)for(const k of g)h(I,k);l(I)},v=r.label;return s.jsxs(M,{direction:"column",fullWidth:!0,children:[m!==n.Null&&o&&V.createElement(d,{...p,inspectorConfig:{...a,type:m}}),s.jsx(F,{label:o?"":v,children:s.jsx(Q,{size:"sm",variant:"subtle",startSlot:s.jsx(U,{size:"12px",checked:o}),onClick:R,children:o?"Enabled ":"Disabled"})})]})})}const X=x(M),q=x(B,{backgroundColor:"$gray1",height:"2px !important"});function D(d){const{inspectorConfig:e,models:t,onModelChange:r,model:c,macroConfig:p}=d,{type:i,property:g,info:u}=e,{t:h}=P(),m=!c&&t&&t.length>1;if(m&&!t.find(y=>e.when?e.when(y):!0)||e.when&&!e.when(c))return null;const a=p?w.getRegisteredMacroComponent(i):w.getRegisteredComponent(i);if(!a)return console.warn(`缺少${i}类型的组件`),null;let o=e.disabled;!m&&c.getEditable&&(o=c.getEditable(e.property)===!1);const l=typeof e.label=="string"?h(e.label):e.label;let R=e.options;R&&(R=R.map(y=>({label:typeof y.label=="string"?h(y.label):y.label,value:y.value})));const v={...e,label:l,info:u,options:R,disabled:o},{triggerAfterInit:I,customComponent:k,...E}=v;return s.jsx(a,{inspectorConfig:E,macroConfig:p,models:t,model:c,onModelChange:r},g)}const C=class C{static registerComponent(e,t){this.components[e]=t}static getRegisteredComponent(e){return C.components[e]}static getRegisteredMacroComponent(e){return C.macroComponents[e]}};S(C,"components",f.getRegisteredComponents()),S(C,"macroComponents",{[n.Color]:b(f.getRegisteredComponent(n.Color)),[n.Vector4]:b(f.getRegisteredComponent(n.Vector4)),[n.Vector3]:b(f.getRegisteredComponent(n.Vector3)),[n.Vector2]:b(f.getRegisteredComponent(n.Vector2)),[n.Number]:b(f.getRegisteredComponent(n.Number)),[n.AssetPicker]:b(f.getRegisteredComponent(n.AssetPicker)),[n.Boolean]:b(f.getRegisteredComponent(n.Boolean)),[n.Null]:b(f.getRegisteredComponent(n.Null))}),S(C,"Item",j(D)),S(C,"List",j(function(t){const{configs:r,models:c,css:p,onModelChange:i,model:g,children:u,fullWidth:h=!1,withSeparator:m}=t;return r!=null&&r.length&&r.sort((a,o)=>{const l=a.priority??0;return(o.priority??0)-l}),r?s.jsxs(X,{css:p,className:"shader-inspector-form",fullWidth:h,children:[r.map(a=>s.jsxs($.Fragment,{children:[s.jsx(C.Item,{inspectorConfig:a,macroConfig:a.macroConfig,model:g,models:c,onModelChange:i},a.property),m&&s.jsx(q,{})]},a.property)),u]}):null}));let w=C;const G=x("div",{backgroundColor:"$appBg",width:"100%"}),H=x("div",{backgroundColor:"$panelBg",borderRadius:"0 0 $2 $2",overflow:"hidden",paddingBottom:"$1"}),J=x("div",{width:"100%",backgroundColor:"$gray3",paddingBottom:"$0_5"}),K=x(B,{backgroundColor:"$appBg",height:"2px !important"}),Y=d=>{var a;const{asset:e}=d,t=e.formConfig,{assetStore:r,inspectorFacade:c}=T(),{i18n:p}=P(),i=r.assets[e.shaderRef.refId],g=i==null?void 0:i.name,u=Object.values(r.assets).filter(o=>o.meta.type==="Shader"&&o.meta.utility!=="error"),h=()=>{r.selectAsset(e.shaderRef.refId)},m=(o,l)=>{c.assetChange(e.id,o,l)};if(t.root)for(const o of t.root){const l=o.comments;l&&(o.info=l[p.language]??l.default??void 0)}return s.jsxs(G,{children:[s.jsx(J,{children:s.jsx(W,{label:O("asset.shader.title"),assets:u,disabled:!!(i!=null&&i.isSubAsset)||e.isSubAsset||!e.getEditable(),value:g,dropLayer:0,onSelect:async o=>{await e.bindShaderAsset(o,e._getMainData()),await c.assetChanges(e.id,{shaderRef:e.shaderRef,shader:e.shader})},onLocate:h})}),((a=t.root)==null?void 0:a.length)>0&&s.jsx(H,{children:s.jsx(w.List,{model:e,onModelChange:m,configs:t.root,withSeparator:!1})}),s.jsx(K,{}),s.jsx(w.List,{model:e,onModelChange:m,configs:Object.values(t.groups)})]})},oe=j(Y);export{oe as M};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aH as _r,aC as c,aO as P,b3 as a,g7 as dt,g8 as bc,b8 as pe,g9 as Mc,ga as wc,gb as Sc,gc as Rc,gd as yc,ge as Ec,gf as Pc,gg as _c,gh as Ic,gi as Ac,gj as F,ds as me,bb as Ne,b9 as $e,be as ee,gk as sn,gl as Ir,gm as Tc,dy as cn,gn as Nc,go as $c,ba as U,bd as G,dt as Ar,du as bt,gp as Tr,gq as Nr,gr as $r,gs as J,gt as Or,gu as jr,gv as Dr,gw as kr,gx as Lr,gy as Fr,b5 as un,b6 as ln,dv as Mt,gz as Oe,dw as Gr,dx as ge,bc as R,gA as dn,dz as Ur,gB as fn,dA as Kr,gC as Br,dB as wt,gD as Oc,gE as Nt,gF as $t,gG as Ot,gH as Ee,gI as er,gJ as jt,gK as Dt,gL as kt,gM as Lt,gN as Ft,gO as tr,bj as jc,gP as Dc}from"./index-
|
|
1
|
+
import{aH as _r,aC as c,aO as P,b3 as a,g7 as dt,g8 as bc,b8 as pe,g9 as Mc,ga as wc,gb as Sc,gc as Rc,gd as yc,ge as Ec,gf as Pc,gg as _c,gh as Ic,gi as Ac,gj as F,ds as me,bb as Ne,b9 as $e,be as ee,gk as sn,gl as Ir,gm as Tc,dy as cn,gn as Nc,go as $c,ba as U,bd as G,dt as Ar,du as bt,gp as Tr,gq as Nr,gr as $r,gs as J,gt as Or,gu as jr,gv as Dr,gw as kr,gx as Lr,gy as Fr,b5 as un,b6 as ln,dv as Mt,gz as Oe,dw as Gr,dx as ge,bc as R,gA as dn,dz as Ur,gB as fn,dA as Kr,gC as Br,dB as wt,gD as Oc,gE as Nt,gF as $t,gG as Ot,gH as Ee,gI as er,gJ as jt,gK as Dt,gL as kt,gM as Lt,gN as Ft,gO as tr,bj as jc,gP as Dc}from"./index-1e23212d.js";/**
|
|
2
2
|
* @license @tabler/icons-react v3.17.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E=Object.defineProperty;var T=(n,e,t)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e,t)=>(T(n,typeof e!="symbol"?e+"":e,t),t);import{bS as v,bT as g,bH as y,ae as i,bU as u,aS as c,aV as b,O as f,bV as p,j as x,n as C,e as V,q as m}from"./index-
|
|
1
|
+
var E=Object.defineProperty;var T=(n,e,t)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e,t)=>(T(n,typeof e!="symbol"?e+"":e,t),t);import{bS as v,bT as g,bH as y,ae as i,bU as u,aS as c,aV as b,O as f,bV as p,j as x,n as C,e as V,q as m}from"./index-1e23212d.js";import"./index-92830754.js";import"./postmen-9e1e15bd.js";import{F as d}from"./index-b2e1cba4.js";import{M}from"./MeshThumbnail-25cd4a13.js";import{A}from"./AssetViewer-0ce46fa1.js";import{e as N}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";class O{static createMesh(e,t){const s=new v(e);return O.setMeshData(s,t),s}static setMeshData(e,t){var s,r;return e.setPositions([...t.positions]),e.setNormals(t.normals),e.setUVs(t.uvs),t.uv1&&e.setUVs(t.uv1,1),t.uv2&&e.setUVs(t.uv2,2),t.uv3&&e.setUVs(t.uv3,3),t.uv4&&e.setUVs(t.uv4,4),t.uv5&&e.setUVs(t.uv5,5),t.uv6&&e.setUVs(t.uv6,6),t.uv7&&e.setUVs(t.uv7,7),t.bounds?(e.bounds.min.copyFrom(t.bounds.min),e.bounds.max.copyFrom(t.bounds.max)):O.calculateBounds(t.positions,e.bounds),(s=t.blendShapes)==null||s.forEach(o=>{const l=new g(o.name);o.frames.forEach(a=>{l.addFrame(a.weight,a.positions,a.normals,a.uvs)}),e.addBlendShape(l)}),(r=t.subMeshes)==null||r.forEach(o=>{e.addSubMesh(o)}),t.indices&&(t.positions.length<=65535?e.setIndices(new Uint16Array(t.indices)):e.setIndices(new Uint32Array(t.indices))),e.uploadData(!1),e}static calculateBounds(e,t){const{min:s,max:r}=t,o=e.length;s.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let l=0;l<o;l++){const a=e[l];s.x=Math.min(a.x,s.x),s.y=Math.min(a.y,s.y),s.z=Math.min(a.z,s.z),r.x=Math.max(a.x,r.x),r.y=Math.max(a.y,r.y),r.z=Math.max(a.z,r.z)}}}class R extends y{constructor(e,t){super(e),this.meshData=t}restoreContent(){O.setMeshData(this.resource,this.meshData)}}var U=(n=>(n.POSITION="Position",n.NORMAL="Normal",n.COLOR_0="Color",n.TANGENT="Tangent",n.WEIGHTS_0="BoneWeight",n.JOINTS_0="BoneIndex",n.TEXCOORD_0="UV",n.TEXCOORD_1="UV1",n.TEXCOORD_2="UV2",n.TEXCOORD_3="UV3",n.TEXCOORD_4="UV4",n.TEXCOORD_5="UV5",n.TEXCOORD_6="UV6",n.TEXCOORD_7="UV7",n))(U||{});const X=["POSITION","NORMAL","COLOR_0","TANGENT","WEIGHTS_0","JOINTS_0","TEXCOORD_0","TEXCOORD_1","TEXCOORD_2","TEXCOORD_3","TEXCOORD_4","TEXCOORD_5","TEXCOORD_6","TEXCOORD_7"],L={[i.Float]:"4 bytes",[i.Vector2]:"8 bytes",[i.Vector3]:"12 bytes",[i.Vector4]:"16 bytes",[i.Byte4]:"4 bytes",[i.UByte4]:"4 bytes",[i.NormalizedByte4]:"4 bytes",[i.NormalizedUByte4]:"4 bytes",[i.NormalizedShort2]:"4 bytes",[i.NormalizedShort4]:"8 bytes",[i.Short2]:"4 bytes",[i.UShort2]:"4 bytes",[i.NormalizedUShort2]:"4 bytes",[i.Short4]:"8 bytes",[i.UShort4]:"8 bytes",[i.NormalizedUShort4]:"8 bytes"};u.Triangles+"",u.TriangleStrip+"",u.TriangleFan+"",u.LineLoop+"",u.LineStrip+"",u.Lines+"",u.Points+"";function S(n){switch(n.topology){case u.Triangles:return`${n.count/3} triangles`;case u.TriangleFan:case u.TriangleStrip:return`${n.count-2} triangles`;case u.Lines:return`${n.count/2} lines`;case u.LineStrip:return`${n.count-1} lines`;case u.LineLoop:return`${n.count} lines`;case u.Points:return`${n.count} points`}}function w(n){if(n instanceof Uint8Array)return"Uint8";if(n instanceof Uint16Array)return"Uint16";if(n instanceof Uint32Array)return"Uint32"}const I=n=>{const e=n.asset.engineObject,t=e.vertexCount,s=e.getIndices(),r=e.subMeshes;return c.jsxs(c.Fragment,{children:[c.jsx(b,{title:`Vertices: ${t}`,defaultOpen:!0,children:X.map(o=>e.vertexElements.find(l=>l.semantic===o)).filter(o=>o!=null).map(o=>c.jsx(d,{label:U[o.attribute],value:`${i[o.format]} (${L[o.format]})`},o.attribute))}),s?c.jsx(b,{title:`Indices: ${s.length}`,defaultOpen:!0,children:c.jsx(d,{label:"Format",value:w(s)})}):null,c.jsx(b,{title:`SubMesh: ${r.length}`,defaultOpen:!0,children:r.map((o,l)=>c.jsx(d,{label:`# ${l}`,value:S(o)},l))})]})};class j extends A{setViewAsset(e,t){const s=t.createChild("mesh_entity"),r=s.addComponent(f);r.mesh=e.engineObject;const o=new p(e.engine);o.baseColor.set(.5,.5,.5,1),r.setMaterial(o),this._entity=s}}var B=Object.defineProperty,F=Object.getOwnPropertyDescriptor,z=(n,e,t,s)=>{for(var r=s>1?void 0:s?F(e,t):e,o=n.length-1,l;o>=0;o--)(l=n[o])&&(r=(s?l(e,t,r):l(r))||r);return s&&r&&B(e,t,r),r};let h=class extends x{constructor(e){super(e);_(this,"meshData",null)}beforeDelete(){return null}afterDelete(){return null}async initByMain(e){const{engine:t}=this,s=JSON.parse(await e.text());this.meshData=s;const r=new v(t);O.setMeshData(r,s),t.resourceManager.addContentRestorer(new R(r,s)),this.bindEngineObject(r),this._releaseMeshCache()}initByEngineObject(e){this.bindEngineObject(e),this._name=e.name,this.meshData={positions:[],subMeshes:[]}}_releaseMeshCache(){const e=this.engineObject;e._verticesUint8=null,e._indices=null,e._verticesFloat32=null,e._positions=null,e._tangents=null,e._normals=null,e._colors=null,e._uv=null,e._uv1=null,e._uv2=null,e._uv3=null,e._uv4=null,e._uv5=null,e._uv6=null,e._uv7=null}};h=z([C({type:"Mesh",label:V("asset.mesh.title"),icon:{},loaderType:"Mesh",extname:"mesh",customInspector:I,viewer:j,thumbnail:M,dragLayer:m.Mesh,async bundle({content:n}){const e=JSON.parse(await n.text()),t=N(e,{type:"Mesh",name:"mesh"});return{content:new Blob([t])}}})],h);export{h as MeshAsset};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var f=(e,r,t)=>r in e?c(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var s=(e,r,t)=>(f(e,typeof r!="symbol"?r+"":r,t),t);import{p as n,C as m,s as p,f as u,z as v,E as b,v as y,x as P,aL as w}from"./index-
|
|
1
|
+
var c=Object.defineProperty;var f=(e,r,t)=>r in e?c(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var s=(e,r,t)=>(f(e,typeof r!="symbol"?r+"":r,t),t);import{p as n,C as m,s as p,f as u,z as v,E as b,v as y,x as P,aL as w}from"./index-1e23212d.js";import"./index-92830754.js";var M=Object.defineProperty,O=Object.getOwnPropertyDescriptor,i=(e,r,t,l)=>{for(var a=l>1?void 0:l?O(r,t):r,h=e.length-1,d;h>=0;h--)(d=e[h])&&(a=(l?d(r,t,a):d(a))||a);return l&&a&&M(r,t,a),a};class o extends b{constructor(){super(...arguments);s(this,"mesh",null);s(this,"material",{refId:"0000200"});s(this,"receiveShadows",!0);s(this,"castShadows",!0);s(this,"priority",0);s(this,"materialOpen",!1)}setMaterialOpen(t){this.materialOpen=t}}i([n({type:m.AssetPicker,assetType:["Mesh"],label:"mesh-renderer.mesh.title",info:"mesh-renderer.mesh.info",bindPath:"mesh"}),p()],o.prototype,"mesh",2);i([n({type:m.AssetPicker,assetType:"Material",label:"mesh-renderer.material.title",info:"mesh-renderer.material.info",customFilter:e=>{var r;return((r=e.engineObject.shader)==null?void 0:r.name)!=="particle-shader"}}),u({engineKey:"setMaterial",setPath:"setMaterial()",getPath:"getMaterial()",valueType:v.ReferResource,getEngineValue:e=>e.getMaterial()}),p({type:"methods",key:"setMaterial",onSerialize:e=>e?[[e]]:void 0,onDeserialize(e){return e?e[0][0]:void 0}})],o.prototype,"material",2);i([n({label:"mesh-renderer.receive-shadows.title",info:"mesh-renderer.receive-shadows.info",bindPath:"receiveShadows"}),y(),p()],o.prototype,"receiveShadows",2);i([n({label:"mesh-renderer.cast-shadows.title",info:"mesh-renderer.cast-shadows.info",bindPath:"castShadows"}),y(),p()],o.prototype,"castShadows",2);i([n({label:"mesh-renderer.priority.title",info:"mesh-renderer.priority.info",bindPath:"priority"}),p()],o.prototype,"priority",2);i([P],o.prototype,"materialOpen",2);i([w],o.prototype,"setMaterialOpen",1);export{o as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as l}from"./index-
|
|
1
|
+
import{u as l}from"./index-92830754.js";import{aQ as f,aU as c,aS as m,aW as h,p as d}from"./index-1e23212d.js";import{c as u}from"./Component-746be670.js";import{c as M}from"./createOnModelChange-b57a0da8.js";import{R}from"./ReferencedMaterial-800a1955.js";import{M as v}from"./MeshRendererBaseComponent-4a3af376.js";import"./MaterialInspector-a36197f2.js";import"./IconPointFilled-209638e2.js";const x=f(function(s){const[r,o]=c.useState(null),e=s.data,{assetStore:t,inspectorFacade:n}=l();return c.useEffect(()=>{t.getAssetByRef(e.material).then(a=>{o(a)})},[e.material]),m.jsxs(m.Fragment,{children:[m.jsx(h.List,{model:e,configs:e.formSchema.items,onModelChange:M("component",e.id,n,e)}),r&&m.jsx(R,{materialAsset:r})]})});var C=Object.defineProperty,j=Object.getOwnPropertyDescriptor,i=(s,r,o,e)=>{for(var t=e>1?void 0:e?j(r,o):r,n=s.length-1,a;n>=0;n--)(a=s[n])&&(t=(e?a(r,o,t):a(t))||t);return e&&t&&C(r,o,t),t};let p=class extends v{constructor(s,r){super(s,r)}};i([d({assetType:["PrimitiveMesh","Mesh"]})],p.prototype,"mesh",2);p=i([u({type:"MeshRenderer",customInspector:x,componentsMenu:{label:"component.renderer.mesh.title"}})],p);export{p as MeshRendererComponent};
|
package/dist/viewport-client/_static/{MeshThumbnail-ab28b3b8.js → MeshThumbnail-25cd4a13.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=Object.defineProperty;var c=(i,e,t)=>e in i?r(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(c(i,typeof e!="symbol"?e+"":e,t),t);import{O as h,Q as o,H as d}from"./index-
|
|
1
|
+
var r=Object.defineProperty;var c=(i,e,t)=>e in i?r(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(c(i,typeof e!="symbol"?e+"":e,t),t);import{O as h,Q as o,H as d}from"./index-1e23212d.js";class a{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.meshRenderer.mesh=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("mesh");t.transform.setRotation(16,-47.4,-16.7),this.meshRenderer=t.addComponent(h);const s=new o(e.engine);s.baseColor.set(.7,.7,.7,1),s.metallic=0,s.renderFace=d.Double,this.meshRenderer.setMaterial(s)}}n(a,"entity"),n(a,"meshRenderer");export{a as M};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ut=Object.defineProperty;var Jt=(a,e,t)=>e in a?Ut(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var x=(a,e,t)=>(Jt(a,typeof e!="symbol"?e+"":e,t),t);import{aH as Re,b9 as we,aC as T,aD as ge,b8 as Ee,ci as be,c9 as Tt,ca as jt,cj as ie,ch as le,eH as Ce,aG as Qt,aQ as Z,aU as $,aS as C,aW as ea,aO as ta,aP as Lt,aF as aa,dD as ra,aR as G,bm as oa,cC as te,bl as st,eT as ze,eU as me,bN as na,by as sa,cy as R,eV as ia,bX as _t,eW as la,eX as ca,eY as pa,eZ as ua,e_ as ma,e$ as q,f0 as da,f1 as ha,f2 as fa,f3 as de,dQ as ya,cf as Te,cg as je,bP as ve,cl as St,B as Mt,cm as Pt,eO as ba,E as va,C as A,f4 as W,f5 as Y,f6 as ye,e as n,x as Q,f as V,z as ga,p as z,s as O}from"./index-
|
|
1
|
+
var Ut=Object.defineProperty;var Jt=(a,e,t)=>e in a?Ut(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var x=(a,e,t)=>(Jt(a,typeof e!="symbol"?e+"":e,t),t);import{aH as Re,b9 as we,aC as T,aD as ge,b8 as Ee,ci as be,c9 as Tt,ca as jt,cj as ie,ch as le,eH as Ce,aG as Qt,aQ as Z,aU as $,aS as C,aW as ea,aO as ta,aP as Lt,aF as aa,dD as ra,aR as G,bm as oa,cC as te,bl as st,eT as ze,eU as me,bN as na,by as sa,cy as R,eV as ia,bX as _t,eW as la,eX as ca,eY as pa,eZ as ua,e_ as ma,e$ as q,f0 as da,f1 as ha,f2 as fa,f3 as de,dQ as ya,cf as Te,cg as je,bP as ve,cl as St,B as Mt,cm as Pt,eO as ba,E as va,C as A,f4 as W,f5 as Y,f6 as ye,e as n,x as Q,f as V,z as ga,p as z,s as O}from"./index-1e23212d.js";import{u as Rt}from"./index-92830754.js";import{c as xa}from"./Component-746be670.js";import"./postmen-9e1e15bd.js";import{c as Sa}from"./createOnModelChange-b57a0da8.js";import{R as Ma}from"./ReferencedMaterial-800a1955.js";import"./TextureAsset-93475ade.js";import"./GlTFAsset-5f37feef.js";import"./MaterialAsset-3b56ac00.js";import{MeshAsset as Pa}from"./MeshAsset-2cf47eb2.js";import"./AnimatorControllerAsset-1c05f4db.js";import"./AnimationClipAsset-61699477.js";import"./SpriteAsset-4e895da5.js";import"./SpriteAtlasAsset-c2894c12.js";import"./AmbientLightAsset-f9c1eb91.js";import"./LottieAsset-9d3ef507.js";import"./ShaderChunkAsset-e9072307.js";import"./SpineSkeletonDataAsset-5b202ba0.js";import"./FontAsset-a3a92f7d.js";import"./SceneAsset-87f2ea92.js";import"./ShaderAsset-98ce1f70.js";import"./PrimitiveMesh-35092ad0.js";import"./XRReferenceImageAsset-dbf129aa.js";import"./PrefabAsset-d0c0cd25.js";import"./PhysicsMaterialAsset-d87d35aa.js";import"./RenderTargetAsset-a003f9f5.js";import"./AudioAsset-5127eeec.js";import"./index-c20fc198.js";import"./MarkdownAsset-a17933fb.js";import{B as tt}from"./index-07bbf729.js";import"./MaterialInspector-a36197f2.js";import"./IconPointFilled-209638e2.js";import"./enum-58295f88.js";import"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import"./Tooltip-dfde37c6.js";import"./AssetViewer-0ce46fa1.js";import"./ktx2-encoder-075abd75.js";import"./TaskQueue-05c94a4d.js";import"./glTFIO-79bbca27.js";import"./ProxyConfigs-ad92ebc7.js";import"./index-b2e1cba4.js";import"./MeshThumbnail-25cd4a13.js";import"./bundlers-9b0d37fc.js";import"./assetEditorActions-c4e5962f.js";import"./module-251ecc50.js";import"./module-498119f3.js";import"./FormItemArray-a2f72cf1.js";import"./Accordion-930aedee.js";import"./IconEdit-2c768a0a.js";import"./ShaderUIScriptAsset-ac824e68.js";import"./module-c6e2d190.js";import"./Menu-0a7dbec0.js";/**
|
|
2
2
|
* @license @tabler/icons-react v3.17.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var M=(t,i,e)=>i in t?y(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e;var r=(t,i,e)=>(M(t,typeof i!="symbol"?i+"":i,e),e);import{j as h,P as a,k as d,p as l,C as b,m,n as v,e as C,o as F,q as P}from"./index-
|
|
1
|
+
var y=Object.defineProperty;var M=(t,i,e)=>i in t?y(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e;var r=(t,i,e)=>(M(t,typeof i!="symbol"?i+"":i,e),e);import{j as h,P as a,k as d,p as l,C as b,m,n as v,e as C,o as F,q as P}from"./index-1e23212d.js";import"./index-92830754.js";var f=Object.defineProperty,g=Object.getOwnPropertyDescriptor,c=(t,i,e,n)=>{for(var o=n>1?void 0:n?g(i,e):i,u=t.length-1,p;u>=0;u--)(p=t[u])&&(o=(n?p(i,e,o):p(o))||o);return n&&o&&f(i,e,o),o};let s=class extends h{constructor(i){super(i);r(this,"dynamicFriction",.6);r(this,"staticFriction",.6);r(this,"bounciness",0);r(this,"frictionCombine",a.Average);r(this,"bounceCombine",a.Average)}async initByMain(i){const e=JSON.parse(await i.text()),n=new d;n.dynamicFriction=this.dynamicFriction=e.dynamicFriction,n.staticFriction=this.staticFriction=e.staticFriction,n.bounciness=this.bounciness=e.bounciness,n.frictionCombine=this.frictionCombine=e.frictionCombine,n.bounceCombine=this.bounceCombine=e.bounceCombine,this.bindEngineObject(n)}async initByCreation(){return this.getMainData()}destroy(){var i;super.destroy(),(i=this.engineObject)==null||i.destroy()}};c([l({type:b.Number,label:"DynamicFriction",bindPath:"dynamicFriction"}),m()],s.prototype,"dynamicFriction",2);c([l({type:b.Number,label:"StaticFriction",bindPath:"staticFriction"}),m()],s.prototype,"staticFriction",2);c([l({type:b.Number,min:0,max:1,label:"Bounciness",bindPath:"bounciness"}),m()],s.prototype,"bounciness",2);c([l({type:b.Select,label:"FrictionCombine",bindPath:"frictionCombine",options:[{label:"Average",value:a.Average},{label:"Minimum",value:a.Minimum},{label:"Multiply",value:a.Multiply},{label:"Maximum",value:a.Maximum}]}),m()],s.prototype,"frictionCombine",2);c([l({type:b.Select,label:"BounceCombine",bindPath:"bounceCombine",options:[{label:"Average",value:a.Average},{label:"Minimum",value:a.Minimum},{label:"Multiply",value:a.Multiply},{label:"Maximum",value:a.Maximum}]}),m()],s.prototype,"bounceCombine",2);s=c([v({type:"PhysicsMaterial",label:C("asset.physics-material.title"),extname:"physMat",importMenuConfig:{type:F.Add},dragLayer:P.PhysicsMaterial,async bundle({content:t}){return{content:t}}})],s);export{s as PhysicsMaterialAsset};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ce=Object.defineProperty;var pe=(o,t,e)=>t in o?ce(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var p=(o,t,e)=>(pe(o,typeof t!="symbol"?t+"":t,e),e);import{aQ as j,aR as z,aS as l,bm as X,cC as P,bl as oe,ej as L,dQ as ne,bN as de,q as ye,cR as q,ek as B,el as J,em as I,en as N,cy as E,f as he,z as me,s as y,p as h,e as r,eo as ue,E as se,ep as U,eq as S,er as V,C as m,es as Y,et as fe,eu as G,dZ as re,ev as be,ew as ge,bq as Ce,cP as W,bs as xe,bt as Se}from"./index-aec7e708.js";import{r as ae}from"./index-e8a45e82.js";import{c as A}from"./Component-ed7aa0ab.js";import"./postmen-2f47f6bb.js";import{F as Pe}from"./FormItemArray-6d69acd4.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 t={};return Object.keys(o.props).forEach(e=>{je[o.class].includes(e)&&(t[e]=o.props[e])}),t}const ze=async(o,t,e)=>{const i=o.engineObject,n=i.shapes;if(n.length===e.length&&e.every((s,a)=>Oe(s.class,n[a]))){for(let s=0;s<e.length;s++)await H(n[s],e[s]),Q(n[s],e[s]);return}i.clearShapes();for(let s=0;s<e.length;s++){const a=e[s],d=De(a);await H(d,a),Q(d,a),i.addShape(d)}};async function H(o,t){const e=t.props.material;if(e!=null&&e.refId)try{const i=await ae.assetStore.getAssetByRef(e);i!=null&&i.engineObject&&(o.material=i.engineObject)}catch(i){console.error(i)}}function Oe(o,t){switch(o){case"BoxColliderShape":return t instanceof N;case"CapsuleColliderShape":return t instanceof I;case"PlaneColliderShape":return t instanceof J;case"SphereColliderShape":return t instanceof B;default:return!1}}function De(o){switch(o.class){case"BoxColliderShape":return new N;case"CapsuleColliderShape":return new I;case"PlaneColliderShape":return new J;case"SphereColliderShape":return new B}}function Q(o,t){const e=t.props;if(o instanceof N&&e.size){const s=o.size;s.copyFrom(e.size),o.size=s}else o instanceof I?(e.radius!==void 0&&(o.radius=e.radius),e.height!==void 0&&(o.height=e.height),e.upAxis!==void 0&&(o.upAxis=e.upAxis)):o instanceof B&&e.radius!==void 0&&(o.radius=e.radius);o.isTrigger=e.isTrigger;const i=o.position;i.copyFrom(e.position),o.position=i;const n=o.rotation;n.copyFrom(e.rotation),o.rotation=n}const _e=o=>o.map(t=>{if(t instanceof N)return{class:"BoxColliderShape",props:{isTrigger:t.isTrigger,size:{x:t.size.x,y:t.size.y,z:t.size.z},position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}};if(t instanceof I)return{class:"CapsuleColliderShape",props:{isTrigger:t.isTrigger,radius:t.radius,height:t.height,upAxis:t.upAxis,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}};if(t instanceof J)return{class:"PlaneColliderShape",props:{isTrigger:t.isTrigger,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}};if(t instanceof B)return{class:"SphereColliderShape",props:{isTrigger:t.isTrigger,radius:t.radius,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}}}),we=j(({item:o,onItemChange:t})=>{const{t:e}=z();return l.jsx(l.Fragment,{children:l.jsx(X,{label:e("physics.shape.box.size.title"),info:e("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"&&t(a=>{a.props.size={...a.props.size,[n]:s}})}})})}),Te=j(()=>l.jsx(l.Fragment,{})),Ae=j(({item:o,onItemChange:t})=>{const{t:e}=z();return l.jsx(l.Fragment,{children:l.jsx(P,{label:e("physics.shape.sphere.radius.title"),info:e("physics.shape.sphere.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&t(n=>{n.props.radius=i})}})})}),Me=j(({item:o,onItemChange:t})=>{const{t:e}=z();return l.jsxs(l.Fragment,{children:[l.jsx(P,{label:e("physics.shape.capsule.radius.title"),info:e("physics.shape.capsule.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&t(n=>{n.props.radius=i})}}),l.jsx(P,{label:e("physics.shape.capsule.height.title"),info:e("physics.shape.capsule.height.info"),value:o.props.height,min:0,onChange:i=>{typeof i=="number"&&t(n=>{n.props.height=i})}}),l.jsx(oe,{label:e("physics.shape.capsule.up-axis.title"),info:e("physics.shape.capsule.up-axis.info"),options:[{label:"X",value:L.X},{label:"Y",value:L.Y},{label:"Z",value:L.Z}],value:o.props.upAxis,onChange:i=>{t(n=>{n.props.upAxis=i})}})]})}),Fe={BoxColliderShape:we,CapsuleColliderShape:Me,PlaneColliderShape:Te,SphereColliderShape:Ae},Z={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:L.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:t})=>{var d;const{t:e}=z(),i=Fe[o.class],n=ae.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(ne,{label:e("physics.collider.trigger.title"),info:e("physics.collider.trigger.info"),value:o.props.isTrigger,onChange:c=>{t(f=>{f.props.isTrigger=c})}}),l.jsx(de,{label:e("physics.collider.material.title"),info:e("physics.collider.material.info"),dropLayer:ye.PhysicsMaterial,value:a==null?void 0:a.name,assets:s,onSelect:c=>{t(f=>{f.props.material=c.getCurrentRef()})},onLocate:()=>{a&&a.id&&n.selectAsset(a.id)}}),l.jsx(i,{item:o,onItemChange:t}),l.jsx(X,{label:e("physics.collider.local-position.title"),info:e("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"&&t(b=>{b.props.position={...b.props.position,[f]:u}})}}),l.jsx(X,{label:e("physics.collider.rotation.title"),info:e("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"&&t(b=>{b.props.rotation={...b.props.rotation,[f]:u}})}})]})}),Be=j(({collider:o,item:t,index:e,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 q||(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=E(f),b=u[e];b&&(c(b),i==null||i("colliderShapes",u))};return l.jsxs(l.Fragment,{children:[l.jsx(oe,{label:n("physics.shape.type.title"),info:n("physics.shape.type.info"),value:t.class,options:s,onChange:c=>{Z[c].class!==t.class&&d(u=>{Object.assign(u,E(Z[c]))})}}),l.jsx(Ve,{item:t,onItemChange:d})]})}),Ie=j(({model:o,inspectorConfig:t,onModelChange:e})=>{const{label:i}=t,n=o.colliderShapes,{t:s}=z(),a=d=>{const c=E(n);d(c),e==null||e("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:e}),id:`${c}`,name:s("physics.shape.item-name",{index:c})})),addable:!0,onAdd:()=>{a(d=>{d.push(E(Z.BoxColliderShape))})},onDelete:d=>{a(c=>{c.splice(+d.id,1)})},addItemText:s("physics.shape.add")})});var Ne=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Le=(o,t,e,i)=>{for(var n=i>1?void 0:i?$e(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Ne(t,e,n),n};async function Ee(o,t){let e;switch(o.class){case"BoxColliderShape":{e=new N;const i=e.size,n=o.props.size;n&&(i.set(n.x,n.y,n.z),e.size=i);break}case"CapsuleColliderShape":{e=new I,o.props.radius!==void 0&&(e.radius=o.props.radius),o.props.height!==void 0&&(e.height=o.props.height),o.props.upAxis!==void 0&&(e.upAxis=o.props.upAxis);break}case"PlaneColliderShape":{e=new J;break}case"SphereColliderShape":{e=new B,o.props.radius!==void 0&&(e.radius=o.props.radius);break}default:throw new Error(`Unknown collider shape class: ${o.class}`)}if(o.props.isTrigger!==void 0&&(e.isTrigger=o.props.isTrigger),o.props.position){const i=o.props.position,n=e.position;n.set(i.x,i.y,i.z),e.position=n}if(o.props.rotation){const i=o.props.rotation,n=e.rotation;n.set(i.x,i.y,i.z),e.rotation=n}if(o.props.material){const i=o.props.material;if(i.refId){const n=await t.getAssetByRef({refId:i.refId});if(!(n!=null&&n.engineObject))throw ue(`Physics material is not ready for refId: ${i.refId}`);e.material=n.engineObject}}return e}class R extends se{constructor(){super(...arguments);p(this,"colliderShapes",[])}}Le([he({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:me.Object,getEngineValue:o=>o.shapes,getEditorValue:_e}),y({type:"methods",key:"addShape",canonicalizeToProps:!0,onSerialize:o=>o.map(t=>[{class:t.class,props:ve(t)}]),onDeserialize:o=>o.map(t=>t[0]),resolveMethodArguments:async(o,t)=>{const e=[];for(const i of o)if(i&&typeof i=="object"&&"class"in i&&"props"in i){const s=await Ee(i,t.root.assetStore);e.push(s)}else e.push(i);return e}}),h({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Ie,onChange:ze})],R.prototype,"colliderShapes",2);var Je=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Xe=(o,t,e,i)=>{for(var n=i>1?void 0:i?Re(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Je(t,e,n),n};let k=class extends R{constructor(o,t){super(o,t)}};k=Xe([A({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],k);const ee=o=>Object.keys(S).filter(t=>(o&S[t])!==0).map(t=>String(S[t])),qe=j(({model:o,onModelChange:t})=>{const e=n=>{const a=n.map(d=>parseInt(d)).reduce((d,c)=>d|c,S.None);t==null||t("constraints",a)},{t:i}=z();return l.jsxs(l.Fragment,{children:[l.jsx(U,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:ee(o.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:e}),l.jsx(U,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:ee(o.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:e})]})});var Ye=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,C=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ze(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Ye(t,e,n),n};let g=class extends R{constructor(t,e){super(t,e);p(this,"isKinematic",!1);p(this,"collisionDetectionMode",V.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.applyBoundPathChange("enabled",m.Toggle,!1)}onInitComplete(){this.applyBoundPathChange("enabled",m.Toggle,!1)}};C([y(),h({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:m.Boolean,bindPath:"isKinematic"})],g.prototype,"isKinematic",2);C([y(),h({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:m.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:V.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:V.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:V.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:V.ContinuousSpeculative}]})],g.prototype,"collisionDetectionMode",2);C([y(),h({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:qe,bindPath:"constraints"})],g.prototype,"constraints",2);C([y(),h({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:m.Number})],g.prototype,"mass",2);C([y(),h({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:m.Boolean})],g.prototype,"useGravity",2);C([y(),h({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:m.Number})],g.prototype,"linearDamping",2);C([y(),h({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:m.Number})],g.prototype,"angularDamping",2);C([y(),h({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:m.Boolean,onChange:(o,t,e)=>{if(e){const i=o.engineObject.centerOfMass;o.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticCenterOfMass",2);C([y(),h({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:m.Vector3,bindPath:"centerOfMass",when:o=>!o.automaticCenterOfMass})],g.prototype,"centerOfMass",2);C([y(),h({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:m.Boolean,onChange:(o,t,e)=>{if(e){const i=o.engineObject.inertiaTensor;o.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticInertiaTensor",2);C([y(),h({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:m.Vector3,bindPath:"inertiaTensor",when:o=>!o.automaticInertiaTensor})],g.prototype,"inertiaTensor",2);C([y(),h({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:m.Vector3,bindPath:"linearVelocity"})],g.prototype,"linearVelocity",2);C([y(),h({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:m.Vector3,bindPath:"angularVelocity"})],g.prototype,"angularVelocity",2);C([y(),h({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:m.Number})],g.prototype,"maxAngularVelocity",2);C([y(),h({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:m.Number})],g.prototype,"maxDepenetrationVelocity",2);C([y(),h({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:m.Number})],g.prototype,"sleepThreshold",2);C([y(),h({label:r("physics.dynamic-collider.solver-iterations.title"),info:r("physics.dynamic-collider.solver-iterations.info"),bindPath:"solverIterations",min:0,max:10,dragStep:1,type:m.Slider})],g.prototype,"solverIterations",2);g=C([A({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],g);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,$=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ke(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Ge(t,e,n),n};let T=class extends R{constructor(t,e){super(t,e);p(this,"stepOffset",.5);p(this,"upDirection",{x:0,y:1,z:0});p(this,"slopeLimit",45);p(this,"nonWalkableMode",Y.PreventClimbing)}async bindEngineObject(t){await super.bindEngineObject(t),t.enabled=!1}};$([y(),h({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:m.Number})],T.prototype,"stepOffset",2);$([y(),h({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:m.Vector3,bindPath:"upDirection"})],T.prototype,"upDirection",2);$([y(),h({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:m.Number})],T.prototype,"slopeLimit",2);$([y(),h({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:m.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}]})],T.prototype,"nonWalkableMode",2);T=$([A({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],T);function Ue(o,t){if(!t)return null;const e=o.entities.get(t),i=(e==null?void 0:e.getComponentByTypeName("DynamicCollider"))||(e==null?void 0:e.getComponentByTypeName("StaticCollider"));return i?{ownerId:t,componentId:i.id}:null}const We=j(o=>{const{inspectorConfig:t,model:e,onModelChange:i}=o,{property:n,label:s,disabled:a,info:d}=t,{ownerId:c}=e[n]||{},f=o.model.root.sceneStore,u=c&&f.entities.get(c),b=F=>{i==null||i(n,Ue(f,F))},{t:x}=z(),le=Array.from(f.entities.values());return l.jsx(l.Fragment,{children:l.jsx(fe,{label:x(s),info:x(d),entities:le,value:c,disabled:a,customFilter:F=>{let K=null;return e.entityModelId!==F.id&&(K=F.getComponentByTypeName("DynamicCollider")||F.getComponentByTypeName("StaticCollider")),K},displayValue:u==null?void 0:u.name,placeholder:x("physics.collider-picker.placeholder"),onSelect:b,onLocate:()=>{o.model.root.sceneStore.selectEntity(c)},onDelete:()=>{b(null)}})})});var He=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,D=(o,t,e,i)=>{for(var n=i>1?void 0:i?Qe(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&He(t,e,n),n};class v extends se{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(e,i,n){var s,a;if(e==="connectedCollider"){const d=n,c=((a=(s=this.root.sceneStore.entities.get(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(e,i,c);return}await super.applyBoundPathChange(e,i,n)}}D([y(),h({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:We,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);D([y(),h({label:r("physics.joint.anchor.title"),type:m.Vector3,bindPath:"anchor",onChange(o,t,e){if(o.automaticConnectedAnchor){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);D([y(),h({label:r("physics.joint.automatic-connected-anchor.title"),type:m.Boolean,bindPath:"automaticConnectedAnchor",onChange(o,t,e){if(e){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);D([y(),h({label:r("physics.joint.connected-anchor.title"),type:m.Vector3,bindPath:"connectedAnchor",when:o=>!o.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);D([y(),h({label:r("physics.joint.break-force.title"),type:m.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);D([y(),h({label:r("physics.joint.break-torque.title"),type:m.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);D([y(),h({label:r("physics.joint.mass-scale.title"),type:m.Number,bindPath:"massScale"})],v.prototype,"massScale",2);D([y(),h({label:r("physics.joint.connected-mass-scale.title"),type:m.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var ke=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(o,t,e,i)=>{for(var n=i>1?void 0:i?et(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&ke(t,e,n),n};let te=class extends v{constructor(o,t){super(o,t)}};te=tt([A({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],te);const it=j(o=>{const{inspectorConfig:t,model:e,onModelChange:i}=o,{property:n,label:s,info:a}=t,d=e.useLimits,c=e.useSpring,f=e[n],u=f.props,{t:b}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(re,{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})}),ot=j(o=>{const{inspectorConfig:t,model:e,onModelChange:i}=o,{property:n,label:s,info:a}=t,d=e.useMotor,c=e[n],f=c.props,{t:u}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(re,{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(ne,{label:u("physics.joint-motor.free-spin"),value:f.freeSpin,onChange:b=>{f.freeSpin=b,i(n,c)}})]}):null})});var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,w=(o,t,e,i)=>{for(var n=i>1?void 0:i?st(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&nt(t,e,n),n};let O=class extends v{constructor(t,e){super(t,e);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(t,e,i){if(t==="limits"){const n=this._buildLimitsFromModel(i);if(!n)return;await super.applyBoundPathChange(t,e,n);return}if(t==="motor"){const n=this._buildMotorFromModel(i);if(!n)return;await super.applyBoundPathChange(t,e,n);return}await super.applyBoundPathChange(t,e,i)}_buildLimitsFromModel(t){const e=t==null?void 0:t.props;if(!e)return null;const i=new be;return i.max=e.max,i.min=e.min,i.contactDistance=e.contactDistance,i.stiffness=e.stiffness,i.damping=e.damping,i}_buildMotorFromModel(t){const e=t==null?void 0:t.props;if(!e)return null;const i=new ge;return i.targetVelocity=e.targetVelocity,i.forceLimit=e.forceLimit,i.gearRatio=e.gearRatio,i.freeSpin=e.freeSpin,i}};w([y(),h({label:r("physics.hinge-joint.axis.title"),type:m.Vector3,bindPath:"axis"})],O.prototype,"axis",2);w([y(),h({label:r("physics.hinge-joint.use-limits.title"),type:m.Boolean,bindPath:"useLimits"})],O.prototype,"useLimits",2);w([y(),h({label:r("physics.hinge-joint.use-spring.title"),type:m.Boolean,bindPath:"useSpring"})],O.prototype,"useSpring",2);w([y(),h({label:r("physics.hinge-joint.limits.title"),customComponent:it,bindPath:"limits"})],O.prototype,"limits",2);w([y(),h({label:r("physics.hinge-joint.use-motor.title"),type:m.Boolean,bindPath:"useMotor"})],O.prototype,"useMotor",2);w([y(),h({label:r("physics.hinge-joint.motor.title"),customComponent:ot,bindPath:"motor"})],O.prototype,"motor",2);O=w([A({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],O);var rt=Object.defineProperty,at=Object.getOwnPropertyDescriptor,M=(o,t,e,i)=>{for(var n=i>1?void 0:i?at(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&rt(t,e,n),n};let _=class extends v{constructor(t,e){super(t,e);p(this,"spring",10);p(this,"damper",.2);p(this,"minDistance",0);p(this,"maxDistance",0);p(this,"tolerance",.025)}};M([y(),h({label:r("physics.spring-joint.spring.title"),type:m.Number,bindPath:"spring"})],_.prototype,"spring",2);M([y(),h({label:r("physics.spring-joint.damper.title"),type:m.Number,bindPath:"damper"})],_.prototype,"damper",2);M([y(),h({label:r("physics.spring-joint.min-distance.title"),type:m.Number,bindPath:"minDistance"})],_.prototype,"minDistance",2);M([y(),h({label:r("physics.spring-joint.max-distance.title"),type:m.Number,bindPath:"maxDistance"})],_.prototype,"maxDistance",2);M([y(),h({label:r("physics.spring-joint.tolerance.title"),type:m.Number,bindPath:"tolerance"})],_.prototype,"tolerance",2);_=M([A({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],_);class lt extends Ce{constructor(){super(...arguments);p(this,"_isPlaying",!1)}onPlay(e){this._isPlaying=e,this._toggleAll(e)}onAddComponent(e){!this._isPlaying&&(e instanceof W||e instanceof q)&&(e.enabled=!1)}_toggleAll(e){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(W,n),d.getComponentsIncludeChildren(q,s)}),n.forEach(d=>{d.enabled=e}),s.forEach(d=>{d.enabled=e})}}var ct=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(o,t,e,i)=>{for(var n=i>1?void 0:i?pt(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&ct(t,e,n),n};let ie=class{constructor(){p(this,"script")}init(){this.script=xe.addScript(lt)}};ie=dt([Se({type:"physicsStore"})],ie);export{T as C,g as D,te as F,O as H,ie as P,k as S,_ as a};
|
|
1
|
+
var ce=Object.defineProperty;var pe=(o,t,e)=>t in o?ce(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var p=(o,t,e)=>(pe(o,typeof t!="symbol"?t+"":t,e),e);import{aQ as j,aR as z,aS as l,bm as X,cC as P,bl as oe,ej as L,dQ as ne,bN as de,q as ye,cR as q,ek as B,el as J,em as I,en as N,cy as E,f as he,z as me,s as y,p as h,e as r,eo as ue,E as se,ep as U,eq as S,er as V,C as m,es as Y,et as fe,eu as G,dZ as re,ev as be,ew as ge,bq as Ce,cP as W,bs as xe,bt as Se}from"./index-1e23212d.js";import{r as ae}from"./index-92830754.js";import{c as A}from"./Component-746be670.js";import"./postmen-9e1e15bd.js";import{F as Pe}from"./FormItemArray-a2f72cf1.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 t={};return Object.keys(o.props).forEach(e=>{je[o.class].includes(e)&&(t[e]=o.props[e])}),t}const ze=async(o,t,e)=>{const i=o.engineObject,n=i.shapes;if(n.length===e.length&&e.every((s,a)=>Oe(s.class,n[a]))){for(let s=0;s<e.length;s++)await H(n[s],e[s]),Q(n[s],e[s]);return}i.clearShapes();for(let s=0;s<e.length;s++){const a=e[s],d=De(a);await H(d,a),Q(d,a),i.addShape(d)}};async function H(o,t){const e=t.props.material;if(e!=null&&e.refId)try{const i=await ae.assetStore.getAssetByRef(e);i!=null&&i.engineObject&&(o.material=i.engineObject)}catch(i){console.error(i)}}function Oe(o,t){switch(o){case"BoxColliderShape":return t instanceof N;case"CapsuleColliderShape":return t instanceof I;case"PlaneColliderShape":return t instanceof J;case"SphereColliderShape":return t instanceof B;default:return!1}}function De(o){switch(o.class){case"BoxColliderShape":return new N;case"CapsuleColliderShape":return new I;case"PlaneColliderShape":return new J;case"SphereColliderShape":return new B}}function Q(o,t){const e=t.props;if(o instanceof N&&e.size){const s=o.size;s.copyFrom(e.size),o.size=s}else o instanceof I?(e.radius!==void 0&&(o.radius=e.radius),e.height!==void 0&&(o.height=e.height),e.upAxis!==void 0&&(o.upAxis=e.upAxis)):o instanceof B&&e.radius!==void 0&&(o.radius=e.radius);o.isTrigger=e.isTrigger;const i=o.position;i.copyFrom(e.position),o.position=i;const n=o.rotation;n.copyFrom(e.rotation),o.rotation=n}const _e=o=>o.map(t=>{if(t instanceof N)return{class:"BoxColliderShape",props:{isTrigger:t.isTrigger,size:{x:t.size.x,y:t.size.y,z:t.size.z},position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}};if(t instanceof I)return{class:"CapsuleColliderShape",props:{isTrigger:t.isTrigger,radius:t.radius,height:t.height,upAxis:t.upAxis,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}};if(t instanceof J)return{class:"PlaneColliderShape",props:{isTrigger:t.isTrigger,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}};if(t instanceof B)return{class:"SphereColliderShape",props:{isTrigger:t.isTrigger,radius:t.radius,position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}}}}),we=j(({item:o,onItemChange:t})=>{const{t:e}=z();return l.jsx(l.Fragment,{children:l.jsx(X,{label:e("physics.shape.box.size.title"),info:e("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"&&t(a=>{a.props.size={...a.props.size,[n]:s}})}})})}),Te=j(()=>l.jsx(l.Fragment,{})),Ae=j(({item:o,onItemChange:t})=>{const{t:e}=z();return l.jsx(l.Fragment,{children:l.jsx(P,{label:e("physics.shape.sphere.radius.title"),info:e("physics.shape.sphere.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&t(n=>{n.props.radius=i})}})})}),Me=j(({item:o,onItemChange:t})=>{const{t:e}=z();return l.jsxs(l.Fragment,{children:[l.jsx(P,{label:e("physics.shape.capsule.radius.title"),info:e("physics.shape.capsule.radius.info"),value:o.props.radius,min:0,onChange:i=>{typeof i=="number"&&t(n=>{n.props.radius=i})}}),l.jsx(P,{label:e("physics.shape.capsule.height.title"),info:e("physics.shape.capsule.height.info"),value:o.props.height,min:0,onChange:i=>{typeof i=="number"&&t(n=>{n.props.height=i})}}),l.jsx(oe,{label:e("physics.shape.capsule.up-axis.title"),info:e("physics.shape.capsule.up-axis.info"),options:[{label:"X",value:L.X},{label:"Y",value:L.Y},{label:"Z",value:L.Z}],value:o.props.upAxis,onChange:i=>{t(n=>{n.props.upAxis=i})}})]})}),Fe={BoxColliderShape:we,CapsuleColliderShape:Me,PlaneColliderShape:Te,SphereColliderShape:Ae},Z={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:L.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:t})=>{var d;const{t:e}=z(),i=Fe[o.class],n=ae.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(ne,{label:e("physics.collider.trigger.title"),info:e("physics.collider.trigger.info"),value:o.props.isTrigger,onChange:c=>{t(f=>{f.props.isTrigger=c})}}),l.jsx(de,{label:e("physics.collider.material.title"),info:e("physics.collider.material.info"),dropLayer:ye.PhysicsMaterial,value:a==null?void 0:a.name,assets:s,onSelect:c=>{t(f=>{f.props.material=c.getCurrentRef()})},onLocate:()=>{a&&a.id&&n.selectAsset(a.id)}}),l.jsx(i,{item:o,onItemChange:t}),l.jsx(X,{label:e("physics.collider.local-position.title"),info:e("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"&&t(b=>{b.props.position={...b.props.position,[f]:u}})}}),l.jsx(X,{label:e("physics.collider.rotation.title"),info:e("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"&&t(b=>{b.props.rotation={...b.props.rotation,[f]:u}})}})]})}),Be=j(({collider:o,item:t,index:e,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 q||(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=E(f),b=u[e];b&&(c(b),i==null||i("colliderShapes",u))};return l.jsxs(l.Fragment,{children:[l.jsx(oe,{label:n("physics.shape.type.title"),info:n("physics.shape.type.info"),value:t.class,options:s,onChange:c=>{Z[c].class!==t.class&&d(u=>{Object.assign(u,E(Z[c]))})}}),l.jsx(Ve,{item:t,onItemChange:d})]})}),Ie=j(({model:o,inspectorConfig:t,onModelChange:e})=>{const{label:i}=t,n=o.colliderShapes,{t:s}=z(),a=d=>{const c=E(n);d(c),e==null||e("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:e}),id:`${c}`,name:s("physics.shape.item-name",{index:c})})),addable:!0,onAdd:()=>{a(d=>{d.push(E(Z.BoxColliderShape))})},onDelete:d=>{a(c=>{c.splice(+d.id,1)})},addItemText:s("physics.shape.add")})});var Ne=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Le=(o,t,e,i)=>{for(var n=i>1?void 0:i?$e(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Ne(t,e,n),n};async function Ee(o,t){let e;switch(o.class){case"BoxColliderShape":{e=new N;const i=e.size,n=o.props.size;n&&(i.set(n.x,n.y,n.z),e.size=i);break}case"CapsuleColliderShape":{e=new I,o.props.radius!==void 0&&(e.radius=o.props.radius),o.props.height!==void 0&&(e.height=o.props.height),o.props.upAxis!==void 0&&(e.upAxis=o.props.upAxis);break}case"PlaneColliderShape":{e=new J;break}case"SphereColliderShape":{e=new B,o.props.radius!==void 0&&(e.radius=o.props.radius);break}default:throw new Error(`Unknown collider shape class: ${o.class}`)}if(o.props.isTrigger!==void 0&&(e.isTrigger=o.props.isTrigger),o.props.position){const i=o.props.position,n=e.position;n.set(i.x,i.y,i.z),e.position=n}if(o.props.rotation){const i=o.props.rotation,n=e.rotation;n.set(i.x,i.y,i.z),e.rotation=n}if(o.props.material){const i=o.props.material;if(i.refId){const n=await t.getAssetByRef({refId:i.refId});if(!(n!=null&&n.engineObject))throw ue(`Physics material is not ready for refId: ${i.refId}`);e.material=n.engineObject}}return e}class R extends se{constructor(){super(...arguments);p(this,"colliderShapes",[])}}Le([he({engineKey:"addShape",editorKey:"colliderShapes",getPath:"shapes",valueType:me.Object,getEngineValue:o=>o.shapes,getEditorValue:_e}),y({type:"methods",key:"addShape",canonicalizeToProps:!0,onSerialize:o=>o.map(t=>[{class:t.class,props:ve(t)}]),onDeserialize:o=>o.map(t=>t[0]),resolveMethodArguments:async(o,t)=>{const e=[];for(const i of o)if(i&&typeof i=="object"&&"class"in i&&"props"in i){const s=await Ee(i,t.root.assetStore);e.push(s)}else e.push(i);return e}}),h({label:r("physics.collider.title"),info:r("physics.collider.info"),customComponent:Ie,onChange:ze})],R.prototype,"colliderShapes",2);var Je=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Xe=(o,t,e,i)=>{for(var n=i>1?void 0:i?Re(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Je(t,e,n),n};let k=class extends R{constructor(o,t){super(o,t)}};k=Xe([A({type:"StaticCollider",componentsMenu:{group:"physics",label:"component.static-collider.title"}})],k);const ee=o=>Object.keys(S).filter(t=>(o&S[t])!==0).map(t=>String(S[t])),qe=j(({model:o,onModelChange:t})=>{const e=n=>{const a=n.map(d=>parseInt(d)).reduce((d,c)=>d|c,S.None);t==null||t("constraints",a)},{t:i}=z();return l.jsxs(l.Fragment,{children:[l.jsx(U,{label:i("physics.collider-constraints.freeze-position.title"),info:i("physics.collider-constraints.freeze-position.info"),type:"multiple",value:ee(o.constraints),options:[{value:S.FreezePositionX.toString(),label:"X"},{value:S.FreezePositionY.toString(),label:"Y"},{value:S.FreezePositionZ.toString(),label:"Z"}],onChange:e}),l.jsx(U,{label:i("physics.collider-constraints.freeze-rotation.title"),info:i("physics.collider-constraints.freeze-rotation.info"),type:"multiple",value:ee(o.constraints),options:[{value:S.FreezeRotationX.toString(),label:"X"},{value:S.FreezeRotationY.toString(),label:"Y"},{value:S.FreezeRotationZ.toString(),label:"Z"}],onChange:e})]})});var Ye=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,C=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ze(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Ye(t,e,n),n};let g=class extends R{constructor(t,e){super(t,e);p(this,"isKinematic",!1);p(this,"collisionDetectionMode",V.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.applyBoundPathChange("enabled",m.Toggle,!1)}onInitComplete(){this.applyBoundPathChange("enabled",m.Toggle,!1)}};C([y(),h({label:r("physics.dynamic-collider.kinematic.title"),info:r("physics.dynamic-collider.kinematic.info"),type:m.Boolean,bindPath:"isKinematic"})],g.prototype,"isKinematic",2);C([y(),h({label:r("physics.dynamic-collider.collision-detection-mode.title"),type:m.Select,bindPath:"collisionDetectionMode",options:[{label:r("physics.dynamic-collider.collision-detection-mode.discrete"),value:V.Discrete},{label:r("physics.dynamic-collider.collision-detection-mode.continuous"),value:V.Continuous},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-dynamic"),value:V.ContinuousDynamic},{label:r("physics.dynamic-collider.collision-detection-mode.continuous-speculative"),value:V.ContinuousSpeculative}]})],g.prototype,"collisionDetectionMode",2);C([y(),h({label:r("physics.dynamic-collider.constraints.title"),info:r("physics.dynamic-collider.constraints.info"),customComponent:qe,bindPath:"constraints"})],g.prototype,"constraints",2);C([y(),h({label:r("physics.dynamic-collider.mass.title"),info:r("physics.dynamic-collider.mass.info"),bindPath:"mass",min:0,type:m.Number})],g.prototype,"mass",2);C([y(),h({label:r("physics.dynamic-collider.gravity.title"),info:r("physics.dynamic-collider.gravity.info"),bindPath:"useGravity",type:m.Boolean})],g.prototype,"useGravity",2);C([y(),h({label:r("physics.dynamic-collider.linear-damping.title"),info:r("physics.dynamic-collider.linear-damping.info"),bindPath:"linearDamping",min:0,type:m.Number})],g.prototype,"linearDamping",2);C([y(),h({label:r("physics.dynamic-collider.angular-damping.title"),info:r("physics.dynamic-collider.angular-damping.info"),bindPath:"angularDamping",min:0,type:m.Number})],g.prototype,"angularDamping",2);C([y(),h({label:r("physics.dynamic-collider.automatic-center-of-mass.title"),info:r("physics.dynamic-collider.automatic-center-of-mass.info"),bindPath:"automaticCenterOfMass",type:m.Boolean,onChange:(o,t,e)=>{if(e){const i=o.engineObject.centerOfMass;o.centerOfMass={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticCenterOfMass",2);C([y(),h({label:r("physics.dynamic-collider.center-of-mass.title"),info:r("physics.dynamic-collider.center-of-mass.info"),type:m.Vector3,bindPath:"centerOfMass",when:o=>!o.automaticCenterOfMass})],g.prototype,"centerOfMass",2);C([y(),h({label:r("physics.dynamic-collider.automatic-inertia-tensor.title"),info:r("physics.dynamic-collider.automatic-inertia-tensor.info"),bindPath:"automaticInertiaTensor",type:m.Boolean,onChange:(o,t,e)=>{if(e){const i=o.engineObject.inertiaTensor;o.inertiaTensor={x:i.x,y:i.y,z:i.z}}}})],g.prototype,"automaticInertiaTensor",2);C([y(),h({label:r("physics.dynamic-collider.inertia-tensor.title"),info:r("physics.dynamic-collider.inertia-tensor.info"),type:m.Vector3,bindPath:"inertiaTensor",when:o=>!o.automaticInertiaTensor})],g.prototype,"inertiaTensor",2);C([y(),h({label:r("physics.dynamic-collider.linear-velocity.title"),info:r("physics.dynamic-collider.linear-velocity.info"),type:m.Vector3,bindPath:"linearVelocity"})],g.prototype,"linearVelocity",2);C([y(),h({label:r("physics.dynamic-collider.angular-velocity.title"),info:r("physics.dynamic-collider.angular-velocity.info"),type:m.Vector3,bindPath:"angularVelocity"})],g.prototype,"angularVelocity",2);C([y(),h({label:r("physics.dynamic-collider.max-angular-velocity.title"),info:r("physics.dynamic-collider.max-angular-velocity.info"),bindPath:"maxAngularVelocity",min:0,type:m.Number})],g.prototype,"maxAngularVelocity",2);C([y(),h({label:r("physics.dynamic-collider.max-depenetration-velocity.title"),info:r("physics.dynamic-collider.max-depenetration-velocity.info"),bindPath:"maxDepenetrationVelocity",min:0,type:m.Number})],g.prototype,"maxDepenetrationVelocity",2);C([y(),h({label:r("physics.dynamic-collider.sleep-threshold.title"),info:r("physics.dynamic-collider.sleep-threshold.info"),bindPath:"sleepThreshold",min:0,type:m.Number})],g.prototype,"sleepThreshold",2);C([y(),h({label:r("physics.dynamic-collider.solver-iterations.title"),info:r("physics.dynamic-collider.solver-iterations.info"),bindPath:"solverIterations",min:0,max:10,dragStep:1,type:m.Slider})],g.prototype,"solverIterations",2);g=C([A({type:"DynamicCollider",componentsMenu:{group:"physics",label:"component.dynamic-collider.title"}})],g);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,$=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ke(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&Ge(t,e,n),n};let T=class extends R{constructor(t,e){super(t,e);p(this,"stepOffset",.5);p(this,"upDirection",{x:0,y:1,z:0});p(this,"slopeLimit",45);p(this,"nonWalkableMode",Y.PreventClimbing)}async bindEngineObject(t){await super.bindEngineObject(t),t.enabled=!1}};$([y(),h({label:r("physics.character.step-offset.title"),info:r("physics.character.step-offset.info"),bindPath:"stepOffset",min:0,type:m.Number})],T.prototype,"stepOffset",2);$([y(),h({label:r("physics.character.up-direction.title"),info:r("physics.character.up-direction.info"),type:m.Vector3,bindPath:"upDirection"})],T.prototype,"upDirection",2);$([y(),h({label:r("physics.character.slop-limit.title"),info:r("physics.character.slop-limit.info"),bindPath:"slopeLimit",min:0,max:180,type:m.Number})],T.prototype,"slopeLimit",2);$([y(),h({label:r("physics.character.non-walkable-mode.title"),info:r("physics.character.non-walkable-mode.info"),bindPath:"nonWalkableMode",type:m.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}]})],T.prototype,"nonWalkableMode",2);T=$([A({type:"CharacterController",componentsMenu:{label:r("component.physics.character.title"),group:"physics"}})],T);function Ue(o,t){if(!t)return null;const e=o.entities.get(t),i=(e==null?void 0:e.getComponentByTypeName("DynamicCollider"))||(e==null?void 0:e.getComponentByTypeName("StaticCollider"));return i?{ownerId:t,componentId:i.id}:null}const We=j(o=>{const{inspectorConfig:t,model:e,onModelChange:i}=o,{property:n,label:s,disabled:a,info:d}=t,{ownerId:c}=e[n]||{},f=o.model.root.sceneStore,u=c&&f.entities.get(c),b=F=>{i==null||i(n,Ue(f,F))},{t:x}=z(),le=Array.from(f.entities.values());return l.jsx(l.Fragment,{children:l.jsx(fe,{label:x(s),info:x(d),entities:le,value:c,disabled:a,customFilter:F=>{let K=null;return e.entityModelId!==F.id&&(K=F.getComponentByTypeName("DynamicCollider")||F.getComponentByTypeName("StaticCollider")),K},displayValue:u==null?void 0:u.name,placeholder:x("physics.collider-picker.placeholder"),onSelect:b,onLocate:()=>{o.model.root.sceneStore.selectEntity(c)},onDelete:()=>{b(null)}})})});var He=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,D=(o,t,e,i)=>{for(var n=i>1?void 0:i?Qe(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&He(t,e,n),n};class v extends se{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(e,i,n){var s,a;if(e==="connectedCollider"){const d=n,c=((a=(s=this.root.sceneStore.entities.get(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(e,i,c);return}await super.applyBoundPathChange(e,i,n)}}D([y(),h({label:r("physics.joint.connected-collider.title"),info:r("physics.joint.connected-collider.info"),customComponent:We,bindPath:"connectedCollider"})],v.prototype,"connectedCollider",2);D([y(),h({label:r("physics.joint.anchor.title"),type:m.Vector3,bindPath:"anchor",onChange(o,t,e){if(o.automaticConnectedAnchor){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"anchor",2);D([y(),h({label:r("physics.joint.automatic-connected-anchor.title"),type:m.Boolean,bindPath:"automaticConnectedAnchor",onChange(o,t,e){if(e){const i=o.engineObject.connectedAnchor;o.connectedAnchor={x:i.x,y:i.y,z:i.z}}}})],v.prototype,"automaticConnectedAnchor",2);D([y(),h({label:r("physics.joint.connected-anchor.title"),type:m.Vector3,bindPath:"connectedAnchor",when:o=>!o.automaticConnectedAnchor})],v.prototype,"connectedAnchor",2);D([y(),h({label:r("physics.joint.break-force.title"),type:m.Number,bindPath:"breakForce"})],v.prototype,"breakForce",2);D([y(),h({label:r("physics.joint.break-torque.title"),type:m.Number,bindPath:"breakTorque"})],v.prototype,"breakTorque",2);D([y(),h({label:r("physics.joint.mass-scale.title"),type:m.Number,bindPath:"massScale"})],v.prototype,"massScale",2);D([y(),h({label:r("physics.joint.connected-mass-scale.title"),type:m.Number,bindPath:"connectedMassScale"})],v.prototype,"connectedMassScale",2);var ke=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(o,t,e,i)=>{for(var n=i>1?void 0:i?et(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&ke(t,e,n),n};let te=class extends v{constructor(o,t){super(o,t)}};te=tt([A({type:"FixedJoint",componentsMenu:{label:r("component.physics.fixed-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],te);const it=j(o=>{const{inspectorConfig:t,model:e,onModelChange:i}=o,{property:n,label:s,info:a}=t,d=e.useLimits,c=e.useSpring,f=e[n],u=f.props,{t:b}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(re,{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})}),ot=j(o=>{const{inspectorConfig:t,model:e,onModelChange:i}=o,{property:n,label:s,info:a}=t,d=e.useMotor,c=e[n],f=c.props,{t:u}=z();return l.jsx(l.Fragment,{children:d?l.jsxs(re,{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(ne,{label:u("physics.joint-motor.free-spin"),value:f.freeSpin,onChange:b=>{f.freeSpin=b,i(n,c)}})]}):null})});var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,w=(o,t,e,i)=>{for(var n=i>1?void 0:i?st(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&nt(t,e,n),n};let O=class extends v{constructor(t,e){super(t,e);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(t,e,i){if(t==="limits"){const n=this._buildLimitsFromModel(i);if(!n)return;await super.applyBoundPathChange(t,e,n);return}if(t==="motor"){const n=this._buildMotorFromModel(i);if(!n)return;await super.applyBoundPathChange(t,e,n);return}await super.applyBoundPathChange(t,e,i)}_buildLimitsFromModel(t){const e=t==null?void 0:t.props;if(!e)return null;const i=new be;return i.max=e.max,i.min=e.min,i.contactDistance=e.contactDistance,i.stiffness=e.stiffness,i.damping=e.damping,i}_buildMotorFromModel(t){const e=t==null?void 0:t.props;if(!e)return null;const i=new ge;return i.targetVelocity=e.targetVelocity,i.forceLimit=e.forceLimit,i.gearRatio=e.gearRatio,i.freeSpin=e.freeSpin,i}};w([y(),h({label:r("physics.hinge-joint.axis.title"),type:m.Vector3,bindPath:"axis"})],O.prototype,"axis",2);w([y(),h({label:r("physics.hinge-joint.use-limits.title"),type:m.Boolean,bindPath:"useLimits"})],O.prototype,"useLimits",2);w([y(),h({label:r("physics.hinge-joint.use-spring.title"),type:m.Boolean,bindPath:"useSpring"})],O.prototype,"useSpring",2);w([y(),h({label:r("physics.hinge-joint.limits.title"),customComponent:it,bindPath:"limits"})],O.prototype,"limits",2);w([y(),h({label:r("physics.hinge-joint.use-motor.title"),type:m.Boolean,bindPath:"useMotor"})],O.prototype,"useMotor",2);w([y(),h({label:r("physics.hinge-joint.motor.title"),customComponent:ot,bindPath:"motor"})],O.prototype,"motor",2);O=w([A({type:"HingeJoint",componentsMenu:{label:r("component.physics.hinge-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],O);var rt=Object.defineProperty,at=Object.getOwnPropertyDescriptor,M=(o,t,e,i)=>{for(var n=i>1?void 0:i?at(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&rt(t,e,n),n};let _=class extends v{constructor(t,e){super(t,e);p(this,"spring",10);p(this,"damper",.2);p(this,"minDistance",0);p(this,"maxDistance",0);p(this,"tolerance",.025)}};M([y(),h({label:r("physics.spring-joint.spring.title"),type:m.Number,bindPath:"spring"})],_.prototype,"spring",2);M([y(),h({label:r("physics.spring-joint.damper.title"),type:m.Number,bindPath:"damper"})],_.prototype,"damper",2);M([y(),h({label:r("physics.spring-joint.min-distance.title"),type:m.Number,bindPath:"minDistance"})],_.prototype,"minDistance",2);M([y(),h({label:r("physics.spring-joint.max-distance.title"),type:m.Number,bindPath:"maxDistance"})],_.prototype,"maxDistance",2);M([y(),h({label:r("physics.spring-joint.tolerance.title"),type:m.Number,bindPath:"tolerance"})],_.prototype,"tolerance",2);_=M([A({type:"SpringJoint",componentsMenu:{label:r("component.physics.spring-joint.title"),group:"physics"},dependentComponent:{type:"DynamicCollider",dependentMode:G.AutoAdd}})],_);class lt extends Ce{constructor(){super(...arguments);p(this,"_isPlaying",!1)}onPlay(e){this._isPlaying=e,this._toggleAll(e)}onAddComponent(e){!this._isPlaying&&(e instanceof W||e instanceof q)&&(e.enabled=!1)}_toggleAll(e){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(W,n),d.getComponentsIncludeChildren(q,s)}),n.forEach(d=>{d.enabled=e}),s.forEach(d=>{d.enabled=e})}}var ct=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(o,t,e,i)=>{for(var n=i>1?void 0:i?pt(t,e):t,s=o.length-1,a;s>=0;s--)(a=o[s])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&ct(t,e,n),n};let ie=class{constructor(){p(this,"script")}init(){this.script=xe.addScript(lt)}};ie=dt([Se({type:"physicsStore"})],ie);export{T as C,g as D,te as F,O as H,ie as P,k as S,_ 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-1e23212d.js";import"./index-92830754.js";import{c as b}from"./Component-746be670.js";import"./postmen-9e1e15bd.js";import{L as u}from"./LightBaseComponent-51d498ea.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 $=Object.defineProperty;var G=(e,t,s)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var E=(e,t,s)=>(G(e,typeof t!="symbol"?t+"":t,s),s);import{aG as _,aU as q,aS as l,aX as Q,dC as H,e as u,aD as J,aP as D,dD as K,aT as M,dE as U,aQ as A,dF as S,dG as W,dH as X,dI as Y,bm as Z,dJ as ee,dK as te,dL as se,bN as oe,q as re,dM as ne,dN as ae,dO as ce,bl as le,t as ie,dP as fe,dQ as pe,dR as me,cC as ue,dS as B,dT as L,cy as be,E as de,a as z,s as C,p as T,C as w,l as ye,g as he}from"./index-
|
|
1
|
+
var $=Object.defineProperty;var G=(e,t,s)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var E=(e,t,s)=>(G(e,typeof t!="symbol"?t+"":t,s),s);import{aG as _,aU as q,aS as l,aX as Q,dC as H,e as u,aD as J,aP as D,dD as K,aT as M,dE as U,aQ as A,dF as S,dG as W,dH as X,dI as Y,bm as Z,dJ as ee,dK as te,dL as se,bN as oe,q as re,dM as ne,dN as ae,dO as ce,bl as le,t as ie,dP as fe,dQ as pe,dR as me,cC as ue,dS as B,dT as L,cy as be,E as de,a as z,s as C,p as T,C as w,l as ye,g as he}from"./index-1e23212d.js";import{u as ge}from"./index-92830754.js";import{c as Pe}from"./Component-746be670.js";import{D as je,M as Ee}from"./Menu-0a7dbec0.js";import{A as xe,a as Ce}from"./Accordion-930aedee.js";/**
|
|
2
2
|
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var z=Object.defineProperty;var k=(d,t,e)=>t in d?z(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e;var b=(d,t,e)=>(k(d,typeof t!="symbol"?t+"":t,e),e);import{dX as N,dY as F,aQ as j,aR as L,aS as C,bN as R,q as O,aV as G,aD as $,dZ as U,C as V,ct as J,d_ as P,by as K,e as S,d$ as D,e0 as W,e1 as Q,e2 as q,e3 as X,dV as Y,de as Z,e4 as H,_ as v,m as tt,a$ as et,x as st,aL as B,n as nt,dr as it}from"./index-aec7e708.js";import{T as at}from"./TaskQueue-05c94a4d.js";import{u as x,I as rt}from"./index-e8a45e82.js";import"./postmen-2f47f6bb.js";import{A as ot}from"./AssetViewer-64cd01fa.js";class w{static update(t,e){!this.entity&&(this.entity=t.createChild("prefab"));const s=this.tempCloneEntity=e.engineObject.instantiate();this.entity.addChild(s)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}b(w,"entity"),b(w,"tempCloneEntity");const M=new F("buildGltfAssetTemplateDiffs");function dt(d,t){var s;M.info("START",{sceneRootName:d==null?void 0:d.name,sceneRootRotation:(s=d==null?void 0:d.transform)!=null&&s.rotation?{x:d.transform.rotation.x,y:d.transform.rotation.y,z:d.transform.rotation.z}:null,sceneChildCount:d==null?void 0:d.childCount,baselineRootName:t==null?void 0:t.name,baselineChildCount:t==null?void 0:t.childCount});const e=N(d,t);return M.info("RESULT",{diffCount:e?Object.keys(e.entityProps??{}).length:0,paths:e?Object.keys(e.entityProps??{}):[]}),e}const ct=j(({asset:d})=>{const{dependentAssets:t}=d,{configDataStore:e}=x(),{t:s}=L(),a=j(({dependentAssetInfo:n})=>{const{assetStore:i}=x(),r=Object.values(i.assets).filter(c=>{const l=c.getMetaConfig().type,y=c.id===n.id,u=c.id===d.id,h=!y&&!u&&!c.isSubAsset;return n.type==="glTF"||n.type==="Prefab"?l==="glTF"||l==="Prefab"&&h:c.getMetaConfig().type===n.type&&h}),o=i.assets[n.id],p=o==null?void 0:o.name;return C.jsx(R,{dropLayer:O.Asset,placeholder:s("prefab.inspector.missed"),assets:r,onSelect:c=>{d.replaceDependentAsset(n,c)},onLocate:()=>{i.selectAsset(n.id)},value:p,asset:o})});return C.jsxs(C.Fragment,{children:[C.jsx(G,{title:s("prefab.inspector.basic-info"),defaultOpen:!0,children:e.isBuc&&C.jsx($,{label:s("prefab.inspector.url")})}),C.jsx(U,{label:s("prefab.inspector.dependent-assets"),children:t.map((n,i)=>C.jsx(a,{dependentAssetInfo:n},`${n.id}-${i}`))})]})}),pt={entities:[{id:"defaultPrefab",name:"prefab",isActive:!0,transform:{class:"Transform",props:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},parent:null,children:[],isClone:!1,components:[]}]};class lt extends ot{constructor(){super(...arguments);b(this,"_animators",[]);b(this,"_particles",[])}setViewAsset(e,s){const a=e.entityManager.rootEntities[0];this._entity=a.engineObject,s.addChild(this._entity),a.getComponentsIncludeChildren("Animator",this._animators).forEach(r=>{r.applyBoundPathChange("enabled",V.Toggle,r.enabled)}),this._entity.getComponentsIncludeChildren(J,this._particles).forEach(r=>{r.generator.stop(!1,P.StopEmittingAndClear),r.generator.main.simulationSpeed=1,r.generator.play()})}stopViewAsset(){super.stopViewAsset(),this._particles.forEach(e=>{e.generator.stop(!1,P.StopEmittingAndClear)})}}var ft=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,E=(d,t,e,s)=>{for(var a=s>1?void 0:s?ht(t,e):t,n=d.length-1,i;n>=0;n--)(i=d[n])&&(a=(s?i(t,e,a):i(a))||a);return s&&a&&ft(t,e,a),a};const I=it("PrefabAsset"),T=new F("PrefabAsset");let _=class extends rt{constructor(t){super(t);b(this,"acceptDragLayer",O.Entity);b(this,"_entityManager");b(this,"_contentQueue",new at);b(this,"entities",[]);b(this,"dependentAssets",[]);b(this,"_skipInitUpdateContent",!1);this._entityManager=new q(t)}static async createByEntity(t){var e,s,a;if(t.isPrefabSubEntity||t.isGLTFRefEntity){K.error(S("prefab.error.create-from-sub"));return}D()&&W();try{T.info("createByEntity START",{entityName:t.name,entityId:t.id,isGLTFWrap:t.isGLTFWrapEntity,childCount:(e=t.children)==null?void 0:e.length,childNames:(s=t.children)==null?void 0:s.map(i=>i.name),hasGLTFChild:(a=t.children)==null?void 0:a.some(i=>i.isGLTFRefEntity)});const{assetFacade:n}=t.root;await t.root.runInUndoGroup("asset.create",async()=>{const i=await n.createAssetByAdd({assetType:"Prefab",name:t.name});i.addInstance(t,{undoable:!0}),await i.updateByEntity(t,!1,{undoable:!0})})}finally{D()&&Q()}}get entityManager(){return this._entityManager}async initByMain(t,e){const{dependentAssets:s}=this.meta;this.url=e;const a=JSON.parse(await t.text());if(this.entities=a.entities,this.dependentAssets=s,this._skipInitUpdateContent){this._skipInitUpdateContent=!1;return}await this._updateContent()}async initByCreation(){return this.entities=pt.entities,this._skipInitUpdateContent=!0,this.getMainData()}async updateByEntity(t,e=!1,s){var r;T.info("updateByEntity START",{entityName:t.name,entityId:t.id,isGLTFWrap:t.isGLTFWrapEntity,updateInstanceFrom:e});const{entities:a,assets:n}=this._getEntityDataIncludeChildren(t,[],new Set);T.info("updateByEntity serialized",{entityCount:a.length,entities:a.map(o=>{var p;return{name:o.name,isClone:o.isClone,instanceAssetId:(p=o.instance)==null?void 0:p.assetId,hasAssetTemplateDiffs:!!o.assetTemplateDiffs,assetTemplateDiffKeys:o.assetTemplateDiffs?Object.keys(o.assetTemplateDiffs.entityProps??{}):[]}})});const i=a[0];(r=i.transform)!=null&&r.props&&(i.transform.props.position={x:0,y:0,z:0}),i.parent=null,this.entities=a,this.dependentAssets=Array.from(n,o=>({id:o.id,name:o.name,type:o.getMetaConfig().type})),this._updateCreateByAddResumeSnapshot(),e&&this.addInstance(t),await this._updateContent(s!=null&&s.undoable?{undoable:!0}:void 0)}async refreshFromData(t){await this._updateContent(t)}replaceDependentAsset(t,e){const s=JSON.stringify(this.entities);this.entities=JSON.parse(s.replace(new RegExp(t.id,"g"),e.id)),t.id=e.id,t.name=e.name,this._updateContent()}destroy(){super.destroy(),this.engineObject&&(this.engineObject._root.destroy(),this.engineObject.destroy())}unpackAllInstances(){this._instances.forEach((t,e)=>{const s=t.entities.get(e);s==null||s.unpackPrefab()}),super.unpackAllInstances()}async instantiate(t,e,s){var o,p;const a=this._entityManager.rootEntities[0].id,n=this._entityManager.getEntityFilesById(a);e&&((p=(o=n[0])==null?void 0:o.transform)!=null&&p.props)&&(n[0].transform.props.position=e.position,n[0].transform.props.rotation=e.rotation,n[0].transform.props.scale=e.scale),s!=null&&s.expectedRootId&&n[0]&&(n[0].id=s.expectedRootId);const r=(await t.deserializeEntities(n))[0];return r.convertToPrefabRefEntity(),this.addInstance(r,s),this._bindInstantiatedEntity(r,s),r}_updateCreateByAddResumeSnapshot(){const t=this.getMainData(),e=this.getMetaData(),s=this.name??"Prefab",a=t==null?null:new Blob([t instanceof ArrayBuffer||typeof t=="string"?t:JSON.stringify(t)]);this.root.assetStore.updateCreateByAddResumeSnapshot(this.id,{assetName:s,serializedMeta:JSON.stringify(e),mainBlob:a})}_bindInstantiatedEntity(t,e){const s=this._entityManager.rootEntities[0];if(!s)return;const{entityMappings:a,componentMappings:n}=this._collectInstanceMappings(s,t);if(!a.length)return;const{prefab:i}=this.root.domainStore.state,r=i.byAssetId[this.id]??[];for(const p of r){const c=i.bindings[p];if((c==null?void 0:c.instanceRootEntityId)===t.id){const l=[],y=this.root.domainStore.getNormalizedState(),u=y.entities[t.id];if(u){l.push({op:u.instance?"replace":"add",path:`/entities/${t.id}/instance`,value:{bindingId:p,assetId:this.id,assetKind:"Prefab",role:"root",sourceEntityId:c.sourceRootEntityId}});for(const h of n){const f=X(y,t.id,h.sceneComponentId);f&&l.push({op:f.instance?"replace":"add",path:`/entities/${t.id}/components/${h.sceneComponentId}/instance`,value:{bindingId:p,role:"linked",sourceComponentKey:h.sourceComponentKey}})}}l.length>0&&this.root.domainStore.applySystem(l);return}}let o=1;for(const p of r){const c=i.bindings[p];c&&c.sourceRevision>o&&(o=c.sourceRevision)}this.root.prefabFacade.bindExistingInstance({assetId:this.id,instanceRootEntityId:t.id,sourceRevision:o,entityMappings:a,componentMappings:n,undoable:(e==null?void 0:e.undoable)===!0})}_collectInstanceMappings(t,e){const s=[],a=[],n=(i,r,o)=>{var h;const p=(i==null?void 0:i.id)??r.id;s.push({sceneEntityId:r.id,sourceEntityId:p,role:o});const c=(i==null?void 0:i.components)??[],l=r.components??[];for(let f=0;f<l.length;f++){const m=l[f];if(!(m!=null&&m.id))continue;const g=((h=c[f])==null?void 0:h.id)??m.id;a.push({sceneEntityId:r.id,sceneComponentId:m.id,sourceComponentKey:g})}const y=(i==null?void 0:i.selfChildren)??[],u=r.selfChildren??[];for(let f=0;f<u.length;f++)n(y[f],u[f],"linked")};return n(t,e,"root"),{entityMappings:s,componentMappings:a}}async replaceInstance(t,e,s){var o;const a=e.entities.get(t),n=(o=a==null?void 0:a.engineObject)==null?void 0:o.transform,i=n?{position:{x:n.position.x,y:n.position.y,z:n.position.z},rotation:{x:n.rotation.x,y:n.rotation.y,z:n.rotation.z},scale:{x:n.scale.x,y:n.scale.y,z:n.scale.z}}:void 0,r=await this.instantiate(e,i,s);return r.convertToPrefabRefEntity(),e.replaceEntity(t,r),r}_instantiateEngineObject(){return this.engineObject.instantiate()}_onDrop(t,e){if(!e||e.id===this.id)return;this.dropping=!1;const{sceneStore:s,sceneUIStore:a}=this.root,n=Array.from(a.selectedKeys);if(n.length>1)for(let i=0;i<n.length;i++)_.createByEntity(s.entities.get(n[i]));else Y({title:S("prefab.replace.title").toString(),description:S("prefab.replace.description",{name:this.name}).toString(),confirmText:S("prefab.replace.confirm").toString(),onConfirm:()=>{const i=s.entities.get(n[0]);this.updateByEntity(i,!0)}})}_rebaseInstanceRevisions(){const{prefabFacade:t,domainStore:e}=this.root,s=e.state.prefab.byAssetId[this.id];if(!s||s.length===0)return;let a=0;for(const n of s){const i=e.state.prefab.bindings[n];i&&i.sourceRevision>a&&(a=i.sourceRevision)}t.updatePrefabContent(this.id,a+1)}_getEntityDataIncludeChildren(t,e,s){var i,r,o,p;const a=this.root.assetStore,n=t.toJSON(!0);if(e.push(n),!t.isGLTFRefEntity)t.components.forEach(c=>{var y;const l=Z(c);for(const u in l)if(l[u].type==="AssetPicker"){const h=(y=c[u])==null?void 0:y.refId;if(h){const f=a.assets[h];f&&s.add(f)}}}),t.children.map(c=>!c.prefabEntityRemoved&&this._getEntityDataIncludeChildren(c,e,s)),(i=t.strippedEntity)==null||i.clear();else{const c=a.assets[t.instanceAssetId];s.add(c);let l=null;try{l=(r=c.instantiateEngineObject)==null?void 0:r.call(c),T.info("_getEntityDataIncludeChildren glTF branch",{entityName:t.name,instanceAssetId:t.instanceAssetId,hasBaseline:!!l,sceneChildCount:(o=t.selfChildren??t.children)==null?void 0:o.length,sceneChildRotations:(p=t.selfChildren??t.children)==null?void 0:p.map(g=>{const A=g.transform;return A!=null&&A.rotation?{x:A.rotation.x,y:A.rotation.y,z:A.rotation.z}:null})});const m=(l==null?void 0:l.childCount)>0?l.getChild(0):l;if(m&&t.engineObject){const g=dt(t.engineObject,m);T.info("diffs result",{diffs:g}),g&&(n.assetTemplateDiffs=g)}}finally{l==null||l.destroy()}const y=t.entityManager.strippedEntities,u=t.getAddedComponents(),h=t.getAddedEntities(),f=new Set;u.forEach(m=>{f.add(m.strippedId)}),h.forEach(m=>{f.add(m.strippedId)}),f.forEach(m=>{const g=y.get(m);this._getEntityDataIncludeChildren(g,e,s)})}return{entities:e,assets:s}}_updateContent(t){return this._contentQueue.enqueue(async()=>{try{await this._updateContentInternal(t)}catch(e){if(e instanceof Error&&e.message==="cancelled")return;I.error("_updateContent failed:",e)}})}async _updateContentInternal(t){const{url:e,dependentAssets:s}=this,a=(t==null?void 0:t.persist)!==!1;await Promise.all(s.map(p=>this.root.assetStore.getAssetByRef({refId:p.id}))),await this._entityManager.init(this);const n=this.engineObject;if(n){this.root.assetStore.engineObjectToAssetMap.delete(n);try{n.destroy()}catch(p){I.warn("failed to destroy oldEngineObject:",p)}}const i=new H(this.engine,e);this.bindEngineObject(i),this.root.assetStore.engineObjectToAssetMap.set(i,this);let r=this._entityManager.rootEntities[0];r||(r=this._entityManager.createEntity("prefab","defaultPrefab"),r.bindEngineObject(new v(this.engine,"prefab")),I.error(`The prefab which id is ${this.id} is broken, use default prefab instead.`)),r.engineObject||(I.warn("rootEntity engineObject is null, binding new Entity"),r.bindEngineObject(new v(this.engine,"prefab"))),this._markAsTemplate(r),i._root=r.engineObject,r.once("delete",()=>{I.error(`The prefab which id is ${this.id} is broken.`),this._updateContent().catch(p=>{I.error(`Failed to rebuild broken prefab which id is ${this.id}.`,p)})}),this._updateDragTempEntity(),this.updateThumbnail(),a&&(this.root.assetFacade.persistAssetMeta(this.id),this.root.assetFacade.persistAssetMain(this.id));const o=t!=null&&t.undoable?{undoable:!0}:void 0;await Promise.all(Array.from(this._instances,([p,c])=>this.replaceInstance(p,c,o))),this._rebaseInstanceRevisions()}_markAsTemplate(t){const e=t.engineObject;if(!e){I.warn("_markAsTemplate: engineObject is null",{prefabId:this.id,entityModelId:t.id});return}const s=e;s._templateResource||s._markAsTemplate(this.engineObject),t.selfChildren.forEach(a=>{this._markAsTemplate(a)})}};E([tt()],_.prototype,"entities",2);E([et(),st],_.prototype,"dependentAssets",2);E([B],_.prototype,"replaceDependentAsset",1);E([B],_.prototype,"_onDrop",1);_=E([nt({type:"Prefab",label:S("asset.prefab.title"),extname:"prefab",dragLayer:O.Prefab,customInspector:ct,viewer:lt,thumbnail:w,async bundle(d){return{content:new Blob([d.content],{type:"application/json"})}}})],_);export{_ as PrefabAsset};
|
|
1
|
+
var z=Object.defineProperty;var k=(d,t,e)=>t in d?z(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e;var b=(d,t,e)=>(k(d,typeof t!="symbol"?t+"":t,e),e);import{dX as N,dY as F,aQ as j,aR as L,aS as C,bN as R,q as O,aV as G,aD as $,dZ as U,C as V,ct as J,d_ as P,by as K,e as S,d$ as D,e0 as W,e1 as Q,e2 as q,e3 as X,dV as Y,de as Z,e4 as H,_ as v,m as tt,a$ as et,x as st,aL as B,n as nt,dr as it}from"./index-1e23212d.js";import{T as at}from"./TaskQueue-05c94a4d.js";import{u as x,I as rt}from"./index-92830754.js";import"./postmen-9e1e15bd.js";import{A as ot}from"./AssetViewer-0ce46fa1.js";class w{static update(t,e){!this.entity&&(this.entity=t.createChild("prefab"));const s=this.tempCloneEntity=e.engineObject.instantiate();this.entity.addChild(s)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}b(w,"entity"),b(w,"tempCloneEntity");const M=new F("buildGltfAssetTemplateDiffs");function dt(d,t){var s;M.info("START",{sceneRootName:d==null?void 0:d.name,sceneRootRotation:(s=d==null?void 0:d.transform)!=null&&s.rotation?{x:d.transform.rotation.x,y:d.transform.rotation.y,z:d.transform.rotation.z}:null,sceneChildCount:d==null?void 0:d.childCount,baselineRootName:t==null?void 0:t.name,baselineChildCount:t==null?void 0:t.childCount});const e=N(d,t);return M.info("RESULT",{diffCount:e?Object.keys(e.entityProps??{}).length:0,paths:e?Object.keys(e.entityProps??{}):[]}),e}const ct=j(({asset:d})=>{const{dependentAssets:t}=d,{configDataStore:e}=x(),{t:s}=L(),a=j(({dependentAssetInfo:n})=>{const{assetStore:i}=x(),r=Object.values(i.assets).filter(c=>{const l=c.getMetaConfig().type,y=c.id===n.id,u=c.id===d.id,h=!y&&!u&&!c.isSubAsset;return n.type==="glTF"||n.type==="Prefab"?l==="glTF"||l==="Prefab"&&h:c.getMetaConfig().type===n.type&&h}),o=i.assets[n.id],p=o==null?void 0:o.name;return C.jsx(R,{dropLayer:O.Asset,placeholder:s("prefab.inspector.missed"),assets:r,onSelect:c=>{d.replaceDependentAsset(n,c)},onLocate:()=>{i.selectAsset(n.id)},value:p,asset:o})});return C.jsxs(C.Fragment,{children:[C.jsx(G,{title:s("prefab.inspector.basic-info"),defaultOpen:!0,children:e.isBuc&&C.jsx($,{label:s("prefab.inspector.url")})}),C.jsx(U,{label:s("prefab.inspector.dependent-assets"),children:t.map((n,i)=>C.jsx(a,{dependentAssetInfo:n},`${n.id}-${i}`))})]})}),pt={entities:[{id:"defaultPrefab",name:"prefab",isActive:!0,transform:{class:"Transform",props:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},parent:null,children:[],isClone:!1,components:[]}]};class lt extends ot{constructor(){super(...arguments);b(this,"_animators",[]);b(this,"_particles",[])}setViewAsset(e,s){const a=e.entityManager.rootEntities[0];this._entity=a.engineObject,s.addChild(this._entity),a.getComponentsIncludeChildren("Animator",this._animators).forEach(r=>{r.applyBoundPathChange("enabled",V.Toggle,r.enabled)}),this._entity.getComponentsIncludeChildren(J,this._particles).forEach(r=>{r.generator.stop(!1,P.StopEmittingAndClear),r.generator.main.simulationSpeed=1,r.generator.play()})}stopViewAsset(){super.stopViewAsset(),this._particles.forEach(e=>{e.generator.stop(!1,P.StopEmittingAndClear)})}}var ft=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,E=(d,t,e,s)=>{for(var a=s>1?void 0:s?ht(t,e):t,n=d.length-1,i;n>=0;n--)(i=d[n])&&(a=(s?i(t,e,a):i(a))||a);return s&&a&&ft(t,e,a),a};const I=it("PrefabAsset"),T=new F("PrefabAsset");let _=class extends rt{constructor(t){super(t);b(this,"acceptDragLayer",O.Entity);b(this,"_entityManager");b(this,"_contentQueue",new at);b(this,"entities",[]);b(this,"dependentAssets",[]);b(this,"_skipInitUpdateContent",!1);this._entityManager=new q(t)}static async createByEntity(t){var e,s,a;if(t.isPrefabSubEntity||t.isGLTFRefEntity){K.error(S("prefab.error.create-from-sub"));return}D()&&W();try{T.info("createByEntity START",{entityName:t.name,entityId:t.id,isGLTFWrap:t.isGLTFWrapEntity,childCount:(e=t.children)==null?void 0:e.length,childNames:(s=t.children)==null?void 0:s.map(i=>i.name),hasGLTFChild:(a=t.children)==null?void 0:a.some(i=>i.isGLTFRefEntity)});const{assetFacade:n}=t.root;await t.root.runInUndoGroup("asset.create",async()=>{const i=await n.createAssetByAdd({assetType:"Prefab",name:t.name});i.addInstance(t,{undoable:!0}),await i.updateByEntity(t,!1,{undoable:!0})})}finally{D()&&Q()}}get entityManager(){return this._entityManager}async initByMain(t,e){const{dependentAssets:s}=this.meta;this.url=e;const a=JSON.parse(await t.text());if(this.entities=a.entities,this.dependentAssets=s,this._skipInitUpdateContent){this._skipInitUpdateContent=!1;return}await this._updateContent()}async initByCreation(){return this.entities=pt.entities,this._skipInitUpdateContent=!0,this.getMainData()}async updateByEntity(t,e=!1,s){var r;T.info("updateByEntity START",{entityName:t.name,entityId:t.id,isGLTFWrap:t.isGLTFWrapEntity,updateInstanceFrom:e});const{entities:a,assets:n}=this._getEntityDataIncludeChildren(t,[],new Set);T.info("updateByEntity serialized",{entityCount:a.length,entities:a.map(o=>{var p;return{name:o.name,isClone:o.isClone,instanceAssetId:(p=o.instance)==null?void 0:p.assetId,hasAssetTemplateDiffs:!!o.assetTemplateDiffs,assetTemplateDiffKeys:o.assetTemplateDiffs?Object.keys(o.assetTemplateDiffs.entityProps??{}):[]}})});const i=a[0];(r=i.transform)!=null&&r.props&&(i.transform.props.position={x:0,y:0,z:0}),i.parent=null,this.entities=a,this.dependentAssets=Array.from(n,o=>({id:o.id,name:o.name,type:o.getMetaConfig().type})),this._updateCreateByAddResumeSnapshot(),e&&this.addInstance(t),await this._updateContent(s!=null&&s.undoable?{undoable:!0}:void 0)}async refreshFromData(t){await this._updateContent(t)}replaceDependentAsset(t,e){const s=JSON.stringify(this.entities);this.entities=JSON.parse(s.replace(new RegExp(t.id,"g"),e.id)),t.id=e.id,t.name=e.name,this._updateContent()}destroy(){super.destroy(),this.engineObject&&(this.engineObject._root.destroy(),this.engineObject.destroy())}unpackAllInstances(){this._instances.forEach((t,e)=>{const s=t.entities.get(e);s==null||s.unpackPrefab()}),super.unpackAllInstances()}async instantiate(t,e,s){var o,p;const a=this._entityManager.rootEntities[0].id,n=this._entityManager.getEntityFilesById(a);e&&((p=(o=n[0])==null?void 0:o.transform)!=null&&p.props)&&(n[0].transform.props.position=e.position,n[0].transform.props.rotation=e.rotation,n[0].transform.props.scale=e.scale),s!=null&&s.expectedRootId&&n[0]&&(n[0].id=s.expectedRootId);const r=(await t.deserializeEntities(n))[0];return r.convertToPrefabRefEntity(),this.addInstance(r,s),this._bindInstantiatedEntity(r,s),r}_updateCreateByAddResumeSnapshot(){const t=this.getMainData(),e=this.getMetaData(),s=this.name??"Prefab",a=t==null?null:new Blob([t instanceof ArrayBuffer||typeof t=="string"?t:JSON.stringify(t)]);this.root.assetStore.updateCreateByAddResumeSnapshot(this.id,{assetName:s,serializedMeta:JSON.stringify(e),mainBlob:a})}_bindInstantiatedEntity(t,e){const s=this._entityManager.rootEntities[0];if(!s)return;const{entityMappings:a,componentMappings:n}=this._collectInstanceMappings(s,t);if(!a.length)return;const{prefab:i}=this.root.domainStore.state,r=i.byAssetId[this.id]??[];for(const p of r){const c=i.bindings[p];if((c==null?void 0:c.instanceRootEntityId)===t.id){const l=[],y=this.root.domainStore.getNormalizedState(),u=y.entities[t.id];if(u){l.push({op:u.instance?"replace":"add",path:`/entities/${t.id}/instance`,value:{bindingId:p,assetId:this.id,assetKind:"Prefab",role:"root",sourceEntityId:c.sourceRootEntityId}});for(const h of n){const f=X(y,t.id,h.sceneComponentId);f&&l.push({op:f.instance?"replace":"add",path:`/entities/${t.id}/components/${h.sceneComponentId}/instance`,value:{bindingId:p,role:"linked",sourceComponentKey:h.sourceComponentKey}})}}l.length>0&&this.root.domainStore.applySystem(l);return}}let o=1;for(const p of r){const c=i.bindings[p];c&&c.sourceRevision>o&&(o=c.sourceRevision)}this.root.prefabFacade.bindExistingInstance({assetId:this.id,instanceRootEntityId:t.id,sourceRevision:o,entityMappings:a,componentMappings:n,undoable:(e==null?void 0:e.undoable)===!0})}_collectInstanceMappings(t,e){const s=[],a=[],n=(i,r,o)=>{var h;const p=(i==null?void 0:i.id)??r.id;s.push({sceneEntityId:r.id,sourceEntityId:p,role:o});const c=(i==null?void 0:i.components)??[],l=r.components??[];for(let f=0;f<l.length;f++){const m=l[f];if(!(m!=null&&m.id))continue;const g=((h=c[f])==null?void 0:h.id)??m.id;a.push({sceneEntityId:r.id,sceneComponentId:m.id,sourceComponentKey:g})}const y=(i==null?void 0:i.selfChildren)??[],u=r.selfChildren??[];for(let f=0;f<u.length;f++)n(y[f],u[f],"linked")};return n(t,e,"root"),{entityMappings:s,componentMappings:a}}async replaceInstance(t,e,s){var o;const a=e.entities.get(t),n=(o=a==null?void 0:a.engineObject)==null?void 0:o.transform,i=n?{position:{x:n.position.x,y:n.position.y,z:n.position.z},rotation:{x:n.rotation.x,y:n.rotation.y,z:n.rotation.z},scale:{x:n.scale.x,y:n.scale.y,z:n.scale.z}}:void 0,r=await this.instantiate(e,i,s);return r.convertToPrefabRefEntity(),e.replaceEntity(t,r),r}_instantiateEngineObject(){return this.engineObject.instantiate()}_onDrop(t,e){if(!e||e.id===this.id)return;this.dropping=!1;const{sceneStore:s,sceneUIStore:a}=this.root,n=Array.from(a.selectedKeys);if(n.length>1)for(let i=0;i<n.length;i++)_.createByEntity(s.entities.get(n[i]));else Y({title:S("prefab.replace.title").toString(),description:S("prefab.replace.description",{name:this.name}).toString(),confirmText:S("prefab.replace.confirm").toString(),onConfirm:()=>{const i=s.entities.get(n[0]);this.updateByEntity(i,!0)}})}_rebaseInstanceRevisions(){const{prefabFacade:t,domainStore:e}=this.root,s=e.state.prefab.byAssetId[this.id];if(!s||s.length===0)return;let a=0;for(const n of s){const i=e.state.prefab.bindings[n];i&&i.sourceRevision>a&&(a=i.sourceRevision)}t.updatePrefabContent(this.id,a+1)}_getEntityDataIncludeChildren(t,e,s){var i,r,o,p;const a=this.root.assetStore,n=t.toJSON(!0);if(e.push(n),!t.isGLTFRefEntity)t.components.forEach(c=>{var y;const l=Z(c);for(const u in l)if(l[u].type==="AssetPicker"){const h=(y=c[u])==null?void 0:y.refId;if(h){const f=a.assets[h];f&&s.add(f)}}}),t.children.map(c=>!c.prefabEntityRemoved&&this._getEntityDataIncludeChildren(c,e,s)),(i=t.strippedEntity)==null||i.clear();else{const c=a.assets[t.instanceAssetId];s.add(c);let l=null;try{l=(r=c.instantiateEngineObject)==null?void 0:r.call(c),T.info("_getEntityDataIncludeChildren glTF branch",{entityName:t.name,instanceAssetId:t.instanceAssetId,hasBaseline:!!l,sceneChildCount:(o=t.selfChildren??t.children)==null?void 0:o.length,sceneChildRotations:(p=t.selfChildren??t.children)==null?void 0:p.map(g=>{const A=g.transform;return A!=null&&A.rotation?{x:A.rotation.x,y:A.rotation.y,z:A.rotation.z}:null})});const m=(l==null?void 0:l.childCount)>0?l.getChild(0):l;if(m&&t.engineObject){const g=dt(t.engineObject,m);T.info("diffs result",{diffs:g}),g&&(n.assetTemplateDiffs=g)}}finally{l==null||l.destroy()}const y=t.entityManager.strippedEntities,u=t.getAddedComponents(),h=t.getAddedEntities(),f=new Set;u.forEach(m=>{f.add(m.strippedId)}),h.forEach(m=>{f.add(m.strippedId)}),f.forEach(m=>{const g=y.get(m);this._getEntityDataIncludeChildren(g,e,s)})}return{entities:e,assets:s}}_updateContent(t){return this._contentQueue.enqueue(async()=>{try{await this._updateContentInternal(t)}catch(e){if(e instanceof Error&&e.message==="cancelled")return;I.error("_updateContent failed:",e)}})}async _updateContentInternal(t){const{url:e,dependentAssets:s}=this,a=(t==null?void 0:t.persist)!==!1;await Promise.all(s.map(p=>this.root.assetStore.getAssetByRef({refId:p.id}))),await this._entityManager.init(this);const n=this.engineObject;if(n){this.root.assetStore.engineObjectToAssetMap.delete(n);try{n.destroy()}catch(p){I.warn("failed to destroy oldEngineObject:",p)}}const i=new H(this.engine,e);this.bindEngineObject(i),this.root.assetStore.engineObjectToAssetMap.set(i,this);let r=this._entityManager.rootEntities[0];r||(r=this._entityManager.createEntity("prefab","defaultPrefab"),r.bindEngineObject(new v(this.engine,"prefab")),I.error(`The prefab which id is ${this.id} is broken, use default prefab instead.`)),r.engineObject||(I.warn("rootEntity engineObject is null, binding new Entity"),r.bindEngineObject(new v(this.engine,"prefab"))),this._markAsTemplate(r),i._root=r.engineObject,r.once("delete",()=>{I.error(`The prefab which id is ${this.id} is broken.`),this._updateContent().catch(p=>{I.error(`Failed to rebuild broken prefab which id is ${this.id}.`,p)})}),this._updateDragTempEntity(),this.updateThumbnail(),a&&(this.root.assetFacade.persistAssetMeta(this.id),this.root.assetFacade.persistAssetMain(this.id));const o=t!=null&&t.undoable?{undoable:!0}:void 0;await Promise.all(Array.from(this._instances,([p,c])=>this.replaceInstance(p,c,o))),this._rebaseInstanceRevisions()}_markAsTemplate(t){const e=t.engineObject;if(!e){I.warn("_markAsTemplate: engineObject is null",{prefabId:this.id,entityModelId:t.id});return}const s=e;s._templateResource||s._markAsTemplate(this.engineObject),t.selfChildren.forEach(a=>{this._markAsTemplate(a)})}};E([tt()],_.prototype,"entities",2);E([et(),st],_.prototype,"dependentAssets",2);E([B],_.prototype,"replaceDependentAsset",1);E([B],_.prototype,"_onDrop",1);_=E([nt({type:"Prefab",label:S("asset.prefab.title"),extname:"prefab",dragLayer:O.Prefab,customInspector:ct,viewer:lt,thumbnail:w,async bundle(d){return{content:new Blob([d.content],{type:"application/json"})}}})],_);export{_ as PrefabAsset};
|
package/dist/viewport-client/_static/{PrimitiveMesh-0572a073.js → PrimitiveMesh-35092ad0.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
var wt=Object.defineProperty;var Mt=(C,s,n)=>s in C?wt(C,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):C[s]=n;var A=(C,s,n)=>(Mt(C,typeof s!="symbol"?s+"":s,n),n);import{K as it,U as q,bE as Rt,af as dt,ag as mt,ah as ft,aj as yt,bF as Pt,ad as at,bG as ct,ae as rt,bH as It,j as At,_ as Ht,O as _t,p as B,e as b,C as T,t as Bt,m as V,n as Tt,o as Vt,q as Nt}from"./index-aec7e708.js";import"./index-e8a45e82.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Et}from"./bundlers-9b0d37fc.js";import{M as Dt}from"./MeshThumbnail-ab28b3b8.js";const z=class z{static createSphere(s=.5,n=18){n=Math.max(2,Math.floor(n));const e=n+1,o=e*e,c=n*n,p=z._generateIndices(o,c*6),R=Math.PI,t=R*2,a=1/e,y=1/n,m=8,h=new Float32Array(o*m);for(let x=0;x<o;++x){const u=x%e,d=x*a|0,l=u*y,i=d*y,M=l*t,f=i*R,v=Math.sin(f),I=-s*Math.cos(M)*v,P=s*Math.cos(f),S=s*Math.sin(M)*v;let r=x*m;h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=l,h[r++]=i}let w=0;for(let x=0;x<c;++x){const u=x%n,l=(x*y|0)*e+u,i=l+1,M=l+e,f=M+1;p[w++]=i,p[w++]=l,p[w++]=f,p[w++]=l,p[w++]=M,p[w++]=f}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:p,vertices:h,bounds:g}}static createCuboid(s=1,n=1,e=1){const o=s/2,c=n/2,p=e/2,R=8,t=new Float32Array(24*R);t[0]=-o,t[1]=c,t[2]=-p,t[6]=0,t[7]=0,t[8]=o,t[9]=c,t[10]=-p,t[14]=1,t[15]=0,t[16]=o,t[17]=c,t[18]=p,t[22]=1,t[23]=1,t[24]=-o,t[25]=c,t[26]=p,t[30]=0,t[31]=1;for(let m=0;m<4;m++){let h=R*m+3;t[h++]=0,t[h++]=1,t[h++]=0}t[32]=-o,t[33]=-c,t[34]=-p,t[38]=0,t[39]=1,t[40]=o,t[41]=-c,t[42]=-p,t[46]=1,t[47]=1,t[48]=o,t[49]=-c,t[50]=p,t[54]=1,t[55]=0,t[56]=-o,t[57]=-c,t[58]=p,t[62]=0,t[63]=0;for(let m=0;m<4;m++){let h=R*m+35;t[h++]=0,t[h++]=-1,t[h++]=0}t[64]=-o,t[65]=c,t[66]=-p,t[70]=0,t[71]=0,t[72]=-o,t[73]=c,t[74]=p,t[78]=1,t[79]=0,t[80]=-o,t[81]=-c,t[82]=p,t[86]=1,t[87]=1,t[88]=-o,t[89]=-c,t[90]=-p,t[94]=0,t[95]=1;for(let m=0;m<4;m++){let h=R*m+67;t[h++]=-1,t[h++]=0,t[h++]=0}t[96]=o,t[97]=c,t[98]=-p,t[102]=1,t[103]=0,t[104]=o,t[105]=c,t[106]=p,t[110]=0,t[111]=0,t[112]=o,t[113]=-c,t[114]=p,t[118]=0,t[119]=1,t[120]=o,t[121]=-c,t[122]=-p,t[126]=1,t[127]=1;for(let m=0;m<4;m++){let h=R*m+99;t[h++]=1,t[h++]=0,t[h++]=0}t[128]=-o,t[129]=c,t[130]=p,t[134]=0,t[135]=0,t[136]=o,t[137]=c,t[138]=p,t[142]=1,t[143]=0,t[144]=o,t[145]=-c,t[146]=p,t[150]=1,t[151]=1,t[152]=-o,t[153]=-c,t[154]=p,t[158]=0,t[159]=1;for(let m=0;m<4;m++){let h=R*m+131;t[h++]=0,t[h++]=0,t[h++]=1}t[160]=-o,t[161]=c,t[162]=-p,t[166]=1,t[167]=0,t[168]=o,t[169]=c,t[170]=-p,t[174]=0,t[175]=0,t[176]=o,t[177]=-c,t[178]=-p,t[182]=0,t[183]=1,t[184]=-o,t[185]=-c,t[186]=-p,t[190]=1,t[191]=1;for(let m=0;m<4;m++){let h=R*m+163;t[h++]=0,t[h++]=0,t[h++]=-1}const a=new Uint16Array(36);a[0]=0,a[1]=2,a[2]=1,a[3]=2,a[4]=0,a[5]=3,a[6]=4,a[7]=6,a[8]=7,a[9]=6,a[10]=4,a[11]=5,a[12]=8,a[13]=10,a[14]=9,a[15]=10,a[16]=8,a[17]=11,a[18]=12,a[19]=14,a[20]=15,a[21]=14,a[22]=12,a[23]=13,a[24]=16,a[25]=18,a[26]=17,a[27]=18,a[28]=16,a[29]=19,a[30]=20,a[31]=22,a[32]=23,a[33]=22,a[34]=20,a[35]=21;const y=new q;return y.min.set(-o,-c,-p),y.max.set(o,c,p),{vertices:t,bounds:y,indices:a}}static createPlane(s=1,n=1,e=1,o=1){e=Math.max(1,Math.floor(e)),o=Math.max(1,Math.floor(o));const c=e+1,p=o+1,R=s/2,t=n/2,a=s/e,y=n/o,m=c*p,h=o*e,w=z._generateIndices(m,h*6),g=1/c,x=1/e,u=1/o,d=8,l=new Float32Array(m*d);for(let f=0;f<m;++f){const v=f%c,I=f*g|0;let P=f*d;l[P++]=v*a-R,l[P++]=0,l[P++]=I*y-t,l[P++]=0,l[P++]=1,l[P++]=0,l[P++]=v*x,l[P++]=I*u}let i=0;for(let f=0;f<h;++f){const v=f%e,P=(f*x|0)*c+v,S=P+1,r=P+c,E=r+1;w[i++]=P,w[i++]=r,w[i++]=S,w[i++]=r,w[i++]=E,w[i++]=S}const M=new q;return M.min.set(-R,0,-t),M.max.set(R,0,t),{bounds:M,vertices:l,indices:w}}static createCylinder(s=.5,n=.5,e=2,o=20,c=1){o=Math.floor(o),c=Math.floor(c);const p=o+1,R=c+1,t=e*.5,a=e/c,y=p*R,m=o*c,h=o*2,w=y+2+h,g=z._generateIndices(w,m*6+h*3),x=1/p,u=1/o,d=1/c,l=8,i=new Float32Array(w*l);let M=0;const f=Math.PI,v=Math.PI*2,I=n-s,P=I/e,S=I/c;for(let F=0;F<y;++F){const Z=F%p,W=F*x|0,O=Z*u,J=W*d,$=f+O*v,et=Math.sin($),ht=Math.cos($),ut=n-W*S,xt=ut*et,vt=W*a-t,Ct=ut*ht;let L=F*l;i[L++]=xt,i[L++]=vt,i[L++]=Ct,i[L++]=et,i[L++]=P,i[L++]=ht,i[L++]=O,i[L++]=1-J}for(let F=0;F<m;++F){const Z=F%o,O=(F*u|0)*p+Z,J=O+1,$=O+p,et=$+1;g[M++]=J,g[M++]=$,g[M++]=O,g[M++]=J,g[M++]=et,g[M++]=$}let r=y*l;i[r++]=0,i[r++]=-t,i[r++]=0,i[r++]=0,i[r++]=-1,i[r++]=0,i[r++]=.5,i[r++]=.5,i[r++]=0,i[r++]=t,i[r++]=0,i[r++]=0,i[r++]=1,i[r++]=0,i[r++]=.5,i[r++]=.5,r=(y+2)*l;const E=1/(s*2),j=1/(n*2),D=p*c;for(let F=0;F<o;++F){const Z=F*l;let W=i[Z],O=i[Z+2];i[r++]=W,i[r++]=-t,i[r++]=O,i[r++]=0,i[r++]=-1,i[r++]=0,i[r++]=W*j+.5,i[r++]=.5-O*j;const J=(F+D)*l;W=i[J],O=i[J+2],i[r++]=W,i[r++]=t,i[r++]=O,i[r++]=0,i[r++]=1,i[r++]=0,i[r++]=W*E+.5,i[r++]=.5-O*E}const Y=y+1,X=y+2,U=X+1;for(let F=0;F<o;++F){const Z=F*2,W=F===o-1?0:Z+2;g[M++]=y,g[M++]=X+W,g[M++]=X+Z,g[M++]=Y,g[M++]=U+Z,g[M++]=U+W}const Q=new q,K=Math.max(s,n);return Q.min.set(-K,-t,-K),Q.max.set(K,t,K),{bounds:Q,vertices:i,indices:g}}static createTorus(s=.5,n=.1,e=30,o=30,c=360){e=Math.floor(e),o=Math.floor(o);const p=(e+1)*(o+1),R=e*o,t=z._generateIndices(p,R*6),a=8,y=new Float32Array(p*a);c=c/180*Math.PI;let m=0;const h=z._tempVec30;for(let x=0;x<=e;x++)for(let u=0;u<=o;u++){const d=u/o*c,l=x/e*Math.PI*2,i=Math.cos(l),M=Math.sin(l),f=Math.cos(d),v=Math.sin(d),I=(s+n*i)*f,P=(s+n*i)*v,S=n*M;y[m++]=I,y[m++]=P,y[m++]=S;const r=s*f,E=s*v;h.set(I-r,P-E,S).normalize(),y[m++]=h.x,y[m++]=h.y,y[m++]=h.z,y[m++]=u/o,y[m++]=x/e}m=0;for(let x=1;x<=e;x++)for(let u=1;u<=o;u++){const d=(o+1)*x+u-1,l=(o+1)*(x-1)+u-1,i=(o+1)*(x-1)+u,M=(o+1)*x+u;t[m++]=d,t[m++]=l,t[m++]=M,t[m++]=l,t[m++]=i,t[m++]=M}const w=new q,g=s+n;return w.min.set(-g,-g,-n),w.max.set(g,g,n),{bounds:w,vertices:y,indices:t}}static createCone(s=.5,n=2,e=20,o=1){e=Math.floor(e),o=Math.floor(o);const c=e+1,p=o+1,R=n*.5,t=n/o,a=c*p,y=e*o,m=a+1+e,h=z._generateIndices(m,y*6+e*3),w=1/c,g=1/e,x=1/o,u=8,d=new Float32Array(m*8);let l=0;const i=Math.PI,M=Math.PI*2,f=s/n;for(let r=0;r<a;++r){const E=r%c,j=r*w|0,D=E*g,Y=j*x,X=i+D*M,U=Math.sin(X),Q=Math.cos(X),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++]=D,d[O++]=1-Y}for(let r=0;r<y;++r){const E=r%e,D=(r*g|0)*c+E,Y=D+1,X=D+c,U=X+1;h[l++]=Y,h[l++]=X,h[l++]=D,h[l++]=Y,h[l++]=U,h[l++]=X}let v=a*u;d[v++]=0,d[v++]=-R,d[v++]=0,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=.5,d[v++]=.5,v=(a+1)*u;const I=1/(s*2);for(let r=0;r<e;++r){const E=d[r*u],j=d[r*u+2];d[v++]=E,d[v++]=-R,d[v++]=j,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=E*I+.5,d[v++]=.5-j*I}const P=a+1;for(let r=0;r<e;++r){const E=r,j=r===e-1?0:E+1;h[l++]=a,h[l++]=P+j,h[l++]=P+E}const S=new q;return S.min.set(-s,-R,-s),S.max.set(s,R,s),{bounds:S,vertices:d,indices:h}}static createCapsule(s=.5,n=2,e=6,o=1){e=Math.max(2,Math.floor(e)),o=Math.floor(o);const c=e+1,p=o+1,R=n*.5,t=n/o,a=c*p,y=e*o,m=c*c,h=e*e,w=a+2*m,g=z._generateIndices(w,(y+2*h)*6),x=1/c,u=1/e,d=1/o,l=Math.PI,i=Math.PI*2,M=8,f=new Float32Array(w*M);let v=0;for(let P=0;P<a;++P){const S=P%c,r=P*x|0,E=S*u,j=r*d,D=l+E*i,Y=Math.sin(D),X=Math.cos(D);let U=P*M;f[U++]=s*Y,f[U++]=r*t-R,f[U++]=s*X,f[U++]=Y,f[U++]=0,f[U++]=X,f[U++]=E,f[U++]=1-j}for(let P=0;P<y;++P){const S=P%e,E=(P*u|0)*c+S,j=E+1,D=E+c,Y=D+1;g[v++]=j,g[v++]=D,g[v++]=E,g[v++]=j,g[v++]=Y,g[v++]=D}z._createCapsuleCap(s,n,e,l,i,a,1,f,g,v),z._createCapsuleCap(s,n,e,l,-i,a+m,-1,f,g,v+6*h);const I=new q;return I.min.set(-s,-s-R,-s),I.max.set(s,s+R,s),{bounds:I,vertices:f,indices:g}}static _generateIndices(s,n){let e=null;return s>65535?e=new Uint32Array(n):e=new Uint16Array(n),e}static _createCapsuleCap(s,n,e,o,c,p,R,t,a,y){const m=e+1,h=n*.5*R,w=m*m,g=e*e,x=1/m,u=1/e,d=8;for(let l=0;l<w;++l){const i=l%m,M=l*x|0,f=i*u,v=M*u,I=o+f*c,P=v*Math.PI*.5,S=Math.sin(P),r=s*Math.sin(I)*S,E=s*Math.cos(P)*R+h,j=s*Math.cos(I)*S;let D=(l+p)*d;t[D++]=r,t[D++]=E,t[D++]=j,t[D++]=r,t[D++]=E-h,t[D++]=j,t[D++]=f,t[D++]=v}for(let l=0;l<g;++l){const i=l%e,f=(l*u|0)*m+i+p,v=f+1,I=f+m,P=I+1;a[y++]=v,a[y++]=f,a[y++]=P,a[y++]=f,a[y++]=I,a[y++]=P}}static createSubdivisionSurfaceSphereData(s=.5,n=3){n=Rt.clamp(Math.floor(n),1,6);const e=new Float32Array(3*(6*Math.pow(4,n)+2)),o=new Float32Array(24*Math.pow(4,n));this._subdiveCatmullClark(n,e,o);const c=e.length/3,p=o.length/4,R=c+Math.pow(2,n+1)-1,t=R+16,a=new Float32Array(t*8),y=this._generateIndices(c,p*6);let m=0;const h={};for(let x=0;x<c;x++){let u=3*x,d=e[u],l=e[u+1],i=e[u+2];const M=1/Math.sqrt(d*d+l*l+i*i);if(d*=M,l*=M,i*=M,u=8*x,a[u]=d*s,a[u+1]=l*s,a[u+2]=i*s,a[u+3]=d,a[u+4]=l,a[u+5]=i,a[u+6]=(Math.PI-Math.atan2(i,d))/(2*Math.PI),a[u+7]=Math.acos(l)/Math.PI,a[u+6]===0){const f=8*(c+m++);a.set(a.subarray(u,u+8),f),a[f+6]=1,h[u/8]=f/8}}let w=0;this._spherePoleIdx=0;for(let x=0;x<p;x++){const u=4*x;let d=o[u],l=o[u+1],i=o[u+2],M=o[u+3];const f=8*d,v=8*l,I=8*i,P=8*M;a[f+2]+a[v+2]+a[I+2]<0&&(a[f+6]===0&&(d=h[d]),a[v+6]===0&&(l=h[l]),a[I+6]===0&&(i=h[i]),a[P+6]===0&&(M=h[M])),y[w]=d,y[w+1]=l,y[w+2]=i,this._generateAndReplacePoleUV(y,a,w,R),y[w+3]=d,y[w+4]=i,y[w+5]=M,this._generateAndReplacePoleUV(y,a,w+3,R),w+=6}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:y,vertices:a,bounds:g}}static _generateAndReplacePoleUV(s,n,e,o){const c=n[8*s[e]+7];if(c===0||c===1){const p=8*s[e],R=8*(o+this._spherePoleIdx);n.set(n.subarray(p,p+8),R),n[R+6]=.5*(n[p+6]+n[8*s[e+1]+6]+n[8*s[e+2]+6]-.5),s[e]=o+this._spherePoleIdx++}}static _subdiveCatmullClark(s,n,e){const o=new Map,c=new Array;n.set(this._sphereSeedPositions),e.set(this._sphereSeedCells);for(let p=0;p<s;p++){const R=6*Math.pow(4,p),t=4*R+2;o.clear(),c.length=0;for(let w=0;w<R;w++){const g=c[w]={facePoint:new it,adjacentEdges:new Array(4)};for(let x=0;x<4;x++){const u=3*e[4*w+x];g.facePoint.x+=.25*n[u],g.facePoint.y+=.25*n[u+1],g.facePoint.z+=.25*n[u+2]}for(let x=0;x<4;x++){const u=e[4*w+x],d=e[4*w+(x+1)%4],l=Math.min(u,d)*t+Math.max(u,d);if(!o.has(l)){const v={edgePoint:new it,edgePointIndex:void 0},I=3*u,P=3*d;v.edgePoint.set(.25*(n[I]+n[P]),.25*(n[I+1]+n[P+1]),.25*(n[I+2]+n[P+2])),o.set(l,v)}const i=o.get(l);g.adjacentEdges[x]=i;const M=i.edgePoint,f=g.facePoint;M.x+=.25*f.x,M.y+=.25*f.y,M.z+=.25*f.z}}const a=R+2,y=a+R;let m=0;this._sphereEdgeIdx=0;const h=e.slice(0,4*R);for(let w=0;w<R;w++){const g=c[w];g.facePoint.copyToArray(n,3*(a+w));const x=a+w;let u,d,l;for(let i=0;i<4;i++){const M=h[m++];switch(i){case 0:{const v=g.adjacentEdges[i%4],I=g.adjacentEdges[(i+3)%4];d=this._calculateEdgeIndex(n,v,y),u=this._calculateEdgeIndex(n,I,y),l=u;break}case 1:case 2:{const v=g.adjacentEdges[i%4];u=d,d=this._calculateEdgeIndex(n,v,y);break}case 3:{u=d,d=l;break}}const f=4*(4*w+i);e[f]=M,e[f+1]=d,e[f+2]=x,e[f+3]=u}}}}static _calculateEdgeIndex(s,n,e){if(n.edgePointIndex!==void 0)return n.edgePointIndex;{n.edgePoint.copyToArray(s,3*(e+this._sphereEdgeIdx));const o=e+this._sphereEdgeIdx++;return n.edgePointIndex=o,o}}};A(z,"_tempVec30",new it),A(z,"_sphereSeedPositions",new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1])),A(z,"_sphereSeedCells",new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1])),A(z,"_sphereEdgeIdx",0),A(z,"_spherePoleIdx",0);let k=z;function Ft(){return[new at(ct.Position,0,rt.Vector3,0),new at(ct.Normal,12,rt.Vector3,0),new at(ct.UV,24,rt.Vector2,0)]}function lt(C,s,{vertices:n,indices:e,bounds:o}){const c=new dt(s,mt.VertexBuffer,n,ft.Static),p=new dt(s,mt.IndexBuffer,e,ft.Static);C.setVertexElements(Ft()),C.setIndexBufferBinding(p,e instanceof Uint16Array?yt.UInt16:yt.UInt32),C.setVertexBufferBinding(c,32),C.bounds=o,C.subMesh?C.subMesh.count=e.length:C.addSubMesh(0,e.length)}class St extends It{constructor(s,n,e){super(s),this.engine=n,this.generateData=e}restoreContent(){lt(this.resource,this.engine,this.generateData())}}function Ot(C,s,n){s.resourceManager.addContentRestorer(new St(C,s,n))}function jt(C,s,n){const e=new Pt(C,s);return Ot(e,C,n),lt(e,C,n()),e}var Ut=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,_=(C,s,n,e)=>{for(var o=e>1?void 0:e?zt(s,n):s,c=C.length-1,p;c>=0;c--)(p=C[c])&&(o=(e?p(s,n,o):p(o))||o);return e&&o&&Ut(s,n,o),o},bt=(C=>(C.Sphere="sphere",C.Cuboid="cuboid",C.Plane="plane",C.Cylinder="cylinder",C.Torus="torus",C.Cone="cone",C.Capsule="capsule",C))(bt||{});const gt=C=>C.type==="sphere",ot=C=>C.type==="capsule",st=C=>C.type==="cone",pt=C=>C.type==="cuboid",G=C=>C.type==="cylinder",tt=C=>C.type==="torus",nt=C=>C.type==="plane",N=C=>C._updateData();let H=class extends At{constructor(s){super(s);A(this,"type","sphere");A(this,"sphereRadius",.5);A(this,"sphereStep",3);A(this,"capsuleRadius",.5);A(this,"capsuleHeight",2);A(this,"capsuleRadialSegments",6);A(this,"capsuleHeightSegments",1);A(this,"coneRadius",.5);A(this,"coneHeight",2);A(this,"coneRadialSegment",20);A(this,"coneHeightSegment",1);A(this,"cuboidWidth",1);A(this,"cuboidHeight",1);A(this,"cuboidDepth",1);A(this,"cylinderRadiusTop",.5);A(this,"cylinderRadiusBottom",.5);A(this,"cylinderHeight",2);A(this,"cylinderRadialSegment",20);A(this,"cylinderHeightSegment",1);A(this,"planeWidth",1);A(this,"planeHeight",1);A(this,"planeHorizontalSegments",1);A(this,"planeVerticalSegments",1);A(this,"torusRadius",.5);A(this,"torusTubeRadius",.1);A(this,"torusRadialSegments",30);A(this,"torusTubularSegments",30);A(this,"torusArc",360)}async initByCreation(s,n,e){const c=(typeof(e==null?void 0:e.primitiveType)=="string"?e.primitiveType:"").trim().toLowerCase();return{type:{sphere:"sphere",cube:"cuboid",cuboid:"cuboid",cylinder:"cylinder",plane:"plane",capsule:"capsule",cone:"cone",torus:"torus"}[c]??"sphere"}}async initByMain(s,n){const e=JSON.parse(await s.text()),o=this.engine,c=e.type;for(const y in e)this[y]=e[y];const p=jt(o,c,()=>this._generateDataByType(this.type));this.bindEngineObject(p);const R=new Ht(o,c&&c.charAt(0).toUpperCase()+c.slice(1)),t=R.addComponent(_t);t.mesh=this.engineObject;const a=await this.root.assetStore.getAssetByRef({refId:"0000200"});t.setMaterial(a.engineObject),this.setDragTempEntity(R)}instantiate(){const s=this.root.sceneStore.createEntity(),n=this.getDragTempEntity();return s.initByEngineObject(n.clone()),s}_updateData(){const s=this.engine,n=this._engineObject;lt(n,s,this._generateDataByType(this.type))}_generateDataByType(s){switch(s){case"sphere":return k.createSubdivisionSurfaceSphereData(this.sphereRadius,this.sphereStep);case"capsule":return k.createCapsule(this.capsuleRadius,this.capsuleHeight,this.capsuleRadialSegments,this.capsuleHeightSegments);case"cone":return k.createCone(this.coneRadius,this.coneHeight,this.coneRadialSegment,this.coneHeightSegment);case"cuboid":return k.createCuboid(this.cuboidWidth,this.cuboidHeight,this.cuboidDepth);case"cylinder":return k.createCylinder(this.cylinderRadiusTop,this.cylinderRadiusBottom,this.cylinderHeight,this.cylinderRadialSegment,this.cylinderHeightSegment);case"plane":return k.createPlane(this.planeWidth,this.planeHeight,this.planeHorizontalSegments,this.planeVerticalSegments);case"torus":return k.createTorus(this.torusRadius,this.torusTubeRadius,this.torusRadialSegments,this.torusTubularSegments,this.torusArc);default:return k.createSphere(this.sphereRadius,this.sphereStep)}}};_([B({label:b("asset.primitive-mesh.type.label"),info:b("asset.primitive-mesh.type.info"),type:T.Select,value:"sphere",options:Bt(bt),onChange(C){C._updateData()}}),V()],H.prototype,"type",2);_([B({label:b("asset.primitive-mesh.sphere.radius.label"),info:b("asset.primitive-mesh.sphere.radius.info"),type:T.Number,min:0,dragStep:.1,when:gt,onChange:N}),V()],H.prototype,"sphereRadius",2);_([B({label:b("asset.primitive-mesh.sphere.step.label"),info:b("asset.primitive-mesh.sphere.step.info"),type:T.Number,min:1,dragStep:1,when:gt,onChange:N}),V()],H.prototype,"sphereStep",2);_([B({label:b("asset.primitive-mesh.capsule.radius.label"),info:b("asset.primitive-mesh.capsule.radius.info"),type:T.Number,min:0,dragStep:.1,when:ot,onChange:N}),V()],H.prototype,"capsuleRadius",2);_([B({label:b("asset.primitive-mesh.capsule.height.label"),info:b("asset.primitive-mesh.capsule.height.info"),type:T.Number,min:0,dragStep:.1,when:ot,onChange:N}),V()],H.prototype,"capsuleHeight",2);_([B({label:b("asset.primitive-mesh.capsule.radial-segments.label"),info:b("asset.primitive-mesh.capsule.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:ot,onChange:N}),V()],H.prototype,"capsuleRadialSegments",2);_([B({label:b("asset.primitive-mesh.capsule.height-segments.label"),info:b("asset.primitive-mesh.capsule.height-segments.info"),type:T.Number,min:1,dragStep:1,when:ot,onChange:N}),V()],H.prototype,"capsuleHeightSegments",2);_([B({label:b("asset.primitive-mesh.cone.radius.label"),info:b("asset.primitive-mesh.cone.radius.info"),type:T.Number,min:0,dragStep:.1,when:st,onChange:N}),V()],H.prototype,"coneRadius",2);_([B({label:b("asset.primitive-mesh.cone.height.label"),info:b("asset.primitive-mesh.cone.height.info"),type:T.Number,min:0,dragStep:.1,when:st,onChange:N}),V()],H.prototype,"coneHeight",2);_([B({label:b("asset.primitive-mesh.cone.radial-segments.label"),info:b("asset.primitive-mesh.cone.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:st,onChange:N}),V()],H.prototype,"coneRadialSegment",2);_([B({label:b("asset.primitive-mesh.cone.height-segments.label"),info:b("asset.primitive-mesh.cone.height-segments.info"),type:T.Number,min:1,dragStep:1,when:st,onChange:N}),V()],H.prototype,"coneHeightSegment",2);_([B({label:b("asset.primitive-mesh.cuboid.width.label"),info:b("asset.primitive-mesh.cuboid.width.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidWidth",2);_([B({label:b("asset.primitive-mesh.cuboid.height.label"),info:b("asset.primitive-mesh.cuboid.height.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidHeight",2);_([B({label:b("asset.primitive-mesh.cuboid.depth.label"),info:b("asset.primitive-mesh.cuboid.depth.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidDepth",2);_([B({label:b("asset.primitive-mesh.cylinder.radius-top.label"),info:b("asset.primitive-mesh.cylinder.radius-top.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderRadiusTop",2);_([B({label:b("asset.primitive-mesh.cylinder.radius-bottom.label"),info:b("asset.primitive-mesh.cylinder.radius-bottom.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderRadiusBottom",2);_([B({label:b("asset.primitive-mesh.cylinder.height.label"),info:b("asset.primitive-mesh.cylinder.height.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderHeight",2);_([B({label:b("asset.primitive-mesh.cylinder.radial-segments.label"),info:b("asset.primitive-mesh.cylinder.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:G,onChange:N}),V()],H.prototype,"cylinderRadialSegment",2);_([B({label:b("asset.primitive-mesh.cylinder.height-segments.label"),info:b("asset.primitive-mesh.cylinder.height-segments.info"),type:T.Number,min:1,dragStep:1,when:G,onChange:N}),V()],H.prototype,"cylinderHeightSegment",2);_([B({label:b("asset.primitive-mesh.plane.width.label"),info:b("asset.primitive-mesh.plane.width.info"),type:T.Number,min:0,dragStep:.1,when:nt,onChange:N}),V()],H.prototype,"planeWidth",2);_([B({label:b("asset.primitive-mesh.plane.height.label"),info:b("asset.primitive-mesh.plane.height.info"),type:T.Number,min:0,dragStep:.1,when:nt,onChange:N}),V()],H.prototype,"planeHeight",2);_([B({label:b("asset.primitive-mesh.plane.horizontal-segments.label"),info:b("asset.primitive-mesh.plane.horizontal-segments.info"),type:T.Number,min:1,dragStep:1,when:nt,onChange:N}),V()],H.prototype,"planeHorizontalSegments",2);_([B({label:b("asset.primitive-mesh.plane.vertical-segments.label"),info:b("asset.primitive-mesh.plane.vertical-segments.info"),type:T.Number,min:1,dragStep:1,when:nt,onChange:N}),V()],H.prototype,"planeVerticalSegments",2);_([B({label:b("asset.primitive-mesh.torus.radius.label"),info:b("asset.primitive-mesh.torus.radius.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusRadius",2);_([B({label:b("asset.primitive-mesh.torus.tube-radius.label"),info:b("asset.primitive-mesh.torus.tube-radius.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusTubeRadius",2);_([B({label:b("asset.primitive-mesh.torus.radial-segments.label"),info:b("asset.primitive-mesh.torus.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:tt,onChange:N}),V()],H.prototype,"torusRadialSegments",2);_([B({label:b("asset.primitive-mesh.torus.tubular-segments.label"),info:b("asset.primitive-mesh.torus.tubular-segments.info"),type:T.Number,min:1,dragStep:1,when:tt,onChange:N}),V()],H.prototype,"torusTubularSegments",2);_([B({label:b("asset.primitive-mesh.torus.arc.label"),info:b("asset.primitive-mesh.torus.arc.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusArc",2);H=_([Tt({type:"PrimitiveMesh",label:b("asset.primitive-mesh.title"),loaderType:"PrimitiveMesh",importMenuConfig:{type:Vt.Add},defaultName:"Mesh",dragLayer:Nt.PrimitiveMesh,thumbnail:Dt,async bundle({content:C}){return{content:new Blob([Et(await C.text())])}}})],H);export{H as PrimitiveMesh};
|
|
1
|
+
var wt=Object.defineProperty;var Mt=(C,s,n)=>s in C?wt(C,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):C[s]=n;var A=(C,s,n)=>(Mt(C,typeof s!="symbol"?s+"":s,n),n);import{K as it,U as q,bE as Rt,af as dt,ag as mt,ah as ft,aj as yt,bF as Pt,ad as at,bG as ct,ae as rt,bH as It,j as At,_ as Ht,O as _t,p as B,e as b,C as T,t as Bt,m as V,n as Tt,o as Vt,q as Nt}from"./index-1e23212d.js";import"./index-92830754.js";import"./meshopt_simplifier.module-cd99529d.js";import{a as Et}from"./bundlers-9b0d37fc.js";import{M as Dt}from"./MeshThumbnail-25cd4a13.js";const z=class z{static createSphere(s=.5,n=18){n=Math.max(2,Math.floor(n));const e=n+1,o=e*e,c=n*n,p=z._generateIndices(o,c*6),R=Math.PI,t=R*2,a=1/e,y=1/n,m=8,h=new Float32Array(o*m);for(let x=0;x<o;++x){const u=x%e,d=x*a|0,l=u*y,i=d*y,M=l*t,f=i*R,v=Math.sin(f),I=-s*Math.cos(M)*v,P=s*Math.cos(f),S=s*Math.sin(M)*v;let r=x*m;h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=I,h[r++]=P,h[r++]=S,h[r++]=l,h[r++]=i}let w=0;for(let x=0;x<c;++x){const u=x%n,l=(x*y|0)*e+u,i=l+1,M=l+e,f=M+1;p[w++]=i,p[w++]=l,p[w++]=f,p[w++]=l,p[w++]=M,p[w++]=f}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:p,vertices:h,bounds:g}}static createCuboid(s=1,n=1,e=1){const o=s/2,c=n/2,p=e/2,R=8,t=new Float32Array(24*R);t[0]=-o,t[1]=c,t[2]=-p,t[6]=0,t[7]=0,t[8]=o,t[9]=c,t[10]=-p,t[14]=1,t[15]=0,t[16]=o,t[17]=c,t[18]=p,t[22]=1,t[23]=1,t[24]=-o,t[25]=c,t[26]=p,t[30]=0,t[31]=1;for(let m=0;m<4;m++){let h=R*m+3;t[h++]=0,t[h++]=1,t[h++]=0}t[32]=-o,t[33]=-c,t[34]=-p,t[38]=0,t[39]=1,t[40]=o,t[41]=-c,t[42]=-p,t[46]=1,t[47]=1,t[48]=o,t[49]=-c,t[50]=p,t[54]=1,t[55]=0,t[56]=-o,t[57]=-c,t[58]=p,t[62]=0,t[63]=0;for(let m=0;m<4;m++){let h=R*m+35;t[h++]=0,t[h++]=-1,t[h++]=0}t[64]=-o,t[65]=c,t[66]=-p,t[70]=0,t[71]=0,t[72]=-o,t[73]=c,t[74]=p,t[78]=1,t[79]=0,t[80]=-o,t[81]=-c,t[82]=p,t[86]=1,t[87]=1,t[88]=-o,t[89]=-c,t[90]=-p,t[94]=0,t[95]=1;for(let m=0;m<4;m++){let h=R*m+67;t[h++]=-1,t[h++]=0,t[h++]=0}t[96]=o,t[97]=c,t[98]=-p,t[102]=1,t[103]=0,t[104]=o,t[105]=c,t[106]=p,t[110]=0,t[111]=0,t[112]=o,t[113]=-c,t[114]=p,t[118]=0,t[119]=1,t[120]=o,t[121]=-c,t[122]=-p,t[126]=1,t[127]=1;for(let m=0;m<4;m++){let h=R*m+99;t[h++]=1,t[h++]=0,t[h++]=0}t[128]=-o,t[129]=c,t[130]=p,t[134]=0,t[135]=0,t[136]=o,t[137]=c,t[138]=p,t[142]=1,t[143]=0,t[144]=o,t[145]=-c,t[146]=p,t[150]=1,t[151]=1,t[152]=-o,t[153]=-c,t[154]=p,t[158]=0,t[159]=1;for(let m=0;m<4;m++){let h=R*m+131;t[h++]=0,t[h++]=0,t[h++]=1}t[160]=-o,t[161]=c,t[162]=-p,t[166]=1,t[167]=0,t[168]=o,t[169]=c,t[170]=-p,t[174]=0,t[175]=0,t[176]=o,t[177]=-c,t[178]=-p,t[182]=0,t[183]=1,t[184]=-o,t[185]=-c,t[186]=-p,t[190]=1,t[191]=1;for(let m=0;m<4;m++){let h=R*m+163;t[h++]=0,t[h++]=0,t[h++]=-1}const a=new Uint16Array(36);a[0]=0,a[1]=2,a[2]=1,a[3]=2,a[4]=0,a[5]=3,a[6]=4,a[7]=6,a[8]=7,a[9]=6,a[10]=4,a[11]=5,a[12]=8,a[13]=10,a[14]=9,a[15]=10,a[16]=8,a[17]=11,a[18]=12,a[19]=14,a[20]=15,a[21]=14,a[22]=12,a[23]=13,a[24]=16,a[25]=18,a[26]=17,a[27]=18,a[28]=16,a[29]=19,a[30]=20,a[31]=22,a[32]=23,a[33]=22,a[34]=20,a[35]=21;const y=new q;return y.min.set(-o,-c,-p),y.max.set(o,c,p),{vertices:t,bounds:y,indices:a}}static createPlane(s=1,n=1,e=1,o=1){e=Math.max(1,Math.floor(e)),o=Math.max(1,Math.floor(o));const c=e+1,p=o+1,R=s/2,t=n/2,a=s/e,y=n/o,m=c*p,h=o*e,w=z._generateIndices(m,h*6),g=1/c,x=1/e,u=1/o,d=8,l=new Float32Array(m*d);for(let f=0;f<m;++f){const v=f%c,I=f*g|0;let P=f*d;l[P++]=v*a-R,l[P++]=0,l[P++]=I*y-t,l[P++]=0,l[P++]=1,l[P++]=0,l[P++]=v*x,l[P++]=I*u}let i=0;for(let f=0;f<h;++f){const v=f%e,P=(f*x|0)*c+v,S=P+1,r=P+c,E=r+1;w[i++]=P,w[i++]=r,w[i++]=S,w[i++]=r,w[i++]=E,w[i++]=S}const M=new q;return M.min.set(-R,0,-t),M.max.set(R,0,t),{bounds:M,vertices:l,indices:w}}static createCylinder(s=.5,n=.5,e=2,o=20,c=1){o=Math.floor(o),c=Math.floor(c);const p=o+1,R=c+1,t=e*.5,a=e/c,y=p*R,m=o*c,h=o*2,w=y+2+h,g=z._generateIndices(w,m*6+h*3),x=1/p,u=1/o,d=1/c,l=8,i=new Float32Array(w*l);let M=0;const f=Math.PI,v=Math.PI*2,I=n-s,P=I/e,S=I/c;for(let F=0;F<y;++F){const Z=F%p,W=F*x|0,O=Z*u,J=W*d,$=f+O*v,et=Math.sin($),ht=Math.cos($),ut=n-W*S,xt=ut*et,vt=W*a-t,Ct=ut*ht;let L=F*l;i[L++]=xt,i[L++]=vt,i[L++]=Ct,i[L++]=et,i[L++]=P,i[L++]=ht,i[L++]=O,i[L++]=1-J}for(let F=0;F<m;++F){const Z=F%o,O=(F*u|0)*p+Z,J=O+1,$=O+p,et=$+1;g[M++]=J,g[M++]=$,g[M++]=O,g[M++]=J,g[M++]=et,g[M++]=$}let r=y*l;i[r++]=0,i[r++]=-t,i[r++]=0,i[r++]=0,i[r++]=-1,i[r++]=0,i[r++]=.5,i[r++]=.5,i[r++]=0,i[r++]=t,i[r++]=0,i[r++]=0,i[r++]=1,i[r++]=0,i[r++]=.5,i[r++]=.5,r=(y+2)*l;const E=1/(s*2),j=1/(n*2),D=p*c;for(let F=0;F<o;++F){const Z=F*l;let W=i[Z],O=i[Z+2];i[r++]=W,i[r++]=-t,i[r++]=O,i[r++]=0,i[r++]=-1,i[r++]=0,i[r++]=W*j+.5,i[r++]=.5-O*j;const J=(F+D)*l;W=i[J],O=i[J+2],i[r++]=W,i[r++]=t,i[r++]=O,i[r++]=0,i[r++]=1,i[r++]=0,i[r++]=W*E+.5,i[r++]=.5-O*E}const Y=y+1,X=y+2,U=X+1;for(let F=0;F<o;++F){const Z=F*2,W=F===o-1?0:Z+2;g[M++]=y,g[M++]=X+W,g[M++]=X+Z,g[M++]=Y,g[M++]=U+Z,g[M++]=U+W}const Q=new q,K=Math.max(s,n);return Q.min.set(-K,-t,-K),Q.max.set(K,t,K),{bounds:Q,vertices:i,indices:g}}static createTorus(s=.5,n=.1,e=30,o=30,c=360){e=Math.floor(e),o=Math.floor(o);const p=(e+1)*(o+1),R=e*o,t=z._generateIndices(p,R*6),a=8,y=new Float32Array(p*a);c=c/180*Math.PI;let m=0;const h=z._tempVec30;for(let x=0;x<=e;x++)for(let u=0;u<=o;u++){const d=u/o*c,l=x/e*Math.PI*2,i=Math.cos(l),M=Math.sin(l),f=Math.cos(d),v=Math.sin(d),I=(s+n*i)*f,P=(s+n*i)*v,S=n*M;y[m++]=I,y[m++]=P,y[m++]=S;const r=s*f,E=s*v;h.set(I-r,P-E,S).normalize(),y[m++]=h.x,y[m++]=h.y,y[m++]=h.z,y[m++]=u/o,y[m++]=x/e}m=0;for(let x=1;x<=e;x++)for(let u=1;u<=o;u++){const d=(o+1)*x+u-1,l=(o+1)*(x-1)+u-1,i=(o+1)*(x-1)+u,M=(o+1)*x+u;t[m++]=d,t[m++]=l,t[m++]=M,t[m++]=l,t[m++]=i,t[m++]=M}const w=new q,g=s+n;return w.min.set(-g,-g,-n),w.max.set(g,g,n),{bounds:w,vertices:y,indices:t}}static createCone(s=.5,n=2,e=20,o=1){e=Math.floor(e),o=Math.floor(o);const c=e+1,p=o+1,R=n*.5,t=n/o,a=c*p,y=e*o,m=a+1+e,h=z._generateIndices(m,y*6+e*3),w=1/c,g=1/e,x=1/o,u=8,d=new Float32Array(m*8);let l=0;const i=Math.PI,M=Math.PI*2,f=s/n;for(let r=0;r<a;++r){const E=r%c,j=r*w|0,D=E*g,Y=j*x,X=i+D*M,U=Math.sin(X),Q=Math.cos(X),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++]=D,d[O++]=1-Y}for(let r=0;r<y;++r){const E=r%e,D=(r*g|0)*c+E,Y=D+1,X=D+c,U=X+1;h[l++]=Y,h[l++]=X,h[l++]=D,h[l++]=Y,h[l++]=U,h[l++]=X}let v=a*u;d[v++]=0,d[v++]=-R,d[v++]=0,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=.5,d[v++]=.5,v=(a+1)*u;const I=1/(s*2);for(let r=0;r<e;++r){const E=d[r*u],j=d[r*u+2];d[v++]=E,d[v++]=-R,d[v++]=j,d[v++]=0,d[v++]=-1,d[v++]=0,d[v++]=E*I+.5,d[v++]=.5-j*I}const P=a+1;for(let r=0;r<e;++r){const E=r,j=r===e-1?0:E+1;h[l++]=a,h[l++]=P+j,h[l++]=P+E}const S=new q;return S.min.set(-s,-R,-s),S.max.set(s,R,s),{bounds:S,vertices:d,indices:h}}static createCapsule(s=.5,n=2,e=6,o=1){e=Math.max(2,Math.floor(e)),o=Math.floor(o);const c=e+1,p=o+1,R=n*.5,t=n/o,a=c*p,y=e*o,m=c*c,h=e*e,w=a+2*m,g=z._generateIndices(w,(y+2*h)*6),x=1/c,u=1/e,d=1/o,l=Math.PI,i=Math.PI*2,M=8,f=new Float32Array(w*M);let v=0;for(let P=0;P<a;++P){const S=P%c,r=P*x|0,E=S*u,j=r*d,D=l+E*i,Y=Math.sin(D),X=Math.cos(D);let U=P*M;f[U++]=s*Y,f[U++]=r*t-R,f[U++]=s*X,f[U++]=Y,f[U++]=0,f[U++]=X,f[U++]=E,f[U++]=1-j}for(let P=0;P<y;++P){const S=P%e,E=(P*u|0)*c+S,j=E+1,D=E+c,Y=D+1;g[v++]=j,g[v++]=D,g[v++]=E,g[v++]=j,g[v++]=Y,g[v++]=D}z._createCapsuleCap(s,n,e,l,i,a,1,f,g,v),z._createCapsuleCap(s,n,e,l,-i,a+m,-1,f,g,v+6*h);const I=new q;return I.min.set(-s,-s-R,-s),I.max.set(s,s+R,s),{bounds:I,vertices:f,indices:g}}static _generateIndices(s,n){let e=null;return s>65535?e=new Uint32Array(n):e=new Uint16Array(n),e}static _createCapsuleCap(s,n,e,o,c,p,R,t,a,y){const m=e+1,h=n*.5*R,w=m*m,g=e*e,x=1/m,u=1/e,d=8;for(let l=0;l<w;++l){const i=l%m,M=l*x|0,f=i*u,v=M*u,I=o+f*c,P=v*Math.PI*.5,S=Math.sin(P),r=s*Math.sin(I)*S,E=s*Math.cos(P)*R+h,j=s*Math.cos(I)*S;let D=(l+p)*d;t[D++]=r,t[D++]=E,t[D++]=j,t[D++]=r,t[D++]=E-h,t[D++]=j,t[D++]=f,t[D++]=v}for(let l=0;l<g;++l){const i=l%e,f=(l*u|0)*m+i+p,v=f+1,I=f+m,P=I+1;a[y++]=v,a[y++]=f,a[y++]=P,a[y++]=f,a[y++]=I,a[y++]=P}}static createSubdivisionSurfaceSphereData(s=.5,n=3){n=Rt.clamp(Math.floor(n),1,6);const e=new Float32Array(3*(6*Math.pow(4,n)+2)),o=new Float32Array(24*Math.pow(4,n));this._subdiveCatmullClark(n,e,o);const c=e.length/3,p=o.length/4,R=c+Math.pow(2,n+1)-1,t=R+16,a=new Float32Array(t*8),y=this._generateIndices(c,p*6);let m=0;const h={};for(let x=0;x<c;x++){let u=3*x,d=e[u],l=e[u+1],i=e[u+2];const M=1/Math.sqrt(d*d+l*l+i*i);if(d*=M,l*=M,i*=M,u=8*x,a[u]=d*s,a[u+1]=l*s,a[u+2]=i*s,a[u+3]=d,a[u+4]=l,a[u+5]=i,a[u+6]=(Math.PI-Math.atan2(i,d))/(2*Math.PI),a[u+7]=Math.acos(l)/Math.PI,a[u+6]===0){const f=8*(c+m++);a.set(a.subarray(u,u+8),f),a[f+6]=1,h[u/8]=f/8}}let w=0;this._spherePoleIdx=0;for(let x=0;x<p;x++){const u=4*x;let d=o[u],l=o[u+1],i=o[u+2],M=o[u+3];const f=8*d,v=8*l,I=8*i,P=8*M;a[f+2]+a[v+2]+a[I+2]<0&&(a[f+6]===0&&(d=h[d]),a[v+6]===0&&(l=h[l]),a[I+6]===0&&(i=h[i]),a[P+6]===0&&(M=h[M])),y[w]=d,y[w+1]=l,y[w+2]=i,this._generateAndReplacePoleUV(y,a,w,R),y[w+3]=d,y[w+4]=i,y[w+5]=M,this._generateAndReplacePoleUV(y,a,w+3,R),w+=6}const g=new q;return g.min.set(-s,-s,-s),g.max.set(s,s,s),{indices:y,vertices:a,bounds:g}}static _generateAndReplacePoleUV(s,n,e,o){const c=n[8*s[e]+7];if(c===0||c===1){const p=8*s[e],R=8*(o+this._spherePoleIdx);n.set(n.subarray(p,p+8),R),n[R+6]=.5*(n[p+6]+n[8*s[e+1]+6]+n[8*s[e+2]+6]-.5),s[e]=o+this._spherePoleIdx++}}static _subdiveCatmullClark(s,n,e){const o=new Map,c=new Array;n.set(this._sphereSeedPositions),e.set(this._sphereSeedCells);for(let p=0;p<s;p++){const R=6*Math.pow(4,p),t=4*R+2;o.clear(),c.length=0;for(let w=0;w<R;w++){const g=c[w]={facePoint:new it,adjacentEdges:new Array(4)};for(let x=0;x<4;x++){const u=3*e[4*w+x];g.facePoint.x+=.25*n[u],g.facePoint.y+=.25*n[u+1],g.facePoint.z+=.25*n[u+2]}for(let x=0;x<4;x++){const u=e[4*w+x],d=e[4*w+(x+1)%4],l=Math.min(u,d)*t+Math.max(u,d);if(!o.has(l)){const v={edgePoint:new it,edgePointIndex:void 0},I=3*u,P=3*d;v.edgePoint.set(.25*(n[I]+n[P]),.25*(n[I+1]+n[P+1]),.25*(n[I+2]+n[P+2])),o.set(l,v)}const i=o.get(l);g.adjacentEdges[x]=i;const M=i.edgePoint,f=g.facePoint;M.x+=.25*f.x,M.y+=.25*f.y,M.z+=.25*f.z}}const a=R+2,y=a+R;let m=0;this._sphereEdgeIdx=0;const h=e.slice(0,4*R);for(let w=0;w<R;w++){const g=c[w];g.facePoint.copyToArray(n,3*(a+w));const x=a+w;let u,d,l;for(let i=0;i<4;i++){const M=h[m++];switch(i){case 0:{const v=g.adjacentEdges[i%4],I=g.adjacentEdges[(i+3)%4];d=this._calculateEdgeIndex(n,v,y),u=this._calculateEdgeIndex(n,I,y),l=u;break}case 1:case 2:{const v=g.adjacentEdges[i%4];u=d,d=this._calculateEdgeIndex(n,v,y);break}case 3:{u=d,d=l;break}}const f=4*(4*w+i);e[f]=M,e[f+1]=d,e[f+2]=x,e[f+3]=u}}}}static _calculateEdgeIndex(s,n,e){if(n.edgePointIndex!==void 0)return n.edgePointIndex;{n.edgePoint.copyToArray(s,3*(e+this._sphereEdgeIdx));const o=e+this._sphereEdgeIdx++;return n.edgePointIndex=o,o}}};A(z,"_tempVec30",new it),A(z,"_sphereSeedPositions",new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1])),A(z,"_sphereSeedCells",new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1])),A(z,"_sphereEdgeIdx",0),A(z,"_spherePoleIdx",0);let k=z;function Ft(){return[new at(ct.Position,0,rt.Vector3,0),new at(ct.Normal,12,rt.Vector3,0),new at(ct.UV,24,rt.Vector2,0)]}function lt(C,s,{vertices:n,indices:e,bounds:o}){const c=new dt(s,mt.VertexBuffer,n,ft.Static),p=new dt(s,mt.IndexBuffer,e,ft.Static);C.setVertexElements(Ft()),C.setIndexBufferBinding(p,e instanceof Uint16Array?yt.UInt16:yt.UInt32),C.setVertexBufferBinding(c,32),C.bounds=o,C.subMesh?C.subMesh.count=e.length:C.addSubMesh(0,e.length)}class St extends It{constructor(s,n,e){super(s),this.engine=n,this.generateData=e}restoreContent(){lt(this.resource,this.engine,this.generateData())}}function Ot(C,s,n){s.resourceManager.addContentRestorer(new St(C,s,n))}function jt(C,s,n){const e=new Pt(C,s);return Ot(e,C,n),lt(e,C,n()),e}var Ut=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,_=(C,s,n,e)=>{for(var o=e>1?void 0:e?zt(s,n):s,c=C.length-1,p;c>=0;c--)(p=C[c])&&(o=(e?p(s,n,o):p(o))||o);return e&&o&&Ut(s,n,o),o},bt=(C=>(C.Sphere="sphere",C.Cuboid="cuboid",C.Plane="plane",C.Cylinder="cylinder",C.Torus="torus",C.Cone="cone",C.Capsule="capsule",C))(bt||{});const gt=C=>C.type==="sphere",ot=C=>C.type==="capsule",st=C=>C.type==="cone",pt=C=>C.type==="cuboid",G=C=>C.type==="cylinder",tt=C=>C.type==="torus",nt=C=>C.type==="plane",N=C=>C._updateData();let H=class extends At{constructor(s){super(s);A(this,"type","sphere");A(this,"sphereRadius",.5);A(this,"sphereStep",3);A(this,"capsuleRadius",.5);A(this,"capsuleHeight",2);A(this,"capsuleRadialSegments",6);A(this,"capsuleHeightSegments",1);A(this,"coneRadius",.5);A(this,"coneHeight",2);A(this,"coneRadialSegment",20);A(this,"coneHeightSegment",1);A(this,"cuboidWidth",1);A(this,"cuboidHeight",1);A(this,"cuboidDepth",1);A(this,"cylinderRadiusTop",.5);A(this,"cylinderRadiusBottom",.5);A(this,"cylinderHeight",2);A(this,"cylinderRadialSegment",20);A(this,"cylinderHeightSegment",1);A(this,"planeWidth",1);A(this,"planeHeight",1);A(this,"planeHorizontalSegments",1);A(this,"planeVerticalSegments",1);A(this,"torusRadius",.5);A(this,"torusTubeRadius",.1);A(this,"torusRadialSegments",30);A(this,"torusTubularSegments",30);A(this,"torusArc",360)}async initByCreation(s,n,e){const c=(typeof(e==null?void 0:e.primitiveType)=="string"?e.primitiveType:"").trim().toLowerCase();return{type:{sphere:"sphere",cube:"cuboid",cuboid:"cuboid",cylinder:"cylinder",plane:"plane",capsule:"capsule",cone:"cone",torus:"torus"}[c]??"sphere"}}async initByMain(s,n){const e=JSON.parse(await s.text()),o=this.engine,c=e.type;for(const y in e)this[y]=e[y];const p=jt(o,c,()=>this._generateDataByType(this.type));this.bindEngineObject(p);const R=new Ht(o,c&&c.charAt(0).toUpperCase()+c.slice(1)),t=R.addComponent(_t);t.mesh=this.engineObject;const a=await this.root.assetStore.getAssetByRef({refId:"0000200"});t.setMaterial(a.engineObject),this.setDragTempEntity(R)}instantiate(){const s=this.root.sceneStore.createEntity(),n=this.getDragTempEntity();return s.initByEngineObject(n.clone()),s}_updateData(){const s=this.engine,n=this._engineObject;lt(n,s,this._generateDataByType(this.type))}_generateDataByType(s){switch(s){case"sphere":return k.createSubdivisionSurfaceSphereData(this.sphereRadius,this.sphereStep);case"capsule":return k.createCapsule(this.capsuleRadius,this.capsuleHeight,this.capsuleRadialSegments,this.capsuleHeightSegments);case"cone":return k.createCone(this.coneRadius,this.coneHeight,this.coneRadialSegment,this.coneHeightSegment);case"cuboid":return k.createCuboid(this.cuboidWidth,this.cuboidHeight,this.cuboidDepth);case"cylinder":return k.createCylinder(this.cylinderRadiusTop,this.cylinderRadiusBottom,this.cylinderHeight,this.cylinderRadialSegment,this.cylinderHeightSegment);case"plane":return k.createPlane(this.planeWidth,this.planeHeight,this.planeHorizontalSegments,this.planeVerticalSegments);case"torus":return k.createTorus(this.torusRadius,this.torusTubeRadius,this.torusRadialSegments,this.torusTubularSegments,this.torusArc);default:return k.createSphere(this.sphereRadius,this.sphereStep)}}};_([B({label:b("asset.primitive-mesh.type.label"),info:b("asset.primitive-mesh.type.info"),type:T.Select,value:"sphere",options:Bt(bt),onChange(C){C._updateData()}}),V()],H.prototype,"type",2);_([B({label:b("asset.primitive-mesh.sphere.radius.label"),info:b("asset.primitive-mesh.sphere.radius.info"),type:T.Number,min:0,dragStep:.1,when:gt,onChange:N}),V()],H.prototype,"sphereRadius",2);_([B({label:b("asset.primitive-mesh.sphere.step.label"),info:b("asset.primitive-mesh.sphere.step.info"),type:T.Number,min:1,dragStep:1,when:gt,onChange:N}),V()],H.prototype,"sphereStep",2);_([B({label:b("asset.primitive-mesh.capsule.radius.label"),info:b("asset.primitive-mesh.capsule.radius.info"),type:T.Number,min:0,dragStep:.1,when:ot,onChange:N}),V()],H.prototype,"capsuleRadius",2);_([B({label:b("asset.primitive-mesh.capsule.height.label"),info:b("asset.primitive-mesh.capsule.height.info"),type:T.Number,min:0,dragStep:.1,when:ot,onChange:N}),V()],H.prototype,"capsuleHeight",2);_([B({label:b("asset.primitive-mesh.capsule.radial-segments.label"),info:b("asset.primitive-mesh.capsule.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:ot,onChange:N}),V()],H.prototype,"capsuleRadialSegments",2);_([B({label:b("asset.primitive-mesh.capsule.height-segments.label"),info:b("asset.primitive-mesh.capsule.height-segments.info"),type:T.Number,min:1,dragStep:1,when:ot,onChange:N}),V()],H.prototype,"capsuleHeightSegments",2);_([B({label:b("asset.primitive-mesh.cone.radius.label"),info:b("asset.primitive-mesh.cone.radius.info"),type:T.Number,min:0,dragStep:.1,when:st,onChange:N}),V()],H.prototype,"coneRadius",2);_([B({label:b("asset.primitive-mesh.cone.height.label"),info:b("asset.primitive-mesh.cone.height.info"),type:T.Number,min:0,dragStep:.1,when:st,onChange:N}),V()],H.prototype,"coneHeight",2);_([B({label:b("asset.primitive-mesh.cone.radial-segments.label"),info:b("asset.primitive-mesh.cone.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:st,onChange:N}),V()],H.prototype,"coneRadialSegment",2);_([B({label:b("asset.primitive-mesh.cone.height-segments.label"),info:b("asset.primitive-mesh.cone.height-segments.info"),type:T.Number,min:1,dragStep:1,when:st,onChange:N}),V()],H.prototype,"coneHeightSegment",2);_([B({label:b("asset.primitive-mesh.cuboid.width.label"),info:b("asset.primitive-mesh.cuboid.width.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidWidth",2);_([B({label:b("asset.primitive-mesh.cuboid.height.label"),info:b("asset.primitive-mesh.cuboid.height.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidHeight",2);_([B({label:b("asset.primitive-mesh.cuboid.depth.label"),info:b("asset.primitive-mesh.cuboid.depth.info"),type:T.Number,min:0,dragStep:.1,when:pt,onChange:N}),V()],H.prototype,"cuboidDepth",2);_([B({label:b("asset.primitive-mesh.cylinder.radius-top.label"),info:b("asset.primitive-mesh.cylinder.radius-top.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderRadiusTop",2);_([B({label:b("asset.primitive-mesh.cylinder.radius-bottom.label"),info:b("asset.primitive-mesh.cylinder.radius-bottom.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderRadiusBottom",2);_([B({label:b("asset.primitive-mesh.cylinder.height.label"),info:b("asset.primitive-mesh.cylinder.height.info"),type:T.Number,min:0,dragStep:.1,when:G,onChange:N}),V()],H.prototype,"cylinderHeight",2);_([B({label:b("asset.primitive-mesh.cylinder.radial-segments.label"),info:b("asset.primitive-mesh.cylinder.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:G,onChange:N}),V()],H.prototype,"cylinderRadialSegment",2);_([B({label:b("asset.primitive-mesh.cylinder.height-segments.label"),info:b("asset.primitive-mesh.cylinder.height-segments.info"),type:T.Number,min:1,dragStep:1,when:G,onChange:N}),V()],H.prototype,"cylinderHeightSegment",2);_([B({label:b("asset.primitive-mesh.plane.width.label"),info:b("asset.primitive-mesh.plane.width.info"),type:T.Number,min:0,dragStep:.1,when:nt,onChange:N}),V()],H.prototype,"planeWidth",2);_([B({label:b("asset.primitive-mesh.plane.height.label"),info:b("asset.primitive-mesh.plane.height.info"),type:T.Number,min:0,dragStep:.1,when:nt,onChange:N}),V()],H.prototype,"planeHeight",2);_([B({label:b("asset.primitive-mesh.plane.horizontal-segments.label"),info:b("asset.primitive-mesh.plane.horizontal-segments.info"),type:T.Number,min:1,dragStep:1,when:nt,onChange:N}),V()],H.prototype,"planeHorizontalSegments",2);_([B({label:b("asset.primitive-mesh.plane.vertical-segments.label"),info:b("asset.primitive-mesh.plane.vertical-segments.info"),type:T.Number,min:1,dragStep:1,when:nt,onChange:N}),V()],H.prototype,"planeVerticalSegments",2);_([B({label:b("asset.primitive-mesh.torus.radius.label"),info:b("asset.primitive-mesh.torus.radius.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusRadius",2);_([B({label:b("asset.primitive-mesh.torus.tube-radius.label"),info:b("asset.primitive-mesh.torus.tube-radius.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusTubeRadius",2);_([B({label:b("asset.primitive-mesh.torus.radial-segments.label"),info:b("asset.primitive-mesh.torus.radial-segments.info"),type:T.Number,min:1,dragStep:1,when:tt,onChange:N}),V()],H.prototype,"torusRadialSegments",2);_([B({label:b("asset.primitive-mesh.torus.tubular-segments.label"),info:b("asset.primitive-mesh.torus.tubular-segments.info"),type:T.Number,min:1,dragStep:1,when:tt,onChange:N}),V()],H.prototype,"torusTubularSegments",2);_([B({label:b("asset.primitive-mesh.torus.arc.label"),info:b("asset.primitive-mesh.torus.arc.info"),type:T.Number,min:0,dragStep:.1,when:tt,onChange:N}),V()],H.prototype,"torusArc",2);H=_([Tt({type:"PrimitiveMesh",label:b("asset.primitive-mesh.title"),loaderType:"PrimitiveMesh",importMenuConfig:{type:Vt.Add},defaultName:"Mesh",dragLayer:Nt.PrimitiveMesh,thumbnail:Dt,async bundle({content:C}){return{content:new Blob([Et(await C.text())])}}})],H);export{H as PrimitiveMesh};
|