clipoox-render 0.3.0 → 0.4.0
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/server-text/titleRaster.js +23 -4
- package/package.json +1 -1
- package/scripts/render-local.mjs +229 -229
- package/shared/transitionStarterPack.json +355 -0
- package/web/assets/{FxEmbed-D7k1ThAF.js → FxEmbed-CGqGi2Lw.js} +1 -1
- package/web/assets/{MotionEmbed-DFni5IAh.js → MotionEmbed-C3CZ3_y_.js} +1 -1
- package/web/assets/{PluginStore-BrupM_8E.js → PluginStore-DKXZ-jBj.js} +1 -1
- package/web/assets/{ShotComposer-BLztjSKy.js → ShotComposer-DFfaYLoV.js} +4 -4
- package/web/assets/{TemplateEmbed-BbAimhLj.js → TemplateEmbed-C8pXcPsc.js} +1 -1
- package/web/assets/{TimelinePlugins-BI1bE9pX.js → TimelinePlugins-DnkV3i4G.js} +3 -3
- package/web/assets/{TimelineShotFx-CQN3WIfN.js → TimelineShotFx-foiuuogg.js} +2 -2
- package/web/assets/{TransitionEmbed-CmoIrHVr.js → TransitionEmbed-BueDilY0.js} +1 -1
- package/web/assets/{Whiteboard-DMk0unYK.js → Whiteboard-zBsNHh5h.js} +1 -1
- package/web/assets/aerial-z34Nww_T.js +2 -0
- package/web/assets/{agentTools-qOww5RUs.js → agentTools-ALxghYpf.js} +2 -2
- package/web/assets/{analyzerRun-B2FLUp4G.js → analyzerRun-DNwryAlU.js} +1 -1
- package/web/assets/{analyzerSandbox-CJVsEhrg.js → analyzerSandbox-A1oFsCrO.js} +1 -1
- package/web/assets/{api-QBI5GJTZ.js → api-DUp403BK.js} +57 -57
- package/web/assets/auraTrack-BKVZCwNt.js +1 -0
- package/web/assets/breakthrough-Cwt8gEwK.js +2 -0
- package/web/assets/{cameraPresets-4pFeF2YG.js → cameraPresets-DSOPj4oy.js} +1 -1
- package/web/assets/{captionLayout-C67EMVI1.js → captionLayout-EuB59pN_.js} +1 -1
- package/web/assets/clientExport-BL1XMTF0.js +1 -0
- package/web/assets/{depthEstimate-mnXDZMW-.js → depthEstimate-DOvsY8mn.js} +1 -1
- package/web/assets/{directorTools-BOHZjcww.js → directorTools-BkbNYbSq.js} +1 -1
- package/web/assets/{distortFrames-Csuj2jHE.js → distortFrames-Drch0LhT.js} +2 -2
- package/web/assets/{distortGL-BaXfN0IK.js → distortGL-BlmBZKRU.js} +2 -2
- package/web/assets/{editTools-m0VGPmfF.js → editTools-BcGinqHC.js} +1 -1
- package/web/assets/exportEncode-MUwVTI52.js +1 -0
- package/web/assets/{exportGlb-CLfTnbMG.js → exportGlb-SIXFRRJM.js} +1 -1
- package/web/assets/{faceTracker-W0iZSiMe.js → faceTracker-DCbZbLMc.js} +1 -1
- package/web/assets/fightDirector-hlF1JS_z.js +1 -0
- package/web/assets/fightDrama-fHN5EXk3.js +2 -0
- package/web/assets/{frameSink-BGRj7wqY.js → frameSink-BvOXjLuw.js} +3 -3
- package/web/assets/{gpuCompose-CIEoLFem.js → gpuCompose-CNkLwpbZ.js} +1 -1
- package/web/assets/gpuExport-DQB6x4eh.js +194 -0
- package/web/assets/{handMatte-mHxZwLZD.js → handMatte-BD7OE3Zc.js} +1 -1
- package/web/assets/{handTracker-dTVeSUzt.js → handTracker-BumGtRCW.js} +2 -2
- package/web/assets/{index-D7M5t2re.js → index-CuaB7Y0L.js} +1 -1
- package/web/assets/{layer-worker-Cp0pjurp.js → layer-worker-DxPMMKIZ.js} +3 -3
- package/web/assets/library-CyjJ8nGG.js +1 -0
- package/web/assets/{lottieLayer-CDCGeJyv.js → lottieLayer-1ET89OUr.js} +5 -5
- package/web/assets/{lottie_light_canvas-BblLU4nU.js → lottie_light_canvas-DD9pkFL8.js} +1 -1
- package/web/assets/{main-CVRIuDW2.js → main-BKjBWQik.js} +91 -91
- package/web/assets/{main-BQ8IY0WV.css → main-Ca_CVxMz.css} +1 -1
- package/web/assets/mapBake-DLoBt_k5.js +1 -0
- package/web/assets/{maskTrack-Dtv6Jr06.js → maskTrack-C2SJbDGO.js} +1 -1
- package/web/assets/{matteFixRun-BLDH2AjH.js → matteFixRun-BdHKC3m5.js} +1 -1
- package/web/assets/{objectLocate-Cy3IFBSF.js → objectLocate-bZtc5AJo.js} +1 -1
- package/web/assets/{pendingMatte-C2AWApuv.js → pendingMatte-mlyLLZCT.js} +2 -2
- package/web/assets/{personAi-DPUnoymj.js → personAi-CUNQeseG.js} +2 -2
- package/web/assets/plateCamera-_jP1xXnj.js +1 -0
- package/web/assets/{plateCameraMatch-Chk-ZjDi.js → plateCameraMatch-rr0oUwQ2.js} +2 -2
- package/web/assets/{plateFollow-B9_QTgvo.js → plateFollow-BjvtcT8q.js} +2 -2
- package/web/assets/{plateMatte-BiqyI_8x.js → plateMatte-BqyL8cQZ.js} +2 -2
- package/web/assets/{pluginAutomation-5DYldFrb.js → pluginAutomation-Dp188qm7.js} +1 -1
- package/web/assets/{poseTracker-PuI8vWpR.js → poseTracker-DDGDhhMF.js} +1 -1
- package/web/assets/{productTools-B1h5cgyt.js → productTools-CRgI88-O.js} +2 -2
- package/web/assets/remote-Dva2qg58.js +1241 -0
- package/web/assets/{rigTrack-CUt4O67J.js → rigTrack-UYZU4P-e.js} +1 -1
- package/web/assets/{rotoMaskStore-DIi45swK.js → rotoMaskStore-BxyxB2bD.js} +1 -1
- package/web/assets/{rotoMatte-013RKqHu.js → rotoMatte-BdYa8FSB.js} +1 -1
- package/web/assets/{rotoscope-d_TUxa-J.js → rotoscope-DDixNQCt.js} +1 -1
- package/web/assets/{shot-worker-B1iZT6F5.js → shot-worker-D9sZS6bn.js} +1 -1
- package/web/assets/{shotFxAgent-BDfe73TP.js → shotFxAgent-7RQNtEe4.js} +2 -2
- package/web/assets/{skin-GDY3QPkV.js → skin-CVwmK130.js} +1 -1
- package/web/assets/{spark.module-DdwuJ_hb.js → spark.module-B34aiScb.js} +1 -1
- package/web/assets/{spellDuel-DjNN00bv.js → spellDuel-BkweL6pI.js} +2 -2
- package/web/assets/{store-2zneEhhu.js → store-75tQUvPT.js} +1 -1
- package/web/assets/surfaceLight-DhU-zgNL.js +1 -0
- package/web/assets/{surfacePin-zDPmq-hH.js → surfacePin-ObK6QgDm.js} +2 -2
- package/web/assets/textAnimators-nVSz_sZo.js +1 -0
- package/web/assets/{thumb-byAKvhQP.js → thumb-r6dlZprA.js} +1 -1
- package/web/assets/{timeline3d-YIIk_Kn2.js → timeline3d-246tBEJl.js} +2 -2
- package/web/assets/timeline3dExport-T57qnWi9.js +1 -0
- package/web/assets/{timelineComp-B73i_8vD.js → timelineComp-BcewYGR2.js} +1 -1
- package/web/assets/{timelineProps-B2pnudeT.js → timelineProps-CJzzAWWO.js} +1 -1
- package/web/assets/{timelineText-BcL4Pw3C.js → timelineText-BzUhNWPB.js} +1 -1
- package/web/assets/titleArt-B8DVR58F.js +5 -0
- package/web/assets/{titleFrameBudget-Cml-MO53.js → titleFrameBudget-BYRZAQPs.js} +260 -260
- package/web/assets/titleFrames-BVgm601q.js +1 -0
- package/web/assets/{tool-Bt9bclIf.js → tool-CAGU3dUa.js} +1 -1
- package/web/assets/{tools-BXeJbgZJ.js → tools-DVaOkokV.js} +1 -1
- package/web/assets/{toonTools-u7Y9fdEZ.js → toonTools-CfGTR_H1.js} +2 -2
- package/web/assets/{trackAnchor-9MnVHe4S.js → trackAnchor-DzUt1r5Q.js} +1 -1
- package/web/assets/{userFonts-BHduCNtc.js → userFonts-DzY0A4bD.js} +1 -1
- package/web/assets/{vfxAlpha-DpV4rbI-.js → vfxAlpha-DQJOaZ9v.js} +2 -2
- package/web/assets/{vfxBackground-Ddviync5.js → vfxBackground-DiktQFOD.js} +2 -2
- package/web/assets/{videoExport-z5WjM0hw.js → videoExport-Ce0ElSQR.js} +1 -1
- package/web/assets/{views-CsrYzCSR.js → views-V3si1lOz.js} +1 -1
- package/web/assets/weaponDuel-D6sLVGmG.js +1 -0
- package/web/assets/{windowFrames-BQEWQkEs.js → windowFrames-D_2QJCJJ.js} +1 -1
- package/web/layer-worker.html +3 -3
- package/web/assets/aerial-DT_gUtSh.js +0 -2
- package/web/assets/auraTrack-CEs_Q9EP.js +0 -1
- package/web/assets/breakthrough-DvkxvNK9.js +0 -2
- package/web/assets/clientExport-C4VgAJtO.js +0 -1
- package/web/assets/exportEncode-D9OT7_5k.js +0 -1
- package/web/assets/fightDirector-CECPf2iH.js +0 -1
- package/web/assets/fightDrama-CqNoa5XI.js +0 -2
- package/web/assets/gpuExport-uyOAyrhm.js +0 -190
- package/web/assets/library-Dsz_MLyd.js +0 -1
- package/web/assets/mapBake-CNMOKXA7.js +0 -1
- package/web/assets/plateCamera-C96L5GKm.js +0 -1
- package/web/assets/remote-BJdzzFZg.js +0 -1241
- package/web/assets/surfaceLight-B_SYg_f8.js +0 -1
- package/web/assets/textAnimators-Bdt5LWXk.js +0 -1
- package/web/assets/timeline3dExport-CEH1RjNf.js +0 -1
- package/web/assets/titleArt-hb_T45WJ.js +0 -5
- package/web/assets/titleFrames-Dw0PEBdV.js +0 -1
- package/web/assets/weaponDuel-CLLgv5A4.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as Vo,f_ as Ct,eb as no,ec as vt,cb as Gt,kb as Bo,ea as wt,d5 as yt,fu as it,fl as ko,f$ as yo,fN as Uo,iI as Go,au as Et,F as ut,b_ as Qo,j9 as go,mK as bo,mL as Jo,ig as so,ie as ro,jb as Zo,fp as Ho,jd as xo,mM as wo,mN as Wo,mO as ao,mP as te,mQ as oe,jc as Qt,je as ee,cA as vo,dB as Yt,kd as ne,mR as se}from"./titleFrameBudget-Cml-MO53.js";import{bV as re,bW as ae}from"./api-QBI5GJTZ.js";const qt=.1,Kt=t=>Math.abs(t)>180?(t%360+540)%360-180:t;function Eo(t,o,s,n,e,a,r,l,i){const c=l-r,f=t==null?s-o:(s-t)/Math.max(1e-9,l-a)*c,h=n==null?s-o:(n-o)/Math.max(1e-9,i-r)*c,p=e*e,u=p*e;return(2*u-3*p+1)*o+(u-2*p+e)*f+(-2*u+3*p)*s+(u-p)*h}function Ao(t,o,s,n,e,a,r,l,i){const c=o+Kt(s-o),f=t==null?null:o+Kt(t-o),h=n==null?null:c+Kt(n-c);return Eo(f,o,c,h,e,a,r,l,i)}function ie(t,o,s=n=>n.time){if(globalThis.__clipooxLinearKeys)return!1;const n=(e,a)=>s(t[a])-s(t[e]);return!(n(o,o+1)>qt||o>0&&n(o-1,o)>qt||o+2<t.length&&n(o+1,o+2)>qt)}function Jt(t,o,s,n){let e=o>0,a=o+2<t.length;if(n!=null){const l=e?s(t[o-1]):null,i=s(t[o]),c=s(t[o+1]),f=a?s(t[o+2]):null;if(i<n-1e-9&&c>=n-1e-9)return{before:!1,after:!1};a&&c<n-1e-9&&f>=n-1e-9&&(a=!1),e&&i>=n-1e-9&&l<n-1e-9&&(e=!1)}return{before:e,after:a}}function ke(t,o,s,n=r=>r.pose,e=r=>r.time,a=null){const r=Jt(t,o,e,a),l=n(t[o]),i=n(t[o+1]),c=r.before?n(t[o-1]):null,f=r.after?n(t[o+2]):null,h=e(t[o]),p=e(t[o+1]),u=c?e(t[o-1]):h-(p-h),m=f?e(t[o+2]):p+(p-h),y={};for(const M of new Set([...Object.keys(l),...Object.keys(i)])){const d=l[M]??0,x=i[M]??0;if(typeof d!="number"||typeof x!="number")continue;const g=c&&typeof c[M]=="number"?c[M]:null,w=f&&typeof f[M]=="number"?f[M]:null;y[M]=Ao(g,d,x,w,s,u,h,p,m)}return y}function le(t,o,s,n=r=>r.position,e=r=>r.time,a=null){const r=Jt(t,o,e,a),l=n(t[o]),i=n(t[o+1]),c=r.before?n(t[o-1]):null,f=r.after?n(t[o+2]):null,h=e(t[o]),p=e(t[o+1]),u=c?e(t[o-1]):h-(p-h),m=f?e(t[o+2]):p+(p-h);return l.map((y,M)=>Eo(c?c[M]:null,y,i[M],f?f[M]:null,s,u,h,p,m))}function ce(t,o,s,n,e=r=>r.time,a=null){const r=Jt(t,o,e,a),l=n(t[o]),i=n(t[o+1]),c=r.before?n(t[o-1]):null,f=r.after?n(t[o+2]):null,h=e(t[o]),p=e(t[o+1]),u=c!=null?e(t[o-1]):h-(p-h),m=f!=null?e(t[o+2]):p+(p-h);return Ao(c,l,i,f,s,u,h,p,m)}const At=30,io=4,bt=Object.freeze({min:.25,max:6,default:3}),Rt=40,Po=300,Co=Object.freeze({position:.01,rotation:2}),So=80,To=Object.freeze(["here","above","explode","throw"]),$t=Object.freeze({bouncy:Object.freeze({restitution:.6,friction:.45}),normal:Object.freeze({restitution:.25,friction:.6}),heavy:Object.freeze({restitution:.04,friction:.9})}),fe=9.81;let Nt=null,Ro=null;const Io=()=>Ro;function _o(){return Nt??=(async()=>{const t=await Vo(()=>import("./rapier-DBjBuyhF.js"),[]),o=t.default??t,s=console.warn;console.warn=(...n)=>{String(n[0]).includes("deprecated parameters")||s(...n)};try{await o.init()}finally{console.warn=s}return Ro=o,o})().catch(t=>{throw Nt=null,t}),Nt}const ot=t=>typeof t=="number"&&Number.isFinite(t),Y=(t,o)=>Array.isArray(t)&&t.length===3&&t.every(ot)?[t[0],t[1],t[2]]:o,J=Math.PI/180,St=t=>(t%360+540)%360-180,Tt=t=>Math.round(t*1e4)/1e4,Vt=t=>Math.round(t*100)/100;function Pt(t){const o=Math.cos(t[0]*J/2),s=Math.cos(t[1]*J/2),n=Math.cos(t[2]*J/2),e=Math.sin(t[0]*J/2),a=Math.sin(t[1]*J/2),r=Math.sin(t[2]*J/2);return[e*s*n+o*a*r,o*a*n-e*s*r,o*s*r+e*a*n,o*s*n-e*a*r]}function jo(t){const[o,s,n,e]=t,a=1-2*(s*s+n*n),r=2*(o*s-n*e),l=2*(o*n+s*e),i=1-2*(o*o+n*n),c=2*(s*n-o*e),f=2*(s*n+o*e),h=1-2*(o*o+s*s),p=Math.asin(Math.max(-1,Math.min(1,l)));return Math.abs(l)<.9999999?[Math.atan2(-c,h)/J,p/J,Math.atan2(-r,a)/J]:[Math.atan2(f,i)/J,p/J,0]}const lo=(t,o)=>{const[s,n,e,a]=t,r=a*o[0]+n*o[2]-e*o[1],l=a*o[1]+e*o[0]-s*o[2],i=a*o[2]+s*o[1]-n*o[0],c=-s*o[0]-n*o[1]-e*o[2];return[r*a+c*-s+l*-e-i*-n,l*a+c*-n+i*-s-r*-e,i*a+c*-e+r*-n-l*-s]},Do=(t,o)=>2*Math.acos(Math.min(1,Math.abs(t[0]*o[0]+t[1]*o[1]+t[2]*o[2]+t[3]*o[3])))/J;function Fo(t){let o=2166136261;for(const n of String(t))o=Math.imul(o^n.codePointAt(0),16777619);let s=o>>>0;return()=>{s=s+1831565813|0;let n=Math.imul(s^s>>>15,1|s);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const co=new Set(["box","sphere","cylinder","wall","platform"]),he=new Set(["person","fx","splat","set","floor"]);function ue(t){return t?t.locked?"Đối tượng đang khoá":t.hold?"Đồ đang cầm đi theo tay người cầm":t.kind==="person"||t.kind==="model"&&(t.skeleton==="native"||t.rig?.kind==="humanoid")?"Nhân vật không rơi như vật thể — dùng chuyển động":he.has(t.kind)?"Loại đối tượng này không rơi được":null:"Chưa chọn đối tượng"}function pe(t){const o=Y(t.scale,[1,1,1]);return t.kind==="sphere"&&Math.abs(o[0]-o[1])<1e-6&&Math.abs(o[1]-o[2])<1e-6||t.kind==="prop"&&t.prop?.kind==="ball"?"ball":t.kind==="cylinder"&&Math.abs(o[0]-o[2])<1e-6?"cylinder":"box"}function me(t){const o=Y(t.scale,[1,1,1]).map(Math.abs),s=Y(t.mirror,[1,1,1]),n=Y(t.origin,[0,0,0]);let e=[1,1,1],a=[0,.5,0];if(t.kind==="proxy"&&t.proxy?.dims)e=Y(t.proxy.dims,e),a=[0,e[1]/2,0];else if(t.kind==="prop"){const i=t.prop?.kind==="ball"?.12:.15;e=[2*i,2*i,2*i],a=[0,t.prop?.kind==="ball"?0:i,0]}else if(t.kind==="model"){const i=t.model?.height??2;e=[i*.6,i,i*.6],a=[0,i/2,0]}else co.has(t.kind)||(e=[.5,.5,.5],a=[0,.25,0]);const r=co.has(t.kind)?[(a[0]-n[0])*s[0],(a[1]-n[1])*s[1],(a[2]-n[2])*s[2]]:a,l=i=>[i[0]*(t.scale?.[0]??1),i[1]*(t.scale?.[1]??1),i[2]*(t.scale?.[2]??1)];return{half:[e[0]*o[0]/2,e[1]*o[1]/2,e[2]*o[2]/2],offset:l(r)}}function de(t,o){let s=0,n=t.length-1;for(;n-s>1;){const e=s+n>>1;t[e].time<=o?s=e:n=e}return s}function zo(t,o,s=null,n=null){const e=t[0],a=t[t.length-1];if(o<=e.time)return{position:e.position,rotation:e.rotation};if(o>=a.time)return{position:a.position,rotation:a.rotation};const r=de(t,o),l=t[r],i=t[r+1],c=(o-l.time)/(i.time-l.time),f=h=>l.rotation[h]+St(i.rotation[h]-l.rotation[h])*c;return ie(t,r,n>0?h=>h.time*n:void 0)?{position:le(t,r,c,h=>h.position,h=>h.time,s),rotation:[f(0),ce(t,r,c,h=>h.rotation[1],h=>h.time,s),f(2)]}:{position:[0,1,2].map(h=>l.position[h]+(i.position[h]-l.position[h])*c),rotation:[f(0),f(1),f(2)]}}function qo(t,{tolerance:o=Co,maxKeys:s=So,before:n=null,seam:e=null,duration:a=null}={}){const r=t.length;if(r<=2)return{keys:t.map(({time:f,position:h,rotation:p})=>({time:f,position:h,rotation:p})),error:{position:0,rotation:0}};const l=new Set([0,r-1]),i=()=>[...l].sort((f,h)=>f-h).map(f=>t[f]);let c={position:0,rotation:0};for(;;){const f=i(),h=n?[n,...f]:f;let p=-1,u=1;c={position:0,rotation:0};for(let m=1;m<r-1;m++){if(l.has(m))continue;const y=t[m],M=zo(h,y.time,e,a),d=Math.hypot(M.position[0]-y.position[0],M.position[1]-y.position[1],M.position[2]-y.position[2]),x=Do(Pt(M.rotation),y.quat);c={position:Math.max(c.position,d),rotation:Math.max(c.rotation,x)};const g=Math.max(d/o.position,x/o.rotation);g>u&&(u=g,p=m)}if(p<0||l.size>=s)break;l.add(p)}return{keys:i().map(({time:f,position:h,rotation:p})=>({time:f,position:h,rotation:p})),error:{position:Tt(c.position),rotation:Vt(c.rotation)}}}const Me=t=>ot(t)?{restitution:Math.max(0,Math.min(.95,t)),friction:.6}:$t[t]??$t.normal;async function ye(t){const o=Zt(await _o(),t),{duration:s,mode:n}=o,e=ot(t.start)?Math.max(0,t.start):0,a=ot(t.shotDuration)&&t.shotDuration>0?t.shotDuration:e+s,r={},l=e/a;for(const i of o.bodies){let c=null;const f=i.samples.map(m=>{let y=jo(m.q);if(c){const M=[y[0]+180,180-y[1],y[2]+180],d=x=>x.reduce((g,w,b)=>g+Math.abs(St(w-c[b])),0);d(M)<d(y)&&(y=M)}return y=y.map(M=>Vt(St(M)===-180?180:St(M))),c=y,{time:l+m.sec/a,position:m.pivot.map(Tt),rotation:y,quat:Pt(y)}}),h=t.before?.[i.id],{keys:p,error:u}=qo(f,{before:h&&ot(h.time)&&h.time<l?h:null,seam:ot(t.seam)?t.seam:null,duration:a});r[i.id]={keys:p,error:u,settledAt:i.settledAt,from:{position:i.position.map(Tt),rotation:i.rotation.map(Vt)},rest:f[f.length-1].position,restCentre:i.samples[i.samples.length-1].centre.map(Tt),restQuat:i.samples[i.samples.length-1].q}}return{tracks:r,settled:o.settled,seconds:s,mode:n}}function Zt(t,o){const s=!!o.planar,n=To.includes(o.mode)?o.mode:"here",e=Math.max(bt.min,Math.min(bt.max,ot(o.duration)?o.duration:bt.default)),a=ot(o.floor)?o.floor:0,r=Me(o.bounciness),l=Fo(`${o.seed??"drop"}|${n}`),i=m=>(l()*2-1)*m,c=(o.bodies||[]).filter(m=>m&&m.id!=null).map(m=>({id:String(m.id),shape:["ball","cylinder"].includes(m.shape)?m.shape:"box",position:Y(m.position,[0,0,0]),rotation:Y(m.rotation,[0,0,0]),half:Y(m.half,[.25,.25,.25]).map(y=>Math.max(.01,Math.abs(y))),offset:Y(m.offset,[0,0,0])})).sort((m,y)=>m.id<y.id?-1:m.id>y.id?1:0).slice(0,Rt);if(!c.length)throw new Error("no objects to drop");const f=m=>Math.hypot(...m.half);for(const m of c){m.q=Pt(m.rotation);const y=lo(m.q,m.offset);m.c=[m.position[0]+y[0],m.position[1]+y[1],m.position[2]+y[2]],m.v=[0,0,0],m.w=[0,0,0]}if(n==="above"){const m=ot(o.height)?Math.max(.3,Math.min(20,o.height)):2,y=Math.max(...c.map(d=>d.c[1]+f(d))),M=[];for(const d of[...c].sort((x,g)=>x.c[1]-g.c[1]||(x.id<g.id?-1:1))){d.q=Pt(s?[d.rotation[0],d.rotation[1],d.rotation[2]+i(35)]:[d.rotation[0]+i(35),d.rotation[1]+i(180),d.rotation[2]+i(35)]);let x=y+m+f(d);for(const g of M)Math.hypot(g.c[0]-d.c[0],g.c[2]-d.c[2])<f(g)+f(d)&&(x=Math.max(x,g.c[1]+f(g)+f(d)+.05));d.c=s?[d.c[0],x,d.c[2]]:[d.c[0]+i(.05),x,d.c[2]+i(.05)],M.push(d)}}if(n==="here")for(const m of c)m.w=[i(1.2),i(1.2),i(1.2)];const h=m=>s?[0,0,m[2]]:m,p=m=>s?[m[0],m[1],0]:m;if(n==="explode"){const m=Y(o.center,[0,1,2].map(M=>c.reduce((d,x)=>d+x.c[M],0)/c.length)),y=ot(o.strength)?Math.max(.5,Math.min(20,o.strength)):4;for(const M of c){let d=M.c[0]-m[0],x=s?0:M.c[2]-m[2],g=Math.hypot(d,x);if(g<.001){const b=l()*Math.PI*2;d=Math.cos(b),x=s?0:Math.sin(b),g=Math.hypot(d,x)||1}const w=y*(.75+l()*.5);M.v=[d/g*w,w*(.6+l()*.4),x/g*w],M.w=[i(7),i(7),i(7)]}}if(n==="throw"){const m=Y(o.velocity,[0,2,3]);for(const y of c)y.v=m.map(M=>M*(1+i(.08))),y.w=[i(5),i(5),i(5)]}const u=new t.World({x:0,y:-(ot(o.gravity)?o.gravity:fe),z:0});try{u.timestep=1/(At*io);for(const g of c)g.v=p(g.v),g.w=h(g.w);const m=(g,w)=>{const b=u.createRigidBody(t.RigidBodyDesc.fixed().setTranslation(g[0],g[1],g[2]));u.createCollider(t.ColliderDesc.cuboid(w[0],w[1],w[2]).setRestitution(r.restitution).setFriction(r.friction),b)};m([0,a-1,0],[1e3,1,1e3]);let y=0;for(const g of o.statics||[]){const w=Y(g?.min,null),b=Y(g?.max,null);if(!w||!b||y>=Po)continue;const v=[0,1,2].map(R=>(b[R]-w[R])/2);v.some(R=>!(R>.002))||b[1]<=a+.001||(m([0,1,2].map(R=>(w[R]+b[R])/2),v),y++)}for(const g of c){g.rb=u.createRigidBody(t.RigidBodyDesc.dynamic().setTranslation(g.c[0],g.c[1],g.c[2]).setRotation({x:g.q[0],y:g.q[1],z:g.q[2],w:g.q[3]}).setLinvel(g.v[0],g.v[1],g.v[2]).setAngvel({x:g.w[0],y:g.w[1],z:g.w[2]}).setLinearDamping(.05).setAngularDamping(g.shape==="box"?.2:1.2).setCcdEnabled(!0)),s&&(g.rb.setEnabledTranslations(!0,!0,!1,!1),g.rb.setEnabledRotations(!1,!1,!0,!1));const w=g.shape==="ball"?t.ColliderDesc.ball(Math.max(...g.half)):g.shape==="cylinder"?t.ColliderDesc.cylinder(g.half[1],Math.max(g.half[0],g.half[2])):t.ColliderDesc.cuboid(g.half[0],g.half[1],g.half[2]);u.createCollider(w.setRestitution(r.restitution).setFriction(r.friction).setDensity(400),g.rb),g.samples=[]}const M=Math.round(e*At);for(let g=0;g<=M;g++){if(g)for(let w=0;w<io;w++)u.step();for(const w of c){const b=w.rb.translation(),v=w.rb.rotation(),R=[v.x,v.y,v.z,v.w],T=lo(R,w.offset),D=w.rb.linvel(),q=w.rb.angvel();w.samples.push({sec:g/At,centre:[b.x,b.y,b.z],pivot:[b.x-T[0],b.y-T[1],b.z-T[2]],q:R,speed:Math.hypot(D.x,D.y,D.z)+Math.hypot(q.x,q.y,q.z)*f(w)})}}let d=!0;return{bodies:c.map(g=>{let w=null;for(let b=g.samples.length-1;b>=0&&g.samples[b].speed<.05;b--)w=g.samples[b].sec;return w==null&&(d=!1),{id:g.id,position:g.position,rotation:g.rotation,half:g.half,offset:g.offset,samples:g.samples,settledAt:w}}),settled:d,duration:e,mode:n}}finally{u.free()}}function ge(t,o,s,{scale:n={},newId:e,lifted:a=!1}={}){const r=e??(()=>globalThis.crypto.randomUUID());return{...t,shots:t.shots.map(l=>{if(l.id!==o)return l;const i={...l.objectKeys};for(const[c,f]of Object.entries(s)){if(!f.keys.length)continue;const h=f.keys[0].time,p=t.items.find(M=>M.id===c),u=Y(n[c],Y(p?.scale,[1,1,1])),m=(i[c]||[]).filter(M=>M.time<h-1e-6),y=1/(At*Math.max(1e-6,l.duration||1));a&&f.from&&m.length&&h-y>m[m.length-1].time+1e-6&&m.push({id:r(),time:h-y,position:[...f.from.position],rotation:[...f.from.rotation],scale:[...u]}),i[c]=[...m,...f.keys.map(M=>({id:r(),time:M.time,position:[...M.position],rotation:[...M.rotation],scale:[...u]}))]}return{...l,objectKeys:i}})}}const Ue=Object.freeze(Object.defineProperty({__proto__:null,BOUNCE_PRESETS:$t,DROP_MODES:To,DROP_SECONDS:bt,KEY_TOLERANCE:Co,MAX_KEYS_PER_BODY:So,MAX_PHYSICS_BODIES:Rt,MAX_PHYSICS_STATICS:Po,PHYSICS_FPS:At,applyDropKeys:ge,bakeDrop:ye,dropUnavailable:ue,eulerFromQuat:jo,fallbackShape:me,loadRapier:_o,quatAngle:Do,quatFromEuler:Pt,rapierReady:Io,sampleBakedKeys:zo,seededRandom:Fo,shapeKind:pe,simulateDrop:Zt,thinKeys:qo},Symbol.toStringTag,{value:"Module"})),Ko=["x","y","zoom","rot","opacity","depth"],X=t=>Math.round(t*1e4)/1e4,Dt=(t,o)=>Object.keys(it).filter(s=>(!o||o.includes(s))&&ko(t,s));function Ge(t,{in:o=.33,out:s=.33}={},n){const e=Bo([Math.max(0,Math.min(1,s)),0,Math.max(0,Math.min(1,1-o)),1]);let a={...t},r={};for(const l of Dt(t)){const i=wt(a,l),c=n?n.filter(h=>h.prop===l):i;if(!c.length)continue;const f=i.map((h,p)=>p<i.length-1&&c.some(u=>Math.abs(u.time-h.time)<1/120)?{...h,ease:e}:h);r={...r,...yt(a,l,f)},a={...a,...r}}return r}const Ht={tl:[0,0],t:[.5,0],tr:[1,0],l:[0,.5],c:[.5,.5],r:[1,.5],bl:[0,1],b:[.5,1],br:[1,1]},Qe=Object.keys(Ht);function Je(t,o,s,n,e,a){const[r,l]=Ht[s],i=o.angle*Math.PI/180,c=Math.abs(o.w*Math.cos(i))+Math.abs(o.h*Math.sin(i)),f=Math.abs(o.w*Math.sin(i))+Math.abs(o.h*Math.cos(i)),h=c/2+(e-c)*r,p=f/2+(a-f)*l,u=(h-o.cx)/e,m=(p-o.cy)/a,y=(d,x)=>Math.max(it[d].min,Math.min(it[d].max,x));let M=no(t,"x",X(y("x",vt(t,"x",n)+u)),n);return M={...M,...no({...t,...M},"y",X(y("y",vt(t,"y",n)+m)),n)},M}function Ze(t,o,s,n,e,a){const[r,l]=Ht[s],i=Gt(t,n,e,a).zoom||1;return Go(t,n,X((r-.5)*o.w/(e*i)),X((l-.5)*o.h/(a*i)),e,a)}function He(t,o,s,n="forward",e=1){let a=t.filter(i=>o.includes(i.id)).sort((i,c)=>c.track-i.track||i.start-c.start);if(a.length<2)return t;if(n==="reverse")a.reverse();else if(n==="center"){const i=(a.length-1)/2;a=[...a].sort((c,f)=>Math.abs(a.indexOf(c)-i)-Math.abs(a.indexOf(f)-i))}else if(n==="random"){let i=e>>>0||1;const c=()=>(i=Math.imul(i^i>>>15,2246822507)>>>0)/4294967295;a=a.map(f=>[c(),f]).sort((f,h)=>f[0]-h[0]).map(f=>f[1])}const r=Math.min(...a.map(i=>i.start)),l=new Map(a.map((i,c)=>[i.id,X(Math.max(0,r+c*s))]));return t.map(i=>l.has(i.id)?{...i,start:Math.min(l.get(i.id),600-i.duration)}:i)}function We(t,o){const s={};for(const e of Dt(t)){const a=wt(t,e).filter(r=>!o||o.some(l=>l.prop===e&&Math.abs(l.time-r.time)<.008333333333333333));a.length&&(s[e]=a)}const n=Math.min(...Object.values(s).flat().map(e=>e.time));return Object.keys(s).length?{props:Object.fromEntries(Object.entries(s).map(([e,a])=>[e,a.map(r=>({...r,time:X(r.time-n)}))]))}:null}function tn(t,o,s){let n={...t},e={};for(const[a,r]of Object.entries(o.props)){if(!it[a]||t.kind==="model"&&a==="rot"||t.kind!=="model"&&["rx","ry","rz"].includes(a))continue;const l=r.map(c=>({...c,time:X(s+c.time)})).filter(c=>c.time<=t.duration+1e-6),i=wt(n,a).filter(c=>!l.some(f=>Math.abs(f.time-c.time)<1/120));e={...e,...yt(n,a,[...i,...l].sort((c,f)=>c.time-f.time))},n={...n,...e}}return e}function on(t,o="elastic",{amount:s=.5,cycles:n=3,props:e}={}){let a={...t},r={};for(const l of Dt(t,e??Ko)){const i=wt(a,l);if(i.length<2)continue;const c=i.at(-2),f=i.at(-1),h=f.time-c.time,p=t.duration-f.time;if(h<=0||p<.1)continue;const u=f.value-c.value;if(Math.abs(u)<1e-6)continue;const m=Math.max(1,Math.min(6,Math.round(n))),y=Math.min(p/(m*2),Math.max(.06,h*.6)),M=[];for(let d=1;d<=m*2;d++){const x=s*Math.pow(.45,Math.ceil(d/2)-1),g=o==="bounce"?(d%2?-1:0)*Math.abs(u)*x*Math.sign(u):(d%2?1:-1)*u*x*.5,w=d===m*2?f.value:f.value+g,b=it[l].min,v=it[l].max;M.push({time:X(f.time+y*d),value:X(Math.max(b,Math.min(v,w))),ease:fo})}r={...r,...yt(a,l,[...i.map((d,x)=>x===i.length-1?{...d,ease:fo}:d),...M])},a={...a,...r}}return r}const fo=[.33,0,.67,1];function en(t,o="cycle",{props:s,maxKeys:n=60}={}){let e={...t},a={};for(const r of Dt(t,s)){const l=wt(e,r);if(l.length<2)continue;const i=l[0].time,c=l.at(-1).time,f=c-i;if(f<=1/30)continue;const h=[...l],p=l.at(-1).value-l[0].value;for(let u=1;h.length<n;u++){const m=o==="pingpong"&&u%2?[...l].reverse().map(M=>({...M,time:c-(M.time-i)})):l;let y=!1;for(const M of m.slice(1)){const d=X(M.time+f*u);if(d>t.duration+1e-6||h.length>=n)break;const x=o==="offset"?M.value+p*u:M.value,{min:g,max:w}=it[r];h.push({...M,time:d,value:X(Math.max(g,Math.min(w,x)))}),y=!0}if(!y)break}a={...a,...yt(e,r,h)},e={...e,...a}}return a}function nn(t,o){const s=Ct(t.shape)?t.shape:yo(t.shape);return s.items.map(n=>({...t,id:o(),label:`${t.label} · ${n.name}`.slice(0,60),shape:{...s,items:[{...n}]}}))}const be=["posX","posY","scale","rotation","anchorX","anchorY","parentId","opacity"];function sn(t){if(t.length<2)throw Error("Chọn ít nhất 2 layer Shape để gộp");const[o,...s]=t,n=a=>be.every(r=>(a[r]??null)===(o[r]??null))&&!a.motionKeys?.some(r=>Ko.some(l=>l in r));if(!t.every(n))throw Error("Chỉ gộp được các layer Shape cùng vị trí / tỉ lệ / góc xoay và không có key chuyển động");const e=[];for(const a of t){const r=Ct(a.shape)?a.shape:yo(a.shape);for(const l of r.items)e.push({...l,id:Uo(e)})}if(e.length>24)throw Error("Một layer Shape chứa tối đa 24 hình");return{...o,start:Math.min(...t.map(a=>a.start)),duration:Math.max(...t.map(a=>a.start+a.duration))-Math.min(...t.map(a=>a.start)),shape:{v:2,items:e}}}function rn(t,o,s,{fps:n=10,makeId:e,label:a}={}){const r=Math.min(o/1280,s/720),l=(y,M)=>[X(((y-o/2)/r+640-280)/.72),X(((M-s/2)/r+360)/.72)],i=Math.max(2,Math.min(255,Math.round(t.duration*n)+1)),c=[];for(let y=0;y<i;y++){const M=Gt(t,t.duration*y/(i-1),o,s);c.push(l(o/2+M.x*o,s/2+M.y*s))}const f=c.map(y=>y[0]),h=c.map(y=>y[1]),p=(Math.min(...f)+Math.max(...f))/2,u=(Math.min(...h)+Math.max(...h))/2,m={id:"s1",name:"Position Trace",type:"path",params:{pts:c.map(([y,M])=>[X(y-p),X(M-u)]),closed:!1},pos:[X(p),X(u)],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:"#c6f432",width:8,cap:"round",join:"round"}};return{id:e(),nodeId:"",kind:"image",url:"",label:a??`${t.label} · trace`.slice(0,60),track:t.track,start:t.start,duration:t.duration,volume:0,motionV:2,shape:{v:2,items:[m]}}}const Wt=/^#[0-9a-fA-F]{6}$/,xe=24,an=["#c6f432","#2bd4c9","#ffffff","#0d0f12","#ff5bd1"];function ln(t,o=16){const s=new Map,n=e=>{if(typeof e=="string"&&Wt.test(e)){const a=e.toLowerCase();s.set(a,(s.get(a)||0)+1)}};for(const e of t){e.title&&(n(e.title.color),n(e.title.accentColor));const a=e.shape;if(a)if(Ct(a))for(const r of a.items){n(r.fill.color);for(const l of r.fill.stops||[])n(l[0]);n(r.stroke?.color)}else for(const r of a.paths)n(r.stroke),n(r.fill)}return[...s.entries()].sort((e,a)=>a[1]-e[1]).slice(0,o).map(e=>e[0])}function cn(t,o,{stroke:s=!1,itemId:n}={}){if(!Wt.test(o))throw Error("Invalid colour");if(t.title)return{title:{...t.title,[s?"accentColor":"color"]:o}};if(!t.shape)throw Error("Chọn layer Shape hoặc chữ để áp màu");return Ct(t.shape)?{shape:{...t.shape,items:t.shape.items.map(e=>n&&e.id!==n?e:s?{...e,stroke:{...e.stroke??{width:8,cap:"round",join:"round"},color:o}}:{...e,fill:e.fill.type==="linear"||e.fill.type==="radial"?{...e.fill,stops:e.fill.stops.map((a,r)=>r===0?[o,a[1]]:a)}:{...e.fill,type:"color",color:o}})}}:{shape:{...t.shape,paths:t.shape.paths.map(e=>s||!e.fill?{...e,stroke:o}:{...e,fill:o})}}}function fn(t,o){if(!Array.isArray(o)||!o.length||o.length>xe||!o.every(e=>Wt.test(e)))throw Error("Invalid palette");const s=e=>o[e%o.length];if(t.title)return{title:{...t.title,color:s(0),...o.length>1?{accentColor:s(1)}:{}}};if(!t.shape)throw Error("Chọn layer Shape hoặc chữ để áp màu");if(!Ct(t.shape))return{shape:{...t.shape,paths:t.shape.paths.map((e,a)=>({...e,...e.fill?{fill:s(a)}:{},...e.stroke?{stroke:e.fill?e.stroke:s(a)}:{}}))}};let n=0;return{shape:{...t.shape,items:t.shape.items.map(e=>{const a=e.fill;return a.type==="linear"||a.type==="radial"?{...e,fill:{...a,stops:a.stops.map(r=>[s(n++),r[1]])}}:a.type==="color"?{...e,fill:{...a,color:s(n++)}}:e.stroke?{...e,stroke:{...e.stroke,color:s(n++)}}:e})}}}function we(t,o,s,n){const e=Gt(t,o,s,n),a=t.card?t.card.width/t.card.height:t.lottie?t.lottie.w/t.lottie.h:null,[r,l]=a&&Number.isFinite(a)&&a>0?a>s/n?[s,s/a]:[n*a,n]:[s,n];return{cx:s/2+e.x*s,cy:n/2+e.y*n,w:r*e.zoom,h:l*e.zoom,angle:e.rot}}const ve=3,Bt=30,Ot=Object.freeze({xy:.002,rot:1.5}),Ee=.2,ho=t=>typeof t=="number"&&Number.isFinite(t),uo=t=>Math.round(t*1e4)/1e4;function Ae(t){return t?t.kind==="audio"?"Âm thanh không rơi được":t.adjust===!0?"Lớp điều chỉnh không có hình để rơi":t.parentId?"Lớp đang gắn vào lớp cha — bỏ gắn rồi thử lại":null:"Không tìm thấy lớp"}function to(t,o,s,n=Bt){const e=t.length;if(e<=2)return[...Array(e).keys()];const a=[0,e-1];for(;;){a.sort((i,c)=>i-c);let r=-1,l=s;for(let i=0;i+1<a.length;i++){const c=a[i],f=a[i+1];for(let h=c+1;h<f;h++){const p=o[c]+(o[f]-o[c])*(t[h]-t[c])/(t[f]-t[c]),u=Math.abs(p-o[h]);u>l&&(l=u,r=h)}}if(r<0||a.length>=n)return a;a.push(r)}}function Pe(t,o,s){let n=0;for(let e=0;e+1<s.length;e++)for(let a=s[e]+1;a<s[e+1];a++){const r=s[e],l=s[e+1];n=Math.max(n,Math.abs(o[r]+(o[l]-o[r])*(t[a]-t[r])/(t[l]-t[r])-o[a]))}return n}function Ce(t,o,s){const n=[],e=r=>Math.floor((r+180)/360),a=(r,l)=>r-360*l;for(let r=0;r<s.length;r++){const l=s[r],i=o[l],c=e(i);if(r){const f=s[r-1],h=e(o[f]);if(h!==c){const p=c>h,u=(p?h+1:h)*360-180,m=(u-o[f])/(i-o[f]),y=Et(t[f]+(t[l]-t[f])*m),M=Math.max(n.at(-1).time+1/ut,Math.min(y,Et(t[l]-2/ut))),d=M+1/ut;d<t[l]-1e-6?n.push({time:M,value:p?180:-180,ease:"hold"},{time:d,value:p?-180:180}):n[n.length-1]={...n[n.length-1],ease:"hold"}}}n.push({time:t[l],value:Math.max(-180,Math.min(180,a(i,c)))})}return n}function hn(t,o,s={}){const n=s.R??Io();if(!n)throw Error("Physics engine not loaded yet — try again");const e=s.W??1280,a=s.H??720,r=ve/a,l=ho(s.at)?s.at:0,i=Math.max(1,Math.min(bt.max,ho(s.duration)?s.duration:bt.default)),c=s.mode==="above"?"above":"here",f=[...new Set(o)].map(b=>t.find(v=>v.id===b));if(!f.length)throw Error("physicsDrop needs clipIds");if(f.length>Rt)throw Error(`At most ${Rt} layers per drop`);for(const[b,v]of f.entries()){const R=Ae(v);if(R)throw Error(`${v?.label??o[b]}: ${R}`)}const h=f.map(b=>{const v=Et(l-b.start);if(v<0||v>b.duration-2/ut)throw Error(`${b.label??b.id}: the playhead is outside the layer`);const R=vt(b,"x",v),T=vt(b,"y",v),D=vt(b,"rot",v),q=s.rectOf?.(b)??we(b,v,e,a),O=[R*e*r,-T*a*r],N=[(q.cx-e/2)*r,-(q.cy-a/2)*r],P=D*Math.PI/180,E=[N[0]-O[0],N[1]-O[1]],I=[E[0]*Math.cos(P)-E[1]*Math.sin(P),E[0]*Math.sin(P)+E[1]*Math.cos(P)];return{id:b.id,position:[O[0],O[1],0],rotation:[0,0,-D],half:[Math.max(4,q.w)*r/2,Math.max(4,q.h)*r/2,Ee],offset:[I[0],I[1],0],local:v,x:R,y:T,rot:D}}),p=-a*r/2,u=a*r/2,m=e*r/2,y=s.walls?[{min:[-m-2,p,-2],max:[-m,u+20,2]},{min:[m,p,-2],max:[m+2,u+20,2]}]:[],M=b=>Math.hypot(b.half[0],b.half[1],b.half[2]),d=Math.max(...h.map(b=>b.position[1]+M(b))),x=Zt(n,{bodies:h,statics:y,floor:p,mode:c,bounciness:s.bounciness,duration:i,height:Math.max(.3,u-d+.05),seed:s.seed??[...o].sort().join(","),planar:!0}),g={},w=t.map(b=>({...b}));for(const b of h){const v=x.bodies.find(F=>F.id===b.id),R=w.findIndex(F=>F.id===b.id);let T=w[R];const D=[],q=[],O=[],N=[];let P=b.rot;for(const F of v.samples){const G=Et(b.local+F.sec);if(G>T.duration+1e-6)break;let H=-2*Math.atan2(F.q[2],F.q[3])*180/Math.PI;H+=360*Math.round((P-H)/360),P=H,D.push(G),q.push(F.pivot[0]/r/e),O.push(-F.pivot[1]/r/a),N.push(H)}const E=c==="above"&&b.local>=1/ut,I={},V={},K=Math.min(...N),B=Math.max(...N),k=B-K<360?Math.ceil((B-180)/360)*360:0,mt=k&&K-k>=-180?N.map(F=>F-k):N,dt=mt!==N&&b.local>=1/ut;for(const[F,G,H]of[["x",q,Ot.xy],["y",O,Ot.xy],["rot",mt,Ot.rot]]){const Mt=E||F==="rot"&&dt,W=wt(T,F).filter(L=>L.time<b.local-(Mt?1.5:.5)/ut),tt=Mt?[{time:Et(b.local-1/ut),value:F==="x"?b.x:F==="y"?b.y:b.rot,...F==="rot"&&dt?{ease:"hold"}:{}}]:[],ft=F==="rot"?G.reduce((L,Q,at)=>L+(at&&Math.floor((Q+180)/360)!==Math.floor((G[at-1]+180)/360)?1:0),0):0,rt=Bt-W.length-tt.length-2*ft;if(rt<2)throw Error(`${T.label??T.id}: too many ${F} keys before the playhead (or too many turns) to add the drop`);const ht=to(D,G,H,rt),gt=it[F].min,j=it[F].max,z=F==="rot"?Ce(D,G,ht):ht.map(L=>({time:D[L],value:Math.max(gt,Math.min(j,G[L]))})),nt=[...W,...tt,...z].map(L=>({time:L.time,value:uo(L.value),...L.ease?{ease:L.ease}:{}}));T={...T,...yt(T,F,nt.slice(0,Bt))},I[F]=z.length,V[F]=uo(Pe(D,G,ht))}w[R]=T,g[b.id]={keys:I,error:V,settledAt:v.settledAt==null?null:Math.round((l+v.settledAt)*1e3)/1e3}}return{clips:w,report:g,settled:x.settled}}const $=Object.freeze({work:480,focals:[.45,.55,.7,.85,1,1.25],maxFrames:900,keyTolPx:.05,points:400,smooth:.3,smoothFrames:4,smoothTolPx:.25,dense:{cols:40,rows:22,keep:700,minFrames:8,max:1500},slide:.01}),C=t=>Math.round(t*1e6)/1e6,A=(t,o)=>[t[0]-o[0],t[1]-o[1],t[2]-o[2]],U=(t,o)=>[t[0]+o[0],t[1]+o[1],t[2]+o[2]],_=(t,o)=>[t[0]*o,t[1]*o,t[2]*o],S=(t,o)=>t[0]*o[0]+t[1]*o[1]+t[2]*o[2],st=(t,o)=>[t[1]*o[2]-t[2]*o[1],t[2]*o[0]-t[0]*o[2],t[0]*o[1]-t[1]*o[0]],et=t=>{const o=Math.hypot(...t)||1;return _(t,1/o)},Z=(t,o)=>[S(t[0],o),S(t[1],o),S(t[2],o)],pt=t=>[0,1,2].map(o=>[t[0][o],t[1][o],t[2][o]]),po=(t,o)=>t.map(s=>[0,1,2].map(n=>s[0]*o[0][n]+s[1]*o[1][n]+s[2]*o[2][n]));function Se(t,o,s,n=bo(29)){const e=t;if(e.length<20)return null;const a=e.map(r=>Math.hypot(...A(r,s))).sort((r,l)=>r-l)[e.length>>1];for(const r of[.015,.03,.05]){const l=a*r;let i=null;for(let u=0;u<2e3;u++){const m=e[Math.floor(n()*e.length)],y=e[Math.floor(n()*e.length)],M=e[Math.floor(n()*e.length)];let d=st(A(y,m),A(M,m));const x=Math.hypot(...d);if(x<1e-9||(d=_(d,1/x),S(d,o)<0&&(d=_(d,-1)),S(d,o)<Math.cos(35*Math.PI/180)))continue;const g=-S(d,m);if(S(d,s)+g<=l)continue;let w=0;for(const b of e)Math.abs(S(d,b)+g)<l&&w++;(!i||w>i.k)&&(i={n:d,d:g,k:w})}if(!i||i.k<e.length*.2)continue;const c=e.filter(u=>Math.abs(S(i.n,u)+i.d)<l),f=_(c.reduce((u,m)=>U(u,m),[0,0,0]),1/c.length),h=[[0,0,0],[0,0,0],[0,0,0]];for(const u of c){const m=A(u,f);for(let y=0;y<3;y++)for(let M=0;M<3;M++)h[y][M]+=m[y]*m[M]}let p=Ft(h);return S(p,o)<0&&(p=_(p,-1)),{n:p,d:-S(p,f),count:c.length}}return null}function Ft(t){const o=t.map(e=>[...e]),s=[[1,0,0],[0,1,0],[0,0,1]];for(let e=0;e<30;e++){let a=0;for(let r=0;r<3;r++)for(let l=r+1;l<3;l++)a+=o[r][l]**2;if(a<1e-24)break;for(let r=0;r<3;r++)for(let l=r+1;l<3;l++){if(Math.abs(o[r][l])<1e-30)continue;const i=(o[l][l]-o[r][r])/(2*o[r][l]),c=Math.sign(i||1)/(Math.abs(i)+Math.sqrt(i*i+1)),f=1/Math.sqrt(c*c+1),h=c*f;for(let p=0;p<3;p++){const u=o[p][r],m=o[p][l];o[p][r]=f*u-h*m,o[p][l]=h*u+f*m}for(let p=0;p<3;p++){const u=o[r][p],m=o[l][p];o[r][p]=f*u-h*m,o[l][p]=h*u+f*m}for(let p=0;p<3;p++){const u=s[p][r],m=s[p][l];s[p][r]=f*u-h*m,s[p][l]=h*u+f*m}}}const n=[0,1,2].reduce((e,a)=>o[a][a]<o[e][e]?a:e,0);return et([s[0][n],s[1][n],s[2][n]])}function It(t,o,s,n){const e=new Map;t.poses.forEach((a,r)=>{if(!(!a||a.lost))for(const[l,i]of t.obs[r]){const c=t.points.get(l);if(!c)continue;const f=Z(a.R,A(c,a.C)),h=f[2]>-1e-6?50:Math.hypot(s+o*f[0]/-f[2]-i[0],n-o*f[1]/-f[2]-i[1]),p=e.get(l)??[0,0,0];p[0]+=h,p[1]++,p[2]=Math.max(p[2],h),e.set(l,p)}});for(const a of e.values())a[0]/=a[1];return e}function _t(t,o,s,n){const e=[...It(t,o,s,n).values()].map(r=>r[0]).sort((r,l)=>r-l),a=Math.floor(e.length*.8);return a>30?e.slice(0,a).reduce((r,l)=>r+l,0)/a:1/0}function mo(t,o,s,n){const{solved:e,keyframes:a}=No(t);for(let r=0;r<3;r++){const l=It(t,o,s,n),i=[...l.values()].map(h=>h[2]).sort((h,p)=>h-p),c=Math.max(1.2,2*(i[i.length>>1]??1));let f=0;for(const[h,p]of l)p[2]>c&&(t.points.delete(h),f++);if(!f)break;Qt(t.poses,t.points,t.obs,a,o,s,n,8),Oo(t,a,e,o,s,n)}}function No(t){const o=t.poses.map((n,e)=>n&&!n.lost?e:-1).filter(n=>n>=0),s=Math.max(1,Math.ceil(o.length/60));return{solved:o,keyframes:[t.pair[0],...o.filter((n,e)=>n!==t.pair[0]&&(e%s===0||e===o.length-1))]}}function Oo(t,o,s,n,e,a){const r=Math.hypot(...A(t.poses[t.pair[1]].C,t.poses[t.pair[0]].C))||1,l=new Set(o);for(const i of s){if(l.has(i))continue;const c=[];for(const[f,h]of t.obs[i])t.points.has(f)&&c.push({X:t.points.get(f),px:h});c.length>=10&&(t.poses[i]=ee(c,t.poses[i],n,e,a,r).pose)}}function Te(t,o,s,n){const{solved:e,keyframes:a}=No(t),r={poses:t.poses.map(c=>c&&{...c,R:c.R.map(f=>[...f]),C:[...c.C]}),points:new Map([...t.points].map(([c,f])=>[c,[...f]]))},l=_t(t,o,s,n),i=Qt(t.poses,t.points,t.obs,a,o,s,n,12,{focal:!0});return Math.abs(i/o-1)<1e-4?o:(Oo(t,a,e,i,s,n),Math.abs(i/o-1)<.15&&_t(t,i,s,n)<l?i:(t.poses=r.poses,t.points=r.points,o))}function Re(t,o,{w:s,h:n,mw:e,mh:a,focals:r=$.focals,focal:l=null,onProgress:i=null}={}){const c=s/2,f=n/2;let h=l,p=0;const u=l?1:r.length+9;if(!h){const P=new Map,E=Math.max(s,n)/s;let I=t;const V=j=>{if(j=Math.round(j*1e3)/1e3,!(j>.2&&j<3)||P.has(j))return;const z=ao(null,j*s,{obs:I,w:s,h:n});z.mode==="free"&&mo(z,j*s,c,f),P.set(j,{s:z,e:z.mode==="free"?_t(z,j*s,c,f):1/0}),i?.(++p/u)};let K=[];for(let j=Math.max(1,Math.round(t.length/25));;j=Math.max(1,j>>1)){I=t.filter((z,nt)=>nt%j===0),P.clear(),p=0;for(const z of r)V(z*E);if(K=[...P.entries()].filter(([,z])=>Number.isFinite(z.e)).sort((z,nt)=>z[0]-nt[0]),K.length||j===1)break}if(!K.length)return i?.(1),null;const B=K.reduce((j,z,nt)=>z[1].e<K[j][1].e?nt:j,0),k=K[B][1].s,mt=B>0?K[B-1][0]:K[B][0]*.8,dt=B<K.length-1?K[B+1][0]:K[B][0]*1.25,F=k.poses.map((j,z)=>j&&!j.lost?z:-1).filter(j=>j>=0),G=k.pair[0],H=j=>{const z={...k,poses:k.poses.map(Q=>Q&&{...Q,R:Q.R.map(at=>[...at]),C:[...Q.C]}),points:new Map([...k.points].map(([Q,at])=>[Q,[...at]]))};Qt(z.poses,z.points,z.obs,[G,...F.filter(Q=>Q!==G)],j*s,c,f,8),i?.(++p/u);let nt=0,L=0;for(const[Q,at]of It(z,j*s,c,f).values())nt+=Q*at,L+=at;return L?nt/L:1/0},Mt=(Math.sqrt(5)-1)/2;let W=mt,tt=dt,ft=tt-Mt*(tt-W),rt=W+Mt*(tt-W),ht=H(ft),gt=H(rt);for(let j=0;j<7;j++)ht<gt?(tt=rt,rt=ft,gt=ht,ft=tt-Mt*(tt-W),ht=H(ft)):(W=ft,ft=rt,ht=gt,rt=W+Mt*(tt-W),gt=H(rt));h=(W+tt)/2}const m=ao(null,h*s,{obs:t,w:s,h:n});if(i?.(1),m.mode!=="free")return null;let y=h*s;const M=m.poses[m.pair[0]].C,d=m.poses[m.pair[0]].R;if(mo(m,y,c,f),!l)for(let P=0;P<3;P++){const E=Te(m,y,c,f),I=Math.abs(E/y-1)<5e-4;if(y=E,I)break}const x=It(m,y,c,f),g=[...x.values()].map(P=>P[0]).sort((P,E)=>P-E),w=Math.max(1.5,3*(g[g.length>>1]??1)),b=[...x.entries()].filter(([P,E])=>m.points.has(P)&&E[0]<=w&&E[1]>=2),v=P=>t.flatMap((E,I)=>E.has(P)?[o[I]]:[]);let R=0,T=0;for(const[,P]of b)R+=P[0]*P[1],T+=P[1];const D=Z(pt(d),[0,1,0]),q=Se([...m.points.values()],D,M)??te(m.points,D,M)??oe(m.points,D,M),O={v:1,w:s,h:n,mw:e||s,mh:a||n,mode:"free",f:C(y),err:C(T?R/T:_t(m,y,c,f)),frames:m.poses.map((P,E)=>[C(o[E]),...xo(P.R).map(C),...P.C.map(C)]),floor:q?[...q.n.map(C),C(q.d)]:null},N=[];for(const[P]of b.sort((E,I)=>I[1][1]-E[1][1])){if(N.length>=$.points)break;const E=m.points.get(P),I=v(P);Xo(O,E,I)<=$.slide*s&&N.push([E.map(C),[C(I[0]),C(I.at(-1))]])}return{...O,points:N.map(P=>P[0]),seen:N.map(P=>P[1])}}function Xo(t,o,s){if(!s.length)return 1/0;const e=(s.length>24?s.filter((p,u)=>u%Math.ceil(s.length/24)===0||u===s.length-1):s).map(p=>et(A(o,lt(t,p).C)));let a=0;for(const p of[e[0],e.at(-1)])for(const u of e)a=Math.max(a,Math.acos(Math.min(1,S(p,u))));const r=lt(t,s[s.length>>1]).C,l=Math.hypot(...A(o,r)),i=U(o,_(et(A(o,r)),l*(.5/t.f)/Math.max(.001,Math.sin(a)))),c=t.frames,f=Math.max(1,Math.floor(c.length/40));let h=0;for(let p=0;p<c.length;p+=f){const u=ct(t,o,c[p][0]),m=ct(t,i,c[p][0]);u&&m&&(h=Math.max(h,Math.hypot(u[0]-m[0],u[1]-m[1])))}return h}function un(t,o,{mw:s,mh:n,focals:e=$.focals,focal:a=null,onProgress:r=null,dense:l=!0}={}){if(t.length<3)throw Error("FLAT");const i=t[0].w,c=t[0].h,f=wo(t,{anchor:!0,onProgress:r&&(u=>r(u*.35))}),h=Re(f,o,{w:i,h:c,mw:s,mh:n,focals:e,focal:a,onProgress:r&&(u=>r(.35+u*.57))});if(h){const u=l?Ie(h,t,o,r&&(m=>r(.92+m*.08))):h;return r?.(1),u}const p=Wo(t,(a??.7)*i);if(p.filter(u=>!u.lost).length<t.length*.5)throw Error("FLAT");return{v:1,w:i,h:c,mw:s||i,mh:n||c,mode:"tripod",frames:p.map((u,m)=>[C(o[m]),...u.q.map(C),C(u.f)])}}function Ie(t,o,s,n=null,e=$.dense){const a=wo(o,{anchor:!0,keep:e.keep,cols:e.cols,rows:e.rows,onProgress:n&&(u=>n(u*.8))}),r=new Map;a.forEach((u,m)=>{for(const[y,M]of u){let d=r.get(y);d||r.set(y,d=[]),d.push([s[m],M[0],M[1]])}});const l=[...r.values()].filter(u=>u.length>=e.minFrames),i=t.points??[],c=u=>i.some(m=>Math.abs(m[0]-u[0])+Math.abs(m[1]-u[1])+Math.abs(m[2]-u[2])<1e-6),f=t.seen??i.map(()=>[t.frames[0][0],t.frames.at(-1)[0]]),h=[...i],p=[...f];for(const u of l){if(h.length>=e.max)break;const m=Lo(t,u);!m||c(m)||Xo(t,m,u.map(y=>y[0]))>$.slide*t.w||(h.push(m.map(C)),p.push([C(u[0][0]),C(u.at(-1)[0])]))}return n?.(1),{...t,points:h,seen:p}}const jt=t=>!!t&&typeof t.ref=="string"&&!Array.isArray(t.frames);function _e(t){if(!t||t.v!==1||!["free","tripod"].includes(t.mode))throw Error("Invalid scene track");for(const n of["w","h","mw","mh"])if(!(Number.isFinite(t[n])&&t[n]>0&&t[n]<=2e4))throw Error("Invalid scene track");if(t.smooth!==void 0&&!(Number.isFinite(t.smooth)&&t.smooth>=0&&t.smooth<=1))throw Error("Invalid scene track");if(jt(t)){if(!/^[0-9a-f]{64}$/.test(t.ref))throw Error("Invalid scene track");return t}const o=t.mode==="free"?8:6;if(!Array.isArray(t.frames)||t.frames.length<2)throw Error("Invalid scene track");let s=-1/0;for(const n of t.frames){if(!Array.isArray(n)||n.length!==o||!n.every(Number.isFinite)||n[0]<s)throw Error("Invalid scene track");s=n[0]}if(t.mode==="free"&&(!(Number.isFinite(t.f)&&t.f>0)||t.floor!=null&&!(Array.isArray(t.floor)&&t.floor.length===4&&t.floor.every(Number.isFinite))||!Array.isArray(t.points)||t.points.length>5e3||!t.points.every(n=>Array.isArray(n)&&n.length===3&&n.every(Number.isFinite))||t.seen!=null&&!(Array.isArray(t.seen)&&t.seen.length===t.points.length&&t.seen.every(n=>Array.isArray(n)&&n.length===2&&n.every(Number.isFinite)&&n[0]<=n[1]))))throw Error("Invalid scene track");return t}function lt(t,o){const s=t.frames,n=s.length;let e=0,a=Math.max(0,n-2);for(;e<a;){const u=e+a+1>>1;s[u][0]<=o?e=u:a=u-1}const r=s[e],l=s[Math.min(n-1,e+1)],i=l[0]>r[0]?Math.max(0,Math.min(1,(o-r[0])/(l[0]-r[0]))):0;let c=r.slice(1,5),f=l.slice(1,5);oo(c,f)<0&&(f=f.map(u=>-u));const h=je(c,f,i),p=go(h);return t.mode==="tripod"?{R:p,C:[0,0,0],f:r[5]+(l[5]-r[5])*i}:{R:p,C:[0,1,2].map(u=>r[5+u]+(l[5+u]-r[5+u])*i),f:t.f}}const oo=(t,o)=>t[0]*o[0]+t[1]*o[1]+t[2]*o[2]+t[3]*o[3];function je(t,o,s){const n=Math.min(1,Math.max(-1,oo(t,o)));if(n>.9995){const i=t.map((f,h)=>f+(o[h]-f)*s),c=Math.hypot(...i);return i.map(f=>f/c)}const e=Math.acos(n),a=Math.sin(e),r=Math.sin((1-s)*e)/a,l=Math.sin(s*e)/a;return t.map((i,c)=>i*r+o[c]*l)}function De(t,o,s){const n=t.seen?.[o];if(!n)return!0;const e=t.frames.length>1?(t.frames.at(-1)[0]-t.frames[0][0])/(t.frames.length-1):0;return s>=n[0]-e-1e-4&&s<=n[1]+e+1e-4}const eo=(t,o)=>(t.points??[]).map((s,n)=>[s,n]).filter(([,s])=>De(t,s,o));function ct(t,o,s){const n=lt(t,s),e=Z(n.R,t.mode==="tripod"?o:A(o,n.C));return e[2]>-1e-6?null:[t.w/2+n.f*e[0]/-e[2],t.h/2-n.f*e[1]/-e[2]]}function zt(t,o,s,n){const e=lt(t,n),a=et([(o-t.w/2)/e.f,-(s-t.h/2)/e.f,-1]);return{o:e.C,d:Z(pt(e.R),a),pose:e}}function Fe(t,o,s,n,{radius:e=null}={}){const{o:a,d:r}=zt(t,o,s,n);if(t.mode==="tripod")return r.map(C);const l=e??Math.max(10,t.w*.04),i=[];for(const[h]of eo(t,n)){const p=ct(t,h,n);if(!p)continue;const u=Math.hypot(p[0]-o,p[1]-s),m=S(A(h,a),r);m>0&&u<=t.w*.15&&i.push({X:h,depth:m,dist:u,w:1/(1+u)})}i.sort((h,p)=>h.dist-p.dist);const c=i.filter((h,p)=>h.dist<=l||p<6);let f=null;if(c.length>=3&&(f=ze(c,a,r)),f===null&&c.length>=2){c.sort((u,m)=>u.depth-m.depth);const h=c.reduce((u,m)=>u+m.w,0);let p=0;for(const u of c)if(p+=u.w,p>=h/2){f=u.depth;break}}else if(f===null&&t.floor){const h=t.floor.slice(0,3),p=S(h,r);if(Math.abs(p)>1e-6){const u=-(S(h,a)+t.floor[3])/p;u>0&&(f=u)}}if(f===null){const h=(t.points??[]).map(p=>S(A(p,a),r)).filter(p=>p>0).sort((p,u)=>p-u);f=h.length?h[h.length>>1]:1}return U(a,_(r,f)).map(C)}function ze(t,o,s){const n=t.slice(0,20),e=n.map(d=>d.depth).sort((d,x)=>d-x),a=e[e.length>>1]*.015,r=n.reduce((d,x)=>d+x.w,0);let l=null,i=0;for(let d=0;d<n.length;d++)for(let x=d+1;x<n.length;x++)for(let g=x+1;g<n.length;g++){let w=st(A(n[x].X,n[d].X),A(n[g].X,n[d].X));const b=Math.hypot(...w);if(b<1e-12)continue;w=_(w,1/b);const v=n.filter(T=>Math.abs(S(w,A(T.X,n[d].X)))<a),R=v.reduce((T,D)=>T+D.w,0);R>i&&(l=v,i=R)}if(!l||l.length<3||i<r*.5)return null;const c=_(l.reduce((d,x)=>U(d,x.X),[0,0,0]),1/l.length),f=[[0,0,0],[0,0,0],[0,0,0]];for(const{X:d}of l){const x=A(d,c);for(let g=0;g<3;g++)for(let w=0;w<3;w++)f[g][w]+=x[g]*x[w]}if(!(f[0][0]+f[1][1]+f[2][2]>0))return null;const p=Ft(f),u=S(p,s);if(Math.abs(u)<.05)return null;const m=Math.min(...l.map(d=>d.depth)),y=Math.max(...l.map(d=>d.depth)),M=S(p,A(c,o))/u;return M>=m*.7&&M<=y*1.4?M:null}function qe(t,o,s,n){if(t.mode!=="free"||!t.floor)return null;const{o:e,d:a}=zt(t,o,s,n),r=t.floor.slice(0,3),l=S(r,a);if(Math.abs(l)<1e-6)return null;const i=-(S(r,e)+t.floor[3])/l;return i>0?U(e,_(a,i)):null}function pn(t,o){return t.mode!=="free"?[]:o.map(s=>Lo(t,s)).filter(Boolean)}function Lo(t,o){if(t.mode!=="free"||o.length<4)return null;const s=o.map(([l,i,c])=>zt(t,i,c,l));let n=0;for(const l of s)n=Math.max(n,Math.acos(Math.min(1,S(l.d,s[0].d))));if(n<.5*Math.PI/180)return null;const e=[[0,0,0],[0,0,0],[0,0,0]],a=[0,0,0];for(const{o:l,d:i}of s)for(let c=0;c<3;c++)for(let f=0;f<3;f++){const h=(c===f?1:0)-i[c]*i[f];e[c][f]+=h,a[c]+=h*l[f]}const r=Ke(e,a);return r&&o.every(([l,i,c])=>{const f=ct(t,r,l);return f&&Math.hypot(f[0]-i,f[1]-c)<1.5})?r:null}function Ke(t,o){const s=e=>e[0][0]*(e[1][1]*e[2][2]-e[1][2]*e[2][1])-e[0][1]*(e[1][0]*e[2][2]-e[1][2]*e[2][0])+e[0][2]*(e[1][0]*e[2][1]-e[1][1]*e[2][0]),n=s(t);return Math.abs(n)<1e-12?null:[0,1,2].map(e=>s(t.map((a,r)=>a.map((l,i)=>i===e?o[r]:l)))/n)}function mn(t,o,s,{extra:n=[]}={}){if(t.mode!=="free")return null;const e=(p,u)=>{let m=0;for(let y=0;y<4;y++){const[M,d]=o[y],[x,g]=o[(y+1)%4],w=(x-M)*(u-d)-(g-d)*(p-M);if(w){if(m&&Math.sign(w)!==m)return!1;m=Math.sign(w)}}return!0},a=lt(t,s),r=[...n,...eo(t,s).map(([p])=>p)].filter(p=>{const u=ct(t,p,s);return u&&e(u[0],u[1])}),l=o.map(([p,u])=>zt(t,p,u,s)),i=(p,u)=>{const m=[];for(const{o:y,d:M}of l){const d=S(p,M);if(Math.abs(d)<1e-9)return null;const x=-(S(p,y)+u)/d;if(!(x>0))return null;m.push(U(y,_(M,x)))}return m};let c=null,f="points";if(r.length>=4){const p=r.map(y=>Math.hypot(...A(y,a.C))).sort((y,M)=>y-M)[r.length>>1],u=p*.015;let m=null;for(let y=0;y<r.length;y++)for(let M=y+1;M<r.length;M++)for(let d=M+1;d<r.length&&d<M+12;d++){let x=st(A(r[M],r[y]),A(r[d],r[y]));const g=Math.hypot(...x);if(g<1e-12)continue;x=_(x,1/g);const w=-S(x,r[y]);let b=0;for(const v of r)Math.abs(S(x,v)+w)<u&&b++;(!m||b>m.c)&&(m={n:x,d:w,c:b})}if(m&&m.c>=4){const y=r.filter(g=>Math.abs(S(m.n,g)+m.d)<u),M=_(y.reduce((g,w)=>U(g,w),[0,0,0]),1/y.length),d=[[0,0,0],[0,0,0],[0,0,0]];for(const g of y){const w=A(g,M);for(let b=0;b<3;b++)for(let v=0;v<3;v++)d[b][v]+=w[b]*w[v]}let x=Ft(d);S(x,A(a.C,M))<0&&(x=_(x,-1)),c={n:x,d:-S(x,M),count:y.length}}}if(!c){const p=o.reduce((d,x)=>d+x[0],0)/4,u=o.reduce((d,x)=>d+x[1],0)/4,m=Fe(t,p,u,s),y=t.floor?qe(t,p,u,s):null,M=Math.hypot(...A(m,a.C));if(y&&Math.abs(Math.hypot(...A(y,a.C))-M)<M*.12)c={n:t.floor.slice(0,3),d:t.floor[3],count:0},f="ground";else{const d=t.floor?t.floor.slice(0,3):Z(pt(a.R),[0,1,0]),x=A(a.C,m);let g=A(x,_(d,S(x,d)));Math.hypot(...g)<1e-9&&(g=x),g=et(g),c={n:g,d:-S(g,m),count:0},f="upright"}}const h=i(c.n,c.d);return h?{corners:h.map(p=>p.map(C)),n:c.n.map(C),d:C(c.d),count:c.count,by:f}:null}function dn(t,o,s,n=null){const e=o.crop||{left:0,right:0,top:0,bottom:0},a=1-e.left-e.right,r=1-e.top-e.bottom,l=[];for(const i of n??t.frames.map(c=>c[0])){const c=s.map(f=>ct(t,f,i));c.some(f=>!f)||l.push([+i.toFixed(4),...c.flatMap(([f,h])=>[C((f/t.w-e.left)/a),C((h/t.h-e.top)/r)]),1])}return l}function Mn(t,o,s,n){const e=o.crop||{left:0,right:0,top:0,bottom:0};return[(e.left+s*(1-e.left-e.right))*t.w,(e.top+n*(1-e.top-e.bottom))*t.h]}function kt(t,o,s,n,e,a,r){const l=o.crop||{left:0,right:0,top:0,bottom:0},i=(s/t.w-l.left)/(1-l.left-l.right),c=(n/t.h-l.top)/(1-l.top-l.bottom),f=Qo(o,i,c,e,a,r,t.mw,t.mh);return[f.px,f.py]}function yn(t,o,s,n,e,a){const r=Math.max(t.start,o.start),l=Math.min(t.start+t.duration,o.start+o.duration);if(!(l>r))return{};const i=[],c=[],f=[r,...s.frames.map(p=>o.start+p[0]).filter(p=>p>r+1e-4&&p<l-1e-4),l];for(const p of f){const u=ct(s,n,p-o.start);if(!u)continue;const[m,y]=kt(s,o,u[0],u[1],p-o.start,e,a),M=+(p-t.start).toFixed(4);i.push({time:M,value:C((m-e/2)/e)}),c.push({time:M,value:C((y-a/2)/a)})}if(!i.length)return{};let h={...t,motionV:2};return delete h.posX,delete h.posY,h={...h,...yt(h,"x",Mo(i,$.keyTolPx/e))},h={...h,...yt(h,"y",Mo(c,$.keyTolPx/a))},{motionV:2,motionKeys:h.motionKeys,posX:void 0,posY:void 0}}const Mo=(t,o)=>to(t.map(s=>s.time),t.map(s=>s.value),o,1/0).map(s=>t[s]);function Ne(t,o,s){if(!(s>0)||o.length<3)return o;const n=s*$.smoothFrames,e=Math.ceil(n*2.5),a=t.mode==="free",r=$.smoothTolPx,l=a?(t.points??[]).filter((h,p)=>p%Math.max(1,Math.floor((t.points?.length??0)/80))===0):[-.4,0,.4].flatMap(h=>[-.25,0,.25].map(p=>[h,p,-1])),i=(h,p)=>{const u=Z(h.R,a?A(p,h.C):Z(pt(o[0].R),p));return u[2]>-1e-6?null:[h.f*u[0]/-u[2],-h.f*u[1]/-u[2]]},c=(h,p)=>{let u=0,m=0;for(const y of l){const M=i(h,y),d=i(p,y);M&&d&&(u=Math.max(u,Math.hypot(M[0]-d[0],M[1]-d[1])),m++)}return m?u:0},f=o.map(h=>xo(h.R));return o.map((h,p)=>{let u=0,m=[0,0,0],y=[0,0,0,0],M=0;for(let b=Math.max(0,p-e);b<=Math.min(o.length-1,p+e);b++){const v=Math.exp(-((b-p)**2)/(2*n*n)),R=oo(f[b],f[p])<0?f[b].map(T=>-T):f[b];u+=v,m=U(m,_(o[b].C,v)),y=y.map((T,D)=>T+R[D]*v),M+=o[b].f*v}const d=b=>{const v=f[p].map((T,D)=>T+(y[D]/u-T)*b),R=Math.hypot(...v);return{R:go(v.map(T=>T/R)),C:U(h.C,_(A(_(m,1/u),h.C),b)),f:h.f+(M/u-h.f)*b}};let x=1,g=d(1),w=c(h,g);for(let b=0;b<6&&w>r;b++)x*=Math.max(.3,r/w*.95),g=d(x),w=c(h,g);return w>r?h:g})}function Yo(t,o,s,n){const e=Ho(s,n),a=lt(t,t.frames[0][0]),r=t.mode==="free",l=r&&t.floor?t.floor.slice(0,3):Z(pt(a.R),[0,1,0]),i=Z(pt(a.R),[0,0,-1]),c=[0,1,2].map(E=>{const I=(t.points??[]).map(V=>V[E]).sort((V,K)=>V-K);return I.length?I[I.length>>1]:a.C[E]+(r?0:i[E])}),f=r&&t.floor?A(c,_(t.floor.slice(0,3),S(t.floor.slice(0,3),c)+t.floor[3])):c,h=et(A(i,_(l,S(i,l)))),u=[st(_(l,-1),h),_(l,-1),h],m=8*e/Math.max(1e-9,Math.hypot(...A(a.C,f))),y=E=>_(Z(u,A(E,f)),m),M=kt(t,o,t.w/2,t.h/2,0,s,n),d=kt(t,o,t.w/2+10,t.h/2,0,s,n),x=Math.hypot(d[0]-M[0],d[1]-M[1])/10,g=[[1,0,0],[0,-1,0],[0,0,-1]],w=t.frames.filter(E=>E[0]>=-1e-6&&E[0]<=o.duration+1e-6),b=[],v={},R=(E,I)=>{if(E===void 0)return I;for(;I-E>180;)I-=360;for(;I-E<-180;)I+=360;return I},T=Ne(t,w.map(E=>lt(t,E[0])),t.smooth??0);for(const[E,I]of w.entries()){const V=T[E],K=po(po(u,pt(V.R)),g),B=y(V.C),k=Jo(K),mt=R(v.pan,k.pan),dt=R(v.roll,k.roll);v.pan=mt,v.roll=dt,b.push({time:+(o.start+I[0]).toFixed(4),cx:C(B[0]/s),cy:C(B[1]/n),cz:C(B[2]/e),pan:C(mt),tilt:C(k.tilt),roll:C(dt),zoom:C(V.f*x/(5*e))})}const D=5*e*(b[0]?.zoom??1),q=$.keyTolPx/D*180/Math.PI,O={cx:$.keyTolPx/s,cy:$.keyTolPx/n,cz:$.keyTolPx/e,pan:q,tilt:q,roll:q,zoom:$.keyTolPx/D},N=new Set;for(const[E,I]of Object.entries(O))for(const V of to(b.map(K=>K.time),b.map(K=>K[E]),I,1/0))N.add(V);return{camera:{enabled:!0,motionV:2,motionKeys:b.filter((E,I)=>N.has(I))},toTimeline:y,fromTimeline:E=>U(Z(pt(u),_(E,1/m)),f),M:u,k:m,U:e,first:a}}function Oe(t,o,s,n,e,{size:a=null,fill:r=1}={}){if(t.mode!=="free")throw Error("TRIPOD");const{camera:l,toTimeline:i,k:c,U:f,first:h}=Yo(t,o,n,e),p=(a??Math.hypot(...A(h.C,s))*.2)*c*r,u=i(s),m=A(i(h.C),u),y=Math.atan2(m[0],-m[2])*180/Math.PI;return{camera:l,place:{is3D:!0,posX:C(u[0]/n),posY:C(u[1]/e),spatialDepth:C(-u[2]/f),modelDepth:C(-u[2]/f),modelGround:!0,modelRotation:{x:0,y:C(y),z:0},scale:C(Math.max(1e-6,p/(1.8*f)))},toTimeline:i}}function Xe(t,o,s,n,e){const a=[];for(const[r,l]of eo(t,n)){const i=ct(t,r,n);if(i){const c=Math.hypot(i[0]-o,i[1]-s);c<=e&&a.push([l,c])}}return a.sort((r,l)=>r[1]-l[1]).map(r=>r[0])}function gn(t,o,s){if(!o.length)return null;const n=lt(t,s),e=t.mode==="free"?n.C:[0,0,0],a=h=>_(h.reduce((p,u)=>U(p,u),[0,0,0]),1/h.length);let r=o.map(h=>t.mode==="free"?h:et(h)),l=a(r),i=r,c="points";if(t.mode==="free"&&r.length<3){const h=ct(t,l,s),p=Math.hypot(...A(l,e));if(h){const u=Xe(t,h[0],h[1],s,t.w*.12).map(d=>t.points[d]).filter(d=>Math.abs(Math.hypot(...A(d,e))/p-1)<.25).slice(0,14),m=p*.02,y=r[0];let M=null;for(let d=0;d<u.length;d++)for(let x=d+1;x<u.length;x++){let g=st(A(u[d],y),A(u[x],y));const w=Math.hypot(...g);if(w<1e-12)continue;g=_(g,1/w);const b=u.filter(v=>Math.abs(S(g,A(v,y)))<m);r.every(v=>Math.abs(S(g,A(v,y)))<m)&&(!M||b.length>M.length)&&(M=b)}M&&M.length>=3&&(i=[...r,...M],c="around")}}let f=null;if(t.mode==="free"&&i.length>=3){if(c==="points"&&i.length>=6){const u=Math.hypot(...A(l,e)),m=u*.01,y=bo(31);let M=null;for(let d=0;d<300;d++){const x=i[Math.floor(y()*i.length)],g=i[Math.floor(y()*i.length)],w=i[Math.floor(y()*i.length)];let b=st(A(g,x),A(w,x));const v=Math.hypot(...b);if(v<1e-12)continue;b=_(b,1/v);const R=i.filter(T=>Math.abs(S(b,A(T,x)))<m);(!M||R.length>M.length)&&(M=R)}M&&M.length>=Math.max(3,i.length*.5)&&(i=M)}const h=a(i),p=[[0,0,0],[0,0,0],[0,0,0]];for(const u of i){const m=A(u,h);for(let y=0;y<3;y++)for(let M=0;M<3;M++)p[y][M]+=m[y]*m[M]}f=Ft(p),c!=="around"&&(l=h)}return f||(f=et(A(e,l)),c="facing"),S(f,A(e,l))<0&&(f=_(f,-1)),{center:l.map(C),n:f.map(C),radius:C(Math.hypot(...A(l,e))*.08),by:c}}function bn(t,o=t.radius,s=36){const n=t.n,e=et(Math.abs(n[1])<.9?st(n,[0,1,0]):st(n,[1,0,0])),a=st(n,e);return Array.from({length:s},(r,l)=>{const i=l/s*2*Math.PI;return U(t.center,U(_(e,o*Math.cos(i)),_(a,o*Math.sin(i))))})}const Le=["x","y","depth","zoom","rot","tiltX","tiltY"];function xn(t,o,s,n,e,a,{width:r=null}={}){if(t.kind==="model"){const{camera:P,place:E}=Oe(o,s,n.center,e,a,{size:n.radius*2});if(!(E.spatialDepth>=so&&E.spatialDepth<=ro))throw Error("FAR");return{camera:P,patch:E}}const{camera:l,toTimeline:i,M:c,k:f,U:h,first:p}=Yo(o,s,e,a),u=i(n.center),m=et(Z(c,n.n)),y=i(o.mode==="free"?lt(o,o.frames[0][0]).C:p.C),M=-u[2]/h;if(!(M>=so&&M<=ro))throw Error("FAR");const d=P=>A(P,_(m,S(P,m)));let x=Math.abs(m[1])<.85?d([0,1,0]):d(A(y,u));Math.hypot(...x)<1e-6&&(x=d([0,1,0])),x=et(x);const g=_(m,-1),w=st(x,g),b=Math.asin(Math.max(-1,Math.min(1,g[1]))),v=Math.atan2(-g[0],g[2]),R=[Math.cos(v),0,Math.sin(v)],T=[Math.sin(b)*Math.sin(v),Math.cos(b),-Math.sin(b)*Math.cos(v)],D=Math.atan2(S(w,T),S(w,R)),q=P=>C(P*180/Math.PI);let O={...t,motionV:2};for(const P of Le)(O.motionKeys??[]).some(E=>E[P]!==void 0)&&(O={...O,motionKeys:Zo(O,P,[])});const N=(r??n.radius*6)*f;return{camera:l,patch:{is3D:!0,motionV:2,motionKeys:O.motionKeys??[],posX:C(u[0]/e),posY:C(u[1]/a),spatialDepth:C(M),scale:C(Math.max(1e-4,N/e)),rotation:q(D),tiltX:q(b),tiltY:q(v)}}}const $o=24e3,xt=new WeakMap,Ut=new Map;function Xt(t){let o=xt.get(t);if(!o){const s=JSON.stringify(t);o=s.length<=$o?Promise.resolve(null):re(s).then(n=>(Ut.set(n,t),n)),o.catch(()=>xt.delete(t)),xt.set(t,o)}return o}async function Ye(t){return Promise.all(t.map(async o=>{let s=o;const n=o.mask;if(n&&n.v===2&&!vo(n)){const r=await Xt(n);r&&(s={...s,mask:{v:2,mw:n.mw,mh:n.mh,ref:r}})}const e=o.planar;if(e&&!Yt(e)){const r=await Xt(e);r&&(s={...s,planar:{v:1,mw:e.mw,mh:e.mh,ref:r}})}const a=o.sceneTrack;if(a&&!jt(a)){const r=await Xt(a);r&&(s={...s,sceneTrack:{v:1,mode:a.mode,w:a.w,h:a.h,mw:a.mw,mh:a.mh,ref:r,...a.key?{key:a.key}:{}}})}return s}))}async function Lt(t){const o=Ut.get(t);if(o)return o;const s=JSON.parse(await ae(t));return Ut.set(t,s),s}async function $e(t){let o=0;return{clips:await Promise.all(t.map(async n=>{let e=n;const a=n.mask;if(vo(a))try{const i=ne(await Lt(a.ref),n.duration);if(i.v!==2||!("masks"in i))throw Error("Invalid mask");xt.set(i,Promise.resolve(a.ref)),e={...e,mask:i}}catch{o++}const r=n.planar;if(Yt(r))try{const i=se(await Lt(r.ref),n.duration);if(Yt(i))throw Error("Invalid planar track");xt.set(i,Promise.resolve(r.ref)),e={...e,planar:i}}catch{o++}const l=n.sceneTrack;if(jt(l))try{const i=_e(await Lt(l.ref));if(jt(i))throw Error("Invalid scene track");xt.set(i,Promise.resolve(l.ref)),e={...e,sceneTrack:{...i,...l.key?{key:l.key}:{}}}}catch{o++}return e})),missing:o}}const wn=Object.freeze(Object.defineProperty({__proto__:null,MASK_INLINE_MAX:$o,packMasks:Ye,unpackMasks:$e},Symbol.toStringTag,{value:"Module"}));export{Ae as A,Mn as B,to as C,an as D,lt as E,qe as F,Qe as G,Fe as H,De as I,Xe as J,fn as K,hn as L,we as M,ue as N,ie as O,xe as P,ce as Q,le as R,$ as S,ke as T,Oe as U,yn as V,Ue as W,wn as X,dn as a,un as b,gn as c,Yo as d,xn as e,kt as f,ct as g,bn as h,ln as i,rn as j,nn as k,We as l,sn as m,He as n,cn as o,Ye as p,en as q,on as r,mn as s,pn as t,$e as u,tn as v,Ze as w,Je as x,Ge as y,_o as z};
|
|
1
|
+
import{_ as Vo,g0 as Ct,ed as no,ee as vt,cd as Gt,kh as ko,ec as wt,d7 as yt,fw as it,fn as Bo,g1 as yo,fP as Uo,iM as Go,au as Et,F as ut,c0 as Jo,jf as go,mS as bo,mT as Qo,ij as so,ii as ro,jh as Zo,fr as Ho,jj as xo,mU as wo,mV as Wo,mW as ao,mX as te,mY as oe,ji as Jt,jk as ee,cC as vo,dD as Yt,kj as ne,mZ as se}from"./titleFrameBudget-BYRZAQPs.js";import{bW as re,bX as ae}from"./api-DUp403BK.js";const qt=.1,Kt=t=>Math.abs(t)>180?(t%360+540)%360-180:t;function Eo(t,o,s,n,e,a,r,l,i){const c=l-r,f=t==null?s-o:(s-t)/Math.max(1e-9,l-a)*c,h=n==null?s-o:(n-o)/Math.max(1e-9,i-r)*c,p=e*e,u=p*e;return(2*u-3*p+1)*o+(u-2*p+e)*f+(-2*u+3*p)*s+(u-p)*h}function Ao(t,o,s,n,e,a,r,l,i){const c=o+Kt(s-o),f=t==null?null:o+Kt(t-o),h=n==null?null:c+Kt(n-c);return Eo(f,o,c,h,e,a,r,l,i)}function ie(t,o,s=n=>n.time){if(globalThis.__clipooxLinearKeys)return!1;const n=(e,a)=>s(t[a])-s(t[e]);return!(n(o,o+1)>qt||o>0&&n(o-1,o)>qt||o+2<t.length&&n(o+1,o+2)>qt)}function Qt(t,o,s,n){let e=o>0,a=o+2<t.length;if(n!=null){const l=e?s(t[o-1]):null,i=s(t[o]),c=s(t[o+1]),f=a?s(t[o+2]):null;if(i<n-1e-9&&c>=n-1e-9)return{before:!1,after:!1};a&&c<n-1e-9&&f>=n-1e-9&&(a=!1),e&&i>=n-1e-9&&l<n-1e-9&&(e=!1)}return{before:e,after:a}}function Be(t,o,s,n=r=>r.pose,e=r=>r.time,a=null){const r=Qt(t,o,e,a),l=n(t[o]),i=n(t[o+1]),c=r.before?n(t[o-1]):null,f=r.after?n(t[o+2]):null,h=e(t[o]),p=e(t[o+1]),u=c?e(t[o-1]):h-(p-h),m=f?e(t[o+2]):p+(p-h),y={};for(const M of new Set([...Object.keys(l),...Object.keys(i)])){const d=l[M]??0,x=i[M]??0;if(typeof d!="number"||typeof x!="number")continue;const g=c&&typeof c[M]=="number"?c[M]:null,w=f&&typeof f[M]=="number"?f[M]:null;y[M]=Ao(g,d,x,w,s,u,h,p,m)}return y}function le(t,o,s,n=r=>r.position,e=r=>r.time,a=null){const r=Qt(t,o,e,a),l=n(t[o]),i=n(t[o+1]),c=r.before?n(t[o-1]):null,f=r.after?n(t[o+2]):null,h=e(t[o]),p=e(t[o+1]),u=c?e(t[o-1]):h-(p-h),m=f?e(t[o+2]):p+(p-h);return l.map((y,M)=>Eo(c?c[M]:null,y,i[M],f?f[M]:null,s,u,h,p,m))}function ce(t,o,s,n,e=r=>r.time,a=null){const r=Qt(t,o,e,a),l=n(t[o]),i=n(t[o+1]),c=r.before?n(t[o-1]):null,f=r.after?n(t[o+2]):null,h=e(t[o]),p=e(t[o+1]),u=c!=null?e(t[o-1]):h-(p-h),m=f!=null?e(t[o+2]):p+(p-h);return Ao(c,l,i,f,s,u,h,p,m)}const At=30,io=4,bt=Object.freeze({min:.25,max:6,default:3}),Rt=40,Po=300,Co=Object.freeze({position:.01,rotation:2}),So=80,To=Object.freeze(["here","above","explode","throw"]),$t=Object.freeze({bouncy:Object.freeze({restitution:.6,friction:.45}),normal:Object.freeze({restitution:.25,friction:.6}),heavy:Object.freeze({restitution:.04,friction:.9})}),fe=9.81;let Xt=null,Ro=null;const Io=()=>Ro;function jo(){return Xt??=(async()=>{const t=await Vo(()=>import("./rapier-DBjBuyhF.js"),[]),o=t.default??t,s=console.warn;console.warn=(...n)=>{String(n[0]).includes("deprecated parameters")||s(...n)};try{await o.init()}finally{console.warn=s}return Ro=o,o})().catch(t=>{throw Xt=null,t}),Xt}const ot=t=>typeof t=="number"&&Number.isFinite(t),Y=(t,o)=>Array.isArray(t)&&t.length===3&&t.every(ot)?[t[0],t[1],t[2]]:o,Q=Math.PI/180,St=t=>(t%360+540)%360-180,Tt=t=>Math.round(t*1e4)/1e4,Vt=t=>Math.round(t*100)/100;function Pt(t){const o=Math.cos(t[0]*Q/2),s=Math.cos(t[1]*Q/2),n=Math.cos(t[2]*Q/2),e=Math.sin(t[0]*Q/2),a=Math.sin(t[1]*Q/2),r=Math.sin(t[2]*Q/2);return[e*s*n+o*a*r,o*a*n-e*s*r,o*s*r+e*a*n,o*s*n-e*a*r]}function _o(t){const[o,s,n,e]=t,a=1-2*(s*s+n*n),r=2*(o*s-n*e),l=2*(o*n+s*e),i=1-2*(o*o+n*n),c=2*(s*n-o*e),f=2*(s*n+o*e),h=1-2*(o*o+s*s),p=Math.asin(Math.max(-1,Math.min(1,l)));return Math.abs(l)<.9999999?[Math.atan2(-c,h)/Q,p/Q,Math.atan2(-r,a)/Q]:[Math.atan2(f,i)/Q,p/Q,0]}const lo=(t,o)=>{const[s,n,e,a]=t,r=a*o[0]+n*o[2]-e*o[1],l=a*o[1]+e*o[0]-s*o[2],i=a*o[2]+s*o[1]-n*o[0],c=-s*o[0]-n*o[1]-e*o[2];return[r*a+c*-s+l*-e-i*-n,l*a+c*-n+i*-s-r*-e,i*a+c*-e+r*-n-l*-s]},Do=(t,o)=>2*Math.acos(Math.min(1,Math.abs(t[0]*o[0]+t[1]*o[1]+t[2]*o[2]+t[3]*o[3])))/Q;function Fo(t){let o=2166136261;for(const n of String(t))o=Math.imul(o^n.codePointAt(0),16777619);let s=o>>>0;return()=>{s=s+1831565813|0;let n=Math.imul(s^s>>>15,1|s);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const co=new Set(["box","sphere","cylinder","wall","platform"]),he=new Set(["person","fx","splat","set","floor"]);function ue(t){return t?t.locked?"Đối tượng đang khoá":t.hold?"Đồ đang cầm đi theo tay người cầm":t.kind==="person"||t.kind==="model"&&(t.skeleton==="native"||t.rig?.kind==="humanoid")?"Nhân vật không rơi như vật thể — dùng chuyển động":he.has(t.kind)?"Loại đối tượng này không rơi được":null:"Chưa chọn đối tượng"}function pe(t){const o=Y(t.scale,[1,1,1]);return t.kind==="sphere"&&Math.abs(o[0]-o[1])<1e-6&&Math.abs(o[1]-o[2])<1e-6||t.kind==="prop"&&t.prop?.kind==="ball"?"ball":t.kind==="cylinder"&&Math.abs(o[0]-o[2])<1e-6?"cylinder":"box"}function me(t){const o=Y(t.scale,[1,1,1]).map(Math.abs),s=Y(t.mirror,[1,1,1]),n=Y(t.origin,[0,0,0]);let e=[1,1,1],a=[0,.5,0];if(t.kind==="proxy"&&t.proxy?.dims)e=Y(t.proxy.dims,e),a=[0,e[1]/2,0];else if(t.kind==="prop"){const i=t.prop?.kind==="ball"?.12:.15;e=[2*i,2*i,2*i],a=[0,t.prop?.kind==="ball"?0:i,0]}else if(t.kind==="model"){const i=t.model?.height??2;e=[i*.6,i,i*.6],a=[0,i/2,0]}else co.has(t.kind)||(e=[.5,.5,.5],a=[0,.25,0]);const r=co.has(t.kind)?[(a[0]-n[0])*s[0],(a[1]-n[1])*s[1],(a[2]-n[2])*s[2]]:a,l=i=>[i[0]*(t.scale?.[0]??1),i[1]*(t.scale?.[1]??1),i[2]*(t.scale?.[2]??1)];return{half:[e[0]*o[0]/2,e[1]*o[1]/2,e[2]*o[2]/2],offset:l(r)}}function de(t,o){let s=0,n=t.length-1;for(;n-s>1;){const e=s+n>>1;t[e].time<=o?s=e:n=e}return s}function zo(t,o,s=null,n=null){const e=t[0],a=t[t.length-1];if(o<=e.time)return{position:e.position,rotation:e.rotation};if(o>=a.time)return{position:a.position,rotation:a.rotation};const r=de(t,o),l=t[r],i=t[r+1],c=(o-l.time)/(i.time-l.time),f=h=>l.rotation[h]+St(i.rotation[h]-l.rotation[h])*c;return ie(t,r,n>0?h=>h.time*n:void 0)?{position:le(t,r,c,h=>h.position,h=>h.time,s),rotation:[f(0),ce(t,r,c,h=>h.rotation[1],h=>h.time,s),f(2)]}:{position:[0,1,2].map(h=>l.position[h]+(i.position[h]-l.position[h])*c),rotation:[f(0),f(1),f(2)]}}function qo(t,{tolerance:o=Co,maxKeys:s=So,before:n=null,seam:e=null,duration:a=null}={}){const r=t.length;if(r<=2)return{keys:t.map(({time:f,position:h,rotation:p})=>({time:f,position:h,rotation:p})),error:{position:0,rotation:0}};const l=new Set([0,r-1]),i=()=>[...l].sort((f,h)=>f-h).map(f=>t[f]);let c={position:0,rotation:0};for(;;){const f=i(),h=n?[n,...f]:f;let p=-1,u=1;c={position:0,rotation:0};for(let m=1;m<r-1;m++){if(l.has(m))continue;const y=t[m],M=zo(h,y.time,e,a),d=Math.hypot(M.position[0]-y.position[0],M.position[1]-y.position[1],M.position[2]-y.position[2]),x=Do(Pt(M.rotation),y.quat);c={position:Math.max(c.position,d),rotation:Math.max(c.rotation,x)};const g=Math.max(d/o.position,x/o.rotation);g>u&&(u=g,p=m)}if(p<0||l.size>=s)break;l.add(p)}return{keys:i().map(({time:f,position:h,rotation:p})=>({time:f,position:h,rotation:p})),error:{position:Tt(c.position),rotation:Vt(c.rotation)}}}const Me=t=>ot(t)?{restitution:Math.max(0,Math.min(.95,t)),friction:.6}:$t[t]??$t.normal;async function ye(t){const o=Zt(await jo(),t),{duration:s,mode:n}=o,e=ot(t.start)?Math.max(0,t.start):0,a=ot(t.shotDuration)&&t.shotDuration>0?t.shotDuration:e+s,r={},l=e/a;for(const i of o.bodies){let c=null;const f=i.samples.map(m=>{let y=_o(m.q);if(c){const M=[y[0]+180,180-y[1],y[2]+180],d=x=>x.reduce((g,w,b)=>g+Math.abs(St(w-c[b])),0);d(M)<d(y)&&(y=M)}return y=y.map(M=>Vt(St(M)===-180?180:St(M))),c=y,{time:l+m.sec/a,position:m.pivot.map(Tt),rotation:y,quat:Pt(y)}}),h=t.before?.[i.id],{keys:p,error:u}=qo(f,{before:h&&ot(h.time)&&h.time<l?h:null,seam:ot(t.seam)?t.seam:null,duration:a});r[i.id]={keys:p,error:u,settledAt:i.settledAt,from:{position:i.position.map(Tt),rotation:i.rotation.map(Vt)},rest:f[f.length-1].position,restCentre:i.samples[i.samples.length-1].centre.map(Tt),restQuat:i.samples[i.samples.length-1].q}}return{tracks:r,settled:o.settled,seconds:s,mode:n}}function Zt(t,o){const s=!!o.planar,n=To.includes(o.mode)?o.mode:"here",e=Math.max(bt.min,Math.min(bt.max,ot(o.duration)?o.duration:bt.default)),a=ot(o.floor)?o.floor:0,r=Me(o.bounciness),l=Fo(`${o.seed??"drop"}|${n}`),i=m=>(l()*2-1)*m,c=(o.bodies||[]).filter(m=>m&&m.id!=null).map(m=>({id:String(m.id),shape:["ball","cylinder"].includes(m.shape)?m.shape:"box",position:Y(m.position,[0,0,0]),rotation:Y(m.rotation,[0,0,0]),half:Y(m.half,[.25,.25,.25]).map(y=>Math.max(.01,Math.abs(y))),offset:Y(m.offset,[0,0,0])})).sort((m,y)=>m.id<y.id?-1:m.id>y.id?1:0).slice(0,Rt);if(!c.length)throw new Error("no objects to drop");const f=m=>Math.hypot(...m.half);for(const m of c){m.q=Pt(m.rotation);const y=lo(m.q,m.offset);m.c=[m.position[0]+y[0],m.position[1]+y[1],m.position[2]+y[2]],m.v=[0,0,0],m.w=[0,0,0]}if(n==="above"){const m=ot(o.height)?Math.max(.3,Math.min(20,o.height)):2,y=Math.max(...c.map(d=>d.c[1]+f(d))),M=[];for(const d of[...c].sort((x,g)=>x.c[1]-g.c[1]||(x.id<g.id?-1:1))){d.q=Pt(s?[d.rotation[0],d.rotation[1],d.rotation[2]+i(35)]:[d.rotation[0]+i(35),d.rotation[1]+i(180),d.rotation[2]+i(35)]);let x=y+m+f(d);for(const g of M)Math.hypot(g.c[0]-d.c[0],g.c[2]-d.c[2])<f(g)+f(d)&&(x=Math.max(x,g.c[1]+f(g)+f(d)+.05));d.c=s?[d.c[0],x,d.c[2]]:[d.c[0]+i(.05),x,d.c[2]+i(.05)],M.push(d)}}if(n==="here")for(const m of c)m.w=[i(1.2),i(1.2),i(1.2)];const h=m=>s?[0,0,m[2]]:m,p=m=>s?[m[0],m[1],0]:m;if(n==="explode"){const m=Y(o.center,[0,1,2].map(M=>c.reduce((d,x)=>d+x.c[M],0)/c.length)),y=ot(o.strength)?Math.max(.5,Math.min(20,o.strength)):4;for(const M of c){let d=M.c[0]-m[0],x=s?0:M.c[2]-m[2],g=Math.hypot(d,x);if(g<.001){const b=l()*Math.PI*2;d=Math.cos(b),x=s?0:Math.sin(b),g=Math.hypot(d,x)||1}const w=y*(.75+l()*.5);M.v=[d/g*w,w*(.6+l()*.4),x/g*w],M.w=[i(7),i(7),i(7)]}}if(n==="throw"){const m=Y(o.velocity,[0,2,3]);for(const y of c)y.v=m.map(M=>M*(1+i(.08))),y.w=[i(5),i(5),i(5)]}const u=new t.World({x:0,y:-(ot(o.gravity)?o.gravity:fe),z:0});try{u.timestep=1/(At*io);for(const g of c)g.v=p(g.v),g.w=h(g.w);const m=(g,w)=>{const b=u.createRigidBody(t.RigidBodyDesc.fixed().setTranslation(g[0],g[1],g[2]));u.createCollider(t.ColliderDesc.cuboid(w[0],w[1],w[2]).setRestitution(r.restitution).setFriction(r.friction),b)};m([0,a-1,0],[1e3,1,1e3]);let y=0;for(const g of o.statics||[]){const w=Y(g?.min,null),b=Y(g?.max,null);if(!w||!b||y>=Po)continue;const v=[0,1,2].map(R=>(b[R]-w[R])/2);v.some(R=>!(R>.002))||b[1]<=a+.001||(m([0,1,2].map(R=>(w[R]+b[R])/2),v),y++)}for(const g of c){g.rb=u.createRigidBody(t.RigidBodyDesc.dynamic().setTranslation(g.c[0],g.c[1],g.c[2]).setRotation({x:g.q[0],y:g.q[1],z:g.q[2],w:g.q[3]}).setLinvel(g.v[0],g.v[1],g.v[2]).setAngvel({x:g.w[0],y:g.w[1],z:g.w[2]}).setLinearDamping(.05).setAngularDamping(g.shape==="box"?.2:1.2).setCcdEnabled(!0)),s&&(g.rb.setEnabledTranslations(!0,!0,!1,!1),g.rb.setEnabledRotations(!1,!1,!0,!1));const w=g.shape==="ball"?t.ColliderDesc.ball(Math.max(...g.half)):g.shape==="cylinder"?t.ColliderDesc.cylinder(g.half[1],Math.max(g.half[0],g.half[2])):t.ColliderDesc.cuboid(g.half[0],g.half[1],g.half[2]);u.createCollider(w.setRestitution(r.restitution).setFriction(r.friction).setDensity(400),g.rb),g.samples=[]}const M=Math.round(e*At);for(let g=0;g<=M;g++){if(g)for(let w=0;w<io;w++)u.step();for(const w of c){const b=w.rb.translation(),v=w.rb.rotation(),R=[v.x,v.y,v.z,v.w],T=lo(R,w.offset),D=w.rb.linvel(),q=w.rb.angvel();w.samples.push({sec:g/At,centre:[b.x,b.y,b.z],pivot:[b.x-T[0],b.y-T[1],b.z-T[2]],q:R,speed:Math.hypot(D.x,D.y,D.z)+Math.hypot(q.x,q.y,q.z)*f(w)})}}let d=!0;return{bodies:c.map(g=>{let w=null;for(let b=g.samples.length-1;b>=0&&g.samples[b].speed<.05;b--)w=g.samples[b].sec;return w==null&&(d=!1),{id:g.id,position:g.position,rotation:g.rotation,half:g.half,offset:g.offset,samples:g.samples,settledAt:w}}),settled:d,duration:e,mode:n}}finally{u.free()}}function ge(t,o,s,{scale:n={},newId:e,lifted:a=!1}={}){const r=e??(()=>globalThis.crypto.randomUUID());return{...t,shots:t.shots.map(l=>{if(l.id!==o)return l;const i={...l.objectKeys};for(const[c,f]of Object.entries(s)){if(!f.keys.length)continue;const h=f.keys[0].time,p=t.items.find(M=>M.id===c),u=Y(n[c],Y(p?.scale,[1,1,1])),m=(i[c]||[]).filter(M=>M.time<h-1e-6),y=1/(At*Math.max(1e-6,l.duration||1));a&&f.from&&m.length&&h-y>m[m.length-1].time+1e-6&&m.push({id:r(),time:h-y,position:[...f.from.position],rotation:[...f.from.rotation],scale:[...u]}),i[c]=[...m,...f.keys.map(M=>({id:r(),time:M.time,position:[...M.position],rotation:[...M.rotation],scale:[...u]}))]}return{...l,objectKeys:i}})}}const Ue=Object.freeze(Object.defineProperty({__proto__:null,BOUNCE_PRESETS:$t,DROP_MODES:To,DROP_SECONDS:bt,KEY_TOLERANCE:Co,MAX_KEYS_PER_BODY:So,MAX_PHYSICS_BODIES:Rt,MAX_PHYSICS_STATICS:Po,PHYSICS_FPS:At,applyDropKeys:ge,bakeDrop:ye,dropUnavailable:ue,eulerFromQuat:_o,fallbackShape:me,loadRapier:jo,quatAngle:Do,quatFromEuler:Pt,rapierReady:Io,sampleBakedKeys:zo,seededRandom:Fo,shapeKind:pe,simulateDrop:Zt,thinKeys:qo},Symbol.toStringTag,{value:"Module"})),Ko=["x","y","zoom","rot","opacity","depth"],N=t=>Math.round(t*1e4)/1e4,Dt=(t,o)=>Object.keys(it).filter(s=>(!o||o.includes(s))&&Bo(t,s));function Ge(t,{in:o=.33,out:s=.33}={},n){const e=ko([Math.max(0,Math.min(1,s)),0,Math.max(0,Math.min(1,1-o)),1]);let a={...t},r={};for(const l of Dt(t)){const i=wt(a,l),c=n?n.filter(h=>h.prop===l):i;if(!c.length)continue;const f=i.map((h,p)=>p<i.length-1&&c.some(u=>Math.abs(u.time-h.time)<1/120)?{...h,ease:e}:h);r={...r,...yt(a,l,f)},a={...a,...r}}return r}const Ht={tl:[0,0],t:[.5,0],tr:[1,0],l:[0,.5],c:[.5,.5],r:[1,.5],bl:[0,1],b:[.5,1],br:[1,1]},Je=Object.keys(Ht);function Qe(t,o,s,n,e,a){const[r,l]=Ht[s],i=o.angle*Math.PI/180,c=Math.abs(o.w*Math.cos(i))+Math.abs(o.h*Math.sin(i)),f=Math.abs(o.w*Math.sin(i))+Math.abs(o.h*Math.cos(i)),h=c/2+(e-c)*r,p=f/2+(a-f)*l,u=(h-o.cx)/e,m=(p-o.cy)/a,y=(d,x)=>Math.max(it[d].min,Math.min(it[d].max,x));let M=no(t,"x",N(y("x",vt(t,"x",n)+u)),n);return M={...M,...no({...t,...M},"y",N(y("y",vt(t,"y",n)+m)),n)},M}function Ze(t,o,s,n,e,a){const[r,l]=Ht[s],i=Gt(t,n,e,a).zoom||1;return Go(t,n,N((r-.5)*o.w/(e*i)),N((l-.5)*o.h/(a*i)),e,a)}function He(t,o,s,n="forward",e=1){let a=t.filter(i=>o.includes(i.id)).sort((i,c)=>c.track-i.track||i.start-c.start);if(a.length<2)return t;if(n==="reverse")a.reverse();else if(n==="center"){const i=(a.length-1)/2;a=[...a].sort((c,f)=>Math.abs(a.indexOf(c)-i)-Math.abs(a.indexOf(f)-i))}else if(n==="random"){let i=e>>>0||1;const c=()=>(i=Math.imul(i^i>>>15,2246822507)>>>0)/4294967295;a=a.map(f=>[c(),f]).sort((f,h)=>f[0]-h[0]).map(f=>f[1])}const r=Math.min(...a.map(i=>i.start)),l=new Map(a.map((i,c)=>[i.id,N(Math.max(0,r+c*s))]));return t.map(i=>l.has(i.id)?{...i,start:Math.min(l.get(i.id),600-i.duration)}:i)}function We(t,o){const s={};for(const e of Dt(t)){const a=wt(t,e).filter(r=>!o||o.some(l=>l.prop===e&&Math.abs(l.time-r.time)<.008333333333333333));a.length&&(s[e]=a)}const n=Math.min(...Object.values(s).flat().map(e=>e.time));return Object.keys(s).length?{props:Object.fromEntries(Object.entries(s).map(([e,a])=>[e,a.map(r=>({...r,time:N(r.time-n)}))]))}:null}function tn(t,o,s){let n={...t},e={};for(const[a,r]of Object.entries(o.props)){if(!it[a]||t.kind==="model"&&a==="rot"||t.kind!=="model"&&["rx","ry","rz"].includes(a))continue;const l=r.map(c=>({...c,time:N(s+c.time)})).filter(c=>c.time<=t.duration+1e-6),i=wt(n,a).filter(c=>!l.some(f=>Math.abs(f.time-c.time)<1/120));e={...e,...yt(n,a,[...i,...l].sort((c,f)=>c.time-f.time))},n={...n,...e}}return e}function on(t,o="elastic",{amount:s=.5,cycles:n=3,props:e}={}){let a={...t},r={};for(const l of Dt(t,e??Ko)){const i=wt(a,l);if(i.length<2)continue;const c=i.at(-2),f=i.at(-1),h=f.time-c.time,p=t.duration-f.time;if(h<=0||p<.1)continue;const u=f.value-c.value;if(Math.abs(u)<1e-6)continue;const m=Math.max(1,Math.min(6,Math.round(n))),y=Math.min(p/(m*2),Math.max(.06,h*.6)),M=[];for(let d=1;d<=m*2;d++){const x=s*Math.pow(.45,Math.ceil(d/2)-1),g=o==="bounce"?(d%2?-1:0)*Math.abs(u)*x*Math.sign(u):(d%2?1:-1)*u*x*.5,w=d===m*2?f.value:f.value+g,b=it[l].min,v=it[l].max;M.push({time:N(f.time+y*d),value:N(Math.max(b,Math.min(v,w))),ease:fo})}r={...r,...yt(a,l,[...i.map((d,x)=>x===i.length-1?{...d,ease:fo}:d),...M])},a={...a,...r}}return r}const fo=[.33,0,.67,1];function en(t,o="cycle",{props:s,maxKeys:n=60}={}){let e={...t},a={};for(const r of Dt(t,s)){const l=wt(e,r);if(l.length<2)continue;const i=l[0].time,c=l.at(-1).time,f=c-i;if(f<=1/30)continue;const h=[...l],p=l.at(-1).value-l[0].value;for(let u=1;h.length<n;u++){const m=o==="pingpong"&&u%2?[...l].reverse().map(M=>({...M,time:c-(M.time-i)})):l;let y=!1;for(const M of m.slice(1)){const d=N(M.time+f*u);if(d>t.duration+1e-6||h.length>=n)break;const x=o==="offset"?M.value+p*u:M.value,{min:g,max:w}=it[r];h.push({...M,time:d,value:N(Math.max(g,Math.min(w,x)))}),y=!0}if(!y)break}a={...a,...yt(e,r,h)},e={...e,...a}}return a}function nn(t,o){const s=Ct(t.shape)?t.shape:yo(t.shape);return s.items.map(n=>({...t,id:o(),label:`${t.label} · ${n.name}`.slice(0,60),shape:{...s,items:[{...n}]}}))}const be=["posX","posY","scale","rotation","anchorX","anchorY","parentId","opacity"];function sn(t){if(t.length<2)throw Error("Chọn ít nhất 2 layer Shape để gộp");const[o,...s]=t,n=a=>be.every(r=>(a[r]??null)===(o[r]??null))&&!a.motionKeys?.some(r=>Ko.some(l=>l in r));if(!t.every(n))throw Error("Chỉ gộp được các layer Shape cùng vị trí / tỉ lệ / góc xoay và không có key chuyển động");const e=[];for(const a of t){const r=Ct(a.shape)?a.shape:yo(a.shape);for(const l of r.items)e.push({...l,id:Uo(e)})}if(e.length>24)throw Error("Một layer Shape chứa tối đa 24 hình");return{...o,start:Math.min(...t.map(a=>a.start)),duration:Math.max(...t.map(a=>a.start+a.duration))-Math.min(...t.map(a=>a.start)),shape:{v:2,items:e}}}function rn(t,o,s,{fps:n=10,makeId:e,label:a}={}){const r=Math.min(o/1280,s/720),l=(y,M)=>[N(((y-o/2)/r+640-280)/.72),N(((M-s/2)/r+360)/.72)],i=Math.max(2,Math.min(255,Math.round(t.duration*n)+1)),c=[];for(let y=0;y<i;y++){const M=Gt(t,t.duration*y/(i-1),o,s);c.push(l(o/2+M.x*o,s/2+M.y*s))}const f=c.map(y=>y[0]),h=c.map(y=>y[1]),p=(Math.min(...f)+Math.max(...f))/2,u=(Math.min(...h)+Math.max(...h))/2,m={id:"s1",name:"Position Trace",type:"path",params:{pts:c.map(([y,M])=>[N(y-p),N(M-u)]),closed:!1},pos:[N(p),N(u)],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:"#c6f432",width:8,cap:"round",join:"round"}};return{id:e(),nodeId:"",kind:"image",url:"",label:a??`${t.label} · trace`.slice(0,60),track:t.track,start:t.start,duration:t.duration,volume:0,motionV:2,shape:{v:2,items:[m]}}}const Wt=/^#[0-9a-fA-F]{6}$/,xe=24,an=["#c6f432","#2bd4c9","#ffffff","#0d0f12","#ff5bd1"];function ln(t,o=16){const s=new Map,n=e=>{if(typeof e=="string"&&Wt.test(e)){const a=e.toLowerCase();s.set(a,(s.get(a)||0)+1)}};for(const e of t){e.title&&(n(e.title.color),n(e.title.accentColor));const a=e.shape;if(a)if(Ct(a))for(const r of a.items){n(r.fill.color);for(const l of r.fill.stops||[])n(l[0]);n(r.stroke?.color)}else for(const r of a.paths)n(r.stroke),n(r.fill)}return[...s.entries()].sort((e,a)=>a[1]-e[1]).slice(0,o).map(e=>e[0])}function cn(t,o,{stroke:s=!1,itemId:n}={}){if(!Wt.test(o))throw Error("Invalid colour");if(t.title)return{title:{...t.title,[s?"accentColor":"color"]:o}};if(!t.shape)throw Error("Chọn layer Shape hoặc chữ để áp màu");return Ct(t.shape)?{shape:{...t.shape,items:t.shape.items.map(e=>n&&e.id!==n?e:s?{...e,stroke:{...e.stroke??{width:8,cap:"round",join:"round"},color:o}}:{...e,fill:e.fill.type==="linear"||e.fill.type==="radial"?{...e.fill,stops:e.fill.stops.map((a,r)=>r===0?[o,a[1]]:a)}:{...e.fill,type:"color",color:o}})}}:{shape:{...t.shape,paths:t.shape.paths.map(e=>s||!e.fill?{...e,stroke:o}:{...e,fill:o})}}}function fn(t,o){if(!Array.isArray(o)||!o.length||o.length>xe||!o.every(e=>Wt.test(e)))throw Error("Invalid palette");const s=e=>o[e%o.length];if(t.title)return{title:{...t.title,color:s(0),...o.length>1?{accentColor:s(1)}:{}}};if(!t.shape)throw Error("Chọn layer Shape hoặc chữ để áp màu");if(!Ct(t.shape))return{shape:{...t.shape,paths:t.shape.paths.map((e,a)=>({...e,...e.fill?{fill:s(a)}:{},...e.stroke?{stroke:e.fill?e.stroke:s(a)}:{}}))}};let n=0;return{shape:{...t.shape,items:t.shape.items.map(e=>{const a=e.fill;return a.type==="linear"||a.type==="radial"?{...e,fill:{...a,stops:a.stops.map(r=>[s(n++),r[1]])}}:a.type==="color"?{...e,fill:{...a,color:s(n++)}}:e.stroke?{...e,stroke:{...e.stroke,color:s(n++)}}:e})}}}function we(t,o,s,n){const e=Gt(t,o,s,n),a=t.card?t.card.width/t.card.height:t.lottie?t.lottie.w/t.lottie.h:null,[r,l]=a&&Number.isFinite(a)&&a>0?a>s/n?[s,s/a]:[n*a,n]:[s,n];return{cx:s/2+e.x*s,cy:n/2+e.y*n,w:r*e.zoom,h:l*e.zoom,angle:e.rot}}const ve=3,kt=30,Ot=Object.freeze({xy:.002,rot:1.5}),Ee=.2,ho=t=>typeof t=="number"&&Number.isFinite(t),uo=t=>Math.round(t*1e4)/1e4;function Ae(t){return t?t.kind==="audio"?"Âm thanh không rơi được":t.adjust===!0?"Lớp điều chỉnh không có hình để rơi":t.parentId?"Lớp đang gắn vào lớp cha — bỏ gắn rồi thử lại":null:"Không tìm thấy lớp"}function to(t,o,s,n=kt){const e=t.length;if(e<=2)return[...Array(e).keys()];const a=[0,e-1];for(;;){a.sort((i,c)=>i-c);let r=-1,l=s;for(let i=0;i+1<a.length;i++){const c=a[i],f=a[i+1];for(let h=c+1;h<f;h++){const p=o[c]+(o[f]-o[c])*(t[h]-t[c])/(t[f]-t[c]),u=Math.abs(p-o[h]);u>l&&(l=u,r=h)}}if(r<0||a.length>=n)return a;a.push(r)}}function Pe(t,o,s){let n=0;for(let e=0;e+1<s.length;e++)for(let a=s[e]+1;a<s[e+1];a++){const r=s[e],l=s[e+1];n=Math.max(n,Math.abs(o[r]+(o[l]-o[r])*(t[a]-t[r])/(t[l]-t[r])-o[a]))}return n}function Ce(t,o,s){const n=[],e=r=>Math.floor((r+180)/360),a=(r,l)=>r-360*l;for(let r=0;r<s.length;r++){const l=s[r],i=o[l],c=e(i);if(r){const f=s[r-1],h=e(o[f]);if(h!==c){const p=c>h,u=(p?h+1:h)*360-180,m=(u-o[f])/(i-o[f]),y=Et(t[f]+(t[l]-t[f])*m),M=Math.max(n.at(-1).time+1/ut,Math.min(y,Et(t[l]-2/ut))),d=M+1/ut;d<t[l]-1e-6?n.push({time:M,value:p?180:-180,ease:"hold"},{time:d,value:p?-180:180}):n[n.length-1]={...n[n.length-1],ease:"hold"}}}n.push({time:t[l],value:Math.max(-180,Math.min(180,a(i,c)))})}return n}function hn(t,o,s={}){const n=s.R??Io();if(!n)throw Error("Physics engine not loaded yet — try again");const e=s.W??1280,a=s.H??720,r=ve/a,l=ho(s.at)?s.at:0,i=Math.max(1,Math.min(bt.max,ho(s.duration)?s.duration:bt.default)),c=s.mode==="above"?"above":"here",f=[...new Set(o)].map(b=>t.find(v=>v.id===b));if(!f.length)throw Error("physicsDrop needs clipIds");if(f.length>Rt)throw Error(`At most ${Rt} layers per drop`);for(const[b,v]of f.entries()){const R=Ae(v);if(R)throw Error(`${v?.label??o[b]}: ${R}`)}const h=f.map(b=>{const v=Et(l-b.start);if(v<0||v>b.duration-2/ut)throw Error(`${b.label??b.id}: the playhead is outside the layer`);const R=vt(b,"x",v),T=vt(b,"y",v),D=vt(b,"rot",v),q=s.rectOf?.(b)??we(b,v,e,a),O=[R*e*r,-T*a*r],X=[(q.cx-e/2)*r,-(q.cy-a/2)*r],P=D*Math.PI/180,E=[X[0]-O[0],X[1]-O[1]],I=[E[0]*Math.cos(P)-E[1]*Math.sin(P),E[0]*Math.sin(P)+E[1]*Math.cos(P)];return{id:b.id,position:[O[0],O[1],0],rotation:[0,0,-D],half:[Math.max(4,q.w)*r/2,Math.max(4,q.h)*r/2,Ee],offset:[I[0],I[1],0],local:v,x:R,y:T,rot:D}}),p=-a*r/2,u=a*r/2,m=e*r/2,y=s.walls?[{min:[-m-2,p,-2],max:[-m,u+20,2]},{min:[m,p,-2],max:[m+2,u+20,2]}]:[],M=b=>Math.hypot(b.half[0],b.half[1],b.half[2]),d=Math.max(...h.map(b=>b.position[1]+M(b))),x=Zt(n,{bodies:h,statics:y,floor:p,mode:c,bounciness:s.bounciness,duration:i,height:Math.max(.3,u-d+.05),seed:s.seed??[...o].sort().join(","),planar:!0}),g={},w=t.map(b=>({...b}));for(const b of h){const v=x.bodies.find(F=>F.id===b.id),R=w.findIndex(F=>F.id===b.id);let T=w[R];const D=[],q=[],O=[],X=[];let P=b.rot;for(const F of v.samples){const G=Et(b.local+F.sec);if(G>T.duration+1e-6)break;let H=-2*Math.atan2(F.q[2],F.q[3])*180/Math.PI;H+=360*Math.round((P-H)/360),P=H,D.push(G),q.push(F.pivot[0]/r/e),O.push(-F.pivot[1]/r/a),X.push(H)}const E=c==="above"&&b.local>=1/ut,I={},V={},K=Math.min(...X),k=Math.max(...X),B=k-K<360?Math.ceil((k-180)/360)*360:0,mt=B&&K-B>=-180?X.map(F=>F-B):X,dt=mt!==X&&b.local>=1/ut;for(const[F,G,H]of[["x",q,Ot.xy],["y",O,Ot.xy],["rot",mt,Ot.rot]]){const Mt=E||F==="rot"&&dt,W=wt(T,F).filter(L=>L.time<b.local-(Mt?1.5:.5)/ut),tt=Mt?[{time:Et(b.local-1/ut),value:F==="x"?b.x:F==="y"?b.y:b.rot,...F==="rot"&&dt?{ease:"hold"}:{}}]:[],ft=F==="rot"?G.reduce((L,J,at)=>L+(at&&Math.floor((J+180)/360)!==Math.floor((G[at-1]+180)/360)?1:0),0):0,rt=kt-W.length-tt.length-2*ft;if(rt<2)throw Error(`${T.label??T.id}: too many ${F} keys before the playhead (or too many turns) to add the drop`);const ht=to(D,G,H,rt),gt=it[F].min,_=it[F].max,z=F==="rot"?Ce(D,G,ht):ht.map(L=>({time:D[L],value:Math.max(gt,Math.min(_,G[L]))})),nt=[...W,...tt,...z].map(L=>({time:L.time,value:uo(L.value),...L.ease?{ease:L.ease}:{}}));T={...T,...yt(T,F,nt.slice(0,kt))},I[F]=z.length,V[F]=uo(Pe(D,G,ht))}w[R]=T,g[b.id]={keys:I,error:V,settledAt:v.settledAt==null?null:Math.round((l+v.settledAt)*1e3)/1e3}}return{clips:w,report:g,settled:x.settled}}const $=Object.freeze({work:480,focals:[.45,.55,.7,.85,1,1.25],maxFrames:900,keyTolPx:.05,points:400,smooth:.3,smoothFrames:4,smoothTolPx:.25,dense:{cols:40,rows:22,keep:700,minFrames:8,max:1500},slide:.01}),C=t=>Math.round(t*1e6)/1e6,A=(t,o)=>[t[0]-o[0],t[1]-o[1],t[2]-o[2]],U=(t,o)=>[t[0]+o[0],t[1]+o[1],t[2]+o[2]],j=(t,o)=>[t[0]*o,t[1]*o,t[2]*o],S=(t,o)=>t[0]*o[0]+t[1]*o[1]+t[2]*o[2],st=(t,o)=>[t[1]*o[2]-t[2]*o[1],t[2]*o[0]-t[0]*o[2],t[0]*o[1]-t[1]*o[0]],et=t=>{const o=Math.hypot(...t)||1;return j(t,1/o)},Z=(t,o)=>[S(t[0],o),S(t[1],o),S(t[2],o)],pt=t=>[0,1,2].map(o=>[t[0][o],t[1][o],t[2][o]]),po=(t,o)=>t.map(s=>[0,1,2].map(n=>s[0]*o[0][n]+s[1]*o[1][n]+s[2]*o[2][n]));function Se(t,o,s,n=bo(29)){const e=t;if(e.length<20)return null;const a=e.map(r=>Math.hypot(...A(r,s))).sort((r,l)=>r-l)[e.length>>1];for(const r of[.015,.03,.05]){const l=a*r;let i=null;for(let u=0;u<2e3;u++){const m=e[Math.floor(n()*e.length)],y=e[Math.floor(n()*e.length)],M=e[Math.floor(n()*e.length)];let d=st(A(y,m),A(M,m));const x=Math.hypot(...d);if(x<1e-9||(d=j(d,1/x),S(d,o)<0&&(d=j(d,-1)),S(d,o)<Math.cos(35*Math.PI/180)))continue;const g=-S(d,m);if(S(d,s)+g<=l)continue;let w=0;for(const b of e)Math.abs(S(d,b)+g)<l&&w++;(!i||w>i.k)&&(i={n:d,d:g,k:w})}if(!i||i.k<e.length*.2)continue;const c=e.filter(u=>Math.abs(S(i.n,u)+i.d)<l),f=j(c.reduce((u,m)=>U(u,m),[0,0,0]),1/c.length),h=[[0,0,0],[0,0,0],[0,0,0]];for(const u of c){const m=A(u,f);for(let y=0;y<3;y++)for(let M=0;M<3;M++)h[y][M]+=m[y]*m[M]}let p=Ft(h);return S(p,o)<0&&(p=j(p,-1)),{n:p,d:-S(p,f),count:c.length}}return null}function Ft(t){const o=t.map(e=>[...e]),s=[[1,0,0],[0,1,0],[0,0,1]];for(let e=0;e<30;e++){let a=0;for(let r=0;r<3;r++)for(let l=r+1;l<3;l++)a+=o[r][l]**2;if(a<1e-24)break;for(let r=0;r<3;r++)for(let l=r+1;l<3;l++){if(Math.abs(o[r][l])<1e-30)continue;const i=(o[l][l]-o[r][r])/(2*o[r][l]),c=Math.sign(i||1)/(Math.abs(i)+Math.sqrt(i*i+1)),f=1/Math.sqrt(c*c+1),h=c*f;for(let p=0;p<3;p++){const u=o[p][r],m=o[p][l];o[p][r]=f*u-h*m,o[p][l]=h*u+f*m}for(let p=0;p<3;p++){const u=o[r][p],m=o[l][p];o[r][p]=f*u-h*m,o[l][p]=h*u+f*m}for(let p=0;p<3;p++){const u=s[p][r],m=s[p][l];s[p][r]=f*u-h*m,s[p][l]=h*u+f*m}}}const n=[0,1,2].reduce((e,a)=>o[a][a]<o[e][e]?a:e,0);return et([s[0][n],s[1][n],s[2][n]])}function It(t,o,s,n){const e=new Map;t.poses.forEach((a,r)=>{if(!(!a||a.lost))for(const[l,i]of t.obs[r]){const c=t.points.get(l);if(!c)continue;const f=Z(a.R,A(c,a.C)),h=f[2]>-1e-6?50:Math.hypot(s+o*f[0]/-f[2]-i[0],n-o*f[1]/-f[2]-i[1]),p=e.get(l)??[0,0,0];p[0]+=h,p[1]++,p[2]=Math.max(p[2],h),e.set(l,p)}});for(const a of e.values())a[0]/=a[1];return e}function jt(t,o,s,n){const e=[...It(t,o,s,n).values()].map(r=>r[0]).sort((r,l)=>r-l),a=Math.floor(e.length*.8);return a>30?e.slice(0,a).reduce((r,l)=>r+l,0)/a:1/0}function mo(t,o,s,n){const{solved:e,keyframes:a}=Xo(t);for(let r=0;r<3;r++){const l=It(t,o,s,n),i=[...l.values()].map(h=>h[2]).sort((h,p)=>h-p),c=Math.max(1.2,2*(i[i.length>>1]??1));let f=0;for(const[h,p]of l)p[2]>c&&(t.points.delete(h),f++);if(!f)break;Jt(t.poses,t.points,t.obs,a,o,s,n,8),Oo(t,a,e,o,s,n)}}function Xo(t){const o=t.poses.map((n,e)=>n&&!n.lost?e:-1).filter(n=>n>=0),s=Math.max(1,Math.ceil(o.length/60));return{solved:o,keyframes:[t.pair[0],...o.filter((n,e)=>n!==t.pair[0]&&(e%s===0||e===o.length-1))]}}function Oo(t,o,s,n,e,a){const r=Math.hypot(...A(t.poses[t.pair[1]].C,t.poses[t.pair[0]].C))||1,l=new Set(o);for(const i of s){if(l.has(i))continue;const c=[];for(const[f,h]of t.obs[i])t.points.has(f)&&c.push({X:t.points.get(f),px:h});c.length>=10&&(t.poses[i]=ee(c,t.poses[i],n,e,a,r).pose)}}function Te(t,o,s,n){const{solved:e,keyframes:a}=Xo(t),r={poses:t.poses.map(c=>c&&{...c,R:c.R.map(f=>[...f]),C:[...c.C]}),points:new Map([...t.points].map(([c,f])=>[c,[...f]]))},l=jt(t,o,s,n),i=Jt(t.poses,t.points,t.obs,a,o,s,n,12,{focal:!0});return Math.abs(i/o-1)<1e-4?o:(Oo(t,a,e,i,s,n),Math.abs(i/o-1)<.15&&jt(t,i,s,n)<l?i:(t.poses=r.poses,t.points=r.points,o))}function Re(t,o,{w:s,h:n,mw:e,mh:a,focals:r=$.focals,focal:l=null,onProgress:i=null}={}){const c=s/2,f=n/2;let h=l,p=0;const u=l?1:r.length+9;if(!h){const P=new Map,E=Math.max(s,n)/s;let I=t;const V=_=>{if(_=Math.round(_*1e3)/1e3,!(_>.2&&_<3)||P.has(_))return;const z=ao(null,_*s,{obs:I,w:s,h:n});z.mode==="free"&&mo(z,_*s,c,f),P.set(_,{s:z,e:z.mode==="free"?jt(z,_*s,c,f):1/0}),i?.(++p/u)};let K=[];for(let _=Math.max(1,Math.round(t.length/25));;_=Math.max(1,_>>1)){I=t.filter((z,nt)=>nt%_===0),P.clear(),p=0;for(const z of r)V(z*E);if(K=[...P.entries()].filter(([,z])=>Number.isFinite(z.e)).sort((z,nt)=>z[0]-nt[0]),K.length||_===1)break}if(!K.length)return i?.(1),null;const k=K.reduce((_,z,nt)=>z[1].e<K[_][1].e?nt:_,0),B=K[k][1].s,mt=k>0?K[k-1][0]:K[k][0]*.8,dt=k<K.length-1?K[k+1][0]:K[k][0]*1.25,F=B.poses.map((_,z)=>_&&!_.lost?z:-1).filter(_=>_>=0),G=B.pair[0],H=_=>{const z={...B,poses:B.poses.map(J=>J&&{...J,R:J.R.map(at=>[...at]),C:[...J.C]}),points:new Map([...B.points].map(([J,at])=>[J,[...at]]))};Jt(z.poses,z.points,z.obs,[G,...F.filter(J=>J!==G)],_*s,c,f,8),i?.(++p/u);let nt=0,L=0;for(const[J,at]of It(z,_*s,c,f).values())nt+=J*at,L+=at;return L?nt/L:1/0},Mt=(Math.sqrt(5)-1)/2;let W=mt,tt=dt,ft=tt-Mt*(tt-W),rt=W+Mt*(tt-W),ht=H(ft),gt=H(rt);for(let _=0;_<7;_++)ht<gt?(tt=rt,rt=ft,gt=ht,ft=tt-Mt*(tt-W),ht=H(ft)):(W=ft,ft=rt,ht=gt,rt=W+Mt*(tt-W),gt=H(rt));h=(W+tt)/2}const m=ao(null,h*s,{obs:t,w:s,h:n});if(i?.(1),m.mode!=="free")return null;let y=h*s;const M=m.poses[m.pair[0]].C,d=m.poses[m.pair[0]].R;if(mo(m,y,c,f),!l)for(let P=0;P<3;P++){const E=Te(m,y,c,f),I=Math.abs(E/y-1)<5e-4;if(y=E,I)break}const x=It(m,y,c,f),g=[...x.values()].map(P=>P[0]).sort((P,E)=>P-E),w=Math.max(1.5,3*(g[g.length>>1]??1)),b=[...x.entries()].filter(([P,E])=>m.points.has(P)&&E[0]<=w&&E[1]>=2),v=P=>t.flatMap((E,I)=>E.has(P)?[o[I]]:[]);let R=0,T=0;for(const[,P]of b)R+=P[0]*P[1],T+=P[1];const D=Z(pt(d),[0,1,0]),q=Se([...m.points.values()],D,M)??te(m.points,D,M)??oe(m.points,D,M),O={v:1,w:s,h:n,mw:e||s,mh:a||n,mode:"free",f:C(y),err:C(T?R/T:jt(m,y,c,f)),frames:m.poses.map((P,E)=>[C(o[E]),...xo(P.R).map(C),...P.C.map(C)]),floor:q?[...q.n.map(C),C(q.d)]:null},X=[];for(const[P]of b.sort((E,I)=>I[1][1]-E[1][1])){if(X.length>=$.points)break;const E=m.points.get(P),I=v(P);No(O,E,I)<=$.slide*s&&X.push([E.map(C),[C(I[0]),C(I.at(-1))]])}return{...O,points:X.map(P=>P[0]),seen:X.map(P=>P[1])}}function No(t,o,s){if(!s.length)return 1/0;const e=(s.length>24?s.filter((p,u)=>u%Math.ceil(s.length/24)===0||u===s.length-1):s).map(p=>et(A(o,lt(t,p).C)));let a=0;for(const p of[e[0],e.at(-1)])for(const u of e)a=Math.max(a,Math.acos(Math.min(1,S(p,u))));const r=lt(t,s[s.length>>1]).C,l=Math.hypot(...A(o,r)),i=U(o,j(et(A(o,r)),l*(.5/t.f)/Math.max(.001,Math.sin(a)))),c=t.frames,f=Math.max(1,Math.floor(c.length/40));let h=0;for(let p=0;p<c.length;p+=f){const u=ct(t,o,c[p][0]),m=ct(t,i,c[p][0]);u&&m&&(h=Math.max(h,Math.hypot(u[0]-m[0],u[1]-m[1])))}return h}function un(t,o,{mw:s,mh:n,focals:e=$.focals,focal:a=null,onProgress:r=null,dense:l=!0}={}){if(t.length<3)throw Error("FLAT");const i=t[0].w,c=t[0].h,f=wo(t,{anchor:!0,onProgress:r&&(u=>r(u*.35))}),h=Re(f,o,{w:i,h:c,mw:s,mh:n,focals:e,focal:a,onProgress:r&&(u=>r(.35+u*.57))});if(h){const u=l?Ie(h,t,o,r&&(m=>r(.92+m*.08))):h;return r?.(1),u}const p=Wo(t,(a??.7)*i);if(p.filter(u=>!u.lost).length<t.length*.5)throw Error("FLAT");return{v:1,w:i,h:c,mw:s||i,mh:n||c,mode:"tripod",frames:p.map((u,m)=>[C(o[m]),...u.q.map(C),C(u.f)])}}function Ie(t,o,s,n=null,e=$.dense){const a=wo(o,{anchor:!0,keep:e.keep,cols:e.cols,rows:e.rows,onProgress:n&&(u=>n(u*.8))}),r=new Map;a.forEach((u,m)=>{for(const[y,M]of u){let d=r.get(y);d||r.set(y,d=[]),d.push([s[m],M[0],M[1]])}});const l=[...r.values()].filter(u=>u.length>=e.minFrames),i=t.points??[],c=u=>i.some(m=>Math.abs(m[0]-u[0])+Math.abs(m[1]-u[1])+Math.abs(m[2]-u[2])<1e-6),f=t.seen??i.map(()=>[t.frames[0][0],t.frames.at(-1)[0]]),h=[...i],p=[...f];for(const u of l){if(h.length>=e.max)break;const m=Lo(t,u);!m||c(m)||No(t,m,u.map(y=>y[0]))>$.slide*t.w||(h.push(m.map(C)),p.push([C(u[0][0]),C(u.at(-1)[0])]))}return n?.(1),{...t,points:h,seen:p}}const _t=t=>!!t&&typeof t.ref=="string"&&!Array.isArray(t.frames);function je(t){if(!t||t.v!==1||!["free","tripod"].includes(t.mode))throw Error("Invalid scene track");for(const n of["w","h","mw","mh"])if(!(Number.isFinite(t[n])&&t[n]>0&&t[n]<=2e4))throw Error("Invalid scene track");if(t.smooth!==void 0&&!(Number.isFinite(t.smooth)&&t.smooth>=0&&t.smooth<=1))throw Error("Invalid scene track");if(_t(t)){if(!/^[0-9a-f]{64}$/.test(t.ref))throw Error("Invalid scene track");return t}const o=t.mode==="free"?8:6;if(!Array.isArray(t.frames)||t.frames.length<2)throw Error("Invalid scene track");let s=-1/0;for(const n of t.frames){if(!Array.isArray(n)||n.length!==o||!n.every(Number.isFinite)||n[0]<s)throw Error("Invalid scene track");s=n[0]}if(t.mode==="free"&&(!(Number.isFinite(t.f)&&t.f>0)||t.floor!=null&&!(Array.isArray(t.floor)&&t.floor.length===4&&t.floor.every(Number.isFinite))||!Array.isArray(t.points)||t.points.length>5e3||!t.points.every(n=>Array.isArray(n)&&n.length===3&&n.every(Number.isFinite))||t.seen!=null&&!(Array.isArray(t.seen)&&t.seen.length===t.points.length&&t.seen.every(n=>Array.isArray(n)&&n.length===2&&n.every(Number.isFinite)&&n[0]<=n[1]))))throw Error("Invalid scene track");return t}function lt(t,o){const s=t.frames,n=s.length;let e=0,a=Math.max(0,n-2);for(;e<a;){const u=e+a+1>>1;s[u][0]<=o?e=u:a=u-1}const r=s[e],l=s[Math.min(n-1,e+1)],i=l[0]>r[0]?Math.max(0,Math.min(1,(o-r[0])/(l[0]-r[0]))):0;let c=r.slice(1,5),f=l.slice(1,5);oo(c,f)<0&&(f=f.map(u=>-u));const h=_e(c,f,i),p=go(h);return t.mode==="tripod"?{R:p,C:[0,0,0],f:r[5]+(l[5]-r[5])*i}:{R:p,C:[0,1,2].map(u=>r[5+u]+(l[5+u]-r[5+u])*i),f:t.f}}const oo=(t,o)=>t[0]*o[0]+t[1]*o[1]+t[2]*o[2]+t[3]*o[3];function _e(t,o,s){const n=Math.min(1,Math.max(-1,oo(t,o)));if(n>.9995){const i=t.map((f,h)=>f+(o[h]-f)*s),c=Math.hypot(...i);return i.map(f=>f/c)}const e=Math.acos(n),a=Math.sin(e),r=Math.sin((1-s)*e)/a,l=Math.sin(s*e)/a;return t.map((i,c)=>i*r+o[c]*l)}function De(t,o,s){const n=t.seen?.[o];if(!n)return!0;const e=t.frames.length>1?(t.frames.at(-1)[0]-t.frames[0][0])/(t.frames.length-1):0;return s>=n[0]-e-1e-4&&s<=n[1]+e+1e-4}const eo=(t,o)=>(t.points??[]).map((s,n)=>[s,n]).filter(([,s])=>De(t,s,o));function ct(t,o,s){const n=lt(t,s),e=Z(n.R,t.mode==="tripod"?o:A(o,n.C));return e[2]>-1e-6?null:[t.w/2+n.f*e[0]/-e[2],t.h/2-n.f*e[1]/-e[2]]}function zt(t,o,s,n){const e=lt(t,n),a=et([(o-t.w/2)/e.f,-(s-t.h/2)/e.f,-1]);return{o:e.C,d:Z(pt(e.R),a),pose:e}}function Fe(t,o,s,n,{radius:e=null}={}){const{o:a,d:r}=zt(t,o,s,n);if(t.mode==="tripod")return r.map(C);const l=e??Math.max(10,t.w*.04),i=[];for(const[h]of eo(t,n)){const p=ct(t,h,n);if(!p)continue;const u=Math.hypot(p[0]-o,p[1]-s),m=S(A(h,a),r);m>0&&u<=t.w*.15&&i.push({X:h,depth:m,dist:u,w:1/(1+u)})}i.sort((h,p)=>h.dist-p.dist);const c=i.filter((h,p)=>h.dist<=l||p<6);let f=null;if(c.length>=3&&(f=ze(c,a,r)),f===null&&c.length>=2){c.sort((u,m)=>u.depth-m.depth);const h=c.reduce((u,m)=>u+m.w,0);let p=0;for(const u of c)if(p+=u.w,p>=h/2){f=u.depth;break}}else if(f===null&&t.floor){const h=t.floor.slice(0,3),p=S(h,r);if(Math.abs(p)>1e-6){const u=-(S(h,a)+t.floor[3])/p;u>0&&(f=u)}}if(f===null){const h=(t.points??[]).map(p=>S(A(p,a),r)).filter(p=>p>0).sort((p,u)=>p-u);f=h.length?h[h.length>>1]:1}return U(a,j(r,f)).map(C)}function ze(t,o,s){const n=t.slice(0,20),e=n.map(d=>d.depth).sort((d,x)=>d-x),a=e[e.length>>1]*.015,r=n.reduce((d,x)=>d+x.w,0);let l=null,i=0;for(let d=0;d<n.length;d++)for(let x=d+1;x<n.length;x++)for(let g=x+1;g<n.length;g++){let w=st(A(n[x].X,n[d].X),A(n[g].X,n[d].X));const b=Math.hypot(...w);if(b<1e-12)continue;w=j(w,1/b);const v=n.filter(T=>Math.abs(S(w,A(T.X,n[d].X)))<a),R=v.reduce((T,D)=>T+D.w,0);R>i&&(l=v,i=R)}if(!l||l.length<3||i<r*.5)return null;const c=j(l.reduce((d,x)=>U(d,x.X),[0,0,0]),1/l.length),f=[[0,0,0],[0,0,0],[0,0,0]];for(const{X:d}of l){const x=A(d,c);for(let g=0;g<3;g++)for(let w=0;w<3;w++)f[g][w]+=x[g]*x[w]}if(!(f[0][0]+f[1][1]+f[2][2]>0))return null;const p=Ft(f),u=S(p,s);if(Math.abs(u)<.05)return null;const m=Math.min(...l.map(d=>d.depth)),y=Math.max(...l.map(d=>d.depth)),M=S(p,A(c,o))/u;return M>=m*.7&&M<=y*1.4?M:null}function qe(t,o,s,n){if(t.mode!=="free"||!t.floor)return null;const{o:e,d:a}=zt(t,o,s,n),r=t.floor.slice(0,3),l=S(r,a);if(Math.abs(l)<1e-6)return null;const i=-(S(r,e)+t.floor[3])/l;return i>0?U(e,j(a,i)):null}function pn(t,o){return t.mode!=="free"?[]:o.map(s=>Lo(t,s)).filter(Boolean)}function Lo(t,o){if(t.mode!=="free"||o.length<4)return null;const s=o.map(([l,i,c])=>zt(t,i,c,l));let n=0;for(const l of s)n=Math.max(n,Math.acos(Math.min(1,S(l.d,s[0].d))));if(n<.5*Math.PI/180)return null;const e=[[0,0,0],[0,0,0],[0,0,0]],a=[0,0,0];for(const{o:l,d:i}of s)for(let c=0;c<3;c++)for(let f=0;f<3;f++){const h=(c===f?1:0)-i[c]*i[f];e[c][f]+=h,a[c]+=h*l[f]}const r=Ke(e,a);return r&&o.every(([l,i,c])=>{const f=ct(t,r,l);return f&&Math.hypot(f[0]-i,f[1]-c)<1.5})?r:null}function Ke(t,o){const s=e=>e[0][0]*(e[1][1]*e[2][2]-e[1][2]*e[2][1])-e[0][1]*(e[1][0]*e[2][2]-e[1][2]*e[2][0])+e[0][2]*(e[1][0]*e[2][1]-e[1][1]*e[2][0]),n=s(t);return Math.abs(n)<1e-12?null:[0,1,2].map(e=>s(t.map((a,r)=>a.map((l,i)=>i===e?o[r]:l)))/n)}function mn(t,o,s,{extra:n=[]}={}){if(t.mode!=="free")return null;const e=(p,u)=>{let m=0;for(let y=0;y<4;y++){const[M,d]=o[y],[x,g]=o[(y+1)%4],w=(x-M)*(u-d)-(g-d)*(p-M);if(w){if(m&&Math.sign(w)!==m)return!1;m=Math.sign(w)}}return!0},a=lt(t,s),r=[...n,...eo(t,s).map(([p])=>p)].filter(p=>{const u=ct(t,p,s);return u&&e(u[0],u[1])}),l=o.map(([p,u])=>zt(t,p,u,s)),i=(p,u)=>{const m=[];for(const{o:y,d:M}of l){const d=S(p,M);if(Math.abs(d)<1e-9)return null;const x=-(S(p,y)+u)/d;if(!(x>0))return null;m.push(U(y,j(M,x)))}return m};let c=null,f="points";if(r.length>=4){const p=r.map(y=>Math.hypot(...A(y,a.C))).sort((y,M)=>y-M)[r.length>>1],u=p*.015;let m=null;for(let y=0;y<r.length;y++)for(let M=y+1;M<r.length;M++)for(let d=M+1;d<r.length&&d<M+12;d++){let x=st(A(r[M],r[y]),A(r[d],r[y]));const g=Math.hypot(...x);if(g<1e-12)continue;x=j(x,1/g);const w=-S(x,r[y]);let b=0;for(const v of r)Math.abs(S(x,v)+w)<u&&b++;(!m||b>m.c)&&(m={n:x,d:w,c:b})}if(m&&m.c>=4){const y=r.filter(g=>Math.abs(S(m.n,g)+m.d)<u),M=j(y.reduce((g,w)=>U(g,w),[0,0,0]),1/y.length),d=[[0,0,0],[0,0,0],[0,0,0]];for(const g of y){const w=A(g,M);for(let b=0;b<3;b++)for(let v=0;v<3;v++)d[b][v]+=w[b]*w[v]}let x=Ft(d);S(x,A(a.C,M))<0&&(x=j(x,-1)),c={n:x,d:-S(x,M),count:y.length}}}if(!c){const p=o.reduce((d,x)=>d+x[0],0)/4,u=o.reduce((d,x)=>d+x[1],0)/4,m=Fe(t,p,u,s),y=t.floor?qe(t,p,u,s):null,M=Math.hypot(...A(m,a.C));if(y&&Math.abs(Math.hypot(...A(y,a.C))-M)<M*.12)c={n:t.floor.slice(0,3),d:t.floor[3],count:0},f="ground";else{const d=t.floor?t.floor.slice(0,3):Z(pt(a.R),[0,1,0]),x=A(a.C,m);let g=A(x,j(d,S(x,d)));Math.hypot(...g)<1e-9&&(g=x),g=et(g),c={n:g,d:-S(g,m),count:0},f="upright"}}const h=i(c.n,c.d);return h?{corners:h.map(p=>p.map(C)),n:c.n.map(C),d:C(c.d),count:c.count,by:f}:null}function dn(t,o,s,n=null){const e=o.crop||{left:0,right:0,top:0,bottom:0},a=1-e.left-e.right,r=1-e.top-e.bottom,l=[];for(const i of n??t.frames.map(c=>c[0])){const c=s.map(f=>ct(t,f,i));c.some(f=>!f)||l.push([+i.toFixed(4),...c.flatMap(([f,h])=>[C((f/t.w-e.left)/a),C((h/t.h-e.top)/r)]),1])}return l}function Mn(t,o,s,n){const e=o.crop||{left:0,right:0,top:0,bottom:0};return[(e.left+s*(1-e.left-e.right))*t.w,(e.top+n*(1-e.top-e.bottom))*t.h]}function Bt(t,o,s,n,e,a,r){const l=o.crop||{left:0,right:0,top:0,bottom:0},i=(s/t.w-l.left)/(1-l.left-l.right),c=(n/t.h-l.top)/(1-l.top-l.bottom),f=Jo(o,i,c,e,a,r,t.mw,t.mh);return[f.px,f.py]}function yn(t,o,s,n,e,a){const r=Math.max(t.start,o.start),l=Math.min(t.start+t.duration,o.start+o.duration);if(!(l>r))return{};const i=[],c=[],f=[r,...s.frames.map(p=>o.start+p[0]).filter(p=>p>r+1e-4&&p<l-1e-4),l];for(const p of f){const u=ct(s,n,p-o.start);if(!u)continue;const[m,y]=Bt(s,o,u[0],u[1],p-o.start,e,a),M=+(p-t.start).toFixed(4);i.push({time:M,value:C((m-e/2)/e)}),c.push({time:M,value:C((y-a/2)/a)})}if(!i.length)return{};let h={...t,motionV:2};return delete h.posX,delete h.posY,h={...h,...yt(h,"x",Mo(i,$.keyTolPx/e))},h={...h,...yt(h,"y",Mo(c,$.keyTolPx/a))},{motionV:2,motionKeys:h.motionKeys,posX:void 0,posY:void 0}}const Mo=(t,o)=>to(t.map(s=>s.time),t.map(s=>s.value),o,1/0).map(s=>t[s]);function Xe(t,o,s){if(!(s>0)||o.length<3)return o;const n=s*$.smoothFrames,e=Math.ceil(n*2.5),a=t.mode==="free",r=$.smoothTolPx,l=a?(t.points??[]).filter((h,p)=>p%Math.max(1,Math.floor((t.points?.length??0)/80))===0):[-.4,0,.4].flatMap(h=>[-.25,0,.25].map(p=>[h,p,-1])),i=(h,p)=>{const u=Z(h.R,a?A(p,h.C):Z(pt(o[0].R),p));return u[2]>-1e-6?null:[h.f*u[0]/-u[2],-h.f*u[1]/-u[2]]},c=(h,p)=>{let u=0,m=0;for(const y of l){const M=i(h,y),d=i(p,y);M&&d&&(u=Math.max(u,Math.hypot(M[0]-d[0],M[1]-d[1])),m++)}return m?u:0},f=o.map(h=>xo(h.R));return o.map((h,p)=>{let u=0,m=[0,0,0],y=[0,0,0,0],M=0;for(let b=Math.max(0,p-e);b<=Math.min(o.length-1,p+e);b++){const v=Math.exp(-((b-p)**2)/(2*n*n)),R=oo(f[b],f[p])<0?f[b].map(T=>-T):f[b];u+=v,m=U(m,j(o[b].C,v)),y=y.map((T,D)=>T+R[D]*v),M+=o[b].f*v}const d=b=>{const v=f[p].map((T,D)=>T+(y[D]/u-T)*b),R=Math.hypot(...v);return{R:go(v.map(T=>T/R)),C:U(h.C,j(A(j(m,1/u),h.C),b)),f:h.f+(M/u-h.f)*b}};let x=1,g=d(1),w=c(h,g);for(let b=0;b<6&&w>r;b++)x*=Math.max(.3,r/w*.95),g=d(x),w=c(h,g);return w>r?h:g})}function Yo(t,o,s,n){const e=Ho(s,n),a=lt(t,t.frames[0][0]),r=t.mode==="free",l=r&&t.floor?t.floor.slice(0,3):Z(pt(a.R),[0,1,0]),i=Z(pt(a.R),[0,0,-1]),c=[0,1,2].map(E=>{const I=(t.points??[]).map(V=>V[E]).sort((V,K)=>V-K);return I.length?I[I.length>>1]:a.C[E]+(r?0:i[E])}),f=r&&t.floor?A(c,j(t.floor.slice(0,3),S(t.floor.slice(0,3),c)+t.floor[3])):c,h=et(A(i,j(l,S(i,l)))),u=[st(j(l,-1),h),j(l,-1),h],m=8*e/Math.max(1e-9,Math.hypot(...A(a.C,f))),y=E=>j(Z(u,A(E,f)),m),M=Bt(t,o,t.w/2,t.h/2,0,s,n),d=Bt(t,o,t.w/2+10,t.h/2,0,s,n),x=Math.hypot(d[0]-M[0],d[1]-M[1])/10,g=[[1,0,0],[0,-1,0],[0,0,-1]],w=t.frames.filter(E=>E[0]>=-1e-6&&E[0]<=o.duration+1e-6),b=[],v={},R=(E,I)=>{if(E===void 0)return I;for(;I-E>180;)I-=360;for(;I-E<-180;)I+=360;return I},T=Xe(t,w.map(E=>lt(t,E[0])),t.smooth??0);for(const[E,I]of w.entries()){const V=T[E],K=po(po(u,pt(V.R)),g),k=y(V.C),B=Qo(K),mt=R(v.pan,B.pan),dt=R(v.roll,B.roll);v.pan=mt,v.roll=dt,b.push({time:+(o.start+I[0]).toFixed(4),cx:C(k[0]/s),cy:C(k[1]/n),cz:C(k[2]/e),pan:C(mt),tilt:C(B.tilt),roll:C(dt),zoom:C(V.f*x/(5*e))})}const D=5*e*(b[0]?.zoom??1),q=$.keyTolPx/D*180/Math.PI,O={cx:$.keyTolPx/s,cy:$.keyTolPx/n,cz:$.keyTolPx/e,pan:q,tilt:q,roll:q,zoom:$.keyTolPx/D},X=new Set;for(const[E,I]of Object.entries(O))for(const V of to(b.map(K=>K.time),b.map(K=>K[E]),I,1/0))X.add(V);return{camera:{enabled:!0,motionV:2,motionKeys:b.filter((E,I)=>X.has(I))},toTimeline:y,fromTimeline:E=>U(Z(pt(u),j(E,1/m)),f),M:u,k:m,U:e,first:a}}function Oe(t,o,s,n,e,{size:a=null,fill:r=1}={}){if(t.mode!=="free")throw Error("TRIPOD");const{camera:l,toTimeline:i,k:c,U:f,first:h}=Yo(t,o,n,e),p=(a??Math.hypot(...A(h.C,s))*.2)*c*r,u=i(s),m=A(i(h.C),u),y=Math.atan2(m[0],-m[2])*180/Math.PI;return{camera:l,place:{is3D:!0,posX:C(u[0]/n),posY:C(u[1]/e),spatialDepth:C(-u[2]/f),modelDepth:C(-u[2]/f),modelGround:!0,modelRotation:{x:0,y:C(y),z:0},scale:C(Math.max(1e-6,p/(1.8*f)))},toTimeline:i}}function Ne(t,o,s,n,e){const a=[];for(const[r,l]of eo(t,n)){const i=ct(t,r,n);if(i){const c=Math.hypot(i[0]-o,i[1]-s);c<=e&&a.push([l,c])}}return a.sort((r,l)=>r[1]-l[1]).map(r=>r[0])}function gn(t,o,s){if(!o.length)return null;const n=lt(t,s),e=t.mode==="free"?n.C:[0,0,0],a=h=>j(h.reduce((p,u)=>U(p,u),[0,0,0]),1/h.length);let r=o.map(h=>t.mode==="free"?h:et(h)),l=a(r),i=r,c="points";if(t.mode==="free"&&r.length<3){const h=ct(t,l,s),p=Math.hypot(...A(l,e));if(h){const u=Ne(t,h[0],h[1],s,t.w*.12).map(d=>t.points[d]).filter(d=>Math.abs(Math.hypot(...A(d,e))/p-1)<.25).slice(0,14),m=p*.02,y=r[0];let M=null;for(let d=0;d<u.length;d++)for(let x=d+1;x<u.length;x++){let g=st(A(u[d],y),A(u[x],y));const w=Math.hypot(...g);if(w<1e-12)continue;g=j(g,1/w);const b=u.filter(v=>Math.abs(S(g,A(v,y)))<m);r.every(v=>Math.abs(S(g,A(v,y)))<m)&&(!M||b.length>M.length)&&(M=b)}M&&M.length>=3&&(i=[...r,...M],c="around")}}let f=null;if(t.mode==="free"&&i.length>=3){if(c==="points"&&i.length>=6){const u=Math.hypot(...A(l,e)),m=u*.01,y=bo(31);let M=null;for(let d=0;d<300;d++){const x=i[Math.floor(y()*i.length)],g=i[Math.floor(y()*i.length)],w=i[Math.floor(y()*i.length)];let b=st(A(g,x),A(w,x));const v=Math.hypot(...b);if(v<1e-12)continue;b=j(b,1/v);const R=i.filter(T=>Math.abs(S(b,A(T,x)))<m);(!M||R.length>M.length)&&(M=R)}M&&M.length>=Math.max(3,i.length*.5)&&(i=M)}const h=a(i),p=[[0,0,0],[0,0,0],[0,0,0]];for(const u of i){const m=A(u,h);for(let y=0;y<3;y++)for(let M=0;M<3;M++)p[y][M]+=m[y]*m[M]}f=Ft(p),c!=="around"&&(l=h)}return f||(f=et(A(e,l)),c="facing"),S(f,A(e,l))<0&&(f=j(f,-1)),{center:l.map(C),n:f.map(C),radius:C(Math.hypot(...A(l,e))*.08),by:c}}function bn(t,o=t.radius,s=36){const n=t.n,e=et(Math.abs(n[1])<.9?st(n,[0,1,0]):st(n,[1,0,0])),a=st(n,e);return Array.from({length:s},(r,l)=>{const i=l/s*2*Math.PI;return U(t.center,U(j(e,o*Math.cos(i)),j(a,o*Math.sin(i))))})}const Le=["x","y","depth","zoom","rot","tiltX","tiltY"];function xn(t,o,s,n,e,a,{width:r=null}={}){if(t.kind==="model"){const{camera:P,place:E}=Oe(o,s,n.center,e,a,{size:n.radius*2});if(!(E.spatialDepth>=so&&E.spatialDepth<=ro))throw Error("FAR");return{camera:P,patch:E}}const{camera:l,toTimeline:i,M:c,k:f,U:h,first:p}=Yo(o,s,e,a),u=i(n.center),m=et(Z(c,n.n)),y=i(o.mode==="free"?lt(o,o.frames[0][0]).C:p.C),M=-u[2]/h;if(!(M>=so&&M<=ro))throw Error("FAR");const d=P=>A(P,j(m,S(P,m)));let x=Math.abs(m[1])<.85?d([0,1,0]):d(A(y,u));Math.hypot(...x)<1e-6&&(x=d([0,1,0])),x=et(x);const g=j(m,-1),w=st(x,g),b=Math.asin(Math.max(-1,Math.min(1,g[1]))),v=Math.atan2(-g[0],g[2]),R=[Math.cos(v),0,Math.sin(v)],T=[Math.sin(b)*Math.sin(v),Math.cos(b),-Math.sin(b)*Math.cos(v)],D=Math.atan2(S(w,T),S(w,R)),q=P=>C(P*180/Math.PI);let O={...t,motionV:2};for(const P of Le)(O.motionKeys??[]).some(E=>E[P]!==void 0)&&(O={...O,motionKeys:Zo(O,P,[])});const X=(r??n.radius*6)*f;return{camera:l,patch:{is3D:!0,motionV:2,motionKeys:O.motionKeys??[],posX:C(u[0]/e),posY:C(u[1]/a),spatialDepth:C(M),scale:C(Math.max(1e-4,X/e)),rotation:q(D),tiltX:q(b),tiltY:q(v)}}}const $o=24e3,xt=new WeakMap,Ut=new Map;function Nt(t){let o=xt.get(t);if(!o){const s=JSON.stringify(t);o=s.length<=$o?Promise.resolve(null):re(s).then(n=>(Ut.set(n,t),n)),o.catch(()=>xt.delete(t)),xt.set(t,o)}return o}async function Ye(t){return Promise.all(t.map(async o=>{let s=o;const n=o.mask;if(n&&n.v===2&&!vo(n)){const r=await Nt(n);r&&(s={...s,mask:{v:2,mw:n.mw,mh:n.mh,ref:r}})}const e=o.planar;if(e&&!Yt(e)){const r=await Nt(e);r&&(s={...s,planar:{v:1,mw:e.mw,mh:e.mh,ref:r}})}const a=o.sceneTrack;if(a&&!_t(a)){const r=await Nt(a);r&&(s={...s,sceneTrack:{v:1,mode:a.mode,w:a.w,h:a.h,mw:a.mw,mh:a.mh,ref:r,...a.key?{key:a.key}:{}}})}return s}))}async function Lt(t){const o=Ut.get(t);if(o)return o;const s=JSON.parse(await ae(t));return Ut.set(t,s),s}async function $e(t){let o=0;return{clips:await Promise.all(t.map(async n=>{let e=n;const a=n.mask;if(vo(a))try{const i=ne(await Lt(a.ref),n.duration);if(i.v!==2||!("masks"in i))throw Error("Invalid mask");xt.set(i,Promise.resolve(a.ref)),e={...e,mask:i}}catch{o++}const r=n.planar;if(Yt(r))try{const i=se(await Lt(r.ref),n.duration);if(Yt(i))throw Error("Invalid planar track");xt.set(i,Promise.resolve(r.ref)),e={...e,planar:i}}catch{o++}const l=n.sceneTrack;if(_t(l))try{const i=je(await Lt(l.ref));if(_t(i))throw Error("Invalid scene track");xt.set(i,Promise.resolve(l.ref)),e={...e,sceneTrack:{...i,...l.key?{key:l.key}:{}}}}catch{o++}return e})),missing:o}}const wn=Object.freeze(Object.defineProperty({__proto__:null,MASK_INLINE_MAX:$o,packMasks:Ye,unpackMasks:$e},Symbol.toStringTag,{value:"Module"}));export{Ae as A,Mn as B,to as C,an as D,lt as E,qe as F,Je as G,Fe as H,De as I,Ne as J,fn as K,hn as L,we as M,ue as N,ie as O,xe as P,ce as Q,le as R,$ as S,Be as T,Oe as U,yn as V,Ue as W,wn as X,dn as a,un as b,gn as c,Yo as d,xn as e,Bt as f,ct as g,bn as h,ln as i,rn as j,nn as k,We as l,sn as m,He as n,cn as o,Ye as p,en as q,on as r,mn as s,pn as t,$e as u,tn as v,Ze as w,Qe as x,Ge as y,jo as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{cM as T,fp as N,c0 as g,eQ as z,eR as A,nk as j,c1 as U,nl as $,Z as I,cz as D,a7 as M,cX as v,nm as q,nn as B,no as J,np as K,_ as Q,nq as V}from"./titleFrameBudget-BYRZAQPs.js";import{c0 as X}from"./api-DUp403BK.js";import{u as b}from"./store-75tQUvPT.js";const Z=/^null:[^\s]{1,80}$/,E=t=>typeof t=="string"&&Z.test(t),G=t=>E(t)?t.slice(5):null,k=(t,e)=>[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]],x=t=>{const e=t[0]*t[3]-t[1]*t[2]||1e-12;return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[3]*t[4])/e,(t[1]*t[4]-t[0]*t[5])/e]};function S(t,e,a,o){const s=N(t,Math.max(0,Math.min(t.duration,e)),a,o),n=s.rot*Math.PI/180,r=Math.cos(n)*s.zoom,l=Math.sin(n)*s.zoom;return[r,l,-l,r,a/2+s.x*a,o/2+s.y*o]}function Y(t,e,a,o,s,n){const r=g(t,0,0,e,a,o,s,n),l=g(t,1,0,e,a,o,s,n),i=g(t,0,1,e,a,o,s,n);return[l.px-r.px,l.py-r.py,i.px-r.px,i.py-r.py,r.px,r.py]}function W(t,e){return e.map(a=>{const o=t[0]*a[0]+t[2]*a[1]+t[4],s=t[1]*a[0]+t[3]*a[1]+t[5];return a.length!==6?[o,s]:[o,s,t[0]*a[2]+t[2]*a[3],t[1]*a[2]+t[3]*a[3],t[0]*a[4]+t[2]*a[5],t[1]*a[4]+t[3]*a[5]]})}function H(t,e,a,o,s,n=1280,r=720,{inverse:l=!1}={}){const i=e.find(p=>p.id===a&&T(p));if(!i)return null;const f=t.mask?.mw??1920,u=t.mask?.mh??1080,c=p=>t.start+p-i.start,m=k(S(i,c(s),n,r),x(S(i,c(o),n,r))),d=Y(t,s,n,r,f,u),P=k(x(d),k(m,d));return l?x(P):P}function tt(t,e,a=1280,o=720){return(t.mask?.v===1?[t.mask]:t.mask?.masks||[]).some(n=>E(n.follow))?{...t.roto||{},followNull:(n,r,l,i,f=!1)=>{const u=H(t,e,G(n),r,l,a,o,{inverse:f});return u?W(u,i):i}}:t.roto}J(X);K(async t=>{const[e,a]=await Promise.all([Q(()=>import("./opentype.module-DcKU8U04.js"),[]),fetch(V[t]).then(o=>{if(!o.ok)throw Error(`Font ${o.status}`);return o.arrayBuffer()})]);return e.default.parse(a)});const F=t=>[...new Set(D(t.mask).flatMap(e=>e.shape?.kind==="text"?[e.shape.weight??800]:[]))],w=new Map;function R(t){const e=F(t).filter(a=>!q(a));for(const a of e){const o=w.get(a);o!==void 0&&(o===1/0||Date.now()<o)||(w.set(a,1/0),v(a).then(()=>{w.delete(a),b.setState(s=>({clips:s.clips.slice()}))},()=>w.set(a,Date.now()+1e4)))}return!e.length}let C=null,h=null,L=null;const y=(t,e,a)=>{const o=t??document.createElement("canvas");return(o.width!==e||o.height!==a)&&Object.assign(o,{width:e,height:a}),o},_=t=>!!(t.mask||t.person);function et(t,e){return t.mask&&!R(t)?-1:t.person?I(t.person)?e:-1:t.key||D(t.mask).some(a=>a.keys.length>1||a.follow||a.mblur||a.in!==void 0||a.out!==void 0)?e:0}function at(t){const e=t.person,a=I(e);return a||M(e).then(()=>b.setState(o=>({clips:o.clips.slice()}))).catch(()=>{}),a}function ot(t,e,a,o,s,n,r){const l=at(e);if(!l){r||(t.save(),t.globalCompositeOperation="source-over",t.fillStyle="#fff",t.fillRect(0,0,o,s),t.restore());return}const i=B(l,e.person,e,a,o,s),f=L=y(L,o,s),u=f.getContext("2d"),c=u.createImageData(o,s);for(let m=0,d=0;m<i.length;m++,d+=4)n?(c.data[d]=c.data[d+1]=c.data[d+2]=255,c.data[d+3]=i[m]):(c.data[d]=c.data[d+1]=c.data[d+2]=i[m],c.data[d+3]=255);u.putImageData(c,0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.filter="none",t.globalCompositeOperation=r?n?"destination-in":"multiply":"copy",t.drawImage(f,0,0),t.restore()}function O(t,e,a,o=!1,s){const{w:n,h:r}=j(t),l=a?y(a,n,r):C=y(C,n,r),i=l.getContext("2d");if(t.mask){R(t);const f=b.getState(),{width:u,height:c}=U(f.timelineFormat);$(i,t.mask,e,n,r,tt(t,s??f.clips,u,c),o)}return t.person&&ot(i,t,e,n,r,o,!!t.mask),l}function nt(t,e,a,o,s,n,r){const l=O(t,r,void 0,!0),i=l.width,f=l.height;h=y(h,i*2,f*2);const u=h.getContext("2d");return u.globalCompositeOperation="copy",u.drawImage(e,a,o,s,n,0,0,i*2,f*2),u.globalCompositeOperation="destination-in",u.imageSmoothingEnabled=!0,u.drawImage(l,0,0,i*2,f*2),u.globalCompositeOperation="source-over",h}const st=t=>z(A(t.filter(e=>!e.disabled))).filter(e=>e._virtual&&(e.mask||e.person));async function rt(t){for(const e of t.filter(_))e.person&&await M(e.person),await Promise.all(F(e).map(v))}async function it(t,e,a,o){const s=document.createElement("canvas");for(const n of t.filter(_)){if(a.wants&&!a.wants("matteFrames",n.id))continue;n.person&&await M(n.person),await Promise.all(F(n).map(v));const r=Math.ceil(n.duration*e);let l="";for(let i=0;i<r;i++){if(o?.aborted)throw new DOMException("Export cancelled","AbortError");if(a.wants&&!a.wants("matteFrames",n.id,i)){await a.push("matteFrames",n.id,"");continue}O(n,i/e,s,!1,t);const f=s.toDataURL("image/webp",.9),u=f.slice(f.indexOf(",")+1);if(u===l){await a.push("matteFrames",n.id,"=");continue}l=u,await a.push("matteFrames",n.id,u),i%10===0&&await new Promise(c=>setTimeout(c,0))}}}const ct=Object.freeze(Object.defineProperty({__proto__:null,maskedCopies:st,maskedSource:nt,matteActive:_,matteCanvas:O,matteStamp:et,prepareMattes:rt,renderMatteFrames:it},Symbol.toStringTag,{value:"Module"}));export{_ as a,nt as b,et as c,tt as m,ct as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,b as u,h}from"./api-
|
|
1
|
+
import{t as e,b as u,h}from"./api-DUp403BK.js";import{i7 as p}from"./remote-Dva2qg58.js";import"./titleFrameBudget-BYRZAQPs.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";const a=new Map,s=n=>new Promise(r=>setTimeout(r,n));async function m(n){for(let r=0;r<100;r++){const o=await u(n,!0).catch(t=>{if(r<20)return null;throw t});if(!o){await s(3e3);continue}if(o.status==="failed")throw Error(e("Vẽ Animation không thành công (credit đã được hoàn)"));if(o.status==="succeeded"&&o.output?.url){const t=await fetch(o.output.url);if(!t.ok)throw Error(e("Không tải được hình vẽ"));return t.json()}await s(3e3)}throw Error(e("Vẽ Animation quá lâu — thử lại sau"))}async function V(n,r){const o=r.params??{},t=o.job;if(!t)throw Error(e("Thiếu job Vẽ Animation"));let i=a.get(t);i||(i=m(t),a.set(t,i),i.catch(()=>a.delete(t)));const c=await i;return p(c,o,{en:h()==="en"})}export{V as runRotoscope};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./titleFrameBudget-
|
|
1
|
+
import"./titleFrameBudget-BYRZAQPs.js";import{R as _}from"./api-DUp403BK.js";import{dt as N,du as T,n as I,dv as L,c as C,ds as A,dw as b}from"./remote-Dva2qg58.js";import j from"./ShotComposer-DFfaYLoV.js";import{u as B}from"./store-75tQUvPT.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./tool-CAGU3dUa.js";import"./timelineProps-CJzzAWWO.js";import"./thumb-r6dlZprA.js";import"./shotFxAgent-7RQNtEe4.js";import"./cameraPresets-DSOPj4oy.js";import"./weaponDuel-D6sLVGmG.js";import"./skin-CVwmK130.js";import"./views-V3si1lOz.js";import"./motionBlur-uAm030t9.js";import"./library-CyjJ8nGG.js";globalThis.__CLIPOOX_THUMB_LIMIT=0;const w="shot-worker";let E=null,i=null,F=0;const S=(t,o)=>window.shotWorkerRpc?window.shotWorkerRpc(t,o):Promise.reject(new Error("no account bridge")),O=t=>({...t,saveSet:(o,a,r)=>S("saveSet",{id:o,name:a,recipe:r}),loadSet:async o=>await S("loadSet",{id:o}),listLibrary:async()=>await S("listLibrary",{}),uploadFile:async()=>{throw new Error("uploads are not available to the 3D Shot worker")}}),P=async(t,o,a)=>{const r=Date.now()+o;for(;!t();){if(Date.now()>r)throw new Error(`${a} timed out`);await new Promise(e=>setTimeout(e,50))}},x=()=>{const t=b();if(!t)throw new Error("no scene open");return t},U={async open(t,o,a={}){t||(t=I(),t.items=[]),L(a.regionClips===!0),B.setState({user:{uid:o},saveState:"saved"}),i={id:w,type:"placeholder",position:{x:0,y:0},data:{tool:"3d-shot",label:"3D Shot",shotScene:t}},C.current={nodes:()=>i?[i]:[],getNode:e=>e===w?i:void 0,addNode:()=>"",updateNodeData:(e,n)=>{i&&e===w&&(i.data={...i.data,...n})}};const r=b();return E??=A.createRoot(document.getElementById("root")),E.render(_.createElement(j,{key:++F,nodeId:w,headless:!0})),await P(()=>{const e=b();return!!e&&e!==r&&!!e.engine()},6e4,"opening the scene"),{ok:!0}},async run(t){const o=[];for(const a of t){let r;try{r=await N(a.tool,a.args||{},O(x()))}catch(c){r={ok:!1,error:String(c?.message||c).slice(0,500)}}const{_image:e,...n}=r;if(o.push({tool:a.tool,ok:r.ok!==!1,result:T(n),...typeof e=="string"?{image:e}:{}}),r.ok===!1)break}return o},stage:()=>x().getStage(),async clip(t={}){const o=x(),a=o.engine(),r=o.getStage(),e=r.shots.find(h=>h.id===r.activeShot);if(!a||!e)throw new Error("renderer not ready");const n=Math.max(2,Math.min(12,Number(t.fps)||8)),c=Math.max(.25,Math.min(4,Number(t.seconds)||2)),g=Math.max(0,Math.min(e.duration,Number(t.from)||0)),R=Math.max(1,Math.min(48,Math.round(c*n))),d=Array.from({length:R},(h,l)=>Math.min(e.duration,g+l/n));a.sync(r,null);const m=await a.renderFrames(e,d,Math.max(180,Math.min(480,Number(t.height)||270)),t.quality==="high"?"high":"draft");if(!t.sheet)return{fps:n,from:g,times:d,frames:m.map(h=>h.toDataURL("image/jpeg",.7))};const p=Math.min(4,m.length),D=Math.ceil(m.length/p),k=m[0].width,u=m[0].height,f=document.createElement("canvas");f.width=p*k,f.height=D*u;const s=f.getContext("2d");return s.font=`${Math.max(12,Math.round(u/14))}px sans-serif`,s.textBaseline="top",m.forEach((h,l)=>{const y=l%p*k,M=Math.floor(l/p)*u;s.drawImage(h,y,M);const v=`${d[l].toFixed(2)} s`;s.fillStyle="rgba(0,0,0,0.55)",s.fillRect(y+4,M+4,s.measureText(v).width+8,Math.round(u/14)+6),s.fillStyle="#fff",s.fillText(v,y+8,M+7)}),{fps:n,from:g,times:d,sheet:f.toDataURL("image/jpeg",.72)}}};window.__shotWorker=U;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{fB as q,i9 as T,en as Q,fF as j,eF as z,fa as G,fG as U,fH as X,et as Y,fJ as C,eD as A,fL as Z,ep as D,ia as V,ib as g,em as tt,ei as ot,ic as et,dt as nt,id as it,ie as rt}from"./remote-BJdzzFZg.js";const O=Math.PI/180,B=t=>[Math.sin(t*O),0,Math.cos(t*O)],_=t=>t.map(o=>+o.toFixed(2)),S=t=>t.kind==="person";function I(t,o){const e=t.filter(i=>S(i)&&!i.hidden&&i.id!==o.id);if(!e.length)return null;const r=B(o.rotation?.[1]??0),n=i=>Math.hypot(i.position[0]-o.position[0],i.position[2]-o.position[2]),l=e.filter(i=>(i.position[0]-o.position[0])*r[0]+(i.position[2]-o.position[2])*r[2]>0);return(l.length?l:e).sort((i,s)=>n(i)-n(s))[0]}function H(t,{items:o=[],selected:e=null,ground:r=[0,0,0],reach:n=8,anchor:l=null}={}){const i=(u,c)=>l?.(u,c)??j(u,c),s=e&&e.kind!=="fx"&&!e.hidden?e:null,f=s&&S(s)?s:null;let m=[...r],d=[0,0,0],a,p;if(t.wantsTarget&&s&&!S(s))return{position:[...s.position],rotation:d,attach:{to:s.id,offset:[0,0,0]},target:{to:s.id,part:"center"}};if(t.attach==="gun"&&f){const u=I(o,f);return{position:[...f.position],rotation:d,attach:{to:f.id,hand:"R",tip:!0},...u?{target:{to:u.id,part:"chest"}}:{}}}switch(t.attach){case"hand":f?(a={to:f.id,hand:"R"},m=[...f.position]):m=[r[0],1.2,r[2]];break;case"body":case"ground":s&&(a={to:s.id,offset:[0,0,0]},m=[...s.position]);break;case"path":case"sky":case"gun":{const u=f?I(o,f):null;let c,b;if(f){c=i(f,t.attach==="sky"?"head":"hand_right");const x=B(f.rotation?.[1]??0);b=u?i(u,"chest"):[c[0]+x[0]*n,Math.max(.6,c[1]-.2),c[2]+x[2]*n]}else s?(c=i(s,"chest"),b=[c[0]+n,c[1],c[2]]):(c=[r[0]-n/2,1.2,r[2]],b=[r[0]+n/2,1,r[2]]);t.attach==="sky"&&(c=[b[0],b[1]+8,b[2]]),p=[_(c),_(b)],m=_(t.attach==="sky"?b:c);break}default:m=[r[0],t.attach==="free"?1.2:0,r[2]]}return{position:m,rotation:d,...a?{attach:a}:{},...p?{path:p}:{}}}const at=[...T.map(t=>t.id),...g.filter(t=>!tt[t].internal&&!T.some(o=>o.id===t))];T.map(t=>`${t.id} (${t.preset}${t.attach==="path"?", needs from/to":t.attach==="sky"?', strikes the "to" point from above':""}: ${t.desc})`).join("; ");const P=/^(.*?)(?:\.(feet|chest|head|hand_right|hand_left|center))?$/,v=t=>P.exec(String(t??"").trim())?.[1]?.trim()??"",F=t=>Array.isArray(t)&&t.length===3&&t.every(o=>typeof o=="number"&&Number.isFinite(o)&&Math.abs(o)<=1e3),J=t=>typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t),y=(t,o)=>{const e=String(o??"").trim().toLowerCase();return t.find(r=>r.id===o||r.name===o)??t.find(r=>r.name.toLowerCase()===e)};function st(t,o,e){const r=[];if(t.from!=null&&r.push(t.from),Array.isArray(t.via)&&r.push(...t.via),t.to!=null&&r.push(t.to),!r.length)return null;if(r.length<2)throw new Error("give both from and to for a flight path (or neither)");return V(r,{find:n=>y(o.items.filter(l=>l.kind!=="fx"),n),at:n=>o.at(n,e),anchor:o.anchor?(n,l)=>o.anchor(n,l,e):void 0})}function ut(t,o){try{const e=q(t.effect)??T.find(h=>h.preset===t.effect);if(!e)throw new Error(`unknown effect '${String(t.effect)}'; use one of ${at.join(", ")}`);const r=o.shot.duration,n=t.start==null?0:Number(t.start);if(!Number.isFinite(n)||n<0||n>=r)throw new Error(`start must be 0..${r} s (the shot is ${r} s long)`);const l=H(e,{items:o.items,selected:t.attach_to?y(o.items,t.attach_to)??null:null,ground:[0,0,0]}),i={preset:e.preset,cat:e.id,intensity:t.intensity??1,seed:t.seed??Math.abs(W(`${t.name??e.id}${n}`))%1e9+1,start:n,duration:t.duration??(e.fill?Math.max(e.duration,r-n):e.duration),loop:t.loop===!0,params:{...Q(e.preset),...e.params||{},...t.params&&typeof t.params=="object"?t.params:{}}};if(t.attach_to!=null){const h=y(o.items.filter(M=>M.kind!=="fx"),t.attach_to);if(!h)throw new Error(`unknown object '${t.attach_to}' to attach to`);const w=t.hand==="right"?"R":t.hand==="left"?"L":void 0;if(t.hand&&t.hand!=="none"&&!w)throw new Error("hand must be 'right', 'left' or 'none'");if(w&&!S(h))throw new Error(`'${h.name}' is not a person: hands exist only on mannequins`);i.attach={to:h.id,...w?{hand:w}:{},...F(t.offset)?{offset:t.offset}:{}},e.attach==="gun"&&S(h)?(i.attach.hand??="R",i.attach.tip=t.tip!==!1):t.tip===!0&&i.attach.hand&&(i.attach.tip=!0)}const s=typeof t.to=="string"?t.to:null,f=s?y(o.items.filter(h=>h.kind!=="fx"),v(s)):null;if(e.wantsTarget){const h=f??(t.attach_to?y(o.items.filter(w=>w.kind!=="fx"),t.attach_to):null);if(h)i.target={to:h.id,part:"center",...t.target_part?{name:String(t.target_part).slice(0,60)}:{}};else if(s)throw new Error(`unknown object '${s}' for to`)}else if(f)i.target={to:f.id,part:P.exec(s)?.[2]??"chest"};else if(s&&!e.wantsTarget)throw new Error(`unknown object '${s}' for to`);const m=t.from!=null?st(t,o,n):null;if(m)i.path=m;else if(e.attach==="gun"&&i.attach?.tip){if(!i.target){const h=I(o.items,o.items.find(w=>w.id===i.attach.to));h&&(i.target={to:h.id,part:"chest"})}}else if(!(t.from==null&&t.to!=null&&!(e.attach==="path"||e.attach==="sky"))){if(e.attach==="path"||e.attach==="sky"){const h=i.attach?o.items.find(E=>E.id===i.attach.to):null;if(!h||!S(h))throw new Error(`${e.id} flies between two points: give from and to (an object name, "Name.hand_right", "Name.chest", or [x, y, z]) or attach_to a person`);const w=o.at(h,n),M=H(e,{items:o.items.map(E=>E.id===h.id?{...E,position:w.position??E.position,rotation:w.rotation??E.rotation}:E),selected:{...h,position:w.position??h.position,rotation:w.rotation??h.rotation},anchor:o.anchor?(E,R)=>o.anchor(E,R,n):null});i.path=M.path,f&&(i.path=[M.path[0],_(j(f,i.target.part,o.at(f,n)))])}}const d=z(i,{strict:!0});if(!d.ok)throw new Error(d.errors.join("; "));const a=J(t.color)?t.color:e.color,p=t.size==null?1:Number(t.size);if(!Number.isFinite(p)||p<.1||p>6)throw new Error("size must be 0.1..6");let u=t.at==null?i.path?e.attach==="sky"?i.path[1]:i.path[0]:F(t.to)&&t.from==null?t.to:f&&!i.attach?_(j(f,"feet",o.at(f,n))):l.position:null;if(t.at!=null)if(F(t.at))u=t.at;else{const h=y(o.items.filter(w=>w.kind!=="fx"),v(t.at));if(!h)throw new Error(`unknown object '${String(t.at)}' for at`);u=j(h,P.exec(String(t.at))?.[2]??"feet",o.at(h,n))}const c=ft(o.items,String(t.name||e.name).slice(0,60)),b={id:o.uid(),name:c,kind:"fx",position:_(u),rotation:[0,Number(t.yaw_deg)||0,0],scale:[p,p,p],color:a,hidden:!1,locked:!1,pose:o.restPose??{},reference:null,fx:d.fx},x=G(o.items,d.fx);if(!x.ok)throw new Error(x.errors.join("; "));const $=U({start:n,duration:d.fx.duration,...d.fx.loop?{loop:!0}:{}},r);return b.fx={...d.fx,start:$.start??n,duration:$.duration??d.fx.duration},{ok:!0,item:b,timing:{start:$.start??n,duration:$.duration??d.fx.duration,...d.fx.loop?{loop:!0}:{}}}}catch(e){return{ok:!1,error:e.message||String(e)}}}const W=t=>{let o=0;for(let e=0;e<t.length;e++)o=Math.imul(o,31)+t.charCodeAt(e)|0;return o},ft=(t,o)=>{let e=o,r=2;for(;t.some(n=>n.name===e);)e=`${o} ${r++}`;return e};function pt(t,o,e){try{const r={...t.fx},n={},i={...e.timing??{start:r.start,duration:r.duration,loop:r.loop}};if(o.start!=null&&(i.start=Number(o.start),!(i.start>=0&&i.start<e.shot.duration)))throw new Error(`start must be 0..${e.shot.duration} s`);if(o.duration!=null&&(i.duration=Number(o.duration)),o.loop!=null&&(i.loop=o.loop===!0),o.color!=null){if(!J(o.color))throw new Error("color must be a CSS hex like #7fe9ff");n.color=o.color}if(o.intensity!=null&&(r.intensity=o.intensity),o.seed!=null&&(r.seed=o.seed),o.params&&typeof o.params=="object"&&(r.params={...r.params,...o.params}),o.size!=null){const a=Number(o.size);if(!(a>=.1&&a<=6))throw new Error("size must be 0.1..6");n.scale=[a,a,a]}o.yaw_deg!=null&&(n.rotation=[t.rotation[0],Number(o.yaw_deg)||0,t.rotation[2]]);const s=e.items.filter(a=>a.kind!=="fx"&&a.id!==t.id);if(o.attach_to!=null)if(o.attach_to==="none")delete r.attach;else{const a=y(s,o.attach_to);if(!a)throw new Error(`unknown object '${o.attach_to}' to attach to`);const p=o.hand==="right"?"R":o.hand==="left"?"L":void 0;if(p&&!S(a))throw new Error(`'${a.name}' is not a person`);r.attach={to:a.id,...p?{hand:p}:{},...F(o.offset)?{offset:o.offset}:{}}}else if(o.hand!=null&&r.attach){const a=o.hand==="right"?"R":o.hand==="left"?"L":void 0;r.attach={...r.attach,hand:a},a||delete r.attach.hand}if(o.at!=null)if(F(o.at))n.position=o.at;else{const a=y(s,v(o.at));if(!a)throw new Error(`unknown object '${String(o.at)}' for at`);n.position=_(j(a,P.exec(String(o.at))?.[2]??"feet",e.at(a,i.start)))}if(o.from!=null||o.to!=null||o.via!=null){const a=r.path??[],p=[o.from??a[0],...Array.isArray(o.via)?o.via:a.slice(1,-1),o.to??a.at(-1)];if(p.some(u=>u==null))throw new Error("give both from and to the first time you set a path");r.path=V(p,{find:u=>y(s,u),at:u=>e.at(u,i.start),anchor:e.anchor?(u,c)=>e.anchor(u,c,i.start):void 0})}if(typeof o.to=="string"){const a=y(s,v(o.to));a&&(r.target={to:a.id,part:P.exec(o.to)?.[2]??"chest"})}o.clear_path===!0&&delete r.path;const f=z({...r,start:i.start,duration:i.duration,loop:i.loop},{strict:!0});if(!f.ok)throw new Error(f.errors.join("; "));const m=G(e.items.filter(a=>a.id!==t.id),f.fx);if(!m.ok)throw new Error(m.errors.join("; "));const d=U(i,e.shot.duration);return{ok:!0,itemPatch:n,fx:{...f.fx,start:d.start??i.start,duration:d.duration??i.duration},timing:{...d,start:d.start??i.start,duration:d.duration??i.duration}}}catch(r){return{ok:!1,error:r.message||String(r)}}}function lt(t){const[o,e,r]=it(rt(t)),n=o*360;return r>.88||e<.12?r<.3?"dark grey":"white":r<.2?"dark":n<15||n>=345?"red":n<40?"orange":n<62?"golden":n<95?"lime green":n<160?"green":n<195?"cyan":n<225?"sky blue":n<255?"blue":n<285?"purple":n<330?"magenta":"pink"}function mt(t,o){const e=n=>{let l=null,i=2;for(const s of t){if(s.kind==="fx"||s.hidden)continue;const f=nt.dist(j(s,"chest"),n);f<i&&(i=f,l=s)}return l?.name},r=[];for(const n of t){if(n.kind!=="fx"||!n.fx||n.hidden)continue;const l=ot(n,o);if(l.off)continue;if(n.fx.preset===A){const a=n.fx.target&&t.find(p=>p.id===n.fx.target.to);a&&r.push(et(n,a.name,l));continue}const i=q(n.fx.cat)??T.find(a=>a.preset===n.fx.preset);if(!i)continue;const s=n.fx.attach?t.find(a=>a.id===n.fx.attach.to):null,f=n.fx.path?e(n.fx.path[0]):null,m=n.fx.path?e(n.fx.path.at(-1)):null,d=f&&m&&f!==m?` from ${f} to ${m}`:n.fx.path&&m?` toward ${m}`:s?` on ${s.name}${n.fx.attach.hand?`'s ${n.fx.attach.hand==="R"?"right":"left"} hand`:""}`:"";r.push(`${i.prompt} (${lt(n.color)} tint)${d}, from ${l.start.toFixed(1)}s to ${(l.start+l.duration).toFixed(1)}s`)}return r.length?`VISUAL EFFECTS
|
|
2
|
-
The previs shows each effect as glowing placeholder light. Recreate them as real, high-quality cinematic VFX with the same colour, timing, size and path (never render text or UI): ${r.slice(0,12).join("; ")}.`:""}const ht=["model","proxy","box","wall","platform","floor","sphere","cylinder","set","prop"];function dt(t){const o=t.scale??[1,1,1];if(t.kind==="proxy"&&t.proxy?.dims)return t.proxy.dims.map((e,r)=>e*o[r]);if(t.kind==="model"){const e=(t.model?.height??2)*o[1];return[e*.6,e,e*.6]}return[...o]}function wt(t,o){try{const e=y(o.items.filter(k=>ht.includes(k.kind)&&!k.hidden),t.target);if(!e)throw new Error(`unknown target '${String(t.target)}': use the name of a model, proxy, box, wall or platform from scene_summary`);const r=t.recipe??"collapse";if(!X.includes(r))throw new Error(`recipe must be one of ${X.join(", ")}`);const n=Y.has(r),l=o.shot.duration,i=t.start==null?0:Number(t.start),s=t.end==null?Math.min(l,i+(n?4:Math.max(1,l*.5))):Number(t.end);if(!(i>=0&&i<l))throw new Error(`start must be 0..${l} s`);if(!(s>i&&s<=l+1e-6))throw new Error(`end must be after start and at most ${l} s`);if(t.mode!=null&&!C.includes(t.mode))throw new Error(`mode must be one of ${C.join(", ")}`);const f=dt(e),m=t.radius??Math.min(6,Math.max(.6,Math.max(...f)/5)),d=o.items.find(k=>k.fx?.preset===
|
|
1
|
+
import{fJ as B,ii as T,ev as Q,fN as N,eN as z,fi as H,fO as U,fP as X,eB as Y,fR as C,eL as v,fT as Z,ex as O,ij as V,ik as g,eu as tt,eq as ot,il as et,dB as nt,im as it,io as rt}from"./remote-Dva2qg58.js";const D=Math.PI/180,G=t=>[Math.sin(t*D),0,Math.cos(t*D)],_=t=>t.map(o=>+o.toFixed(2)),S=t=>t.kind==="person";function I(t,o){const e=t.filter(i=>S(i)&&!i.hidden&&i.id!==o.id);if(!e.length)return null;const r=G(o.rotation?.[1]??0),n=i=>Math.hypot(i.position[0]-o.position[0],i.position[2]-o.position[2]),l=e.filter(i=>(i.position[0]-o.position[0])*r[0]+(i.position[2]-o.position[2])*r[2]>0);return(l.length?l:e).sort((i,s)=>n(i)-n(s))[0]}function q(t,{items:o=[],selected:e=null,ground:r=[0,0,0],reach:n=8,anchor:l=null}={}){const i=(u,c)=>l?.(u,c)??N(u,c),s=e&&e.kind!=="fx"&&!e.hidden?e:null,f=s&&S(s)?s:null;let m=[...r],d=[0,0,0],a,p;if(t.wantsTarget&&s&&!S(s))return{position:[...s.position],rotation:d,attach:{to:s.id,offset:[0,0,0]},target:{to:s.id,part:"center"}};if(t.attach==="gun"&&f){const u=I(o,f);return{position:[...f.position],rotation:d,attach:{to:f.id,hand:"R",tip:!0},...u?{target:{to:u.id,part:"chest"}}:{}}}switch(t.attach){case"hand":f?(a={to:f.id,hand:"R"},m=[...f.position]):m=[r[0],1.2,r[2]];break;case"body":case"ground":s&&(a={to:s.id,offset:[0,0,0]},m=[...s.position]);break;case"path":case"sky":case"gun":{const u=f?I(o,f):null;let c,x;if(f){c=i(f,t.attach==="sky"?"head":"hand_right");const b=G(f.rotation?.[1]??0);x=u?i(u,"chest"):[c[0]+b[0]*n,Math.max(.6,c[1]-.2),c[2]+b[2]*n]}else s?(c=i(s,"chest"),x=[c[0]+n,c[1],c[2]]):(c=[r[0]-n/2,1.2,r[2]],x=[r[0]+n/2,1,r[2]]);t.attach==="sky"&&(c=[x[0],x[1]+8,x[2]]),p=[_(c),_(x)],m=_(t.attach==="sky"?x:c);break}default:m=[r[0],t.attach==="free"?1.2:0,r[2]]}return{position:m,rotation:d,...a?{attach:a}:{},...p?{path:p}:{}}}const at=[...T.map(t=>t.id),...g.filter(t=>!tt[t].internal&&!T.some(o=>o.id===t))];T.map(t=>`${t.id} (${t.preset}${t.attach==="path"?", needs from/to":t.attach==="sky"?', strikes the "to" point from above':""}: ${t.desc})`).join("; ");const P=/^(.*?)(?:\.(feet|chest|head|hand_right|hand_left|center))?$/,A=t=>P.exec(String(t??"").trim())?.[1]?.trim()??"",F=t=>Array.isArray(t)&&t.length===3&&t.every(o=>typeof o=="number"&&Number.isFinite(o)&&Math.abs(o)<=1e3),J=t=>typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t),y=(t,o)=>{const e=String(o??"").trim().toLowerCase();return t.find(r=>r.id===o||r.name===o)??t.find(r=>r.name.toLowerCase()===e)};function st(t,o,e){const r=[];if(t.from!=null&&r.push(t.from),Array.isArray(t.via)&&r.push(...t.via),t.to!=null&&r.push(t.to),!r.length)return null;if(r.length<2)throw new Error("give both from and to for a flight path (or neither)");return V(r,{find:n=>y(o.items.filter(l=>l.kind!=="fx"),n),at:n=>o.at(n,e),anchor:o.anchor?(n,l)=>o.anchor(n,l,e):void 0})}function ut(t,o){try{const e=B(t.effect)??T.find(h=>h.preset===t.effect);if(!e)throw new Error(`unknown effect '${String(t.effect)}'; use one of ${at.join(", ")}`);const r=o.shot.duration,n=t.start==null?0:Number(t.start);if(!Number.isFinite(n)||n<0||n>=r)throw new Error(`start must be 0..${r} s (the shot is ${r} s long)`);const l=q(e,{items:o.items,selected:t.attach_to?y(o.items,t.attach_to)??null:null,ground:[0,0,0]}),i={preset:e.preset,cat:e.id,intensity:t.intensity??1,seed:t.seed??Math.abs(W(`${t.name??e.id}${n}`))%1e9+1,start:n,duration:t.duration??(e.fill?Math.max(e.duration,r-n):e.duration),loop:t.loop===!0,params:{...Q(e.preset),...e.params||{},...t.params&&typeof t.params=="object"?t.params:{}}};if(t.attach_to!=null){const h=y(o.items.filter(M=>M.kind!=="fx"),t.attach_to);if(!h)throw new Error(`unknown object '${t.attach_to}' to attach to`);const w=t.hand==="right"?"R":t.hand==="left"?"L":void 0;if(t.hand&&t.hand!=="none"&&!w)throw new Error("hand must be 'right', 'left' or 'none'");if(w&&!S(h))throw new Error(`'${h.name}' is not a person: hands exist only on mannequins`);i.attach={to:h.id,...w?{hand:w}:{},...F(t.offset)?{offset:t.offset}:{}},e.attach==="gun"&&S(h)?(i.attach.hand??="R",i.attach.tip=t.tip!==!1):t.tip===!0&&i.attach.hand&&(i.attach.tip=!0)}const s=typeof t.to=="string"?t.to:null,f=s?y(o.items.filter(h=>h.kind!=="fx"),A(s)):null;if(e.wantsTarget){const h=f??(t.attach_to?y(o.items.filter(w=>w.kind!=="fx"),t.attach_to):null);if(h)i.target={to:h.id,part:"center",...t.target_part?{name:String(t.target_part).slice(0,60)}:{}};else if(s)throw new Error(`unknown object '${s}' for to`)}else if(f)i.target={to:f.id,part:P.exec(s)?.[2]??"chest"};else if(s&&!e.wantsTarget)throw new Error(`unknown object '${s}' for to`);const m=t.from!=null?st(t,o,n):null;if(m)i.path=m;else if(e.attach==="gun"&&i.attach?.tip){if(!i.target){const h=I(o.items,o.items.find(w=>w.id===i.attach.to));h&&(i.target={to:h.id,part:"chest"})}}else if(!(t.from==null&&t.to!=null&&!(e.attach==="path"||e.attach==="sky"))){if(e.attach==="path"||e.attach==="sky"){const h=i.attach?o.items.find(E=>E.id===i.attach.to):null;if(!h||!S(h))throw new Error(`${e.id} flies between two points: give from and to (an object name, "Name.hand_right", "Name.chest", or [x, y, z]) or attach_to a person`);const w=o.at(h,n),M=q(e,{items:o.items.map(E=>E.id===h.id?{...E,position:w.position??E.position,rotation:w.rotation??E.rotation}:E),selected:{...h,position:w.position??h.position,rotation:w.rotation??h.rotation},anchor:o.anchor?(E,R)=>o.anchor(E,R,n):null});i.path=M.path,f&&(i.path=[M.path[0],_(N(f,i.target.part,o.at(f,n)))])}}const d=z(i,{strict:!0});if(!d.ok)throw new Error(d.errors.join("; "));const a=J(t.color)?t.color:e.color,p=t.size==null?1:Number(t.size);if(!Number.isFinite(p)||p<.1||p>6)throw new Error("size must be 0.1..6");let u=t.at==null?i.path?e.attach==="sky"?i.path[1]:i.path[0]:F(t.to)&&t.from==null?t.to:f&&!i.attach?_(N(f,"feet",o.at(f,n))):l.position:null;if(t.at!=null)if(F(t.at))u=t.at;else{const h=y(o.items.filter(w=>w.kind!=="fx"),A(t.at));if(!h)throw new Error(`unknown object '${String(t.at)}' for at`);u=N(h,P.exec(String(t.at))?.[2]??"feet",o.at(h,n))}const c=ft(o.items,String(t.name||e.name).slice(0,60)),x={id:o.uid(),name:c,kind:"fx",position:_(u),rotation:[0,Number(t.yaw_deg)||0,0],scale:[p,p,p],color:a,hidden:!1,locked:!1,pose:o.restPose??{},reference:null,fx:d.fx},b=H(o.items,d.fx);if(!b.ok)throw new Error(b.errors.join("; "));const $=U({start:n,duration:d.fx.duration,...d.fx.loop?{loop:!0}:{}},r);return x.fx={...d.fx,start:$.start??n,duration:$.duration??d.fx.duration},{ok:!0,item:x,timing:{start:$.start??n,duration:$.duration??d.fx.duration,...d.fx.loop?{loop:!0}:{}}}}catch(e){return{ok:!1,error:e.message||String(e)}}}const W=t=>{let o=0;for(let e=0;e<t.length;e++)o=Math.imul(o,31)+t.charCodeAt(e)|0;return o},ft=(t,o)=>{let e=o,r=2;for(;t.some(n=>n.name===e);)e=`${o} ${r++}`;return e};function pt(t,o,e){try{const r={...t.fx},n={},i={...e.timing??{start:r.start,duration:r.duration,loop:r.loop}};if(o.start!=null&&(i.start=Number(o.start),!(i.start>=0&&i.start<e.shot.duration)))throw new Error(`start must be 0..${e.shot.duration} s`);if(o.duration!=null&&(i.duration=Number(o.duration)),o.loop!=null&&(i.loop=o.loop===!0),o.color!=null){if(!J(o.color))throw new Error("color must be a CSS hex like #7fe9ff");n.color=o.color}if(o.intensity!=null&&(r.intensity=o.intensity),o.seed!=null&&(r.seed=o.seed),o.params&&typeof o.params=="object"&&(r.params={...r.params,...o.params}),o.size!=null){const a=Number(o.size);if(!(a>=.1&&a<=6))throw new Error("size must be 0.1..6");n.scale=[a,a,a]}o.yaw_deg!=null&&(n.rotation=[t.rotation[0],Number(o.yaw_deg)||0,t.rotation[2]]);const s=e.items.filter(a=>a.kind!=="fx"&&a.id!==t.id);if(o.attach_to!=null)if(o.attach_to==="none")delete r.attach;else{const a=y(s,o.attach_to);if(!a)throw new Error(`unknown object '${o.attach_to}' to attach to`);const p=o.hand==="right"?"R":o.hand==="left"?"L":void 0;if(p&&!S(a))throw new Error(`'${a.name}' is not a person`);r.attach={to:a.id,...p?{hand:p}:{},...F(o.offset)?{offset:o.offset}:{}}}else if(o.hand!=null&&r.attach){const a=o.hand==="right"?"R":o.hand==="left"?"L":void 0;r.attach={...r.attach,hand:a},a||delete r.attach.hand}if(o.at!=null)if(F(o.at))n.position=o.at;else{const a=y(s,A(o.at));if(!a)throw new Error(`unknown object '${String(o.at)}' for at`);n.position=_(N(a,P.exec(String(o.at))?.[2]??"feet",e.at(a,i.start)))}if(o.from!=null||o.to!=null||o.via!=null){const a=r.path??[],p=[o.from??a[0],...Array.isArray(o.via)?o.via:a.slice(1,-1),o.to??a.at(-1)];if(p.some(u=>u==null))throw new Error("give both from and to the first time you set a path");r.path=V(p,{find:u=>y(s,u),at:u=>e.at(u,i.start),anchor:e.anchor?(u,c)=>e.anchor(u,c,i.start):void 0})}if(typeof o.to=="string"){const a=y(s,A(o.to));a&&(r.target={to:a.id,part:P.exec(o.to)?.[2]??"chest"})}o.clear_path===!0&&delete r.path;const f=z({...r,start:i.start,duration:i.duration,loop:i.loop},{strict:!0});if(!f.ok)throw new Error(f.errors.join("; "));const m=H(e.items.filter(a=>a.id!==t.id),f.fx);if(!m.ok)throw new Error(m.errors.join("; "));const d=U(i,e.shot.duration);return{ok:!0,itemPatch:n,fx:{...f.fx,start:d.start??i.start,duration:d.duration??i.duration},timing:{...d,start:d.start??i.start,duration:d.duration??i.duration}}}catch(r){return{ok:!1,error:r.message||String(r)}}}function lt(t){const[o,e,r]=it(rt(t)),n=o*360;return r>.88||e<.12?r<.3?"dark grey":"white":r<.2?"dark":n<15||n>=345?"red":n<40?"orange":n<62?"golden":n<95?"lime green":n<160?"green":n<195?"cyan":n<225?"sky blue":n<255?"blue":n<285?"purple":n<330?"magenta":"pink"}function mt(t,o){const e=n=>{let l=null,i=2;for(const s of t){if(s.kind==="fx"||s.hidden)continue;const f=nt.dist(N(s,"chest"),n);f<i&&(i=f,l=s)}return l?.name},r=[];for(const n of t){if(n.kind!=="fx"||!n.fx||n.hidden)continue;const l=ot(n,o);if(l.off)continue;if(n.fx.preset===v){const a=n.fx.target&&t.find(p=>p.id===n.fx.target.to);a&&r.push(et(n,a.name,l));continue}const i=B(n.fx.cat)??T.find(a=>a.preset===n.fx.preset);if(!i)continue;const s=n.fx.attach?t.find(a=>a.id===n.fx.attach.to):null,f=n.fx.path?e(n.fx.path[0]):null,m=n.fx.path?e(n.fx.path.at(-1)):null,d=f&&m&&f!==m?` from ${f} to ${m}`:n.fx.path&&m?` toward ${m}`:s?` on ${s.name}${n.fx.attach.hand?`'s ${n.fx.attach.hand==="R"?"right":"left"} hand`:""}`:"";r.push(`${i.prompt} (${lt(n.color)} tint)${d}, from ${l.start.toFixed(1)}s to ${(l.start+l.duration).toFixed(1)}s`)}return r.length?`VISUAL EFFECTS
|
|
2
|
+
The previs shows each effect as glowing placeholder light. Recreate them as real, high-quality cinematic VFX with the same colour, timing, size and path (never render text or UI): ${r.slice(0,12).join("; ")}.`:""}const ht=["model","proxy","box","wall","platform","floor","sphere","cylinder","set","prop"];function dt(t){const o=t.scale??[1,1,1];if(t.kind==="proxy"&&t.proxy?.dims)return t.proxy.dims.map((e,r)=>e*o[r]);if(t.kind==="model"){const e=(t.model?.height??2)*o[1];return[e*.6,e,e*.6]}return[...o]}function wt(t,o){try{const e=y(o.items.filter(k=>ht.includes(k.kind)&&!k.hidden),t.target);if(!e)throw new Error(`unknown target '${String(t.target)}': use the name of a model, proxy, box, wall or platform from scene_summary`);const r=t.recipe??"collapse";if(!X.includes(r))throw new Error(`recipe must be one of ${X.join(", ")}`);const n=Y.has(r),l=o.shot.duration,i=t.start==null?0:Number(t.start),s=t.end==null?Math.min(l,i+(n?4:Math.max(1,l*.5))):Number(t.end);if(!(i>=0&&i<l))throw new Error(`start must be 0..${l} s`);if(!(s>i&&s<=l+1e-6))throw new Error(`end must be after start and at most ${l} s`);if(t.mode!=null&&!C.includes(t.mode))throw new Error(`mode must be one of ${C.join(", ")}`);const f=dt(e),m=t.radius??Math.min(6,Math.max(.6,Math.max(...f)/5)),d=o.items.find(k=>k.fx?.preset===v&&k.fx.target?.to===e.id),a={radius:m,...Object.fromEntries(["strength","chunks","debris","collapse","falloff","shake","mode"].filter(k=>t[k]!=null).map(k=>[k,t[k]])),...t.direction!=null?{yaw:Number(t.direction)}:{}};d&&t.chunks==null&&(a.chunks=d.fx.params.chunks);const p=t.seed??d?.fx.seed??Math.abs(W(`${e.name}${i}`))%1e9+1,u=Z({target:e.id,recipe:r,seed:p,start:i,duration:n?s-i:l-i,params:a}),c=z(u,{strict:!0});if(!c.ok)throw new Error(c.errors.join("; "));if(n){const k=o.items.filter(K=>K.fx?.preset===v).length,j=e.position;return{ok:!0,item:{id:o.uid(),name:t.name?String(t.name).slice(0,60):`Mix FX ${k+1}`,kind:"fx",position:[j[0],+(j[1]+f[1]+.6).toFixed(2),j[2]],rotation:[0,0,0],scale:[1,1,1],color:O[r].color,hidden:!1,locked:!1,pose:o.restPose,reference:null,fx:c.fx},timing:{start:i,duration:+(s-i).toFixed(2)},keys:[]}}const x=c.fx.params.radius+c.fx.params.falloff+.3,b=e.position,$=+(b[1]+f[1]/2).toFixed(2),h=F(t.from)?t.from.map(Number):[+(b[0]-f[0]/2-x).toFixed(2),$,b[2]],w=F(t.to)?t.to.map(Number):[+(b[0]+f[0]/2+x).toFixed(2),$,b[2]],M=o.items.filter(k=>k.fx?.preset===v).length,E={id:o.uid(),name:t.name?String(t.name).slice(0,60):`Mix FX ${M+1}`,kind:"fx",position:h,rotation:[0,0,0],scale:[1,1,1],color:O[r].color,hidden:!1,locked:!1,pose:o.restPose,reference:null,fx:c.fx},R=(k,j,L)=>({id:k,time:+j.toFixed(4),position:L,rotation:[0,0,0],scale:[1,1,1]});return{ok:!0,item:E,timing:{start:i,duration:+(l-i).toFixed(2)},keys:[R(o.uid(),i/l,h),R(o.uid(),s/l,w)]}}catch(e){return{ok:!1,error:e.message}}}export{y as a,ut as b,wt as c,pt as d,mt as f,q as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ij as N,ik as C,dN as Q,il as X,im as V,io as Y,ip as Z,iq as K,dL as W,ir as ee}from"./remote-BJdzzFZg.js";import{Vector3 as w,Line as F,SphereGeometry as te,Mesh as B,BufferGeometry as ne,Euler as oe,MathUtils as re,Box3 as L,LineBasicMaterial as se,MeshBasicMaterial as ie,Matrix4 as _,Bone as ae,Object3D as ce,Skeleton as ue,Uint16BufferAttribute as le,Float32BufferAttribute as de,SkinnedMesh as fe,Quaternion as pe,Sphere as he}from"./three.module-Bx43vjkH.js";const ye="clipoox-rig-weights",k="weights",ge=8;function R(){return new Promise(e=>{try{if(typeof indexedDB>"u")return e(null);const t=indexedDB.open(ye,1);t.onupgradeneeded=()=>{try{t.result.createObjectStore(k)}catch{}},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch{e(null)}})}async function me(e){const t=await R();if(!t)return null;try{return await new Promise(n=>{try{const r=t.transaction(k,"readonly").objectStore(k).get(e);r.onsuccess=()=>{const o=r.result;n(o?.data?.skinIndex instanceof Uint16Array?o.data:null)},r.onerror=()=>n(null)}catch{n(null)}})}finally{try{t.close()}catch{}}}async function we(e,t){const n=await R();if(n)try{await new Promise(r=>{try{const o=n.transaction(k,"readwrite"),i=o.objectStore(k);i.put({at:Date.now(),data:t},e);const s=[],c=i.openCursor();c.onsuccess=()=>{const u=c.result;u?(s.push({key:u.key,at:u.value.at||0}),u.continue()):s.sort((a,p)=>p.at-a.at).slice(ge).forEach(a=>i.delete(a.key))},o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()}catch{r()}})}finally{try{n.close()}catch{}}}async function be(){const e=await R();if(e)try{await new Promise(t=>{try{const n=e.transaction(k,"readwrite");n.objectStore(k).clear(),n.oncomplete=()=>t(),n.onerror=()=>t()}catch{t()}})}finally{try{e.close()}catch{}}}async function xe(e,t,n=!0){const r=`${N(e.positions,e.index)}|${e.rigKey}`;if(n){const i=await me(r).catch(()=>null);if(i)return t?.(1),{...i,source:"disk",key:r}}const o=C({positions:e.positions,index:e.index,joints:e.joints,onProgress:t});return n&&await we(r,o).catch(()=>{}),{...o,source:"computed",key:r}}function ve(e,t,n=!0){const r=async()=>({...await xe(e,t,n),via:"main"});if(typeof Worker>"u")return new Promise((s,c)=>setTimeout(()=>r().then(s,c),0));let o;try{o=new Worker(new URL("/assets/weights.worker-r1GBeQWE.js",import.meta.url),{type:"module"})}catch{return r()}const i={...e,positions:e.positions.slice(),index:e.index.slice()};return new Promise((s,c)=>{let u=!1;const a=()=>{if(!u){u=!0;try{o.terminate()}catch{}r().then(s,c)}};o.onmessage=p=>{p.data.type==="progress"?t?.(p.data.fraction??0):p.data.type==="done"&&!u?(u=!0,o.terminate(),s({...p.data.result,via:"worker"})):p.data.type==="error"&&a()},o.onerror=p=>{p.preventDefault?.(),a()};try{o.postMessage({input:i,disk:n},[i.positions.buffer,i.index.buffer])}catch{a()}})}const M=new Map,Me=12,ke=3e4,j=new Map,O=new Set,S=()=>O.forEach(e=>{try{e()}catch{}});function Be(e){return O.add(e),()=>{O.delete(e)}}function Oe(e){for(const n of j.values())if(n.modelKey===e)return{progress:n.progress,vertices:n.vertices};const t=H.get(e);return t&&Date.now()-t.at<G?{progress:1,vertices:t.vertices,done:!0}:null}const H=new Map,G=6e3;function Re(e){if(!e)M.clear();else for(const t of[...M.keys()])t.startsWith(`${e}|`)&&M.delete(t);be()}function A(e){e.updateMatrixWorld(!0);const t=e.matrixWorld.clone().invert(),n=[];return e.traverse(r=>{r instanceof B&&!r.userData.rigOverlay&&r.geometry?.getAttribute("position")&&n.push({mesh:r,matrix:t.clone().multiply(r.matrixWorld)})}),n}function je(e){const t=new L,n=new w;for(const{mesh:r,matrix:o}of A(e)){const i=r.geometry.getAttribute("position"),s=Math.max(1,Math.floor(i.count/2e4));for(let c=0;c<i.count;c+=s)t.expandByPoint(n.fromBufferAttribute(i,c).applyMatrix4(o))}return t}function Ie(e){let t=null,n=null;const r=new w;for(const{mesh:o,matrix:i}of A(e)){const s=o.geometry.getAttribute("position");for(let c=0;c<s.count;c++)r.fromBufferAttribute(s,c).applyMatrix4(i),(!t||r.x<t[0])&&(t=[r.x,r.y,r.z]),(!n||r.x>n[0])&&(n=[r.x,r.y,r.z])}return t&&n?{L:t,R:n}:null}function Se(e,t=A(e)){const n=t.reduce((a,{mesh:p})=>a+p.geometry.getAttribute("position").count,0),r=t.reduce((a,{mesh:p})=>a+(p.geometry.index?.count??p.geometry.getAttribute("position").count),0),o=new Float32Array(n*3),i=new Uint32Array(r),s=new w;let c=0,u=0;for(const{mesh:a,matrix:p}of t){const l=a.geometry,g=l.getAttribute("position");for(let y=0;y<g.count;y++)s.fromBufferAttribute(g,y).applyMatrix4(p),o[(c+y)*3]=s.x,o[(c+y)*3+1]=s.y,o[(c+y)*3+2]=s.z;if(l.index)for(let y=0;y<l.index.count;y++)i[u++]=c+l.index.getX(y);else for(let y=0;y<g.count;y++)i[u++]=c+y;c+=g.count}return{positions:o,index:i}}function E(e,t,n,r,o){const i=[];let s=0;for(const{mesh:u}of t){const a=u.geometry.getAttribute("position").count;i.push({skinIndex:n.skinIndex.slice(s*4,(s+a)*4),skinWeight:n.skinWeight.slice(s*4,(s+a)*4)}),s+=a}const c={perMesh:i,radius:n.boneRadius,spheres:n.boneSpheres,vertices:n.vertices,ms:n.ms,source:r,via:o};for(M.set(e,c);M.size>Me;)M.delete(M.keys().next().value);return c}function Ae(e,t,n,r={}){const o=A(e),i=o.map(({mesh:f})=>`${f.geometry.getAttribute("position").count}:${f.geometry.index?.count??0}`).join(","),s=`${n}|${i}|${W(t)}`,c=M.get(s);if(c)return{meshes:o,weights:c,cached:!0,key:s,job:null};const u=j.get(s);if(u)return{meshes:o,weights:null,cached:!1,key:s,job:u.promise};const a=o.reduce((f,{mesh:h})=>f+h.geometry.getAttribute("position").count,0),p=Se(e,o),l=W(t);if(o.length&&o.every(({mesh:f})=>f.geometry.userData.rigWeights===l&&f.geometry.getAttribute("skinIndex"))){const f=new Uint16Array(a*4),h=new Float32Array(a*4);let d=0;for(const{mesh:m}of o){const v=m.geometry;f.set(v.getAttribute("skinIndex").array,d*4),h.set(v.getAttribute("skinWeight").array,d*4),d+=v.getAttribute("position").count}const x=ee({positions:p.positions,skinIndex:f,skinWeight:h,joints:t.joints});return{meshes:o,weights:E(s,o,{skinIndex:f,skinWeight:h,...x,vertices:a,ms:0},"computed","main"),cached:!1,key:s,job:null}}if(a<=ke&&r.background!==!0){const f=C({...p,joints:t.joints});return f.vertices,Math.round(f.ms),{meshes:o,weights:E(s,o,f,"computed","main"),cached:!1,key:s,job:null}}const g={promise:Promise.resolve(),progress:0,vertices:a,modelKey:n};let y=0;return g.promise=ve({...p,joints:t.joints,rigKey:W(t)},f=>{g.progress=f,y++,S()}).then(f=>{E(s,o,f,f.source,f.via),g.via=f.via,f.via,f.source,f.vertices,Math.round(f.ms)}).catch(f=>{console.warn("[rig] weights",f.message)}).finally(()=>{j.delete(s),H.set(n,{at:Date.now(),vertices:a}),S(),setTimeout(S,G+50)}),j.set(s,g),S(),{meshes:o,weights:null,cached:!1,key:s,job:g.promise}}function Pe(e,t,n,r){if(!t.joints.length)return null;const{meshes:o,weights:i,cached:s,key:c,job:u}=Ae(e,t,n);if(!o.length)return null;u&&r?.(`rig:${c}`,u);const a=t.joints.map(h=>{const d=new ae;return d.name=h.name,d.userData.rigBone=h.name,d});if(t.joints.forEach((h,d)=>{const x=h.parent?t.joints.findIndex(v=>v.name===h.parent):-1,m=new w(...h.pos);x<0?(a[d].position.copy(m),e.add(a[d])):(a[d].position.copy(m.sub(new w(...t.joints[x].pos))),a[x].add(a[d]))}),t.kind==="humanoid")for(const h of["L","R"]){const d=Y(t,h),x=t.joints.findIndex(v=>v.name===`wrist${h}`);if(!d||x<0)continue;const m=new ce;m.name=`rigHold${h}`,m.userData.rigHold=h,m.position.copy(d.position),m.quaternion.copy(d.quaternion),m.scale.setScalar(d.scale),a[x].add(m)}e.updateMatrixWorld(!0);const p=[];if(i){const h=new ue(a);o.forEach(({mesh:d},x)=>{const m=d.geometry,v=i.perMesh[x];m.setAttribute("skinIndex",new le(v.skinIndex,4)),m.setAttribute("skinWeight",new de(v.skinWeight,4));const b=new fe(m,d.material);b.name=d.name,b.castShadow=d.castShadow,b.receiveShadow=d.receiveShadow,b.position.copy(d.position),b.quaternion.copy(d.quaternion),b.scale.copy(d.scale),b.frustumCulled=!0,b.userData.rigSkinned=!0,b.userData.slots=d.userData.slots;const I=d.parent;I.add(b),I.remove(d);for(const J of[...d.children])b.add(J);p.push(b)}),e.updateMatrixWorld(!0);for(const d of p)d.bind(h,d.matrixWorld)}const l=je(e),g=Math.max(.001,...l.getSize(new w).toArray()),y=i?void 0:[...j.values()].find(h=>h.promise===u),f={rig:t,bones:a,poser:Z(t,i?.radius??null),meshes:p,rootRest:a[0].position.clone(),size:g,center:l.getCenter(new w),info:i?{vertices:i.vertices,ms:Math.round(i.ms),cached:s,source:s?i.source==="disk"?"disk":"memory":i.source,via:i.via}:{vertices:y?.vertices??0,ms:0,cached:!1,source:"pending",progress:y?.progress??0},spheres:i?.spheres??null};return e.userData.rig=f,f}const D=new _,P=new _,q=new w,We=new w;function U(e){const t=e.spheres;if(!(!t||!e.meshes.length))for(const n of e.meshes){n.updateMatrixWorld(!0),P.copy(n.matrixWorld).invert();const r=[],o=[];if(e.bones.forEach((u,a)=>{const p=t[a*4+3];if(!(p>0))return;const l=e.rig.joints[a].pos;D.multiplyMatrices(P,u.matrixWorld),r.push(We.set(t[a*4]-l[0],t[a*4+1]-l[1],t[a*4+2]-l[2]).applyMatrix4(D).clone()),o.push(p*D.getMaxScaleOnAxis())}),!r.length)continue;const i=new L;r.forEach((u,a)=>{i.expandByPoint(q.copy(u).addScalar(o[a])),i.expandByPoint(q.copy(u).addScalar(-o[a]))});const s=i.getCenter(new w);let c=0;r.forEach((u,a)=>{c=Math.max(c,u.distanceTo(s)+o[a])}),n.boundingSphere=new he(s,c),n.boundingBox=i}}function qe(e,t,n,r=!1){if(r)e.bones.forEach(o=>o.quaternion.identity()),e.bones[0].position.copy(e.rootRest);else{const{local:o,shift:i}=e.poser.solve(t,n||{});e.bones.forEach((s,c)=>s.quaternion.copy(o[c])),e.bones[0].position.copy(e.rootRest),e.bones[0].position.y+=i}e.bones[0].updateMatrixWorld(!0),U(e)}function Te(e,t){const n=V(e.rig),r=l=>l?e.bones[e.rig.joints.findIndex(g=>g.name===l)]:void 0,o=r(n.head),i=e.rig.joints.find(l=>l.name==="headTop"),s=e.rig.joints.find(l=>l.name===n.head),c=i&&s?Math.max(.05,i.pos[1]-s.pos[1]):.25,u=new w(0,.55*c,.3*c),a=(l,g,y,f,h)=>{if(!l)return;l.updateWorldMatrix(!0,!1);const d=l.worldToLocal(t.clone()).sub(h);l.quaternion.multiply(new pe().setFromEuler(K(d,y,f,g))),l.updateMatrixWorld(!0)},p=r(n.neck);p&&a(p,.4,30,15,u.clone().add(new w(0,.3*c,0))),a(o,1,70,35,u);for(const l of n.eyes)a(r(l),1,45,35,new w);U(e)}function $e(e,t,n){const r=e.rig.joints.findIndex(c=>c.name===t);if(r<0)return[0,0,0];const i=e.poser.solve(n,{}).local[r].clone().invert().multiply(e.bones[r].quaternion),s=new oe().setFromQuaternion(i,"XYZ");return[s.x,s.y,s.z].map(c=>Math.round(re.radToDeg(c)*10)/10)}const T=new Map;function $(e){let t=T.get(e);return t||(t=e==="line"?new se({color:"#b8df78",depthTest:!1,transparent:!0,opacity:.9}):new ie({color:e==="picked"?"#ffad52":e==="end"?"#7fd6ff":"#b8df78",depthTest:!1,transparent:!0,opacity:.95}),t.userData.shared=!0,t.dispose=()=>{},T.set(e,t)),t}let z=null;function ze(e){const t=[];e.traverse(n=>{n.userData.rigOverlay&&t.push(n)});for(const n of t)n.parent?.remove(n),n instanceof F&&n.geometry.dispose()}function Ce(e,t,n=1){const r=e.size*.014*n;z??=(()=>{const o=new te(1,12,8);return o.userData.shared=!0,o.dispose=()=>{},o})(),e.rig.joints.forEach((o,i)=>{const s=e.bones[i],c=Q(e.rig.joints,o),u=new B(z,$(o.name===t?"picked":c?"end":"joint")),a=X(o.name)?.3:1;u.scale.setScalar(a*(o.name===t?r*1.5:c?r*.75:r)),u.userData.rigOverlay=!0,u.userData.rigJoint=o.name,u.renderOrder=1e3,u.layers.set(1),u.raycast=B.prototype.raycast,s.add(u);for(const p of e.bones.filter(l=>l.parent===s)){const l=new F(new ne().setFromPoints([new w,p.position.clone()]),$("line"));l.userData.rigOverlay=!0,l.renderOrder=999,l.layers.set(1),l.raycast=()=>{},s.add(l)}})}export{Ce as a,$e as b,Re as c,Ie as d,Se as e,je as f,Te as g,Pe as h,Be as o,qe as p,ze as r,Oe as w};
|
|
1
|
+
import{is as N,it as C,dV as Q,iu as V,iv as X,iw as Y,ix as Z,iy as K,dT as W,iz as ee}from"./remote-Dva2qg58.js";import{Vector3 as w,Line as F,SphereGeometry as te,Mesh as B,BufferGeometry as ne,Euler as oe,MathUtils as re,Box3 as _,LineBasicMaterial as se,MeshBasicMaterial as ie,Matrix4 as H,Bone as ae,Object3D as ce,Skeleton as ue,Uint16BufferAttribute as le,Float32BufferAttribute as de,SkinnedMesh as fe,Quaternion as pe,Sphere as he}from"./three.module-Bx43vjkH.js";const ye="clipoox-rig-weights",k="weights",ge=8;function R(){return new Promise(e=>{try{if(typeof indexedDB>"u")return e(null);const t=indexedDB.open(ye,1);t.onupgradeneeded=()=>{try{t.result.createObjectStore(k)}catch{}},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch{e(null)}})}async function me(e){const t=await R();if(!t)return null;try{return await new Promise(n=>{try{const r=t.transaction(k,"readonly").objectStore(k).get(e);r.onsuccess=()=>{const o=r.result;n(o?.data?.skinIndex instanceof Uint16Array?o.data:null)},r.onerror=()=>n(null)}catch{n(null)}})}finally{try{t.close()}catch{}}}async function we(e,t){const n=await R();if(n)try{await new Promise(r=>{try{const o=n.transaction(k,"readwrite"),i=o.objectStore(k);i.put({at:Date.now(),data:t},e);const s=[],c=i.openCursor();c.onsuccess=()=>{const u=c.result;u?(s.push({key:u.key,at:u.value.at||0}),u.continue()):s.sort((a,p)=>p.at-a.at).slice(ge).forEach(a=>i.delete(a.key))},o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()}catch{r()}})}finally{try{n.close()}catch{}}}async function be(){const e=await R();if(e)try{await new Promise(t=>{try{const n=e.transaction(k,"readwrite");n.objectStore(k).clear(),n.oncomplete=()=>t(),n.onerror=()=>t()}catch{t()}})}finally{try{e.close()}catch{}}}async function xe(e,t,n=!0){const r=`${N(e.positions,e.index)}|${e.rigKey}`;if(n){const i=await me(r).catch(()=>null);if(i)return t?.(1),{...i,source:"disk",key:r}}const o=C({positions:e.positions,index:e.index,joints:e.joints,onProgress:t});return n&&await we(r,o).catch(()=>{}),{...o,source:"computed",key:r}}function ve(e,t,n=!0){const r=async()=>({...await xe(e,t,n),via:"main"});if(typeof Worker>"u")return new Promise((s,c)=>setTimeout(()=>r().then(s,c),0));let o;try{o=new Worker(new URL("/assets/weights.worker-r1GBeQWE.js",import.meta.url),{type:"module"})}catch{return r()}const i={...e,positions:e.positions.slice(),index:e.index.slice()};return new Promise((s,c)=>{let u=!1;const a=()=>{if(!u){u=!0;try{o.terminate()}catch{}r().then(s,c)}};o.onmessage=p=>{p.data.type==="progress"?t?.(p.data.fraction??0):p.data.type==="done"&&!u?(u=!0,o.terminate(),s({...p.data.result,via:"worker"})):p.data.type==="error"&&a()},o.onerror=p=>{p.preventDefault?.(),a()};try{o.postMessage({input:i,disk:n},[i.positions.buffer,i.index.buffer])}catch{a()}})}const M=new Map,Me=12,ke=3e4,j=new Map,O=new Set,S=()=>O.forEach(e=>{try{e()}catch{}});function Be(e){return O.add(e),()=>{O.delete(e)}}function Oe(e){for(const n of j.values())if(n.modelKey===e)return{progress:n.progress,vertices:n.vertices};const t=L.get(e);return t&&Date.now()-t.at<G?{progress:1,vertices:t.vertices,done:!0}:null}const L=new Map,G=6e3;function Re(e){if(!e)M.clear();else for(const t of[...M.keys()])t.startsWith(`${e}|`)&&M.delete(t);be()}function A(e){e.updateMatrixWorld(!0);const t=e.matrixWorld.clone().invert(),n=[];return e.traverse(r=>{r instanceof B&&!r.userData.rigOverlay&&r.geometry?.getAttribute("position")&&n.push({mesh:r,matrix:t.clone().multiply(r.matrixWorld)})}),n}function je(e){const t=new _,n=new w;for(const{mesh:r,matrix:o}of A(e)){const i=r.geometry.getAttribute("position"),s=Math.max(1,Math.floor(i.count/2e4));for(let c=0;c<i.count;c+=s)t.expandByPoint(n.fromBufferAttribute(i,c).applyMatrix4(o))}return t}function Ie(e){let t=null,n=null;const r=new w;for(const{mesh:o,matrix:i}of A(e)){const s=o.geometry.getAttribute("position");for(let c=0;c<s.count;c++)r.fromBufferAttribute(s,c).applyMatrix4(i),(!t||r.x<t[0])&&(t=[r.x,r.y,r.z]),(!n||r.x>n[0])&&(n=[r.x,r.y,r.z])}return t&&n?{L:t,R:n}:null}function Se(e,t=A(e)){const n=t.reduce((a,{mesh:p})=>a+p.geometry.getAttribute("position").count,0),r=t.reduce((a,{mesh:p})=>a+(p.geometry.index?.count??p.geometry.getAttribute("position").count),0),o=new Float32Array(n*3),i=new Uint32Array(r),s=new w;let c=0,u=0;for(const{mesh:a,matrix:p}of t){const l=a.geometry,g=l.getAttribute("position");for(let y=0;y<g.count;y++)s.fromBufferAttribute(g,y).applyMatrix4(p),o[(c+y)*3]=s.x,o[(c+y)*3+1]=s.y,o[(c+y)*3+2]=s.z;if(l.index)for(let y=0;y<l.index.count;y++)i[u++]=c+l.index.getX(y);else for(let y=0;y<g.count;y++)i[u++]=c+y;c+=g.count}return{positions:o,index:i}}function E(e,t,n,r,o){const i=[];let s=0;for(const{mesh:u}of t){const a=u.geometry.getAttribute("position").count;i.push({skinIndex:n.skinIndex.slice(s*4,(s+a)*4),skinWeight:n.skinWeight.slice(s*4,(s+a)*4)}),s+=a}const c={perMesh:i,radius:n.boneRadius,spheres:n.boneSpheres,vertices:n.vertices,ms:n.ms,source:r,via:o};for(M.set(e,c);M.size>Me;)M.delete(M.keys().next().value);return c}function Ae(e,t,n,r={}){const o=A(e),i=o.map(({mesh:f})=>`${f.geometry.getAttribute("position").count}:${f.geometry.index?.count??0}`).join(","),s=`${n}|${i}|${W(t)}`,c=M.get(s);if(c)return{meshes:o,weights:c,cached:!0,key:s,job:null};const u=j.get(s);if(u)return{meshes:o,weights:null,cached:!1,key:s,job:u.promise};const a=o.reduce((f,{mesh:h})=>f+h.geometry.getAttribute("position").count,0),p=Se(e,o),l=W(t);if(o.length&&o.every(({mesh:f})=>f.geometry.userData.rigWeights===l&&f.geometry.getAttribute("skinIndex"))){const f=new Uint16Array(a*4),h=new Float32Array(a*4);let d=0;for(const{mesh:m}of o){const v=m.geometry;f.set(v.getAttribute("skinIndex").array,d*4),h.set(v.getAttribute("skinWeight").array,d*4),d+=v.getAttribute("position").count}const x=ee({positions:p.positions,skinIndex:f,skinWeight:h,joints:t.joints});return{meshes:o,weights:E(s,o,{skinIndex:f,skinWeight:h,...x,vertices:a,ms:0},"computed","main"),cached:!1,key:s,job:null}}if(a<=ke&&r.background!==!0){const f=C({...p,joints:t.joints});return f.vertices,Math.round(f.ms),{meshes:o,weights:E(s,o,f,"computed","main"),cached:!1,key:s,job:null}}const g={promise:Promise.resolve(),progress:0,vertices:a,modelKey:n};let y=0;return g.promise=ve({...p,joints:t.joints,rigKey:W(t)},f=>{g.progress=f,y++,S()}).then(f=>{E(s,o,f,f.source,f.via),g.via=f.via,f.via,f.source,f.vertices,Math.round(f.ms)}).catch(f=>{console.warn("[rig] weights",f.message)}).finally(()=>{j.delete(s),L.set(n,{at:Date.now(),vertices:a}),S(),setTimeout(S,G+50)}),j.set(s,g),S(),{meshes:o,weights:null,cached:!1,key:s,job:g.promise}}function Pe(e,t,n,r){if(!t.joints.length)return null;const{meshes:o,weights:i,cached:s,key:c,job:u}=Ae(e,t,n);if(!o.length)return null;u&&r?.(`rig:${c}`,u);const a=t.joints.map(h=>{const d=new ae;return d.name=h.name,d.userData.rigBone=h.name,d});if(t.joints.forEach((h,d)=>{const x=h.parent?t.joints.findIndex(v=>v.name===h.parent):-1,m=new w(...h.pos);x<0?(a[d].position.copy(m),e.add(a[d])):(a[d].position.copy(m.sub(new w(...t.joints[x].pos))),a[x].add(a[d]))}),t.kind==="humanoid")for(const h of["L","R"]){const d=Y(t,h),x=t.joints.findIndex(v=>v.name===`wrist${h}`);if(!d||x<0)continue;const m=new ce;m.name=`rigHold${h}`,m.userData.rigHold=h,m.position.copy(d.position),m.quaternion.copy(d.quaternion),m.scale.setScalar(d.scale),a[x].add(m)}e.updateMatrixWorld(!0);const p=[];if(i){const h=new ue(a);o.forEach(({mesh:d},x)=>{const m=d.geometry,v=i.perMesh[x];m.setAttribute("skinIndex",new le(v.skinIndex,4)),m.setAttribute("skinWeight",new de(v.skinWeight,4));const b=new fe(m,d.material);b.name=d.name,b.castShadow=d.castShadow,b.receiveShadow=d.receiveShadow,b.position.copy(d.position),b.quaternion.copy(d.quaternion),b.scale.copy(d.scale),b.frustumCulled=!0,b.userData.rigSkinned=!0,b.userData.slots=d.userData.slots;const I=d.parent;I.add(b),I.remove(d);for(const J of[...d.children])b.add(J);p.push(b)}),e.updateMatrixWorld(!0);for(const d of p)d.bind(h,d.matrixWorld)}const l=je(e),g=Math.max(.001,...l.getSize(new w).toArray()),y=i?void 0:[...j.values()].find(h=>h.promise===u),f={rig:t,bones:a,poser:Z(t,i?.radius??null),meshes:p,rootRest:a[0].position.clone(),size:g,center:l.getCenter(new w),info:i?{vertices:i.vertices,ms:Math.round(i.ms),cached:s,source:s?i.source==="disk"?"disk":"memory":i.source,via:i.via}:{vertices:y?.vertices??0,ms:0,cached:!1,source:"pending",progress:y?.progress??0},spheres:i?.spheres??null};return e.userData.rig=f,f}const D=new H,P=new H,T=new w,We=new w;function U(e){const t=e.spheres;if(!(!t||!e.meshes.length))for(const n of e.meshes){n.updateMatrixWorld(!0),P.copy(n.matrixWorld).invert();const r=[],o=[];if(e.bones.forEach((u,a)=>{const p=t[a*4+3];if(!(p>0))return;const l=e.rig.joints[a].pos;D.multiplyMatrices(P,u.matrixWorld),r.push(We.set(t[a*4]-l[0],t[a*4+1]-l[1],t[a*4+2]-l[2]).applyMatrix4(D).clone()),o.push(p*D.getMaxScaleOnAxis())}),!r.length)continue;const i=new _;r.forEach((u,a)=>{i.expandByPoint(T.copy(u).addScalar(o[a])),i.expandByPoint(T.copy(u).addScalar(-o[a]))});const s=i.getCenter(new w);let c=0;r.forEach((u,a)=>{c=Math.max(c,u.distanceTo(s)+o[a])}),n.boundingSphere=new he(s,c),n.boundingBox=i}}function Te(e,t,n,r=!1){if(r)e.bones.forEach(o=>o.quaternion.identity()),e.bones[0].position.copy(e.rootRest);else{const{local:o,shift:i}=e.poser.solve(t,n||{});e.bones.forEach((s,c)=>s.quaternion.copy(o[c])),e.bones[0].position.copy(e.rootRest),e.bones[0].position.y+=i}e.bones[0].updateMatrixWorld(!0),U(e)}function qe(e,t){const n=X(e.rig),r=l=>l?e.bones[e.rig.joints.findIndex(g=>g.name===l)]:void 0,o=r(n.head),i=e.rig.joints.find(l=>l.name==="headTop"),s=e.rig.joints.find(l=>l.name===n.head),c=i&&s?Math.max(.05,i.pos[1]-s.pos[1]):.25,u=new w(0,.55*c,.3*c),a=(l,g,y,f,h)=>{if(!l)return;l.updateWorldMatrix(!0,!1);const d=l.worldToLocal(t.clone()).sub(h);l.quaternion.multiply(new pe().setFromEuler(K(d,y,f,g))),l.updateMatrixWorld(!0)},p=r(n.neck);p&&a(p,.4,30,15,u.clone().add(new w(0,.3*c,0))),a(o,1,70,35,u);for(const l of n.eyes)a(r(l),1,45,35,new w);U(e)}function $e(e,t,n){const r=e.rig.joints.findIndex(c=>c.name===t);if(r<0)return[0,0,0];const i=e.poser.solve(n,{}).local[r].clone().invert().multiply(e.bones[r].quaternion),s=new oe().setFromQuaternion(i,"XYZ");return[s.x,s.y,s.z].map(c=>Math.round(re.radToDeg(c)*10)/10)}const q=new Map;function $(e){let t=q.get(e);return t||(t=e==="line"?new se({color:"#b8df78",depthTest:!1,transparent:!0,opacity:.9}):new ie({color:e==="picked"?"#ffad52":e==="end"?"#7fd6ff":"#b8df78",depthTest:!1,transparent:!0,opacity:.95}),t.userData.shared=!0,t.dispose=()=>{},q.set(e,t)),t}let z=null;function ze(e){const t=[];e.traverse(n=>{n.userData.rigOverlay&&t.push(n)});for(const n of t)n.parent?.remove(n),n instanceof F&&n.geometry.dispose()}function Ce(e,t,n=1){const r=e.size*.014*n;z??=(()=>{const o=new te(1,12,8);return o.userData.shared=!0,o.dispose=()=>{},o})(),e.rig.joints.forEach((o,i)=>{const s=e.bones[i],c=Q(e.rig.joints,o),u=new B(z,$(o.name===t?"picked":c?"end":"joint")),a=V(o.name)?.3:1;u.scale.setScalar(a*(o.name===t?r*1.5:c?r*.75:r)),u.userData.rigOverlay=!0,u.userData.rigJoint=o.name,u.renderOrder=1e3,u.layers.set(1),u.raycast=B.prototype.raycast,s.add(u);for(const p of e.bones.filter(l=>l.parent===s)){const l=new F(new ne().setFromPoints([new w,p.position.clone()]),$("line"));l.userData.rigOverlay=!0,l.renderOrder=999,l.layers.set(1),l.raycast=()=>{},s.add(l)}})}export{Ce as a,$e as b,Re as c,Ie as d,Se as e,je as f,qe as g,Pe as h,Be as o,Te as p,ze as r,Oe as w};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Color as YA,DataArrayTexture as pA,RGBAIntegerFormat as BA,UnsignedIntType as v,RawShaderMaterial as RQ,Vector3 as F,DataTexture as lI,RGIntegerFormat as FQ,BufferGeometry as Ww,ShaderMaterial as cB,Texture as jw,Data3DTexture as vw,Vector4 as gI,Box3 as dg,Matrix4 as FA,Matrix3 as Hg,InstancedBufferGeometry as JC,BufferAttribute as QQ,InstancedBufferAttribute as zw,DynamicDrawUsage as _w,Object3D as Lg,WebGLArrayRenderTarget as kB,NearestFilter as og,Quaternion as Z,Loader as $w,FileLoader as As,GLSL3 as RB,Vector2 as OA,Euler as Yg,Mesh as BQ,DoubleSide as UC,Clock as FB,Matrix2 as nC,WebGLCubeRenderTarget as eC,LinearMipMapLinearFilter as HC,RGBAFormat as sI,CubeCamera as LC,PMREMGenerator as YC,MeshStandardMaterial as CQ,WebGLRenderTarget as EQ,SRGBColorSpace as iQ,UnsignedByteType as nI,PerspectiveCamera as vQ,Raycaster as gC,OrthographicCamera as Is,LinearSRGBColorSpace as gs,LinearFilter as QC,Camera as zQ,UnsignedShortType as Qs,FloatType as Bs,REVISION as Cs,ShaderChunk as Es}from"./three.module-Bx43vjkH.js";import{
|
|
1
|
+
import{Color as YA,DataArrayTexture as pA,RGBAIntegerFormat as BA,UnsignedIntType as v,RawShaderMaterial as RQ,Vector3 as F,DataTexture as lI,RGIntegerFormat as FQ,BufferGeometry as Ww,ShaderMaterial as cB,Texture as jw,Data3DTexture as vw,Vector4 as gI,Box3 as dg,Matrix4 as FA,Matrix3 as Hg,InstancedBufferGeometry as JC,BufferAttribute as QQ,InstancedBufferAttribute as zw,DynamicDrawUsage as _w,Object3D as Lg,WebGLArrayRenderTarget as kB,NearestFilter as og,Quaternion as Z,Loader as $w,FileLoader as As,GLSL3 as RB,Vector2 as OA,Euler as Yg,Mesh as BQ,DoubleSide as UC,Clock as FB,Matrix2 as nC,WebGLCubeRenderTarget as eC,LinearMipMapLinearFilter as HC,RGBAFormat as sI,CubeCamera as LC,PMREMGenerator as YC,MeshStandardMaterial as CQ,WebGLRenderTarget as EQ,SRGBColorSpace as iQ,UnsignedByteType as nI,PerspectiveCamera as vQ,Raycaster as gC,OrthographicCamera as Is,LinearSRGBColorSpace as gs,LinearFilter as QC,Camera as zQ,UnsignedShortType as Qs,FloatType as Bs,REVISION as Cs,ShaderChunk as Es}from"./three.module-Bx43vjkH.js";import{ic as SB}from"./remote-Dva2qg58.js";import"./api-DUp403BK.js";import"./titleFrameBudget-BYRZAQPs.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";class _Q extends JC{constructor(A,I){super(),this.ordering=A,this.setAttribute("position",new QQ(is,3)),this.setIndex(new QQ(Ds,1)),this._maxInstanceCount=A.length,this.instanceCount=I,this.attribute=new zw(A,1,!1,1),this.attribute.setUsage(_w),this.setAttribute("splatIndex",this.attribute)}update(A,I){this.ordering=A,this.attribute.array=A,this.instanceCount=I,this.attribute.addUpdateRange(0,I),this.attribute.needsUpdate=!0}}const is=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),Ds=new Uint16Array([0,1,2,0,2,3]),rC=`(function() {
|
|
2
2
|
"use strict";
|
|
3
3
|
class CsplatArray {
|
|
4
4
|
static __wrap(ptr) {
|