@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,6 @@
|
|
|
1
|
+
import{aC as oe,bE as te,bF as re,bG as T,bx as c,aD as r,bH as D,bI as ne,bJ as ie,bK as ae,bL as M,bM as ce,bN as se,bO as de,bP as le,bQ as O,aH as b,bR as pe}from"./index-0a8702e2.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 Ne=oe("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),u="Accordion",ue=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[H,he,fe]=te(u),[C,Te]=re(u,[fe,T]),P=T(),V=c.forwardRef((o,i)=>{const{type:e,...n}=o,a=n,t=n;return r.jsx(H.Provider,{scope:o.__scopeAccordion,children:e==="multiple"?r.jsx(xe,{...t,ref:i}):r.jsx(me,{...a,ref:i})})});V.displayName=u;var[L,ge]=C(u),[B,be]=C(u,{collapsible:!1}),me=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},collapsible:t=!1,...s}=o,[d,l]=D({prop:e,defaultProp:n,onChange:a});return r.jsx(L,{scope:o.__scopeAccordion,value:d?[d]:[],onItemOpen:l,onItemClose:c.useCallback(()=>t&&l(""),[t,l]),children:r.jsx(B,{scope:o.__scopeAccordion,collapsible:t,children:r.jsx(K,{...s,ref:i})})})}),xe=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},...t}=o,[s=[],d]=D({prop:e,defaultProp:n,onChange:a}),l=c.useCallback(g=>d((h=[])=>[...h,g]),[d]),f=c.useCallback(g=>d((h=[])=>h.filter($=>$!==g)),[d]);return r.jsx(L,{scope:o.__scopeAccordion,value:s,onItemOpen:l,onItemClose:f,children:r.jsx(B,{scope:o.__scopeAccordion,collapsible:!0,children:r.jsx(K,{...t,ref:i})})})}),[ve,A]=C(u),K=c.forwardRef((o,i)=>{const{__scopeAccordion:e,disabled:n,dir:a,orientation:t="vertical",...s}=o,d=c.useRef(null),l=ne(d,i),f=he(e),h=ie(a)==="ltr",$=ae(o.onKeyDown,m=>{var E;if(!ue.includes(m.key))return;const Z=m.target,I=f().filter(j=>{var N;return!((N=j.ref.current)!=null&&N.disabled)}),x=I.findIndex(j=>j.ref.current===Z),z=I.length;if(x===-1)return;m.preventDefault();let p=x;const S=0,w=z-1,y=()=>{p=x+1,p>w&&(p=S)},R=()=>{p=x-1,p<S&&(p=w)};switch(m.key){case"Home":p=S;break;case"End":p=w;break;case"ArrowRight":t==="horizontal"&&(h?y():R());break;case"ArrowDown":t==="vertical"&&y();break;case"ArrowLeft":t==="horizontal"&&(h?R():y());break;case"ArrowUp":t==="vertical"&&R();break}const ee=p%z;(E=I[ee].ref.current)==null||E.focus()});return r.jsx(ve,{scope:e,disabled:n,direction:a,orientation:t,children:r.jsx(H.Slot,{scope:e,children:r.jsx(M.div,{...s,"data-orientation":t,ref:l,onKeyDown:n?void 0:$})})})}),v="AccordionItem",[Ce,k]=C(v),G=c.forwardRef((o,i)=>{const{__scopeAccordion:e,value:n,...a}=o,t=A(v,e),s=ge(v,e),d=P(e),l=ce(),f=n&&s.value.includes(n)||!1,g=t.disabled||o.disabled;return r.jsx(Ce,{scope:e,open:f,disabled:g,triggerId:l,children:r.jsx(se,{"data-orientation":t.orientation,"data-state":Y(f),...d,...a,ref:i,disabled:g,open:f,onOpenChange:h=>{h?s.onItemOpen(n):s.onItemClose(n)}})})});G.displayName=v;var U="AccordionHeader",W=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(U,e);return r.jsx(M.h3,{"data-orientation":a.orientation,"data-state":Y(t.open),"data-disabled":t.disabled?"":void 0,...n,ref:i})});W.displayName=U;var _="AccordionTrigger",F=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(_,e),s=be(_,e),d=P(e);return r.jsx(H.ItemSlot,{scope:e,children:r.jsx(de,{"aria-disabled":t.open&&!s.collapsible||void 0,"data-orientation":a.orientation,id:t.triggerId,...d,...n,ref:i})})});F.displayName=_;var J="AccordionContent",Q=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(J,e),s=P(e);return r.jsx(le,{role:"region","aria-labelledby":t.triggerId,"data-orientation":a.orientation,...s,...n,ref:i,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...o.style}})});Q.displayName=J;function Y(o){return o?"open":"closed"}var Ae=V,$e=G,Ie=W,Se=F,we=Q;const ye=O({from:{height:0,opacity:0},to:{height:"var(--radix-accordion-content-height)",opacity:1}}),Re=O({from:{height:"var(--radix-accordion-content-height)",opacity:1},to:{height:0,opacity:0}}),q=c.createContext({size:"sm"}),je=b(Ae,{width:"100%",display:"flex",flexDirection:"column"}),_e=b($e,{position:"relative",boxSizing:"border-box",width:"100%",backgroundColor:"$surface",border:"1px solid $border",borderBottom:"none",overflow:"hidden","&:first-child":{borderTopLeftRadius:"$sm",borderTopRightRadius:"$sm"},"&:last-child":{borderBottomLeftRadius:"$sm",borderBottomRightRadius:"$sm",borderBottom:"1px solid $border"},"&[data-state=open]":{borderColor:"$borderStrong","&:not(:first-child)":{borderTopColor:"$borderStrong"},"& + &":{borderTopColor:"$borderStrong"}},"&:has(+ [data-state=open])":{borderBottomColor:"$borderStrong"}}),X=b(pe,{width:"$iconSm",height:"$iconSm",color:"currentColor",flexShrink:0,transform:"rotate(0deg)",transition:"transform .2s ease, color .2s ease"}),He=b(Ie,{all:"unset",display:"block"}),Pe=b(Se,{all:"unset",display:"flex",width:"100%",minHeight:"30px",padding:"0 $3",alignItems:"center",justifyContent:"space-between",gap:"$2",fontSize:"$2",lineHeight:"$lineHeights$2",fontWeight:500,color:"$text",overflow:"hidden",boxSizing:"border-box",userSelect:"none",backgroundColor:"$grayA2",transition:"$backgroundColor, $borderColor, $color","& > span":{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'&[data-state="open"]':{[`& ${X}`]:{transform:"rotate(90deg)"}},"&:hover":{backgroundColor:"$grayA3",color:"$textStrong"},"&:focus-visible":{outline:"none",boxShadow:"$focus"},variants:{size:{sm:{minHeight:"27px",padding:"0 $2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{minHeight:"30px",padding:"0 $3",fontSize:"$2",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),ke=b(we,{overflow:"hidden",fontSize:"$1",color:"$text",backgroundColor:"$grayA2",'&[data-state="open"]':{animation:`${ye} 200ms cubic-bezier(0.16, 1, 0.3, 1)`},'&[data-state="closed"]':{animation:`${Re} 180ms cubic-bezier(0.16, 1, 0.3, 1)`},"@media (prefers-reduced-motion: reduce)":{'&[data-state="open"], &[data-state="closed"]':{animation:"none"}}}),ze=b("div",{color:"$text",borderTop:"1px solid $border",variants:{size:{sm:{padding:"$2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{padding:"$3",fontSize:"$1",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),De=function(i){const{size:e="sm",...n}=i;return r.jsx(q.Provider,{value:{size:e},children:r.jsx(je,{...n})})};function Me(o){const{size:i}=c.useContext(q),{children:e,title:n,arrow:a=!0,...t}=o;return r.jsxs(_e,{...t,children:[r.jsx(He,{children:r.jsxs(Pe,{size:i,children:[r.jsx("span",{children:n}),a&&r.jsx(X,{"aria-hidden":!0})]})}),r.jsx(ke,{children:r.jsx(ze,{size:i,children:e})})]})}export{De as A,Ne as I,Me as a};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var nt=Object.defineProperty;var st=(r,t,n)=>t in r?nt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;var k=(r,t,n)=>(st(r,typeof t!="symbol"?t+"":t,n),n);import{b_ as R,O as rt,b$ as ot,Q as it,j as at,c0 as E,c1 as Q,c2 as ct,c3 as ut,c4 as ht,c5 as lt,c6 as ft,a7 as mt,e as bt,c7 as dt,c8 as gt}from"./index-0a8702e2.js";import{H as yt}from"./enum-58295f88.js";import{a as pt}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{k as wt}from"./ktx2-encoder-1e63c1eb.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";import"./TaskQueue-05c94a4d.js";import"./ktx-parse.modern-6c9f771f.js";class D{static getWorker(t){const n=this.getWorkerCodeByFunctionList(t);if(this._workerCache[n])return this._workerCache[n];const e=this.getWorkerURLByCode(n),s=new Worker(e);return this._workerCache[n]=s,this.registerWorkerEvent(s),s}static registerWorkerEvent(t){t.onmessage=n=>{const e=n.data,{type:s,taskID:i}=e;switch(s){case"calculateSHFromTextureCube":const a=this._callbacks[i],o=e.result;a.resolve(o);break}}}static getURLByWorker(t){for(let n in this._workerCache)if(this._workerCache[n]===t)return n}static getWorkerCodeByFunctionList(t){const n=kt.toString(),e=n.substring(n.indexOf("{")+1,n.lastIndexOf("}"));return`
|
|
2
|
+
${t.map(i=>i.toString()).join(`
|
|
3
|
+
`)}
|
|
4
|
+
${e}
|
|
5
|
+
`}static getWorkerURLByCode(t){return URL.createObjectURL(new Blob([t],{type:"application/javascript"}))}static calculateSHFromTextureCube(t,n,e,s,i,a,o){return new Promise(h=>{const l=this._taskID++,f=this.getWorker([j,F,Y,Z,V,A]);this._callbacks[l]={resolve:h},f.postMessage({type:"calculateSHFromTextureCube",taskID:l,textureSize:o,dataPX:t,dataNX:n,dataPY:e,dataNY:s,dataPZ:i,dataNZ:a})})}}k(D,"_callbacks",{}),k(D,"_workerCache",{}),k(D,"_taskID",0);function kt(){self.onmessage=function(t){const n=t.data,{type:e,taskID:s}=n;switch(e){case"calculateSHFromTextureCube":const{textureSize:i,dataPX:a,dataNX:o,dataPY:h,dataNY:l,dataPZ:f,dataNZ:b}=n,u=new Float32Array(27);let c=0;c=A(a,0,i,c,u),c=A(o,1,i,c,u),c=A(h,2,i,c,u),c=A(l,3,i,c,u),c=A(f,4,i,c,u),c=A(b,5,i,c,u),V(u,4*Math.PI/c),self.postMessage({type:"calculateSHFromTextureCube",taskID:s,result:u});break}}}class St{static async fromTextureCube(t,n){const s=t.width,i=new Uint16Array(s*s*4),a=new Uint16Array(s*s*4),o=new Uint16Array(s*s*4),h=new Uint16Array(s*s*4),l=new Uint16Array(s*s*4),f=new Uint16Array(s*s*4);t.getPixelBuffer(R.PositiveX,0,0,s,s,0,i),t.getPixelBuffer(R.NegativeX,0,0,s,s,0,a),t.getPixelBuffer(R.PositiveY,0,0,s,s,0,o),t.getPixelBuffer(R.NegativeY,0,0,s,s,0,h),t.getPixelBuffer(R.PositiveZ,0,0,s,s,0,l),t.getPixelBuffer(R.NegativeZ,0,0,s,s,0,f);const b=await D.calculateSHFromTextureCube(i,a,o,h,l,f,s),u=new Float32Array(b);return Tt(u),n.copyFromArray(u),n}}function j(r){const t=r&32768?-1:1,n=r>>10&31,e=r&1023;return n===31?e===0?t*(1/0):NaN:n===0?t*2**-14*(e/1024):t*2**(n-15)*(1+e/1024)}function Z(r,t,n,e){const s=r[0],i=r[1],a=r[2],o=t[0]*n,h=t[1]*n,l=t[2]*n,f=.282095,b=-.488603*i,u=.488603*a,c=-.488603*s,m=1.092548*(s*i),d=-1.092548*(i*a),g=.315392*(3*a*a-1),w=-1.092548*(s*a),S=.546274*(s*s-i*i);e[0]+=o*f,e[1]+=h*f,e[2]+=l*f,e[3]+=o*b,e[4]+=h*b,e[5]+=l*b,e[6]+=o*u,e[7]+=h*u,e[8]+=l*u,e[9]+=o*c,e[10]+=h*c,e[11]+=l*c,e[12]+=o*m,e[13]+=h*m,e[14]+=l*m,e[15]+=o*d,e[16]+=h*d,e[17]+=l*d,e[18]+=o*g,e[19]+=h*g,e[20]+=l*g,e[21]+=o*w,e[22]+=h*w,e[23]+=l*w,e[24]+=o*S,e[25]+=h*S,e[26]+=l*S}function F(r,t){return Math.atan2(r*t,Math.sqrt(r*r+t*t+1))}function Y(r,t,n){const e=1/r,s=(t+.5)*2*e-1,i=(n+.5)*2*e-1,a=s-e,o=i-e,h=s+e,l=i+e;return F(a,o)-F(a,l)-F(h,o)+F(h,l)}function I(r,t){return t*(t+1)+r}function K(r,t){if(r===0)return 1;if(r>=t)return 0;let n=Math.PI*r/t;return n=Math.sin(n)/n,Math.pow(n,4)}function _t(r,t){const n=-r[1],e=r[2],s=-r[0],i=-t[0][1]*n+t[0][2]*e+-t[0][0]*s,a=-t[1][1]*n+t[1][2]*e+-t[1][0]*s,o=-t[2][1]*n+t[2][2]*e+-t[2][0]*s;return[i,a,o]}function Lt(r,t){const n=1.7320508076,e=Math.SQRT1_2;function s(u,c,m){return[c*u,-(c*m),1/(2*n)*(3*m*m-1),-(m*u),.5*(u*u-c*c)]}const i=t[0],a=t[1],o=t[2],h=[s(i[0],i[1],i[2]),s(o[0],o[1],o[2]),s(e*(i[0]+a[0]),e*(i[1]+a[1]),e*(i[2]+a[2])),s(e*(i[0]+o[0]),e*(i[1]+o[1]),e*(i[2]+o[2])),s(e*(a[0]+o[0]),e*(a[1]+o[1]),e*(a[2]+o[2]))],l=[[0,1,2,0,0],[-1,0,0,0,-2],[0,n,0,0,0],[1,1,0,-2,0],[2,1,0,0,0]],f=[0,0,0,0,0];for(let u=0;u<5;u++)for(let c=0;c<5;c++)f[u]+=l[u][c]*r[c];const b=[0,0,0,0,0];for(let u=0;u<5;u++)for(let c=0;c<5;c++)b[u]+=h[u][c]*f[c];return b}function Bt(r){const t=1.7724538509,n=1.7320508076,e=2.2360679775,s=3.8729833462,i=[1/(2*t),-n/(2*t),n/(2*t),-n/(2*t),s/(2*t),-s/(2*t),e/(4*t),-s/(2*t),s/(4*t)],a=Math.sqrt(r[3]*r[3]+r[1]*r[1]+r[2]*r[2]);if(a<1e-8)return i[0]*r[0];const o=-r[3]/a,h=-r[1]/a,l=r[2]/a,f=-o,b=-h,u=-l;let c=u,m=0,d=-f;const g=Math.sqrt(c*c+d*d);g<1e-8?(c=1,m=0,d=0):(c/=g,d/=g);const w=m*u-d*b,S=d*f-c*u,O=c*b-m*f,x=[[c,w,-f],[m,S,-b],[d,O,-u]],_=_t([r[1],r[2],r[3]],x),L=Lt([r[4],r[5],r[6],r[7],r[8]],x),y=[r[0],_[0],_[1],_[2],L[0],L[1],L[2],L[3],L[4]],X=i[8]*Math.sqrt(y[8]*y[8]+y[4]*y[4]),B=3*i[6]*y[6]+X,T=i[2]*y[2],H=i[0]*y[0]-i[6]*y[6]-X,C=-T/(2*B),$=B*C*C+T*C+H,G=Math.min(B+T+H,B-T+H),J=B>0&&C>=-1&&C<=1?$:G,v=i[4]*Math.sqrt(y[5]*y[5]+y[7]*y[7]);let U=J-.5*v;if(U<0){const W=p=>B*p*p+T*p+H+v*p*Math.sqrt(1-p*p),tt=p=>{const P=p*p,et=Math.sqrt(1-P);return(P-1)*(v-2*v*P+(T+2*B*p)*et)/(3*v*p-2*v*P*p-2*B*Math.pow(1-P,1.5))};let M=-Math.SQRT1_2,q;do U=W(M),q=tt(M),M=M-q;while(Math.abs(M)<=1&&Math.abs(q)>1e-5);Math.abs(M)>1&&(U=Math.min(W(1),W(-1)))}return U}function At(r,t){const e=r.slice();for(let s=0;s<3;s++){const i=K(s,t);e[I(0,s)]*=i;for(let a=1;a<=s;a++)e[I(-a,s)]*=i,e[I(a,s)]*=i}return e}function Tt(r){let n=13;for(let e=0;e<3;e++){const s=[];for(let o=0;o<9;o++)s[o]=r[o*3+e];let i=3,a=n;for(let o=0;o<16&&i+.1<a;o++){const h=.5*(i+a),l=At(s,h);Bt(l)<0?a=h:i=h}n=Math.min(n,i)}for(let e=0;e<3;e++){const s=K(e,n);for(let i=-e;i<=e;i++){const a=I(i,e);r[a*3]*=s,r[a*3+1]*=s,r[a*3+2]*=s}}}function V(r,t){const n=r;n[0]*=t,n[1]*=t,n[2]*=t,n[3]*=t,n[4]*=t,n[5]*=t,n[6]*=t,n[7]*=t,n[8]*=t,n[9]*=t,n[10]*=t,n[11]*=t,n[12]*=t,n[13]*=t,n[14]*=t,n[15]*=t,n[16]*=t,n[17]*=t,n[18]*=t,n[19]*=t,n[20]*=t,n[21]*=t,n[22]*=t,n[23]*=t,n[24]*=t,n[25]*=t,n[26]*=t}function A(r,t,n,e,s){const a=[],o=[];let h=e;for(let l=0;l<n;l++)for(let f=0;f<n;f++){const b=l*n*4+f*4;a[0]=j(r[b]),a[1]=j(r[b+1]),a[2]=j(r[b+2]);const u=1/n,c=(f+.5)*2*u-1,m=(l+.5)*2*u-1;switch(t){case 0:o[0]=1,o[1]=-m,o[2]=-c;break;case 1:o[0]=-1,o[1]=-m,o[2]=c;break;case 2:o[0]=c,o[1]=1,o[2]=m;break;case 3:o[0]=c,o[1]=-1,o[2]=-m;break;case 4:o[0]=c,o[1]=-m,o[2]=1;break;case 5:o[0]=-c,o[1]=-m,o[2]=-1;break}const d=o[0]*o[0]+o[1]*o[1]+o[2]*o[2],g=Math.sqrt(d);o[0]/=g,o[1]/=g,o[2]/=g;const w=Y(n,f,l);h+=w,Z(o,a,w,s)}return h}class N{static update(t,n){this.entity?this.entity.isActive=!0:this.initScene(t);const e=t.scene;e&&(this._scene=e,this.preAmbientLight=e.ambientLight,e.ambientLight=n.engineObject)}static clear(){this.entity.isActive=!1,this._scene&&(this._scene.ambientLight=this.preAmbientLight,this._scene=null)}static initScene(t){const{engine:n}=t,s=(this.entity=t.createChild("material")).addComponent(rt);s.mesh=ot.createSphere(n,2,64,!0);const i=new it(n);i.roughness=.5,i.metallic=.5,s.setMaterial(i)}}k(N,"entity",null),k(N,"preAmbientLight"),k(N,"_scene");var vt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,Rt=(r,t,n,e)=>{for(var s=e>1?void 0:e?Mt(t,n):t,i=r.length-1,a;i>=0;i--)(a=r[i])&&(s=(e?a(t,n,s):a(s))||s);return e&&s&&vt(t,n,s),s};const xt=1;let z=class extends at{constructor(t){super(t);k(this,"_sh",new E);k(this,"_bakerData")}async bakeFromScene(t){const n=this.root.sceneStore.engineObject,e=Q.fromScene(n,this.root.sceneStore.bakerResolution);await this._applyBakeResult(t,e,e)}async bakeFromTexture(t){const n=Q.fromTextureCubeMap(t,this.root.sceneStore.bakerResolution,ct.Linear);await this._applyBakeResult(t.engine,n,t)}async _applyBakeResult(t,n,e){const s=this._sh;if(await St.fromTextureCube(e,s),this._bakerData=ut(n,s),!this.engineObject){const a=new ht(t);a.diffuseMode=lt.SphericalHarmonics,this.bindEngineObject(a)}const i=this.engineObject;i.specularTexture=n,i.diffuseSphericalHarmonics=s}async initByCreation(t,n,e){return(e==null?void 0:e.from)==="Scene"?await this.bakeFromScene(this.engine):(e==null?void 0:e.from)==="Texture"&&await this.bakeFromTexture(e.srcTexture),this.getMainData()}async initByMain(t,n){const e=await t.arrayBuffer();if(!ft(e,xt)){this.root.sceneStore.bake();return}const s=await this.engine.resourceManager.load({url:n,type:mt.AmbientLight});this.bindEngineObject(s),this._bakerData=e}getMainData(){return this._bakerData}};z=Rt([pt({type:"AmbientLight",label:bt("asset.ambient-light.title"),loaderType:"AmbientLight",defaultName:"ambient_light.ambLight",extname:"ambLight",thumbnail:N,async bundle({content:r},t){if(t.assetOptions.textureOptions.textureType==="ktx2")try{const e=await r.arrayBuffer(),i=dt.decode(e).headerLength,a=27*4,o=i+a,h=new Uint8Array(e,o,4);if(h[0]===171&&h[1]===75&&h[2]===84&&h[3]===88)return{content:r};const l=new E;l.copyFromArray(new Float32Array(e,i,27));const f=new Uint16Array(e,o,1)[0],b=Math.floor(Math.log2(f))+1;let u=o+2;const c=[];for(let g=0;g<b;g++){const w=f>>g,S=[];for(let O=0;O<6;O++){const x=w*w*4,_=new Uint16Array(e,u,x);u+=x*2;const L=new Uint8Array(_.byteLength);L.set(new Uint8Array(_.buffer,_.byteOffset,_.byteLength)),S.push(L.buffer)}c.push(S)}const m=await wt.encode(c,{isUASTC:!0,isHDR:!0,imageType:yt.RGBAHalfFloat,width:f,height:f,generateMipmap:!1,isPerceptual:!1,isSetKTX2SRGBTransferFunc:!1,needSupercompression:!0}),d=gt(l,m);return{content:new Blob([d])}}catch(e){console.error("AmbientLight KTX2 encoding failed, fallback to raw:",e)}return{content:r}}})],z);export{z as AmbientLightAsset};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ht=Object.defineProperty;var ut=(_,t,n)=>t in _?ht(_,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):_[t]=n;var g=(_,t,n)=>(ut(_,typeof t!="symbol"?t+"":t,n),n);import{aT as X,aD as V,b8 as yt,e as j,cX as et,cH as dt,aV as mt,aH as ft,aK as gt,o as st,S as ot,u as D,J as E,bb as Pt,be as _t,bC as vt,bA as bt,O as Ct,cY as Tt,cQ as wt,cZ as Et,c_ as At,c$ as St,$ as xt,a1 as Mt,d0 as Vt,d1 as It,d2 as Ot,d3 as jt,d4 as Rt,d5 as Bt,d6 as Ft,d7 as Dt,d8 as Lt,d9 as $t,da as Kt,db as Nt,dc as kt,dd as zt,w as y,de as Ut,cO as I,df as Ht,dg as Gt,dh as Jt,di as Qt,dj as Wt,dk as qt,dl as Yt,dm as Xt,dn as Zt,dp as te,dq as ee,j as re,dr as O,ds as H,bT as W,dt as x,cb as q,du as ne,dv as rt,aw as ae,dw as se,am as nt,dx as F,H as at,dy as oe,X as ie,dz as pe,aA as ce,aB as le,V as he,I as ue,x as ye,dA as G,cR as de,m as me,b0 as fe,bp as ge,dB as Pe}from"./index-0a8702e2.js";import{b as it,a as _e,A as ve}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import{A as be}from"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as Ce}from"./AssetViewer-bc198e16.js";import{o as Te}from"./assetEditorActions-c4e5962f.js";import{e as pt}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{L as we}from"./module-6406b050.js";import{a as Ee}from"./module-107b7430.js";import{n as Y}from"./index-be6bc38a.js";const Ae=X(()=>{const _=it("animationClipStore"),{selectedEvent:t}=_,{paramType:n}=t;return V.jsxs("div",{children:[V.jsx(yt,{label:j("animation.clip.param-type.title"),options:[{value:"string",label:String(j("animation.clip.param-type.string"))},{value:"number",label:String(j("animation.clip.param-type.number"))},{value:"null",label:String(j("animation.clip.param-type.null"))}],value:n||"null",onChange:r=>{t.paramType=r,_.updateEvents([t])}}),V.jsx(et,{label:j("animation.clip.function-name"),value:t.functionName,onChange:r=>{t.functionName=r,_.updateEvents([t])}}),n==="number"&&V.jsx(dt,{label:j("animation.clip.number"),value:t.number,onChange:r=>{t.number=r,_.updateEvents([t])}}),n==="string"&&V.jsx(et,{label:j("animation.clip.string"),value:t.string,onChange:r=>{t.string=r,_.updateEvents([t])}})]})}),Se=X(function(){const t=it("animationClipStore"),{selectedEvent:n}=t;return n?V.jsx(mt,{title:j("animation.clip.event"),defaultOpen:!0,children:V.jsx(V.Fragment,{children:V.jsx(Ae,{})})}):null});var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,N=(_,t,n,r)=>{for(var e=r>1?void 0:r?Me(t,n):t,a=_.length-1,o;a>=0;a--)(o=_[a])&&(e=(r?o(t,n,e):o(e))||e);return r&&e&&xe(t,n,e),e};const Ve=ft(gt,{position:"absolute",top:0,left:0,margin:"auto",width:"100%",height:228,alignItems:"center",justifyContent:"center"});class $ extends Ce{constructor(){super();g(this,"frameTime",0);g(this,"duration",0);g(this,"playing",!1);g(this,"_clip");g(this,"_updateComponent");g(this,"animationNames");g(this,"overridePreviewer",X(({asset:n,viewer:r})=>V.jsx(V.Fragment,{children:n.isSubAsset||n.root.sceneUIStore.lastSelectedId?V.jsx(be,{asset:n,viewer:r}):V.jsx(Ve,{children:V.jsx(V.Fragment,{children:j("animation.clip.select-entity-preview")})})})));st(this)}selectAnimation(n){}async setViewAsset(n,r){var o,s;let e;if(n.isSubAsset){const i=await n.root.assetStore.getAssetByRef({refId:n.mainId}),{defaultSceneRoot:c}=i.engineObject;e=((o=n.root.sceneStore.lastSelectedEntity)==null?void 0:o.engineObject)||c}else e=(s=n.root.sceneStore.lastSelectedEntity)==null?void 0:s.engineObject;if(!e)return;this._clip=n.engineObject,this.animationNames=[n.name],this._entity=e.clone(),r.addChild(this._entity);const a=this;this._updateComponent=this._entity.addComponent(class extends ot{onUpdate(i){a._onUpdate(100/3)}}),this.frameTime=0,this.duration=this._clip.length}stopViewAsset(){var n;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(n=this._updateComponent)==null||n.destroy()}setFrameTime(n){this.frameTime=n,this._sampleAnimation()}playAnimation(){this._clip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(n){!this.playing||!this._clip||!this.duration||(this.frameTime+=n/1e3,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this._clip._sampleAnimation(this._entity,this.frameTime)}catch(n){console.warn(n)}}}N([D],$.prototype,"frameTime",2);N([D],$.prototype,"duration",2);N([D],$.prototype,"playing",2);N([E],$.prototype,"setViewAsset",1);N([E],$.prototype,"setFrameTime",1);N([E],$.prototype,"playAnimation",1);N([E],$.prototype,"pauseAnimation",1);N([E],$.prototype,"_onUpdate",1);const K=new Map([[Pt,"Transform"],[_t,"Animator"],[vt,"DirectLight"],[bt,"Camera"],[Ct,"MeshRenderer"],[Tt,"SkinnedMeshRenderer"],[wt,"ParticleRenderer"],[Et,"PointLight"],[At,"SpotLight"],[ot,"Script"],[St,"SpriteMask"],[xt,"SpriteRenderer"],[Mt,"TextRenderer"],[Vt,"UITransform"],[It,"UICanvas"],[Ot,"UIGroup"],[jt,"Button"],[Rt,"Image"],[Bt,"Text"],[Ft,"DynamicCollider"],[Dt,"StaticCollider"],[Lt,"CharacterController"],[$t,"SpringJoint"],[Kt,"FixedJoint"],[Nt,"HingeJoint"],[kt,"AudioSource"],[zt,"PostProcess"],[Ee,"SpineAnimationRenderer"],[we,"LottieAnimation"]]);var Ie=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,T=(_,t,n,r)=>{for(var e=r>1?void 0:r?Oe(t,n):t,a=_.length-1,o;a>=0;a--)(o=_[a])&&(e=(r?o(t,n,e):o(e))||e);return r&&e&&Ie(t,n,e),e};const Z=new Map([[y.Float,{curveClass:Ut,name:"AnimationFloatCurve",defaultInterpolation:I.Hermite}],[y.FloatArray,{curveClass:Ht,name:"AnimationFloatArrayCurve",defaultInterpolation:I.Hermite}],[y.Vector2,{curveClass:Gt,name:"AnimationVector2Curve",defaultInterpolation:I.Hermite}],[y.Vector3,{curveClass:Jt,name:"AnimationVector3Curve",defaultInterpolation:I.Hermite}],[y.Vector4,{curveClass:Qt,name:"AnimationVector4Curve",defaultInterpolation:I.Hermite}],[y.Quaternion,{curveClass:Wt,name:"AnimationQuaternionCurve",defaultInterpolation:I.Hermite}],[y.Color,{curveClass:qt,name:"AnimationColorCurve",defaultInterpolation:I.Hermite}],[y.ReferResource,{curveClass:Yt,name:"AnimationRefCurve",defaultInterpolation:I.Step}],[y.Rect,{curveClass:Xt,name:"AnimationRectCurve",defaultInterpolation:I.Step}],[y.Boolean,{curveClass:Zt,name:"AnimationBoolCurve",defaultInterpolation:I.Step}],[y.String,{curveClass:te,name:"AnimationStringCurve",defaultInterpolation:I.Step}],[y.Array,{curveClass:ee,name:"AnimationArrayCurve",defaultInterpolation:I.Hermite}]]),ct=new Map;Z.forEach((_,t)=>{ct.set(_.curveClass,t)});const lt=new Map;Z.forEach(_=>{lt.set(_.curveClass,_.name)});let C=class extends re{constructor(t){super(t);g(this,"samples",60);g(this,"properties",[]);g(this,"pathPropertyMap",new Map);g(this,"keyframeDataList",[]);g(this,"events",{});g(this,"data");g(this,"selectedEventId");g(this,"rootEntityId");g(this,"showEditor");g(this,"readOnly",!1);g(this,"_propertyCurveMap",{});g(this,"_originValueStore",new Map);g(this,"_initKeyframeDataPromise");g(this,"_parseKeyframeValuePromise");g(this,"_colorList",["#3477FA","#67FEBB","#C201BF","#F6ED17","#FE6C02","#FD86C2","#A2B44B","#68D8F0","#008225","#A56A02"]);g(this,"_colorIndex",0);g(this,"_openIndex",0);g(this,"_componentsChangedListenerDisposer");g(this,"_propertyPathCache",new Map);g(this,"_propertyLabelMap",new Map);g(this,"_editorPathCache",new Map);st(this),this.onDoubleClick=this.onDoubleClick.bind(this)}get rootEntity(){return this.root.sceneStore.entities.get(this.rootEntityId)}get addedPropertiesTreeData(){return this.properties.map(t=>this._convertPropertyToTreeItem(t))}persistMainViaFacade(){this.root.assetFacade.persistAssetMain(this.id)}persistMetaViaFacade(){this.root.assetFacade.persistAssetMeta(this.id)}addProperty(t){const{type:n,parentProperty:r}=t,e=F(t),a=this.pathPropertyMap.get(e),o=this.properties;let s;if(a)Y.error(j("animation.clip.error.property-existed"));else{if(n===O.Property)s=this._addPropertyToList(o,t,null);else{const i=o.find(c=>c.propertyPath===r.propertyPath&&c.relativePath===r.relativePath&&c.componentType===r.componentType);if(i)i.properties.find(p=>p.path===e)?Y.error(j("animation.clip.error.sub-property-existed")):s=this._addPropertyToList(i.properties,t,i);else{const c=this._addPropertyToList(o,r,null,!1);s=this._addPropertyToList(c.properties,t,c)}}return this._sortProperties(),this.properties=o.slice(0),this._updateCurveBindings(),this.persistMetaViaFacade(),this.persistMainViaFacade(),s}}delProperty(t){const n=new Set;t.forEach(r=>{if(n.add(r.path),this.pathPropertyMap.delete(r.path),r.type===O.Property)r.properties.forEach(e=>{n.add(e.path),this.pathPropertyMap.delete(e.path)}),this._delPropertyFromList(this.properties,r);else{const e=this.properties.find(a=>a.path===r.parentPath);e&&(this._delPropertyFromList(e.properties,r),e.hasSubProperty&&!e.properties.length&&this._delPropertyFromList(this.properties,e))}}),this._sortProperties(),this.properties=this.properties.slice(0),this._removeCurveBindings(n),this._updateCurveBindings(),this.updateKeyframes(this.keyframeDataList.filter(r=>!n.has(r.path))),this.persistMetaViaFacade(),this.persistMainViaFacade()}async addKeyframe(t,n){const{rootEntity:r}=this,e=this.pathPropertyMap.get(n),{type:a,path:o,parentPath:s,properties:i,supported:c}=e;if(!c){Y.error(j("animation.clip.error.property-not-supported"));return}const p=a===O.SubProperty?this.pathPropertyMap.get(s):null,{editorReference:h,editorPropertyPath:u,propertyPos:d}=await this._getReferenceAndActualPropertyPath(r,e),l=u[d],m=H(h)[l];let f=h[l];m!=null&&m.getActualEditorValue&&(f=m.getActualEditorValue(f));let A=e.valueType;a===O.Property&&(m!=null&&m.valueType)&&(A=m.valueType),a===O.SubProperty&&(f=f[u[d+1]]);const P=W(f);if(i.length)i.forEach(b=>{const{path:v}=b,w=P[b.name],S=this.keyframeDataList.find(M=>M.path===v&&M.frame===t);if(S)S.value=w,S.inTangentMode=x.Linear,S.outTangentMode=x.Linear;else{const M=this._createKeyframeData(t,w,b.valueType,void 0,void 0,b,e);this.keyframeDataList.push(M)}});else{const b=this.keyframeDataList.find(v=>v.path===o&&v.frame===t);if(b)b.value=P,b.inTangent=void 0,b.outTangent=void 0;else{const v=this._createKeyframeData(t,P,A,void 0,void 0,e,a===O.SubProperty?p:null);this.keyframeDataList.push(v)}}this.updateKeyframes(this.keyframeDataList)}addKeyframeByRecording(t,n){const r=this._ensurePropertyExists(n);r&&this.addKeyframe(t,r.path)}deleteKeyframes(t){t.forEach(n=>{const r=this.keyframeDataList.indexOf(n);r>-1&&this.keyframeDataList.splice(r,1)}),this.updateKeyframes(this.keyframeDataList)}updateKeyframes(t,n=!0){const r={};t.length&&t.sort((e,a)=>e.frame-a.frame),t.forEach(e=>{const a=e.path;r[a]??(r[a]=[]),r[a].push(e),r[a].sort((o,s)=>o.frame-s.frame)});for(const e in r)for(let a=0,o=r[e].length;a<o;++a){const s=r[e][a];if(s.interpolationType===I.Step)continue;const i=r[e][a-1],c=r[e][a+1];s.isFirst=a===0,s.isLast=a===o-1,a>0&&(s.frame-i.frame===0?s.linearInTangent=0:s.linearInTangent=(s.value-i.value)/((s.frame-i.frame)/this.samples),s.inTangent=s.inTangentMode===x.Linear?s.linearInTangent:s.inTangent,isNaN(s.inTangent)&&(s.inTangent=-1/0)),a<o-1&&(c.frame-s.frame===0?s.linearOutTangent=0:s.linearOutTangent=(c.value-s.value)/((c.frame-s.frame)/this.samples),s.outTangent=s.outTangentMode===x.Linear?s.linearOutTangent:s.outTangent,isNaN(s.outTangent)&&(s.outTangent=-1/0))}this.keyframeDataList=t.slice(0),this.isSubAsset||(this._generateEngineKeyframes(t),n&&this.persistMainViaFacade())}addEvent(t){const n={id:q(),time:t/this.samples,functionName:"onEvent"};this.events[n.id]=n,this.updateEvents(this.events)}deleteEvent(t){delete this.events[t.id],this.updateEvents(this.events)}updateEvents(t,n=!0){const r=this.engineObject;if(this.events={...t},r.clearEvents(),Object.values(this.events).map(e=>{const a=e.paramType==="string"?e.string:e.number;r.addEvent(e.functionName,e.time,a)}),this.data.events=Object.values(this.events).map(e=>({time:e.time,functionName:e.functionName,parameter:e.paramType==="string"?e.string:e.number})),n){const{isSubAsset:e}=this;if(e){const{assets:a}=this.root.assetStore,o=a[this.mainId];if(o){const s=o.engineObject.animations.indexOf(this._engineObject);o.updateAnimationEvents(s,this.data.events)}}this.persistMainViaFacade()}}updateSamples(t){this.samples=+t.toFixed(0)}updateRootEntity(t){if(!(!t||t.id===this.rootEntityId)){if(this.rootEntityId=t.id,this.engineObject){this._clearPropertyMappings();const n=this._init().then(async()=>{await this._generateKeyframeDataList(),await this._updateCurveBindings(),this.showEditor&&(await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}).catch(r=>{console.warn("AnimationClipAsset:updateRootEntity rebuild failed",this.name,r)});this._initKeyframeDataPromise=n}this._listenRootEntityChanged(),this.persistMetaViaFacade()}}setTangentMode(t,n,r){t.forEach(e=>{if(n===ne.In)switch(e.inTangentMode=r,r){case x.Linear:e.inTangent=e.linearInTangent;break;case x.Constant:e.inTangent=-1/0;break;case x.Free:break}else switch(e.outTangentMode=r,r){case x.Linear:e.outTangent=e.linearOutTangent;break;case x.Constant:e.outTangent=-1/0;break;case x.Free:break}}),this.persistMetaViaFacade(),this.updateKeyframes(this.keyframeDataList)}async checkPropertiesSupport(t){const{properties:n}=this;let r=!1;const e=n.map(async a=>{const o=!!a.supported,{editorReference:s}=await this._getReferenceAndActualPropertyPath(t,a);s?a.supported=!0:a.supported=!1,!o&&a.supported&&(r=!0)});await Promise.all(e),r&&(this.properties=this.properties.slice(0),await this._generateKeyframeDataList(),this.updateKeyframes(this.keyframeDataList,!1),await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}updateSelectedEvent(t){this.selectedEventId=t}async openEditor(t){if(t&&!this.showEditor){this._initKeyframeDataPromise||(this._initKeyframeDataPromise=this._generateKeyframeDataList()),this.showEditor=t,this.root.projectStore.animationEditing=t;const n=++this._openIndex;if(await this._initKeyframeDataPromise,n!==this._openIndex)return;this.saveEditorOriginValue(),this.sampleAnimation(this.root.animationClipStore.currentFrame),rt()}!t&&this.showEditor&&(this.showEditor=t,this.root.projectStore.animationEditing=t,this.revertValue())}async sampleAnimation(t){const n=this.rootEntity;if(n){const r=n.engineObject;try{await this._parseKeyframeValuePromise,this.engineObject._sampleAnimation(r,t/this.samples),this._syncToEditor()}catch(e){console.warn(e)}}}async saveEditorOriginValue(){const{_originValueStore:t}=this,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:o,property:s}=e,i=K.get(o),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:i,propertyPath:s});if(!c)return;const u=p[h];if(!t.has(e)){let d=u;u==="rotationQuaternion"&&(d="rotation"),t.set(e,W(c[d]))}});await Promise.all(r)}async revertValue(){const{_originValueStore:t}=this,n=Array.from(t).map(async([r,e])=>{const{relativePath:a,type:o,property:s}=r,i=K.get(o),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:i,propertyPath:s});if(!c)return;const u=p[h];let d=u;u==="rotationQuaternion"&&(d="rotation"),this._setEditorValue(c,d,e)});await Promise.all(n),t.clear()}async initByMain(t){const{engine:n,meta:r}=this;r.rootEntityId&&(this.rootEntityId=r.rootEntityId),this._listenRootEntityChanged();try{const e=JSON.parse(await t.text()),a=pt(e,{type:"AnimationClip",name:e.name}),o=await ae(a,n);this.bindEngineObject(o),await this._init()}catch(e){console.error(`[AnimationClipAsset] Failed to load "${this.name}"`,e)}}async initByEngineObject(t){this.bindEngineObject(t),this._name=t.name,await this._init()}async initByCreation(t,n){this.setNameByIncrease(n||"AnimationClip");const r=new se(this.name);return this.bindEngineObject(r),this.data={name:this.name,curveBindings:r.curveBindings,events:[]},await this._init(),this.getMainData()}_clearPropertyMappings(){this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyPathCache.clear(),this._propertyLabelMap.clear(),this._editorPathCache.clear(),this.properties.length=0,this._colorIndex=0,this._originValueStore.clear()}_sortProperties(){this.properties.sort((t,n)=>(t.level??0)-(n.level??0))}async _init(){const t=this.engineObject;this._clearPropertyMappings();const r=(await this._groupCurveBindingsByParent(t.curveBindings)).map(async a=>{if(await this._generatePropertiesFromBindingGroup(a),this.isSubAsset)return Promise.resolve();const o=a.bindings.flatMap(s=>{const{curve:i}=s;return i.keys.map(c=>this._editorValueToEngineValue(c.value,this._getValueTypeByCurve(i)).then(p=>{c.value=p}))});return Promise.all(o)});if(!this.isSubAsset){const{properties:a,pathPropertyMap:o}=this;a.forEach(s=>{s.properties.length||this._colorIndex++,o.set(s.path,s),s.properties.forEach(i=>{this._colorIndex++,o.set(i.path,i)})})}await Promise.all(r),this._sortProperties();const e={};t.events.forEach(a=>{const o=q(),s=a.parameter?typeof a.parameter:"null";e[o]={id:o,time:a.time,functionName:a.functionName,paramType:s,string:s==="string"?a.parameter:void 0,number:s==="number"?a.parameter:void 0}}),this.data={name:t.name,curveBindings:t.curveBindings,events:[]},this.updateEvents(e,!1)}async onDoubleClick(){Te(this.root,"AnimationClip",{afterOpen:()=>{rt()}})}getMainData(){const t=this.data,n={...t,curveBindings:t.curveBindings.map(r=>{const{curve:e}=r,a=lt.get(e.constructor);return{...r,type:K.get(r.type)||r.type,curveType:a,curve:{interpolation:e.interpolation,keys:e.keys.map(o=>{const s=o.value,i=s instanceof nt?this.root.assetStore.engineObjectToAssetMap.get(s).getCurrentRef():s;return{...o,value:W(i)}})}}})};return JSON.stringify(n)}async _syncToEditor(){const t=this.rootEntity,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:o,property:s,getProperty:i}=e,c=K.get(o);if(!e.curve.keys.length)return;const p=await this._getActualPropertyPath(i??s,a,c),{editorReference:h,engineGetReference:u,editorPropertyPath:d,enginePropertyGetPath:l,propertyPos:m}=await this._getReferenceAndActualPropertyPath(t,{relativePath:a,componentType:c,propertyPath:p});if(!u||!h)return;const f=F({relativePath:a,componentType:c,propertyPath:d.slice(0,m+1).join(".")}),A=this.pathPropertyMap.get(f);let P=d[m],b=this._getEngineValue(u,l[m]),v=A.valueType;P==="rotationQuaternion"&&(P="rotation",b=b.toEuler(new at).scale(180/Math.PI),v=y.Vector3);const w=this._engineValueToEditorValue(b,v,!1);this._setEditorValue(h,P,w)});await Promise.all(r)}async _setEditorValue(t,n,r){var o,s;const e=(o=oe(t))==null?void 0:o[n],a=(s=H(t))==null?void 0:s[n];if(a!=null&&a.getEditorValue&&(r=a.getEditorValue(r)),a!=null&&a.setActualEditorValue?a==null||a.setActualEditorValue(t,n,r):t[n]=r,e!=null&&e.onChange){const i=r!=null&&r.refId?await t.root.assetStore.getAssetByRef(r):r;await e.onChange(t,n,i)}}_removeCurveBindings(t){const n=this.engineObject;if(!n)return;const r=new Set;for(const e of t){const a=this._propertyCurveMap[e];a&&(r.add(a),delete this._propertyCurveMap[e])}if(r.size>0){const e=n.curveBindings;for(let a=e.length-1;a>=0;a--){const o=e[a];r.has(o.curve)&&(e.splice(a,1),this._originValueStore.delete(o))}}}async _updateCurveBindings(){var n;const t=this.rootEntity;if(t)for(const r of this.properties)try{const{relativePath:e,componentType:a,valueType:o,properties:s,interpolationType:i}=r,c=F(r),p=await this._getReferenceAndActualPropertyPath(t,r),{editorReference:h,enginePropertySetPath:u,enginePropertyGetPath:d,editorPropertyPath:l,propertyPos:m}=p||{};if(!h||!u||!d||m===void 0)continue;const f=l[m],A=(n=H(h))==null?void 0:n[f],P=u.join("."),b=d.join(".");if(s.length)for(const v of s){const w=F(v),S=this._createCurve(w,v.valueType,v.interpolationType),M=v.name;await this._addCurveBinding(e,a,`${P}.${M}`,`${b}.${M}`,S),this._propertyCurveMap[w]=S}else{let v=o;A!=null&&A.valueType&&(v=A.valueType);const w=this._createCurve(c,v,i);await this._addCurveBinding(e,a,P,b,w),this._propertyCurveMap[c]=w}}catch(e){console.warn("updateCurveBindings skipped property (unresolved):",r==null?void 0:r.propertyPath,e);continue}}_createCurve(t,n,r){let e=this._propertyCurveMap[t];if(!e){const a=Z.get(n);a?(e=new a.curveClass,e.interpolation=r??a.defaultInterpolation):console.warn(`Unsupported curve value type: ${n}`)}return e}async _addCurveBinding(t,n,r,e,a){const o=ie.getClass(n),s=this.engineObject;let i=!0;for(let c=0,p=s.curveBindings.length;c<p;++c){const h=s.curveBindings[c];h.relativePath===t&&h.type===o&&h.property===r&&h.getProperty===e&&(h.curve=a,i=!1)}i&&(s.addCurveBinding(t,o,r,e,a),await this.saveEditorOriginValue())}_addPropertyToList(t,n,r,e=!0){var i;const a=this._covertToPropertyData(n,r),o=t.push(a),s=t[o-1];return this.pathPropertyMap.set(s.path,s),e&&((i=n.children)!=null&&i.length)&&n.children.forEach(c=>{this._addPropertyToList(s.properties,c,s,e)}),s}_delPropertyFromList(t,n){const r=t.findIndex(e=>e.path===n.path);r>-1&&(t.splice(r,1),this.pathPropertyMap.delete(n.path))}_covertToPropertyData(t,n){const{name:r,label:e,relativePath:a,componentType:o,propertyPath:s,type:i,valueType:c,interpolationType:p,children:h}=t,u=F(t),d=F(n),l=a.split("/").length-1;return{name:e||r,level:l,path:u,type:i,valueType:c,interpolationType:p,propertyPath:s,componentType:o,relativePath:a,hasSubProperty:h.length>0,curveColor:c===y.Float?this._getRandomColor():null,supported:!0,properties:[],parentPath:d}}async _getReferenceAndActualPropertyPath(t,n){if(!t)return{};const{relativePath:r,componentType:e,propertyPath:a}=n,o=t.findByPath(r);if(!o)return{};const s=o.getComponentByTypeName(e);if(!s)return{};const i=[],c=[],p=[],h=a.split("."),u=h.length-1;let d=-1,l=s;for(let P=0,b=u;P<=b;++P){const v=h[P];if(!l)return{};const w=H(l);let S="",M=v,k=v,z=v,B=P;for(let R=P,J=u;R<=J;++R){S+=h[R];const Q=(w==null?void 0:w[S])||{},{getPath:U,setPath:L,editorKey:tt}=Q;L&&(k=L,B=R),(U||L)&&(R===u&&L?k=L:k=U??L,z=U??L,B=R),tt&&(M=tt,B=R),R<u&&(S+=".")}P=B,c.push(k),p.push(z),i.push(M),pe(l,M)&&(d=i.length-1),P<u&&(l=l[M],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l)))}const m=d>-1?d-1:i.length-1;l=s;for(let P=0,b=m;P<b;++P)l=l[i[P]],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l));const f=this._getEngineValue(s.engineObject,c.slice(0,m).join(".")),A=this._getEngineValue(s.engineObject,p.slice(0,m).join("."));return{editorReference:l,engineSetReference:f,engineGetReference:A,enginePropertySetPath:c,enginePropertyGetPath:p,editorPropertyPath:i,propertyPos:m,subPropertyPos:d}}_getEngineValue(t,n){if(!n)return t;let r=t;const e=n.split(".");for(let a=0,o=e.length;a<o;a++){const s=e[a];if(s.indexOf("[")>-1){const i=s.indexOf("[");r=r[s.slice(0,i)],r=r[parseInt(s.slice(i+1,-1))]}else if(s.endsWith(")")){const i=s.slice(0,s.indexOf("(")),c=s.match(/\w+\(([^)]*)\)/)[1].split(",").map(p=>p.trim().replace(/['"]+/g,"")).filter(p=>p!=="");r=r[i](...c)}else r=r[s]}return r}async _generateKeyframeDataList(){const t=this.engineObject,n=[],r=this.pathPropertyMap,e=t.curveBindings.map(async a=>{const{relativePath:o,type:s,getProperty:i,property:c,curve:p}=a,h=K.get(s),u=i??c,d=await this._convertPropertyProxyPath(u,h,o),m=F({relativePath:o,componentType:h,propertyPath:d||u});d||console.warn(`无法转换引擎路径到编辑器路径: ${u},使用原路径`);const f=r.get(m);if(!f){d&&console.warn(`转换后的路径仍未找到属性定义: ${m}, 原引擎路径: ${u}`);return}this._propertyCurveMap[m]=p;const A=f.valueType;p.keys.forEach(P=>{const{time:b,value:v,inTangent:w,outTangent:S}=P,M=Math.floor(b*this.samples),k=this._engineValueToEditorValue(v,A,!0),z=this._getSubProperties(A,p);if(z)z.forEach(B=>{const R=`${m}.${B}`,J=r.get(R),Q=w&&w[B],U=S&&S[B],L=this._createKeyframeData(M,k[B],y.Float,Q,U,J,f);n.push(L)});else{const B=r.get(f.parentPath),R=this._createKeyframeData(M,k,A,w,S,f,B);n.push(R)}})});await Promise.all(e),this.updateKeyframes(n,!1)}_createKeyframeData(t,n,r,e,a,o,s){const{path:i,curveColor:c}=o,{path:p=""}=s||{};return{id:q(),frame:t,path:i,value:n,isActive:!0,valueType:r??y.Float,curveColor:c,parentPath:p,inTangent:e,outTangent:a,interpolationType:o.interpolationType,inTangentMode:e===void 0?x.Linear:e===-1/0?x.Constant:x.Free,outTangentMode:a===void 0?x.Linear:a===-1/0?x.Constant:x.Free}}_generateEngineKeyframes(t){const{_propertyCurveMap:n,samples:r,engineObject:e}=this,a=this._groupKeyframesByPath(t),s=this._collectPathsToSync(n,a).map(i=>this._syncCurveForPath(i,n[i],a.get(i)||[],r,e));this._parseKeyframeValuePromise=Promise.all(s)}_groupKeyframesByPath(t){return t.reduce((n,r)=>{const e=n.get(r.path)||[];return e.push(r),n.set(r.path,e),n},new Map)}_collectPathsToSync(t,n){const r=new Set;return Object.keys(t).forEach(e=>r.add(e)),n.forEach((e,a)=>r.add(a)),Array.from(r)}async _syncCurveForPath(t,n,r,e,a){if(!n)return;const o=await this._convertToEngineKeyframes(r,e);this._removeObsoleteKeyframes(n,o),this._addOrUpdateKeyframes(n,o,a)}async _convertToEngineKeyframes(t,n){const r=new Map;for(const e of t){const a=e.frame/n,o=await this._editorValueToEngineValue(e.value,e.valueType);o===void 0&&e.valueType===y.ReferResource||r.set(a,{value:o,inTangent:e.inTangent,outTangent:e.outTangent})}return r}_removeObsoleteKeyframes(t,n){const r=new Set(n.keys());for(let e=t.keys.length-1;e>=0;e--){const a=t.keys[e];r.has(a.time)||t.keys.splice(e,1)}}_addOrUpdateKeyframes(t,n,r){const e=new Map;t.keys.forEach(a=>{e.set(a.time,a)});for(const[a,{value:o,inTangent:s,outTangent:i}]of n){const c=e.get(a);if(c)c.value=o,c.inTangent=s,c.outTangent=i;else{const p=new Pe;p.time=a,p.value=o,p.inTangent=s,p.outTangent=i,t.addKey(p)}a>r._length&&(r._length=a)}}async _editorValueToEngineValue(t,n){var r;switch(n){case y.ReferResource:return t!=null&&t.refId?(r=await this.root.assetStore.getAssetByRef(t))==null?void 0:r.engineObject:t;case y.Color:return new ye(t.r,t.g,t.b,t.a);case y.Vector2:return new ue(t.x,t.y);case y.Vector3:return new at(t.x,t.y,t.z);case y.Vector4:return new he(t.x,t.y,t.z,t.w);case y.Quaternion:return new le(t.x,t.y,t.z,t.w);case y.Rect:return new ce(t.x,t.y,t.width,t.height);case y.Float:return t;default:return t}}_engineValueToEditorValue(t,n,r){var a,o,s;let e;switch(n){case y.MethodParam:{if(e=[],r)for(let i=0,c=t.length;i<c;i++){const p=t[i];e[i]??(e[i]=[]);for(let h=0,u=p.length;h<u;h++){const d=p[h];e[i][h]=((a=this.root.assetStore.engineObjectToAssetMap.get(d))==null?void 0:a.getCurrentRef())??d}}else t&&t instanceof nt?e=[[((o=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:o.getCurrentRef())??t]]:t instanceof Array?e=t:e=[[t]];break}case y.ReferResource:{e=(s=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:s.getCurrentRef();break}case y.Color:{e={r:t.r,g:t.g,b:t.b,a:t.a},["r","g","b","a"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Vector2:{e={x:t.x,y:t.y},["x","y"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Vector3:{e={x:t.x,y:t.y,z:t.z},["x","y","z"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Vector4:case y.Quaternion:{e={x:t.x,y:t.y,z:t.z,w:t.w},["x","y","z","w"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Rect:{e={x:t.x,y:t.y,width:t.width,height:t.height},["x","y","width","height"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Float:{e=Math.round(t*1e3)/1e3;break}default:e=t}return e}_getValueTypeByCurve(t){return ct.get(t.constructor)}_parsePropertyPath(t){const n=this._propertyPathCache.get(t);if(n)return n;const r=t.lastIndexOf("."),e=r===-1?{parentPath:t,subProperty:null}:{parentPath:t.substring(0,r),subProperty:t.substring(r+1)};return this._propertyPathCache.set(t,e),e}_isSubPropertyName(t){return/^([xyzw]|[rgba]|width|height)$/.test(t)}async _convertPropertyProxyPath(t,n,r){try{const e=this._resolveProxyHost(n,r,t);if(!e)return null;const a=`${r}|${n}|${t}`;if(this._editorPathCache.has(a))return this._editorPathCache.get(a);const o=await this._recursiveConvert(t,e,0);return o&&o!==t&&await this._buildLabelMappingsForPath(o,r,n,e),this._editorPathCache.set(a,o??null),o}catch{const a=`${r}|${n}|${t}`;return this._editorPathCache.set(a,null),null}}async _buildLabelMappingsForPath(t,n,r,e){try{const a=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t}),o=(a==null?void 0:a.editorPropertyPath)||t.split("."),s=typeof(a==null?void 0:a.propertyPos)=="number"?a.propertyPos:o.length-1;for(let i=0;i<=s;i++){const c=o.slice(0,i+1).join("."),p=F({relativePath:n,componentType:r,propertyPath:c});if(!this._propertyLabelMap.has(p)){const h=await this._extractLabelForPartialPath(c,e);h&&this._propertyLabelMap.set(p,h)}}}catch(a){console.warn("建立标签映射失败:",a)}}async _extractLabelForPartialPath(t,n){try{const r=t.split("."),e=r[r.length-1];let a=n,o=null;for(let s=0;s<r.length;s++){const i=r[s],c=a==null?void 0:a[G];if(c&&c[i]){const p=c[i];p.label&&(o=p.label),s<r.length-1&&(a=await this._getNextObject(a,i))}else break}return o||e}catch{return t.split(".").pop()||t}}async _recursiveConvert(t,n,r){if(r>6)return t;const e=n[G];if(!e)return t;for(const[a,o]of Object.entries(e)){if(!this._isPathMatch(t,o))continue;const s=o.getPath||o.setPath;if(s){if(s.endsWith("()")&&t.startsWith(s+".")){const i=t.substring(s.length+1),c=await this._getNextObject(n,a);if(!c)return`${a}.${i}`;const p=await this._recursiveConvert(i,c,r+1);return p?`${a}.${p}`:`${a}.${i}`}return this._buildEditorPath(a,t,o)}}return t}async _getNextObject(t,n){var r;try{let e=t[n];if(!e){const a=`get${n.charAt(0).toUpperCase()+n.slice(1)}`;typeof t[a]=="function"&&(e=t[a]())}if(e!=null&&e.refId&&((r=this.root)!=null&&r.assetStore)){let a=this.root.assetStore.engineObjectToAssetMap.get(e);if(!a)try{a=await this.root.assetStore.getAssetByRef(e)}catch{return e}if(a)return a}return e}catch{return null}}_resolveProxyHost(t,n,r){try{if(!this.rootEntity)return null;const e=n?this.rootEntity.findByPath(n):this.rootEntity;if(!e)return null;const a=e.getComponentByTypeName(t);return a?r?this._resolvePropertyProxyHolder(a,r):a:null}catch(e){return console.warn(`获取代理宿主失败: ${t}, ${n}`,r,e),null}}_resolvePropertyProxyHolder(t,n){try{const r=[t];this._addRelatedObjectCandidates(t,r);for(const e of r)if(this._hasMatchingProxyConfig(e,n))return e;return t}catch(r){return console.warn(`解析 PropertyProxy 持有者失败: ${n}`,r),t}}_addRelatedObjectCandidates(t,n){try{const r=t[G];if(!r)return;const e=new Set;for(const a of Object.values(r)){const o=this._extractObjectPathFromConfig(a);o&&e.add(o)}for(const a of e){const o=this._getEngineValue(t.engineObject,a);if(o){const s=this.root.assetStore.engineObjectToAssetMap.get(o);s&&!n.includes(s)&&n.push(s)}}}catch{}}_extractObjectPathFromConfig(t){const n=t.getPath||t.setPath;if(!n)return null;const r=n.match(/^([^.]+\([^)]*\))/);return r?r[1]:null}_hasMatchingProxyConfig(t,n){const r=t[G];if(!r)return!1;for(const e of Object.values(r))if(this._isPathMatch(n,e))return!0;return!1}_isPathMatch(t,n){return n?n.getPath&&this._isExactPathMatch(t,n.getPath)||n.setPath&&this._isExactPathMatch(t,n.setPath)||n.engineKey&&t.includes(n.engineKey):!1}_isExactPathMatch(t,n){if(!n)return!1;const r=p=>p.replace(/['"`\s]/g,""),e=p=>{let h="";for(let u=0;u<p.length;u++){const d=p[u];if(d==="("){for(;u<p.length&&p[u]!==")";)u++;h+="()"}else h+=d}return h},a=p=>e(r(p).replace(/\$value/g,"value")),o=a(t),s=a(n);if(o===s||((p,h)=>p.startsWith(h+".")||p.startsWith(h+"["))(o,s))return!0;if(!n.includes(".")&&!n.includes("(")&&!n.includes("[")){const p=o.split(".");for(const h of p){const u=h.indexOf("[");if((u>=0?h.slice(0,u):h)===s)return!0}}return!1}_buildEditorPath(t,n,r){if(!r)return t;const e=r.getPath||r.setPath;if(!e)return t;if(e.endsWith("()")&&n.startsWith(e+".")){const s=n.substring(e.length+1);return`${t}.${s}`}const a=n.replace(/['"`]/g,"").replace(/\$value/g,"value"),o=e.replace(/['"`]/g,"").replace(/\$value/g,"value");if(a.includes(o))return a.replace(o,t);if(!e.includes(".")&&!e.includes("(")){const s=n.match(/\.([a-zA-Z_]\w*)$/);if(s){const i=s[1];if(i!==e)return`${t}.${i}`}}return t}_validateCurveBinding(t){const{relativePath:n,type:r,getProperty:e,property:a}=t;return K.get(r)?e??a?!0:(console.warn(`绑定缺少属性路径: ${n}`),!1):(console.warn(`未知组件类型: ${r},跳过绑定`),!1)}async _groupCurveBindingsByParent(t){const n=new Map;return await Promise.all(t.map(async r=>{if(!this._validateCurveBinding(r))return;const{relativePath:e,type:a,getProperty:o,property:s}=r,i=K.get(a),c=o??s,h=await this._convertPropertyProxyPath(c,i,e)||c,u=this._parsePropertyPath(h),d=u.subProperty&&this._isSubPropertyName(u.subProperty);let l,m;d&&u.subProperty?(m=u.parentPath,l=`${e}.${i}.${m}`):(m=h,l=`${e}.${i}.${h}`),n.has(l)||n.set(l,{parentPath:m,relativePath:e,componentType:i,bindings:[]}),n.get(l).bindings.push(r)})),Array.from(n.values())}_validateAndGetParentValueType(t){if(t.length===1){const l=t[0],m=l.getProperty??l.property,{subProperty:f}=this._parsePropertyPath(m);return!f||!this._isSubPropertyName(f)?null:y.Float}if(!t.every(l=>this._getValueTypeByCurve(l.curve)===y.Float)){const l=t.map(m=>this._getValueTypeByCurve(m.curve));return console.warn(`分组中的绑定类型不一致: ${l.join(", ")},无法创建父属性`),null}const r=t.map(l=>l.curve.interpolation),e=r[0];r.every(l=>l===e)||console.warn(`子属性插值类型不一致: ${r.join(", ")}`);const o=t.map(l=>{const m=l.getProperty??l.property,f=m.lastIndexOf(".");return f===-1?null:m.substring(f+1)}).filter(Boolean).sort(),s=o.join(",");switch(s){case"x,y":return y.Vector2;case"x,y,z":return y.Vector3;case"w,x,y,z":return y.Vector4;case"a,b,g,r":return y.Color;case"height,width,x,y":return y.Rect}const i=new Set(["x","y","z","w"]),c=new Set(["r","g","b","a"]),p=new Set(["x","y","width","height"]),h=o.every(l=>i.has(l)),u=o.every(l=>c.has(l)),d=o.every(l=>p.has(l));return h?o.some(l=>l==="w")?y.Vector4:o.some(l=>l==="z")?y.Vector3:y.Vector2:u?y.Color:d?y.Rect:(console.warn(`无法识别的子属性组合: ${s}`),null)}_validateBindingGroup(t){const{bindings:n}=t;return n.every(r=>this._validateCurveBinding(r))&&this._validateAndGetParentValueType(n)!==null}_createParentProperty(t,n){const{parentPath:r,relativePath:e,componentType:a}=t,o=F({relativePath:e,componentType:a,propertyPath:r}),s=I.Linear,i=this._propertyLabelMap.get(o),c=r.split(".").pop()||r;return{name:i||c,level:e.split("/").length-1,path:o,type:O.Property,valueType:n,interpolationType:s,componentType:a,relativePath:e,hasSubProperty:!0,curveColor:null,supported:!0,properties:[],propertyPath:r}}async _createSubPropertiesFromBindings(t,n,r,e){return Promise.all(t.map(async a=>{const{getProperty:o,property:s,curve:i}=a,c=o??s,p=await this._convertPropertyProxyPath(c,e,r)||c,h=p.lastIndexOf("."),u=h===-1?p:p.substring(h+1),d=`${n}.${u}`,l={name:u,level:r.split("/").length,path:d,type:O.SubProperty,valueType:y.Float,interpolationType:i.interpolation,componentType:e,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p,parentPath:n};return this.pathPropertyMap.set(d,l),l}))}_registerPropertyGroup(t,n){t.properties=n,this.pathPropertyMap.has(t.path)&&console.warn(`覆盖已存在的属性路径: ${t.path}`),this.pathPropertyMap.set(t.path,t),this.properties.push(t)}async _generatePropertiesFromBindingGroup(t){const{parentPath:n,relativePath:r,componentType:e,bindings:a}=t;if(!this.rootEntity){await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const o=await this._convertPropertyProxyPath(n,e,r)||n;if(!this._validateBindingGroup(t)){this.rootEntity&&a.length>1&&console.debug("AnimationClipAsset: grouping skipped",this.name,e,r,n),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const s=this._validateAndGetParentValueType(a);if(s===null){console.error("验证通过但获取不到父属性类型"),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const i=this._createParentProperty({...t,parentPath:o},s),c=await this._createSubPropertiesFromBindings(a,i.path,r,e);this._registerPropertyGroup(i,c)}async _generatePropertyByEngineObject(t){const{pathPropertyMap:n}=this,{relativePath:r,type:e,curve:a,getProperty:o,property:s}=t,i=K.get(e),c=o??s,p=await this._convertPropertyProxyPath(c,i,r)??c,h=this._getValueTypeByCurve(a),u=F({relativePath:r,componentType:i,propertyPath:p}),d=this._propertyLabelMap.get(u),l=p.lastIndexOf("."),m=l===-1?p:p.substring(l+1),f={name:d||m,level:r.split("/").length-1,path:u,type:O.Property,valueType:h,interpolationType:a.interpolation,componentType:i,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p},A=this._getSubProperties(h,a);A&&(f.curveColor=null,f.hasSubProperty=!0,f.properties=A.map(P=>{const b=`${u}.${P}`,v={name:P,level:r.split("/").length,path:b,type:O.SubProperty,valueType:y.Float,interpolationType:a.interpolation,componentType:i,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:`${p}.${P}`};return n.set(b,v),v})),n.set(u,f),this.properties.push(f)}async _getActualPropertyPath(t,n,r){if(!this.isSubAsset){const{editorPropertyPath:e=[]}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t});t=e.join(".")}return t}_getRandomColor(){const{_colorList:t}=this,n=(e,a)=>{const o=parseInt(e.slice(1),16),s=parseInt(a.slice(1),16);return`#${parseInt(`${(o+s)/2}`).toString(16).toUpperCase()}`},r=()=>{const e=[];for(let o=0,s=t.length-1;o<s;o++){const i=n(t[o],t[o+1]);e.push(i)}const a=t.slice(0,t.length-1);for(let o=0,s=a.length+e.length;o<s;o++)t[o]=o%2===0?a[o/2]:e[(o-1)/2]};for(;this._colorIndex>=t.length;)r();return t[this._colorIndex++]}_getSubProperties(t,n){let r;switch(t){case y.Vector2:{r=["x","y"];break}case y.Vector3:{r=["x","y","z"];break}case y.Vector4:{r=["x","y","z","w"];break}case y.Quaternion:{r=["x","y","z","w"];break}case y.Color:{r=["r","g","b","a"];break}case y.Array:case y.FloatArray:n.keys[0]&&(r=Array.from(n.keys[0].value).map((e,a)=>a))}return r}_listenRootEntityChanged(){var n;const t=this.rootEntity;t&&(this.showEditor&&(this.openEditor(!1),this.openEditor(!0)),(n=this._componentsChangedListenerDisposer)==null||n.call(this),this._componentsChangedListenerDisposer=de(()=>t.components.length,()=>{this.checkPropertiesSupport(t),this.engineObject.curveBindings.forEach(r=>{r._tempCurveOwner={}})}))}_convertPropertyToTreeItem(t){var m;const{name:n,label:r,properties:e=[],relativePath:a,componentType:o,path:s,type:i,curveColor:c,supported:p,level:h}=t,u=((m=this.rootEntity.findByPath(a))==null?void 0:m.name)||a.split("/").pop(),d=r||n;return{name:i===O.Property?`${u}:${o}.${d}`:d,id:s,canAddKeyframe:i===O.Property||i===O.SubProperty,curveColor:c,supported:p,level:h,children:e.map(f=>this._convertPropertyToTreeItem(f))}}_ensurePropertyExists(t){const n=F(t);let r=this.pathPropertyMap.get(n);return r||(r=this.addProperty(t)),t.children&&t.children.length&&t.children.forEach(e=>{this._ensurePropertyExists(e)}),r}destroy(){var t;super.destroy(),(t=this._componentsChangedListenerDisposer)==null||t.call(this),this._propertyPathCache.clear(),this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyLabelMap.clear(),this._editorPathCache.clear(),this._originValueStore.clear()}};T([D],C.prototype,"samples",2);T([D],C.prototype,"properties",2);T([D],C.prototype,"keyframeDataList",2);T([D],C.prototype,"events",2);T([me()],C.prototype,"data",2);T([D],C.prototype,"selectedEventId",2);T([D,fe()],C.prototype,"rootEntityId",2);T([D],C.prototype,"readOnly",2);T([ge],C.prototype,"addedPropertiesTreeData",1);T([E],C.prototype,"addProperty",1);T([E],C.prototype,"delProperty",1);T([E],C.prototype,"addKeyframe",1);T([E],C.prototype,"deleteKeyframes",1);T([E],C.prototype,"updateKeyframes",1);T([E],C.prototype,"addEvent",1);T([E],C.prototype,"deleteEvent",1);T([E],C.prototype,"updateEvents",1);T([E],C.prototype,"updateSamples",1);T([E],C.prototype,"updateRootEntity",1);T([E],C.prototype,"setTangentMode",1);T([E],C.prototype,"checkPropertiesSupport",1);T([E],C.prototype,"updateSelectedEvent",1);T([E],C.prototype,"openEditor",1);C=T([_e({type:"AnimationClip",label:j("asset.animation-clip.title"),icon:"animate-clip",extname:"anim",importMenuConfig:{type:ve.Add},customInspector:Se,viewer:$,async bundle({content:_},t,n){var a;const r=JSON.parse(await _.text());for(const o of r.curveBindings)if(o.curveType==="AnimationRefCurve"){for(const s of o.curve.keys)if((a=s.value)!=null&&a.refId){const i=n.resolveRef(s.value.refId);i&&(s.value=i)}}const e=pt(r,{type:"AnimationClip",name:r.name});return{content:new Blob([e])}}})],C);export{C as A,Se as a,$ as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=Object.defineProperty;var O=(r,t,a)=>t in r?j(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var c=(r,t,a)=>(O(r,typeof t!="symbol"?t+"":t,a),a);import{aT as v,aU as x,aJ as N,aD as S,aK as B,aI as I,j as L,aZ as U,a_ as z,a$ as F,u as M,b0 as R,m as _,b1 as J,e as V,n as $,b2 as K}from"./index-0a8702e2.js";import{u as W,a as Z,A as k}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import"./meshopt_simplifier.module-cd99529d.js";import{b as q}from"./bundlers-9b0d37fc.js";import{o as G}from"./assetEditorActions-c4e5962f.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";const H=v(function(){const{layoutStore:t}=W(),{t:a}=x(),e=N.useCallback(()=>{t.toggleTabVisibility("AnimatorController")},[]);return S.jsx(B,{align:"both",css:{padding:"$1"},fullWidth:!0,children:S.jsx(I,{size:"sm",onClick:e,children:a("animation.animator-controller.editor.open")})})});var Q=Object.defineProperty,X=Object.getOwnPropertyDescriptor,y=(r,t,a,e)=>{for(var s=e>1?void 0:e?X(t,a):t,o=r.length-1,i;o>=0;o--)(i=r[o])&&(s=(e?i(t,a,s):i(s))||s);return e&&s&&Q(t,a,s),s};let d=class extends L{constructor(t){super(t);c(this,"statesNameMap",{});c(this,"internalDataUpdated",!1);c(this,"layers",[]);c(this,"parameters",[]);c(this,"_syncing");c(this,"_syncingPromise");this.onDoubleClick=this.onDoubleClick.bind(this)}applyPropertyFromDomain(t,a){super.applyPropertyFromDomain(t,a),(t==="layers"||t==="parameters")&&this.applyControllerData().catch(e=>{console.error("[AnimatorControllerAsset] applyControllerData failed:",e)})}initByEngineObject(t){return this.setNameByIncrease("AnimatorController"),this.bindEngineObject(t),this.layers=t.layers.map(a=>{const e=a.stateMachine,o={states:e.states.map(i=>({name:i.name,speed:i.speed,wrapMode:i.wrapMode,clipStartNormalizedTime:i.clipStartTime,clipEndNormalizedTime:i.clipEndTime,clip:this.root.assetStore.engineObjectToAssetMap.get(i.clip).getCurrentRef(),transitions:[],scripts:[],isEntryState:i===e.defaultState,isExitState:!1,isAnyState:!1})),transitions:[],entryTransitions:[],anyTransitions:[]};return{name:a.name,blendingMode:a.blendingMode,weight:a.weight,stateMachine:o}}),this.internalDataUpdated=!0,this.getMainData()}async initByMain(t){const{internalDataUpdated:a}=this.meta;a&&(this.internalDataUpdated=!0);const e=JSON.parse(await t.text()),s=new U(this.engine);this.bindEngineObject(s),this.layers=e.layers||[],this.parameters=e.parameters||[],await this.applyControllerData()}async applyControllerData(){this._syncing&&await this._syncingPromise,this._syncing=!0;try{this.statesNameMap={};const t=this.engineObject;t.clearLayers(),t._parameters.length=0,t._parametersMap={};const{layers:a,parameters:e}=this;this._syncingPromise=Promise.all(a.map((s,o)=>{const{name:i,blendingMode:m,weight:u}=s,l=new z(i);return t.addLayer(l),l.blendingMode=m,l.weight=u,this._applyStateMachineData(o)})),e.forEach(s=>{const{isTrigger:o,name:i,defaultValue:m}=s;o?t.addTriggerParameter(i):t.addParameter(i,m)}),await this._syncingPromise}finally{this._syncing=!1}}async initByCreation(){return this.layers=[{name:"Base",weight:1,blendingMode:F.Override,stateMachine:{states:[],transitions:[],entryTransitions:[],anyTransitions:[]}}],this.getMainData()}onDoubleClick(){G(this.root,"AnimatorController",{clearSceneSelection:!0})}async _applyStateMachineData(t){const a=this.engineObject.layers[t],{stateMachine:e}=this.layers[t],s=a.stateMachine;if(e){const{states:o=[],transitions:i=[],entryTransitions:m=[],anyTransitions:u=[]}=e,l={},T={},w=o.map(async n=>{var A,E;const{id:h,name:f,speed:b,wrapMode:g,clipStartNormalizedTime:P,clipEndNormalizedTime:D,clip:C}=n;(A=this.statesNameMap)[t]||(A[t]={}),this.statesNameMap[t][n.name]=n;const p=s.addState(f);p.speed=b,p.wrapMode=g,p.clipStartTime=P,p.clipEndTime=D,l[h]=p,C&&(p.clip=(E=await this.root.assetStore.getAssetByRef(C))==null?void 0:E.engineObject)});i.forEach(n=>{const h=this._createTransition(n,l[n.destinationStateId]);T[n.id]=h}),o.forEach(n=>{const{id:h,transitions:f}=n;f.forEach(b=>{const g=T[b];g&&l[h].addTransition(g)})}),m.forEach(n=>{s.addEntryStateTransition(this._createTransition(n,l[n.destinationStateId]))}),u.forEach(n=>{s.addAnyStateTransition(this._createTransition(n,l[n.destinationStateId]))}),await Promise.all(w),this.engineObject._updateFlagManager.dispatch()}}_createTransition(t,a){const e=new K;return e.duration=t.duration,e.offset=t.offset,e.exitTime=t.exitTime,e.solo=t.solo,e.mute=t.mute,e.hasExitTime=t.hasExitTime,e._isExit=t.isExit,e.destinationState=a,t.conditions.forEach(s=>{e.addCondition(s.parameterName,s.mode,s.threshold)}),e}};y([M,R()],d.prototype,"internalDataUpdated",2);y([_(),M],d.prototype,"layers",2);y([_(),M],d.prototype,"parameters",2);y([J],d.prototype,"applyPropertyFromDomain",1);d=y([Z({type:"AnimatorController",label:V("asset.animator-controller.title"),icon:"animate-controller",extname:"animCtrl",importMenuConfig:{type:k.Add},dragLayer:$.AnimationController,customInspector:H,async bundle({content:r}){return{content:new Blob([q(await r.text())])}}})],d);export{d as AnimatorControllerAsset};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var P=(n,o,t)=>o in n?f(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t;var i=(n,o,t)=>(P(n,typeof o!="symbol"?o+"":o,t),t);import{E as y,bc as u,s as m,p as c,C as d,t as h,e as C,bd as _,be as v,o as g,bf as S,bg as O}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as A}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";var w=Object.defineProperty,E=Object.getOwnPropertyDescriptor,p=(n,o,t,r)=>{for(var e=r>1?void 0:r?E(o,t):o,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(o,t,e):l(e))||e);return r&&e&&w(o,t,e),e};let s=class extends y{constructor(o,t){super(o,t);i(this,"animatorController",null);i(this,"cullingMode",u.None);i(this,"speed",1)}async bindEngineObject(o){await super.bindEngineObject(o),o.enabled=!1}};p([m(),c({type:d.AssetPicker,assetType:"AnimatorController",label:"animation.animator-controller.controller.title",info:"animation.animator-controller.controller.info",bindPath:"animatorController"})],s.prototype,"animatorController",2);p([m(),c({type:d.Select,label:"animation.animator-controller.culling-mode.title",info:"animation.animator-controller.culling-mode.info",options:h(u,void 0,n=>C(`animation.animator-controller.culling-mode.${n.toLowerCase()}`)),bindPath:"cullingMode"})],s.prototype,"cullingMode",2);p([m(),c({type:d.Number,label:"animation.animator-controller.speed.title",info:"animation.animator-controller.speed.info",bindPath:"speed"})],s.prototype,"speed",2);s=p([A({type:"Animator",componentsMenu:{label:"component.animator.title"},unique:!0})],s);class M extends _{constructor(){super(...arguments);i(this,"_animatorComponents",[]);i(this,"onScriptPlay")}init(t){this.onScriptPlay=t.onScriptPlay}onPlay(t){this.engine.sceneManager.scenes[0].rootEntities.forEach(e=>{e.getComponentsIncludeChildren(v,this._animatorComponents)}),this._animatorComponents.forEach(e=>{e.enabled=t,t||e._reset()}),this.onScriptPlay&&this.onScriptPlay(t)}}var j=Object.defineProperty,D=Object.getOwnPropertyDescriptor,$=(n,o,t,r)=>{for(var e=r>1?void 0:r?D(o,t):o,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(o,t,e):l(e))||e);return r&&e&&j(o,t,e),e};let b=class{constructor(n){i(this,"script");i(this,"root");g(this),this.root=n}init(){this.script=S.addScript(M),this.script.init({onScriptPlay:n=>{var o;(o=this.root.animatorControllerStore)==null||o.updateGlobalPlayState(n)}})}};b=$([O({type:"animatorStore"})],b);export{s as A,b as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{aC as p,aH as l,aT as o,aD as i,b4 as u,aG as d,aM as x,b5 as g,b6 as m,aJ as r}from"./index-0a8702e2.js";import{I as h}from"./IconPlayerPlayFilled-b058c98f.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 y=p("filled","player-pause-filled","IconPlayerPauseFilled",[["path",{d:"M9 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z",key:"svg-0"}],["path",{d:"M17 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z",key:"svg-1"}]]);const f=l("div",{position:"absolute",top:0,padding:"$1",backgroundColor:"$panelBg",width:"100%",variants:{sticky:{true:{position:"absolute",top:0}}}}),S=l("div",{height:"220px",width:"100%",border:"1px solid $gray5",borderRadius:"$4",overflow:"hidden"}),j=l("div",{position:"absolute",bottom:"$3",left:0,width:"100%",textAlign:"center",color:"#ddd",textShadow:"0 0 2px #000",fontWeight:"bold",fontSize:"$2"}),z=({asset:t,viewer:e})=>{const a=r.useRef(null),[n,s]=r.useState("");return r.useEffect(()=>{t.startViewer(a.current),s(e.getDescription(t));const c=()=>s(e.getDescription(t));return t.addPropertyChangeListener("engineObjectReady",c),()=>{t.removePropertyChangeListener("engineObjectReady",c),t.stopViewer()}},[t]),i.jsxs(f,{children:[i.jsx(S,{ref:a}),i.jsx($,{asset:t,viewerWithAnimations:e}),n&&i.jsxs(j,{children:[n," "]})]})},v=l("div",{position:"absolute",bottom:8,left:8,right:8,display:"grid",gap:"$1",marginTop:"$1 $2",variants:{hasClips:{true:{gridTemplateColumns:"100px 18px 1fr"},false:{gridTemplateColumns:"$4_5 1fr"}}}}),b=o(function(t){const{frameTime:e,duration:a}=t.clipState;return i.jsx(u,{size:"xs",startSlot:i.jsx(d,{size:"sm",css:{color:"$grayA10"},children:e.toFixed(2).replace(".",":")}),endSlot:i.jsx(d,{size:"sm",css:{color:"$grayA10"},children:a.toFixed(2).replace(".",":")}),tooltip:!1,min:0,max:a||0,disabled:a===0,step:.01,defaultValue:[0],value:[e],onValueChange:n=>{t.clipState.setFrameTime(n[0])},css:{flex:1}})}),C=o(function(t){const e=t.clipState;return i.jsx(x,{size:"xs",onClick:()=>{e.playing=!e.playing,e.playing?e.playAnimation():e.pauseAnimation()},children:e.playing?i.jsx(y,{}):i.jsx(h,{})})}),P=o(function(t){const{animationNames:e,animationIndex:a=0}=t.clipState;return i.jsxs(v,{hasClips:!!e.length,children:[i.jsx(g,{value:a,onValueChange:n=>{t.clipState.selectAnimation&&t.clipState.selectAnimation(n)},valueType:"number",size:"xs",sideOffset:8,children:e.map((n,s)=>n?i.jsx(m,{value:s,children:n},s):null)}),t.children]})}),$=o(function({asset:t,viewerWithAnimations:e}){var n;if(!t.getViewerReady())return null;const a=((n=e.animationNames)==null?void 0:n.length)>0;return a&&e.selectAnimation&&e.selectAnimation(0),a?i.jsxs(P,{clipState:e,children:[i.jsx(C,{clipState:e}),i.jsx(b,{clipState:e})]}):null});export{z as A,y as I};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var n=(t,e,s)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var i=(t,e,s)=>(n(t,typeof e!="symbol"?e+"":e,s),s);import{U as o}from"./index-0a8702e2.js";class _{constructor(){i(this,"overridePreviewer");i(this,"_entity");i(this,"_requestResetCamera");i(this,"_boundingBox",new o)}stopViewAsset(){this._entity&&(this._entity=null)}getDescription(e){return""}}export{_ as A};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var b=Object.defineProperty;var m=(t,e,r)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>(m(t,typeof e!="symbol"?e+"":e,r),r);import{aH as y,aT as c,aD as n,o as f,u as d,j as A,a7 as O,e as j}from"./index-0a8702e2.js";import{a as w,A as P}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as _}from"./AssetViewer-bc198e16.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var g=Object.defineProperty,h=Object.getOwnPropertyDescriptor,v=(t,e,r,s)=>{for(var o=s>1?void 0:s?h(e,r):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=(s?a(e,r,o):a(o))||o);return s&&o&&g(e,r,o),o};const x=y("div",{position:"absolute",top:"100px",backgroundColor:"$panelBg",variants:{sticky:{true:{position:"absolute",top:0}}}}),R=c(({asset:t})=>n.jsx(x,{children:n.jsx("audio",{src:t.url,controls:!0,children:"Your browser does not support the audio element."})}));class l extends _{constructor(){super();p(this,"duration",0);p(this,"playing",!1);p(this,"audioName");p(this,"overridePreviewer",c(({asset:r})=>n.jsx(R,{asset:r})));f(this)}setViewAsset(r,s){}}v([d],l.prototype,"duration",2);v([d],l.prototype,"playing",2);var D=Object.defineProperty,U=Object.getOwnPropertyDescriptor,C=(t,e,r,s)=>{for(var o=s>1?void 0:s?U(e,r):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=(s?a(e,r,o):a(o))||o);return s&&o&&D(e,r,o),o};let u=class extends A{constructor(e){super(e);p(this,"urlObj")}async initByMain(e){this.urlObj=e;const r=URL.createObjectURL(e);try{const s=await this.engine.resourceManager.load({url:r,type:O.Audio});this.bindEngineObject(s)}finally{URL.revokeObjectURL(r)}}};u=C([w({type:"Audio",label:j("asset.audio.title"),loaderType:"Audio",importMenuConfig:{type:P.Upload,tooltip:"请上传音频文件(支持 OGG, WAV, MP3)",accept:".ogg,.wav,.mp3"},viewer:l,bundle({content:t}){return{content:t}}})],u);export{u as AudioAsset};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var b=Object.defineProperty;var d=(p,o,e)=>o in p?b(p,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[o]=e;var n=(p,o,e)=>(d(p,typeof o!="symbol"?o+"":o,e),e);import{E as f,p as r,C as a,s as m}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var P=Object.defineProperty,v=Object.getOwnPropertyDescriptor,i=(p,o,e,u)=>{for(var t=u>1?void 0:u?v(o,e):o,s=p.length-1,y;s>=0;s--)(y=p[s])&&(t=(u?y(o,e,t):y(t))||t);return u&&t&&P(o,e,t),t};let l=class extends f{constructor(o,e){super(o,e);n(this,"clip",null);n(this,"playOnEnabled",!0);n(this,"loop",!0);n(this,"volume",0);n(this,"mute",!1)}};i([r({label:"Audio resource",info:"Audio resource info",type:a.AssetPicker,assetType:"Audio",bindPath:"clip"}),m()],l.prototype,"clip",2);i([r({label:"playOnEnabled",info:"playOnEnabled info",type:a.Toggle,bindPath:"playOnEnabled"}),m()],l.prototype,"playOnEnabled",2);i([r({label:"IsLooping",info:"IsLooping info",type:a.Toggle,bindPath:"loop"}),m()],l.prototype,"loop",2);i([r({label:"Volume",info:"Volume info",type:a.Slider,min:0,max:1,bindPath:"volume"}),m()],l.prototype,"volume",2);i([r({label:"Mute",info:"Mute info",type:a.Toggle,bindPath:"mute"}),m()],l.prototype,"mute",2);l=i([c({type:"AudioSource",componentsMenu:{label:"component.audio.title"}})],l);export{l as AudioComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aH as o,aK as r}from"./index-0a8702e2.js";const a=o(r,{borderRadius:"$2",fontSize:"$1",padding:"$1 $2",userSelect:"none",fontWeight:500,variants:{type:{info:{backgroundColor:"$blue3",color:"$blueA11"},warning:{backgroundColor:"$amber3",color:"$amber11"},error:{backgroundColor:"$red3",color:"$red11"},success:{backgroundColor:"$green3",color:"$green11"}}}});export{a as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _=Object.defineProperty;var q=(e,l,a)=>l in e?_(e,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[l]=a;var t=(e,l,a)=>(q(e,typeof l!="symbol"?l+"":l,a),a);import{L as m,a as f,E as k,V as L,b as w,d as P,D as C,c as x,A as O,M as A,C as s,s as o,p as i,t as g,e as b,l as R,g as S,f as M,h as E,r as D,S as F}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as z}from"./Component-f923abb1.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var V=Object.defineProperty,j=Object.getOwnPropertyDescriptor,n=(e,l,a,p)=>{for(var c=p>1?void 0:p?j(l,a):l,u=e.length-1,h;u>=0;u--)(h=e[u])&&(c=(p?h(l,a,c):h(c))||c);return p&&c&&V(l,a,c),c};const d=[...Object.values(m),f.Nothing,f.Everything];class T extends F{constructor(){super(...arguments);t(this,"_originalMask");t(this,"_onEndRenderOnce",null)}onBeginRender(a){this._originalMask=a.cullingMask,a.cullingMask&=~(m.Viewport|m.Outline|m.NavigationGizmo|m.Gizmo)}onEndRender(a){if(a.cullingMask=this._originalMask,this._onEndRenderOnce){const p=this._onEndRenderOnce;this._onEndRenderOnce=null,p(a)}}executeAfterRender(a){this._onEndRenderOnce=a}}let r=class extends k{constructor(){super(...arguments);t(this,"_lastRTAsset",null);t(this,"isOrthographic",!1);t(this,"nearClipPlane",.1);t(this,"farClipPlane",100);t(this,"fieldOfView",45);t(this,"orthographicSize",10);t(this,"viewport",new L(0,0,1,1));t(this,"priority",0);t(this,"enableFrustumCulling",!0);t(this,"clearFlags",w.All);t(this,"cullingMask",P(f.Everything,d));t(this,"postProcessMask",P(f.Everything,d));t(this,"depthTextureMode",C.None);t(this,"opaqueTextureEnabled",!1);t(this,"opaqueTextureDownsampling",x.TwoX);t(this,"antiAliasing",O.None);t(this,"msaaSamples",A.FourX);t(this,"enableHDR",!1);t(this,"enablePostProcess",!0);t(this,"isAlphaOutputRequired",!1);t(this,"renderTarget",null)}onEnabled(){this.applyBoundPathChange("enabled",s.Toggle,!1)}onInitComplete(){if(this.engineObject.entity.addComponent(T),this.renderTarget){const l=this.root.assetStore.assets[this.renderTarget.refId];if(l){this._lastRTAsset=l;const a=this.engineObject.entity.getComponent(T);a&&a.executeAfterRender(()=>{var p;l.updateThumbnail(),(p=l.subAssets)==null||p.forEach(c=>c.updateThumbnail())})}}else this.applyBoundPathChange("enabled",s.Toggle,!1)}};n([o(),i({label:"camera.is-orthographic",bindPath:"isOrthographic"})],r.prototype,"isOrthographic",2);n([o(),i({label:"camera.near-clip-plane",bindPath:"nearClipPlane"})],r.prototype,"nearClipPlane",2);n([o(),i({label:"camera.far-clip-plane",bindPath:"farClipPlane"})],r.prototype,"farClipPlane",2);n([o(),i({label:"camera.field-of-view",bindPath:"fieldOfView",when:e=>!e.isOrthographic})],r.prototype,"fieldOfView",2);n([o(),i({label:"camera.orthographic-size",bindPath:"orthographicSize",when:e=>e.isOrthographic})],r.prototype,"orthographicSize",2);n([o(),i({type:s.Vector4,min:0,max:1,label:"camera.viewport.title",bindPath:"viewport"})],r.prototype,"viewport",2);n([o(),i({label:"camera.priority.title",bindPath:"priority"})],r.prototype,"priority",2);n([o(),i({label:"camera.enable-frustum-culling",bindPath:"enableFrustumCulling"})],r.prototype,"enableFrustumCulling",2);n([o(),i({label:"camera.clear-flags.title",bindPath:"clearFlags",type:s.Select,options:g(w,void 0,e=>b(`camera.clear-flags.${e.toLocaleLowerCase()}`))})],r.prototype,"clearFlags",2);n([o(R(d)),i({label:"camera.culling-mask",bindPath:"cullingMask",type:s.Select,...S(d)}),M(E(d))],r.prototype,"cullingMask",2);n([o(R(d)),i({label:"camera.post-process-mask",bindPath:"postProcessMask",type:s.Select,...S(d)}),M(E(d))],r.prototype,"postProcessMask",2);n([o(),i({label:"camera.depth-texture-mode.title",info:"camera.depth-texture-mode.info",bindPath:"depthTextureMode",type:s.Select,options:g(C,void 0,e=>b(`camera.depth-texture-mode.${e.toLowerCase()}`))})],r.prototype,"depthTextureMode",2);n([o(),i({label:"camera.opaque-texture-enabled.title",info:"camera.opaque-texture-enabled.info",bindPath:"opaqueTextureEnabled",type:s.Toggle})],r.prototype,"opaqueTextureEnabled",2);n([o(),i({label:"camera.opaque-texture-down-sampling.title",info:"camera.opaque-texture-down-sampling.info",bindPath:"opaqueTextureDownsampling",type:s.Select,options:g(x,void 0,e=>b(`camera.opaque-texture-down-sampling.${e.toLowerCase()}`)),when:e=>e.opaqueTextureEnabled})],r.prototype,"opaqueTextureDownsampling",2);n([o(),i({label:"camera.anti-aliasing.title",info:"camera.anti-aliasing.info",bindPath:"antiAliasing",type:s.Select,options:g(O,void 0,e=>b(`camera.anti-aliasing.${e.toLowerCase()}`))})],r.prototype,"antiAliasing",2);n([o(),i({label:"camera.msaa-samples.title",info:"camera.msaa-samples.info",bindPath:"msaaSamples",type:s.Select,options:g(A,void 0,e=>b(`camera.msaa-samples.${e.toLowerCase()}`))})],r.prototype,"msaaSamples",2);n([o(),i({label:"camera.enable-hdr.title",info:"camera.enable-hdr.info",bindPath:"enableHDR",type:s.Toggle})],r.prototype,"enableHDR",2);n([o(),i({label:"camera.enable-post-process.title",info:"camera.enable-post-process.info",bindPath:"enablePostProcess",type:s.Toggle})],r.prototype,"enablePostProcess",2);n([o(),i({label:"camera.is-alpha-output-required.title",info:"camera.is-alpha-output-required.info",bindPath:"isAlphaOutputRequired",type:s.Toggle})],r.prototype,"isAlphaOutputRequired",2);n([i({label:"camera.render-target.title",type:s.AssetPicker,assetType:"RenderTarget",onChange:async(e,l,a)=>{var h;const p=e._lastRTAsset;p&&!a&&D(()=>{var y;p.thumbnailUrl="",(y=p.subAssets)==null||y.forEach(v=>{v.thumbnailUrl=""})}),e._lastRTAsset=a??null,e.renderTarget=a?a.getCurrentRef():null,await e.applyBoundPathChange("renderTarget",s.AssetPicker,e.renderTarget);const c=e.root.projectStore.currentViewport.previewManager;c.hasUserRT=!!a;const u=e.engineObject;a?(u.enabled=!0,a.updateThumbnail(),(h=a.subAssets)==null||h.forEach(y=>y.updateThumbnail())):c.isPreviewOn||(u.enabled=!1)}}),o()],r.prototype,"renderTarget",2);r=n([z({type:"Camera",componentsMenu:{label:"component.camera.title"}})],r);export{r as CameraComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=Object.defineProperty;var y=(c,t,e)=>t in c?v(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var i=(c,t,e)=>(y(c,typeof t!="symbol"?t+"":t,e),e);import{bq as p,H as h,ay as u,S as C,bA as b,I as g,U as w,bB as z,bC as M,x as f,bD as P,bu as T,bw as E,bv as D}from"./index-0a8702e2.js";import"./AssetPreviewer-24e31d97.js";const x=p.zeroTolerance,d=class d{constructor(t=1,e=0,a=0){i(this,"_matrix",new u);i(this,"_matrixInv",new u);this.radius=t,this.phi=e,this.theta=a}makeSafe(){const t=Math.floor(this.phi/Math.PI);return this.phi=p.clamp(this.phi,t*Math.PI+x,(t+1)*Math.PI-x),this}set(t,e,a){return this.radius=t,this.phi=e,this.theta=a,this}setYAxis(t){const{_xAxis:e,_yAxis:a,_zAxis:n}=d;h.equals(e.set(1,0,0),a.copyFrom(t).normalize())&&e.set(0,1,0),h.cross(e,a,n),n.normalize(),h.cross(a,n,e);const{elements:s}=this._matrix;s[0]=e.x,s[1]=e.y,s[2]=e.z,s[4]=a.x,s[5]=a.y,s[6]=a.z,s[8]=n.x,s[9]=n.y,s[10]=n.z;const{elements:r}=this._matrixInv;r[0]=e.x,r[4]=e.y,r[8]=e.z,r[1]=a.x,r[5]=a.y,r[9]=a.z,r[2]=n.x,r[6]=n.y,r[10]=n.z}setFromVec3(t,e=!1){return t.transformNormal(this._matrixInv),this.radius=t.length(),this.radius===0?(this.theta=0,this.phi=0):e?(this.phi=2*Math.PI-Math.acos(p.clamp(t.y/this.radius,-1,1)),this.theta=Math.atan2(-t.x,-t.z)):(this.phi=Math.acos(p.clamp(t.y/this.radius,-1,1)),this.theta=Math.atan2(t.x,t.z)),this}setToVec3(t){const{radius:e,phi:a,theta:n}=this,s=Math.sin(a)*e;return this.phi-=Math.floor(this.phi/Math.PI/2)*Math.PI*2,t.set(s*Math.sin(n),e*Math.cos(a),s*Math.cos(n)),t.transformNormal(this._matrix),this.phi>Math.PI}};i(d,"_xAxis",new h),i(d,"_yAxis",new h),i(d,"_zAxis",new h);let _=d;class A extends C{constructor(e){super(e);i(this,"domElement");i(this,"camera");i(this,"cameraTransform");i(this,"autoRotate",!1);i(this,"autoRotateSpeed",Math.PI);i(this,"enableDamping",!0);i(this,"rotateSpeed",2);i(this,"zoomSpeed",1);i(this,"keyPanSpeed",7);i(this,"dampingFactor",.2);i(this,"zoomFactor",.2);i(this,"minDistance",.1);i(this,"maxDistance",1/0);i(this,"minZoom",0);i(this,"maxZoom",1/0);i(this,"minPolarAngle",1/180*Math.PI);i(this,"maxPolarAngle",179/180*Math.PI);i(this,"minAzimuthAngle",-1/0);i(this,"maxAzimuthAngle",1/0);i(this,"_enableKeys",!0);i(this,"_up",new h(0,1,0));i(this,"_target",new h);i(this,"_atTheBack",!1);i(this,"_spherical",new _);i(this,"_sphericalDelta",new _);i(this,"_sphericalDump",new _);i(this,"_zoomFrag",0);i(this,"_scale",1);i(this,"_panOffset",new h);i(this,"_tempVec3",new h);i(this,"_enableHandler",7);i(this,"_isRotating",!1);this.domElement=e.engine.canvas._webCanvas}get up(){return this._up}set up(e){this._up.copyFrom(e),this._spherical.setYAxis(e),this._atTheBack=!1}get target(){return this._target}set target(e){this._target.copyFrom(e),this._atTheBack=!1}get enableRotate(){return(this._enableHandler&1)!==0}set enableRotate(e){e?this._enableHandler|=1:this._enableHandler&=-2}get enableZoom(){return(this._enableHandler&2)!==0}set enableZoom(e){e?this._enableHandler|=2:this._enableHandler&=-3}get enablePan(){return(this._enableHandler&4)!==0}set enablePan(e){e?this._enableHandler|=4:this._enableHandler&=-5}onAwake(){const{engine:e,entity:a}=this;this.input=e.inputManager,this.camera=a.getComponent(b),this.cameraTransform=a.transform,this._spherical.setYAxis(this._up),this._atTheBack=!1}onUpdate(e){this._updateTransform()}rotate(e){if(!(this._enableHandler&1))return;const a=2*Math.PI*e.x/this.domElement.clientWidth*this.rotateSpeed;this._sphericalDelta.theta-=a;const n=2*Math.PI*e.y/this.domElement.clientHeight*this.rotateSpeed;this._sphericalDelta.phi-=n,this._sphericalDump.theta=-a,this._sphericalDump.phi=-n,this._isRotating=!0}zoom(e){this._enableHandler&2&&(e>0?this._scale/=Math.pow(.95,this.zoomSpeed):e<0&&(this._scale*=Math.pow(.95,this.zoomSpeed)))}pan(e){if(!(this._enableHandler&4))return;const{cameraTransform:a}=this,{elements:n}=a.worldMatrix,{clientHeight:s}=this.domElement,r=h.distance(a.position,this.target)*(this.camera.fieldOfView/2)*(Math.PI/180),o=-2*e.x*(r/s),m=2*e.y*(r/s);this._panOffset.x+=n[0]*o+n[4]*m,this._panOffset.y+=n[1]*o+n[5]*m,this._panOffset.z+=n[2]*o+n[6]*m}_updateTransform(){const{cameraTransform:e,target:a,_tempVec3:n,_spherical:s,_sphericalDump:r,_sphericalDelta:o,_panOffset:m}=this;this.enableDamping&&!this._isRotating&&(o.theta=r.theta*=1-this.dampingFactor,o.phi=r.phi*=1-this.dampingFactor),h.subtract(e.position,a,n),s.setFromVec3(n,this._atTheBack),s.theta+=o.theta,s.phi+=o.phi,s.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,s.theta)),s.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,s.phi)),s.makeSafe(),this._scale!==1&&(this._zoomFrag=s.radius*(this._scale-1)),s.radius+=this._zoomFrag,s.radius=Math.max(this.minDistance,Math.min(this.maxDistance,s.radius)),this._atTheBack=s.setToVec3(n),h.add(a.add(m),n,e.worldPosition),e.lookAt(a,n.copyFrom(this.up).scale(this._atTheBack?-1:1)),this._zoomFrag=0,this._scale=1,o.set(0,0,0),m.set(0,0,0),this._isRotating=!1}addDefaultControl(){const e=new g,a=new g,n=this.domElement,s=l=>{e.set(l.clientX,l.clientY),document.addEventListener("pointermove",r),document.addEventListener("pointerup",o)},r=l=>{a.set(l.clientX,l.clientY).subtract(e),this.rotate(a),e.set(l.clientX,l.clientY)},o=()=>{document.removeEventListener("pointerup",o),document.removeEventListener("pointermove",r)},m=l=>{this.zoom(l.deltaY)};return n.addEventListener("pointerdown",s),n.addEventListener("wheel",m,{passive:!1}),()=>{n.removeEventListener("pointerdown",s),document.removeEventListener("pointerup",o),document.removeEventListener("pointermove",r),n.removeEventListener("wheel",m)}}}function I({currentRenderTarget:c,width:t,height:e,createRenderTarget:a,createImageData:n}){if(c&&c.width===t&&c.height===e)return{renderTarget:c,imageData:null,reused:!0};if(c){const o=c.getColorTexture(0);o==null||o.destroy(),c.destroy()}const s=a(t,e),r=new Uint8ClampedArray(t*e*4);return{renderTarget:s,imageData:n(r,t,e),reused:!1}}class S{constructor(t,e,a,n=!1){i(this,"_engine");i(this,"_renderTarget");i(this,"_scene");i(this,"_rootEntity");i(this,"_camera");i(this,"_canvas",null);i(this,"_imageData");i(this,"_curBoundingBox",new w);i(this,"_tempSizeVec3",new h);i(this,"_tempCenterVec",new h);i(this,"_orbitControl",null);i(this,"_resizeObserver");i(this,"_preventWheelCallback");i(this,"_renderComponent");i(this,"_container");t=t>>0,e=e>>0;const s=this._createCanvas(t,e);this._canvas=s,this._engine=a,this._createScene(a);const r=this.createRenderTarget(a,t,e);this._renderTarget=r,n&&this._addOrbitControl()}get engine(){return this._engine}get width(){return this._canvas.width}get height(){return this._canvas.height}get canvas(){return this._canvas}get camera(){return this._camera}get scene(){return this._scene}get rootEntity(){return this._rootEntity}_createCanvas(t,e){const a=document.createElement("canvas");return a.width=t,a.height=e,a}_createScene(t){var m;const e=new z(t),a=e.createRootEntity("root"),n=a.createChild("light");n.transform.setPosition(-9,15,17),n.transform.lookAt(new h(0,0,0));const s=n.addComponent(M);s.color=new f(1,1,1,1);const o=a.createChild("camera_entity").addComponent(b);return e.ambientLight=(m=t.sceneManager.activeScene)==null?void 0:m.ambientLight,e.background.solidColor=new f(.0157,.0157,.0157,0),this._scene=e,this._camera=o,o.nearClipPlane=.1,o.farClipPlane=100,this._rootEntity=a,{scene:e,camera:o,rootEntity:a}}_addOrbitControl(){const t=this._camera.entity,e=t.addComponent(A);e.domElement=this._canvas,e.addDefaultControl(),e.maxDistance=1/0,this._orbitControl=e;const a=this;this._renderComponent=t.addComponent(class extends C{onEndRender(){a._render()}}),this._renderComponent.enabled=!1,this._preventWheelCallback=n=>{n.stopPropagation(),n.preventDefault()}}renderOneFrame(t,e){const a=this._engine,n=this._scene;a.sceneManager.addScene(n),this._resetCamera(),this.setCamera(t/e),a.update(),this._render(),a.sceneManager.removeScene(n)}setCamera(t){this._camera.aspectRatio=t,this._camera.renderTarget=this._renderTarget}_resetCamera(t,e){var a,n;if(e!=null&&e.getSize){const{width:s,height:r}=e.getSize(),o=new g(s,r).length();this._camera.entity.transform.setPosition(0,0,o*1.2),(a=this._orbitControl)==null||a.target.set(0,0,0)}else{P(t||this._rootEntity,this._curBoundingBox),this._curBoundingBox.getExtent(this._tempSizeVec3),this._curBoundingBox.getCenter(this._tempCenterVec);const{_tempCenterVec:s}=this,r=this._camera.entity,o=this._tempSizeVec3.length();this._camera.farClipPlane=o*1e3,r.transform.setPosition(s.x,s.y,o*1.8),(n=this._orbitControl)==null||n.target.set(s.x,s.y,s.z)}}createRenderTarget(t,e,a){const n=I({currentRenderTarget:this._renderTarget,width:e,height:a,createRenderTarget:(s,r)=>{const o=new T(t,s,r,void 0,!1);return new E(t,s,r,o,D.Depth,4)},createImageData:(s,r,o)=>new ImageData(new Uint8ClampedArray(s),r,o)});return n.reused||(this._imageData=n.imageData,this._renderTarget=n.renderTarget),n.renderTarget}_render(){if(!this._renderTarget)return;const t=this._renderTarget;t.getColorTexture(0).getPixelBuffer(0,0,t.width,t.height,0,this._imageData.data),this._canvas.getContext("2d").putImageData(this._imageData,0,0)}async createImageUrl(){return new Promise(t=>{this._canvas.toBlob(e=>{const a=URL.createObjectURL(new Blob([e],{type:"image/png"}));t(a)})})}addToContainer(t,e,a){this._renderComponent.enabled=!0,this._container=t,t.appendChild(this._canvas);const n=new ResizeObserver(()=>{this._onCanvasResize(t.clientWidth,t.clientHeight),this._resetCamera(a,e)});n.observe(t),this._resizeObserver=n,e._requestResetCamera=()=>this._resetCamera(a,e),t.addEventListener("mousewheel",this._preventWheelCallback,{passive:!1})}removeFromContainer(){this._renderComponent.enabled=!1,this._resizeObserver.disconnect(),this._canvas.remove(),this._container.removeEventListener("mousewheel",this._preventWheelCallback)}_onCanvasResize(t,e){const a=Math.round(t*window.devicePixelRatio),n=Math.round(e*window.devicePixelRatio),s=this._canvas;s.width=a,s.height=n,this.createRenderTarget(this._engine,a,n),this.setCamera(a/n),this._engine.sceneManager.addScene(this._scene)}}export{S as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as r}from"./index-0a8702e2.js";function a(e){return function(n){e.class=n,e.componentsMenu={label:e.type,...e.componentsMenu},e.refMap=new Set,e.external=e.external??!1,r.registerComponent(e.type,e)}}export{a as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.defineProperty;var y=(e,a,o)=>a in e?g(e,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[a]=o;var r=(e,a,o)=>(y(e,typeof a!="symbol"?a+"":a,o),o);import{i as f,e as m,p as h,C as i,t as b,s as l,v as c}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as P}from"./Component-f923abb1.js";import{L as N}from"./LightBaseComponent-fbc3ae49.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var u=Object.defineProperty,S=Object.getOwnPropertyDescriptor,p=(e,a,o,n)=>{for(var t=n>1?void 0:n?S(a,o):a,d=e.length-1,w;d>=0;d--)(w=e[d])&&(t=(n?w(a,o,t):w(t))||t);return n&&t&&u(a,o,t),t};let s=class extends N{constructor(a,o){super(a,o);r(this,"shadowType",f.None);r(this,"shadowBias",1);r(this,"shadowNormalBias",1);r(this,"shadowNearPlaneOffset",.1);r(this,"shadowStrength",1);this.formSchema.addGroup(m("light.shadow.title"),["shadowType","shadowBias","shadowNormalBias","shadowNearPlaneOffset","shadowStrength"],{collapsible:!1})}};p([h({type:i.Select,options:b(f,void 0,e=>m(`light.shadow.type.${e.toLowerCase()}`)),bindPath:"shadowType",property:"shadowType",label:"light.shadow.type.label",info:"light.shadow.type.info"}),l(),c()],s.prototype,"shadowType",2);p([h({type:i.Number,bindPath:"shadowBias",property:"shadowBias",dragStep:.01,label:"light.shadow.bias.label",info:"light.shadow.bias.info"}),l()],s.prototype,"shadowBias",2);p([h({type:i.Number,bindPath:"shadowNormalBias",property:"shadowNormalBias",dragStep:.01,label:"light.shadow.normal-bias.label",info:"light.shadow.normal-bias.info"}),l()],s.prototype,"shadowNormalBias",2);p([h({type:i.Number,bindPath:"shadowNearPlaneOffset",property:"shadowNearPlaneOffset",dragStep:.01,label:"light.shadow.near-plane-offset.label",info:"light.shadow.near-plane-offset.info"}),l()],s.prototype,"shadowNearPlaneOffset",2);p([h({type:i.Slider,bindPath:"shadowStrength",property:"shadowStrength",min:0,max:1,dragStep:.01,label:"light.shadow.strength.label",info:"light.shadow.strength.info"}),l()],s.prototype,"shadowStrength",2);s=p([P({type:"DirectLight",componentsMenu:{group:"light",label:"component.light.direct.title"}})],s);export{s as DirectLightComponent};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var d=Object.defineProperty;var m=(s,e,t)=>e in s?d(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(m(s,typeof e!="symbol"?e+"":e,t),t);import{cc as u,cd as y,ce as h,aT as w,aD as b,a1 as f,j as v,a7 as x,e as j}from"./index-0a8702e2.js";import{a as O,A}from"./InstanceEditorAsset-a70e73fe.js";import{A as F}from"./AssetPreviewer-24e31d97.js";import{n as R}from"./index-be6bc38a.js";import{A as U}from"./AssetViewer-bc198e16.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";async function g(s){const e={uploadFiles:[],errors:[]};for(const t in s){const n=s[t],r=n.name.toLocaleLowerCase();(r.endsWith(".ttf")||r.endsWith(".otf")||r.endsWith(".woff"))&&e.uploadFiles.push({main:n})}return e}async function C(s){const e=s.main;try{const t=e.name,n=u(t),r=y(t,n),o=await h.uploadBlob(`${t}.json`,e),i={fontName:r,fontUrl:encodeURI(o.url).replace(/\(/g,"%28").replace(/\)/g,"%29")};return new File([JSON.stringify(i)],r)}catch(t){console.error(t),R.error(`parse font file fail ${t}`)}return e}class p extends U{constructor(){super()}setViewAsset(e,t){const n=t.createChild("font_entity"),r=n.addComponent(f);r.font=e.engineObject,r.text=`ABCDEFGHIJKLM
|
|
2
|
+
NOPQRSTUVWXYZ
|
|
3
|
+
abcdefghijklm
|
|
4
|
+
nopqrstuvwxyz
|
|
5
|
+
1234567890`,this._entity=n}}const L=w(({asset:s})=>b.jsx(F,{asset:s}));p.previewer=L;class c{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.textRenderer.font=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("font"),n=this.textRenderer=t.addComponent(f);n.text="Aa",n.fontSize=60}}a(c,"entity"),a(c,"textRenderer");var P=Object.defineProperty,T=Object.getOwnPropertyDescriptor,_=(s,e,t,n)=>{for(var r=n>1?void 0:n?T(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&P(e,t,r),r};let l=class extends v{constructor(e){super(e);a(this,"urlObj")}async initByMain(e){this.urlObj=e;const t=URL.createObjectURL(e),n=await this.engine.resourceManager.load({url:t,type:x.Font});URL.revokeObjectURL(t),this.bindEngineObject(n)}};l=_([O({type:"Font",label:j("asset.font.title"),loaderType:"Font",extname:"font",viewer:p,thumbnail:c,importMenuConfig:{type:A.Upload,tooltip:"请上传字体文件(支持 TTF, OTF, WOFF)",accept:".ttf,.otf,.woff"},filterUploadFiles:g,preUpload:C})],l);export{l as FontAsset};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aH as p,aI as m,aJ as h,aD as e,aE as f,aF as b,aK as i,aL as j,aM as l,aN as I}from"./index-0a8702e2.js";import{A as v,a as A,I as g}from"./Accordion-4897319b.js";const D=p(m,{width:"100%",border:"none",position:"relative",borderRadius:0,"& > svg":{marginRight:"$1"},"&::after":{content:"''",position:"absolute",top:0,left:0,width:"100%",borderTop:"1px solid $grayA2"}});function z(r){const{renameable:n,onDelete:s,removable:o}=r;return e.jsxs(i,{align:"v",css:{flex:1,justifyContent:"space-between"},children:[e.jsx("span",{children:r.title}),e.jsxs(i,{gap:"xxs",children:[n&&e.jsx(l,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:t=>{t.preventDefault(),t.stopPropagation(),s&&s()},children:e.jsx(g,{size:"14px"})}),o&&e.jsx(l,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:t=>{t.preventDefault(),t.stopPropagation(),s&&s()},children:e.jsx(I,{size:"14px"})})]})]})}function w(r){const{items:n=[],onAdd:s,onDelete:o,addItemText:t="Add Item",defaultValue:d,addable:c=!1}=r,u=a=>()=>{o&&o(a)},x=h.useMemo(()=>n.length?n.map(a=>`${a.id}`):[],[n]);return e.jsx(f,{...b(r),direction:"column",children:e.jsxs(v,{type:"multiple",defaultValue:d??x,children:[n.map(a=>e.jsx(A,{value:`${a.id}`,title:e.jsx(z,{title:a.name,onDelete:u(a),removable:a.removable,renameable:a.renameable}),arrow:!!a.children,children:a.children&&e.jsx(i,{direction:"column",children:a.children})},a.id)),c&&e.jsxs(D,{size:"sm",variant:"soft",onClick:s,children:[e.jsx(j,{size:"12px"})," ",t]})]})})}export{w as F};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var Lt=Object.defineProperty;var $t=(e,t,s)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var w=(e,t,s)=>($t(e,typeof t!="symbol"?t+"":t,s),s);import{eW as Vt,aH as Ut,aT as ht,aD as I,bz as Ft,n as gt,aU as Dt,aV as $e,aE as te,e1 as be,cF as se,by as Ve,aJ as qt,dJ as Ue,o as pt,S as Bt,u as j,J as G,be as Gt,eX as Wt,e as dt,_ as Ht,cY as Xt,eY as Fe,a7 as Kt,O as De,v as Qt,b0 as W,b1 as Jt,cj as Yt}from"./index-0a8702e2.js";import{B as N,P,a as v,A as Ie,b as Pe,K as mt,N as Zt,M as V,E as ie,D as ze,u as ve,R as me,S as es,T as Me,c as yt,d as bt,e as vt,C as ts,f as ss,g as ns,G as Ae,h as qe,F as rs,i as _e}from"./glTFIO-45ff9a17.js";import{a as le}from"./meshopt_simplifier.module-cd99529d.js";import{u as At,I as as,a as is,A as os}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{A as ls}from"./AssetViewer-bc198e16.js";import{M as cs}from"./MaterialAsset-74a15124.js";import{k as fs}from"./ktx2-encoder-1e63c1eb.js";import{n as Be}from"./index-be6bc38a.js";function Ge(e){const t=e%4;return t===0?e:e+(4-t)}function us(e){return e.toLowerCase().endsWith(".png")?"image/png":e.toLowerCase().endsWith(".jpg")||e.toLowerCase().endsWith(".jpeg")?"image/jpeg":e.toLowerCase().endsWith(".webp")?"image/webp":"application/octet-stream"}function _t(e){const{json:t,resources:s}=e,n=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),a=N.pad(N.encodeText(r),32),i=N.toView(new Uint32Array([a.byteLength,1313821514])),l=N.concat([i,a]);n[n.length-1]+=l.byteLength;const o=Object.values(s)[0];if(!o||!o.byteLength)return N.concat([N.toView(n),l]);const u=N.pad(o,0),c=N.toView(new Uint32Array([u.byteLength,5130562])),h=N.concat([c,u]);return n[n.length-1]+=h.byteLength,N.concat([N.toView(n),l,h])}function hs(e){const t=e.json,s=[],n=[];let r=0;function a(h){return h.uri===void 0?void 0:e.resources[h.uri]}const i=t.buffers??[],l=new Map;i.forEach((h,f)=>{const g=a(h);g!==void 0&&(s.push(new Uint8Array(g)),n.push(r),delete h.uri,h.byteLength=g.byteLength,l.set(f,r),r+=Ge(g.byteLength))});let o=i.length;(t.images||[]).forEach(h=>{const f=a(h);if(!f){delete h.uri;return}const g={buffer:0,byteOffset:r,byteLength:f.byteLength};l.set(o++,r),r+=Ge(f.byteLength);const p=t.bufferViews??[];h.bufferView=p.length,h.mimeType=us(h.uri),delete h.uri,p.push(g),s.push(new Uint8Array(f)),n.push(g.byteOffset)});for(const h of t.bufferViews??[])h.byteOffset=(h.byteOffset??0)+(l.get(h.buffer)??0),h.buffer=0;const c=new Uint8Array(r);return s.forEach((h,f)=>{c.set(h,n[f])}),t.buffers=[{byteLength:r}],_t({json:t,resources:{"buffer.bin":c}})}function gs(e){for(var t=new Array(e),s=0;s<e;++s)t[s]=s;return t}var ps=gs;/*!
|
|
2
|
+
* Determine if an object is a Buffer
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/var ds=function(e){return e!=null&&(Tt(e)||ms(e)||!!e._isBuffer)};function Tt(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function ms(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Tt(e.slice(0,0))}var ys=ps,bs=ds,vs=typeof Float64Array<"u";function As(e,t){return e[0]-t[0]}function _s(){var e=this.stride,t=new Array(e.length),s;for(s=0;s<t.length;++s)t[s]=[Math.abs(e[s]),s];t.sort(As);var n=new Array(t.length);for(s=0;s<n.length;++s)n[s]=t[s][1];return n}function Ts(e,t){var s=["View",t,"d",e].join("");t<0&&(s="View_Nil"+e);var n=e==="generic";if(t===-1){var r="function "+s+"(a){this.data=a;};var proto="+s+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+s+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+s+"(a){return new "+s+"(a);}",m=new Function(r);return m()}else if(t===0){var r="function "+s+"(a,d) {this.data = a;this.offset = d};var proto="+s+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+s+"_copy() {return new "+s+"(this.data,this.offset)};proto.pick=function "+s+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+s+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+s+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+s+"(a,b,c,d){return new "+s+"(a,d)}",m=new Function("TrivialArray",r);return m(ce[e][0])}var r=["'use strict'"],a=ys(t),i=a.map(function(d){return"i"+d}),l="this.offset+"+a.map(function(d){return"this.stride["+d+"]*i"+d}).join("+"),o=a.map(function(d){return"b"+d}).join(","),u=a.map(function(d){return"c"+d}).join(",");r.push("function "+s+"(a,"+o+","+u+",d){this.data=a","this.shape=["+o+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+s+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+s+"_size(){return "+a.map(function(d){return"this.shape["+d+"]"}).join("*"),"}})"),t===1?r.push("proto.order=[0]"):(r.push("Object.defineProperty(proto,'order',{get:"),t<4?(r.push("function "+s+"_order(){"),t===2?r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):r.push("ORDER})")),r.push("proto.set=function "+s+"_set("+i.join(",")+",v){"),n?r.push("return this.data.set("+l+",v)}"):r.push("return this.data["+l+"]=v}"),r.push("proto.get=function "+s+"_get("+i.join(",")+"){"),n?r.push("return this.data.get("+l+")}"):r.push("return this.data["+l+"]}"),r.push("proto.index=function "+s+"_index(",i.join(),"){return "+l+"}"),r.push("proto.hi=function "+s+"_hi("+i.join(",")+"){return new "+s+"(this.data,"+a.map(function(d){return["(typeof i",d,"!=='number'||i",d,"<0)?this.shape[",d,"]:i",d,"|0"].join("")}).join(",")+","+a.map(function(d){return"this.stride["+d+"]"}).join(",")+",this.offset)}");var c=a.map(function(d){return"a"+d+"=this.shape["+d+"]"}),h=a.map(function(d){return"c"+d+"=this.stride["+d+"]"});r.push("proto.lo=function "+s+"_lo("+i.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+h.join(","));for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");r.push("return new "+s+"(this.data,"+a.map(function(d){return"a"+d}).join(",")+","+a.map(function(d){return"c"+d}).join(",")+",b)}"),r.push("proto.step=function "+s+"_step("+i.join(",")+"){var "+a.map(function(d){return"a"+d+"=this.shape["+d+"]"}).join(",")+","+a.map(function(d){return"b"+d+"=this.stride["+d+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");r.push("return new "+s+"(this.data,"+a.map(function(d){return"a"+d}).join(",")+","+a.map(function(d){return"b"+d}).join(",")+",c)}");for(var g=new Array(t),p=new Array(t),f=0;f<t;++f)g[f]="a[i"+f+"]",p[f]="b[i"+f+"]";r.push("proto.transpose=function "+s+"_transpose("+i+"){"+i.map(function(d,y){return d+"=("+d+"===undefined?"+y+":"+d+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+s+"(this.data,"+g.join(",")+","+p.join(",")+",this.offset)}"),r.push("proto.pick=function "+s+"_pick("+i+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+s+"(data,shape,stride,offset){return new "+s+"(data,"+a.map(function(d){return"shape["+d+"]"}).join(",")+","+a.map(function(d){return"stride["+d+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",r.join(`
|
|
7
|
+
`));return m(ce[e],_s)}function Es(e){if(bs(e))return"buffer";if(vs)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(e)?"array":"generic"}var ce={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function ws(e,t,s,n){if(e===void 0){var u=ce.array[0];return u([])}else typeof e=="number"&&(e=[e]);t===void 0&&(t=[e.length]);var r=t.length;if(s===void 0){s=new Array(r);for(var a=r-1,i=1;a>=0;--a)s[a]=i,i*=t[a]}if(n===void 0){n=0;for(var a=0;a<r;++a)s[a]<0&&(n-=(t[a]-1)*s[a])}for(var l=Es(e),o=ce[l];o.length<=r+1;)o.push(Ts(l,o.length-1));var u=o[r+1];return u(e,t,s,n)}var Is=ws;const Ms=Vt(Is);var Ns={};function Cs(e,t){for(var s=1,n=e.length,r=e[0],a=e[0],i=1;i<n;++i)if(a=r,r=e[i],t(r,a)){if(i===s){s++;continue}e[s++]=r}return e.length=s,e}function Ss(e){for(var t=1,s=e.length,n=e[0],r=e[0],a=1;a<s;++a,r=n)if(r=n,n=e[a],n!==r){if(a===t){t++;continue}e[t++]=n}return e.length=t,e}function Os(e,t,s){return e.length===0?e:t?(s||e.sort(t),Cs(e,t)):(s||e.sort(),Ss(e))}var xs=Os,js=xs;function Et(e,t,s){var n=e.length,r=t.arrayArgs.length,a=t.indexArgs.length>0,i=[],l=[],o=0,u=0,c,h;for(c=0;c<n;++c)l.push(["i",c,"=0"].join(""));for(h=0;h<r;++h)for(c=0;c<n;++c)u=o,o=e[c],c===0?l.push(["d",h,"s",c,"=t",h,"p",o].join("")):l.push(["d",h,"s",c,"=(t",h,"p",o,"-s",u,"*t",h,"p",u,")"].join(""));for(l.length>0&&i.push("var "+l.join(",")),c=n-1;c>=0;--c)o=e[c],i.push(["for(i",c,"=0;i",c,"<s",o,";++i",c,"){"].join(""));for(i.push(s),c=0;c<n;++c){for(u=o,o=e[c],h=0;h<r;++h)i.push(["p",h,"+=d",h,"s",c].join(""));a&&(c>0&&i.push(["index[",u,"]-=s",u].join("")),i.push(["++index[",o,"]"].join(""))),i.push("}")}return i.join(`
|
|
8
|
+
`)}function Rs(e,t,s,n){for(var r=t.length,a=s.arrayArgs.length,i=s.blockSize,l=s.indexArgs.length>0,o=[],u=0;u<a;++u)o.push(["var offset",u,"=p",u].join(""));for(var u=e;u<r;++u)o.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),o.push(["if(j",u,"<",i,"){"].join("")),o.push(["s",t[u],"=j",u].join("")),o.push(["j",u,"=0"].join("")),o.push(["}else{s",t[u],"=",i].join("")),o.push(["j",u,"-=",i,"}"].join("")),l&&o.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<a;++u){for(var c=["offset"+u],h=e;h<r;++h)c.push(["j",h,"*t",u,"p",t[h]].join(""));o.push(["p",u,"=(",c.join("+"),")"].join(""))}o.push(Et(t,s,n));for(var u=e;u<r;++u)o.push("}");return o.join(`
|
|
9
|
+
`)}function Ps(e){for(var t=0,s=e[0].length;t<s;){for(var n=1;n<e.length;++n)if(e[n][t]!==e[0][t])return t;++t}return t}function Te(e,t,s){for(var n=e.body,r=[],a=[],i=0;i<e.args.length;++i){var l=e.args[i];if(!(l.count<=0)){var o=new RegExp(l.name,"g"),u="",c=t.arrayArgs.indexOf(i);switch(t.argTypes[i]){case"offset":var h=t.offsetArgIndex.indexOf(i),f=t.offsetArgs[h];c=f.array,u="+q"+h;case"array":u="p"+c+u;var g="l"+i,p="a"+c;if(t.arrayBlockIndices[c]===0)l.count===1?s[c]==="generic"?l.lvalue?(r.push(["var ",g,"=",p,".get(",u,")"].join("")),n=n.replace(o,g),a.push([p,".set(",u,",",g,")"].join(""))):n=n.replace(o,[p,".get(",u,")"].join("")):n=n.replace(o,[p,"[",u,"]"].join("")):s[c]==="generic"?(r.push(["var ",g,"=",p,".get(",u,")"].join("")),n=n.replace(o,g),l.lvalue&&a.push([p,".set(",u,",",g,")"].join(""))):(r.push(["var ",g,"=",p,"[",u,"]"].join("")),n=n.replace(o,g),l.lvalue&&a.push([p,"[",u,"]=",g].join("")));else{for(var m=[l.name],d=[u],y=0;y<Math.abs(t.arrayBlockIndices[c]);y++)m.push("\\s*\\[([^\\]]+)\\]"),d.push("$"+(y+1)+"*t"+c+"b"+y);if(o=new RegExp(m.join(""),"g"),u=d.join("+"),s[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");n=n.replace(o,[p,"[",u,"]"].join(""))}break;case"scalar":n=n.replace(o,"Y"+t.scalarArgs.indexOf(i));break;case"index":n=n.replace(o,"index");break;case"shape":n=n.replace(o,"shape");break}}}return[r.join(`
|
|
10
|
+
`),n,a.join(`
|
|
11
|
+
`)].join(`
|
|
12
|
+
`).trim()}function zs(e){for(var t=new Array(e.length),s=!0,n=0;n<e.length;++n){var r=e[n],a=r.match(/\d+/);a?a=a[0]:a="",r.charAt(0)===0?t[n]="u"+r.charAt(1)+a:t[n]=r.charAt(0)+a,n>0&&(s=s&&t[n]===t[n-1])}return s?t[0]:t.join("")}function ks(e,t){for(var s=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,n=new Array(e.arrayArgs.length),r=new Array(e.arrayArgs.length),a=0;a<e.arrayArgs.length;++a)r[a]=t[2*a],n[a]=t[2*a+1];for(var i=[],l=[],o=[],u=[],c=[],a=0;a<e.arrayArgs.length;++a){e.arrayBlockIndices[a]<0?(o.push(0),u.push(s),i.push(s),l.push(s+e.arrayBlockIndices[a])):(o.push(e.arrayBlockIndices[a]),u.push(e.arrayBlockIndices[a]+s),i.push(0),l.push(e.arrayBlockIndices[a]));for(var h=[],f=0;f<n[a].length;f++)o[a]<=n[a][f]&&n[a][f]<u[a]&&h.push(n[a][f]-o[a]);c.push(h)}for(var g=["SS"],p=["'use strict'"],m=[],f=0;f<s;++f)m.push(["s",f,"=SS[",f,"]"].join(""));for(var a=0;a<e.arrayArgs.length;++a){g.push("a"+a),g.push("t"+a),g.push("p"+a);for(var f=0;f<s;++f)m.push(["t",a,"p",f,"=t",a,"[",o[a]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[a]);++f)m.push(["t",a,"b",f,"=t",a,"[",i[a]+f,"]"].join(""))}for(var a=0;a<e.scalarArgs.length;++a)g.push("Y"+a);if(e.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var d=new Array(s),a=0;a<s;++a)d[a]="0";m.push(["index=[",d.join(","),"]"].join(""))}for(var a=0;a<e.offsetArgs.length;++a){for(var y=e.offsetArgs[a],T=[],f=0;f<y.offset.length;++f)y.offset[f]!==0&&(y.offset[f]===1?T.push(["t",y.array,"p",f].join("")):T.push([y.offset[f],"*t",y.array,"p",f].join("")));T.length===0?m.push("q"+a+"=0"):m.push(["q",a,"=",T.join("+")].join(""))}var A=js([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));m=m.concat(A),m.length>0&&p.push("var "+m.join(","));for(var a=0;a<e.arrayArgs.length;++a)p.push("p"+a+"|=0");e.pre.body.length>3&&p.push(Te(e.pre,e,r));var b=Te(e.body,e,r),_=Ps(c);_<s?p.push(Rs(_,c[0],e,b)):p.push(Et(c[0],e,b)),e.post.body.length>3&&p.push(Te(e.post,e,r)),e.debug&&console.log("-----Generated cwise routine for ",t,`:
|
|
13
|
+
`+p.join(`
|
|
14
|
+
`)+`
|
|
15
|
+
----------`);var E=[e.funcName||"unnamed","_cwise_loop_",n[0].join("s"),"m",_,zs(r)].join(""),x=new Function(["function ",E,"(",g.join(","),"){",p.join(`
|
|
16
|
+
`),"} return ",E].join(""));return x()}var Ls=ks,$s=Ls;function Vs(e){var t=["'use strict'","var CACHED={}"],s=[],n=e.funcName+"_cwise_thunk";t.push(["return function ",n,"(",e.shimArgs.join(","),"){"].join(""));for(var r=[],a=[],i=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],l=[],o=[],u=0;u<e.arrayArgs.length;++u){var c=e.arrayArgs[u];s.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),r.push("t"+c),r.push("r"+c),a.push("t"+c),a.push("r"+c+".join()"),i.push("array"+c+".data"),i.push("array"+c+".stride"),i.push("array"+c+".offset|0"),u>0&&(l.push("array"+e.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[u]))),o.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[u])+"]"))}e.arrayArgs.length>1&&(t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<e.scalarArgs.length;++u)i.push("scalar"+e.scalarArgs[u]);s.push(["type=[",a.join(","),"].join()"].join("")),s.push("proc=CACHED[type]"),t.push("var "+s.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",r.join(","),"])}","return proc(",i.join(","),")}"].join("")),e.debug&&console.log(`-----Generated thunk:
|
|
17
|
+
`+t.join(`
|
|
18
|
+
`)+`
|
|
19
|
+
----------`);var h=new Function("compile",t.join(`
|
|
20
|
+
`));return h($s.bind(void 0,e))}var Us=Vs,Fs=Us;function Ds(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function qs(e){var t=new Ds;t.pre=e.pre,t.body=e.body,t.post=e.post;var s=e.args.slice(0);t.argTypes=s;for(var n=0;n<s.length;++n){var r=s[n];if(r==="array"||typeof r=="object"&&r.blockIndices){if(t.argTypes[n]="array",t.arrayArgs.push(n),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+n),n<t.pre.args.length&&t.pre.args[n].count>0)throw new Error("cwise: pre() block may not reference array args");if(n<t.post.args.length&&t.post.args[n].count>0)throw new Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(n),t.shimArgs.push("scalar"+n);else if(r==="index"){if(t.indexArgs.push(n),n<t.pre.args.length&&t.pre.args[n].count>0)throw new Error("cwise: pre() block may not reference array index");if(n<t.body.args.length&&t.body.args[n].lvalue)throw new Error("cwise: body() block may not write to array index");if(n<t.post.args.length&&t.post.args[n].count>0)throw new Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(n),n<t.pre.args.length&&t.pre.args[n].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(n<t.body.args.length&&t.body.args[n].lvalue)throw new Error("cwise: body() block may not write to array shape");if(n<t.post.args.length&&t.post.args[n].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof r=="object"&&r.offset)t.argTypes[n]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(n);else throw new Error("cwise: Unknown argument type "+s[n])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>s.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>s.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>s.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,Fs(t)}var Bs=qs;(function(e){var t=Bs,s={body:"",args:[],thisVars:[],localVars:[]};function n(f){if(!f)return s;for(var g=0;g<f.args.length;++g){var p=f.args[g];g===0?f.args[g]={name:p,lvalue:!0,rvalue:!!f.rvalue,count:f.count||1}:f.args[g]={name:p,lvalue:!1,rvalue:!0,count:1}}return f.thisVars||(f.thisVars=[]),f.localVars||(f.localVars=[]),f}function r(f){return t({args:f.args,pre:n(f.pre),body:n(f.body),post:n(f.proc),funcName:f.funcName})}function a(f){for(var g=[],p=0;p<f.args.length;++p)g.push("a"+p);var m=new Function("P",["return function ",f.funcName,"_ndarrayops(",g.join(","),") {P(",g.join(","),");return a0}"].join(""));return m(r(f))}var i={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var f in i){var g=i[f];e[f]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+g+"=b"},rvalue:!0,funcName:f+"eq"}),e[f+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+g+"=s"},rvalue:!0,funcName:f+"seq"})}})();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var f in l){var g=l[f];e[f]=a({args:["array","array"],body:{args:["a","b"],body:"a="+g+"b"},funcName:f}),e[f+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+g+"a"},rvalue:!0,count:2,funcName:f+"eq"})}})();var o={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var f in o){var g=o[f];e[f]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+g+"b"},rvalue:!0,count:2,funcName:f+"eq"}),e[f+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+g+"s"},rvalue:!0,count:2,funcName:f+"seq"})}})();var u=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var f=0;f<u.length;++f){var g=u[f];e[g]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:g}),e[g+"eq"]=a({args:["array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"})}})();var c=["max","min","atan2","pow"];(function(){for(var f=0;f<c.length;++f){var g=c[f];e[g]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g}),e[g+"s"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g+"s"}),e[g+"eq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"}),e[g+"seq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"seq"})}})();var h=["atan2","pow"];(function(){for(var f=0;f<h.length;++f){var g=h[f];e[g+"op"]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"op"}),e[g+"ops"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"ops"}),e[g+"opeq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opeq"}),e[g+"opseq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opseq"})}})(),e.any=t({args:["array"],pre:s,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),e.all=t({args:["array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),e.sum=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),e.prod=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),e.norm2squared=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),e.norm2=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),e.norminf=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),e.norm1=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),e.sup=t({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.inf=t({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.argmin=t({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.argmax=t({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),e.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),e.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),e.equals=t({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})})(Ns);function Gs(e,t){if(!(e instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");const s=new Blob([e],{type:t}),n=URL.createObjectURL(s);return new Promise((r,a)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=function(){URL.revokeObjectURL(n);const o=new OffscreenCanvas(i.width,i.height).getContext("2d");o.drawImage(i,0,0);const u=o.getImageData(0,0,i.width,i.height);r(Ms(new Uint8Array(u.data),[i.width,i.height,4],[4,4*i.width,1],0))},i.onerror=l=>{URL.revokeObjectURL(n),a(l)},i.src=n})}async function Ws(e,t){return Gs(e,t)}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},B.apply(null,arguments)}P.Mode;function D(e,t){return Object.defineProperty(t,"name",{value:e}),t}function H(e,t){const s=B({},e);for(const n in t)t[n]!==void 0&&(s[n]=t[n]);return s}class Ee{constructor(){this._map=new Map}get size(){return this._map.size}has(t){return this._map.has(t)}add(t,s){let n=this._map.get(t);return n||(n=new Set,this._map.set(t,n)),n.add(s),this}get(t){return this._map.get(t)||new Set}keys(){return this._map.keys()}}const Hs=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function We(e){return Hs.format(e)}function Xs(e,t,s=2){const n=e>t?"–":"+",r="%";return n+(Math.abs(e-t)/e*100).toFixed(s)+r}function Ks(e,t){return`${We(e)} → ${We(t)} (${Xs(e,t)})`}function wt(e){const t=[];for(const s of e.listAttributes())t.push(s);for(const s of e.listTargets())for(const n of s.listAttributes())t.push(n);return Array.from(new Set(t))}function Qs(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function ee(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function Js(e,t=e){const s=It(e,t);for(let n=0;n<s.length;n++)s[n]=n;return s}function It(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function Mt(e){for(const t in e)return!1;return!0}var fe=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Ys(e,t){var s=t[0],n=t[1],r=t[2],a=t[3],i=t[4],l=t[5],o=t[6],u=t[7],c=t[8],h=t[9],f=t[10],g=t[11],p=t[12],m=t[13],d=t[14],y=t[15],T=s*l-n*i,A=s*o-r*i,b=s*u-a*i,_=n*o-r*l,E=n*u-a*l,x=r*u-a*o,L=c*m-h*p,X=c*d-f*p,K=c*y-g*p,Q=h*d-f*m,J=h*y-g*m,Y=f*y-g*d,M=T*Y-A*J+b*Q+_*K-E*X+x*L;return M?(M=1/M,e[0]=(l*Y-o*J+u*Q)*M,e[1]=(r*J-n*Y-a*Q)*M,e[2]=(m*x-d*E+y*_)*M,e[3]=(f*E-h*x-g*_)*M,e[4]=(o*K-i*Y-u*X)*M,e[5]=(s*Y-r*K+a*X)*M,e[6]=(d*b-p*x-y*A)*M,e[7]=(c*x-f*b+g*A)*M,e[8]=(i*J-l*K+u*L)*M,e[9]=(n*K-s*J-a*L)*M,e[10]=(p*E-m*b+y*T)*M,e[11]=(h*b-c*E-g*T)*M,e[12]=(l*X-i*Q-o*L)*M,e[13]=(s*Q-n*X+r*L)*M,e[14]=(m*A-p*_-d*T)*M,e[15]=(c*_-h*A+f*T)*M,e):null}function ke(e,t,s){var n=t[0],r=t[1],a=t[2],i=t[3],l=t[4],o=t[5],u=t[6],c=t[7],h=t[8],f=t[9],g=t[10],p=t[11],m=t[12],d=t[13],y=t[14],T=t[15],A=s[0],b=s[1],_=s[2],E=s[3];return e[0]=A*n+b*l+_*h+E*m,e[1]=A*r+b*o+_*f+E*d,e[2]=A*a+b*u+_*g+E*y,e[3]=A*i+b*c+_*p+E*T,A=s[4],b=s[5],_=s[6],E=s[7],e[4]=A*n+b*l+_*h+E*m,e[5]=A*r+b*o+_*f+E*d,e[6]=A*a+b*u+_*g+E*y,e[7]=A*i+b*c+_*p+E*T,A=s[8],b=s[9],_=s[10],E=s[11],e[8]=A*n+b*l+_*h+E*m,e[9]=A*r+b*o+_*f+E*d,e[10]=A*a+b*u+_*g+E*y,e[11]=A*i+b*c+_*p+E*T,A=s[12],b=s[13],_=s[14],E=s[15],e[12]=A*n+b*l+_*h+E*m,e[13]=A*r+b*o+_*f+E*d,e[14]=A*a+b*u+_*g+E*y,e[15]=A*i+b*c+_*p+E*T,e}function Zs(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function en(e,t,s,n){var r=t[0],a=t[1],i=t[2],l=t[3],o=r+r,u=a+a,c=i+i,h=r*o,f=r*u,g=r*c,p=a*u,m=a*c,d=i*c,y=l*o,T=l*u,A=l*c,b=n[0],_=n[1],E=n[2];return e[0]=(1-(p+d))*b,e[1]=(f+A)*b,e[2]=(g-T)*b,e[3]=0,e[4]=(f-A)*_,e[5]=(1-(h+d))*_,e[6]=(m+y)*_,e[7]=0,e[8]=(g+T)*E,e[9]=(m-y)*E,e[10]=(1-(h+p))*E,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function tn(){var e=new fe(3);return fe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function sn(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e}function Ne(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e}function Ce(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e}function He(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function nn(e,t,s){var n=t[0],r=t[1],a=t[2],i=s[3]*n+s[7]*r+s[11]*a+s[15];return i=i||1,e[0]=(s[0]*n+s[4]*r+s[8]*a+s[12])/i,e[1]=(s[1]*n+s[5]*r+s[9]*a+s[13])/i,e[2]=(s[2]*n+s[6]*r+s[10]*a+s[14])/i,e}var rn=sn;(function(){var e=tn();return function(t,s,n,r,a,i){var l,o;for(s||(s=3),n||(n=0),r?o=Math.min(r*s+n,t.length):o=t.length,l=n;l<o;l+=s)e[0]=t[l],e[1]=t[l+1],e[2]=t[l+2],a(e,e,i),t[l]=e[0],t[l+1]=e[1],t[l+2]=e[2];return t}})();const F="dedup",we={keepUniqueNames:!1,propertyTypes:[v.ACCESSOR,v.MESH,v.TEXTURE,v.MATERIAL,v.SKIN]};function an(e=we){const t=H(we,e),s=new Set(t.propertyTypes);for(const n of t.propertyTypes)if(!we.propertyTypes.includes(n))throw new Error(`${F}: Unsupported deduplication on type "${n}".`);return D(F,n=>{const r=n.getLogger();s.has(v.ACCESSOR)&&on(n),s.has(v.TEXTURE)&&cn(n,t),s.has(v.MATERIAL)&&fn(n,t),s.has(v.MESH)&&ln(n,t),s.has(v.SKIN)&&un(n,t),r.debug(`${F}: Complete.`)})}function on(e){const t=e.getLogger(),s=new Map,n=new Map,r=new Map,a=new Map,i=e.getRoot().listMeshes();i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(g=>l(g,n)),l(f.getIndices(),s)})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers())l(f.getInput(),r),l(f.getOutput(),a);function l(h,f){if(!h)return;const g=[h.getCount(),h.getType(),h.getComponentType(),h.getNormalized(),h.getSparse()].join(":");let p=f.get(g);p||f.set(g,p=new Set),p.add(h)}function o(h,f){for(let g=0;g<h.length;g++){const p=h[g],m=N.toView(p.getArray());if(!f.has(p))for(let d=g+1;d<h.length;d++){const y=h[d];f.has(y)||N.equals(m,N.toView(y.getArray()))&&f.set(y,p)}}}let u=0;const c=new Map;for(const h of[n,s,r,a])for(const f of h.values())u+=f.size,o(Array.from(f),c);t.debug(`${F}: Merged ${c.size} of ${u} accessors.`),i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(p=>{c.has(p)&&f.swap(p,c.get(p))});const g=f.getIndices();g&&c.has(g)&&f.swap(g,c.get(g))})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers()){const g=f.getInput(),p=f.getOutput();g&&c.has(g)&&f.swap(g,c.get(g)),p&&c.has(p)&&f.swap(p,c.get(p))}Array.from(c.keys()).forEach(h=>h.dispose())}function ln(e,t){const s=e.getLogger(),n=e.getRoot(),r=new Map;n.listAccessors().forEach((l,o)=>r.set(l,o)),n.listMaterials().forEach((l,o)=>r.set(l,o));const a=n.listMeshes().length,i=new Map;for(const l of n.listMeshes()){const o=[];for(const c of l.listPrimitives())o.push(Nt(c,r));let u="";if(t.keepUniqueNames&&(u+=l.getName()+";"),u+=o.join(";"),i.has(u)){const c=i.get(u);l.listParents().forEach(h=>{h.propertyType!==v.ROOT&&h.swap(l,c)}),l.dispose()}else i.set(u,l)}s.debug(`${F}: Merged ${a-i.size} of ${a} meshes.`)}function cn(e,t){const s=e.getLogger(),n=e.getRoot(),r=n.listTextures(),a=new Map;for(let i=0;i<r.length;i++){const l=r[i],o=l.getImage();if(!a.has(l))for(let u=i+1;u<r.length;u++){const c=r[u],h=c.getImage();if(a.has(c)||l.getMimeType()!==c.getMimeType()||t.keepUniqueNames&&l.getName()!==c.getName())continue;const f=l.getSize(),g=c.getSize();!f||!g||f[0]===g[0]&&f[1]===g[1]&&(!o||!h||N.equals(o,h)&&a.set(c,l))}}s.debug(`${F}: Merged ${a.size} of ${n.listTextures().length} textures.`),Array.from(a.entries()).forEach(([i,l])=>{i.listParents().forEach(o=>{o instanceof me||o.swap(i,l)}),i.dispose()})}function fn(e,t){const s=e.getLogger(),r=e.getRoot().listMaterials(),a=new Map,i=new Map,l=new Set;t.keepUniqueNames||l.add("name");for(let o=0;o<r.length;o++){const u=r[o];if(!a.has(u)&&!Xe(u,i))for(let c=o+1;c<r.length;c++){const h=r[c];a.has(h)||Xe(h,i)||u.equals(h,l)&&a.set(h,u)}}s.debug(`${F}: Merged ${a.size} of ${r.length} materials.`),Array.from(a.entries()).forEach(([o,u])=>{o.listParents().forEach(c=>{c instanceof me||c.swap(o,u)}),o.dispose()})}function un(e,t){const s=e.getLogger(),r=e.getRoot().listSkins(),a=new Map,i=new Set(["joints"]);t.keepUniqueNames||i.add("name");for(let l=0;l<r.length;l++){const o=r[l];if(!a.has(o))for(let u=l+1;u<r.length;u++){const c=r[u];a.has(c)||o.equals(c,i)&&Qs(o.listJoints(),c.listJoints())&&a.set(c,o)}}s.debug(`${F}: Merged ${a.size} of ${r.length} skins.`),Array.from(a.entries()).forEach(([l,o])=>{l.listParents().forEach(u=>{u instanceof me||u.swap(l,o)}),l.dispose()})}function Nt(e,t){const s=[];for(const n of e.listSemantics()){const r=e.getAttribute(n);s.push(n+":"+t.get(r))}if(e instanceof P){const n=e.getIndices();n&&s.push("indices:"+t.get(n));const r=e.getMaterial();r&&s.push("material:"+t.get(r)),s.push("mode:"+e.getMode());for(const a of e.listTargets())s.push("target:"+Nt(a,t))}return s.join(",")}function Xe(e,t){if(t.has(e))return t.get(e);const s=e.getGraph(),n=new Set,r=s.listParentEdges(e);for(;r.length>0;){const a=r.pop();if(a.getAttributes().modifyChild===!0)return t.set(e,!0),!0;const i=a.getChild();if(!n.has(i))for(const l of s.listChildEdges(i))r.push(l)}return t.set(e,!1),!1}function Ct(){var e=new fe(4);return fe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function hn(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e}function gn(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e}function pn(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e[3]=t[3]*s[3],e}function dn(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e}function mn(e){var t=e[0],s=e[1],n=e[2],r=e[3];return Math.hypot(t,s,n,r)}var St=gn,yn=pn,Ot=mn;(function(){var e=Ct();return function(t,s,n,r,a,i){var l,o;for(s||(s=4),n||(n=0),r?o=Math.min(r*s+n,t.length):o=t.length,l=n;l<o;l+=s)e[0]=t[l],e[1]=t[l+1],e[2]=t[l+2],e[3]=t[l+3],a(e,e,i),t[l]=e[0],t[l+1]=e[1],t[l+2]=e[2],t[l+3]=e[3];return t}})();const bn=/color|emissive|diffuse/i;function vn(e){return e.getGraph().listParentEdges(e).some(r=>r.getAttributes().isColor||bn.test(r.getName()))?"srgb":null}function An(e){const t=e.getGraph(),s=new Set,n=new Set;function r(a){const i=new Set;for(const l of t.listChildEdges(a))l.getChild()instanceof Me&&i.add(l.getName()+"Info");for(const l of t.listChildEdges(a)){const o=l.getChild();s.has(o)||(s.add(o),o instanceof yt&&i.has(l.getName())?n.add(o):o instanceof bt&&r(o))}}return r(e),Array.from(n)}function _n(e){const s=ze.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter(r=>r.getParent()!==s).map(r=>r.getName());return Array.from(new Set(n))}const q="prune",Se=3/255,Ke={propertyTypes:[v.NODE,v.SKIN,v.MESH,v.CAMERA,v.PRIMITIVE,v.PRIMITIVE_TARGET,v.ANIMATION,v.MATERIAL,v.TEXTURE,v.ACCESSOR,v.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function xt(e=Ke){const t=H(Ke,e),s=new Set(t.propertyTypes),n=t.keepExtras;return D(q,async r=>{const a=r.getLogger(),i=r.getRoot(),l=r.getGraph(),o=new Tn,u=c=>o.dispose(c.target);if(l.addEventListener("node:dispose",u),s.has(v.MESH))for(const c of i.listMeshes())c.listPrimitives().length>0||c.dispose();if(s.has(v.NODE)){if(!t.keepLeaves)for(const c of i.listScenes())jt(l,c,n);for(const c of i.listNodes())S(c,n)}if(s.has(v.SKIN))for(const c of i.listSkins())S(c,n);if(s.has(v.MESH))for(const c of i.listMeshes())S(c,n);if(s.has(v.CAMERA))for(const c of i.listCameras())S(c,n);if(s.has(v.PRIMITIVE)&&Qe(l,v.PRIMITIVE,n),s.has(v.PRIMITIVE_TARGET)&&Qe(l,v.PRIMITIVE_TARGET,n),!t.keepAttributes&&s.has(v.ACCESSOR)){const c=new Map;for(const h of i.listMeshes())for(const f of h.listPrimitives()){const g=f.getMaterial();if(!g)continue;const p=Rt(r,f,g),m=wn(f,p);Je(f,m),f.listTargets().forEach(d=>Je(d,m)),c.has(g)?c.get(g).add(f):c.set(g,new Set([f]))}for(const[h,f]of c)In(h,Array.from(f))}if(!t.keepIndices&&s.has(v.ACCESSOR))for(const c of i.listMeshes())for(const h of c.listPrimitives())En(h);if(s.has(v.ANIMATION))for(const c of i.listAnimations()){for(const h of c.listChannels())h.getTargetNode()||h.dispose();if(c.listChannels().length)c.listSamplers().forEach(h=>S(h,n));else{const h=c.listSamplers();S(c,n),h.forEach(f=>S(f,n))}}if(s.has(v.MATERIAL)&&i.listMaterials().forEach(c=>S(c,n)),s.has(v.TEXTURE)&&(i.listTextures().forEach(c=>S(c,n)),t.keepSolidTextures||await Mn(r)),s.has(v.ACCESSOR)&&i.listAccessors().forEach(c=>S(c,n)),s.has(v.BUFFER)&&i.listBuffers().forEach(c=>S(c,n)),l.removeEventListener("node:dispose",u),o.empty())a.debug(`${q}: No unused properties found.`);else{const c=o.entries().map(([h,f])=>`${h} (${f})`).join(", ");a.info(`${q}: Removed types... ${c}`)}a.debug(`${q}: Complete.`)})}class Tn{constructor(){this.disposed={}}empty(){for(const t in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(t){this.disposed[t.propertyType]=this.disposed[t.propertyType]||0,this.disposed[t.propertyType]++}}function S(e,t){const s=e.listParents().filter(r=>!(r instanceof me||r instanceof Pe)),n=t&&!Mt(e.getExtras());!s.length&&!n&&e.dispose()}function Qe(e,t,s){for(const n of e.listEdges()){const r=n.getParent();r.propertyType===t&&S(r,s)}}function jt(e,t,s){if(t.listChildren().forEach(i=>jt(e,i,s)),t instanceof es)return;const n=e.listParentEdges(t).some(i=>{const l=i.getParent().propertyType;return l!==v.ROOT&&l!==v.SCENE&&l!==v.NODE}),r=e.listChildren(t).length===0,a=s&&!Mt(t.getExtras());r&&!n&&!a&&t.dispose()}function Je(e,t){for(const s of t)e.setAttribute(s,null)}function En(e){const t=e.getIndices(),s=t&&t.getArray(),n=e.listAttributes()[0];if(!(!s||!n)&&t.getCount()===n.getCount()){for(let r=0,a=s.length;r<a;r++)if(r!==s[r])return;e.setIndices(null)}}function wn(e,t){const s=[];for(const n of e.listSemantics())(n==="NORMAL"&&!t.has(n)||n==="TANGENT"&&!t.has(n)||n.startsWith("TEXCOORD_")&&!t.has(n)||n.startsWith("COLOR_")&&n!=="COLOR_0")&&s.push(n);return s}function Rt(e,t,s,n=new Set){const a=e.getGraph().listChildEdges(s),i=new Set;for(const u of a)u.getChild()instanceof Me&&i.add(u.getName());for(const u of a){const c=u.getName(),h=u.getChild();h instanceof yt&&i.has(c.replace(/Info$/,""))&&n.add(`TEXCOORD_${h.getTexCoord()}`),h instanceof Me&&c.match(/normalTexture/i)&&n.add("TANGENT"),h instanceof bt&&Rt(e,t,h,n)}const l=s instanceof vt&&!s.getExtension("KHR_materials_unlit"),o=t.getMode()===P.Mode.POINTS;return l&&!o&&n.add("NORMAL"),n}function In(e,t){const s=An(e),n=new Set(s.map(o=>o.getTexCoord())),r=Array.from(n).sort(),a=new Map(r.map((o,u)=>[o,u])),i=new Map(r.map((o,u)=>[`TEXCOORD_${o}`,`TEXCOORD_${u}`]));for(const o of s){const u=o.getTexCoord();o.setTexCoord(a.get(u))}for(const o of t){const u=o.listSemantics().filter(c=>c.startsWith("TEXCOORD_")).sort();l(o,u),o.listTargets().forEach(c=>l(c,u))}function l(o,u){for(const c of u){const h=o.getAttribute(c);if(!h)continue;const f=i.get(c);f!==c&&(o.setAttribute(f,h),o.setAttribute(c,null))}}}async function Mn(e){const t=e.getRoot(),s=e.getGraph(),n=e.getLogger(),a=t.listTextures().map(async i=>{var l;const o=await Cn(i);if(!o)return;vn(i)==="srgb"&&ts.convertSRGBToLinear(o,o);const u=i.getName()||i.getURI(),c=(l=i.getSize())==null?void 0:l.join("x"),h=_n(i);for(const f of s.listParentEdges(i)){const g=f.getParent();g!==t&&Nn(g,o,f.getName(),n)&&f.dispose()}i.listParents().length===1&&(i.dispose(),n.debug(`${q}: Removed solid-color texture "${u}" (${c}px ${h.join(", ")})`))});await Promise.all(a)}function Nn(e,t,s,n){if(e instanceof vt)switch(s){case"baseColorTexture":return e.setBaseColorFactor(yn(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(rn([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Se;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return Ot(St(Ct(),t,[.5,.5,1,1]))<=Se}return n.warn(`${q}: Detected single-color ${s} texture. Pruning ${s} not yet supported.`),!1}async function Cn(e){const t=await Sn(e);if(!t)return null;const s=[1/0,1/0,1/0,1/0],n=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[a,i]=t.shape;for(let l=0;l<a;l++){for(let o=0;o<i;o++)for(let u=0;u<4;u++)s[u]=Math.min(s[u],t.get(l,o,u)),n[u]=Math.max(n[u],t.get(l,o,u));if(Ot(St(r,n,s))/255>Se)return null}return dn(r,hn(r,n,s),.5/255)}async function Sn(e){try{return await Ws(e.getImage(),e.getMimeType())}catch{return null}}const Ye=2**32-1;var C;(function(e){e.RENDER="render",e.RENDER_CACHED="render-cached",e.UPLOAD="upload",e.UPLOAD_NAIVE="upload-naive",e.DISTINCT="distinct",e.DISTINCT_POSITION="distinct-position",e.UNUSED="unused"})(C||(C={}));function ue(e,t){const s=e.getAttribute("POSITION"),n=e.getIndices();switch(t){case C.RENDER:return n?n.getCount():s.getCount();case C.RENDER_CACHED:return n?new Set(n.getArray()).size:s.getCount();case C.UPLOAD_NAIVE:case C.UPLOAD:return s.getCount();case C.DISTINCT:case C.DISTINCT_POSITION:return On(t);case C.UNUSED:return n?s.getCount()-new Set(n.getArray()).size:0;default:return xn(t)}}function On(e){throw new Error(`Not implemented: ${e}`)}function xn(e){throw new Error(`Unexpected value: ${e}`)}function jn(e,t,s){const n=ze.fromGraph(e.getGraph());(!t||!s)&&([t,s]=Rn(e));const r=e.getIndices(),a=r?r.getArray():null,i=ue(e,C.RENDER),l=n.createAccessor(),o=i,u=It(o,s);for(let h=0;h<o;h++)u[h]=t[a?a[h]:h];e.setIndices(l.setArray(u));const c=wt(e);for(const h of e.listAttributes()){const f=ee(n,h);Oe(h,r,t,f,s),e.swap(h,f)}for(const h of e.listTargets())for(const f of h.listAttributes()){const g=ee(n,f);Oe(f,r,t,g,s),h.swap(f,g)}r&&r.listParents().length===1&&r.dispose();for(const h of c)h.listParents().length===1&&h.dispose();return e}function Oe(e,t,s,n,r){const a=e.getElementSize(),i=e.getArray(),l=t?t.getArray():null,o=t?t.getCount():e.getCount(),u=new i.constructor(r*a),c=new Uint8Array(r);for(let h=0;h<o;h++){const f=l?l[h]:h,g=s[f];if(!c[g]){for(let p=0;p<a;p++)u[g*a+p]=i[f*a+p];c[g]=1}}return n.setArray(u)}function Rn(e){const t=ue(e,C.UPLOAD),s=e.getIndices(),n=s?s.getArray():null;if(!s||!n)return[Js(t,1e6),t];const r=new Uint32Array(t).fill(Ye);let a=0;for(let i=0;i<n.length;i++){const l=n[i];r[l]===Ye&&(r[l]=a++)}return[r,a]}Ie.ComponentType;P.Mode;P.Mode;const ne="reorder",Pn={target:"size",cleanup:!0};function zn(e){const t=H(Pn,e),s=t.encoder;if(!s)throw new Error(`${ne}: encoder dependency required — install "meshoptimizer".`);return D(ne,async n=>{const r=n.getLogger();await s.ready;const a=kn(n);for(const i of a.indicesToAttributes.keys()){let l=i.getArray();l instanceof Uint32Array?l=l.slice():l=new Uint32Array(l);const[o,u]=s.reorderMesh(l,a.indicesToMode.get(i)===P.Mode.TRIANGLES,t.target==="size"),c=ee(n,i);c.setArray(u<=65534?new Uint16Array(l):l);for(const h of a.indicesToAttributes.get(i)){const f=ee(n,h);Oe(h,i,o,f,u);for(const g of a.indicesToPrimitives.get(i)){g.getIndices()===i&&g.swap(i,c),g.swap(h,f);for(const p of g.listTargets())p.swap(h,f)}}}t.cleanup&&await n.transform(xt({propertyTypes:[v.ACCESSOR],keepAttributes:!0,keepIndices:!0})),a.indicesToAttributes.size?r.debug(`${ne}: Complete.`):r.warn(`${ne}: No qualifying primitives found; may need to weld first.`)})}function kn(e){const t=new Map,s=new Ee,n=new Ee,r=new Ee;for(const a of e.getRoot().listMeshes())for(const i of a.listPrimitives()){const l=i.getIndices();if(l){t.set(l,i.getMode()),s.add(l,i);for(const o of wt(i))n.add(l,o),r.add(o,i)}}return{indicesToPrimitives:s,indicesToAttributes:n,indicesToMode:t,attributesToPrimitives:r}}function Ln(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw new Error("Limit must be positive multiple of four.");const s=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter(u=>u.startsWith("WEIGHTS_")).length,r=new Uint16Array(n*4),a=new Float32Array(n*4),i=new Float32Array(n*4),l=new Uint32Array(n*4),o=new Uint32Array(n*4);for(let u=0;u<s;u++){he(e,u,"WEIGHTS",a),he(e,u,"JOINTS",l);for(let c=0;c<n*4;c++)r[c]=c;r.sort((c,h)=>a[c]>a[h]?-1:1);for(let c=0;c<r.length;c++)i[c]=a[r[c]],o[c]=l[r[c]];ge(e,u,"WEIGHTS",i),ge(e,u,"JOINTS",o)}for(let u=n;u*4>t;u--){const c=e.getAttribute(`WEIGHTS_${u-1}`),h=e.getAttribute(`JOINTS_${u-1}`);e.setAttribute(`WEIGHTS_${u-1}`,null),e.setAttribute(`JOINTS_${u-1}`,null),c.listParents().length===1&&c.dispose(),h.listParents().length===1&&h.dispose()}$n(e)}function $n(e){if(!Vn(e))return;const t=e.getAttribute("POSITION").getCount(),s=e.listSemantics().filter(h=>h.startsWith("WEIGHTS_")).length,n=e.getAttribute("WEIGHTS_0"),r=n.getArray(),a=n.getComponentType(),i=n.getNormalized(),l=i?a:void 0,o=i?V.decodeNormalizedInt(1,a):Number.EPSILON,u=new Uint32Array(s*4).fill(0),c=r.slice(0,s*4).fill(0);for(let h=0;h<t;h++){he(e,h,"JOINTS",u),he(e,h,"WEIGHTS",c,l);let f=Ze(c,l);if(f!==0&&f!==1){if(Math.abs(1-f)>o)for(let g=0;g<c.length;g++)if(i){const p=V.decodeNormalizedInt(c[g],a);c[g]=V.encodeNormalizedInt(p/f,a)}else c[g]/=f;if(f=Ze(c,l),i&&f!==1){for(let g=c.length-1;g>=0;g--)if(c[g]>0){const p=1-f;c[g]+=Math.sign(p)*V.encodeNormalizedInt(Math.abs(p),a);break}}}for(let g=c.length-1;g>=0;g--)c[g]===0&&(u[g]=0);ge(e,h,"JOINTS",u),ge(e,h,"WEIGHTS",c,l)}}function he(e,t,s,n,r){let a;const i=[0,0,0,0];for(let l=0;a=e.getAttribute(`${s}_${l}`);l++){a.getElement(t,i);for(let o=0;o<4;o++)r?n[l*4+o]=V.encodeNormalizedInt(i[o],r):n[l*4+o]=i[o]}return n}function ge(e,t,s,n,r){let a;const i=[0,0,0,0];for(let l=0;a=e.getAttribute(`${s}_${l}`);l++){for(let o=0;o<4;o++)r?i[o]=V.decodeNormalizedInt(n[l*4+o],r):i[o]=n[l*4+o];a.setElement(t,i)}}function Ze(e,t){let s=0;for(let n=0;n<e.length;n++)t?s+=V.decodeNormalizedInt(e[n],t):s+=e[n];return s}function Vn(e){const t=e.listSemantics().filter(r=>r.startsWith("WEIGHTS_")).map(r=>e.getAttribute(r)),s=t.map(r=>r.getNormalized()),n=t.map(r=>r.getComponentType());return new Set(s).size===1&&new Set(n).size===1}const U="quantize",Un=[Int8Array,Int16Array,Int32Array],{TRANSLATION:Fn,ROTATION:Dn,SCALE:qn,WEIGHTS:Bn}=Pe.TargetPath,Gn=[Fn,Dn,qn],oe={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};function Le(e=oe){const t=H(oe,B({patternTargets:e.pattern||oe.pattern},e));return D(U,async s=>{const n=s.getLogger(),r=s.getRoot();let a;t.quantizationVolume==="scene"&&(a=tt(Zn(r.listMeshes().map(st))));for(const l of s.getRoot().listMeshes()){t.quantizationVolume==="mesh"&&(a=tt(st(l))),a&&t.pattern.test("POSITION")&&(Wn(s,l,a),Kn(l,1/a.scale));for(const o of l.listPrimitives()){const u=ue(o,C.RENDER),c=ue(o,C.UPLOAD);u<c/2&&jn(o),et(s,o,a,t);for(const h of o.listTargets())et(s,h,a,t)}}r.listMeshes().flatMap(l=>l.listPrimitives()).some(Pt)&&s.createExtension(mt).setRequired(!0),t.cleanup&&await s.transform(xt({propertyTypes:[v.ACCESSOR,v.SKIN,v.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),an({propertyTypes:[v.ACCESSOR,v.MATERIAL,v.SKIN],keepUniqueNames:!0})),n.debug(`${U}: Complete.`)})}function et(e,t,s,n){const r=t instanceof ss,a=e.getLogger();for(const i of t.listSemantics()){if(!r&&!n.pattern.test(i)||r&&!n.patternTargets.test(i))continue;const l=t.getAttribute(i),{bits:o,ctor:u}=Jn(i,l,a,n);if(!u)continue;if(o<8||o>16)throw new Error(`${U}: Requires bits = 8–16.`);if(l.getComponentSize()<=o/8)continue;const c=l.clone();if(i==="POSITION"){const h=s.scale,f=[];t instanceof P?Ys(f,ye(s)):Zs(f,[1/h,1/h,1/h]);for(let g=0,p=[0,0,0],m=c.getCount();g<m;g++)c.getElement(g,p),c.setElement(g,nn(p,p,f))}Qn(c,u,o),t.setAttribute(i,c)}if(n.normalizeWeights&&t.getAttribute("WEIGHTS_0")&&Ln(t,1/0),t instanceof P&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){const i=t.getIndices();i.setArray(new Uint16Array(i.getArray()))}}function tt(e){const{min:t,max:s}=e,n=Math.max((s[0]-t[0])/2,(s[1]-t[1])/2,(s[2]-t[2])/2);return{offset:[t[0]+(s[0]-t[0])/2,t[1]+(s[1]-t[1])/2,t[2]+(s[2]-t[2])/2],scale:n}}function Wn(e,t,s){const n=ye(s);for(const r of t.listParents()){if(!(r instanceof Zt))continue;const a=r.listParents().filter(f=>f instanceof Pe),i=a.some(f=>Gn.includes(f.getTargetPath())),l=r.listChildren().length>0,o=r.getSkin();if(o){r.setSkin(Hn(o,s));continue}const u=r.getExtension("EXT_mesh_gpu_instancing");if(u){r.setExtension("EXT_mesh_gpu_instancing",Xn(u,s));continue}let c;l||i?(c=e.createNode("").setMesh(t),r.addChild(c).setMesh(null),a.filter(f=>f.getTargetPath()===Bn).forEach(f=>f.setTargetNode(c))):c=r;const h=c.getMatrix();ke(h,h,n),c.setMatrix(h)}}function Hn(e,t){e=e.clone();const s=ye(t),n=e.getInverseBindMatrices().clone(),r=[];for(let a=0,i=n.getCount();a<i;a++)n.getElement(a,r),ke(r,r,s),n.setElement(a,r);return e.setInverseBindMatrices(n)}function Xn(e,t){var s,n,r;if(!e.getAttribute("TRANSLATION")&&!e.getAttribute("ROTATION")&&!e.getAttribute("SCALE"))return e;e=e.clone();const a=(s=e.getAttribute("TRANSLATION"))==null?void 0:s.clone(),i=(n=e.getAttribute("ROTATION"))==null?void 0:n.clone(),l=(r=e.getAttribute("SCALE"))==null?void 0:r.clone(),o=a||i||l,u=[0,0,0],c=[0,0,0,1],h=[1,1,1],f=[0,0,0],g=[0,0,0,1],p=[1,1,1],m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],d=ye(t);for(let y=0,T=o.getCount();y<T;y++)V.compose(a?a.getElement(y,f):u,i?i.getElement(y,g):c,l?l.getElement(y,p):h,m),ke(m,m,d),V.decompose(m,f,g,p),a&&a.setElement(y,f),i&&i.setElement(y,g),l&&l.setElement(y,p);return a&&e.setAttribute("TRANSLATION",a),i&&e.setAttribute("ROTATION",i),l&&e.setAttribute("SCALE",l),e}function Kn(e,t){for(const s of e.listPrimitives()){let n=s.getMaterial();if(!n)continue;let r=n.getExtension("KHR_materials_volume");!r||r.getThicknessFactor()<=0||(r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),n=n.clone().setExtension("KHR_materials_volume",r),s.setMaterial(n))}}function Qn(e,t,s){const n=new t(e.getArray().length),r=Un.includes(t)?1:0,a=s-r,i=t.BYTES_PER_ELEMENT*8-r,l=Math.pow(2,a)-1,o=i-a,u=2*a-i,c=[r>0?-1:0,1];for(let h=0,f=0,g=[];h<e.getCount();h++){e.getElement(h,g);for(let p=0;p<g.length;p++){let m=er(g[p],c);m=Math.round(Math.abs(m)*l),m=m<<o|m>>u,n[f++]=m*Math.sign(g[p])}}e.setArray(n).setNormalized(!0).setSparse(!1)}function Jn(e,t,s,n){const r=t.getMinNormalized([]),a=t.getMaxNormalized([]);let i,l;if(e==="POSITION")i=n.quantizePosition,l=i<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")i=n.quantizeNormal,l=i<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))i=n.quantizeColor,l=i<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some(o=>o<0)||a.some(o=>o>1))return s.warn(`${U}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=n.quantizeTexcoord,l=i<=8?Uint8Array:Uint16Array}else{if(e.startsWith("JOINTS_"))return i=Math.max(...t.getMax([]))<=255?8:16,l=i<=8?Uint8Array:Uint16Array,t.getComponentSize()>i/8&&t.setArray(new l(t.getArray())),{bits:-1};if(e.startsWith("WEIGHTS_")){if(r.some(o=>o<0)||a.some(o=>o>1))return s.warn(`${U}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=n.quantizeWeight,l=i<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some(o=>o<-1)||a.some(o=>o>1))return s.warn(`${U}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};i=n.quantizeGeneric,l=r.some(o=>o<0)?l=i<=8?Int8Array:Int16Array:l=i<=8?Uint8Array:Uint16Array}else throw new Error(`${U}: Unexpected semantic, "${e}".`)}return{bits:i,ctor:l}}function st(e){const t=[],s=[];for(const r of e.listPrimitives()){const a=r.getAttribute("POSITION");a&&t.push(a);for(const i of r.listTargets()){const l=i.getAttribute("POSITION");l&&s.push(l)}}if(t.length===0)throw new Error(`${U}: Missing "POSITION" attribute.`);const n=nt(t,3);if(s.length>0){const{min:r,max:a}=nt(s,3);Ne(n.min,n.min,Ne(r,He(r,r,2),[0,0,0])),Ce(n.max,n.max,Ce(a,He(a,a,2),[0,0,0]))}return n}function Yn(e,t){const s=t.getComponentSize();if(e==="POSITION"||e==="NORMAL"||e==="TANGENT")return s<4;if(e.startsWith("TEXCOORD_")){const n=t.getComponentType(),r=t.getNormalized();return s<4&&!(r&&n===Ie.ComponentType.UNSIGNED_BYTE)&&!(r&&n===Ie.ComponentType.UNSIGNED_SHORT)}return!1}function Pt(e){for(const t of e.listSemantics()){const s=e.getAttribute("POSITION");if(Yn(t,s))return!0}return e.propertyType===v.PRIMITIVE?e.listTargets().some(Pt):!1}function nt(e,t){const s=new Array(t).fill(1/0),n=new Array(t).fill(-1/0),r=[],a=[];for(const i of e){i.getMinNormalized(r),i.getMaxNormalized(a);for(let l=0;l<t;l++)s[l]=Math.min(s[l],r[l]),n[l]=Math.max(n[l],a[l])}return{min:s,max:n}}function Zn(e){const t=e[0];for(const s of e)Ne(t.min,t.min,s.min),Ce(t.max,t.max,s.max);return t}function ye(e){return en([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function er(e,t){return Math.min(Math.max(e,t[0]),t[1])}const tr=B({level:"high"},oe),rt="meshopt";function zt(e){const t=H(tr,e),s=t.encoder;if(!s)throw new Error(`${rt}: encoder dependency required — install "meshoptimizer".`);return D(rt,async n=>{let r,a,i=t.quantizeNormal;n.getRoot().listAccessors().length!==0&&(t.level==="medium"?(r=/.*/,a=/.*/):(r=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR)(_\d+)?$/,a=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR|NORMAL|TANGENT)(_\d+)?$/,i=Math.min(i,8)),await n.transform(zn({encoder:s,target:"size"}),Le(B({},t,{pattern:r,patternTargets:a,quantizeNormal:i}))),n.createExtension(ie).setRequired(!0).setEncoderOptions({method:t.level==="medium"?ie.EncoderMethod.QUANTIZE:ie.EncoderMethod.FILTER}))})}const xe="unweld",sr={};function nr(e=sr){return D(xe,t=>{const s=t.getLogger(),n=new Map;for(const r of t.getRoot().listMeshes())for(const a of r.listPrimitives())rr(a,n);s.debug(`${xe}: Complete.`)})}function rr(e,t=new Map){const s=e.getIndices();if(!s)return;const n=e.getGraph(),r=ze.fromGraph(n),a=r.getLogger(),i=e.getAttribute("POSITION").getCount();for(const o of e.listAttributes())e.swap(o,at(r,o,s,t)),o.listParents().length===1&&o.dispose();for(const o of e.listTargets())for(const u of o.listAttributes())o.swap(u,at(r,u,s,t)),u.listParents().length===1&&u.dispose();const l=e.getAttribute("POSITION").getCount();a.debug(`${xe}: ${Ks(i,l)} vertices.`),e.setIndices(null),s.listParents().length===1&&s.dispose()}function at(e,t,s,n){if(n.has(t)&&n.get(t).has(s))return n.get(t).get(s);const r=t.getArray(),a=r.constructor,i=new a(s.getCount()*t.getElementSize()),l=s.getArray(),o=t.getElementSize();for(let c=0,h=s.getCount();c<h;c++)for(let f=0;f<o;f++)i[c*o+f]=r[l[c]*o+f];n.has(t)||n.set(t,new Map);const u=ee(e,t).setArray(i);return n.get(t).set(s,u),u}var it;(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(it||(it={}));const ar=1e-6;function ir(e,t,s,n=1e-4){const r=t.length/e.length,a=new Array(r).fill(0),i=new Array(r).fill(0),l=new Array(r).fill(0),o=new Array(r).fill(0),u=e.length-1;let c=1;for(let h=1;h<u;++h){const f=e[c-1],g=e[h],p=e[h+1],m=(g-f)/(p-f);let d=!1;if(g!==p&&(h!==1||g!==e[0]))if(Z(t,c-1,o),Z(t,h,i),Z(t,h+1,l),s==="slerp"){const y=cr(a,o,l,m),T=lt(o,i)+lt(i,l);d=!re(i,y,n)||T+Number.EPSILON>=Math.PI}else if(s==="lerp"){const y=lr(a,o,l,m);d=!re(i,y,n)}else s==="step"&&(d=!re(i,o)||!re(i,l));d&&(h!==c&&(e[c]=e[h],ot(t,c,Z(t,h,a))),c++)}return u>0&&(e[c]=e[u],ot(t,c,Z(t,u,a)),c++),c}function Z(e,t,s){for(let n=0,r=s.length;n<r;n++)s[n]=e[t*r+n];return s}function ot(e,t,s){for(let n=0,r=s.length;n<r;n++)e[t*r+n]=s[n]}function re(e,t,s=0){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(Math.abs(e[n]-t[n])>s)return!1;return!0}function or(e,t,s){return e*(1-s)+t*s}function lr(e,t,s,n){for(let r=0;r<t.length;r++)e[r]=or(t[r],s[r],n);return e}function cr(e,t,s,n){let r=t[0],a=t[1],i=t[2],l=t[3],o=s[0],u=s[1],c=s[2],h=s[3],f,g,p,m,d;return g=r*o+a*u+i*c+l*h,g<0&&(g=-g,o=-o,u=-u,c=-c,h=-h),1-g>ar?(f=Math.acos(g),p=Math.sin(f),m=Math.sin((1-n)*f)/p,d=Math.sin(n*f)/p):(m=1-n,d=n),e[0]=m*r+d*o,e[1]=m*a+d*u,e[2]=m*i+d*c,e[3]=m*l+d*h,e}function lt(e,t){const s=fr(e,t);return Math.acos(2*s*s-1)}function fr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}Promise.resolve();P.Mode;var je;(function(e){e.LANCZOS3="lanczos3",e.LANCZOS2="lanczos2"})(je||(je={}));je.LANCZOS3;const $="tangents",ct={overwrite:!1};function ur(e=ct){const t=H(ct,e);if(!t.generateTangents)throw new Error(`${$}: generateTangents callback required — install "mikktspace".`);return D($,s=>{const n=s.getLogger(),r=new Map,a=new Map;let i=0;for(const l of s.getRoot().listMeshes()){const o=l.getName(),u=l.listPrimitives();for(let c=0;c<u.length;c++){const h=u[c];if(!gr(h,n,o,c,t.overwrite))continue;const f=hr(h),g=h.getAttribute("POSITION").getArray(),p=h.getAttribute("NORMAL").getArray(),m=h.getAttribute(f).getArray(),d=r.get(g)||ve();r.set(g,d);const y=r.get(p)||ve();r.set(p,y);const T=r.get(m)||ve();r.set(m,T);const A=h.getAttribute("TANGENT");A&&A.listParents().length===2&&A.dispose();const b=`${d}|${y}|${T}`;let _=a.get(b);if(_){n.debug(`${$}: Found cache for primitive ${c} of mesh "${o}".`),h.setAttribute("TANGENT",_),i++;continue}n.debug(`${$}: Generating for primitive ${c} of mesh "${o}".`);const E=h.getAttribute("POSITION").getBuffer(),x=t.generateTangents(g instanceof Float32Array?g:new Float32Array(g),p instanceof Float32Array?p:new Float32Array(p),m instanceof Float32Array?m:new Float32Array(m));for(let L=3;L<x.length;L+=4)x[L]*=-1;_=s.createAccessor().setBuffer(E).setArray(x).setType("VEC4"),h.setAttribute("TANGENT",_),a.set(b,_),i++}}i?n.debug(`${$}: Complete.`):n.warn(`${$}: No qualifying primitives found. See debug output.`)})}function hr(e){const t=e.getMaterial();if(!t)return"TEXCOORD_0";const s=t.getNormalTextureInfo();if(!s)return"TEXCOORD_0";const r=`TEXCOORD_${s.getTexCoord()}`;return e.getAttribute(r)?r:"TEXCOORD_0"}function gr(e,t,s,n,r){return e.getMode()!==P.Mode.TRIANGLES||!e.getAttribute("POSITION")||!e.getAttribute("NORMAL")||!e.getAttribute("TEXCOORD_0")?(t.debug(`${$}: Skipping primitive ${n} of mesh "${s}": primitives must have attributes=[POSITION, NORMAL, TEXCOORD_0] and mode=TRIANGLES.`),!1):e.getAttribute("TANGENT")&&!r?(t.debug(`${$}: Skipping primitive ${n} of mesh "${s}": TANGENT found.`),!1):e.getIndices()?(t.warn(`${$}: Skipping primitive ${n} of mesh "${s}": primitives must be unwelded.`),!1):!0}async function pr(e,t,s,n={}){var y;const{remapMaterials:r,animationEvents:a,textureOptions:i,optimizeOptions:l}=s,o=await t.readBinary(e),u=o.getRoot().listExtensionsUsed(),c=u.some(T=>T.extensionName==="EXT_meshopt_compression"),h=u.some(T=>T.extensionName==="KHR_mesh_quantization");if((i==null?void 0:i.textureType)==="ktx2"&&n.ktx2Encode){const T=o.getRoot().listTextures();T.length>0&&o.createExtension(ns).setRequired(!0);const A=T.filter(b=>b.getMimeType()!=="image/ktx2");await Promise.all(A.map(async b=>{b.setMimeType("image/ktx2");const _=b.getImage(),E=await n.ktx2Encode(_.buffer,{isUASTC:i.mode==="UASTC",qualityLevel:i.quality??255});b.setImage(E)}))}r&&o.getRoot().listMaterials().forEach((T,A)=>{if(r[A]){const b=o.createExtension(Ae).createGlTFRemapping().setRefId(r[A].refId);T.setExtension(Ae.EXTENSION_NAME,b)}}),a&&o.getRoot().listAnimations().forEach((T,A)=>{if(a[A]){const b=o.createExtension(qe).createAnimationEvent().setEvents(a[A]);T.setExtension(qe.EXTENSION_NAME,b)}});const g=[];l!=null&&l.meshopt&&!c&&(await le.ready,g.push(zt({encoder:le}))),l!=null&&l.meshQuantize&&!h&&g.push(Le({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),g.length>0&&await o.transform(...g);const p=await t.writeJSON(o,{format:rs.GLB});if(n.resolveRef&&r){const T=Ae.EXTENSION_NAME;(y=p.json.materials)==null||y.forEach(A=>{var _;const b=(_=A.extensions)==null?void 0:_[T];if(b!=null&&b.refId){const E=n.resolveRef(b.refId);E&&(A.extensions[T]={url:E.url})}})}return{name:s.name.replace(/\.[^.]+$/,"")+".glb",content:_t(p)}}const ft=Ut("div",{color:"$gray10"}),dr=ht(({asset:e,index:t,originMaterial:s})=>{const{assetStore:n}=At(),r=e.remapMaterials[t];let a=Object.values(n.assets);a=a.filter(l=>l.getMetaConfig().type==="Material"&&!l.isSubAsset);const i=n.assets[r==null?void 0:r.refId];return I.jsx(Ft,{dropLayer:gt.Material,assets:a,customFilter:l=>l.mainId!==e.id,onSelect:l=>{(!i||l.engineObject!==i.engineObject)&&e.replaceMaterial(t,l.getCurrentRef())},onDelete:()=>{r&&e.resetMaterial(t)},onLocate:()=>{r&&r.refId&&n.selectAsset(r.refId)},label:s.name,value:i==null?void 0:i.name,asset:i})}),mr=ht(({asset:e})=>{var l;const t=e.engineObject.materials,{inspectorFacade:s}=At(),n=e.glTFInfo,r=(l=n.issues)==null?void 0:l.messages,{t:a}=Dt();function i(o,u){s.assetChange(e.id,o,u,"asset-meta")}return I.jsxs(I.Fragment,{children:[I.jsxs($e,{title:a("asset.gltf.basic-info"),defaultOpen:!0,children:[n.triangles?I.jsx(te,{label:a("asset.gltf.triangles"),children:I.jsx(be,{value:n.triangles,disabled:!0})}):null,n.drawcall?I.jsx(te,{label:a("asset.gltf.drawcall"),children:I.jsx(be,{value:n.drawcall,disabled:!0})}):null,I.jsx(se,{label:a("asset.gltf.compute-tangents"),value:e.needComputeTangents,onChange:o=>{i("needComputeTangents",o)},checkboxLabel:I.jsx(ft,{children:a("asset.gltf.refresh-tip")})}),I.jsx(se,{label:a("asset.gltf.keep-mesh-data"),value:e.params.keepMeshData,onChange:o=>{e.params={...e.params,keepMeshData:o}},checkboxLabel:I.jsx(ft,{children:a("asset.gltf.refresh-tip")})})]}),I.jsx(Ve,{}),r?I.jsxs(qt.Fragment,{children:[I.jsxs($e,{title:`${a("asset.gltf.issues")}: ${r.length}`,defaultOpen:!1,children:[r.slice(0,15).map((o,u)=>I.jsx(te,{label:o.pointer,children:I.jsx(be,{value:o.message,css:{color:"red"},disabled:!0})},u)),r.length>15?I.jsx(te,{label:"..."}):null]}),I.jsx(Ve,{})]}):null,I.jsx(Ue,{label:a("asset.gltf.remapped-materials"),children:t==null?void 0:t.map((o,u)=>I.jsx(dr,{originMaterial:o,asset:e,index:u},`${e.id}-${u}`))}),I.jsxs(Ue,{label:a("asset.gltf.compression"),children:[!e.optimize.meshopt&&I.jsx(se,{label:a("asset.gltf.quantize"),value:e.optimize.meshQuantize,onChange:o=>{Tracert.click("c351684.d417982",{checked:o}),i("optimize",{...e.optimize,meshQuantize:o})}}),I.jsx(se,{label:a("asset.gltf.meshopt"),value:e.optimize.meshopt,onChange:o=>{Tracert.click("c351684.d417983",{checked:o}),i("optimize",{...e.optimize,meshopt:o})}})]})]})});function pe(e){return/^(?:http|blob|data:|\/)/.test(e)}function kt(e){return/^data:(.+?);base64,/.test(e)}function de(e,t){return t.charAt(0)==="."?ut(e+t):ut(e.substring(0,e.lastIndexOf("/")+1)+t)}function ut(e){const t=[],s=e.split("/");for(let n=0;n<s.length;n++){const r=s[n];if(!(!r||r===".")){if(r===".."){t.length>0&&t.pop();continue}t.push(r)}}return t.join("/")}async function yr(e,t){const s=JSON.parse(await e.text()),n=s.images,r={},a="",i=[];if(n)for(let o=0;o<n.length;o++){const c=n[o].uri;if(c)if(pe(c))i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}));else{const h=de(a,c);i.push(t[h].arrayBuffer().then(f=>{r[c]=new Uint8Array(f)}))}}const l=s.buffers;if(l)for(let o=0;o<l.length;o++){const c=l[o].uri;if(c)if(!pe(c)&&!kt(c)){const h=de(a,c);i.push(t[h].arrayBuffer().then(f=>{r[c]=new Uint8Array(f)}))}else i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}))}return await Promise.all(i),hs({json:s,resources:r})}async function br(e){const t={uploadFiles:[],errors:[]};for(const s in e){const n=e[s],a=n.name.toLowerCase();if(a.endsWith(".glb")||a.endsWith(".fbx"))t.uploadFiles.push({main:n});else if(a.endsWith(".gltf")){const i=await vr(n,e);typeof i=="string"?t.errors.push(i):t.uploadFiles.push(i)}}return t}async function vr(e,t){const s=JSON.parse(await e.text()),n=s.images,r=s.buffers,a="",i={main:e,subFiles:{},postfix:".glb"};if(n)for(let l=0;l<n.length;l++){const u=n[l].uri;if(u&&!pe(u)){const c=de(a,u);if(t[c])i.subFiles[c]=t[c];else return`${u} is not found in the files.`}}if(r)for(let l=0;l<r.length;l++){const u=r[l].uri;if(u&&!pe(u)&&!kt(u)){const c=de(a,u);if(t[c])i.subFiles[c]=t[c];else return`${u} is not found in the files.`}}return i}async function Ar(e,t){const s=e.main,n=s.name.replace(/\.[^.]+$/,".glb");if(s.name.toLocaleLowerCase().endsWith(".gltf")){const r=e.subFiles??{},a=await yr(s,r);return new File([a.buffer],n)}return s}function _r(e){const t=Object.entries(e.remapMaterials).filter(([,s])=>!!s);if(!t.length){e.settleInitCompleted();return}e.onInitComplete(async()=>{try{await Promise.all(t.map(([s,n])=>e.replaceMaterial(Number(s),n,!1)))}catch{}finally{e.settleInitCompleted()}})}async function Tr(e){e.notifySuccess("Success. page will reload, please wait...");try{await e.assetFacade.persistAssetMetaImmediate(e.assetId),e.reload()}catch(t){e.logError("Failed to persist optimize config before reload",t),e.notifyError("Failed to save optimize config, reload canceled.")}}class Re{static update(t,s){!this.entity&&(this.entity=t.createChild("glTF"));const n=this.tempCloneEntity=s.engineObject.instantiateSceneRoot();this.entity.addChild(n)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}w(Re,"entity"),w(Re,"tempCloneEntity");var Er=Object.defineProperty,wr=Object.getOwnPropertyDescriptor,z=(e,t,s,n)=>{for(var r=n>1?void 0:n?wr(t,s):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(n?i(t,s,r):i(r))||r);return n&&r&&Er(t,s,r),r};class R extends ls{constructor(){super();w(this,"animationNames",[]);w(this,"frameTime",0);w(this,"duration",0);w(this,"playing",!1);w(this,"animationIndex",0);w(this,"selectedClip");w(this,"_updateComponent");w(this,"_clips",[]);pt(this)}setViewAsset(s,n){const{animations:r=[]}=s.engineObject;this._clips=r,this.animationIndex=0,this.animationNames=r.map(i=>i.name),this._entity=s.instantiateEngineObject(),n.addChild(this._entity);const a=this;r.length>0&&(this._updateComponent=this._entity.addComponent(class extends Bt{onUpdate(i){a._onUpdate(i)}})),this.duration=0}stopViewAsset(){var s;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(s=this._updateComponent)==null||s.destroy(),this.animationNames=null}selectAnimation(s){this.selectedClip=this._clips[s],this.frameTime=0,this.duration=this.selectedClip.length,this.animationIndex=s,this._sampleAnimation()}setFrameTime(s){this.frameTime=s,this._sampleAnimation()}playAnimation(){this.selectedClip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(s){!this.playing||!this.selectedClip||!this.duration||(this.frameTime+=s,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this.selectedClip._sampleAnimation(this._entity.children[0],this.frameTime)}catch(s){console.warn(s)}}}z([j],R.prototype,"animationNames",2);z([j],R.prototype,"frameTime",2);z([j],R.prototype,"duration",2);z([j],R.prototype,"playing",2);z([j],R.prototype,"animationIndex",2);z([G],R.prototype,"selectAnimation",1);z([G],R.prototype,"setFrameTime",1);z([G],R.prototype,"playAnimation",1);z([G],R.prototype,"pauseAnimation",1);z([G],R.prototype,"_onUpdate",1);var Ir=Object.defineProperty,Mr=Object.getOwnPropertyDescriptor,k=(e,t,s,n)=>{for(var r=n>1?void 0:n?Mr(t,s):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(n?i(t,s,r):i(r))||r);return n&&r&&Ir(t,s,r),r};const ae=Yt("gltf");let O=class extends as{constructor(t){super(t);w(this,"exportedUrl","");w(this,"glTFInfo",{drawcall:void 0,triangles:void 0,issues:void 0});w(this,"remapMaterials",{});w(this,"animationEvents",{});w(this,"needComputeTangents",!0);w(this,"fbxUrl",null);w(this,"optimize",{meshopt:!1,meshQuantize:!1});w(this,"params",{keepMeshData:!1});w(this,"initCompleted");w(this,"_rootKey","defaultSceneRoot");w(this,"mappedMaterialsPath",[]);w(this,"_initCompletedResolve");w(this,"_autorunDisposer",null);w(this,"_propertyChangeListeners",new Map);pt(this),this.initCompleted=new Promise(s=>{this._initCompletedResolve=s})}applyMetaFromDomain(t){if(super.applyMetaFromDomain(t),"needComputeTangents"in t&&(this.needComputeTangents=t.needComputeTangents),"optimize"in t&&typeof t.optimize=="object"){const s=t.optimize;this.optimize={...this.optimize,...s}}}async generateSubAssets(){const t=this.engineObject;if(this._subAssets=[],t.meshes)for(let s=0;s<t.meshes.length;s++){const n=t.meshes[s];for(let r=0;r<n.length;r++){const a=await this.root.assetStore.createSubAsset("Mesh",n[r],this.id,`meshes[${s}][${r}]`);this._subAssets.push(a)}}if(t.textures)for(let s=0;s<t.textures.length;s++){const n=await this.root.assetStore.createSubAsset("Texture",t.textures[s],this.id,`textures[${s}]`);this._subAssets.push(n)}if(t.animations){for(let r=0;r<t.animations.length;r++){const a=t.animations[r],i=this.animationEvents[r];i&&i.forEach(o=>{a.addEvent(o.functionName,o.time,o.parameter)});const l=await this.root.assetStore.createSubAsset("AnimationClip",a,this.id,`animations[${r}]`);this._subAssets.push(l)}const s=t.defaultSceneRoot.getComponent(Gt).animatorController,n=await this.root.assetStore.createSubAsset("AnimatorController",s,this.id,"animatorController[0]");this._subAssets.push(n)}if(t.materials)for(let s=0;s<t.materials.length;s++){const n=await this.root.assetStore.createSubAsset("Material",t.materials[s],this.id,`materials[${s}]`);this._subAssets.push(n)}}async initByMain(t,s){const{engine:n,meta:r}=this;this.url=s,this.animationEvents=r.animationEvents||{},this.optimize=r.optimize??this.optimize;let a=this.optimize.meshopt,i=this.optimize.meshQuantize;this._autorunDisposer=Wt(()=>{const o=this.optimize.meshQuantize;i!==o&&(this.optimize.meshQuantize=o,i=o,this._saveMetaAndReload());const u=this.optimize.meshopt;a!==u&&(this.optimize.meshopt=u,a=u,this._saveMetaAndReload())}),this.params=r.params??this.params;let l;try{l=URL.createObjectURL(t),await this.initByUrl(l+"#.glb",n)}finally{l!==void 0&&URL.revokeObjectURL(l)}this.needComputeTangents=r.needComputeTangents??!0,_r({remapMaterials:r.remapMaterials||{},onInitComplete:o=>{this.on("initcomplete",o)},replaceMaterial:async(o,u,c)=>{await this.replaceMaterial(o,u,c)},settleInitCompleted:()=>{this._initCompletedResolve()}}),this.fbxUrl=r.fbxUrl}_saveMetaAndReload(){Tr({assetFacade:this.root.assetFacade,assetId:this.id,reload:()=>window.location.reload(),notifySuccess:t=>Be.success(dt(t)),notifyError:t=>Be.error(t),logError:(t,s)=>ae.error(t,s)})}resetMaterial(t){const s=this._engineObject.materials[t];this._internalReplaceMaterial(t,s),this.remapMaterials[t]=void 0,this.root.assetFacade.persistAssetMeta(this.id)}async replaceMaterial(t,s,n=!0){this.remapMaterials[t]=s;const r=this._findComponentsByMaterialPathIndex(t),a=await this.root.assetStore.getAssetByRef(s);if(a instanceof cs){const i=a.engineObject;r.forEach(({component:c,materialIndex:h})=>{c.setMaterial(h,i)});const l=String(t),o=this._propertyChangeListeners.get(l);o&&a.off("propertychange",o);const u=()=>{this.updateThumbnail()};this._propertyChangeListeners.set(l,u),a.on("propertychange",u)}else ae.warn(`${s.refId} shouldn't be selected`);n&&await this.root.assetFacade.persistAssetMeta(this.id),this.updateThumbnail()}updateAnimationEvents(t,s){this.animationEvents[t]=s,this.root.assetFacade.persistAssetMeta(this.id)}async instantiate(t){await this.initCompleted;const s=t.createByEngineObject(this.instantiateEngineObject());s.isGLTFWrapEntity=!0,s.isPrefabRefEntity=!1,await s.ensureReady();const n=s.selfChildren[0];return n?this.addInstance(n):ae.warn(`[GlTFAsset] instantiate: wrap entity has no child, skip addInstance. asset=${this.id}`),s}destroy(){var s;(s=this._autorunDisposer)==null||s.call(this),this._autorunDisposer=null,this._propertyChangeListeners.clear();const t=this.engineObject;t&&(t._defaultSceneRoot.destroy(),t.destroy()),super.destroy()}instantiateEngineObject(){const t=super.instantiateEngineObject(),s=new Ht(this.engine,this.name.replace(/\.glb$/g,""));return s.addChild(t),this._fixClonedSkins(t),s}_fixClonedSkins(t){const s=t.getComponentsIncludeChildren(Xt,[]);for(const n of s){const r=n.skin;if(r&&r.bones.length>0&&!r._skinMatrices){const a=r.bones;r.bones=a}}}_instantiateEngineObject(){return this.engineObject.instantiateSceneRoot()}_destroyInstances(){this._instances.forEach((t,s)=>{const n=t.entities.get(s);if(n){const r=n.parentEntity;r?r.destroy():n.destroy()}}),this._instances.clear()}_internalReplaceMaterial(t,s){this._findComponentsByMaterialPathIndex(t).forEach(({component:r,materialIndex:a})=>{r.setMaterial(a,s)}),this.updateThumbnail()}_findComponentsByMaterialPathIndex(t){const s=[...this._clonedEntities,this._engineObject.defaultSceneRoot],n=this.mappedMaterialsPath[t],r=[];if(!n)return ae.warn(`${this._name} replaced material not found.(gltf may be replaced either)`),r;for(let a=0;a<s.length;a++){const i=s[a];n.forEach(l=>{const u=Cr(l.entityPath,i).getComponents(Fe,[]);r.push({component:u[l.componentIndex],materialIndex:l.materialIndex})})}return r}async initByUrl(t,s){const n=await s.resourceManager.load({type:Kt.GLTF,url:t,params:this.params});return this.initMappedMaterialPath(n),this.bindEngineObject(n),this._updateDragTempEntity(),await this.generateSubAssets(),await this.initBasicInfo(n),this}async getRemappedMaterial(t){var n;const s=this.remapMaterials[t];return s?(n=await this.root.assetStore.getAssetByRef(s))==null?void 0:n.engineObject:this._engineObject.materials[t]}initMappedMaterialPath(t){const s=t.materials,n=t.defaultSceneRoot;if(s){const r=t.defaultSceneRoot.getComponentsIncludeChildren(De,[]);s.forEach(a=>{const i=[];this.mappedMaterialsPath.push(i);for(let l=0;l<r.length;l++){const o=r[l],u=o.getMaterials(),c=o.entity.getComponents(Fe,[]);for(let h=0;h<u.length;h++)u[h]===a&&i.push({entityPath:Nr(o.entity,n),componentIndex:c.indexOf(o),materialIndex:h})}})}}async initBasicInfo(t){this.glTFInfo.drawcall=t.defaultSceneRoot.getComponentsIncludeChildren(De,[]).length}};k([j,Qt()],O.prototype,"exportedUrl",2);k([W(),j],O.prototype,"remapMaterials",2);k([W()],O.prototype,"animationEvents",2);k([W(),j],O.prototype,"needComputeTangents",2);k([W(),j],O.prototype,"fbxUrl",2);k([W(),j],O.prototype,"optimize",2);k([W(),j],O.prototype,"params",2);k([Jt],O.prototype,"applyMetaFromDomain",1);k([G],O.prototype,"resetMaterial",1);O=k([is({type:"glTF",label:dt("asset.gltf.title"),loaderType:"GLTF",importMenuConfig:{type:os.Upload,tooltip:"请上传模型文件(支持gltf,glb,fbx,obj)或包含模型和资源文件(bin、贴图等)的zip压缩包",accept:".zip,.fbx,.gltf,.glb,application/json",subAccept:".bin,.jpeg,.jpg,.png",multiple:!0},filterUploadFiles:br,preUpload:Ar,extname:"glb",dragLayer:gt.GlTF,customInspector:mr,viewer:R,thumbnail:Re,async preInitialize({main:e,meta:t,name:s}){const n=new Uint8Array(await e.arrayBuffer()),r=await _e.readBinary(n),a=t.optimize||{},i=t.needComputeTangents??!0,l=a.meshQuantize,o=a.meshopt,u=[],c=r.getRoot().listExtensionsUsed(),h=c.some(p=>p.extensionName===mt.EXTENSION_NAME),f=c.some(p=>p.extensionName===ie.EXTENSION_NAME);l&&!h&&u.push(Le({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),o&&!f&&(await le.ready,u.push(zt({encoder:le})));try{i&&(u.push(nr()),u.push(ur({generateTangents:window.mikktspace.generateTangents,overwrite:!0}))),await r.transform(...u)}catch(p){console.error("The gltf-transform plugin encountered some errors when performing meshopt, quantize, or calculating tangents, we have disabled these features automatically.",p)}const g=await _e.writeBinary(r);return new File([g.buffer],s,{type:"model/gltf-binary"})},async bundle({content:e,name:t,meta:s},n,r){var l;const a=new Uint8Array(await e.arrayBuffer()),i=await pr(a,_e,{name:t,remapMaterials:s.remapMaterials,animationEvents:s.animationEvents??{},textureOptions:(l=n.assetOptions)==null?void 0:l.textureOptions,optimizeOptions:s.optimize},{resolveRef:r?o=>r.resolveRef(o):void 0,ktx2Encode:(o,u)=>fs.encode(o,u)});return{name:i.name,content:new Blob([i.content],{type:"model/gltf-binary"})}}})],O);function Nr(e,t){const s=[];for(;e!==t;)s.unshift(e.siblingIndex),e=e.parent;return s}function Cr(e,t){let s=t;for(let n=0;n<e.length;n++)s=s.children[e[n]];return s}const Vr=Object.freeze(Object.defineProperty({__proto__:null,get GlTFAsset(){return O}},Symbol.toStringTag,{value:"Module"}));export{O as G,R as a,Vr as b};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{aC as a}from"./index-0a8702e2.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 e=a("filled","player-play-filled","IconPlayerPlayFilled",[["path",{d:"M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z",key:"svg-0"}]]);export{e as I};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{aC as e}from"./index-0a8702e2.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 o=e("filled","point-filled","IconPointFilled",[["path",{d:"M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z",key:"svg-0"}]]);export{o as I};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=Object.defineProperty;var x=(i,t,e)=>t in i?w(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var c=(i,t,e)=>(x(i,typeof t!="symbol"?t+"":t,e),e);import{dC as D,aJ as g,j as p,aX as A,cj as B,e as R,n as E,dD as y,o as F,dE as _,u as C,bp as z,J as O,H as P,U as k,S as L,bD as M}from"./index-0a8702e2.js";import{r as T}from"./ThumbnailRegistry-495c18c9.js";let b=null;function l(){return b??(b=new D),b}const j=new Proxy({},{get(i,t,e){const s=l(),n=Reflect.get(s,t,s);return typeof n=="function"?n.bind(s):n},set(i,t,e,s){return Reflect.set(l(),t,e),!0},has(i,t){return Reflect.has(l(),t)},ownKeys(){return Reflect.ownKeys(l())},getOwnPropertyDescriptor(i,t){const e=Reflect.getOwnPropertyDescriptor(l(),t);return e||{configurable:!0,enumerable:!0,writable:!0,value:l()[t]}}}),v=g.createContext(j);function $(){const i=g.useContext(v);if(!i)throw new Error("useRootStore must be used within a RootProvider");return i}const q=i=>g.useContext(v)[i],K=B("Plugin Asset");var S=(i=>(i[i.Add=1]="Add",i[i.Upload=2]="Upload",i))(S||{});function U(i){return t=>{var e;K.info("register",i.type,"verbose"),typeof i.icon=="string"?(i.icon,i.icon=void 0):(e=i==null?void 0:i.icon)!=null&&e.fallback&&i.icon.fallback,p.registerAssetMeta(t,{...i,targetConstructor:t}),i.viewer&&A(i.type,new i.viewer),i.thumbnail&&T(i.type,i.thumbnail),i.dragLayer&&(t.dragLayer=i.dragLayer)}}var N=Object.defineProperty,J=Object.getOwnPropertyDescriptor,h=(i,t,e,s)=>{for(var n=s>1?void 0:s?J(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(n=(s?a(t,e,n):a(n))||n);return s&&n&&N(t,e,n),n};let u=class extends p{constructor(t){super(t);c(this,"isRoot",!1);c(this,"isFolder",!0);c(this,"hidden",!1);c(this,"extname","");c(this,"childrenId",[]);c(this,"acceptDragLayer",E.MainAsset);F(this)}get thumbnailUrl(){return this.locked?y.FolderLocked:y.Folder}get children(){const t=[];return this.childrenId.forEach(e=>{const s=this.root.assetStore.assets[e];s&&t.push(s)}),t}afterDelete(){const t=this.root.assetStore.assets;for(;this.childrenId.length;){const e=this.childrenId[0],s=t[e];s.loadingStatus==="success"&&s.beforeDelete&&s.beforeDelete(),this.childrenId.splice(0,1),delete this.root.assetStore.assets[e],s.loadingStatus==="success"&&s.afterDelete&&s.afterDelete()}}async initByMeta(t){super.initByMeta(t),this.isRoot=!!t.isRoot,t.hidden!=null&&(this.hidden=t.hidden),this.initObjectProperties()}async initByMain(t){}initByCreation(t,e,s){return Promise.resolve()}onDoubleClick(){this.root.assetStore.openFolder(this.id)}saveMain(){return null}recursive(t,e=!1){const s=this.children,n=[];for(let r=0;r<s.length;r++){const a=s[r];a.isFolder?(n.push(a),e&&t(a)):t(a)}return n.forEach(r=>r.recursive(t,e))}async asyncRecursive(t,e=!1){const s=this.children,n=[];for(let r=0;r<s.length;r++){const a=s[r];a.isFolder?(n.push(a),e&&await t(a)):await t(a)}for(let r=0;r<n.length;r++)await n[r].asyncRecursive(t,e)}_onDrop(t,e){if(!e||this.id===e.id)return;const{assetStore:s,assetUIStore:n,assetFacade:r}=this.root;if(this.dropping=!1,n.pickedAssets.includes(e.id)){if(n.pickedAssets.includes(this.id))return;for(let a=0;a<n.pickedAssets.length;a++)try{const o=n.pickedAssets[a];if(!s.assets[o])continue;r.moveAsset(o,this.id)}catch(o){_(o instanceof Error?o.message:String(o))}}else try{r.moveAsset(e.id,this.id)}catch(a){_(a instanceof Error?a.message:String(a))}}};h([C],u.prototype,"childrenId",2);h([z],u.prototype,"children",1);h([O],u.prototype,"_onDrop",1);u=h([U({type:"Folder",label:R("asset.folder.title"),dragLayer:E.Folder,importMenuConfig:{type:S.Add}})],u);const d=class d extends p{constructor(){super(...arguments);c(this,"isTemplate",!0);c(this,"_clonedEntities",[]);c(this,"_instances",new Map);c(this,"_rootKey","");c(this,"_tempSize",0)}_buildInstanceLink(){const e=this.getMetaConfig().type;if(e!=="Prefab"&&e!=="glTF")return null;const s=e;return{assetId:this.id,bindingId:"",assetKind:s,role:"root",...this._rootKey&&{sourceEntityId:this._rootKey}}}instantiateEngineObject(){const e=this._instantiateEngineObject();this._clonedEntities.push(e);const s=this._clonedEntities;return e.addComponent(class extends L{onDestroy(){const n=s.indexOf(this.entity);n>=0&&s.splice(n,1)}}),e}addInstance(e,s){var m;const n=e.instanceAssetId;if(n){const f=this.root.assetStore.assets[n];f.isTemplate&&f.removeInstance(e)}const a=e.root.domainStore.getNormalizedState().entities[e.id],o=this._buildInstanceLink();a&&o?(m=a.instance)!=null&&m.bindingId||e.root.entityFacade.updateEntity(e.id,{instance:o}):o&&(e.pendingInstance=o),this._instances.set(e.id,e.entityManager),e.on("delete",()=>{this.removeInstance(e)})}removeInstance(e){var n;((n=e.root.domainStore.getNormalizedState().entities[e.id])==null?void 0:n.instance)!==void 0?e.root.entityFacade.updateEntity(e.id,{instance:null}):e.pendingInstance=null,this._instances.delete(e.id)}get instanceCount(){return this._instances.size}static resolveInstanceEntityIds(e,s){const n=new Set;for(let r=0;r<e.length;r++){const a=e[r],o=s[a];o&&n.add(o.parentId===null?a:o.parentId)}return Array.from(n)}getInstanceEntityIds(){return d.resolveInstanceEntityIds(Array.from(this._instances.keys()),this.root.domainStore.state.entities)}unpackAllInstances(){this._instances.forEach((e,s)=>{var r;const n=e.entities.get(s);n&&(((r=n.root.domainStore.getNormalizedState().entities[n.id])==null?void 0:r.instance)!==void 0?n.root.entityFacade.updateEntity(n.id,{instance:null}):n.pendingInstance=null)}),this._instances.clear()}afterDelete(){this.unpackAllInstances(),this.root.sceneStore.selectEntity(null),this._clonedEntities.forEach(s=>s.destroy());const e=this.getDragTempEntity();e&&(e.destroy(),this.setDragTempEntity(null))}_updateDragTempEntity(){try{const e=this.instantiateEngineObject();this.setDragTempEntity(e),this._tempSize=this._getSize(e)}catch(e){console.warn(`[InstanceEditorAsset] Failed to create drag temp entity for asset ${this.id}:`,e)}}_destroyInstances(){this._instances.forEach((e,s)=>{const n=e.entities.get(s);n==null||n.destroy()}),this._instances.clear()}async updateThumbnail(){this._tempSize?super.updateThumbnail():super.updateThumbnail(!0)}_getSize(e){M(e,d._tempBoundingBox),d._tempBoundingBox.getExtent(d._tempExtend);const s=d._tempExtend.length();return s===1/0?0:s}};c(d,"_tempExtend",new P),c(d,"_tempBoundingBox",new k);let I=d;export{S as A,u as F,I,U as a,q as b,$ as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var u=(r,e,o)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(u(r,typeof e!="symbol"?e+"":e,o),o);import{a as n,s as y,aR as v,p as c,C as g,l as P,f as b,h as f,g as C,E as L,d as _}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";var x=Object.defineProperty,O=Object.getOwnPropertyDescriptor,h=(r,e,o,l)=>{for(var a=l>1?void 0:l?O(e,o):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(a=(l?i(e,o,a):i(a))||a);return l&&a&&x(e,o,a),a};const t=[n.Everything,n.Nothing];class d extends L{constructor(){super(...arguments);p(this,"color",{r:1,g:1,b:1,a:1,intensity:1});p(this,"cullingMask",_(n.Everything,t))}}h([y(v()),c({label:"light.color",type:g.Color,mode:"hdr",bindPath:"color"})],d.prototype,"color",2);h([y(P(t)),b(f(t)),c({label:"light.culling-mask",type:g.Select,...C(t),bindPath:"cullingMask"})],d.prototype,"cullingMask",2);export{d as L};
|