@galacean/cli 2.0.0-alpha.11 → 2.0.0-alpha.12
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 +3084 -2863
- package/dist/viewport-client/_static/Accordion-4897319b.js +6 -0
- package/dist/viewport-client/_static/AmbientLightAsset-f70b95f1.js +5 -0
- package/dist/viewport-client/_static/AnimationClipAsset-01f3deb6.js +1 -0
- package/dist/viewport-client/_static/AnimatorControllerAsset-b7424e9c.js +1 -0
- package/dist/viewport-client/_static/AnimatorStore-fd98c00e.js +1 -0
- package/dist/viewport-client/_static/AssetPreviewer-24e31d97.js +6 -0
- package/dist/viewport-client/_static/AssetViewer-bc198e16.js +1 -0
- package/dist/viewport-client/_static/AudioAsset-eae03324.js +1 -0
- package/dist/viewport-client/_static/AudioComponent-44070c2c.js +1 -0
- package/dist/viewport-client/_static/Callout-cb4a55ff.js +1 -0
- package/dist/viewport-client/_static/CameraComponent-907ac745.js +1 -0
- package/dist/viewport-client/_static/CanvasRenderer-9dd98cb3.js +1 -0
- package/dist/viewport-client/_static/Component-f923abb1.js +1 -0
- package/dist/viewport-client/_static/DirectLight-58f5fe9e.js +1 -0
- package/dist/viewport-client/_static/FontAsset-abfb9a8a.js +5 -0
- package/dist/viewport-client/_static/FormItemArray-66be8701.js +1 -0
- package/dist/viewport-client/_static/GlTFAsset-9c68f862.js +20 -0
- package/dist/viewport-client/_static/IconPlayerPlayFilled-b058c98f.js +6 -0
- package/dist/viewport-client/_static/IconPointFilled-a304fd34.js +6 -0
- package/dist/viewport-client/_static/InstanceEditorAsset-a70e73fe.js +1 -0
- package/dist/viewport-client/_static/LightBaseComponent-fbc3ae49.js +1 -0
- package/dist/viewport-client/_static/LottieAnimationComponent-1c3e02a5.js +1 -0
- package/dist/viewport-client/_static/LottieAsset-377c1419.js +1 -0
- package/dist/viewport-client/_static/MarkdownAsset-7ea387a9.js +1 -0
- package/dist/viewport-client/_static/MaterialAsset-74a15124.js +1 -0
- package/dist/viewport-client/_static/MaterialInspector-aec1248b.js +1 -0
- package/dist/viewport-client/_static/Menu-cd3be298.js +17 -0
- package/dist/viewport-client/_static/MeshAsset-73e2cc8e.js +1 -0
- package/dist/viewport-client/_static/MeshRendererBaseComponent-3a0e09ed.js +1 -0
- package/dist/viewport-client/_static/MeshRendererComponent-5385d30f.js +1 -0
- package/dist/viewport-client/_static/MeshThumbnail-49273f71.js +1 -0
- package/dist/viewport-client/_static/ParticleRendererComponent-5a7b57d9.js +21 -0
- package/dist/viewport-client/_static/PhysicsMaterialAsset-a5ac9f82.js +1 -0
- package/dist/viewport-client/_static/PhysicsStore-0729e76d.js +1 -0
- package/dist/viewport-client/_static/PointLight-0e1d1546.js +1 -0
- package/dist/viewport-client/_static/PostProcessComponent-8276d33c.js +1 -0
- package/dist/viewport-client/_static/PrefabAsset-1a7edfbd.js +1 -0
- package/dist/viewport-client/_static/PrimitiveMesh-3ce6fa2f.js +1 -0
- package/dist/viewport-client/_static/ProxyConfigs-4de3304c.js +1 -0
- package/dist/viewport-client/_static/ReferencedMaterial-a87818f3.js +1 -0
- package/dist/viewport-client/_static/RenderTargetAsset-33c0d9e7.js +1 -0
- package/dist/viewport-client/_static/SceneAsset-8917c210.js +1 -0
- package/dist/viewport-client/_static/ShaderAsset-cb3ff628.js +185 -0
- package/dist/viewport-client/_static/ShaderChunkAsset-83f923f4.js +5 -0
- package/dist/viewport-client/_static/ShaderUIScriptAsset-d13fa4e2.js +516 -0
- package/dist/viewport-client/_static/SkinnedMeshRendererComponent-2a8323bf.js +1 -0
- package/dist/viewport-client/_static/SpineAnimationComponent-e733d50f.js +1 -0
- package/dist/viewport-client/_static/SpineSkeletonDataAsset-b64a3ee3.js +1 -0
- package/dist/viewport-client/_static/SpotLight-ca6c0c3b.js +1 -0
- package/dist/viewport-client/_static/SpriteAsset-9a31ec24.js +1 -0
- package/dist/viewport-client/_static/SpriteAtlasAsset-a862db46.js +1 -0
- package/dist/viewport-client/_static/SpriteBaseComponent-f6f1731f.js +1 -0
- package/dist/viewport-client/_static/SpriteMaskComponent-778be04f.js +1 -0
- package/dist/viewport-client/_static/SpriteRendererComponent-2b4d153b.js +1 -0
- package/dist/viewport-client/_static/TaskQueue-05c94a4d.js +1 -0
- package/dist/viewport-client/_static/TextBaseComponent-69233798.js +11 -0
- package/dist/viewport-client/_static/TextRendererComponent-130b4e99.js +1 -0
- package/dist/viewport-client/_static/TextureAsset-28fedf2a.js +36 -0
- package/dist/viewport-client/_static/ThumbnailMixin-35997457.js +1 -0
- package/dist/viewport-client/_static/ThumbnailRegistry-495c18c9.js +1 -0
- package/dist/viewport-client/_static/Tooltip-33f770ba.js +1 -0
- package/dist/viewport-client/_static/TrailRendererComponent-148550b5.js +1 -0
- package/dist/viewport-client/_static/TransformBaseComponent-02318c5a.js +1 -0
- package/dist/viewport-client/_static/TransformComponent-96106065.js +1 -0
- package/dist/viewport-client/_static/ViewerManager-202b570a.js +1 -0
- package/dist/viewport-client/_static/XRReferenceImageAsset-6a6adb3b.js +1 -0
- package/dist/viewport-client/_static/assetEditorActions-c4e5962f.js +1 -0
- package/dist/viewport-client/_static/audio-244358e2.js +1 -0
- package/dist/viewport-client/_static/bundlers-9b0d37fc.js +1 -0
- package/dist/viewport-client/_static/createOnModelChange-b57a0da8.js +1 -0
- package/dist/viewport-client/_static/encode-ac4bb64e.js +1 -0
- package/dist/viewport-client/_static/enum-58295f88.js +1 -0
- package/dist/viewport-client/_static/glTFIO-45ff9a17.js +1 -0
- package/dist/viewport-client/_static/index-0a8702e2.js +11217 -0
- package/dist/viewport-client/_static/index-237c84cd.js +20 -0
- package/dist/viewport-client/_static/index-37c74ae9.js +26 -0
- package/dist/viewport-client/_static/index-4cca0201.js +1 -0
- package/dist/viewport-client/_static/index-59732f86.js +1 -0
- package/dist/viewport-client/_static/index-6c8198f6.js +2 -0
- package/dist/viewport-client/_static/index-6f827618.js +1 -0
- package/dist/viewport-client/_static/index-803ca489.js +1 -0
- package/dist/viewport-client/_static/index-85a6cf6a.js +1 -0
- package/dist/viewport-client/_static/index-98982ce2.js +1 -0
- package/dist/viewport-client/_static/index-b3d51f87.js +1 -0
- package/dist/viewport-client/_static/index-be6bc38a.js +177 -0
- package/dist/viewport-client/_static/index-c403cbcd.js +1 -0
- package/dist/viewport-client/_static/index-e46ec5b1.js +16 -0
- package/dist/viewport-client/_static/index-e73966ae.js +1 -0
- package/dist/viewport-client/_static/index-e95b4498.js +1 -0
- package/dist/viewport-client/_static/index-f5a67a46.js +1 -0
- package/dist/viewport-client/_static/ktx-parse.modern-6c9f771f.js +1 -0
- package/dist/viewport-client/_static/ktx2-encoder-1e63c1eb.js +1 -0
- package/dist/viewport-client/_static/ktx2-worker-a04f41ea.js +1 -0
- package/dist/viewport-client/_static/meshopt_simplifier.module-cd99529d.js +1 -0
- package/dist/viewport-client/_static/module-107b7430.js +56 -0
- package/dist/viewport-client/_static/module-5c85b07e.js +1 -0
- package/dist/viewport-client/_static/module-6406b050.js +1 -0
- package/dist/viewport-client/_static/postmen-45d4c238.js +1 -0
- package/dist/viewport-client/_static/scriptPropertyActions-d3a583d2.js +1 -0
- package/dist/viewport-client/_static/utilities-e09052e3.js +11 -0
- package/dist/viewport-client/index.html +20 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var fe=Object.defineProperty;var pe=(r,e,t)=>e in r?fe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var p=(r,e,t)=>(pe(r,typeof e!="symbol"?e+"":e,t),t);import{aT as mt,aJ as v,aD as R,aY as zt,by as de,aK as tt,eZ as me,cX as we,$ as wt,a4 as ye,aH as it,aU as Yt,H as Rt,bu as xe,bw as ve,bv as be,bB as Re,x as Se,bA as Ie,cw as Ce,ew as Pe,aM as Te,e_ as _e,eR as Be,e as pt,bz as Qt,n as yt,aG as ke,aI as Fe,I as Zt,j as Me,e$ as Nt,a9 as Ee,_ as Oe,C as O,cb as Ae,aP as je,p as Q,m as Z,f as De,v as Le,J as ze,bV as Ne,cd as He,cc as Ht}from"./index-0a8702e2.js";import{u as $e,F as We,a as qe,A as $t}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{A as Ve}from"./AssetViewer-bc198e16.js";import"./meshopt_simplifier.module-cd99529d.js";import{c as Ue}from"./bundlers-9b0d37fc.js";import{b as Je,a as te}from"./TextureAsset-28fedf2a.js";function Ge(r,e){const t={};for(let i=0;i<r.length;i++){const n=r[i],a=e(n);Object.hasOwn(t,a)||(t[a]=[]),t[a].push(n)}return t}function Ke(r,e){const t=[],i=[];for(let n=0;n<r.length;n++){const a=r[n];e(a)?t.push(a):i.push(a)}return[t,i]}const Xe=mt(function(r){const[e,t]=v.useState(null),i=r.asset,{assetStore:n,inspectorFacade:a}=$e(),c=(s,o,g)=>{a.assetChange(s,o,g)};return v.useEffect(()=>{n.getAssetByRef(i.texture).then(s=>{t(s)})},[i.texture]),R.jsxs(R.Fragment,{children:[R.jsx(zt.List,{model:i,configs:i.formSchema.items,onModelChange:(s,o)=>c(i.id,s,o)}),e&&R.jsxs(R.Fragment,{children:[R.jsx(de,{}),R.jsx(tt,{justifyContent:"between",css:{padding:"$2 0"},children:R.jsx(me,{children:"Texture Option"})}),R.jsx(we,{label:"Name",value:e.name,readOnly:!0}),R.jsx(zt.List,{model:e,configs:e.formSchema.items,onModelChange:(s,o)=>c(e.id,s,o)})]})]})});class Ct{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.spriteRenderer.sprite=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("sprite");this.spriteRenderer=t.addComponent(wt)}}p(Ct,"entity"),p(Ct,"spriteRenderer");class Ye extends Ve{constructor(){super()}setViewAsset(e,t){const i=t.createChild("sprite_entity"),n=i.addComponent(wt);n.sprite=e.engineObject,this._entity=i}getDescription(e){var i;const t=(i=e.engineObject)==null?void 0:i.texture;if(t){const{width:n,height:a}=t;return`${n}x${a}`}else return""}}const J=1,Qe=220,Ze=180,St=ye._pixelsPerUnit??100,ti={left:"x",bottom:"y",right:"z",top:"w"},ei={left:{axis:"x",fromStart:!0},right:{axis:"x",fromStart:!1},top:{axis:"y",fromStart:!0},bottom:{axis:"y",fromStart:!1}},ii=[["left","right"],["top","bottom"]],ni={left:"width",right:"width",top:"height",bottom:"height"},ri={left:"right",right:"left",top:"bottom",bottom:"top"},si=it(tt,{width:"220px"}),ai=it("div",{position:"relative",width:"100%",height:"180px",borderRadius:"$2",border:"1px solid $gray6",overflow:"hidden",backgroundImage:"linear-gradient(45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,0.06) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.06) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.06) 75%)",backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px"}),oi=it("div",{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",border:"1px solid $gray9",background:"linear-gradient(135deg, rgba(76, 132, 255, 0.26) 0%, rgba(76, 132, 255, 0.08) 48%, rgba(76, 132, 255, 0.2) 100%)",boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.2)"}),ci=it("canvas",{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",pointerEvents:"none"}),li=it("div",{position:"absolute",borderRadius:"$1",backgroundColor:"rgba(126, 211, 129, 0.1)",pointerEvents:"none"}),Wt=it("div",{position:"absolute",top:0,bottom:0,width:"10px",marginLeft:"-5px",cursor:"ew-resize","&::before":{content:'""',position:"absolute",left:"50%",top:0,bottom:0,borderLeft:"1px dashed $blue9"}}),qt=it("div",{position:"absolute",left:0,right:0,height:"10px",marginTop:"-5px",cursor:"ns-resize","&::before":{content:'""',position:"absolute",top:"50%",left:0,right:0,borderTop:"1px dashed $blue9"}}),hi={flex:1,minWidth:0};function q(r,e,t){return Math.min(t,Math.max(e,r))}function Y(r,e=2){const t=Math.pow(10,e);return Math.round(r*t)/t}function et(r,e=0){return Number.isFinite(r)?r:e}function dt(r,e,t,i){return r=q(et(r),0,t),e=q(et(e),0,t),r+e>t&&(i?e=t-r:r=t-e),[r,e]}function ft(r,e){const[t,i]=dt(r.x,r.z,1,e==="x"),[n,a]=dt(r.y,r.w,1,e==="y");return{x:Y(t,2),y:Y(n,2),z:Y(i,2),w:Y(a,2)}}function Tt(r,e,t,i){const n=Math.max(J,Math.round(et(e,J))),a=Math.max(J,Math.round(et(t,J))),[c,s]=dt(r.left,r.right,n,i==="left"),[o,g]=dt(r.top,r.bottom,a,i==="top");return{left:Math.round(c),bottom:Math.round(g),right:Math.round(s),top:Math.round(o)}}function Vt(r,e,t){const i=ft(r);return Tt({left:i.x*e,bottom:i.y*t,right:i.z*e,top:i.w*t},e,t)}function ui(r,e,t){const i=Tt(r,e,t),n=Math.max(J,e),a=Math.max(J,t),c=Y(q(i.left/n,0,1),2),s=Y(q(i.bottom/a,0,1),2),o=Y(q(i.right/n,0,1-c),2),g=Y(q(i.top/a,0,1-s),2);return{x:c,y:s,z:o,w:g}}function gi(r,e,t,i){const a=Math.max(1,et(t,1)),c=Math.max(1,et(i,1)),s=Math.max(1,r-16*2),o=Math.max(1,e-16*2),g=Math.min(s,o),l=Math.max(a,c),f=g/l;return{width:Math.max(1,a*f),height:Math.max(1,c*f)}}function fi(r,e=!0){const[t,i]=v.useState({width:0,height:0});return v.useLayoutEffect(()=>{if(!e){i({width:0,height:0});return}const n=r.current;if(!n)return;const a=()=>{i({width:n.clientWidth,height:n.clientHeight})};a();const c=new ResizeObserver(a);return c.observe(n),()=>{c.disconnect()}},[r,e]),t}const pi=mt(function(e){var Mt,Et,Ot,At,jt,Dt;const{model:t,inspectorConfig:i,onModelChange:n}=e,{property:a,disabled:c,label:s,info:o}=i,{t:g}=Yt();if(!t||!a)return null;const l={width:t.engineObject.width*St,height:t.engineObject.height*St},f=ft(t[a]??{x:0,y:0,z:0,w:0}),u=Vt(f,l.width,l.height),d=v.useRef(null),m=v.useRef(null),b=v.useRef(null),S=v.useRef(null),w=v.useRef(null),P=v.useRef(null),M=v.useRef(!1),j=v.useRef(!1),$=v.useRef(!1),K=v.useRef(new Rt),E=v.useRef(new Rt),nt=v.useRef(new Rt),[X,rt]=v.useState(!1),[U,H]=v.useState(null),_=fi(d,X),k=v.useMemo(()=>({width:_.width>0?_.width:Qe,height:_.height>0?_.height:Ze}),[_.height,_.width]);$.current=X;const T=v.useMemo(()=>gi(k.width,k.height,l.width,l.height),[l.height,l.width,k.height,k.width]),F=v.useMemo(()=>({left:q(u.left/Math.max(l.width,J),0,1),bottom:q(u.bottom/Math.max(l.height,J),0,1),right:q(u.right/Math.max(l.width,J),0,1),top:q(u.top/Math.max(l.height,J),0,1)}),[u.bottom,u.left,u.right,u.top,l.height,l.width]),W=v.useCallback((h=!1)=>{if(P.current!==null&&(cancelAnimationFrame(P.current),P.current=null),M.current=!1,j.current=!1,!h)return;const y=w.current,x=S.current;if(x){const I=(y==null?void 0:y.canvasCtx)??x.getContext("2d");I==null||I.clearRect(0,0,x.width,x.height)}},[]),ct=v.useCallback(()=>{W();const h=w.current;if(h){if(h.renderTarget){const y=h.renderTarget.getColorTexture(0);y==null||y.destroy(!0),h.renderTarget.destroy(!0),h.renderTarget=null}try{t.engine.sceneManager.removeScene(h.scene)}catch{}h.scene.destroy(),w.current=null,W(!0)}},[t.engine,W]),_t=v.useCallback(()=>{const h=w.current,y=S.current;if(!h||!y)return!1;const x=window.devicePixelRatio||1,I=Math.round(T.width*x),C=Math.round(T.height*x);if(I<=0||C<=0)return!1;if((y.width!==I||y.height!==C)&&(y.width=I,y.height=C),h.renderTarget&&h.renderTarget.width===I&&h.renderTarget.height===C)return h.camera.aspectRatio=I/C,!0;if(h.renderTarget){const st=h.renderTarget.getColorTexture(0);st==null||st.destroy(!0),h.renderTarget.destroy(!0)}const N=new xe(t.engine,I,C,void 0,!1),G=new ve(t.engine,I,C,N,be.Depth,4),bt=new ImageData(new Uint8ClampedArray(I*C*4),I,C);return h.renderTarget=G,h.imageData=bt,h.camera.aspectRatio=I/C,h.camera.renderTarget=G,!0},[T.height,T.width,t.engine]),Bt=v.useCallback(()=>{const h=w.current;if(!h||!h.spriteRenderer.sprite)return;const y=h.spriteRenderer.bounds,x=K.current,I=E.current;y.getCenter(x),y.getExtent(I);const C=h.camera.aspectRatio>0?h.camera.aspectRatio:1,N=Math.max(I.x,l.width*.5,.5),G=Math.max(I.y,l.height*.5,.5);h.camera.isOrthographic=!0,h.camera.orthographicSize=Math.max(G,N/C)/St,h.camera.nearClipPlane=.1,h.camera.farClipPlane=100,h.cameraEntity.transform.setPosition(x.x,x.y,10),nt.current.set(x.x,x.y,0),h.cameraEntity.transform.lookAt(nt.current)},[l.height,l.width]),kt=v.useCallback(()=>{const h=w.current,y=S.current;if(!h||!h.renderTarget||!h.imageData||!y)return;const x=t.engine;if(j.current)return;j.current=!0;try{h.camera.renderTarget=h.renderTarget,x.sceneManager.addScene(h.scene),x.update()}finally{try{x.sceneManager.removeScene(h.scene)}catch{}j.current=!1}h.renderTarget.getColorTexture(0).getPixelBuffer(0,0,h.renderTarget.width,h.renderTarget.height,0,h.imageData.data);const C=h.canvasCtx??y.getContext("2d");C==null||C.putImageData(h.imageData,0,0)},[t.engine]),lt=v.useCallback(()=>{if(w.current)return;const h=S.current;if(!h)return;const y=new Re(t.engine);y.background.solidColor=new Se(0,0,0,0);const x=y.createRootEntity("sprite_border_preview_root"),I=x.createChild("sprite_border_preview_camera"),C=I.addComponent(Ie),G=x.createChild("sprite_border_preview_sprite").addComponent(wt);G.sprite=t.engineObject??null,w.current={scene:y,camera:C,cameraEntity:I,spriteRenderer:G,renderTarget:null,imageData:null,canvasCtx:h.getContext("2d")}},[t.engine,t.engineObject]),Ft=v.useCallback(()=>{M.current||(M.current=!0,P.current=requestAnimationFrame(()=>{if(M.current=!1,P.current=null,!$.current)return;w.current||lt();const h=w.current;h&&(h.spriteRenderer.sprite=t.engineObject??null),_t()&&(Bt(),kt())}))},[_t,Bt,lt,t.engineObject,kt]),ht=v.useCallback((h,y)=>{const x=Tt(h,l.width,l.height,y),I=ui(x,l.width,l.height);t[a]=I;const C=y?ti[y]:void 0;n==null||n(a,I,C)},[t,n,a,l.height,l.width]),re=v.useCallback((h,y)=>{const x=ft(h,y);t[a]=x,n==null||n(a,x,y)},[t,n,a]),se=v.useCallback((h,y)=>{ht({...u,[h]:et(y,0)},h)},[u,ht]),ut=v.useMemo(()=>{const h=y=>x=>{x.preventDefault();const I=m.current,C=document.activeElement;I&&C instanceof HTMLElement&&I.contains(C)&&C.blur(),H(y)};return{left:h("left"),right:h("right"),top:h("top"),bottom:h("bottom")}},[]);v.useEffect(()=>{if(!U)return;const h=ei[U],y=I=>{const C=b.current;if(!C)return;const N=C.getBoundingClientRect();if(N.width<=0||N.height<=0)return;const G=ft(t[a]??{x:0,y:0,z:0,w:0}),bt=Vt(G,l.width,l.height),st=h.axis==="x"?I.clientX:I.clientY,le=h.axis==="x"?N.left:N.top,he=h.axis==="x"?N.right:N.bottom,Lt=h.axis==="x"?N.width:N.height,ue=h.axis==="x"?l.width:l.height,ge=q(h.fromStart?(st-le)/Lt:(he-st)/Lt,0,1);ht({...bt,[U]:ge*ue},U)},x=()=>{H(null)};return window.addEventListener("mousemove",y),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",x)}},[ht,U,t,a,l.height,l.width]),v.useEffect(()=>{if(!X){ct();return}w.current||lt();const h=w.current;h&&(h.spriteRenderer.sprite=t.engineObject??null),Ft()},[ct,lt,X,Ft,T.height,T.width,t.engineObject,t.height,(Mt=t.pivot)==null?void 0:Mt.x,(Et=t.pivot)==null?void 0:Et.y,(Ot=t.region)==null?void 0:Ot.height,(At=t.region)==null?void 0:At.width,(jt=t.region)==null?void 0:jt.x,(Dt=t.region)==null?void 0:Dt.y,t.width]),v.useEffect(()=>()=>{ct()},[ct]);const ae=typeof s=="string"?g(s):s,oe=typeof o=="string"?g(o):o,ce=v.useMemo(()=>({x:"L",y:"B",z:"R",w:"T"}),[]);return R.jsx(Ce,{disabled:c,label:ae,info:oe,min:0,max:1,step:.01,dragStep:.01,value:f,slotMapping:ce,onChange:re,formEndSlot:R.jsx(Pe,{disabled:c,side:"bottom",align:"start",sideOffset:4,onOpenAutoFocus:h=>h.preventDefault(),onOpenChange:h=>{rt(h),h||H(null)},trigger:R.jsx(Te,{variant:"subtle",corner:!0,disabled:c,children:R.jsx(_e,{size:14})}),children:R.jsxs(si,{ref:m,direction:"column",gap:"sm",children:[R.jsx(ai,{ref:d,children:R.jsxs(oi,{ref:b,css:{width:`${T.width}px`,height:`${T.height}px`},children:[R.jsx(ci,{ref:S}),R.jsx(li,{css:{left:`${F.left*100}%`,right:`${F.right*100}%`,top:`${F.top*100}%`,bottom:`${F.bottom*100}%`}}),R.jsx(Wt,{onMouseDown:ut.left,css:{left:`${F.left*100}%`}}),R.jsx(Wt,{onMouseDown:ut.right,css:{left:`${(1-F.right)*100}%`}}),R.jsx(qt,{onMouseDown:ut.top,css:{top:`${F.top*100}%`}}),R.jsx(qt,{onMouseDown:ut.bottom,css:{top:`${(1-F.bottom)*100}%`}})]})}),R.jsx(tt,{direction:"column",gap:"xs",css:{width:"100%"},children:ii.map(([h,y])=>R.jsx(tt,{gap:"sm",align:"v",children:[h,y].map(x=>R.jsx(tt,{direction:"column",css:hi,children:R.jsx(Be,{min:0,max:Math.max(0,l[ni[x]]-u[ri[x]]),dragStep:1,step:1,value:u[x],startSlot:x[0].toUpperCase(),endSlot:"px",onValueChange:I=>se(x,I)})},x))},h))})]})})})});class D{constructor(e=0,t=0,i=0,n=0,a=""){p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"name","");p(this,"isRotated",!1);p(this,"allowRotate");this.x=e,this.y=t,this.width=i,this.height=n,this.name=a}clone(){return new D(this.x,this.y,this.width,this.height,`${this.name}-clone`)}isContainedIn(e){return this.x>=e.x&&this.y>=e.y&&this.x+this.width<=e.x+e.width&&this.y+this.height<=e.y+e.height}static isContainedIn(e,t){return e.isContainedIn(t)}}var L=(r=>(r[r.BestShortSideFit=0]="BestShortSideFit",r[r.BestLongSideFit=1]="BestLongSideFit",r[r.BestAreaFit=2]="BestAreaFit",r[r.BottomLeftRule=3]="BottomLeftRule",r[r.ContactPointRule=4]="ContactPointRule",r))(L||{});class di{constructor(){p(this,"binWidth");p(this,"binHeight");p(this,"allowRotate");p(this,"usedRectangles");p(this,"freeRectangles");this.binWidth=0,this.binHeight=0,this.allowRotate=!1,this.usedRectangles=[],this.freeRectangles=[]}init(e,t,i){this.binWidth=e,this.binHeight=t,this.allowRotate=i||!1,this.usedRectangles.length=0,this.freeRectangles.length=0,this.freeRectangles.push(new D(0,0,e,t))}insert(e,t,i){let n=new D;const a={value:0},c={value:0},s=i||0,o=this.allowRotate;if(!this._canFit(e,t,o))return n;switch(s){case L.BestShortSideFit:n=this._findPositionForNewNodeBestShortSideFit(e,t,a,c,o);break;case L.BottomLeftRule:n=this._findPositionForNewNodeBottomLeft(e,t,a,c,o);break;case L.ContactPointRule:n=this._findPositionForNewNodeContactPoint(e,t,a,o);break;case L.BestLongSideFit:n=this._findPositionForNewNodeBestLongSideFit(e,t,c,a,o);break;case L.BestAreaFit:n=this._findPositionForNewNodeBestAreaFit(e,t,a,c,o);break}return n.height===0||this._placeRectangle(n),n}insert2(e,t){const i=[],n=t||0;for(;e.length>0;){let a=1/0,c=1/0,s=-1,o=new D,g=-1/0;for(let f=0;f<e.length;f++){const u=e[f],d=this._getAllowRotate(u);if(!this._canFit(u.width,u.height,d))continue;const m={value:0},b={value:0},S=this._scoreRectangle(u.width,u.height,n,m,b,d),w=this._getSortKey(u,n);m.value<a||m.value===a&&b.value<c?(a=m.value,c=b.value,o=S,s=f,g=w):s!==-1&&m.value!==1/0&&b.value!==1/0&&m.value===a&&b.value===c&&w>g&&(o=S,s=f,g=w)}if(s===-1)return i;this._placeRectangle(o);const l=e.splice(s,1)[0];l.x=o.x,l.y=o.y,l.isRotated=o.isRotated,i.push(l)}return i}_placeRectangle(e){let t=this.freeRectangles.length;for(let i=0;i<t;i++)this._splitFreeNode(this.freeRectangles[i],e)&&(this.freeRectangles.splice(i,1),i--,t--);this._purgeFreeList(),this._pruneFreeList(),this.usedRectangles.push(e)}_scoreRectangle(e,t,i,n,a,c){let s=new D;switch(n.value=1/0,a.value=1/0,i){case L.BestShortSideFit:s=this._findPositionForNewNodeBestShortSideFit(e,t,n,a,c);break;case L.BottomLeftRule:s=this._findPositionForNewNodeBottomLeft(e,t,n,a,c);break;case L.ContactPointRule:s=this._findPositionForNewNodeContactPoint(e,t,n,c),n.value=-n.value;break;case L.BestLongSideFit:s=this._findPositionForNewNodeBestLongSideFit(e,t,a,n,c);break;case L.BestAreaFit:s=this._findPositionForNewNodeBestAreaFit(e,t,n,a,c);break}return s.height===0&&(n.value=1/0,a.value=1/0),s}_findPositionForNewNodeBottomLeft(e,t,i,n,a){const c=this.freeRectangles,s=new D;i.value=1/0,n.value=1/0;let o,g;for(let l=0;l<c.length;l++)o=c[l],o.width>=e&&o.height>=t&&(g=o.y+t,(g<i.value||g===i.value&&o.x<n.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,i.value=g,n.value=o.x)),a&&o.width>=t&&o.height>=e&&(g=o.y+e,(g<i.value||g===i.value&&o.x<n.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,i.value=g,n.value=o.x));return s}_findPositionForNewNodeBestShortSideFit(e,t,i,n,a){const c=this.freeRectangles,s=new D;i.value=1/0;let o,g,l,f,u;for(let d=0;d<c.length;d++)if(o=c[d],o.width>=e&&o.height>=t&&(g=Math.abs(o.width-e),l=Math.abs(o.height-t),f=Math.min(g,l),u=Math.max(g,l),(f<i.value||f===i.value&&u<n.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,i.value=f,n.value=u)),a&&o.width>=t&&o.height>=e){const m=Math.abs(o.width-t),b=Math.abs(o.height-e),S=Math.min(m,b),w=Math.max(m,b);(S<i.value||S===i.value&&w<n.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,i.value=S,n.value=w)}return s}_findPositionForNewNodeBestLongSideFit(e,t,i,n,a){const c=this.freeRectangles,s=new D;n.value=1/0;let o,g,l,f,u;for(let d=0;d<c.length;d++)o=c[d],o.width>=e&&o.height>=t&&(g=Math.abs(o.width-e),l=Math.abs(o.height-t),f=Math.min(g,l),u=Math.max(g,l),(u<n.value||u===n.value&&f<i.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,i.value=f,n.value=u)),a&&o.width>=t&&o.height>=e&&(g=Math.abs(o.width-t),l=Math.abs(o.height-e),f=Math.min(g,l),u=Math.max(g,l),(u<n.value||u===n.value&&f<i.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,i.value=f,n.value=u));return s}_findPositionForNewNodeBestAreaFit(e,t,i,n,a){const c=this.freeRectangles,s=new D;i.value=1/0;let o,g,l,f,u;for(let d=0;d<c.length;d++)o=c[d],u=o.width*o.height-e*t,o.width>=e&&o.height>=t&&(g=Math.abs(o.width-e),l=Math.abs(o.height-t),f=Math.min(g,l),(u<i.value||u===i.value&&f<n.value)&&(s.x=o.x,s.y=o.y,s.width=e,s.height=t,s.isRotated=!1,n.value=f,i.value=u)),a&&o.width>=t&&o.height>=e&&(g=Math.abs(o.width-t),l=Math.abs(o.height-e),f=Math.min(g,l),(u<i.value||u===i.value&&f<n.value)&&(s.x=o.x,s.y=o.y,s.width=t,s.height=e,s.isRotated=!0,n.value=f,i.value=u));return s}_commonIntervalLength(e,t,i,n){return t<i||n<e?0:Math.min(t,n)-Math.max(e,i)}_contactPointScoreNode(e,t,i,n){const a=this.usedRectangles;let c=0;(e===0||e+i===this.binWidth)&&(c+=n),(t===0||t+n===this.binHeight)&&(c+=i);let s;for(let o=0;o<a.length;o++)s=a[o],(s.x===e+i||s.x+s.width===e)&&(c+=this._commonIntervalLength(s.y,s.y+s.height,t,t+n)),(s.y===t+n||s.y+s.height===t)&&(c+=this._commonIntervalLength(s.x,s.x+s.width,e,e+i));return c}_findPositionForNewNodeContactPoint(e,t,i,n){const a=this.freeRectangles,c=new D;i.value=-1;let s,o;for(let g=0;g<a.length;g++)s=a[g],s.width>=e&&s.height>=t&&(o=this._contactPointScoreNode(s.x,s.y,e,t),o>i.value&&(c.x=s.x,c.y=s.y,c.width=e,c.height=t,c.isRotated=!1,i.value=o)),n&&s.width>=t&&s.height>=e&&(o=this._contactPointScoreNode(s.x,s.y,t,e),o>i.value&&(c.x=s.x,c.y=s.y,c.width=t,c.height=e,c.isRotated=!0,i.value=o));return c}_splitFreeNode(e,t){const i=this.freeRectangles;if(t.x>=e.x+e.width||t.x+t.width<=e.x||t.y>=e.y+e.height||t.y+t.height<=e.y)return!1;let n;return t.x<e.x+e.width&&t.x+t.width>e.x&&(t.y>e.y&&t.y<e.y+e.height&&(n=e.clone(),n.height=t.y-n.y,n.width>0&&n.height>0&&i.push(n)),t.y+t.height<e.y+e.height&&(n=e.clone(),n.y=t.y+t.height,n.height=e.y+e.height-(t.y+t.height),n.width>0&&n.height>0&&i.push(n))),t.y<e.y+e.height&&t.y+t.height>e.y&&(t.x>e.x&&t.x<e.x+e.width&&(n=e.clone(),n.width=t.x-n.x,n.width>0&&n.height>0&&i.push(n)),t.x+t.width<e.x+e.width&&(n=e.clone(),n.x=t.x+t.width,n.width=e.x+e.width-(t.x+t.width),n.width>0&&n.height>0&&i.push(n))),!0}_pruneFreeList(){const e=this.freeRectangles;let t=0;for(;t<e.length;){let i=t+1;const n=e[t];for(;i<e.length;){const a=e[i];if(D.isContainedIn(n,a)){e.splice(t,1),t--;break}D.isContainedIn(a,n)&&(e.splice(i,1),i--),i++}t++}}_purgeFreeList(){const e=this.freeRectangles;for(let t=e.length-1;t>=0;t--){const i=e[t];(i.width<=0||i.height<=0)&&e.splice(t,1)}}_canFit(e,t,i){return!!(e<=this.binWidth&&t<=this.binHeight||i&&t<=this.binWidth&&e<=this.binHeight)}_getAllowRotate(e){return typeof e.allowRotate=="boolean"?e.allowRotate:this.allowRotate}_getSortKey(e,t){return t===L.BestAreaFit?e.width*e.height:Math.max(e.width,e.height)}}var B=(r=>(r[r.Success=0]="Success",r[r.NoImage=1]="NoImage",r[r.ImageLoadError=2]="ImageLoadError",r[r.OffscreenBlobError=3]="OffscreenBlobError",r[r.CanvasBlobError=4]="CanvasBlobError",r[r.PackError=5]="PackError",r))(B||{});class mi{constructor(){p(this,"mipmap");p(this,"wrapModeV");p(this,"wrapModeU");p(this,"filterMode");p(this,"anisoLevel");p(this,"version",0);p(this,"format",1);p(this,"atlasItems",[])}}class wi{constructor(){p(this,"id");p(this,"name");p(this,"atlasRotated");p(this,"atlasRegion");p(this,"atlasRegionOffset");p(this,"region");p(this,"pivot");p(this,"border");p(this,"pixelsPerUnit");p(this,"width");p(this,"height")}}class xt{}class yi extends xt{constructor(){super(...arguments);p(this,"canvas");p(this,"context2D")}async parse(t){const i=t.outPut.info=new mi,n=t.option.padding??0,a=t.bins??[];t.outPut.imageFiles=[];const c=i.atlasItems;for(let s=0,o=a.length;s<o;s++){const g=a[s];this.initCanvas(g.width,g.height);const{context2D:l}=this,{rects:f}=g,u=new Array,d={img:"",type:"",width:g.width,height:g.height,sprites:u};for(let b=0,S=f.length;b<S;b++){const w=new wi,P=f[b];w.name=P.name,w.atlasRotated=P.isRotated,w.atlasRegion={x:P.x,y:P.y,w:P.width,h:P.height};const M=this.getItem(t.images,P.name),j=M==null?void 0:M.image;if(j){const $=P.x,K=P.y,E=t.option.allowTrim?M.trimRect:void 0,nt=E?E.x:0,X=E?E.y:0,rt=E?E.w:j.width,U=E?E.h:j.height;if(E){const T=M.sourceWidth??j.width,F=M.sourceHeight??j.height;w.atlasRegionOffset={x:E.x,y:E.y,z:T-E.x-E.w,w:F-E.y-E.h}}let H,_,k;if(P.isRotated){_=U,k=rt;let T;try{T=new OffscreenCanvas(_,k)}catch{T=document.createElement("canvas"),T.width=_,T.height=k}const F=T.getContext("2d");F.translate(_,0),F.rotate(Math.PI/2),F.drawImage(j,nt,X,rt,U,0,0,rt,U),H=T}else _=rt,k=U,H=j;if(P.isRotated?l.drawImage(H,0,0,_,k,$,K,_,k):l.drawImage(H,nt,X,_,k,$,K,_,k),n>0)try{const T=P.isRotated?0:nt,F=P.isRotated?0:X;for(let W=1;W<=n;++W)l.drawImage(H,T,F,_,1,$,K-W,_,1),l.drawImage(H,T,F+k-1,_,1,$,K+k+W-1,_,1),l.drawImage(H,T,F,1,k,$-W,K,1,k),l.drawImage(H,T+_-1,F,1,k,$+_+W-1,K,1,k)}catch(T){console.error(JSON.stringify(T))}}u.push(w)}const m=await this.drawCanvas();if(m)t.outPut.imageFiles.push(m),c.push(d);else return B.CanvasBlobError}return B.Success}getItem(t,i){for(let n=t.length-1;n>=0;n--)if(t[n].name===i)return t[n];return null}initCanvas(t,i){if(this.canvas)this.canvas.width!==t||this.canvas.height!==i?(this.canvas.width=t,this.canvas.height=i):this.context2D.clearRect(0,0,t,i);else{try{this.canvas=new OffscreenCanvas(t,i)}catch{this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=i}this.context2D=this.canvas.getContext("2d",{willReadFrequently:!0})}}async drawCanvas(){return new Promise((t,i)=>{this.canvas instanceof HTMLCanvasElement?this.canvas.toBlob(n=>{n.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert canvas blob to ArrayBuffer"))})},"image/png",1):this.canvas.convertToBlob({type:"image/png",quality:1}).then(n=>{n.arrayBuffer().then(a=>{t(a)}).catch(a=>{console.error(JSON.stringify(a)),i(new Error("Failed to convert offscreen blob to ArrayBuffer"))})}).catch(n=>{console.error(JSON.stringify(n)),i(new Error("Failed to convert offscreen canvas to blob"))})})}}class xi extends xt{parse(e){return new Promise((t,i)=>{const{images:n}=e,{width:a,height:c,allowRotate:s,allowTrim:o}=e.option,g=n.length,l=[];for(let f=0;f<g;f++){const u=n[f];let d;const m=u.src;u.image||(m instanceof ArrayBuffer?d=this._loadImageFromBuffer(u):d=this._loadImageFromURL(u),l.push(d))}Promise.all(l).then(f=>{if(!o)for(let u=0,d=f.length;u<d;u++){const m=f[u];if(!(m.width<=a&&m.height<=c||!!s&&m.height<=a&&m.width<=c)){t(B.PackError);return}}t(B.Success)}).catch(f=>{console.error("OptLoadImage:Error",JSON.stringify(f)),i(B.ImageLoadError)})})}_loadImageFromBuffer(e){return new Promise((t,i)=>{const n=e.src,a=new window.Blob([n],{type:e.type}),c=new Image;c.onerror=function(){i(new Error("Failed to load image buffer"))},c.onload=function(){requestAnimationFrame(()=>{c.onload=null,c.onerror=null,c.onabort=null,e.image=c,t(c)})},c.crossOrigin="anonymous",c.src=URL.createObjectURL(a)})}_loadImageFromURL(e){return new Promise((t,i)=>{const n=new Image;n.onerror=function(){i(new Error("Failed to load image buffer"))},n.onload=function(){requestAnimationFrame(()=>{n.onload=null,n.onerror=null,n.onabort=null,e.image=n,t(n)})},n.crossOrigin="anonymous",n.src=e.src})}}const gt=[2048,1024,512,256,128,64,32,16,8,4,2];class vi extends xt{parse(e){const{option:t,images:i}=e,n=t.padding??0,a=!!t.allowRotate,c=t.method??L.BestLongSideFit;let s,o;if(t.square?s=o=Math.min(t.width,t.height):(s=t.width,o=t.height),t.pot){let u=!1,d=!1;for(let m=0,b=gt.length;m<b;++m){const S=gt[m];if(!u&&s>=S&&(s=S,u=!0),!d&&o>=S&&(o=S,d=!0),u&&d)break}}const g=[],l=n*2;for(let u=i.length-1;u>=0;u--){const d=i[u],m=d.image;if(!m)return B.ImageLoadError;const b=t.allowTrim?d.trimRect:void 0,S=b?b.w:m.width,w=b?b.h:m.height;if(!this.checkSizeLegality(S,w,s,o,l,a))return console.log("打包失败,",d.name,"单图尺寸超图集大小"),B.PackError;g.push(new D(0,0,S+l,w+l,d.name))}const f=[];for(;g.length>0;){const u=new di;u.init(s,o,a);const d=u.insert2(g,c);if(d.length===0)return B.PackError;let m=0,b=0;for(let S=0;S<d.length;S++){const w=d[S],P=w.isRotated?w.height:w.width,M=w.isRotated?w.width:w.height,j=w.x+P,$=w.y+M;m=Math.max(m,j),b=Math.max(b,$),n>0&&(w.x+=n,w.y+=n,w.width-=l,w.height-=l)}if(t.square&&(m=b=Math.max(m,b)),t.pot){let S=!1,w=!1;for(let P=gt.length-1;P>=0;--P){const M=gt[P];if(!S&&m<=M&&(m=M,S=!0),!w&&b<=M&&(b=M,w=!0),S&&w)break}}f.push({rects:d,width:m,height:b})}return e.bins=f,B.Success}checkSizeLegality(e,t,i,n,a,c){const s=e+a,o=t+a;return c?s<=i&&o<=n||o<=i&&s<=n:s<=i&&o<=n}}const at=class at extends xt{static _getTrimContext(){let{_trimContext:e}=at;if(!e){let t;try{t=new OffscreenCanvas(1,1)}catch{t=document.createElement("canvas")}const i=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,ctx:i},at._trimContext=e}return e}parse(e){if(!e.option.allowTrim)return B.Success;const{images:t}=e,{canvas:i,ctx:n}=at._getTrimContext();for(let a=0,c=t.length;a<c;a++){const s=t[a],o=s.image;if(!o)continue;const{width:g,height:l}=o;s.sourceWidth=g,s.sourceHeight=l,i.width=g,i.height=l,n.drawImage(o,0,0);const f=n.getImageData(0,0,g,l).data,u=this._getTrimRect(f,g,l);(u.w<g||u.h<l)&&(s.trimRect=u)}return B.Success}_getTrimRect(e,t,i){let n=t,a=0,c=i,s=0;for(let o=0;o<i;o++){const g=o*t*4;for(let l=0;l<t;l++)e[g+l*4+3]>0&&(l<n&&(n=l),l>a&&(a=l),o<c&&(c=o),o>s&&(s=o))}return a<n||s<c?{x:0,y:0,w:1,h:1}:{x:n,y:c,w:a-n+1,h:s-c+1}}};p(at,"_trimContext",null);let Pt=at;const Ut=[new xi,new Pt,new vi,new yi],It={width:1024,height:1024,padding:1,allowRotate:!1,square:!1,pot:!1,method:L.BestLongSideFit};async function ee(r,e){if(r.length===0)return{code:B.NoImage,msg:Jt(B.NoImage)};if(e===void 0)e=It;else{const a=Object.keys(It);for(let c=a.length-1;c>=0;c--){const s=a[c];e[s]===void 0&&(e[s]=It[s])}}const t={};r.sort((a,c)=>c.name.toLowerCase().localeCompare(a.name.toLowerCase()));const i={option:e,images:r,outPut:t};let n=B.Success;for(let a=0;a<Ut.length;a++){const c=await Ut[a].parse(i);if(c!==B.Success){n=c;break}}return t.code=n,t.msg=Jt(n),t}function Jt(r){switch(r){case B.Success:return"打包成功!";case B.NoImage:return"传入图片长度为0.";case B.ImageLoadError:return"图片加载失败.";case B.CanvasBlobError:return"画布 blob 转换失败.";case B.OffscreenBlobError:return"离线画布 blob 转换失败.";case B.PackError:return"图集尺寸限制,打包失败。"}}async function ot(r,e){await r.root.assetFacade.updateAssetProps(r.id,e)}async function bi(r,e){const t=await Promise.all(r.sprites.map(s=>e.getFileById(s.refId)).map(async s=>({...s,mainData:JSON.parse(await s.content.text())}))),[i,n]=Ke(t,s=>!!s.mainData.texture),a=Ge(i,s=>s.mainData.texture.refId);return{packItems:await Promise.all(i.filter(s=>{var g;const o=(g=s.mainData.texture)==null?void 0:g.refId;return o?!!e.getFileById(o):!1}).map(async s=>{const o=s.mainData.texture.refId,l=await(await e.loadFile(o)).arrayBuffer();return{name:o,src:l}})),spriteAssetMap:a,spritesEmpty:n}}async function Ai(r){const e=r.root.assetStore,t=await Promise.all(r.sprites.map(a=>e.getAssetByRef(a))),n=(await Promise.all(t.filter(a=>a&&a.texture).map(a=>e.getAssetByRef(a.texture)))).filter(a=>a).map(a=>({name:a.id,src:a.imageBuffer}));return await ee(n,{padding:r.padding,width:r.maxWidth,height:r.maxHeight})}async function ji(r,e){let t,i=[];const{spriteAssetMap:n,packItems:a,spritesEmpty:c}=await bi(r,e);if(a.length>0?(t=await ee(a,{padding:r.padding,width:r.maxWidth,height:r.maxHeight}),t.code===0?(i=t.info.atlasItems??[],i.forEach(s=>{const{sprites:o}=s;s.sprites=o.flatMap(g=>{const l=n[g.name],{atlasRegion:f,originalSize:u,atlasRotated:d}=g;return l.map(m=>Gt(m,f,u,d))})})):i=[],t.info.atlasItems=i):(t={code:1,msg:pt("sprite.atlas.pack-error.no-sprite")},i=[]),c.length>0){const s=c.map(o=>Gt(o));i.push({img:"",sprites:s})}return t.info&&(t.info.atlasItems=i),t}function Gt(r,e,t=0,i=!1){const n=r.mainData,a=n.region,c=n.pivot,s=n.border,o={name:r.path,atlasRegion:e?{x:e.x,y:e.y,w:e.w,h:e.h}:{x:0,y:0,w:1,h:1},originalSize:t,atlasRotated:i,pivot:{x:c.x,y:c.y},region:{x:a.x,y:a.y,w:a.width,h:a.height},border:{x:s.x,y:s.y,z:s.z,w:s.w},width:n.width,height:n.height};return isNaN(n.width)||(o.width=n.width),isNaN(n.height)||(o.height=n.height),o}function Di(r){const e=[],t=i=>{const n=i.children,a=Object.keys(n);for(let c=a.length-1;c>=0;c--){const s=n[a[c]];s instanceof A?e.push(s):s instanceof We&&t(s)}};return t(r),e}function vt(r,e){const t=e.id,i=r.sprites;for(let n=i.length-1;n>=0;n--)if(i[n].refId===t)return n;return-1}function Li(r,e,t,i,n="#212324",a=15){var S;const{width:c,height:s}=t,{width:o,height:g}=e;let l,f,u,d;i.clearRect(0,0,t.width,t.height),i.fillStyle=n,c/s>o/g?(f=s,l=s/g*o,u=(c-l)/2,d=0,i.fillRect(0,0,u,s),i.fillRect(u+l,0,u,s)):(l=c,f=c/o*g,u=0,d=(s-f)/2,i.fillRect(0,0,c,d),i.fillRect(0,d+f,c,d)),i.drawImage(e,0,0,e.width,e.height,u,d,l,f);const m="Size: "+o+"x"+g+" Usage: "+r+"%";i.font=a+"px Arial";const b=((S=i.measureText(m))==null?void 0:S.width)||a*m.length;i.fillStyle="#000000",i.fillText(m,(c-b)/2,s-a*1/3-2),i.fillStyle="#ffffff",i.fillText(m,(c-b)/2,s-a/2-2)}function zi(r){return r.sprites.length>0}async function Ni(r,e){await ot(r,{texture:e?e.getCurrentRef():null})}async function ie(r,e){const{belongToAtlas:t}=e,i=t==null?void 0:t.refId;if(i&&i!==r.id){const n=await r.root.assetStore.getAssetByRef(t);if(n){const a=n.sprites.filter(c=>c.refId!==e.id);a.length!==n.sprites.length&&await ot(n,{sprites:a})}}if(i!==r.id&&await ot(e,{belongToAtlas:r.getCurrentRef()}),vt(r,e)<0){const n=[...r.sprites,e.getCurrentRef()];await ot(r,{sprites:n})}}async function Kt(r,e){var i;((i=e.belongToAtlas)==null?void 0:i.refId)===r.id&&await ot(e,{belongToAtlas:null});const t=vt(r,e);if(t>=0){const n=r.sprites.filter((a,c)=>c!==t);await ot(r,{sprites:n})}}const Ri=mt(({asset:r,sprite:e})=>{const{assetStore:t}=r.root,i=Object.values(t.assets).filter(n=>n.getMetaConfig().type==="SpriteAtlas");return R.jsx(Qt,{direction:"column",dropLayer:yt.Sprite,assets:i,onSelect:async n=>{await Kt(r,e),await ie(n,e)},onDelete:()=>{Kt(r,e)},onLocate:()=>{r&&r.id&&t.selectAsset(r.id)},asset:r,value:r.name})}),Si=mt(({model:r})=>{const{t:e}=Yt(),{assetStore:t}=r.root;Ii(r);const i=r.belongToAtlas?t.assets[r.belongToAtlas.refId]:null,n=Object.values(t.assets).filter(a=>a.getMetaConfig().type==="SpriteAtlas");return R.jsxs(tt,{fullWidth:!0,css:{padding:"0 $0_5 $1"},children:[R.jsx(ke,{size:"1",css:{marginTop:"$1"},children:e("sprite.atlas.belong-to")}),r.belongToAtlas?R.jsx(Ri,{asset:i,sprite:r},i.id):R.jsx(Qt,{dropLayer:yt.Sprite,assets:n,onSelect:a=>{ie(a,r)},trigger:R.jsx(tt,{align:"h",css:{padding:"$1 $2 $1"},children:R.jsx(Fe,{size:"sm",variant:"solid",css:{padding:"$1 $6"},children:e("sprite.atlas.belong-to")})}),label:"",value:null,asset:null})]})});async function Ii(r){const e=r.root.assetStore,t=r.belongToAtlas,i=t?await e.getAssetByRef(t):null;if(i){vt(i,r)<0&&await r.root.assetFacade.updateAssetProps(i.id,{sprites:[...i.sprites,r.getCurrentRef()]});return}t&&await r.root.assetFacade.updateAssetProps(r.id,{belongToAtlas:null})}var Ci=Object.defineProperty,Pi=Object.getOwnPropertyDescriptor,V=(r,e,t,i)=>{for(var n=i>1?void 0:i?Pi(e,t):e,a=r.length-1,c;a>=0;a--)(c=r[a])&&(n=(i?c(e,t,n):c(n))||n);return i&&n&&Ci(e,t,n),n};const z=new Zt;function ne(r){return r.quickPivot===9}function Xt(r){switch(r){case 0:z.set(.5,.5);break;case 1:z.set(0,1);break;case 2:z.set(.5,1);break;case 3:z.set(1,1);break;case 4:z.set(0,.5);break;case 5:z.set(1,.5);break;case 6:z.set(0,0);break;case 7:{z.set(.5,0);break}case 8:{z.set(1,0);break}}}let A=class extends Me{constructor(e){super(e);p(this,"_delOnTexDel");p(this,"_customWidth");p(this,"_customHeight");p(this,"acceptDragLayer",yt.Texture);p(this,"texture",null);p(this,"width");p(this,"height");p(this,"region",{x:0,y:0,width:1,height:1});p(this,"quickPivot",0);p(this,"pivot",{x:.5,y:.5});p(this,"border",{x:0,y:0,z:0,w:0});p(this,"belongToAtlas",null)}async afterDelete(){this.engineObject.destroy(!0);const{belongToAtlas:e}=this;if(e){const t=await this.root.assetStore.getAssetByRef(e);if(t){const i=vt(t,this);i>-1&&t.sprites.splice(i,1),this.belongToAtlas=null,await this.root.assetFacade.persistAssetMain(t.id)}}this._delOnTexDel&&(this._delOnTexDel(),this._delOnTexDel=null)}getMainData(){const e=this[Nt]??{},t={};return Object.keys(e).forEach(i=>{switch(i){case"width":isNaN(this._customWidth)||(t.width=this._customWidth);break;case"height":isNaN(this._customHeight)||(t.height=this._customHeight);break;default:t[i]=this[i];break}}),JSON.stringify(t)}async initByMain(e){const t=new Ee(this.engine),i=JSON.parse(await e.text());if(isNaN(i.width)||(t.width=this._customWidth=i.width),isNaN(i.height)||(t.height=this._customHeight=i.height),i.texture){const a=await this.root.assetStore.getAssetByRef(i.texture);a&&(await a.ensureReady(),t.texture=a.engineObject)}for(const a in i)this[a]=i[a];this.bindEngineObject(t);const n=new Oe(this.engine);n.addComponent(wt).sprite=t,this.setDragTempEntity(n),await this.applyBoundPathChange("name",O.Input,this.name)}async initByCreation(){const{assetStore:e,assetUIStore:t}=this.root,{pickedAssets:i}=t,n=JSON.parse(this.getMainData());if(i&&i.length===1){const a={refId:i[0]},c=await e.getAssetByRef(a);c instanceof Je?(c.setTextureType(te.Sprite),n.texture=a):c instanceof A&&c.texture&&(n.texture={refId:c.texture.refId})}return n}instantiate(){const e=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:i,rotation:n}=t.transform,a={components:[{class:"SpriteRenderer",id:Ae(),props:{drawMode:0,enabled:!0,flipX:!1,flipY:!1,maskInteraction:0,maskLayer:je.Everything,sprite:this.getCurrentRef()}}],id:e.id,isActive:!0,isClone:!1,name:this.name?"sprite-"+this.name:"sprite",transform:{class:"Transform",props:{position:{x:i.x,y:i.y,z:i.z},rotation:{x:n.x,y:n.y,z:n.z},scale:{x:1,y:1,z:1}}}};return e.initByFile(a),e}initByEngineObject(e){const t=Object.keys(this[Nt]),i=["texture","quickPivot","belongToAtlas"],n=a=>!i.includes(a);t.filter(n).forEach(a=>{const c=e[a];typeof c=="object"?Object.keys(c).forEach(o=>{this[a][o]=c[o]}):this[a]=c}),this.bindEngineObject(e)}async _onDrop(e,t){const i="texture";this.dropping=!1,this.texture=t.getCurrentRef(),this.formSchema.getPropertyConfig(i).onChange(this,i,t),this.updateThumbnail()}};V([Q({info:"sprite.texture.info",label:"sprite.texture.label",type:O.AssetPicker,assetType:"Texture",customFilter:r=>r.isSubAsset===!1,onChange:async(r,e,t)=>{const i=r.engineObject;if(r._delOnTexDel&&(r._delOnTexDel(),r._delOnTexDel=null),await r.applyBoundPathChange("texture",O.AssetPicker,t==null?void 0:t.getCurrentRef()),t){const n=()=>{var a;(a=r._delOnTexDel)==null||a.call(r),r._delOnTexDel=null,r.texture=null,r.applyBoundPathChange("texture",O.AssetPicker,void 0),r.updateThumbnail()};t.on("delete",n),r._delOnTexDel=()=>{t.off("delete",n)}}isNaN(r._customWidth)?r.width=i.width:(r.width=r._customWidth,await r.applyBoundPathChange("width",O.Number,r._customWidth)),isNaN(r._customHeight)?r.height=i.height:(r.height=r._customHeight,await r.applyBoundPathChange("height",O.Number,r._customHeight))}}),Z()],A.prototype,"texture",2);V([Q({label:"sprite.width.label",info:"sprite.width.info",type:O.Number,triggerAfterInit:!1,async onChange(r,e,t){isNaN(t)||(r._customWidth=t,await r.applyBoundPathChange("width",O.Number,t))}}),Z()],A.prototype,"width",2);V([Q({label:"sprite.height.label",info:"sprite.height.info",type:O.Number,triggerAfterInit:!1,async onChange(r,e,t){isNaN(t)||(r._customHeight=t,await r.applyBoundPathChange("height",O.Number,t))}}),Z()],A.prototype,"height",2);V([Q({info:"sprite.region.info",label:"sprite.region.label",type:O.Rect,min:0,max:1,dragStep:.01,onChange(r,e,t){r.applyBoundPathChange("region",O.Rect,t)}}),Z()],A.prototype,"region",2);V([De({setPath:"pivot",getActualEditorValue:r=>(Xt(r),new Zt().copyFrom(z)),getEditorValue:r=>{const{x:e,y:t}=r;return e===.5&&t===.5?0:e===0&&t===1?1:e===.5&&t===1?2:e===1&&t===1?3:e===0&&t===.5?4:e===1&&t===.5?5:e===0&&t===0?6:e===.5&&t===0?7:e===1&&t===0?8:9}}),Q({info:"sprite.quick-pivot.info",label:"sprite.quick-pivot.label",type:O.Select,value:0,options:[{label:"sprite.quick-pivot.center",value:0},{label:"sprite.quick-pivot.top-left",value:1},{label:"sprite.quick-pivot.top",value:2},{label:"sprite.quick-pivot.top-right",value:3},{label:"sprite.quick-pivot.left",value:4},{label:"sprite.quick-pivot.right",value:5},{label:"sprite.quick-pivot.bottom-left",value:6},{label:"sprite.quick-pivot.bottom",value:7},{label:"sprite.quick-pivot.bottom-right",value:8},{label:"sprite.quick-pivot.custom",value:9}],onChange(r,e,t){ne(r)?z.copyFrom(r.pivot):Xt(t),r.pivot.x=z.x,r.pivot.y=z.y,r.applyBoundPathChange("pivot",O.Vector2,z)}}),Z()],A.prototype,"quickPivot",2);V([Q({info:"sprite.pivot.info",label:"sprite.pivot.label",type:O.Vector2,onChange(r,e,t){r.quickPivot===9&&r.applyBoundPathChange("pivot",O.Vector2,t)},when:ne}),Z()],A.prototype,"pivot",2);V([Q({info:"sprite.border.info",label:"sprite.border.label",customComponent:pi,slotMapping:{x:"Left",y:"Down",z:"Right",w:"Up"},onChange(r,e,t){r.applyBoundPathChange("border",O.Vector4,t)}}),Z()],A.prototype,"border",2);V([Q({info:pt("sprite.belong.info"),label:pt("sprite.belong.label"),customComponent:Si}),Z()],A.prototype,"belongToAtlas",2);V([Le()],A.prototype,"getMainData",1);V([ze],A.prototype,"_onDrop",1);A=V([qe({type:"sprite",label:pt("asset.sprite.title"),loaderType:"Sprite",extname:"sprite",importMenuConfig:{type:$t.Upload|$t.Add,tooltip:"支持多选",accept:".png,.jpg,.jpeg,.webp",multiple:!0},viewer:Ye,thumbnail:Ct,defaultName:"Sprite",dragLayer:yt.Sprite,dragType:"2d",preUpload:async(r,e,t,i)=>{const n=r.main.name;if(i)if(i.meta.type==="Texture"){await Ne.assets.update(i.serverId,{file:r.main});return}else throw`Can't overwrite type: ${i.meta.type}, name: ${n}`;const a=await t.root.assetFacade.createAssetByUpload({uploadAssetFile:r,assetType:"Texture"});return a.setTextureType(te.Sprite),new File([JSON.stringify({texture:a.getCurrentRef()})],He(n,Ht(n))+"-spr"+Ht(n))},customInspector:Xe,async bundle({id:r,content:e,path:t},i,n){const a=n.vfs;return{content:new Blob([await Ue(r,await e.text(),t,async c=>{const s=a.getFileById(c);if(!s)return null;const o=s.content??await a.loadFile(s.id);return o?o.text():null})])}}})],A);const Hi=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAsset(){return A}},Symbol.toStringTag,{value:"Module"}));export{A as S,ie as a,ji as b,ee as c,Li as d,Hi as e,Di as g,zi as h,Ai as p,Kt as r,Ni as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var K=Object.defineProperty;var Q=(e,t,s)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var h=(e,t,s)=>(Q(e,typeof t!="symbol"?t+"":t,s),s);import{aH as V,aJ as k,aD as d,aK as C,aI as B,aT as W,aU as J,bz as H,n as R,dF as X,b8 as Y,cz as Z,cw as ee,aL as te,j as L,cb as se,cd as O,an as j,a0 as y,bu as ae,e as F,dG as _,p as w,C as S,m as x,s as re,J as ie}from"./index-0a8702e2.js";import{F as U,a as oe,A as ne}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{u as z,h as le,d as $,r as pe,S as E,a as D,g as ce,p as de,b as ue}from"./SpriteAsset-9a31ec24.js";import{F as ge}from"./FormItemArray-66be8701.js";import{s as N}from"./utilities-e09052e3.js";import{b as fe}from"./TextureAsset-28fedf2a.js";function he(e,t){const s=new Map;for(let r=0;r<e.length;r++){const a=e[r],i=t(a);s.has(i)||s.set(i,a)}return Array.from(s.values())}const me=V("div",{position:"relative",width:"100%",marginBottom:"$2",aspectRatio:"1/1"}),be=V("div",{position:"absolute",width:"100%",height:"100%",padding:"$1",boxSizing:"border-box","& canvas":{width:"100%",height:"100%",border:"1px solid $grayA4",borderRadius:"$3",overflow:"hidden"}}),ve=k.forwardRef(function(t,s){const{buttonContent:r,onClick:a}=t;return d.jsxs(C,{direction:"column",fullWidth:!0,children:[d.jsx(me,{children:d.jsx(be,{children:d.jsx("canvas",{ref:s,width:"400",height:"400"})})}),r&&d.jsx(C,{align:"h",css:{margin:"$0 auto"},children:d.jsx(B,{size:"sm",variant:"solid",css:{padding:"0 $14"},onClick:a,children:r})})]})});function we(e){let t=!1;return e.textureRef?e.assetStore.getAssetByRef(e.textureRef).then(s=>{t||e.setTextureAsset(s??null)}).catch(()=>{t||e.setTextureAsset(null)}):e.setTextureAsset(null),()=>{t=!0}}function xe(e,t){return new Promise((s,r)=>{const a=new window.Blob([e],{type:t}),i=new window.Image,n=URL.createObjectURL(a);let c=!1;const m=()=>{c||(c=!0,URL.revokeObjectURL(n))};i.crossOrigin="anonymous",i.onerror=()=>{m(),r(new Error("Failed to load image buffer"))},i.onload=()=>{requestAnimationFrame(()=>{m(),s(i)})},i.src=n})}const ye=W(({item:e})=>{const[t,s]=k.useState(null),{assetStore:r}=e.root,{t:a}=J(),i=Object.values(r.assets).filter(n=>!n.isSubAsset&&n.getMetaConfig().type==="Texture");return k.useEffect(()=>we({assetStore:r,textureRef:e.texture,setTextureAsset:s}),[r,e.texture]),d.jsxs(d.Fragment,{children:[d.jsx(H,{dropLayer:R.Sprite,assets:i,onSelect:n=>{z(e,n)},onDelete:()=>{z(e,null)},onLocate:()=>{var n;(n=e.texture)!=null&&n.refId&&r.selectAsset(e.texture.refId)},label:a("sprite.texture.label"),value:t&&t.name,asset:t}),d.jsx(X,{label:a("sprite.region.label"),value:{x:e.region.x,y:e.region.y,width:e.region.width,height:e.region.height},onChange:(n,c)=>{e.root.inspectorFacade.assetChange(e.id,"region",{...e.region,[c]:n[c]})},min:0,max:1}),d.jsx(Y,{label:a("sprite.quick-pivot.label"),value:e.quickPivot,options:[{label:a("sprite.quick-pivot.center"),value:0},{label:a("sprite.quick-pivot.top-left"),value:1},{label:a("sprite.quick-pivot.top"),value:2},{label:a("sprite.quick-pivot.top-right"),value:3},{label:a("sprite.quick-pivot.left"),value:4},{label:a("sprite.quick-pivot.right"),value:5},{label:a("sprite.quick-pivot.bottom-left"),value:6},{label:a("sprite.quick-pivot.bottom"),value:7},{label:a("sprite.quick-pivot.bottom-right"),value:8},{label:a("sprite.quick-pivot.custom"),value:9}],onChange:n=>{e.root.inspectorFacade.assetChange(e.id,"quickPivot",n)}}),e.quickPivot===9&&d.jsx(Z,{label:"",value:{x:0,y:0}}),d.jsx(ee,{label:a("sprite.border.label"),value:{x:e.border.x,y:e.border.y,z:e.border.z,w:e.border.w},onChange:(n,c)=>{e.root.inspectorFacade.assetChange(e.id,"border",{...e.border,[c]:n[c]})},min:0,max:1})]})}),Se=W(({model:e,inspectorConfig:t})=>{const{label:s}=t,r=e.sprites,{assetStore:a}=e.root,i=le(e),{t:n}=J();Ie(e);const c=Object.values(a.assets).filter(o=>{switch(o.getMetaConfig().type){case"sprite":return!r.find(l=>l.refId===o.id);case"Folder":return!0}return!1}),m=k.useRef(null);let u,g;k.useLayoutEffect(()=>{u=m.current,g=u==null?void 0:u.getContext("2d"),e.previewImage&&g&&$(e.usage,e.previewImage,u,g)});async function b(){var o;if(i){if(g){const p=await de(e),l=((o=p.info)==null?void 0:o.atlasItems)??[],I=l.reduce((T,P)=>T+P.sprites.reduce((G,q)=>G+q.width*q.height,0),0),A=l.reduce((T,P)=>T+P.width*P.height,0),M=A>0?Number((I/A*100).toFixed(2)):0;p.code===0?xe(p.imageFiles[0],"image/png").then(T=>{e.replacePreview(T),$(M,T,u,g)}):N({title:n("sprite.atlas.pack-error.title"),description:p.msg})}}else N({title:n("sprite.atlas.pack-error.title"),description:n("sprite.atlas.pack-error.no-sprite")})}return d.jsxs(d.Fragment,{children:[d.jsx(ge,{label:s,items:r.map((o,p)=>{const l=a.assets[o.refId];return{removable:!0,children:d.jsx(ye,{item:l}),id:`${p}`,name:l.getRouteString()}}),onDelete:async o=>{const p=await a.getAssetByRef(r[o.id]);await pe(e,p)}}),d.jsxs(C,{align:"both",direction:"column",children:[d.jsx(H,{assets:c,dropLayer:R.Sprite|R.Folder,customFilter:o=>o instanceof E||o instanceof U,onSelect:o=>{if(o instanceof E)D(e,o);else if(o instanceof U){const p=ce(o);for(let l=p.length-1;l>=0;l--)D(e,p[l])}},trigger:d.jsx(B,{size:"sm",variant:"solid",css:{flex:1},startSlot:d.jsx(te,{}),children:n("sprite.atlas.add-object.label")}),label:n("sprite.atlas.add-sprite"),value:null,asset:null}),d.jsx(B,{size:"sm",variant:"solid",positive:!0,fullWidth:!0,css:{margin:"$1"},onClick:b,children:n("sprite.atlas.pack-preview.label")})]}),i&&d.jsx(ve,{ref:m})]})});async function Ie(e){var a;const t=e.root.assetStore.assets,s=e.sprites,r=[];for(let i=0;i<s.length;i++){const n=s[i],c=t[n.refId];c&&(r.push(n),((a=c.belongToAtlas)==null?void 0:a.refId)!==e.id&&await D(e,c))}r.length!==s.length&&await e.root.assetFacade.updateAssetProps(e.id,{sprites:r})}function Ae(e,t,s,r={}){return{id:e,type:t,version:s.engineVersion??"",extraData:{},dependencies:[],...r}}var Te=Object.defineProperty,je=Object.getOwnPropertyDescriptor,v=(e,t,s,r)=>{for(var a=r>1?void 0:r?je(t,s):t,i=e.length-1,n;i>=0;i--)(n=e[i])&&(a=(r?n(t,s,a):n(a))||a);return r&&a&&Te(t,s,a),a};let f=class extends L{constructor(t){super(t);h(this,"acceptDragLayer",R.Sprite);h(this,"previewTexture2D");h(this,"previewImage");h(this,"usage",0);h(this,"maxWidth",1024);h(this,"maxHeight",1024);h(this,"padding",2);h(this,"allowRotation",!1);h(this,"tightPacking",!1);h(this,"mipmap",!1);h(this,"filterMode",j.Bilinear);h(this,"wrapModeU",y.Repeat);h(this,"wrapModeV",y.Repeat);h(this,"anisoLevel",1);h(this,"sprites",[]);this.setNameByIncrease("SpriteAtlas");const s=this.formSchema;s.addGroup(F("sprite.atlas.packing"),["maxWidth","maxHeight","padding","allowRotation","tightPacking"]),s.addGroup(F("sprite.atlas.export"),["filterMode","wrapModeU","wrapModeV","anisoLevel","mipmap"]),s.addGroup(F("sprite.atlas.list"),["sprites"])}static async updateSubTextureAssets(t,s,r,a,i){var p;const n=t.meta,c=i.vfs,m=t.dependencies||(t.dependencies=[]),u=((p=m[s])==null?void 0:p.ref.refId)??se(),g=O(t.name).split(".")[0];m[s]||(m[s]={key:"atlasItems["+s+"].img",ref:{refId:u}});let b=c.getFileById(u),o;return b?o=b.meta:(o=Ae(u,L.getRegisteredAssetMeta(fe).type,a),i.addFile({name:g+"_image_"+s,assetId:u,url:null,parentId:t.parentId,main:null,meta:o}),b=c.getFileById(u),b.ignoreBundle=!0),o.colorDilate=n.colorDilate??!1,o.filterMode=n.filterMode??j.Bilinear,o.wrapModeU=n.wrapModeU??y.Repeat,o.wrapModeV=n.wrapModeV??y.Repeat,o.anisoLevel=n.anisoLevel??1,o.runtimeOptions=n.runtimeOptions??{},i.updateFile(u,{main:new Blob([r],{type:"image/png"}),meta:o}),await i.bundleSingleFile(b,a),b}replacePreview(t){this.previewImage=t;const s=this.previewTexture2D;this.previewTexture2D=new ae(this.engineObject.engine,t.width,t.height),this.previewTexture2D.setImageSource(t),s&&s.destroy(!0)}async afterDelete(){this.engineObject.destroy(!0);const{sprites:t,id:s}=this,r=this.root.assetStore,i=[...t].map(async n=>{var c;try{const u=await r.getAssetByRef(n);((c=u==null?void 0:u.belongToAtlas)==null?void 0:c.refId)===s&&await this.root.assetFacade.updateAssetProps(u.id,{belongToAtlas:null})}catch(m){console.warn(`[SpriteAtlasAsset] Failed to cleanup sprite relation: ${(n==null?void 0:n.refId)??"unknown"}`,m)}});await Promise.allSettled(i),t.length=0}addSprites(t){const s=he([...this.sprites,...t.map(a=>({refId:a.id}))],a=>a.refId),r=t.map(a=>this.root.assetFacade.updateAssetProps(a.id,{belongToAtlas:{refId:this.id}}));return r.push(this.root.assetFacade.updateAssetProps(this.id,{sprites:s})),Promise.all(r)}async initByMain(t){const{engine:s}=this,r=JSON.parse(await t.text());for(const i in r)this[i]=r[i];const a=new _(s);this.bindEngineObject(a),a.asset=this}async initByCreation(){this.setNameByIncrease("SpriteAtlas");const t=new _(this.engine);return this.bindEngineObject(t),t.asset=this,this.getMainData()}async _onDrop(t,s){this.dropping=!1,!this.sprites.find(r=>r.refId===s.id)&&await this.addSprites([s])}};v([w({info:"sprite.atlas.max-width.info",label:"sprite.atlas.max-width.label",type:S.Input}),x()],f.prototype,"maxWidth",2);v([w({info:"sprite.atlas.max-height.info",label:"sprite.atlas.max-height.label",type:S.Input}),x()],f.prototype,"maxHeight",2);v([w({info:"sprite.atlas.padding.info",label:"sprite.atlas.padding.label",type:S.Number,min:0,max:5,dragStep:1}),x()],f.prototype,"padding",2);v([w({info:"sprite.atlas.rotation.info",label:"sprite.atlas.rotation.label",type:S.Toggle}),x()],f.prototype,"allowRotation",2);v([w({info:"sprite.atlas.tight-packing.info",label:"sprite.atlas.tight-packing.label",type:S.Toggle}),x()],f.prototype,"tightPacking",2);v([w({label:"sprite.atlas.mipmap.label",type:S.Toggle}),x()],f.prototype,"mipmap",2);v([w({label:"sprite.atlas.filter-mode.label",type:S.Select,value:j.Bilinear,options:[{label:"sprite.atlas.filter-mode.point",value:j.Point},{label:"sprite.atlas.filter-mode.bilinear",value:j.Bilinear},{label:"sprite.atlas.filter-mode.trilinear",value:j.Trilinear}]}),x()],f.prototype,"filterMode",2);v([w({label:"sprite.atlas.wrap-mode-u.label",type:S.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:y.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:y.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:y.Mirror}]}),x()],f.prototype,"wrapModeU",2);v([w({label:"sprite.atlas.wrap-mode-v.label",type:S.Select,options:[{label:"sprite.atlas.wrap-mode.clamp",value:y.Clamp},{label:"sprite.atlas.wrap-mode.repeat",value:y.Repeat},{label:"sprite.atlas.wrap-mode.mirror",value:y.Mirror}]}),x()],f.prototype,"wrapModeV",2);v([w({label:"sprite.atlas.aniso-level.label",type:S.Slider,dragStep:1,max:16,min:1}),x()],f.prototype,"anisoLevel",2);v([re({type:"methods",key:"addSprite"}),w({label:F("sprite.atlas.sprite-list.label"),customComponent:Se}),x()],f.prototype,"sprites",2);v([ie],f.prototype,"addSprites",1);f=v([oe({type:"SpriteAtlas",label:F("asset.sprite-atlas.title"),loaderType:"SpriteAtlas",extname:"atlas",importMenuConfig:{type:ne.Add},async bundle(e,t,s){var m;const r=s.vfs,a=e.content??await r.loadFile(e.id),i=JSON.parse(await a.text()),n=e.meta,c=e.dependencies||(e.dependencies=[]);if(n.ignorePack){const u=i.atlasItems;for(let g=0,b=u.length;g<b;g++){const o=i.atlasItems[g],p=await fetch(o.img).then(I=>I.arrayBuffer()),l=await f.updateSubTextureAssets(e,g,p,t,s);o.type=l.exportType,o.img="./"+O(l.path)}}else{const u=e.id,g=i.sprites;for(let o=g.length-1;o>=0;o--){const p=g[o].refId,l=r.getFileById(p);if(l){const I=l.content??await r.loadFile(l.id);((m=JSON.parse(await I.text()).belongToAtlas)==null?void 0:m.refId)!==u&&(g.splice(o,1),console.warn("Sprite.belongToAtlas is not equal to this asset."))}else g.splice(o,1),console.warn("SpriteAsset[refId:",p,"] not found")}const b=await ue(i,r);if(b.code===0){const o=b.info;for(const l in o)i[l]=o[l];const p=b.imageFiles;for(let l=0,I=p.length;l<I;l++){const A=await f.updateSubTextureAssets(e,l,p[l],t,s),M=i.atlasItems[l];M.type=A.exportType,M.img="./"+O(A.path)}}else{for(let o=0,p=c.length;o<p;o++){const l=c[o].ref.refId;r.deleteFile(l)}c.length=0}}return delete i.usage,delete i.allowRotation,delete i.maxHeight,delete i.maxWidth,delete i.padding,delete i.sprites,delete i.tightPacking,{content:new Blob([JSON.stringify(i)])}}})],f);const De=Object.freeze(Object.defineProperty({__proto__:null,get SpriteAtlasAsset(){return f}},Symbol.toStringTag,{value:"Module"}));export{f as S,De as a,Ae as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var y=(e,r,p)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):e[r]=p;var s=(e,r,p)=>(y(e,typeof r!="symbol"?r+"":r,p),p);import{p as d,C as a,s as m,aS as o,E as w}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";var C=Object.defineProperty,P=Object.getOwnPropertyDescriptor,c=(e,r,p,i)=>{for(var t=i>1?void 0:i?P(r,p):r,l=e.length-1,n;l>=0;l--)(n=e[l])&&(t=(i?n(r,p,t):n(t))||t);return i&&t&&C(r,p,t),t};class b extends w{constructor(){super(...arguments);s(this,"sprite",null);s(this,"color",{r:1,g:1,b:1,a:1});s(this,"drawMode",o.Simple)}}c([d({label:"sprite.renderer.sprite.label",info:"sprite.renderer.sprite.info",type:a.AssetPicker,assetType:"sprite",onChange:async(e,r,p)=>{e.sprite=p?p.getCurrentRef():null,await e.applyBoundPathChange("sprite",a.AssetPicker,e.sprite),e.emit("propertychange","sprite",p)}}),m()],b.prototype,"sprite",2);c([d({bindPath:"color",label:"sprite.renderer.color.label",info:"sprite.renderer.color.info",type:a.Color}),m()],b.prototype,"color",2);c([d({label:"sprite.renderer.draw-mode.label",info:"sprite.renderer.draw-mode.info",type:a.Select,bindPath:"drawMode",value:o.Simple,options:[{label:"sprite.renderer.draw-mode.simple",value:o.Simple},{label:"sprite.renderer.draw-mode.sliced",value:o.Sliced},{label:"sprite.renderer.draw-mode.tiled",value:o.Tiled}]}),m()],b.prototype,"drawMode",2);export{b as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var b=(r,e,t)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>(b(r,typeof e!="symbol"?e+"":e,t),t);import{E as h,aP as f,p as m,C as y,s as c,l as P,g as v}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as C}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var g=Object.defineProperty,S=Object.getOwnPropertyDescriptor,o=(r,e,t,i)=>{for(var p=i>1?void 0:i?S(e,t):e,l=r.length-1,n;l>=0;l--)(n=r[l])&&(p=(i?n(e,t,p):n(p))||p);return i&&p&&g(e,t,p),p};let a=class extends h{constructor(e,t){super(e,t);s(this,"sprite",null);s(this,"alphaCutoff",.5);s(this,"influenceLayers",[f.Everything])}};o([m({label:"sprite.mask.sprite.label",info:"sprite.mask.sprite.info",type:y.AssetPicker,assetType:"sprite",bindPath:"sprite"}),c()],a.prototype,"sprite",2);o([m({label:"sprite.mask.alpha-cutoff.label",info:"sprite.mask.alpha-cutoff.info",dragStep:.01,min:0,max:1,type:y.Slider,bindPath:"alphaCutoff"}),c()],a.prototype,"alphaCutoff",2);o([c(P()),m({label:"sprite.mask.influence-layers.label",info:"sprite.mask.influence-layers.info",type:y.Select,...v([f.Nothing,f.Everything]),bindPath:"influenceLayers"})],a.prototype,"influenceLayers",2);a=o([C({type:"SpriteMask",componentsMenu:{group:"2D",label:"component.sprite-mask.title"}})],a);export{a as SpriteMaskComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var x=Object.defineProperty;var M=(i,t,e)=>t in i?x(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>(M(i,typeof t!="symbol"?t+"":t,e),e);import{aH as _,aK as C,aT as S,aU as w,aD as l,b7 as P,aJ as g,aY as y,aV as v,aQ as u,aP as m,C as o,p as c,s as h,l as O,g as I,f as j}from"./index-0a8702e2.js";import{u as R}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as H}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{c as b}from"./createOnModelChange-b57a0da8.js";import{S as k}from"./SpriteBaseComponent-f6f1731f.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";const B=_("div",{marginLeft:"5px"}),Y=_(C,{border:"1px solid $gray6",borderRadius:"$2",padding:"$0_5",color:"$gray11",cursor:"pointer"}),z=S(function(i){const t=i.data,{t:e}=w();return l.jsxs(Y,{align:"v",children:[t.loadingStatus==="loading"&&l.jsx(P,{size:"xs"}),t.loadingStatus==="success"&&l.jsx("img",{src:t.thumbnailUrl,alt:e("sprite.inspector.thumbnail"),width:"20px",height:"20px"}),l.jsxs(B,{children:[e("sprite.inspector.title"),"(",t.name,")"]})]})}),X=S(function(i){const[t,e]=g.useState(null),r=i.data,{assetStore:s,inspectorFacade:n}=R();return g.useEffect(()=>{s.getAssetByRef(r.sprite).then(f=>{e(f)})},[r.sprite]),l.jsxs(l.Fragment,{children:[l.jsx(y.List,{model:r,configs:r.formSchema.items,onModelChange:b("component",r.id,n,r)}),t?l.jsx(v,{nesting:!0,title:l.jsx(z,{data:t}),defaultOpen:!1,children:l.jsx(y.List,{model:t,configs:t.formSchema.items,onModelChange:b("asset",t.id,n,t)})}):null]})});var N=Object.defineProperty,E=Object.getOwnPropertyDescriptor,L=(i,t,e)=>t in i?N(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,d=(i,t,e,r)=>{for(var s=r>1?void 0:r?E(t,e):t,n=i.length-1,f;n>=0;n--)(f=i[n])&&(s=(r?f(t,e,s):f(s))||s);return r&&s&&N(t,e,s),s},T=(i,t,e)=>(L(i,typeof t!="symbol"?t+"":t,e),e);let a=class extends k{constructor(t,e){super(t,e);p(this,"width",0);p(this,"height",0);p(this,"flip",[]);p(this,"maskInteraction",u.None);p(this,"maskLayer",[m.Everything]);p(this,"material",{refId:a._internalSpriteMaterialRefId});p(this,"priority",0);p(this,"_customWidth");p(this,"_customHeight");this.on("propertychange",(r,s)=>{if(r==="sprite"){const n=this.engineObject;isNaN(this._customWidth)?this.width=n.width:(this.width=this._customWidth,this.applyBoundPathChange("width",o.Number,this._customWidth)),isNaN(this._customHeight)?this.height=n.height:(this.height=this._customHeight,this.applyBoundPathChange("height",o.Number,this._customHeight))}})}async applyBoundPathChange(t,e,r){if(t==="flip"){const s=Array.isArray(r)?r:[];await super.applyBoundPathChange("flipX",o.Toggle,s.includes("flipX")),await super.applyBoundPathChange("flipY",o.Toggle,s.includes("flipY"));return}await super.applyBoundPathChange(t,e,r)}deserializeByEngineObject(t){var r;super.deserializeByEngineObject(t);const e=[];t.flipX&&e.push("flipX"),t.flipY&&e.push("flipY"),this.flip=e,(r=this._originValueMap)==null||r.set("flip",[...e])}deserialize(t){super.deserialize(t);const{props:e}=t;e!=null&&e.flipX&&this.flip.push("flipX"),e!=null&&e.flipY&&this.flip.push("flipY"),isNaN(e==null?void 0:e.width)||(this._customWidth=e.width),isNaN(e==null?void 0:e.height)||(this._customHeight=e.height)}toJSON(){const t=super.toJSON(),e=this.flip;return e&&(t.props.flipX=e.indexOf("flipX")!==-1,t.props.flipY=e.indexOf("flipY")!==-1),isNaN(this._customWidth)||(t.props.width=this._customWidth),isNaN(this._customHeight)||(t.props.height=this._customHeight),t}};T(a,"_internalSpriteMaterialRefId","0000203");d([c({label:"sprite.renderer.width.label",info:"sprite.renderer.width.info",type:o.Number,bindPath:"width",triggerAfterInit:!1,onChange(i,t,e){isNaN(e)||(i._customWidth=e)}}),h()],a.prototype,"width",2);d([c({label:"sprite.renderer.height.label",info:"sprite.renderer.height.info",type:o.Number,bindPath:"height",triggerAfterInit:!1,onChange(i,t,e){isNaN(e)||(i._customHeight=e)}}),h()],a.prototype,"height",2);d([c({label:"sprite.renderer.flip.label",info:"sprite.renderer.flip.info",type:o.ToggleGroup,bindPath:"flip",multiple:!0,options:[{label:"sprite.renderer.flip.x",value:"flipX"},{label:"sprite.renderer.flip.y",value:"flipY"}]}),h()],a.prototype,"flip",2);d([c({label:"sprite.renderer.mask-interaction.label",info:"sprite.renderer.mask-interaction.info",type:o.Select,bindPath:"maskInteraction",value:u.None,options:[{label:"sprite.renderer.mask-interaction.none",value:u.None},{label:"sprite.renderer.mask-interaction.visible-inside",value:u.VisibleInsideMask},{label:"sprite.renderer.mask-interaction.visible-outside",value:u.VisibleOutsideMask}]}),h()],a.prototype,"maskInteraction",2);d([h(O()),c({label:"sprite.renderer.mask-layer.label",info:"sprite.renderer.mask-layer.info",type:o.Select,...I([m.Nothing,m.Everything]),bindPath:"maskLayer"}),h()],a.prototype,"maskLayer",2);d([c({label:"sprite.renderer.material.label",info:"sprite.renderer.material.info",type:o.AssetPicker,assetType:"Material",customFilter:i=>{var t;return((t=i.engineObject.shader)==null?void 0:t.name)!=="particle-shader"},onChange:async(i,t,e)=>{const{material:r}=i,s=i.engineObject;if(!r){s.setMaterial(null);return}const{refId:n}=r;n===a._internalSpriteMaterialRefId?s.setMaterial(s.engine._basicResources.spriteDefaultMaterial):e?i.engineObject.setMaterial(e.engineObject):console.error(`Material asset not found: ${r.refId}`)}}),j({engineKey:"setMaterial",getEngineValue:i=>i.getMaterial()}),h({type:"methods",key:"setMaterial",onSerialize:i=>i?[[i]]:void 0,onDeserialize(i){return i?i[0][0]:void 0}})],a.prototype,"material",2);d([c({label:"sprite.renderer.priority.label",info:"sprite.renderer.priority.info",type:o.Number,bindPath:"priority"}),h()],a.prototype,"priority",2);a=d([H({type:"SpriteRenderer",componentsMenu:{group:"2D",label:"component.renderer.sprite.title"},customInspector:X})],a);export{a as SpriteRendererComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var h=(n,s,e)=>s in n?a(n,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[s]=e;var t=(n,s,e)=>(h(n,typeof s!="symbol"?s+"":s,e),e);class f{constructor(){t(this,"queue",[]);t(this,"isRunning",!1)}enqueue(s){return new Promise((e,i)=>{const r=async()=>{try{const u=await s();e(u)}catch(u){i(u)}};this.queue.push(r),this.run()})}async run(){if(this.isRunning||this.queue.length===0)return;this.isRunning=!0;const s=this.queue.shift();s&&await s(),this.isRunning=!1,this.run()}}export{f as T};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var u=Object.defineProperty;var w=(e,o,t)=>o in e?u(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var l=(e,o,t)=>(w(e,typeof o!="symbol"?o+"":o,t),t);import{aC as v,cL as T,aD as n,cM as g,p as s,C as i,s as c,cN as a,f as y,w as b,cO as m,cP as d,e as C,E as A}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";/**
|
|
2
|
+
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/var B=v("outline","bold","IconBold",[["path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7h-6z",key:"svg-0"}],["path",{d:"M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7",key:"svg-1"}]]);/**
|
|
7
|
+
* @license @tabler/icons-react v3.24.0 - MIT
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/var j=v("outline","italic","IconItalic",[["path",{d:"M11 5l6 0",key:"svg-0"}],["path",{d:"M7 19l6 0",key:"svg-1"}],["path",{d:"M14 5l-4 14",key:"svg-2"}]]);const z=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M11 21v-4H7.5q-.625 0-1.062-.437T6 15.5q0-.625.438-1.062T7.5 14H11v-4H4.5q-.625 0-1.062-.437T3 8.5q0-.625.438-1.062T4.5 7H11V3q0-.425.288-.712T12 2q.425 0 .713.288T13 3v4h6.5q.625 0 1.063.438T21 8.5q0 .625-.437 1.063T19.5 10H13v4h3.5q.625 0 1.063.438T18 15.5q0 .625-.437 1.063T16.5 17H13v4q0 .425-.288.713T12 22q-.425 0-.712-.288T11 21"})}),S=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M3 22q-.425 0-.712-.288T2 21V3q0-.425.288-.712T3 2q.425 0 .713.288T4 3v18q0 .425-.288.713T3 22m4.5-5q-.625 0-1.062-.437T6 15.5q0-.625.438-1.062T7.5 14h7q.625 0 1.063.438T16 15.5q0 .625-.437 1.063T14.5 17zm0-7q-.625 0-1.062-.437T6 8.5q0-.625.438-1.062T7.5 7h13q.625 0 1.063.438T22 8.5q0 .625-.437 1.063T20.5 10z"})}),I=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M21 22q-.425 0-.712-.288T20 21V3q0-.425.288-.712T21 2q.425 0 .713.288T22 3v18q0 .425-.288.713T21 22M9.5 17q-.625 0-1.062-.437T8 15.5q0-.625.438-1.062T9.5 14h7q.625 0 1.063.438T18 15.5q0 .625-.437 1.063T16.5 17zm-6-7q-.625 0-1.062-.437T2 8.5q0-.625.438-1.062T3.5 7h13q.625 0 1.063.438T18 8.5q0 .625-.437 1.063T16.5 10z"})}),P=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M3 22q-.425 0-.712-.288T2 21q0-.425.288-.712T3 20h18q.425 0 .713.288T22 21q0 .425-.288.713T21 22zm5.5-4q-.625 0-1.062-.437T7 16.5v-13q0-.625.438-1.062T8.5 2q.625 0 1.063.438T10 3.5v13q0 .625-.437 1.063T8.5 18m7 0q-.625 0-1.062-.437T14 16.5v-7q0-.625.438-1.062T15.5 8q.625 0 1.063.438T17 9.5v7q0 .625-.437 1.063T15.5 18"})}),M=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M8.5 21q-.625 0-1.062-.437T7 19.5V13H3q-.425 0-.712-.288T2 12q0-.425.288-.712T3 11h4V4.5q0-.625.438-1.062T8.5 3q.625 0 1.063.438T10 4.5V11h4V7.5q0-.625.438-1.062T15.5 6q.625 0 1.063.438T17 7.5V11h4q.425 0 .713.288T22 12q0 .425-.288.713T21 13h-4v3.5q0 .625-.437 1.063T15.5 18q-.625 0-1.062-.437T14 16.5V13h-4v6.5q0 .625-.437 1.063T8.5 21"})}),O=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M8.5 22q-.625 0-1.062-.437T7 20.5v-13q0-.625.438-1.062T8.5 6q.625 0 1.063.438T10 7.5v13q0 .625-.437 1.063T8.5 22m7-6q-.625 0-1.062-.437T14 14.5v-7q0-.625.438-1.062T15.5 6q.625 0 1.063.438T17 7.5v7q0 .625-.437 1.063T15.5 16M3 4q-.425 0-.712-.288T2 3q0-.425.288-.712T3 2h18q.425 0 .713.288T22 3q0 .425-.288.713T21 4z"})}),F={[T.Top]:n.jsx(O,{}),[T.Center]:n.jsx(M,{}),[T.Bottom]:n.jsx(P,{})},_={[g.Left]:n.jsx(S,{}),[T.Center]:n.jsx(z,{}),[T.Bottom]:n.jsx(I,{})},V=n.jsx(B,{}),H=n.jsx(j,{});var N=Object.defineProperty,D=Object.getOwnPropertyDescriptor,f=(e,o,t,r)=>{for(var h=r>1?void 0:r?D(o,t):o,x=e.length-1,q;x>=0;x--)(q=e[x])&&(h=(r?q(o,t,h):q(h))||h);return r&&h&&N(o,t,h),h};class p extends A{constructor(){super(...arguments);l(this,"_curFontAsset",null);l(this,"_curDeleteFontCB",null);l(this,"text","");l(this,"color",{r:1,g:1,b:1,a:1});l(this,"fontSize",24);l(this,"font",null);l(this,"lineSpacing",0);l(this,"fontStyleArr",[]);l(this,"horizontalAlignment",g.Center);l(this,"verticalAlignment",T.Center);l(this,"enableWrapping",!1);l(this,"overflowMode",d.Overflow)}onInitComplete(){}deserialize(t){super.deserialize(t)}toJSON(){const t=super.toJSON(),r=this.fontStyleArr;return r&&(t.props.fontStyle=a.None,r.indexOf("bold")!==-1&&(t.props.fontStyle|=a.Bold),r.indexOf("italic")!==-1&&(t.props.fontStyle|=a.Italic)),t}}l(p,"_defaultFontRefId","0000900");f([s({label:"text-renderer.text.label",info:"text-renderer.text.info",type:i.Textarea,bindPath:"text"}),c()],p.prototype,"text",2);f([s({label:"text-renderer.color.label",info:"text-renderer.color.info",type:i.Color,bindPath:"color"}),c()],p.prototype,"color",2);f([s({label:"text-renderer.font-size.label",info:"text-renderer.font-size.info",type:i.Number,bindPath:"fontSize"}),c()],p.prototype,"fontSize",2);f([s({label:"text-renderer.font.label",info:"text-renderer.font.info",type:i.AssetPicker,assetType:"Font",onChange:async(e,o,t)=>{if(t&&t!==e._curFontAsset){await e.applyBoundPathChange("font",i.AssetPicker,t.getCurrentRef()),e._curDeleteFontCB&&e._curDeleteFontCB();const r=()=>{e.font=void 0,e.applyBoundPathChange("font",i.AssetPicker,void 0)};t.on("delete",r),e._curDeleteFontCB=()=>{t.off("delete",r)},e._curFontAsset=t}else e.font=void 0,await e.applyBoundPathChange("font",i.AssetPicker,void 0),e._curFontAsset=null,e._curDeleteFontCB&&e._curDeleteFontCB(),e._curDeleteFontCB=null}}),c()],p.prototype,"font",2);f([s({label:"text-renderer.line-spacing.label",info:"text-renderer.line-spacing.info",type:i.Number,bindPath:"lineSpacing"}),c()],p.prototype,"lineSpacing",2);f([s({label:"text-renderer.font-style.label",info:"text-renderer.font-style.info",type:i.ToggleGroup,multiple:!0,options:[{label:V,value:"bold"},{label:H,value:"italic"}],onChange(e,o,t){let r=a.None;t.indexOf("bold")!==-1&&(r|=a.Bold),t.indexOf("italic")!==-1&&(r|=a.Italic),e.applyBoundPathChange("fontStyle",i.Number,r)}}),y({valueType:b.Float,interpolationType:m.Step,getActualEditorValue:e=>{let o=a.None;return e.indexOf("bold")!==-1&&(o|=a.Bold),e.indexOf("italic")!==-1&&(o|=a.Italic),o},getEditorValue:e=>{const o=[];return e&a.Bold&&o.push("bold"),e&a.Italic&&o.push("italic"),o}}),c()],p.prototype,"fontStyleArr",2);f([y({valueType:b.Float,interpolationType:m.Step}),s({label:"text-renderer.horizontal-alignment.label",info:"text-renderer.horizontal-alignment.info",type:i.SegmentControl,bindPath:"horizontalAlignment",value:g.Center,options:Object.values(g).filter(e=>typeof e=="number").map(e=>({label:_[e],value:e}))}),c()],p.prototype,"horizontalAlignment",2);f([s({label:"text-renderer.vertical-alignment.label",info:"text-renderer.vertical-alignment.info",type:i.SegmentControl,bindPath:"verticalAlignment",value:T.Center,options:Object.values(T).filter(e=>typeof e=="number").map(e=>({label:F[e],value:e}))}),c()],p.prototype,"verticalAlignment",2);f([s({label:"text-renderer.enable-wrapping.label",info:"text-renderer.enable-wrapping.info",type:i.Toggle,bindPath:"enableWrapping"}),c()],p.prototype,"enableWrapping",2);f([s({label:"text-renderer.overflow-mode.label",info:"text-renderer.overflow-mode.info",type:i.Select,bindPath:"overflowMode",value:d.Overflow,options:Object.keys(d).filter(e=>isNaN(Number(e))).map(e=>({label:C(`text-renderer.overflow-mode.${e.toLocaleLowerCase()}`),value:d[e]}))}),c()],p.prototype,"overflowMode",2);export{p as T};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var x=(r,e,t)=>e in r?c(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>(x(r,typeof e!="symbol"?e+"":e,t),t);import{aQ as p,aP as h,p as l,C as s,s as m,g as f,l as u}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as v}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{T as k}from"./TextBaseComponent-69233798.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var g=Object.defineProperty,P=Object.getOwnPropertyDescriptor,a=(r,e,t,d)=>{for(var i=d>1?void 0:d?P(e,t):e,b=r.length-1,y;b>=0;b--)(y=r[b])&&(i=(d?y(e,t,i):y(i))||i);return d&&i&&g(e,t,i),i};let n=class extends k{constructor(e,t){super(e,t);o(this,"width",0);o(this,"height",0);o(this,"maskInteraction",p.None);o(this,"maskLayer",[h.Layer0]);o(this,"priority",0)}};a([l({label:"text-renderer.width.label",info:"text-renderer.width.info",type:s.Number,bindPath:"width"}),m()],n.prototype,"width",2);a([l({label:"text-renderer.height.label",info:"text-renderer.height.info",type:s.Number,bindPath:"height"}),m()],n.prototype,"height",2);a([l({label:"text-renderer.mask-interaction.label",info:"text-renderer.mask-interaction.info",type:s.Select,bindPath:"maskInteraction",value:p.None,options:[{label:"text-renderer.mask-interaction.none",value:p.None},{label:"text-renderer.mask-interaction.visible-inside",value:p.VisibleInsideMask},{label:"text-renderer.mask-interaction.visible-outside",value:p.VisibleOutsideMask}]}),m()],n.prototype,"maskInteraction",2);a([l({label:"text-renderer.mask-layer.label",info:"text-renderer.mask-layer.info",type:s.Select,bindPath:"maskLayer",...f([h.Nothing,h.Everything])}),m(u())],n.prototype,"maskLayer",2);a([l({label:"text-renderer.priority.label",info:"text-renderer.priority.info",type:s.Number,bindPath:"priority"}),m()],n.prototype,"priority",2);n=a([v({type:"TextRenderer",componentsMenu:{group:"2D",label:"component.text-renderer.title"}})],n);export{n as TextRendererComponent};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var be=Object.defineProperty;var ye=(n,e,t)=>e in n?be(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var v=(n,e,t)=>(ye(n,typeof e!="symbol"?e+"":e,t),t);import{aC as ge,e6 as we,ao as $,bo as Y,$ as J,a9 as Z,O as Q,b$ as ee,ap as te,aT as q,aU as xe,aD as w,b8 as ne,aK as z,aG as G,by as ve,cH as Me,aV as Ce,e as P,cF as Se,aJ as _e,aY as Re,_ as Te,j as Be,an as U,a0 as C,p as D,C as j,b0 as T,u as Oe,x as Ae,n as De,bu as X,bv as ae,eq as je,er as ie,es as Ee}from"./index-0a8702e2.js";import{H as re}from"./enum-58295f88.js";import{u as Ue,a as Ie,A as Pe}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{e as se}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{T as Le}from"./Tooltip-33f770ba.js";import{A as Fe}from"./AssetViewer-bc198e16.js";import{k as H}from"./ktx2-encoder-1e63c1eb.js";/**
|
|
2
|
+
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/var Ve=ge("filled","help-circle-filled","IconHelpCircleFilled",[["path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm0 13a1 1 0 0 0 -.993 .883l-.007 .117l.007 .127a1 1 0 0 0 1.986 0l.007 -.117l-.007 -.127a1 1 0 0 0 -.993 -.883zm1.368 -6.673a2.98 2.98 0 0 0 -3.631 .728a1 1 0 0 0 1.44 1.383l.171 -.18a.98 .98 0 0 1 1.11 -.15a1 1 0 0 1 -.34 1.886l-.232 .012a1 1 0 0 0 .111 1.994a3 3 0 0 0 1.371 -5.673z",key:"svg-0"}]]);const K=function(n,e,t){return n>=t?t:n<=e?e:n};function oe(n,e,t,i,a){const r=new Uint8Array(n);i=K(i,0,255),a=K(a,0,255);const s=(d,p)=>(p*e+d)*4,o=[[-1,0],[1,0],[0,-1],[0,1]],l=[];for(let d=0;d<t;d++)for(let p=0;p<e;p++)if(r[s(p,d)+3]!==0)for(const[y,b]of o){const h=p+y,m=d+b;if(h>=0&&h<e&&m>=0&&m<t&&r[s(h,m)+3]===0){l.push([p,d]);break}}const c=new Set,u=[];for(;l.length>0;){const d=[];for(const[p,y]of l)for(const[b,h]of o){const m=p+b,f=y+h;if(m<0||m>=e||f<0||f>=t)continue;const x=s(m,f);if(r[x+3]>i)continue;const g=f*e+m;if(c.has(g))continue;c.add(g);const S=s(p,y);r[x]=r[S],r[x+1]=r[S+1],r[x+2]=r[S+2],r[x+3]=255,d.push([m,f]),u.push(x)}l.length=0;for(let p=0;p<d.length;p++)l.push(d[p])}for(const d of u)r[d+3]=a;return r}async function le(n,e={range:10,alpha:0}){return typeof document<"u"?Ge(n,e):He(n,e)}async function Ge(n,e){const t=URL.createObjectURL(new Blob([n])),i=await new Promise((l,c)=>{const u=new Image;u.crossOrigin="*",u.onload=()=>l(u),u.onerror=c,u.src=t});URL.revokeObjectURL(t);const a=document.createElement("canvas");a.width=i.width,a.height=i.height;const r=a.getContext("2d");if(!r)return null;r.drawImage(i,0,0);const s=r.getImageData(0,0,i.width,i.height),o=oe(new Uint8Array(s.data.buffer),i.width,i.height,e.range,e.alpha);return r.putImageData(new ImageData(new Uint8ClampedArray(o),i.width,i.height),0,0),new Promise(l=>{a.toBlob(c=>l(c))})}async function He(n,e){const t=(await we(()=>import("./index-6c8198f6.js").then(o=>o.i),["_static/index-6c8198f6.js","_static/index-0a8702e2.js"])).default,{data:i,info:a}=await t(Buffer.from(n)).ensureAlpha().raw().toBuffer({resolveWithObject:!0}),r=oe(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a.width,a.height,e.range,e.alpha),s=await t(Buffer.from(r),{raw:{width:a.width,height:a.height,channels:4}}).png().toBuffer();return new Blob([new Uint8Array(s)])}function L(n){const e=n instanceof Uint8Array?n:new Uint8Array(n);return e[0]===35&&e[1]===63}function k(n,e){const t=new Float32Array(1),i=new Uint32Array(t.buffer);for(let a=0;a<n.length;a++){t[0]=n[a];const r=i[0],s=r>>16&32768,o=(r>>23&255)-127+15,l=r&8388607;o<=0?e[a]=s:o>=31?e[a]=s|31744:e[a]=s|o<<10|l>>13}}function F(n){const e=ze(n),{width:t,height:i,dataPosition:a}=e,r=Ne(n.subarray(a),t,i),s=ke(r,t,i);return{width:t,height:i,pixels:s}}function ke(n,e,t){const i=e*t,a=new Float32Array(i*4);for(let r=0;r<i;r++){const s=r*4,o=r*4,l=Math.pow(2,n[s+3]-128-8);a[o]=Math.min(n[s]*l,65504),a[o+1]=Math.min(n[s+1]*l,65504),a[o+2]=Math.min(n[s+2]*l,65504),a[o+3]=1}return a}function ze(n){let e=N(n,0);if(e[0]!=="#"||e[1]!=="?")throw new Error("HDR: invalid header");let t=0,i=!1,a=!1;do t+=e.length+1,e=N(n,t),e==="FORMAT=32-bit_rle_rgbe"?i=!0:e.length===0&&(a=!0);while(!a);if(!i)throw new Error("HDR: unsupported format");t+=e.length+1,e=N(n,t);const r=/^\-Y (.*) \+X (.*)$/g.exec(e);if(!r||r.length<3)throw new Error("HDR: missing size");return{width:parseInt(r[2]),height:parseInt(r[1]),dataPosition:t+e.length+1}}function Ne(n,e,t){const i=n.byteLength,a=new Uint8Array(4*e*t);let r=0,s=0;const o=4*e,l=new Uint8Array(o);let c=t;for(;c>0&&s<i;){const u=n[s++],d=n[s++],p=n[s++],y=n[s++];if(u!==2||d!==2||p&128||e<8||e>32767)return n;if((p<<8|y)!==e)throw new Error("HDR: wrong scanline width");let b=0;for(;b<o&&s<i;){let h=n[s++];const m=h>128;if(m&&(h-=128),h===0||b+h>o)throw new Error("HDR: bad scanline");if(m){const f=n[s++];for(let x=0;x<h;x++)l[b++]=f}else l.set(n.subarray(s,s+h),b),b+=h,s+=h}for(let h=0;h<e;h++,r+=4)a[r]=l[h],a[r+1]=l[h+e],a[r+2]=l[h+e*2],a[r+3]=l[h+e*3];c--}return a}function N(n,e){let t="";for(let i=e;i<n.length;i++){const a=String.fromCharCode(n[i]);if(a===`
|
|
7
|
+
`)break;t+=a}return t}function $e(n,e,t){if(n.length!==e*t*4)throw new Error(`HDREncoder: pixel count mismatch (expected ${e*t*4}, got ${n.length})`);const i=qe(e,t),a=Xe(n,e,t),r=new Uint8Array(i.length+a.length);return r.set(i,0),r.set(a,i.length),r.buffer}function qe(n,e){const t=`#?RADIANCE
|
|
8
|
+
# Written by Galacean HDREncoder
|
|
9
|
+
FORMAT=32-bit_rle_rgbe
|
|
10
|
+
|
|
11
|
+
-Y ${e} +X ${n}
|
|
12
|
+
`;return new TextEncoder().encode(t)}function Xe(n,e,t){const i=t*(4+4*e*2),a=new Uint8Array(i);let r=0;const s=new Uint8Array(4*e);for(let o=0;o<t;o++){Ke(n,o*e*4,e,s),a[r++]=2,a[r++]=2,a[r++]=e>>8&255,a[r++]=e&255;for(let l=0;l<4;l++)r=We(s,l,e,a,r)}return a.subarray(0,r)}function Ke(n,e,t,i){for(let a=0;a<t;a++){const r=e+a*4,s=a*4,o=n[r],l=n[r+1],c=n[r+2],u=Math.max(o,l,c);if(u<1e-32)i[s]=0,i[s+1]=0,i[s+2]=0,i[s+3]=0;else{const d=Math.ceil(Math.log2(u)),p=256/Math.pow(2,d);i[s]=Math.min(255,Math.max(0,Math.round(o*p))),i[s+1]=Math.min(255,Math.max(0,Math.round(l*p))),i[s+2]=Math.min(255,Math.max(0,Math.round(c*p))),i[s+3]=d+128}}}function We(n,e,t,i,a){let r=0;for(;r<t;){const s=r,o=n[r*4+e];let l=1;for(;r+l<t&&l<127&&n[(r+l)*4+e]===o;)l++;if(l>=4)i[a++]=128+l,i[a++]=o,r+=l;else{let c=1;for(r=s;r+c<t&&c<128;){const u=n[(r+c)*4+e];let d=1;for(;r+c+d<t&&d<4&&n[(r+c+d)*4+e]===u;)d++;if(d>=4)break;c++}i[a++]=c;for(let u=0;u<c;u++)i[a++]=n[(r+u)*4+e];r+=c}}return a}const Ye=[[1,-1,-1,1,-1,1,1,1,-1,1,1,1],[-1,-1,1,-1,-1,-1,-1,1,1,-1,1,-1],[-1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1],[-1,1,-1,1,1,-1,-1,1,1,1,1,1],[-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1],[1,-1,1,-1,-1,1,1,1,1,-1,1,1]];function ce(n,e,t,i){const a=i??t>>1,r=[];for(let s=0;s<6;s++){const o=Ye[s],l=new Float32Array(a*a*4);Je(n,e,t,o,a,l),r.push(l)}return{faceSize:a,faces:r}}function Je(n,e,t,i,a,r){const s=1/a,o=(i[3]-i[0])*s,l=(i[4]-i[1])*s,c=(i[5]-i[2])*s,u=(i[9]-i[6])*s,d=(i[10]-i[7])*s,p=(i[11]-i[8])*s;let y=0;for(let b=0;b<a;b++){let h=i[0],m=i[1],f=i[2],x=i[6],g=i[7],S=i[8];for(let B=0;B<a;B++){let O=h+(x-h)*y,A=m+(g-m)*y,I=f+(S-f)*y;const R=1/Math.sqrt(O*O+A*A+I*I);O*=R,A*=R,I*=R;const he=Math.atan2(O,I)/Math.PI*.5+.5,me=Math.acos(A)/Math.PI,fe=(b*a+B)*4;Ze(n,e,t,he,me,r,fe),h+=o,m+=l,f+=c,x+=u,g+=d,S+=p}y+=s}}function Ze(n,e,t,i,a,r,s){const o=i*e-.5,l=(1-a)*t-.5,c=Math.floor(o),u=Math.floor(l),d=o-c,p=l-u,y=(c%e+e)%e,b=((c+1)%e+e)%e,h=Math.max(0,Math.min(u,t-1)),m=Math.max(0,Math.min(u+1,t-1)),f=(h*e+y)*4,x=(h*e+b)*4,g=(m*e+y)*4,S=(m*e+b)*4,B=(1-d)*(1-p),O=d*(1-p),A=(1-d)*p,I=d*p;for(let R=0;R<4;R++)r[s+R]=n[f+R]*B+n[x+R]*O+n[g+R]*A+n[S+R]*I}$.create("editor-cube-preview",`
|
|
13
|
+
attribute vec3 POSITION;
|
|
14
|
+
attribute vec3 NORMAL;
|
|
15
|
+
|
|
16
|
+
uniform mat4 renderer_MVPMat;
|
|
17
|
+
uniform vec3 camera_Position;
|
|
18
|
+
uniform mat4 renderer_ModelMat;
|
|
19
|
+
varying vec3 v_reflectDir;
|
|
20
|
+
|
|
21
|
+
void main(){
|
|
22
|
+
gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);
|
|
23
|
+
// All in object space, same as Unity's PreviewCubemap.shader
|
|
24
|
+
mat4 worldToModel = inverse(renderer_ModelMat);
|
|
25
|
+
vec3 objSpaceCameraPos = (worldToModel * vec4(camera_Position, 1.0)).xyz;
|
|
26
|
+
vec3 objSpaceViewDir = -normalize(objSpaceCameraPos - POSITION);
|
|
27
|
+
v_reflectDir = reflect(objSpaceViewDir, NORMAL);
|
|
28
|
+
}
|
|
29
|
+
`,`
|
|
30
|
+
varying vec3 v_reflectDir;
|
|
31
|
+
uniform samplerCube u_cubeTexture;
|
|
32
|
+
|
|
33
|
+
void main(){
|
|
34
|
+
gl_FragColor = textureCube(u_cubeTexture, normalize(v_reflectDir));
|
|
35
|
+
}
|
|
36
|
+
`);class E{static update(e,t){t.shape===V.Cube?this.updateCube(e,t):this.update2D(e,t)}static clear(){this.spriteEntity&&(this.spriteEntity.isActive=!1),this.cubeEntity&&(this.cubeEntity.isActive=!1)}static update2D(e,t){this.cubeEntity&&(this.cubeEntity.isActive=!1),this.spriteEntity?this.spriteEntity.isActive=!0:this.init2DScene(e),this.entity=this.spriteEntity,this.sprite.texture=t.engineObject}static updateCube(e,t){this.spriteEntity&&(this.spriteEntity.isActive=!1),this.cubeEntity?this.cubeEntity.isActive=!0:this.initCubeScene(e),this.entity=this.cubeEntity,this.cubeMaterial.shaderData.setTexture(Y.getByName("u_cubeTexture"),t.engineObject)}static init2DScene(e){const t=this.spriteEntity=e.createChild("sprite");this.spriteRenderer=t.addComponent(J),this.spriteRenderer.sprite=this.sprite=new Z(e.engine)}static initCubeScene(e){const{engine:t}=e,a=(this.cubeEntity=e.createChild("cube-preview-sphere")).addComponent(Q);a.mesh=ee.createSphere(t,.5,32),this.cubeMaterial=new te(t,$.find("editor-cube-preview")),a.setMaterial(this.cubeMaterial)}}v(E,"entity"),v(E,"spriteEntity"),v(E,"spriteRenderer"),v(E,"sprite"),v(E,"cubeEntity"),v(E,"cubeMaterial");const Qe=q(function(n){const{t:e}=xe(),t=n.encodeOptions,i=n.isHDR;return w.jsxs(w.Fragment,{children:[w.jsx(ne,{formStartSlot:w.jsx(z,{css:{marginLeft:"$4"}}),label:e("asset.ktx2.mode.label"),formEndSlot:w.jsx(Le,{content:w.jsxs(z,{direction:"column",children:[w.jsx(G,{size:"1",weight:"medium",children:e("asset.ktx2.mode.uastc.label")}),w.jsx(G,{size:"1",muted:!0,children:e("asset.ktx2.mode.uastc.desc")}),w.jsx(ve,{css:{margin:"$1 0"}}),w.jsx(G,{size:"1",weight:"medium",children:e("asset.ktx2.mode.etc1s.label")}),w.jsx(G,{size:"1",muted:!0,children:e("asset.ktx2.mode.etc1s.desc")})]}),children:w.jsx(Ve,{size:"18px"})}),value:i?"UASTC":t.mode,disabled:n.disabled||i,onChange:a=>{t.mode=a,n.onChange&&n.onChange(),Tracert.click("c351684.d417985",{type:a})},options:[{label:e("asset.ktx2.mode.uastc.label"),value:"UASTC"},{label:e("asset.ktx2.mode.etc1s.label"),value:"ETC1S"}]}),!i&&t.mode==="ETC1S"?w.jsx(Me,{formStartSlot:w.jsx(z,{css:{marginLeft:"$8"}}),disabled:n.disabled,label:e("asset.ktx2.quality"),min:0,max:255,step:1,value:t.quality,onChange:a=>{t.quality=Math.floor(a),n.onChange&&n.onChange()}}):null]})}),et=q(({textureOptions:n,onChange:e,disabled:t,isHDR:i})=>w.jsx(w.Fragment,{children:w.jsxs(Ce,{defaultOpen:!0,title:P("texture.bundle.format-options"),children:[w.jsx(Se,{label:P("texture.bundle.overwrite"),disabled:t,value:n.overwrite,onChange:a=>{n.overwrite=a,e&&e()}}),w.jsx(ne,{label:P("texture.bundle.texture-compression"),value:n.textureType,disabled:!n.overwrite||t,onChange:a=>{n.textureType=a,e&&e()},options:[{label:P("texture.bundle.type.ktx2"),value:"ktx2"},{label:P("texture.bundle.type.original"),value:"original"}]}),n.textureType==="ktx2"?w.jsx(Qe,{labelFirst:!1,onChange:e,disabled:!n.overwrite||t,encodeOptions:n,isHDR:i}):null]})})),tt=new Set(["colorDilate"]),nt=new Set(["isSRGBColorSpace","mipmap","filterMode","wrapModeU","wrapModeV","anisoLevel"]),at=q(n=>{var l;const e=n.asset,{inspectorFacade:t}=Ue(),i=e.runtimeOptions,a=!e.getEditable(),r=e instanceof M&&e.shape===V.Cube,s=e instanceof M&&((l=e.name)==null?void 0:l.endsWith(".hdr")),o=_e.useMemo(()=>{let c=e.formSchema.items;return e.isSubAsset?c=c.filter(u=>nt.has(u.property)):r&&(c=c.filter(u=>!tt.has(u.property))),s&&(c=c.map(u=>u.property==="isSRGBColorSpace"?{...u,disabled:!0}:u)),c},[r,s,e.isSubAsset,e.formSchema.items]);return w.jsxs(w.Fragment,{children:[w.jsx(Re.List,{model:e,configs:o,onModelChange:(c,u)=>{t.assetChange(e.id,c,u)}}),!e.isSubAsset&&w.jsx(et,{onChange:()=>{t.assetChange(e.id,"runtimeOptions",{...i},"asset-meta")},textureOptions:i,disabled:a,isHDR:s})]})});async function ue(n){var i;const{asset:e,shouldRefresh:t}=n;if(!(!e.isInitCompleted||!t)){if(e.isSubAsset){const a=(i=e.mainAsset)==null?void 0:i._rebuild;await(a==null?void 0:a());return}await e.updateEngineObject()}}async function it(n){var e;(e=n.currentTexture)==null||e.destroy(),await n.rebuild(),n.notifyReady()}class rt extends Fe{constructor(){super(...arguments);v(this,"_asset");v(this,"_rootEntity");v(this,"_onRebuild",()=>{var t;this._entity&&(this._entity.destroy(),this._entity=null),this._rebuild(),(t=this._requestResetCamera)==null||t.call(this)})}setViewAsset(t,i){this._asset=t,this._rootEntity=i,this._rebuild(),t.addPropertyChangeListener("engineObjectReady",this._onRebuild)}stopViewAsset(){var t;(t=this._asset)==null||t.removePropertyChangeListener("engineObjectReady",this._onRebuild),super.stopViewAsset(),this._asset=null,this._rootEntity=null}getDescription(t){return`${t.width}x${t.height}`}_rebuild(){const{_asset:t,_rootEntity:i}=this;!t||!i||!t.engineObject||t.engineObject.destroyed||(t.shape===V.Cube?this._buildCubePreview(i,t):this._build2DPreview(i,t))}_buildCubePreview(t,i){const a=t.engine,r=new Te(a,"cube-preview-sphere"),s=r.addComponent(Q);s.mesh=ee.createSphere(a,1,32);const o=new te(a,$.find("editor-cube-preview"));s.setMaterial(o),o.shaderData.setTexture(Y.getByName("u_cubeTexture"),i.engineObject),t.addChild(r),this._entity=r}_build2DPreview(t,i){const a=t.createChild("texture-preview"),r=a.addComponent(J);r.sprite=new Z(t.engine,i.engineObject),this._entity=a}}var st=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,_=(n,e,t,i)=>{for(var a=i>1?void 0:i?ot(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=(i?s(e,t,a):s(a))||a);return i&&a&&st(e,t,a),a},V=(n=>(n["2D"]="2D",n.Cube="Cube",n))(V||{}),pe=(n=>(n[n.Default=0]="Default",n[n.Sprite=1]="Sprite",n))(pe||{});function lt(n){const{pixels:e,width:t,height:i}=F(new Uint8Array(n)),a=new Uint16Array(e.length);return k(e,a),{input:a.buffer,options:{isUASTC:!0,isHDR:!0,imageType:re.RGBAHalfFloat,width:t,height:i}}}function de(n){return createImageBitmap(n,{premultiplyAlpha:"none"}).then(e=>{const i=new OffscreenCanvas(e.width,e.height).getContext("2d");i.drawImage(e,0,0);const a=i.getImageData(0,0,e.width,e.height),r=new Float32Array(a.data.length);for(let s=0;s<a.data.length;s++)r[s]=a.data[s]/255;return{pixels:r,width:e.width,height:e.height}})}async function ct(n,e,t,i,a){if(L(e)){const{pixels:r,width:s,height:o}=F(new Uint8Array(e)),l=new Uint16Array(r.length);k(r,l);const c=new X(n,s,o,ae.R16G16B16A16,t,!1);return c.name=a,c.setPixelBuffer(l),t&&c.generateMipmaps(),{texture:c,width:s,height:o}}else{const r=await createImageBitmap(new Blob([e]),{premultiplyAlpha:"none"}),s=new X(n,r.width,r.height,void 0,t,i);return s.name=a,s.setImageSource(r),t&&s.generateMipmaps(),{texture:s,width:r.width,height:r.height}}}async function ut(n,e,t,i,a){const r=L(e),{pixels:s,width:o,height:l}=r?F(new Uint8Array(e)):await de(new Blob([e])),{faceSize:c,faces:u}=ce(s,o,l),d=r?ae.R16G16B16A16:void 0,p=new je(n,c,d,t,!r&&i);p.name=a;for(let y=0;y<6;y++)if(r){const b=new Uint16Array(c*c*4);k(u[y],b),p.setPixelBuffer(y,b,0)}else{const b=new OffscreenCanvas(c,c),h=b.getContext("2d"),m=h.createImageData(c,c),f=u[y];for(let g=0;g<f.length;g++)m.data[g]=Math.round(Math.min(1,Math.max(0,f[g]))*255);h.putImageData(m,0,0);const x=await createImageBitmap(b);p.setImageSource(y,x)}return t&&p.generateMipmaps(),{texture:p,faceSize:c}}async function pt({content:n,meta:e,name:t,path:i},a){let r=await n.arrayBuffer();const s=e.runtimeOptions;let o=a.assetOptions.textureOptions;s!=null&&s.overwrite&&(o=Object.assign({},a.assetOptions.textureOptions,s)),e.colorDilate&&(r=await(await le(r,{range:4,alpha:2})).arrayBuffer());const l=e.filterMode??U.Bilinear,c=e.wrapModeU??C.Repeat,u=e.wrapModeV??C.Repeat,d=e.anisoLevel??1,p=e.mipmap??!0,y=e.isSRGBColorSpace??!0,b=L(r);if(o.textureType==="ktx2")try{const{input:f,options:x}=b?lt(r):{input:r,options:{isUASTC:o.mode==="UASTC",qualityLevel:o.quality}};let g=await H.encode(f,{...x,generateMipmap:p,isSetKTX2SRGBTransferFunc:!b&&y});return g=H.setTextureParams(g,{wrapModeU:c,wrapModeV:u,filterMode:l,anisoLevel:d}),{name:ie(t,".ktx2"),type:"KTX2",content:new Blob([g],{type:"image/ktx2"})}}catch(f){console.error(f),console.error("downgrade to uncompressed texture")}let h,m;if(b){const f=F(new Uint8Array(r));h=f.width,m=f.height}else{const f=URL.createObjectURL(n);try{const x=await Ee(f);h=x.width,m=x.height}finally{URL.revokeObjectURL(f)}}return{type:"Texture",content:new Blob([se(r,{type:"Texture2D",name:t,width:h,height:m,mipmap:Number(p),isSRGBColorSpace:Number(b?0:y),filterMode:l,wrapModeU:c,wrapModeV:u,anisoLevel:d,format:b?7:e.format,url:i})])}}async function W(n,e){return Promise.all(n.map(async t=>{const i=new OffscreenCanvas(e,e),a=i.getContext("2d"),r=a.createImageData(e,e);for(let o=0;o<t.length;o++)r.data[o]=Math.round(Math.min(1,Math.max(0,t[o]))*255);return a.putImageData(r,0,0),(await i.convertToBlob({type:"image/png"})).arrayBuffer()}))}async function dt({content:n,meta:e,name:t},i){const a=e.runtimeOptions;let r=i.assetOptions.textureOptions;a!=null&&a.overwrite&&(r=Object.assign({},r,a));const s=e.filterMode??U.Bilinear,o=e.wrapModeU??C.Clamp,l=e.wrapModeV??C.Clamp,c=e.anisoLevel??1,u=e.mipmap??!0,d=await n.arrayBuffer(),p=L(d),{pixels:y,width:b,height:h}=p?F(new Uint8Array(d)):await de(n),{faceSize:m,faces:f}=ce(y,b,h);if(r.textureType==="ktx2")try{let g,S;p?(g=f.map(O=>{const A=new Uint16Array(O.length);return k(O,A),A.buffer}),S={isUASTC:!0,isHDR:!0,imageType:re.RGBAHalfFloat,width:m,height:m}):(g=await W(f,m),S={isUASTC:r.mode==="UASTC",qualityLevel:r.quality});let B=await H.encode(g,{...S,generateMipmap:u,isSetKTX2SRGBTransferFunc:!p});return B=H.setTextureParams(B,{wrapModeU:o,wrapModeV:l,filterMode:s,anisoLevel:c}),{name:ie(t,".ktx2"),type:"KTX2",content:new Blob([B],{type:"image/ktx2"})}}catch(g){console.error(g),console.error("Cube: downgrade to uncompressed texture")}const x=p?f.map(g=>$e(g,m,m)):await W(f,m);return{type:"Texture",content:new Blob([se(x,{type:"TextureCube",name:t,faceSize:m,mipmap:Number(u),filterMode:s,anisoLevel:c,wrapModeU:o,wrapModeV:l,isSRGBColorSpace:Number(e.isSRGBColorSpace??0)})])}}let M=class extends Be{constructor(){super(...arguments);v(this,"shape","2D");v(this,"isSRGBColorSpace",!0);v(this,"mipmap",!0);v(this,"filterMode",U.Bilinear);v(this,"wrapModeU",C.Repeat);v(this,"wrapModeV",C.Repeat);v(this,"anisoLevel",1);v(this,"width",0);v(this,"height",0);v(this,"colorDilate",!1);v(this,"runtimeOptions",{overwrite:!1,textureType:"ktx2",mode:"ETC1S",quality:150,isNormal:!1});v(this,"_imageBuffer")}get imageBuffer(){return this._imageBuffer}beforeDelete(){}afterDelete(){var e;(e=this.engineObject)==null||e.destroy(!0)}setTextureType(e){e===1&&(this.wrapModeU=this.wrapModeV=C.Clamp,this.mipmap=!1,this.root.assetFacade.updateAssetMeta(this.id,{wrapModeU:this.wrapModeU,wrapModeV:this.wrapModeV,mipmap:this.mipmap}))}async initByEngineObject(e){this.bindEngineObject(e),this.filterMode=e.filterMode,this.wrapModeU=e.wrapModeU,this.wrapModeV=e.wrapModeV,this.anisoLevel=e.anisoLevel,this.width=e.width,this.height=e.height,this.mipmap=e._mipmap,this.isSRGBColorSpace=e.isSRGBColorSpace,this._name=e.name}async initByMain(e){const{meta:t}=this;this._imageBuffer=await e.arrayBuffer(),t.runtimeOptions&&(this.runtimeOptions=t.runtimeOptions),this.shape=t.shape??this.shape,this.filterMode=t.filterMode??this.filterMode,this.anisoLevel=t.anisoLevel??this.anisoLevel,this.wrapModeU=t.wrapModeU??this.wrapModeU,this.wrapModeV=t.wrapModeV??this.wrapModeV,this.colorDilate=t.colorDilate??this.colorDilate,this.mipmap=t.mipmap??this.mipmap,this.isSRGBColorSpace=t.isSRGBColorSpace??this.isSRGBColorSpace,await this._rebuildEngineObject()}async updateEngineObject(){await it({currentTexture:this.engineObject,rebuild:async()=>{await this._rebuildEngineObject()},notifyReady:()=>{this.triggerPropertyChange("engineObjectReady",!1)}})}async updateTextureImageSource(e){const t=await createImageBitmap(new Blob([e]),{premultiplyAlpha:"none"});this.engineObject.setImageSource(t),this.mipmap&&this.engineObject.generateMipmaps()}async onShapeChanged(e){const t=this.engineObject;await this._rebuildEngineObject(),t==null||t.destroy(!0),await this.root.assetFacade.updateAssetMeta(this.id,{shape:e}),this.updateThumbnail(),this.triggerPropertyChange("engineObjectReady",!1)}async _rebuildEngineObject(){if(this.shape==="Cube"){const{texture:e,faceSize:t}=await ut(this.engine,this._imageBuffer,this.mipmap,this.isSRGBColorSpace,this.name);this.width=t,this.height=t,this.bindEngineObject(e)}else{const{texture:e,width:t,height:i}=await ct(this.engine,this._imageBuffer,this.mipmap,this.isSRGBColorSpace,this.name);this.width=t,this.height=i,this.bindEngineObject(e)}}};_([D({label:"texture.shape.title",type:j.Select,onChange:async(n,e,t)=>{n.isInitCompleted&&await n.onShapeChanged(t)},options:[{label:"2D",value:"2D"},{label:"Cube",value:"Cube"}]}),T()],M.prototype,"shape",2);_([D({label:"texture.sRGB.title",type:j.Toggle,onChange:async(n,e,t)=>{await ue({asset:n,shouldRefresh:n.shape==="2D"})}}),T()],M.prototype,"isSRGBColorSpace",2);_([D({label:"texture.mipmap.title",type:j.Toggle,onChange:async(n,e,t)=>{await ue({asset:n,shouldRefresh:!0})}}),T()],M.prototype,"mipmap",2);_([D({label:"texture.filter-mode.title",type:j.Select,value:U.Bilinear,bindPath:"filterMode",options:[{label:"texture.filter-mode.point",value:U.Point},{label:"texture.filter-mode.bilinear",value:U.Bilinear},{label:"texture.filter-mode.trilinear",value:U.Trilinear}]}),T()],M.prototype,"filterMode",2);_([D({label:"texture.wrap-mode.u.title",type:j.Select,bindPath:"wrapModeU",options:[{label:"texture.wrap-mode.clamp",value:C.Clamp},{label:"texture.wrap-mode.repeat",value:C.Repeat},{label:"texture.wrap-mode.mirror",value:C.Mirror}]}),T()],M.prototype,"wrapModeU",2);_([D({label:"texture.wrap-mode.v.title",type:j.Select,bindPath:"wrapModeV",options:[{label:"texture.wrap-mode.clamp",value:C.Clamp},{label:"texture.wrap-mode.repeat",value:C.Repeat},{label:"texture.wrap-mode.mirror",value:C.Mirror}]}),T()],M.prototype,"wrapModeV",2);_([D({label:"texture.aniso-level.title",type:j.Slider,dragStep:1,max:16,min:1,bindPath:"anisoLevel"}),T()],M.prototype,"anisoLevel",2);_([T()],M.prototype,"width",2);_([T()],M.prototype,"height",2);_([D({label:"texture.dilate.title",info:"texture.dilate.info",type:j.Toggle}),T()],M.prototype,"colorDilate",2);_([Oe,T()],M.prototype,"runtimeOptions",2);M=_([Ie({type:"Texture",label:P("asset.texture.title"),loaderType:"Texture",importMenuConfig:{type:Pe.Upload,accept:".png,.jpg,.jpeg,.webp,.hdr",multiple:!0},preUpload:async n=>{const e=await n.main.arrayBuffer();return L(e)?{main:n.main,meta:JSON.stringify({isSRGBColorSpace:!1})}:n.main},viewer:rt,thumbnail:E,extname:"tex",icon:{bgSolidColor:new Ae(0,0,0,0)},dragLayer:De.Texture,customInspector:at,async preInitialize({main:n,meta:e,name:t}){if(e.colorDilate){const i=await n.arrayBuffer(),a=await le(i,{range:4,alpha:2});return new File([a],t,{type:"Texture"})}return n},async bundle({content:n,meta:e,name:t,path:i},a){return e.shape==="Cube"?dt({content:n,meta:e,name:t},a):pt({content:n,meta:e,name:t,path:i},a)}})],M);const Ct=Object.freeze(Object.defineProperty({__proto__:null,get TextureAsset(){return M},TextureShape:V,TextureUseType:pe},Symbol.toStringTag,{value:"Module"}));export{Qe as K,V as T,pe as a,M as b,at as c,Ct as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var u=(e,A,a)=>A in e?h(e,A,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[A]=a;var m=(e,A,a)=>(u(e,typeof A!="symbol"?A+"":A,a),a);import{J as g,K as b,u as p}from"./index-0a8702e2.js";import{C as d}from"./CanvasRenderer-9dd98cb3.js";import{g as _,a as f}from"./ThumbnailRegistry-495c18c9.js";import"./AssetPreviewer-24e31d97.js";import"./IconPlayerPlayFilled-b058c98f.js";var Q=Object.defineProperty,j=Object.getOwnPropertyDescriptor,y=(e,A,a,i)=>{for(var t=i>1?void 0:i?j(A,a):A,s=e.length-1,o;s>=0;s--)(o=e[s])&&(t=(i?o(A,a,t):o(t))||t);return i&&t&&Q(A,a,t),t};const r=window.devicePixelRatio,k=Math.round(70*r),D=Math.round(70*r),R={Scene:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*Z36ZQ4DCa58AAAAAAAAAAAAADuiaAQ/original",script:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*rMekSIWSS4oAAAAAAAAAAAAADuiaAQ/original",Folder:"https://mdn.alipayobjects.com/huamei_x9dkln/afts/img/A*FCaHQb2o4LsAAAAAAAAAAAAADsGIAQ/original",FolderLocked:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*q3h-RoSMm8AAAAAAQCAAAAgAeuiaAQ/original",Font:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*fYh9QKvlmX0AAAAAAAAAAAAADuiaAQ/original",Lottie:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*G7AkQoIP5c4AAAAAAAAAAAAADuiaAQ/original",SpriteAtlas:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*3R4xR5csHVEAAAAAAAAAAAAADuiaAQ/original",AnimatorController:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*-kFKQ5avQB8AAAAAAAAAAAAADuiaAQ/original",AnimationClip:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*_oBXQrnu50sAAAAAAAAAAAAADuiaAQ/original",Spine:"https://mdn.alipayobjects.com/huamei_x9dkln/afts/img/A*IQVfRLMioacAAAAAAAAAAAAADsGIAQ/original",Shader:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*kM0jQIKIzlgAAAAAAAAAAAAADuiaAQ/original",ShaderChunk:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*kM0jQIKIzlgAAAAAAAAAAAAADuiaAQ/original",XRReferenceImage:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*L0kBS4FGJLIAAAAAAAAAAAAADuiaAQ/original",glTF:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*HQs2QrqBTawAAAAAAAAAAAAADuiaAQ/original",Prefab:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*HQs2QrqBTawAAAAAAAAAAAAADuiaAQ/original",SpineSkeletonData:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*UnoLR4LjgcEAAAAAAAAAAAAADuiaAQ/original",SpineAtlas:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*q7BUSabi8scAAAAAAAAAAAAADuiaAQ/original",PhysicsMaterial:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*v6BsQbKRjKsAAAAAAAAAAAAADuiaAQ/original",Audio:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*r-1FSpQZvcUAAAAAAAAAAAAADuiaAQ/original",RenderTarget:"https://mdn.alipayobjects.com/huamei_ic2ff1/afts/img/2fpfRbIC87EAAAAAQBAAAAgADhHBAQFr/original",Markdown:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*427uS5hw3wgAAAAAMOAAAAgAeuiaAQ/original"};var n;const c=(n=class{constructor(A){m(this,"_state",p({thumbnailUrl:""}));m(this,"_updateThumbnailDebounced");this.asset=A,this._updateThumbnailDebounced=b(this._updateThumbnail.bind(this),100,{edges:["trailing"]}),n.registerCanvas(k,D,A.engine)}static async createThumbnailUrl(A){const a=A.getMetaConfig().type,i=_(a);if(!i){console.error("can't find '"+a+"' ThumbnailItem.");return}const t=this._canvasRenderer,{rootEntity:s,width:o,height:l}=t;return i.update(s,A),t.renderOneFrame(o,l),i.clear(),t.createImageUrl()}static registerCanvas(A,a,i){if(!this._canvasRenderer){this._canvasRenderer=new d(A,a,i);const t=f();for(const s in t)t[s].entity=null}}get thumbnailUrl(){return this._state.thumbnailUrl||(R[this.asset.getMetaConfig().type]??"")}set thumbnailUrl(A){this._state.thumbnailUrl=A}updateThumbnail(A){this._updateThumbnailDebounced(A)}async _updateThumbnail(A=!1){if(A){URL.revokeObjectURL(this._state.thumbnailUrl),this._state.thumbnailUrl="";return}this.asset.engineObject&&(URL.revokeObjectURL(this._state.thumbnailUrl),this._state.thumbnailUrl=await n.createThumbnailUrl(this.asset))}dispose(){this._state.thumbnailUrl&&(URL.revokeObjectURL(this._state.thumbnailUrl),this._state.thumbnailUrl="")}},m(n,"_canvasRenderer"),n);y([g],c.prototype,"_updateThumbnail",1);let C=c;export{C as ThumbnailMixin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t={};function i(e){return t[e]}function r(){return t}function s(e,n){t[e]=n}export{r as a,i as g,s as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aJ as s,bI as _,dR as le,aD as f,bL as O,bK as g,dS as G,dT as ce,dU as ue,dV as de,dW as fe,bF as pe,dX as Y,dY as ve,dZ as z,d_ as he,d$ as ye,bM as xe,bH as Ee,e0 as be,bQ as me,aH as Ce}from"./index-0a8702e2.js";var ge="DismissableLayer",I="dismissableLayer.update",Te="dismissableLayer.pointerDownOutside",Pe="dismissableLayer.focusOutside",V,X=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),q=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:u,...c}=e,d=s.useContext(X),[l,h]=s.useState(null),v=(l==null?void 0:l.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=s.useState({}),x=_(n,p=>h(p)),E=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),C=E.indexOf(b),m=l?E.indexOf(l):-1,P=d.layersWithOutsidePointerEventsDisabled.size>0,T=m>=C,w=De(p=>{const A=p.target,$=[...d.branches].some(k=>k.contains(A));!T||$||(o==null||o(p),i==null||i(p),p.defaultPrevented||u==null||u())},v),D=Oe(p=>{const A=p.target;[...d.branches].some(k=>k.contains(A))||(a==null||a(p),i==null||i(p),p.defaultPrevented||u==null||u())},v);return le(p=>{m===d.layers.size-1&&(r==null||r(p),!p.defaultPrevented&&u&&(p.preventDefault(),u()))},v),s.useEffect(()=>{if(l)return t&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(V=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(l)),d.layers.add(l),U(),()=>{t&&d.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=V)}},[l,v,t,d]),s.useEffect(()=>()=>{l&&(d.layers.delete(l),d.layersWithOutsidePointerEventsDisabled.delete(l),U())},[l,d]),s.useEffect(()=>{const p=()=>y({});return document.addEventListener(I,p),()=>document.removeEventListener(I,p)},[]),f.jsx(O.div,{...c,ref:x,style:{pointerEvents:P?T?"auto":"none":void 0,...e.style},onFocusCapture:g(e.onFocusCapture,D.onFocusCapture),onBlurCapture:g(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:g(e.onPointerDownCapture,w.onPointerDownCapture)})});q.displayName=ge;var we="DismissableLayerBranch",Re=s.forwardRef((e,n)=>{const t=s.useContext(X),r=s.useRef(null),o=_(n,r);return s.useEffect(()=>{const a=r.current;if(a)return t.branches.add(a),()=>{t.branches.delete(a)}},[t.branches]),f.jsx(O.div,{...e,ref:o})});Re.displayName=we;function De(e,n=globalThis==null?void 0:globalThis.document){const t=G(e),r=s.useRef(!1),o=s.useRef(()=>{});return s.useEffect(()=>{const a=u=>{if(u.target&&!r.current){let c=function(){K(Te,t,d,{discrete:!0})};const d={originalEvent:u};u.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=c,n.addEventListener("click",o.current,{once:!0})):c()}else n.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{n.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),n.removeEventListener("pointerdown",a),n.removeEventListener("click",o.current)}},[n,t]),{onPointerDownCapture:()=>r.current=!0}}function Oe(e,n=globalThis==null?void 0:globalThis.document){const t=G(e),r=s.useRef(!1);return s.useEffect(()=>{const o=a=>{a.target&&!r.current&&K(Pe,t,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,t]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function U(){const e=new CustomEvent(I);document.dispatchEvent(e)}function K(e,n,t,{discrete:r}){const o=t.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:t});n&&o.addEventListener(e,n,{once:!0}),r?ce(o,a):o.dispatchEvent(a)}var Le="Portal",Z=s.forwardRef((e,n)=>{var u;const{container:t,...r}=e,[o,a]=s.useState(!1);ue(()=>a(!0),[]);const i=t||o&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return i?de.createPortal(f.jsx(O.div,{...r,ref:n}),i):null});Z.displayName=Le;var Ae=s.forwardRef((e,n)=>{const{children:t,...r}=e,o=s.Children.toArray(t),a=o.find(_e);if(a){const i=a.props.children,u=o.map(c=>c===a?s.Children.count(i)>1?s.Children.only(null):s.isValidElement(i)?i.props.children:null:c);return f.jsx(M,{...r,ref:n,children:s.isValidElement(i)?s.cloneElement(i,void 0,u):null})}return f.jsx(M,{...r,ref:n,children:t})});Ae.displayName="Slot";var M=s.forwardRef((e,n)=>{const{children:t,...r}=e;if(s.isValidElement(t)){const o=je(t);return s.cloneElement(t,{...Se(r,t.props),ref:n?fe(n,o):o})}return s.Children.count(t)>1?s.Children.only(null):null});M.displayName="SlotClone";var J=({children:e})=>f.jsx(f.Fragment,{children:e});function _e(e){return s.isValidElement(e)&&e.type===J}function Se(e,n){const t={...n};for(const r in n){const o=e[r],a=n[r];/^on[A-Z]/.test(r)?o&&a?t[r]=(...u)=>{a(...u),o(...u)}:o&&(t[r]=o):r==="style"?t[r]={...o,...a}:r==="className"&&(t[r]=[o,a].filter(Boolean).join(" "))}return{...e,...t}}function je(e){var r,o;let n=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,t=n&&"isReactWarning"in n&&n.isReactWarning;return t?e.ref:(n=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,t=n&&"isReactWarning"in n&&n.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Ne="VisuallyHidden",Q=s.forwardRef((e,n)=>f.jsx(O.span,{...e,ref:n,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));Q.displayName=Ne;var ke=Q,[S,ot]=pe("Tooltip",[Y]),j=Y(),ee="TooltipProvider",Ie=700,H="tooltip.open",[Me,B]=S(ee),te=e=>{const{__scopeTooltip:n,delayDuration:t=Ie,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,[i,u]=s.useState(!0),c=s.useRef(!1),d=s.useRef(0);return s.useEffect(()=>{const l=d.current;return()=>window.clearTimeout(l)},[]),f.jsx(Me,{scope:n,isOpenDelayed:i,delayDuration:t,onOpen:s.useCallback(()=>{window.clearTimeout(d.current),u(!1)},[]),onClose:s.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u(!0),r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(l=>{c.current=l},[]),disableHoverableContent:o,children:a})};te.displayName=ee;var N="Tooltip",[He,L]=S(N),ne=e=>{const{__scopeTooltip:n,children:t,open:r,defaultOpen:o=!1,onOpenChange:a,disableHoverableContent:i,delayDuration:u}=e,c=B(N,e.__scopeTooltip),d=j(n),[l,h]=s.useState(null),v=xe(),y=s.useRef(0),x=i??c.disableHoverableContent,E=u??c.delayDuration,b=s.useRef(!1),[C=!1,m]=Ee({prop:r,defaultProp:o,onChange:p=>{p?(c.onOpen(),document.dispatchEvent(new CustomEvent(H))):c.onClose(),a==null||a(p)}}),P=s.useMemo(()=>C?b.current?"delayed-open":"instant-open":"closed",[C]),T=s.useCallback(()=>{window.clearTimeout(y.current),b.current=!1,m(!0)},[m]),w=s.useCallback(()=>{window.clearTimeout(y.current),m(!1)},[m]),D=s.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{b.current=!0,m(!0)},E)},[E,m]);return s.useEffect(()=>()=>window.clearTimeout(y.current),[]),f.jsx(be,{...d,children:f.jsx(He,{scope:n,contentId:v,open:C,stateAttribute:P,trigger:l,onTriggerChange:h,onTriggerEnter:s.useCallback(()=>{c.isOpenDelayed?D():T()},[c.isOpenDelayed,D,T]),onTriggerLeave:s.useCallback(()=>{x?w():window.clearTimeout(y.current)},[w,x]),onOpen:T,onClose:w,disableHoverableContent:x,children:t})})};ne.displayName=N;var W="TooltipTrigger",re=s.forwardRef((e,n)=>{const{__scopeTooltip:t,...r}=e,o=L(W,t),a=B(W,t),i=j(t),u=s.useRef(null),c=_(n,u,o.onTriggerChange),d=s.useRef(!1),l=s.useRef(!1),h=s.useCallback(()=>d.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),f.jsx(ve,{asChild:!0,...i,children:f.jsx(O.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:g(e.onPointerMove,v=>{v.pointerType!=="touch"&&!l.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),l.current=!0)}),onPointerLeave:g(e.onPointerLeave,()=>{o.onTriggerLeave(),l.current=!1}),onPointerDown:g(e.onPointerDown,()=>{d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:g(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:g(e.onBlur,o.onClose),onClick:g(e.onClick,o.onClose)})})});re.displayName=W;var F="TooltipPortal",[We,Be]=S(F,{forceMount:void 0}),oe=e=>{const{__scopeTooltip:n,forceMount:t,children:r,container:o}=e,a=L(F,n);return f.jsx(We,{scope:n,forceMount:t,children:f.jsx(z,{present:t||a.open,children:f.jsx(Z,{asChild:!0,container:o,children:r})})})};oe.displayName=F;var R="TooltipContent",se=s.forwardRef((e,n)=>{const t=Be(R,e.__scopeTooltip),{forceMount:r=t.forceMount,side:o="top",...a}=e,i=L(R,e.__scopeTooltip);return f.jsx(z,{present:r||i.open,children:i.disableHoverableContent?f.jsx(ae,{side:o,...a,ref:n}):f.jsx(Fe,{side:o,...a,ref:n})})}),Fe=s.forwardRef((e,n)=>{const t=L(R,e.__scopeTooltip),r=B(R,e.__scopeTooltip),o=s.useRef(null),a=_(n,o),[i,u]=s.useState(null),{trigger:c,onClose:d}=t,l=o.current,{onPointerInTransitChange:h}=r,v=s.useCallback(()=>{u(null),h(!1)},[h]),y=s.useCallback((x,E)=>{const b=x.currentTarget,C={x:x.clientX,y:x.clientY},m=Ge(C,b.getBoundingClientRect()),P=Ye(C,m),T=ze(E.getBoundingClientRect()),w=qe([...P,...T]);u(w),h(!0)},[h]);return s.useEffect(()=>()=>v(),[v]),s.useEffect(()=>{if(c&&l){const x=b=>y(b,l),E=b=>y(b,c);return c.addEventListener("pointerleave",x),l.addEventListener("pointerleave",E),()=>{c.removeEventListener("pointerleave",x),l.removeEventListener("pointerleave",E)}}},[c,l,y,v]),s.useEffect(()=>{if(i){const x=E=>{const b=E.target,C={x:E.clientX,y:E.clientY},m=(c==null?void 0:c.contains(b))||(l==null?void 0:l.contains(b)),P=!Xe(C,i);m?v():P&&(v(),d())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,l,i,d,v]),f.jsx(ae,{...e,ref:a})}),[$e,Ve]=S(N,{isInside:!1}),ae=s.forwardRef((e,n)=>{const{__scopeTooltip:t,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...u}=e,c=L(R,t),d=j(t),{onClose:l}=c;return s.useEffect(()=>(document.addEventListener(H,l),()=>document.removeEventListener(H,l)),[l]),s.useEffect(()=>{if(c.trigger){const h=v=>{const y=v.target;y!=null&&y.contains(c.trigger)&&l()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,l]),f.jsx(q,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:l,children:f.jsxs(he,{"data-state":c.stateAttribute,...d,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[f.jsx(J,{children:r}),f.jsx($e,{scope:t,isInside:!0,children:f.jsx(ke,{id:c.contentId,role:"tooltip",children:o||r})})]})})});se.displayName=R;var ie="TooltipArrow",Ue=s.forwardRef((e,n)=>{const{__scopeTooltip:t,...r}=e,o=j(t);return Ve(ie,t).isInside?null:f.jsx(ye,{...o,...r,ref:n})});Ue.displayName=ie;function Ge(e,n){const t=Math.abs(n.top-e.y),r=Math.abs(n.bottom-e.y),o=Math.abs(n.right-e.x),a=Math.abs(n.left-e.x);switch(Math.min(t,r,o,a)){case a:return"left";case o:return"right";case t:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Ye(e,n,t=5){const r=[];switch(n){case"top":r.push({x:e.x-t,y:e.y+t},{x:e.x+t,y:e.y+t});break;case"bottom":r.push({x:e.x-t,y:e.y-t},{x:e.x+t,y:e.y-t});break;case"left":r.push({x:e.x+t,y:e.y-t},{x:e.x+t,y:e.y+t});break;case"right":r.push({x:e.x-t,y:e.y-t},{x:e.x-t,y:e.y+t});break}return r}function ze(e){const{top:n,right:t,bottom:r,left:o}=e;return[{x:o,y:n},{x:t,y:n},{x:t,y:r},{x:o,y:r}]}function Xe(e,n){const{x:t,y:r}=e;let o=!1;for(let a=0,i=n.length-1;a<n.length;i=a++){const u=n[a].x,c=n[a].y,d=n[i].x,l=n[i].y;c>r!=l>r&&t<(d-u)*(r-c)/(l-c)+u&&(o=!o)}return o}function qe(e){const n=e.slice();return n.sort((t,r)=>t.x<r.x?-1:t.x>r.x?1:t.y<r.y?-1:t.y>r.y?1:0),Ke(n)}function Ke(e){if(e.length<=1)return e.slice();const n=[];for(let r=0;r<e.length;r++){const o=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}n.pop();const t=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}return t.pop(),n.length===1&&t.length===1&&n[0].x===t[0].x&&n[0].y===t[0].y?n:n.concat(t)}var Ze=ne,Je=re,Qe=oe,et=se;const tt=me({"0%":{opacity:0,transform:"scale(0) translateY(-4px)"},"100%":{opacity:1,transform:"scale(1) translateY(0px)"}}),nt=Ce(et,{display:"flex",alignItems:"center",fontSize:"13px",padding:"$2 $3",backgroundColor:"$gray2",borderRadius:"$4",color:"$gray12",boxShadow:"inset 0 0 0 1px $colors$grayA4",transformOrigin:"var(--radix-tooltip-content-transform-origin)",animation:`${tt} 0.2s ease forwards`});function st(e){const{children:n,content:t,side:r="bottom",sideOffset:o=6,delayDuration:a=0,...i}=e;return f.jsx(te,{children:f.jsxs(Ze,{delayDuration:a,...i,children:[f.jsx(Je,{asChild:!0,children:n}),f.jsx(Qe,{children:f.jsx(nt,{sideOffset:o,side:r,children:t})})]})})}export{st as T};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=Object.defineProperty;var F=(t,e,r)=>e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var u=(t,e,r)=>(F(t,typeof e!="symbol"?e+"":e,r),r);import{aT as O,aU as D,aJ as S,aD as p,aE as I,ck as L,cl as Y,cm as z,cn as K,co as N,cp as B,cq as M,x as U,cr as q,aY as H,E as J,cs as A,p as P,C as f,s as h,f as G,t as W,e as $,w as Q}from"./index-0a8702e2.js";import{u as X}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as Z}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{B as k}from"./index-37c74ae9.js";import{c as tt}from"./createOnModelChange-b57a0da8.js";import{R as et}from"./ReferencedMaterial-a87818f3.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";import"./Menu-cd3be298.js";import"./MaterialInspector-aec1248b.js";import"./IconPointFilled-a304fd34.js";const v=(t=[[0,1],[1,1]])=>({class:"ParticleCurve",constructParams:t.map(([e,r])=>({class:"CurveKey",constructParams:[e,r]}))}),w=t=>({class:"ParticleCurve",constructParams:t.constructParams.map(e=>({class:"CurveKey",constructParams:[e.constructParams[0],e.constructParams[1]]})),editorYTickScale:t.editorYTickScale}),R=(t,e=v())=>{var r;return(r=t==null?void 0:t.constructParams)!=null&&r.length?w(t):w(e)},rt=(t,e=v())=>{const r=new L;return R(t,e).constructParams.forEach(a=>{r.addKey(new Y(a.constructParams[0],a.constructParams[1]))}),r},at=(t,e=v())=>(r,i,a)=>{const n=R(a,e);t(r,rt(n,e)),r[i]=n},it=O(({model:t,inspectorConfig:e,onModelChange:r})=>{const{t:i}=D(),a=e.property,n=e.defaultCurve??v(),o=R(t[a],n),g=o.editorYTickScale??e.yTickScale??1;S.useEffect(()=>{t[a]||(o.editorYTickScale=g,t[a]=o)},[]);const y=s=>{const l=t[a],V=s/g;t[a]={...l,constructParams:l.constructParams.map(x=>({...x,constructParams:[x.constructParams[0],x.constructParams[1]*V]})),editorYTickScale:s},r==null||r(a)},c=s=>{!s||s.length>4||(t[a]={class:"ParticleCurve",constructParams:s.map(l=>({class:"CurveKey",constructParams:[l.x,l.y*g]})),editorYTickScale:g},r==null||r(a))};return p.jsx(I,{label:i(e.label||a),info:i(e.info),children:p.jsx(k,{algo:"linear",yRangeMode:e.yRangeMode,yTickScale:g,yTickScaleMin:e.yTickScaleMin,yTickScaleMax:e.yTickScaleMax,onYTickScaleChange:y,onYTickScaleCommit:()=>r==null?void 0:r(a),value:o.constructParams.map(s=>({x:s.constructParams[0],y:s.constructParams[1]/g})),onChange:c})})}),b=(t=[{time:0,color:{r:1,g:1,b:1,a:1}},{time:1,color:{r:1,g:1,b:1,a:1}}],e=[{time:0,alpha:1},{time:1,alpha:1}])=>({class:"ParticleGradient",constructParams:[t.map(r=>({time:r.time,color:{r:r.color.r,g:r.color.g,b:r.color.b,a:r.color.a}})),e.map(r=>({time:r.time,alpha:r.alpha}))]}),_=t=>b(t.constructParams[0],t.constructParams[1]),E=(t,e=b())=>{var r,i,a;return!((i=(r=t==null?void 0:t.constructParams)==null?void 0:r[0])!=null&&i.length)||!((a=t.constructParams[1])!=null&&a.length)?_(e):_(t)},nt=(t,e=b())=>{const r=E(t,e);return new B(r.constructParams[0].map(i=>new M(i.time,new U(i.color.r,i.color.g,i.color.b,i.color.a))),r.constructParams[1].map(i=>new q(i.time,i.alpha)))},ot=(t,e=b())=>(r,i,a)=>{const n=E(a,e);t(r,nt(n,e)),r[i]=n},ct=O(({model:t,inspectorConfig:e,onModelChange:r})=>{const{t:i}=D(),a=e.property,n=e.defaultGradient??b(),o=E(t[a],n);S.useEffect(()=>{t[a]||(t[a]=o)},[]);const g={color:o.constructParams[0].map(c=>({value:z(c.color),position:c.time})),alpha:o.constructParams[1].map(c=>({value:{r:255,g:255,b:255,a:c.alpha},position:c.time}))},y=c=>{if(!c||c.color.length>4||c.alpha.length>4)return;const s={class:"ParticleGradient",constructParams:[c.color.map(l=>({time:l.position,color:N(l.value)})),c.alpha.map(l=>({time:l.position,alpha:l.value.a}))]};t[a]=s,r==null||r(a)};return p.jsx(I,{label:i(e.label||a),info:i(e.info),children:p.jsx(K,{fullsize:!0,mode:"particle",value:g,onValueChange:y})})}),st=O(function(t){const[e,r]=S.useState(null),i=t.data,{assetStore:a,inspectorFacade:n}=X();return S.useEffect(()=>{a.getAssetByRef(i.material).then(o=>{r(o)})},[i.material]),p.jsxs(p.Fragment,{children:[p.jsx(H.List,{model:i,configs:i.formSchema.items,onModelChange:tt("component",i.id,n,i)}),e&&p.jsx(p.Fragment,{children:p.jsx(et,{materialAsset:e})})]})});var lt=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,d=(t,e,r,i)=>{for(var a=i>1?void 0:i?mt(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(a=(i?o(e,r,a):o(a))||a);return i&&a&<(e,r,a),a};const ut="0000205",T=v([[0,1],[1,1]]),C=b([{time:0,color:{r:1,g:1,b:1,a:1}},{time:1,color:{r:1,g:1,b:1,a:1}}],[{time:0,alpha:1},{time:1,alpha:1}]);let m=class extends J{constructor(){super(...arguments);u(this,"emitting",!0);u(this,"time",5);u(this,"minVertexDistance",.1);u(this,"widthCurve",T);u(this,"colorGradient",C);u(this,"textureMode",A.Stretch);u(this,"textureScale",{x:1,y:1});u(this,"material",{refId:ut});u(this,"priority",0)}};d([P({type:f.Toggle,bindPath:"emitting",label:"trail.emitting.label",info:"trail.emitting.info"}),h()],m.prototype,"emitting",2);d([P({type:f.Number,bindPath:"time",min:0,dragStep:.1,label:"trail.time.label",info:"trail.time.info"}),h()],m.prototype,"time",2);d([P({type:f.Number,bindPath:"minVertexDistance",min:0,dragStep:.01,label:"trail.min-vertex-distance.label",info:"trail.min-vertex-distance.info"}),h()],m.prototype,"minVertexDistance",2);d([G({getPath:"widthCurve",setPath:"widthCurve"}),P({customComponent:it,label:"trail.width-curve.label",info:"trail.width-curve.info",defaultCurve:T,yRangeMode:"positive",onChange:at((t,e)=>{t.setBoundPathValue("widthCurve",f.Input,e)},T)}),h()],m.prototype,"widthCurve",2);d([G({getPath:"colorGradient",setPath:"colorGradient"}),P({customComponent:ct,label:"trail.color-gradient.label",info:"trail.color-gradient.info",defaultGradient:C,onChange:ot((t,e)=>{t.setBoundPathValue("colorGradient",f.Input,e)},C)}),h()],m.prototype,"colorGradient",2);d([P({type:f.Select,bindPath:"textureMode",label:"trail.texture-mode.label",info:"trail.texture-mode.info",options:W(A,void 0,t=>$(`trail.texture-mode.${t.toLowerCase()}`))}),h()],m.prototype,"textureMode",2);d([P({type:f.Vector2,bindPath:"textureScale",min:.01,dragStep:.1,label:"trail.texture-scale.label",info:"trail.texture-scale.info"}),h()],m.prototype,"textureScale",2);d([G({engineKey:"setMaterial",setPath:"setMaterial()",getPath:"getMaterial()",valueType:Q.ReferResource,getEngineValue:t=>t.getMaterial()}),P({type:f.AssetPicker,assetType:"Material",label:"trail.material.label",info:"trail.material.info",customFilter:t=>{var e;return((e=t.engineObject.shader)==null?void 0:e.name)==="trail"}}),h({type:"methods",key:"setMaterial",onSerialize:t=>t?[[t]]:void 0,onDeserialize(t){return t?t[0][0]:void 0}})],m.prototype,"material",2);d([P({type:f.Number,bindPath:"priority",min:0,dragStep:1,label:"trail.priority.label",info:"trail.priority.info"}),h()],m.prototype,"priority",2);m=d([Z({type:"TrailRenderer",customInspector:st,componentsMenu:{group:"effects",label:"component.trail-renderer.title"}})],m);export{m as TrailRendererComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=Object.defineProperty;var P=(r,e,t)=>e in r?C(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>(P(r,typeof e!="symbol"?e+"":e,t),t);import{aT as g,b9 as D,aU as O,aD as l,ba as A,aM as M,bb as B,p as f,e as p,C as T,s as u,E as F}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";function I(r){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...r,children:l.jsx("path",{fill:"currentColor",d:"M3 9a1 1 0 0 0 1-1V5a1 1 0 0 1 1-1h3a1 1 0 0 0 0-2H5a3 3 0 0 0-3 3v3a1 1 0 0 0 1 1m5 11H5a1 1 0 0 1-1-1v-3a1 1 0 0 0-2 0v3a3 3 0 0 0 3 3h3a1 1 0 0 0 0-2m9-7a1 1 0 0 0 0-2h-1.14A4 4 0 0 0 13 8.14V7a1 1 0 0 0-2 0v1.14A4 4 0 0 0 8.14 11H7a1 1 0 0 0 0 2h1.14A4 4 0 0 0 11 15.86V17a1 1 0 0 0 2 0v-1.14A4 4 0 0 0 15.86 13Zm-5 1a2 2 0 1 1 2-2a2 2 0 0 1-2 2m9 1a1 1 0 0 0-1 1v3a1 1 0 0 1-1 1h-3a1 1 0 0 0 0 2h3a3 3 0 0 0 3-3v-3a1 1 0 0 0-1-1M19 2h-3a1 1 0 0 0 0 2h3a1 1 0 0 1 1 1v3a1 1 0 0 0 2 0V5a3 3 0 0 0-3-3"})})}const S=g(D),H=g(({inspectorConfig:r,models:e,onModelChange:t,model:o})=>{const{label:n,property:a,disabled:h}=r,{t:v}=O(),E=!o;e=e||[o];const z=o.root.sceneStore.entities,d=e[0],b=o.root.sceneStore.rootEntity.children,_=e.map(i=>i.id);function j(i){const V=d.engineObject,y=z.get(i);if(!y)return;const w=y.engineObject.getComponent(B);V.lookAt(w.worldPosition),d.syncRotation()}return l.jsx(S,{disabled:h,label:v(n),value:E?{x:null,y:null,z:null}:o[a],onChange:(i,V)=>{e.forEach(y=>y[a]=i),t&&t(a,i)},formEndSlot:l.jsx(A,{trigger:l.jsx(M,{variant:"subtle",corner:!0,children:l.jsx(I,{style:{width:"13px",height:"13px"}})}),disabledEntities:_,entityMap:b,entities:b,label:n,onSelect:j})})});var R=Object.defineProperty,q=Object.getOwnPropertyDescriptor,x=(r,e,t,o)=>{for(var n=o>1?void 0:o?q(e,t):e,a=r.length-1,h;a>=0;a--)(h=r[a])&&(n=(o?h(e,t,n):h(n))||n);return o&&n&&R(e,t,n),n},s;const m=(s=class extends F{constructor(){super(...arguments);c(this,"position",{x:0,y:0,z:0});c(this,"rotation",{x:0,y:0,z:0});c(this,"scale",{x:1,y:1,z:1})}static equalVector3(t,o){return t.x===o.x&&t.y===o.y&&t.z===o.z}static roundToThreeDecimal(t){return Math.round(t*1e3)/1e3}static roundVector2(t,o){return o.x=this.roundToThreeDecimal(t.x),o.y=this.roundToThreeDecimal(t.y),o}static copyVector2(t,o){o.x=t.x,o.y=t.y}static roundVector3(t,o){return o.x=this.roundToThreeDecimal(t.x),o.y=this.roundToThreeDecimal(t.y),o.z=this.roundToThreeDecimal(t.z),o}static copyVector3(t,o){o.x=t.x,o.y=t.y,o.z=t.z}syncTransformToEditor(t){this._syncTransformToEditor("position",t.position),this._syncTransformToEditor("rotation",t.rotation),this._syncTransformToEditor("scale",t.scale)}_syncTransformToEditor(t,o){const n=this[t],a=s.roundVector3(o,s._tempVector3);s.equalVector3(a,n)||(s.copyVector3(a,n),this.notifyPropertyChange(t,!1))}},c(s,"_tempVector2",{x:0,y:0}),c(s,"_tempVector3",{x:0,y:0,z:0}),s);x([f({label:p("transform.position.title"),info:p("transform.position.info"),type:T.Vector3,bindPath:"position"}),u()],m.prototype,"position",2);x([f({label:p("transform.rotation.title"),info:p("transform.rotation.info"),customComponent:H,type:T.Vector3,bindPath:"rotation"}),u()],m.prototype,"rotation",2);x([f({label:p("transform.scale.title"),info:p("transform.scale.info"),type:T.Vector3,constrainable:!0,bindPath:"scale"}),u()],m.prototype,"scale",2);let K=m;export{K as T};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.defineProperty;var h=(r,t,o)=>t in r?p(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var m=(r,t,o)=>(h(r,typeof t!="symbol"?t+"":t,o),o);import{J as l,e as s}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as u}from"./Component-f923abb1.js";import{T}from"./TransformBaseComponent-02318c5a.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var d=Object.defineProperty,g=Object.getOwnPropertyDescriptor,f=(r,t,o,n)=>{for(var e=n>1?void 0:n?g(t,o):t,i=r.length-1,a;i>=0;i--)(a=r[i])&&(e=(n?a(t,o,e):a(e))||e);return n&&e&&d(t,o,e),e};let c=class extends T{constructor(t,o){super(t,o);m(this,"syncEngineToEditor",l(()=>{const{position:t,rotation:o,scale:n}=this.engineObject;this._syncTransformToEditor("position",t),this._syncTransformToEditor("rotation",o),this._syncTransformToEditor("scale",n)}))}syncRotation(){this._syncTransformToEditor("rotation",this.engineObject.rotation)}checkCanDisable(){return{code:1,msg:s("transform.error.cant-disable")}}checkCanDeletable(){return{code:1,msg:s("transform.error.cant-delete")}}get ignoreToJSON(){return!0}onAddToEntity(t){for(let o=0;o<t.components.length;o++){const n=t.components[o];(n.type==="Transform"||n.type==="UITransform")&&n!==this&&t.removeComponent(n)}t.setComponentIndex(this,0)}getAnimatableProperties(){let t=[];const o=n=>{if(!(n!=null&&n.length))return t;n.filter(e=>!e.when||e.when(this)).forEach(e=>{e.type==="Group"?o(e.children):t.push({property:e.property,label:s(e.label),type:e.type})})};return o(this.formSchema.items),t=t.concat(this._additionAnimatableProperties),t}};f([l],c.prototype,"syncRotation",1);c=f([u({type:"Transform",componentsMenu:{hide:!0,label:s("component.transform.title")}})],c);export{c as TransformComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var a=(r,e,t)=>e in r?n(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(a(r,typeof e!="symbol"?e+"":e,t),t);import{o,u as c,aW as h,aX as w}from"./index-0a8702e2.js";import{C as _}from"./CanvasRenderer-9dd98cb3.js";import"./AssetPreviewer-24e31d97.js";import"./IconPlayerPlayFilled-b058c98f.js";class V{constructor(e){i(this,"isPreviewReady",!1);i(this,"_canvas");i(this,"_rootEntity");i(this,"_currentViewer",null);i(this,"_canvasRenderer");o(this,{isPreviewReady:c});const t=new _(100,100,e,!0);this._canvas=t.canvas,this._canvas.style.width="100%",this._canvas.style.height="100%",this._canvasRenderer=t,this._rootEntity=t.scene.createRootEntity("root_object")}get currentViewer(){return this._currentViewer}get rootEntity(){return this._rootEntity}async startPreview(e,t){const s=t.getMetaConfig().type;if(this._currentViewer=h(s)??null,!this._currentViewer){console.error("Not support this asset type: ",s);return}await this._currentViewer.setViewAsset(t,this._rootEntity),this._canvasRenderer.addToContainer(e,this._currentViewer,this._rootEntity),this.isPreviewReady=!0}stopPreview(){this._rootEntity.clearChildren(),this._currentViewer.stopViewAsset(),this.isPreviewReady=!1,this._canvasRenderer.removeFromContainer()}}function p(r,e){w(r,e)}export{V as ViewerManager,p as registerViewer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var g=(t,e,r)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>(g(t,typeof e!="symbol"?e+"":e,r),r);import{$ as f,j as u,a9 as d,bu as b,bv as y,b0 as U,p as R,e as p,C as w}from"./index-0a8702e2.js";import{X as j}from"./module-5c85b07e.js";import{a as O,A as I}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as v}from"./AssetViewer-bc198e16.js";import{e as C}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";class _ extends v{constructor(){super()}setViewAsset(e,r){const s=r.createChild("sprite_entity"),i=s.addComponent(f);i.sprite=e._sprite,this._entity=s}}function x(t){const e=t.getCurrentUrl();return e&&(t.revokeObjectUrl(e),t.setCurrentUrl("")),new Promise((r,s)=>{const i=t.createImage();i.crossOrigin="*";const n=t.createObjectUrl(t.blob),a=()=>{t.revokeObjectUrl(n),t.getCurrentUrl()===n&&t.setCurrentUrl("")};t.setCurrentUrl(n),i.src=n,i.onload=()=>{a(),r(i)},i.onerror=m=>{a(),s(m)}})}var W=Object.defineProperty,A=Object.getOwnPropertyDescriptor,o=(t,e,r,s)=>{for(var i=s>1?void 0:s?A(e,r):e,n=t.length-1,a;n>=0;n--)(a=t[n])&&(i=(s?a(e,r,i):a(i))||i);return s&&i&&W(e,r,i),i};let l=class extends u{constructor(e){super(e);c(this,"imgUrl");c(this,"_sprite");c(this,"physicalWidth",.1);this._sprite=new d(this.engine)}async initByMain(e){const r=await x({blob:e,getCurrentUrl:()=>this.imgUrl,setCurrentUrl:a=>{this.imgUrl=a},createImage:()=>new Image,createObjectUrl:a=>URL.createObjectURL(a),revokeObjectUrl:a=>URL.revokeObjectURL(a)}),{_sprite:s}=this,i=new j("reference",r,r.width/100),n=new b(this.engine,r.width,r.height,y.R8G8B8A8,!1);n.setImageSource(r),s.texture=n,s.width=r.width/100,s.height=r.height/100,this.physicalWidth=i.physicalWidth=this.meta.physicalWidth,this.bindEngineObject(i)}initByEngineObject(e){this.bindEngineObject(e),this.physicalWidth=e.physicalWidth}};o([U(),R({label:p("xr.image.width.label"),info:p("xr.image.width.info"),type:w.Number})],l.prototype,"physicalWidth",2);l=o([O({type:"XRReferenceImage",label:p("asset.xr-reference-image.title"),loaderType:"XRReferenceImage",importMenuConfig:{type:I.Upload,tooltip:"支持多选",accept:".png,.jpg,.jpeg,.webp",multiple:!0},viewer:_,defaultName:"ReferenceImage",extname:"bin",async bundle({content:t,meta:e,name:r}){const s=await t.arrayBuffer();return{type:"XRReferenceImage",content:new Blob([C([s],{type:"XRReferenceImage",name:r,physicalWidth:e.physicalWidth})])}}})],l);export{l as XRReferenceImageAsset};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(l,t,e={}){var a,c;e.clearSceneSelection&&((a=l.sceneStore)==null||a.selectEntity(null)),l.layoutStore.toggleTabVisibility(t),l.layoutStore.activeTab(t),(c=e.afterOpen)==null||c.call(e)}export{i as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=Object.defineProperty;var u=(e,o,r)=>o in e?l(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r;var n=(e,o,r)=>(u(e,typeof o!="symbol"?o+"":o,r),r);import{E as c,s as v,p as d,C as f}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as _}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var y=Object.defineProperty,C=Object.getOwnPropertyDescriptor,a=(e,o,r,t)=>{for(var p=t>1?void 0:t?C(o,r):o,m=e.length-1,i;m>=0;m--)(i=e[m])&&(p=(t?i(o,r,p):i(p))||p);return t&&p&&y(o,r,p),p};let s=class extends c{constructor(o,r){super(o,r);n(this,"volume",0)}};a([v(),d({type:f.Slider,min:0,max:10,dragStep:.01,bindPath:"volume"})],s.prototype,"volume",2);s=a([_({type:"Audio",class:"AudioSource"})],s);export{s as AudioComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function p(r){const{layers:s,parameters:a}=JSON.parse(r),e={layers:[],parameters:[]};for(const t of s){const n={...t};delete n._stateMachineGraphData,e.layers.push(n)}return e.parameters=a,JSON.stringify(e)}function f(r){const s=JSON.parse(r),a=s.type,e={type:a};for(const t in s)t!=="type"&&t.startsWith(a)&&(e[t]=s[t]);return JSON.stringify(e)}async function u(r,s,a,e){var o;const t=JSON.parse(s);delete t.quickPivot;const n=(o=t.belongToAtlas)==null?void 0:o.refId;if(!n)delete t.belongToAtlas;else{const i=await e(n);i&&((JSON.parse(i).sprites??[]).some(l=>l.refId==r)||(delete t.belongToAtlas,console.warn("Sprite atlas asset not includes this sprite.")))}return t.fullPath=a,JSON.stringify(t)}export{f as a,p as b,u as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function C(c,s,n,g,t){return(e,h)=>{const a=h===void 0?g[e]:h;switch(c){case"scene":n.sceneChange(e,a);break;case"entity":n.entityChange(s,e,a);break;case"component":n.componentChange(s,e,a);break;case"asset":n.assetChange(s,e,a,t);break}}}export{C as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as x}from"./meshopt_simplifier.module-cd99529d.js";function v(t,n,i){const e=n??i;t.writeUint8(typeof e=="boolean"?e?1:0:Number(e))}function z(t,n,i){const{width:e,height:s}=i;if(!e||!s)throw new Error(`Cannot determine image dimensions (width=${e}, height=${s})`);if(e>65535||s>65535)throw new Error(`Texture dimensions ${e}x${s} exceed Uint16 max (65535)`);m(t,i),t.writeUint16(e),t.writeUint16(s),v(t,i.isSRGBColorSpace,1),t.writeImagesData([n])}function A(t,n,i){const{faceSize:e}=i;if(!e)throw new Error(`Cannot determine face size (faceSize=${e})`);if(e>65535)throw new Error(`Face size ${e} exceeds Uint16 max (65535)`);if(n.length!==6)throw new Error(`Expected 6 faces, got ${n.length}`);m(t,i),t.writeUint16(e),v(t,i.isSRGBColorSpace,0),t.writeImagesData(n)}function m(t,n){t.writeStr(n.url??""),v(t,n.mipmap,1),t.writeUint8(n.filterMode??1),t.writeUint8(n.anisoLevel??1),t.writeUint8(n.wrapModeU??0),t.writeUint8(n.wrapModeV??0),t.writeUint8(n.format??1)}const U={AnimationVector2Curve:{vKeys:["x","y"],tKeys:["x","y"]},AnimationVector3Curve:{vKeys:["x","y","z"],tKeys:["x","y","z"]},AnimationVector4Curve:{vKeys:["x","y","z","w"],tKeys:["x","y","z","w"]},AnimationQuaternionCurve:{vKeys:["x","y","z","w"],tKeys:["x","y","z","w"]},AnimationColorCurve:{vKeys:["r","g","b","a"],tKeys:["x","y","z","w"]}};function T(t,n){t.writeStr(n.name);const i=n.events??[];t.writeUint16(i.length);for(const e of i)t.writeFloat32(e.time),t.writeStr(e.functionName),t.writeStr(JSON.stringify({val:e.parameter}));t.writeUint16(n.curveBindings.length);for(const e of n.curveBindings){const{relativePath:s,type:f,property:r,getProperty:u,curveType:l,curve:c}=e;t.writeStr(s),t.writeStr(typeof f=="string"?f:""),t.writeStr(r),t.writeStr(u),t.writeUint8(c.interpolation),t.writeUint16(c.keys.length),t.writeStr(l);for(const o of c.keys)switch(t.writeFloat32(o.time),l){case"AnimationFloatCurve":{const a=o;t.writeFloat32(a.value),t.writeFloat32(a.inTangent??0),t.writeFloat32(a.outTangent??0);break}case"AnimationArrayCurve":case"AnimationFloatArrayCurve":{const a=o;t.writeUint16(a.value.length),t.writeFloat32Array(a.value),t.writeFloat32Array(a.inTangent??[]),t.writeFloat32Array(a.outTangent??[]);break}case"AnimationRefCurve":{t.writeStr(JSON.stringify(o.value));break}case"AnimationBoolCurve":{t.writeUint8(o.value?1:0);break}case"AnimationStringCurve":{t.writeStr(o.value);break}default:{const a=U[l];if(a){const d=o,p={x:0,y:0,z:0,w:0,...d.inTangent},S={x:0,y:0,z:0,w:0,...d.outTangent};for(const g of a.vKeys)t.writeFloat32(d.value[g]);for(const g of a.tKeys)t.writeFloat32(p[g]);for(const g of a.tKeys)t.writeFloat32(S[g])}break}}}}const b=[{key:"normals",size:3,write:w},{key:"uvs",size:2,write:y},{key:"uv1",size:2,write:y},{key:"uv2",size:2,write:y},{key:"uv3",size:2,write:y},{key:"uv4",size:2,write:y},{key:"uv5",size:2,write:y},{key:"uv6",size:2,write:y},{key:"uv7",size:2,write:y}];function C(t,n){const i=n.positions.length;let e=i*3*4;const s={positions:{start:0,end:e},bounds:{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}},subMeshes:n.subMeshes};for(const{key:c,size:o}of b)n[c]&&(s[c]={start:e,end:e+=i*o*4});n.colors&&(s.colors={start:e,end:e+=i*4*4}),n.boneIndices&&(s.boneIndices={start:e,end:e+=i*4*4}),n.boneWeights&&(s.boneWeights={start:e,end:e+=i*4*4}),n.blendShapes&&(s.blendShapes=n.blendShapes.map(c=>({name:c.name,frames:c.frames.map(o=>{const a={weight:o.weight,deltaPosition:{start:e,end:e+=i*3*4}};return o.deltaNormals&&(a.deltaNormals={start:e,end:e+=i*3*4}),o.deltaTangents&&(a.deltaTangents={start:e,end:e+=i*4*4}),a})})));const f=new Float32Array(e/4);let r=0;w(f,n.positions,r),r+=i*3;for(const{key:c,size:o,write:a}of b){const d=n[c];d&&(a(f,d,r),r+=i*o)}if(n.colors&&(k(f,n.colors,r),r+=i*4),n.boneIndices&&(h(f,n.boneIndices,r),r+=i*4),n.boneWeights&&(h(f,n.boneWeights,r),r+=i*4),n.blendShapes)for(const c of n.blendShapes)for(const o of c.frames)w(f,o.deltaPositions,r),r+=i*3,o.deltaNormals&&(w(f,o.deltaNormals,r),r+=i*3),o.deltaTangents&&(h(f,o.deltaTangents,r),r+=i*4);n.bounds&&(s.bounds=n.bounds);let u=null;if(n.indices){const c=i>65535?1:0;u=c===1?new Uint32Array(n.indices):new Uint16Array(n.indices);const o=c===0?Uint16Array.BYTES_PER_ELEMENT:Uint32Array.BYTES_PER_ELEMENT;s.indices={type:c,start:e,end:e+=n.indices.length*o}}t.writeStr(JSON.stringify(s));const l=Math.ceil(t.offset/4)*4-t.offset;l>0&&t.writeBytes(new ArrayBuffer(l)),t.writeBytes(f.buffer),u&&t.writeBytes(u.buffer)}function y(t,n,i){for(let e=0;e<n.length;e++)t[i+e*2]=n[e].x,t[i+e*2+1]=n[e].y}function w(t,n,i){for(let e=0;e<n.length;e++)t[i+e*3]=n[e].x,t[i+e*3+1]=n[e].y,t[i+e*3+2]=n[e].z}function h(t,n,i){for(let e=0;e<n.length;e++)t[i+e*4]=n[e].x,t[i+e*4+1]=n[e].y,t[i+e*4+2]=n[e].z,t[i+e*4+3]=n[e].w}function k(t,n,i){for(let e=0;e<n.length;e++)t[i+e*4]=n[e].r,t[i+e*4+1]=n[e].g,t[i+e*4+2]=n[e].b,t[i+e*4+3]=n[e].a}function E(t,n,i){t.writeFloat32(i.physicalWidth),t.writeUint8(n.length),t.writeImagesData(n)}const F=1313033287,B={Texture2D:z,TextureCube:A,AnimationClip:T,Mesh:C,XRReferenceImage:E};function M(t,n){const{name:i,version:e=1,type:s}=n,f=B[s];if(!f)throw new Error(`[asset-bundle-utils] No encoder registered for type "${s}"`);const r=new x;r.writeUint32(F);const u=r.offset;r.writeUint32(0),r.writeUint8(e),r.writeStr(s),r.writeStr(i);const l=r.offset,o=(l+3&-4)-l;return o>0&&r.writeBytes(new ArrayBuffer(o)),f(r,t,n),r.patchUint32(u,r.offset),r.buffer}export{M as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=(a=>(a[a.RGBAHalfFloat=0]="RGBAHalfFloat",a[a.RGBAFloat=1]="RGBAFloat",a[a.EXR=3]="EXR",a[a.HDR=4]="HDR",a))(l||{});export{l as H};
|