clipoox-render 0.2.0 → 0.3.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.
Files changed (131) hide show
  1. package/dist/server-text/titleRaster.js +1394 -0
  2. package/package.json +5 -3
  3. package/scripts/render-local.mjs +1514 -1379
  4. package/shared/transitionStarterPack.json +261 -0
  5. package/web/assets/{FxEmbed-BymBArNa.js → FxEmbed-D7k1ThAF.js} +1 -1
  6. package/web/assets/{GLTFLoader-Dy6SrZg8.js → GLTFLoader-BHWu1lKg.js} +1 -1
  7. package/web/assets/{MotionEmbed-PmXWSWe5.js → MotionEmbed-DFni5IAh.js} +1 -1
  8. package/web/assets/PluginStore-BrupM_8E.js +3 -0
  9. package/web/assets/{ShotComposer-Dprx-Yi7.js → ShotComposer-BLztjSKy.js} +4 -4
  10. package/web/assets/TemplateEmbed-BbAimhLj.js +2 -0
  11. package/web/assets/TimelinePlugins-BI1bE9pX.js +5 -0
  12. package/web/assets/TimelinePlugins-DYarX9RK.css +1 -0
  13. package/web/assets/TimelineShotFx-CQN3WIfN.js +2 -0
  14. package/web/assets/TransitionEmbed-CmoIrHVr.js +1 -0
  15. package/web/assets/{Whiteboard-DybaKCdo.js → Whiteboard-DMk0unYK.js} +3 -3
  16. package/web/assets/aerial-DT_gUtSh.js +2 -0
  17. package/web/assets/{agentTools-CxZqRLeR.js → agentTools-qOww5RUs.js} +2 -2
  18. package/web/assets/analyzerRun-B2FLUp4G.js +1 -0
  19. package/web/assets/{analyzerSandbox-DO5ZTv5q.js → analyzerSandbox-CJVsEhrg.js} +2 -2
  20. package/web/assets/{api-BsKbf3l3.js → api-QBI5GJTZ.js} +148 -148
  21. package/web/assets/auraTrack-CEs_Q9EP.js +1 -0
  22. package/web/assets/{breakthrough-Dv1bndQb.js → breakthrough-DvkxvNK9.js} +2 -2
  23. package/web/assets/{cameraPresets-B234aNzE.js → cameraPresets-4pFeF2YG.js} +1 -1
  24. package/web/assets/{captionLayout-CNgb471H.js → captionLayout-C67EMVI1.js} +1 -1
  25. package/web/assets/{clientExport-NtJmxOYP.js → clientExport-C4VgAJtO.js} +1 -1
  26. package/web/assets/{depthEstimate-wVYSJtW8.js → depthEstimate-mnXDZMW-.js} +1 -1
  27. package/web/assets/{directorTools-BqFcShgT.js → directorTools-BOHZjcww.js} +1 -1
  28. package/web/assets/{distortFrames-D3TQNcJA.js → distortFrames-Csuj2jHE.js} +2 -2
  29. package/web/assets/{distortGL-BklPDXPq.js → distortGL-BaXfN0IK.js} +2 -2
  30. package/web/assets/{editTools-BQlG5WB_.js → editTools-m0VGPmfF.js} +1 -1
  31. package/web/assets/{exportEncode-CaKEPgsy.js → exportEncode-D9OT7_5k.js} +1 -1
  32. package/web/assets/{exportGlb-DstxwzH5.js → exportGlb-CLfTnbMG.js} +1 -1
  33. package/web/assets/faceTracker-W0iZSiMe.js +1 -0
  34. package/web/assets/fightDirector-CECPf2iH.js +1 -0
  35. package/web/assets/{fightDrama-G7bXfpQu.js → fightDrama-CqNoa5XI.js} +2 -2
  36. package/web/assets/{frameSink-Dj71jCRb.js → frameSink-BGRj7wqY.js} +3 -3
  37. package/web/assets/{gpuCompose-DIxBHlTa.js → gpuCompose-CIEoLFem.js} +1 -1
  38. package/web/assets/gpuExport-uyOAyrhm.js +190 -0
  39. package/web/assets/handMatte-mHxZwLZD.js +1 -0
  40. package/web/assets/handTracker-dTVeSUzt.js +2 -0
  41. package/web/assets/{index-CZn97Ygs.js → index-D7M5t2re.js} +1 -1
  42. package/web/assets/layer-worker-Cp0pjurp.js +5 -0
  43. package/web/assets/library-Dsz_MLyd.js +1 -0
  44. package/web/assets/{lottieLayer-CfUPParC.js → lottieLayer-CDCGeJyv.js} +5 -5
  45. package/web/assets/{lottie_light_canvas-7iv3btPX.js → lottie_light_canvas-BblLU4nU.js} +1 -1
  46. package/web/assets/main-BQ8IY0WV.css +1 -0
  47. package/web/assets/{main-M1vRa-gd.js → main-CVRIuDW2.js} +76 -76
  48. package/web/assets/{mapBake-lPNhNZgv.js → mapBake-CNMOKXA7.js} +1 -1
  49. package/web/assets/maskTrack-Dtv6Jr06.js +1 -0
  50. package/web/assets/matteFixRun-BLDH2AjH.js +1 -0
  51. package/web/assets/{objectLocate-BDqfSo9J.js → objectLocate-Cy3IFBSF.js} +1 -1
  52. package/web/assets/{objectTrack.worker-ENzKeSiV.js → objectTrack.worker-BlZkgpOX.js} +483 -352
  53. package/web/assets/pendingMatte-C2AWApuv.js +2 -0
  54. package/web/assets/personAi-DPUnoymj.js +2 -0
  55. package/web/assets/plateCamera-C96L5GKm.js +1 -0
  56. package/web/assets/{plateCameraMatch-D41LQrsm.js → plateCameraMatch-Chk-ZjDi.js} +2 -2
  57. package/web/assets/{plateFollow-CNfi4xuP.js → plateFollow-B9_QTgvo.js} +2 -2
  58. package/web/assets/plateMatte-BiqyI_8x.js +2 -0
  59. package/web/assets/{pluginAutomation-BtQ_w2TB.js → pluginAutomation-5DYldFrb.js} +1 -1
  60. package/web/assets/poseTracker-PuI8vWpR.js +1 -0
  61. package/web/assets/{productTools-r2RgILaA.js → productTools-B1h5cgyt.js} +2 -2
  62. package/web/assets/remote-BJdzzFZg.js +1241 -0
  63. package/web/assets/{rigTrack-Bx9QHlFv.js → rigTrack-CUt4O67J.js} +1 -1
  64. package/web/assets/{rotoMaskStore-pxpRt5Cj.js → rotoMaskStore-DIi45swK.js} +1 -1
  65. package/web/assets/{rotoMatte-DyXlW4jK.js → rotoMatte-013RKqHu.js} +1 -1
  66. package/web/assets/{rotoscope-GORCSVBr.js → rotoscope-d_TUxa-J.js} +1 -1
  67. package/web/assets/{sceneTrack.worker-CEvCN5OB.js → sceneTrack.worker-CT4uoTKn.js} +475 -344
  68. package/web/assets/{shot-worker-B8JWkmBz.js → shot-worker-B1iZT6F5.js} +1 -1
  69. package/web/assets/{shotFxAgent-CzHfe75S.js → shotFxAgent-BDfe73TP.js} +2 -2
  70. package/web/assets/{skin-BkaT2QuX.js → skin-GDY3QPkV.js} +1 -1
  71. package/web/assets/{spark.module-BRT8yMS4.js → spark.module-DdwuJ_hb.js} +1 -1
  72. package/web/assets/{spellDuel-BUy289OT.js → spellDuel-DjNN00bv.js} +2 -2
  73. package/web/assets/{store-BSSbvpzr.js → store-2zneEhhu.js} +1 -1
  74. package/web/assets/{surfaceLight-CMaBhZ_d.js → surfaceLight-B_SYg_f8.js} +1 -1
  75. package/web/assets/surfacePin-zDPmq-hH.js +2 -0
  76. package/web/assets/{textAnimators-Cihw35O8.js → textAnimators-Bdt5LWXk.js} +1 -1
  77. package/web/assets/{thumb-Cs636sYt.js → thumb-byAKvhQP.js} +1 -1
  78. package/web/assets/timeline3d-YIIk_Kn2.js +2 -0
  79. package/web/assets/timeline3dExport-CEH1RjNf.js +1 -0
  80. package/web/assets/{timelineComp-CRRzLazc.js → timelineComp-B73i_8vD.js} +1 -1
  81. package/web/assets/{timelineProps-tN2YsMYN.js → timelineProps-B2pnudeT.js} +1 -1
  82. package/web/assets/{timelineText-CkoUgWcY.js → timelineText-BcL4Pw3C.js} +1 -1
  83. package/web/assets/{titleArt-CcTdJuOC.js → titleArt-hb_T45WJ.js} +5 -5
  84. package/web/assets/{titleFrameBudget-3MFHWIT6.js → titleFrameBudget-Cml-MO53.js} +970 -839
  85. package/web/assets/titleFrames-Dw0PEBdV.js +1 -0
  86. package/web/assets/{tool-BhIsq238.js → tool-Bt9bclIf.js} +1 -1
  87. package/web/assets/{tools-DMUnabc_.js → tools-BXeJbgZJ.js} +1 -1
  88. package/web/assets/{toonTools-CICrV3QB.js → toonTools-u7Y9fdEZ.js} +2 -2
  89. package/web/assets/trackAnchor-9MnVHe4S.js +1 -0
  90. package/web/assets/{userFonts-BZ4QL-zq.js → userFonts-BHduCNtc.js} +1 -1
  91. package/web/assets/{vfxAlpha-D3Dk1tfF.js → vfxAlpha-DpV4rbI-.js} +1 -1
  92. package/web/assets/vfxBackground-Ddviync5.js +2 -0
  93. package/web/assets/{videoExport-l5MGvMn_.js → videoExport-z5WjM0hw.js} +1 -1
  94. package/web/assets/{views-BdWnG2xK.js → views-CsrYzCSR.js} +1 -1
  95. package/web/assets/weaponDuel-CLLgv5A4.js +1 -0
  96. package/web/assets/{windowFrames-CoIyWqxr.js → windowFrames-BQEWQkEs.js} +1 -1
  97. package/web/layer-worker.html +3 -3
  98. package/web/assets/PluginStore-BVsm6n6N.js +0 -3
  99. package/web/assets/TemplateEmbed-CrZXoUk_.js +0 -2
  100. package/web/assets/TimelinePlugins-B1KGtbmb.js +0 -5
  101. package/web/assets/TimelinePlugins-B5WmAawO.css +0 -1
  102. package/web/assets/TimelineShotFx-DoLx312Y.js +0 -2
  103. package/web/assets/TransitionEmbed-C5SUosv2.js +0 -1
  104. package/web/assets/aerial-DSt_mJNA.js +0 -2
  105. package/web/assets/analyzerRun-DCJwb_-Z.js +0 -1
  106. package/web/assets/auraTrack-QR0WqBHp.js +0 -1
  107. package/web/assets/desktop-BWhFnYwd.js +0 -1
  108. package/web/assets/faceTracker-DWxxieVC.js +0 -1
  109. package/web/assets/fightDirector-OMlPZgjv.js +0 -1
  110. package/web/assets/gpuExport-CPSw_dmq.js +0 -189
  111. package/web/assets/handMatte-DHsHHz4m.js +0 -1
  112. package/web/assets/handTracker-D_O-C4Dw.js +0 -2
  113. package/web/assets/layer-worker-Bar7WgOA.js +0 -5
  114. package/web/assets/library-BtBrCaFk.js +0 -1
  115. package/web/assets/main-BPmr0TOL.css +0 -1
  116. package/web/assets/maskTrack-D2jUh7aw.js +0 -1
  117. package/web/assets/matteFixRun-B7tWV9Y1.js +0 -1
  118. package/web/assets/pendingMatte-q35zVaiB.js +0 -2
  119. package/web/assets/personAi-ZjQVo-80.js +0 -2
  120. package/web/assets/plateCamera-A2E_WO_x.js +0 -1
  121. package/web/assets/plateMatte-BdIxGhw5.js +0 -2
  122. package/web/assets/poseTracker-DVX__OK7.js +0 -1
  123. package/web/assets/remote-sTZauTqM.js +0 -1220
  124. package/web/assets/surfacePin-DM9b9ubh.js +0 -2
  125. package/web/assets/timeline3d-BEuZZOxM.js +0 -2
  126. package/web/assets/timeline3dExport-CmSI_pjv.js +0 -1
  127. package/web/assets/titleFrames-w-iWje9N.js +0 -1
  128. package/web/assets/trackAnchor-D2bB5mZE.js +0 -1
  129. package/web/assets/vfxBackground-CHlCg8lb.js +0 -2
  130. package/web/assets/vfxTrack-CqiQDEYm.js +0 -1
  131. package/web/assets/weaponDuel-B2wTffPC.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pendingMatte-q35zVaiB.js","assets/titleFrameBudget-3MFHWIT6.js","assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js","assets/main-M1vRa-gd.js","assets/spark.module-BRT8yMS4.js","assets/userFonts-BZ4QL-zq.js","assets/lottieLayer-CfUPParC.js","assets/desktop-BWhFnYwd.js","assets/timeline3d-BEuZZOxM.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-CaKEPgsy.js","assets/captionLayout-CNgb471H.js","assets/timelineText-CkoUgWcY.js","assets/titleArt-CcTdJuOC.js","assets/rotoMatte-DyXlW4jK.js","assets/distortGL-BklPDXPq.js","assets/motionBlur-uAm030t9.js","assets/main-BPmr0TOL.css"])))=>i.map(i=>d[i]);
2
- import{b_ as L,c0 as ft,mL as j,dF as pt,dD as dt,mM as gt,mN as R,mO as yt,mP as ct,dK as wt,dP as kt,dS as tt,b$ as V,mQ as Mt,mR as bt,dT as xt,fp as vt,mS as St,dR as Pt,mT as Tt,_ as Ft,a7 as At,bY as Et,bZ as _t,dz as qt,mU as Ct,mV as It,mW as Ot}from"./titleFrameBudget-3MFHWIT6.js";import{T as lt,U as Dt,V as Nt,X as Rt,Y as Vt,Z as Kt,_ as et}from"./main-M1vRa-gd.js";import{h_ as Bt,h$ as Qt}from"./remote-sTZauTqM.js";import{measureSurfaceLight as Ut}from"./surfaceLight-CMaBhZ_d.js";import{u as C}from"./store-BSSbvpzr.js";import{F as Y,J as Z,I as nt,U as zt,V as Gt}from"./rotoMaskStore-pxpRt5Cj.js";import{t as A}from"./api-BsKbf3l3.js";import"./three.module-Bx43vjkH.js";import"./spark.module-BRT8yMS4.js";import"./timelineComp-CRRzLazc.js";import"./textAnimators-Cihw35O8.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./rigTrack-Bx9QHlFv.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./GLTFLoader-Dy6SrZg8.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";const rt=(t,a,m,n,e)=>{if(n<0||e<0||n>a-1.001||e>m-1.001)return NaN;const h=Math.floor(n),o=Math.floor(e),i=n-h,c=e-o,r=o*a+h;return(t[r]*(1-i)+t[r+1]*i)*(1-c)+(t[r+a]*(1-i)+t[r+a+1]*i)*c};function ot(t,a,m,n,e,h,{radius:o=10,samples:i=28,min:c=10,sign:r=null}={}){const s=Math.hypot(e[0]-n[0],e[1]-n[1]);if(s<8)return null;const f=[(e[0]-n[0])/s,(e[1]-n[1])/s];let u=[-f[1],f[0]];const l=[(n[0]+e[0])/2,(n[1]+e[1])/2];(l[0]-h[0])*u[0]+(l[1]-h[1])*u[1]<0&&(u=[-u[0],-u[1]]);const p={drop:[],rise:[]};for(let S=0;S<i;S++){const F=.08+.84*S/(i-1),x=[n[0]+(e[0]-n[0])*F,n[1]+(e[1]-n[1])*F];let k=null,M=null;for(let v=-o;v<=o;v+=.5){const _=x[0]+u[0]*v,q=x[1]+u[1]*v,P=rt(t,a,m,_+u[0],q+u[1])-rt(t,a,m,_-u[0],q-u[1]);if(!Number.isFinite(P)||Math.abs(P)<c)continue;const E=Math.abs(P)*(1-.7*Math.abs(v)/o);P<0&&(!k||E>k.score)&&(k={x:_,y:q,score:E}),P>0&&(!M||E>M.score)&&(M={x:_,y:q,score:E})}k&&p.drop.push(k),M&&p.rise.push(M)}const g=S=>S.reduce((F,x)=>F+x.score,0),d=r?p[r]:g(p.drop)*1.25>=g(p.rise)?p.drop:p.rise;if(d.length<i*.5)return null;const w=(S,F,x)=>{const k=x.x-F.x,M=x.y-F.y,v=Math.hypot(k,M)||1;return Math.abs((S.x-F.x)*M-(S.y-F.y)*k)/v};let y=null;for(let S=0;S<d.length;S++)for(let F=S+2;F<d.length;F++){const x=d.filter(k=>w(k,d[S],d[F])<=1.2);(!y||x.length>y.length||x.length===y.length&&x.reduce((k,M)=>k+M.score,0)>y.reduce((k,M)=>k+M.score,0))&&(y=x)}if(!y||y.length<i*.4)return null;const b=Ht(y);return b&&{...b,inliers:y.length/i}}function Ht(t){if(t.length<2)return null;let a=0,m=0;for(const i of t)a+=i.x,m+=i.y;a/=t.length,m/=t.length;let n=0,e=0,h=0;for(const i of t){const c=i.x-a,r=i.y-m;n+=c*c,e+=c*r,h+=r*r}const o=.5*Math.atan2(2*e,n-h);return{p:[a,m],d:[Math.cos(o),Math.sin(o)]}}const H=(t,a)=>{const m=t.d[0]*a.d[1]-t.d[1]*a.d[0];if(Math.abs(m)<1e-6)return null;const n=((a.p[0]-t.p[0])*a.d[1]-(a.p[1]-t.p[1])*a.d[0])/m;return[t.p[0]+t.d[0]*n,t.p[1]+t.d[1]*n]},$t=t=>{let a=0;for(let m=0;m<4;m++){const n=t[m],e=t[(m+1)%4],h=t[(m+2)%4],o=(e[0]-n[0])*(h[1]-e[1])-(e[1]-n[1])*(h[0]-e[0]);if(!o||a&&Math.sign(o)!==a)return!1;a=Math.sign(o)}return!0};function at(t,a,m,n,e={}){const h=e.radius??10,o=[n.reduce((l,p)=>l+p[0],0)/4,n.reduce((l,p)=>l+p[1],0)/4],i=l=>[0,1,2,3].map(p=>ot(t,a,m,n[p],n[(p+1)%4],o,{...e,sign:l})),c=l=>l.every(Boolean)?l.reduce((p,g)=>p+g.inliers,0):-1,r=i("drop"),s=i("rise"),f=c(r)*1.15>=c(s)?r:s;if(f.some(l=>!l))return null;const u=[H(f[3],f[0]),H(f[0],f[1]),H(f[1],f[2]),H(f[2],f[3])];if(u.some(l=>!l)||!$t(u)||u.some((l,p)=>Math.hypot(l[0]-n[p][0],l[1]-n[p][1])>2*h))return null;if(e.clean){const l=f===r?"drop":"rise",p=[u.reduce((d,w)=>d+w[0],0)/4,u.reduce((d,w)=>d+w[1],0)/4],g=[0,1,2,3].map(d=>ot(t,a,m,u[d],u[(d+1)%4],p,{...e,radius:Math.min(h,4),samples:48,sign:l}));if(g.some(d=>!d)||g.filter(d=>d.inliers>=.97).length<3||g.some(d=>d.inliers<.6))return null}return u}function Lt(t,a,{jump:m=3}={}){const n=t.length,e=t.map((i,c)=>i??null);for(let i=0;i<n;i++)if(!e[i]){let c=i-1;for(;c>=0&&!t[c];)c--;let r=i+1;for(;r<n&&!t[r];)r++;e[i]=c>=0&&r<n?t[c].map((s,f)=>s.map((u,l)=>u+(t[r][f][l]-u)*(i-c)/(r-c))):c>=0?t[c]:r<n?t[r]:a[i]}const h=e.map((i,c)=>i.map((r,s)=>r.map((f,u)=>{const l=[];for(let p=-2;p<=2;p++){const g=e[Math.min(n-1,Math.max(0,c+p))];l.push(g[s][u])}return l.sort((p,g)=>p-g),l[2]}))),o=e.map((i,c)=>i.map((r,s)=>Math.hypot(r[0]-h[c][s][0],r[1]-h[c][s][1])>m?h[c][s]:r));return o.map((i,c)=>i.map((r,s)=>r.map((f,u)=>{let l=0,p=0;for(let g=-1;g<=1;g++){const d=o[c+g];d&&(l+=d[s][u],p++)}return l/p})))}const it=[15,100],st=46,K=(t,a)=>t[0]*a[0]+t[1]*a[1]+t[2]*a[2],mt=t=>Math.hypot(...t),z=t=>{const a=mt(t)||1;return t.map(m=>m/a)},W=(t,a)=>[t[1]*a[2]-t[2]*a[1],t[2]*a[0]-t[0]*a[2],t[0]*a[1]-t[1]*a[0]],J=(t,a)=>t.map(m=>[0,1,2].map(n=>m[0]*a[0][n]+m[1]*a[1][n]+m[2]*a[2][n])),Wt=t=>[0,1,2].map(a=>[0,1,2].map(m=>t[m][a]));function Xt(t){const a=t.map(n=>[...n]),m=[[1,0,0],[0,1,0],[0,0,1]];for(let n=0;n<60;n++){let e=0,h=1;if(Math.abs(a[0][2])>Math.abs(a[e][h])&&(e=0,h=2),Math.abs(a[1][2])>Math.abs(a[e][h])&&(e=1,h=2),Math.abs(a[e][h])<1e-15)break;const o=(a[h][h]-a[e][e])/(2*a[e][h]),i=(o>=0?1:-1)/(Math.abs(o)+Math.sqrt(o*o+1)),c=1/Math.sqrt(i*i+1),r=i*c;for(let s=0;s<3;s++){const f=a[s][e],u=a[s][h];a[s][e]=c*f-r*u,a[s][h]=r*f+c*u}for(let s=0;s<3;s++){const f=a[e][s],u=a[h][s];a[e][s]=c*f-r*u,a[h][s]=r*f+c*u}for(let s=0;s<3;s++){const f=m[s][e],u=m[s][h];m[s][e]=c*f-r*u,m[s][h]=r*f+c*u}}return[0,1,2].map(n=>({v:a[n][n],e:[m[0][n],m[1][n],m[2][n]]})).sort((n,e)=>e.v-n.v)}function Yt(t){const a=J(Wt(t),t),[m,n,e]=Xt(a),h=Math.sqrt(Math.max(1e-18,n.v)),o=m.v/(h*h),i=e.v/(h*h);if(o-i<2e-4)return null;const c=Math.sqrt(o-i),r=Math.sqrt(Math.max(0,1-i)),s=Math.sqrt(Math.max(0,o-1)),f=m.e.map((p,g)=>(r*p+s*e.e[g])/c),u=m.e.map((p,g)=>(r*p-s*e.e[g])/c),l=[W(n.e,f),W(n.e,u)].map(p=>(p=z(p),p[2]<0?p.map(g=>-g):p));return l.w=o-i,l}const Zt=t=>[[t[0],t[1],t[2]],[t[3],t[4],t[5]],[t[6],t[7],t[8]]];function Jt(t){let a={cost:1/0,n:null};for(const m of t[0]){const n=t.map(c=>c.w*c.w),e=n.reduce((c,r)=>c+r,0)||1,h=t.map(c=>c.reduce((r,s)=>K(r,m)>K(s,m)?r:s)),o=z(h.reduce((c,r,s)=>c.map((f,u)=>f+r[u]*n[s]),[0,0,0])),i=h.reduce((c,r,s)=>c+n[s]*Math.acos(Math.max(-1,Math.min(1,K(r,o)))),0)/e;i<a.cost&&(a={cost:i,n:o})}return a}function jt(t,a,m,n){const e=t.planar,h=e.frames.filter(l=>Math.abs(l[0]-n)>1/20),o=Math.min(30,h.length);if(o<2)return null;const i=l=>l.map(([p,g])=>[p-a/2,g-m/2]),c=i(j(t,n,a,m)),r=Array.from({length:o},(l,p)=>h[Math.round(p*(h.length-1)/Math.max(1,o-1))]).map(l=>pt(c,i(j(t,l[0],a,m)))).filter(Boolean);if(r.length<2)return null;const s=l=>{const p=m/2/Math.tan(l*Math.PI/360),g=[[p,0,0],[0,p,0],[0,0,1]],d=[[1/p,0,0],[0,1/p,0],[0,0,1]],w=r.map(b=>Yt(J(J(d,Zt(b)),g))).filter(Boolean);if(w.length<2)return null;const y=Jt(w);return{...y,cost:y.cost+.008*((l-st)/30)**2,raw:y.cost}};let f=null,u=st;for(let l=it[0];l<=it[1];l+=1){const p=s(l);p&&(!f||p.cost<f.cost)&&(f=p,u=l)}if(!f)return null;for(let l=u-1;l<=u+1;l+=.1){const p=s(l);p&&p.cost<f.cost&&(f=p,u=l)}return{fov:+u.toFixed(2),n:f.n,spread:+f.raw.toFixed(5)}}function te(t,a,m,n,e){const h=jt(t,a,m,n);if(!h)return null;const o=m/2/Math.tan(h.fov*Math.PI/360),i=h.n,{mw:c,mh:r}=t.planar,s=e.map(([x,k])=>{const M=L(t,x,k,n,a,m,c,r),v=[(M.px-a/2)/o,(M.py-m/2)/o,1],_=K(i,v);return _>1e-6?v.map(q=>q/_):null});if(s.some(x=>!x))return null;const f=W(i,[0,-1,0]),u=mt(f)>.15?z(f[0]<0?f.map(x=>-x):f):z([1-i[0]*i[0],-i[0]*i[1],-i[0]*i[2]]);let l=z(W(i,u));l[1]<0&&(l=l.map(x=>-x));const p=s.map(x=>K(x,u)),g=s.map(x=>K(x,l)),d=(p[0]+p[3])/2,w=(p[1]+p[2])/2,y=(g[0]+g[1])/2,b=(g[2]+g[3])/2;if(!(w>d&&b>y))return null;const S=(x,k)=>i.map((M,v)=>M+x*u[v]+k*l[v]),F=[[d,y],[w,y],[w,b],[d,b]].map(([x,k])=>{const M=S(x,k),v=ft(t,o*M[0]/M[2]+a/2,o*M[1]/M[2]+m/2,n,a,m,c,r);return[+v.u.toFixed(5),+v.v.toFixed(5)]});return{fov:h.fov,surface:F,n:i}}const $=new Map,ee=1/30;async function ht(t,a,m,n,e=null){const h=[];let o=0,i=0;for(const[c,r]of[[1,n.fwd],[-1,n.back]])if(!(Math.abs(r-n.from)<ee))try{const s=await Vt({clip:t,url:a,quad:m,mode:"perspective",from:n.from,to:r,scene:e});o=s.mw,i=s.mh,h.push({dir:c,frames:s.frames,lostAt:s.lostAt,expected:Math.round(Math.abs(r-n.from)*30)})}catch(s){if(s.message!=="FLAT")throw s;h.push({dir:c,frames:[],lostAt:n.from,expected:Math.round(Math.abs(r-n.from)*30)})}return{runs:h,mw:o,mh:i,quality:Ot(h)}}const U=new Map;function ne(t,a,m){const n=[t.id,a,t.start,t.inPoint??0,t.duration,t.playbackRate??1,m.from,m.back,m.fwd].join("|"),e=Date.now();for(const[o,i]of U)e-i.at>6e4&&U.delete(o);let h=U.get(n);return h||(h={at:e,p:ht(t,a,R(ct),m)},U.set(n,h),h.p.catch(()=>U.delete(n))),h.p}async function re(t,a,m,n){const e=await lt(t,a);try{const h=await e.grab(n),o=r=>qt(h,e.w,e.h,R(r).map(([s,f])=>{const u=e.toPx(s,f);return[u.x,u.y]}),"perspective").features.length,i=o(m);if(i>=Ct)return{region:m,score:i,moved:!1};let c={region:m,score:i,moved:!1};for(const r of It(m)){const s=o(r);s>c.score&&(c={region:r,score:s,moved:!0})}return c}finally{e.close()}}async function ut(t,a,m,n,e){let h;const o={clip:t,url:a,u:m.x+m.w/2,v:m.y+m.h/2,from:n,to:e},i=r=>r?r.lostAt??e:-1,c=await Kt(o).catch(r=>{if(r.name==="AbortError")throw r;return null});if(c&&c.lostAt===null)h=c;else if(c&&i(c)>=n+.6*(e-n)){const r=c.track.points.at(-1),s=r[0]<e-.1?await et({...o,u:r[1],v:r[2],from:r[0]}).catch(f=>{if(f.name==="AbortError")throw f;return null}):null;h=s&&s.track.points.length>1?{track:{...c.track,points:[...c.track.points,...s.track.points.filter(f=>f[0]>r[0]+1e-4)]},lostAt:s.lostAt}:c}else{const r=await et(o).catch(s=>{if(s.name==="AbortError"||!c)throw s;return null});h=r&&i(r)>=i(c)?r:c}return h}async function oe(t,a,m,n,e,h){const o=Math.max(0,n.at-a.start),i=Math.min(a.duration,t.start+t.duration-a.start),c=n.region;let r;try{r=await ut(a,m,c,o,i)}catch(w){if(w.name==="AbortError")throw w;return e(A("“{0}”: không bám được vật này — chọn chỗ có nhiều chi tiết hơn.",[t.label]))}const s=C.getState(),f=s.clips.find(w=>w.id===t.id),u=s.clips.find(w=>w.id===a.id);if(!f||f.pendingPin!==n||!u)return{clipId:t.id,ok:!1,message:A("Timeline đã thay đổi. Hãy thử lại.")};const{width:l,height:p}=V(s.timelineFormat),g=r.track.points.map(([w,y,b])=>{const S=L(u,y,b,w,l,p,r.track.mw,r.track.mh);return[u.start+w-f.start,S.px,S.py]}).filter(w=>w[0]>=-1e-6);if(g.length<2)return e(A("“{0}”: không bám được vật này — chọn chỗ có nhiều chi tiết hơn.",[t.label]));const d=Bt(f,g,l,p);return h?.(),C.setState(w=>({clips:w.clips.map(y=>y.id===f.id?{...y,...d}:y)})),{clipId:f.id,ok:!0,path:"region",message:r.lostAt!==null?A("Vệt theo vật: bám được tới giây {0}.",[r.lostAt.toFixed(2)]):A("Vệt theo vật: đã bám {0} khung.",[g.length])}}async function ae(t,a,m,n,e,h){let o=a;const i=Math.max(0,n.at-o.start),c=Math.min(o.duration,t.start+t.duration-o.start),{width:r,height:s}=V(C.getState().timelineFormat);let f;try{if(n.person){const w=()=>{const k=C.getState().clips,M=k.find(v=>v.id===o.id);return M?.person&&M.person.src!=="object"?M.person:k.find(v=>v.id!==o.id&&v.kind==="video"&&v.url===o.url&&v.person&&v.person.src!=="object")?.person};let y=w();for(let k=0;k<1200&&!y&&C.getState().clips.some(M=>M.url===o.url&&M.personPending);k++)await new Promise(M=>setTimeout(M,500)),y=w();if(!y){const{segmentClipMatte:k}=await Ft(async()=>{const{segmentClipMatte:M}=await import("./pendingMatte-q35zVaiB.js");return{segmentClipMatte:M}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));y=await k(o)}if(!y)return e(A("“{0}”: chưa tách người trên clip này — mở Roto → Tách người, hoặc chọn điểm người chạy.",[t.label]));const b=await At(y),S=1/30,F=[],x=y;for(let k=i;k<=c+1e-6;k+=S){const M=Rt(Et(b,x,_t(o,k)),x.w,x.h);if(!M)continue;const v=L(o,M.x+M.w/2,M.y+M.h*.42,k,r,s,x.mw,x.mh);F.push([k,v.px/r,v.py/s])}f=F.map((k,M)=>{const v=F.slice(Math.max(0,M-2),M+3);return[k[0],v.reduce((_,q)=>_+q[1],0)/v.length,v.reduce((_,q)=>_+q[2],0)/v.length]})}else{const w=await ut(o,m,n.region,i,c);f=w.track.points.map(([y,b,S])=>{const F=L(o,b,S,y,r,s,w.track.mw,w.track.mh);return[y,F.px/r,F.py/s]})}}catch(w){if(w.name==="AbortError")throw w;return e(A("“{0}”: không bám được vật này — chọn chỗ có nhiều chi tiết hơn.",[t.label]))}const u=C.getState(),l=u.clips.find(w=>w.id===t.id),p=u.clips.find(w=>w.id===o.id);if(!l||l.pendingPin!==n||!p)return{clipId:t.id,ok:!1,message:A("Timeline đã thay đổi. Hãy thử lại.")};const g=f.map(([w,y,b])=>[p.start+w-l.start,y,b]).filter(w=>w[0]>=-1e-6);if(g.length<2)return e(A("“{0}”: không bám được vật này — chọn chỗ có nhiều chi tiết hơn.",[t.label]));const d=Qt(l,g);return h?.(),C.setState(w=>({clips:w.clips.map(y=>y.id===l.id?{...y,...d}:y)})),{clipId:l.id,ok:!0,path:"region",message:A("Vệt sét: đã bám {0} khung.",[g.length])}}async function ie(t,a,m,n,e,h){let o;try{o=await Nt(a,m)}catch(y){if(y.name==="AbortError")throw y;return e(A("“{0}”: video quá ít chi tiết để dựng camera 3D — thử một cảnh có nhiều mái nhà, đường, cây.",[t.label]))}const i=C.getState(),c=i.clips.find(y=>y.id===t.id),r=i.clips.find(y=>y.id===a.id);if(!c||c.pendingPin!==n||!r)return{clipId:t.id,ok:!1,message:A("Timeline đã thay đổi. Hãy thử lại.")};const{width:s,height:f}=V(i.timelineFormat),u=n.at-r.start,l=n.region,[p,g]=Y(o,r,l.x+l.w/2,l.y+l.h/2);let d,w=i.timelineCamera;if(c.kind==="model"){if(o.mode!=="free")return e(A("“{0}”: máy quay chỉ xoay tại chỗ — toà nhà 3D cần cảnh máy bay / di chuyển.",[c.label]));const y=Z(o,p,g,u)??nt(o,p,g,u),b=Z(o,...Y(o,r,l.x,l.y+l.h/2),u),S=Z(o,...Y(o,r,l.x+l.w,l.y+l.h/2),u),F=zt(o,r,y,s,f,{size:b&&S?Math.hypot(b[0]-S[0],b[1]-S[1],b[2]-S[2]):null,fill:.8});w=F.camera,d={pendingPin:void 0,pin:void 0,...F.place}}else d={pendingPin:void 0,pin:void 0,...Gt(c,r,o,nt(o,p,g,u),s,f)};return h?.(),C.setState(y=>({timelineCamera:w,clips:y.clips.map(b=>b.id===r.id?{...b,sceneTrack:o}:b.id===c.id?{...b,...d}:b)})),{clipId:c.id,ok:!0,path:"scene",message:A("“{0}” đã dính vào cảnh 3D của video (camera dựng từ {1} khung, như 3D Camera Tracker).",[c.label,o.frames.length])}}async function se(t,a,m,n){if(!m.frames.length)return null;const e=await lt(t,a);try{const h=Math.max(6,Math.round(e.w*.025)),o=[],i=[],c=g=>e.grab(g+.002);for(const g of m.frames){const d=dt(m,g[0]).map(([w,y])=>{const b=e.toPx(w,y);return[b.x,b.y]});o.push(d),i.push(at(await c(g[0]),e.w,e.h,d,{radius:h}))}if(i.filter(Boolean).length<i.length*.6)return null;const r=m.frames.map(g=>g[0]),s=m.frames.map(g=>g[9]);if(n){const g=.03333333333333333,d=async(P,E)=>{const N=[];let O=P<0?i.findIndex(Boolean):i.length-1-[...i].reverse().findIndex(Boolean),B=i[O],D=r[O];for(let G=0;G<600&&(D=+(D+P*g).toFixed(4),!(P<0?D<E-1e-6:D>E+1e-6));G++){const Q=at(await c(D),e.w,e.h,B,{radius:h,clean:!0});if(!Q)break;N.push({t:D,q:Q}),B=Q}return{k:O,out:N}},w=await d(-1,Math.max(0,n.back)),y=await d(1,Math.min(t.duration,n.fwd)),b=w.out.reverse(),S=y.out,F=w.k,x=y.k,k=P=>P>=F&&P<=x,M=[...b.map(P=>P.t),...r.filter((P,E)=>k(E)),...S.map(P=>P.t)],v=[...b.map(P=>P.q),...i.filter((P,E)=>k(E)),...S.map(P=>P.q)],_=[...b.map(P=>P.q),...o.filter((P,E)=>k(E)),...S.map(P=>P.q)],q=[...b.map(()=>.9),...s.filter((P,E)=>k(E)),...S.map(()=>.9)];r.splice(0,r.length,...M),i.splice(0,i.length,...v),o.splice(0,o.length,..._),s.splice(0,s.length,...q)}const f=Lt(i,o).map(g=>g.map(([d,w])=>{const y=e.toUv(d,w);return[+y.u.toFixed(5),+y.v.toFixed(5)]})),u=r.map((g,d)=>[g,...f[d].flat(),s[d]]),l=m.surface?.t??u[0][0];let p=0;return u.forEach((g,d)=>{Math.abs(g[0]-l)<Math.abs(u[p][0]-l)&&(p=d)}),{...m,frames:u,surface:{t:u[p][0],pts:f[p]}}}finally{e.close()}}async function ce(t,a){const m=C.getState(),n=m.clips.find(s=>s.id===t),e=n?.pendingPin;if(!n||!e)return{clipId:t,ok:!1,message:A("Không còn lớp cần gắn.")};const h=s=>(C.setState(f=>({clips:f.clips.map(u=>u.id===t&&u.pendingPin===e?{...u,pendingPin:void 0}:u)})),{clipId:t,ok:!1,message:s}),o=m.clips.find(s=>s.id===e.source);if(!o||o.kind!=="video")return h(A("“{0}”: không tìm thấy video để bám.",[n.label]));const i=document.querySelector(`video[data-clip-media="${o.id}"]`)?.currentSrc||o.url;if(e.mode==="scene")return ie(n,o,i,e,h,a);if(e.mode==="trail")return oe(n,o,i,e,h,a);if(e.mode==="bolt")return ae(n,o,i,e,h,a);const c=gt(n,o,e.at),r=R(e.region);try{const s=await re(o,i,e.region,c.from);let f=s.moved?"nearby":"region";const u=o.sceneTrack?.mode==="free"&&o.sceneTrack.key===Dt(o,i)?o.sceneTrack:null;let l=s.score>=yt||u?await ht(o,i,R(s.region),c,u):null,p=R(s.region);const g={plane:l?.quality??null};if((e.mode==="camera3d"||e.mode==="point")&&(!l||l.quality.weak)){const T=await ne(o,i,c);g.frame=T.quality,(!l||T.quality.score>l.quality.score*1.25+.05)&&(l=T,p=R(ct),f="frame")}if(!l||!l.mw||!l.runs.some(T=>T.frames.length))throw Error("FLAT");let d=wt({v:1,mw:l.mw,mh:l.mh,mode:"perspective",frames:[]},c.from,p);for(const T of l.runs)d=kt(d,T.frames,c.from,T.dir);f!=="region"&&(d=tt(d,c.from,r));const{width:w,height:y}=V(C.getState().timelineFormat),b=te({...o,planar:d},w,y,c.from,r);if(b&&(d=tt(d,c.from,b.surface)),e.mode==="plane"){const T=await se(o,i,d,c).catch(()=>null);T&&(d=T)}const S=C.getState(),F=S.clips.find(T=>T.id===t),x=S.clips.find(T=>T.id===o.id);if(!F||F.pendingPin!==e||!x)return{clipId:t,ok:!1,message:A("Timeline đã thay đổi. Hãy thử lại.")};const{patch:k,solve:M,follow:v}=Mt(F,x.id,e.mode);if(k.pin?.scene){const T=await Ut(x,d,i).catch(()=>null);k.pin={...k.pin,...b?{lens:b.fov}:{},...T?{light:T}:{}}}const _=C.getState(),q=_.clips.find(T=>T.id===t),P=_.clips.find(T=>T.id===o.id);if(!q||q.pendingPin!==e||!P)return{clipId:t,ok:!1,message:A("Timeline đã thay đổi. Hãy thử lại.")};let E=k,N=_.timelineCamera;if(v){const{width:T,height:I}=V(_.timelineFormat);E={...k,...bt(q,{...P,planar:d},T,I)}}if(M){const{width:T,height:I}=V(_.timelineFormat),X=xt({...P,planar:d},T,I,N,b?{zoom:I/2/Math.tan(b.fov*Math.PI/360)/(5*vt(T,I))}:{});N?.motionKeys?.length||(N=X.camera),E={...k,...q.kind==="model"?St(X.plane,T,I):Pt(X.plane,T,{fill:.6})}}const O=k.pin&&!k.pin.scene?Tt({...q,...E},P,d,_.timelineFormat?.fps||30):null;O&&(E={...E,...O}),a?.(),C.setState(T=>({timelineCamera:N,clips:T.clips.map(I=>I.id===P.id&&!v?{...I,planar:d}:I.id===t?{...I,...E}:I)}));const B=l.runs.find(T=>T.lostAt!==null&&T.frames.length),D=d.frames.length,G=f==="region"?"":f==="nearby"?A(" (vùng được dời sang chỗ nhiều chi tiết hơn)"):A(" (bám theo chuyển động cả khung hình)"),Q=O?A(" Lớp hiện từ giây {0} đến {1} — đúng các khung thấy trọn mặt phẳng.",[O.start.toFixed(2),(O.start+O.duration).toFixed(2)]):"";return{clipId:t,ok:!0,path:f,quality:g,message:(B&&!O?A("“{0}” đã dính vào cảnh ({1} khung) — mất mặt phẳng ở giây {2}; sửa góc ở tab Roto rồi track tiếp.",[n.label,D,(B.lostAt+o.start).toFixed(2)]):A("“{0}” đã dính vào cảnh: track {1} khung trên “{2}”.",[n.label,D,o.label]))+G+Q}}catch(s){const f=s.message,u=f==="FLAT"?A("vùng này quá trơn để track — chọn mặt phẳng có nhiều chi tiết hơn"):["NO_TRACK","NOT_PERSPECTIVE","DEGENERATE","OUT_OF_RANGE"].includes(f)?A("không dựng được camera 3D từ track ({0})",[f]):f;return h(A("“{0}” chưa dính vào cảnh: {1}.",[n.label,u]))}}function Oe({ids:t,checkpoint:a,skipRunning:m=!1}={}){const n=C.getState().clips.filter(e=>e.pendingPin&&(!t||t.includes(e.id))&&!(m&&$.has(e.id))).map(e=>e.id);return Promise.all(n.map(e=>{let h=$.get(e);return h||(h=ce(e,a).finally(()=>$.delete(e)),$.set(e,h)),h}))}export{Oe as runSurfacePins,se as snapPlanarToEdges};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js"])))=>i.map(i=>d[i]);
2
- import{PMREMGenerator as ie,SRGBColorSpace as oe,Texture as J,CanvasTexture as ae,Group as M,MeshStandardMaterial as I,Color as Z,BoxGeometry as C,Mesh as l,PlaneGeometry as re,CircleGeometry as $,MeshBasicMaterial as ee,CylinderGeometry as ce,ExtrudeGeometry as de,ShapeGeometry as he,Shape as le,Scene as ue,PerspectiveCamera as pe,Plane as D,WebGLRenderer as me,HemisphereLight as fe,DirectionalLight as we,Box3 as z,Vector3 as p,AnimationMixer as ye,Matrix4 as q,Matrix3 as ge,Quaternion as H,Euler as xe,BufferGeometry as U,BufferAttribute as R,ShaderMaterial as ve,Points as be,GridHelper as Me,Raycaster as Ae,Vector2 as ze,LoopRepeat as Pe,Line as Se,LineBasicMaterial as Ce}from"./three.module-Bx43vjkH.js";import{G as Y}from"./GLTFLoader-Dy6SrZg8.js";import{az as Oe}from"./api-BsKbf3l3.js";import{lJ as O,_ as Te,fy as V,fz as Ee,lK as Ie,lL as We,lM as Fe,lN as Le,lO as _e,lP as De,cb as Re,f7 as Be,f9 as Ge,ec as B,fp as je}from"./titleFrameBudget-3MFHWIT6.js";import{R as ke}from"./RoomEnvironment-Dmv_G5ka.js";const qe=new Map;async function He(r){try{const e=await(await Te(async()=>{const{signOutput:t}=await import("./api-BsKbf3l3.js").then(s=>s.c1);return{signOutput:t}},__vite__mapDeps([0,1]))).signOutput({gcsUri:r});return typeof e=="string"&&e?e:null}catch{return null}}function te(r,e,t){const s=new le,n=-r/2,o=-e/2;return t=Math.min(t,r/2,e/2),s.moveTo(n+t,o),s.lineTo(n+r-t,o),s.quadraticCurveTo(n+r,o,n+r,o+t),s.lineTo(n+r,o+e-t),s.quadraticCurveTo(n+r,o+e,n+r-t,o+e),s.lineTo(n+t,o+e),s.quadraticCurveTo(n,o+e,n,o+e-t),s.lineTo(n,o+t),s.quadraticCurveTo(n,o,n+t,o),s}function b(r,e,t){const s=new he(te(r,e,t),12),n=s.attributes.uv,o=s.attributes.position;for(let i=0;i<n.count;i++)n.setXY(i,o.getX(i)/r+.5,o.getY(i)/e+.5);return s}function P(r,e,t,s,n=.012){const o=new de(te(r-n*2,e-n*2,Math.max(.001,s-n)),{depth:t-n*2,bevelEnabled:!0,bevelThickness:n,bevelSize:n,bevelSegments:4,curveSegments:14});return o.translate(0,0,-(t-n*2)/2),o}const g=(r,e=.32)=>new I({color:r,metalness:.85,roughness:e}),E=()=>new I({color:"#050506",metalness:.2,roughness:.08}),X=r=>new I({color:r,metalness:.1,roughness:.75}),W=()=>new ee({color:"#ffffff",toneMapped:!1});function N(r,{w:e,h:t,d:s,r:n,bezel:o,island:i,lenses:a}){const c=new M;c.add(new l(P(e,t,s,n),g(r)));const d=new l(b(e-.012,t-.012,n-.006),E());d.position.z=s/2+.0015,c.add(d);const u=e-o*2,h=t-o*2,f=new l(b(u,h,Math.max(.01,n-o)),W());if(f.position.z=s/2+.003,c.add(f),i){const m=new l(b(u*.3,h*.032,h*.016),new ee({color:"#000"}));m.position.set(0,h/2-h*.035,s/2+.004),c.add(m)}if(a){const m=new l(P(e*.42,e*.42,.02,e*.1,.006),E());m.position.set(-e/2+e*.27,t/2-e*.27,-s/2-.008),c.add(m);for(let y=0;y<a;y++){const x=y*2*Math.PI/Math.max(1,a)+.6,v=new l(new ce(e*.075,e*.08,.018,28),g("#2a2a2c",.2));v.rotation.x=Math.PI/2,v.position.set(m.position.x+Math.cos(x)*e*.09,m.position.y+Math.sin(x)*e*.09,-s/2-.022),c.add(v);const A=new l(new $(e*.05,24),E());A.rotation.y=Math.PI,A.position.set(v.position.x,v.position.y,-s/2-.0315),c.add(A)}}for(const[m,y]of[[t*.22,t*.08],[t*.09,t*.08]]){const x=new l(new C(.008,y,s*.35),g(r));x.position.set(-e/2-.002,m,0),c.add(x)}const w=new l(new C(.008,t*.12,s*.35),g(r));return w.position.set(e/2+.002,t*.14,0),c.add(w),{object:c,screen:f,screenAspect:u/h}}function Ue(r,e){const t=new M,s=1.8,n=1.22,o=.045,i=new l(P(s,n,o,.06),g(r));i.rotation.x=-Math.PI/2,t.add(i);const a=new l(b(s*.86,n*.42,.02),X("#111214"));a.rotation.x=-Math.PI/2,a.position.set(0,o/2+.001,-n*.15),t.add(a);const c=new C(s*.86/15*.82,.006,n*.42/6*.78),d=X("#1b1c1f");for(let L=0;L<6;L++)for(let _=0;_<15;_++){const k=new l(c,d);k.position.set(-s*.43+(_+.5)*s*.86/15,o/2+.004,-n*.15-n*.21+(L+.5)*n*.42/6),t.add(k)}const u=new l(b(s*.36,n*.26,.025),g(r,.5));u.rotation.x=-Math.PI/2,u.position.set(0,o/2+.0012,n*.27),t.add(u);const h=new M;h.position.set(0,o/2,-n/2),t.add(h);const f=1.16,w=.022,m=new M;m.position.set(0,f/2,0),h.add(m),m.add(new l(P(s,f,w,.05),g(r)));const y=new l(b(s-.01,f-.01,.045),E());y.position.z=w/2+.0015,m.add(y);const x=s-.09,v=f-.1,A=new l(b(x,v,.012),W());A.position.set(0,.01,w/2+.003),m.add(A);const F=new l(new $(.07,40),g("#e9e9ea",.15));F.rotation.y=Math.PI,F.position.z=-w/2-.002,m.add(F);const j=Math.max(0,Math.min(1,e));return h.rotation.x=(1-j)*Math.PI/2-j*.26,{object:t,screen:A,screenAspect:x/v}}function Ye(r){const e=new M,t=1.8,s=1.04,n=.035;e.add(new l(P(t,s,n,.02,.006),g(r,.45)));const o=t-.04,i=s-.04,a=new l(b(o,i,.006),W());a.position.z=n/2+.002,e.add(a);const c=new l(new C(.12,.32,.04),g(r,.4));c.position.set(0,-s/2-.14,-.05),e.add(c);const d=new l(P(.62,.26,.025,.08,.006),g(r,.4));return d.rotation.x=-Math.PI/2,d.position.set(0,-s/2-.3,-.02),e.add(d),{object:e,screen:a,screenAspect:o/i}}function Ve(r){const e=new M,t=1.2,s=1.6,n=.42,o=new I({color:new Z(r).multiplyScalar(.62),metalness:0,roughness:.85}),i=new C(t,s,n);e.add(new l(i,o));const a=new l(new re(t*.98,s*.98),W());return a.position.z=n/2+.002,e.add(a),{object:e,screen:a,screenAspect:t/s}}function Xe(r){const e=r.color??(r.type==="box"?O.white:r.type==="tv"?O.black:r.type==="laptop"?O.silver:O.titanium);switch(r.type){case"phone":return N(e,{w:.83,h:1.8,d:.075,r:.13,bezel:.032,island:!0,lenses:3});case"tablet":return N(e,{w:1.35,h:1.8,d:.06,r:.09,bezel:.05,island:!1,lenses:1});case"laptop":return Ue(e,r.open??1);case"tv":return Ye(e);default:return Ve(e)}}const K=new WeakMap;function Ne(r){let e=K.get(r);if(!e){const t=new ie(r);e=t.fromScene(new ke,0,.1,100,{size:64}).texture,t.dispose(),K.set(r,e)}return e}class Ke{constructor(e,t,s){this.mesh=e,this.aspect=t,this.media=s;const n=o=>s.kind==="video"?this.loadVideo(o):this.loadImage(o);this.ready=s?.url?n(s.url).catch(async o=>{const i=s.gcsUri?await He(s.gcsUri):null;if(!i||i===s.url)throw o;return n(i)}):Promise.resolve(),s?.url||e.material.color.set("#0d0f12")}texture=null;video=null;ready;whenReady(){return this.ready}fit(e,t){const s=this.texture,n=e/t;n>this.aspect?(s.repeat.set(this.aspect/n,1),s.offset.set((1-this.aspect/n)/2,0)):(s.repeat.set(1,n/this.aspect),s.offset.set(0,(1-n/this.aspect)/2))}apply(e,t,s){e.colorSpace=oe,e.anisotropy=4,this.texture=e,this.fit(t,s);const n=this.mesh.material;n.map=e,n.needsUpdate=!0}loadImage(e){return new Promise((t,s)=>{const n=new Image;n.crossOrigin="anonymous",n.onload=()=>{this.apply(new J(n),n.naturalWidth,n.naturalHeight),this.texture.needsUpdate=!0,t()},n.onerror=()=>s(Error("Không tải được ảnh màn hình thiết bị")),n.src=e})}canvas=null;draw(){const e=this.video,t=this.canvas;!e||!t||e.readyState<2||(t.getContext("2d").drawImage(e,0,0,t.width,t.height),this.texture&&(this.texture.needsUpdate=!0))}loadVideo(e){const t=document.createElement("video");return t.crossOrigin="anonymous",t.muted=!0,t.playsInline=!0,t.preload="auto",this.video=t,new Promise((s,n)=>{t.onloadeddata=()=>{const o=Math.min(1,1280/Math.max(t.videoWidth,t.videoHeight)),i=document.createElement("canvas");i.width=Math.max(2,Math.round(t.videoWidth*o)),i.height=Math.max(2,Math.round(t.videoHeight*o)),this.canvas=i,this.apply(new ae(i),t.videoWidth,t.videoHeight),this.draw(),s()},t.onerror=()=>n(Error("Không tải được video màn hình thiết bị")),t.src=e})}async sync(e,t=!1){const s=this.video,n=this.media;if(!s||!n||!this.texture)return;const o=Number.isFinite(s.duration)&&s.duration>0?s.duration:0;let i=(n.inPoint||0)+Math.max(0,e)*(n.speed||1);if(o&&(i=Math.min(i,o-.04)),Math.abs(s.currentTime-i)>(t?.004:.12)){const a=new Promise(c=>{const d=()=>{s.removeEventListener("seeked",d),c()};s.addEventListener("seeked",d),setTimeout(d,t?4e3:600)});if(s.currentTime=i,t)await a;else{a.then(()=>this.draw());return}}this.draw()}dispose(){this.texture?.dispose(),this.video&&(this.video.removeAttribute("src"),this.video.load(),this.video=null)}}const se=new Map,G=new Set,Qe=r=>r?se.get(r):void 0;function Je(r){return G.add(r),()=>{G.delete(r)}}const Q=(r,e)=>r.name||`Animation ${e+1}`,ne=new Map,Ze=r=>r?ne.get(r):void 0,T=600,$e="attribute float aAlpha;attribute float aSize;varying float vA;uniform float uScale;void main(){vA=aAlpha;vec4 mv=modelViewMatrix*vec4(position,1.);gl_PointSize=aSize*uScale/max(.05,-mv.z);gl_Position=projectionMatrix*mv;}",et="uniform vec3 uColor;varying float vA;void main(){vec2 d=gl_PointCoord-.5;float r=length(d);if(r>.5)discard;gl_FragColor=vec4(uColor,vA*smoothstep(.5,.05,r));}",S=Math.PI/180;class tt{canvas;renderer;scene=new ue;camera=new pe(40,1,.01,100);halfY=0;group=new M;disposed=!1;mixer=null;clips=[];action=null;rest=[];width;height;screen=null;pieces=[];dust=null;cut=[new D,new D];guides=null;buildOn=!1;constructor(e,t){this.width=e,this.height=t,this.renderer=new me({alpha:!0,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(1),this.renderer.setSize(e,t,!1),this.renderer.setClearColor(0,0),this.canvas=this.renderer.domElement,this.camera.aspect=e/t,this.camera.position.set(0,0,5),this.camera.lookAt(0,0,0),this.camera.updateProjectionMatrix(),this.scene.add(this.group,new fe(16777215,7829367,3));const s=new we(16777215,3);s.position.set(3,5,5),this.scene.add(s)}async load(e){const t=await Oe(e);this.add(await new Y().loadAsync(t),e)}async loadBuffer(e,t){this.add(await new Y().parseAsync(e,""),t)}async loadDevice(e){if(!e.device)throw Error("Không phải thiết bị 3D");const t=Xe(e.device);this.scene.environment=Ne(this.renderer),this.addObject(t.object),!this.disposed&&(this.screen=new Ke(t.screen,t.screenAspect,e.deviceScreen),await this.screen.whenReady())}async prepare(e){await this.screen?.sync(e,!0)}addObject(e){if(this.disposed){this.disposeObject(e);return}const t=new z().setFromObject(e),s=t.getSize(new p),n=Math.max(s.x,s.y,s.z);e.scale.setScalar(1.8/n),e.updateMatrixWorld(!0),this.halfY=s.y*1.8/n/2,e.position.sub(new z().setFromObject(e).getCenter(new p)),e.updateMatrixWorld(!0),this.group.add(e)}add(e,t){if(this.disposed){this.disposeObject(e.scene);return}const n=new z().setFromObject(e.scene).getSize(new p),o=Math.max(n.x,n.y,n.z);if(!Number.isFinite(o)||o<=0)throw Error("GLB không có hình học hợp lệ");e.scene.scale.setScalar(1.8/o),e.scene.updateMatrixWorld(!0);const i=new z().setFromObject(e.scene).getCenter(new p);e.scene.position.sub(i),e.scene.updateMatrixWorld(!0),this.halfY=n.y*1.8/o/2,this.group.add(e.scene),this.clips=e.animations||[],this.clips.length&&(this.mixer=new ye(e.scene),e.scene.traverse(a=>{a!==e.scene&&this.rest.push({o:a,p:a.position.clone(),q:a.quaternion.clone(),s:a.scale.clone()})})),this.collectPieces(e.scene),ne.set(t,this.pieces.length),se.set(t,this.clips.map((a,c)=>({name:Q(a,c),duration:a.duration}))),G.forEach(a=>a())}collectPieces(e){this.group.updateMatrixWorld(!0);const t=[];e.traverse(c=>{c.isMesh&&t.push(c)});const s=new z().setFromObject(e),n=c=>{const d=c.getSize(new p);return d.x*d.y*d.z},o=n(s)*.02,i=s.getSize(new p),a=i.x*i.z;for(const c of t.slice(0,V.maxPieces)){const d=new z().setFromObject(c),u=d.getCenter(new p),h=d.getSize(new p),f=new q().copy(c.parent.matrixWorld).invert();this.pieces.push({o:c,p:c.position.clone(),q:c.quaternion.clone(),s:c.scale.clone(),toParent:new ge().setFromMatrix4(f),box:{bottom:d.min.y,cx:u.x,cz:u.z,h:h.y,r:Math.max(h.x,h.z)/2,big:n(d)>o,base:h.x*h.z>=a*.25&&d.min.y<=s.min.y+i.y*.03}})}}build(e,t){let s=null;try{s=e.modelBuild?Ee(e.modelBuild):null}catch{s=null}const n=new Set;this.group.traverse(i=>{const a=i.material;if(a)for(const c of Array.isArray(a)?a:[a])n.add(c)});const o=[];if(s){const i=Ie(this.pieces.map(d=>d.box),s);this.pieces.forEach((d,u)=>{const h=We(s.style,d.box,i[u],t,u,s.seed);d.o.position.copy(d.p),d.o.quaternion.copy(d.q),d.o.scale.copy(d.s),d.o.visible=h.visible,(h.dx||h.dy||h.dz)&&d.o.position.add(new p(h.dx,h.dy,h.dz).applyMatrix3(d.toParent)),(h.rx||h.ry||h.rz)&&d.o.quaternion.multiply(new H().setFromEuler(new xe(h.rx,h.ry,h.rz)))}),this.group.updateMatrixWorld(!0);const a=new p(0,1,0).applyQuaternion(this.group.getWorldQuaternion(new H)).normalize();Fe(s,t)&&o.push(this.cut[0].setFromNormalAndCoplanarPoint(a,this.group.localToWorld(new p(0,-this.halfY,0))));const c=Le(s,t,this.halfY);c!==null&&o.push(this.cut[1].setFromNormalAndCoplanarPoint(a.clone().negate(),this.group.localToWorld(new p(0,c,0)))),this.dustAt(_e(this.pieces.map(d=>d.box),i,s,t,T),s.dustColor),this.buildOn=!0}else{for(const i of this.pieces)i.o.position.copy(i.p),i.o.quaternion.copy(i.q),i.o.scale.copy(i.s),i.o.visible=!0;this.dustAt([],V.dustColor),this.buildOn=!1}this.renderer.localClippingEnabled=o.length>0;for(const i of n){const a=o.length?o:null;i.clippingPlanes!==a&&(i.clippingPlanes?.length||a)&&(i.clippingPlanes=a,i.needsUpdate=!0)}}dustAt(e,t){if(!e.length&&!this.dust)return;if(!this.dust){const a=new U;a.setAttribute("position",new R(new Float32Array(T*3),3)),a.setAttribute("aAlpha",new R(new Float32Array(T),1)),a.setAttribute("aSize",new R(new Float32Array(T),1));const c=new ve({uniforms:{uColor:{value:new Z(t)},uScale:{value:this.height*1.2}},vertexShader:$e,fragmentShader:et,transparent:!0,depthWrite:!1});this.dust=new be(a,c),this.dust.frustumCulled=!1,this.group.add(this.dust)}const s=this.dust.geometry,n=s.getAttribute("position"),o=s.getAttribute("aAlpha"),i=s.getAttribute("aSize");e.forEach((a,c)=>{n.setXYZ(c,a[0],a[1],a[2]),o.setX(c,a[3]),i.setX(c,a[4])}),s.setDrawRange(0,e.length),n.needsUpdate=o.needsUpdate=i.needsUpdate=!0,this.dust.material.uniforms.uColor.value.set(t)}setGuides(e,t=4){if(!e){this.guides&&(this.scene.remove(this.guides),this.disposeObject(this.guides),this.guides=null);return}if(this.guides)return;const s=new M,n=new Me(t,16,6742271,2781056);n.rotation.x=Math.PI/2;for(const i of Array.isArray(n.material)?n.material:[n.material])i.transparent=!0,i.opacity=.85,i.depthWrite=!1;const o=(i,a)=>new Se(new U().setFromPoints([new p,i]),new Ce({color:a}));s.add(n,o(new p(.5,0,0),16731469),o(new p(0,.5,0),5111674),o(new p(0,0,.5),5086207)),this.guides=s,this.scene.add(s)}surfaceAt(e,t){const s=new Ae;s.setFromCamera(new ze(e/this.width*2-1,1-t/this.height*2),this.camera);const n=s.ray.intersectPlane(new D(new p(0,0,1),0),new p);return n?{x:n.x,y:n.y}:null}pose(e,t){if(!this.mixer)return;const s=e.modelAnim,n=s?this.clips.find((i,a)=>Q(i,a)===s.clip):void 0;if(!s||!n){if(this.action){this.mixer.stopAllAction(),this.action=null;for(const i of this.rest)i.o.position.copy(i.p),i.o.quaternion.copy(i.q),i.o.scale.copy(i.s)}return}const o=this.mixer.clipAction(n);this.action!==o&&(this.mixer.stopAllAction(),o.setLoop(Pe,1/0),o.play(),this.action=o),o.time=De(s,n.duration,t,e.inPoint||0),this.mixer.update(0)}render(e,t,s=!1,n){const o=Re(e,Math.max(0,t),this.width,this.height),i=o,a=o.depth;if(Be(n)&&e.is3D!==!1){const u=this.width,h=this.height,f=je(u,h),w=Ge(n,e.start+Math.max(0,t),u,h);this.group.position.set(i.x*u/f,-i.y*h/f,a);const m=y=>new p(w.R[0][y],-w.R[1][y],-w.R[2][y]);this.camera.position.set(w.pos[0]/f,-w.pos[1]/f,-w.pos[2]/f),this.camera.quaternion.setFromRotationMatrix(new q().makeBasis(m(0),m(1).negate(),m(2).negate())),this.camera.fov=2*Math.atan(h/2/w.f)/S}else{this.camera.position.set(0,0,5),this.camera.quaternion.identity(),this.camera.fov=40;const h=2*(5-a)*Math.tan(this.camera.fov*S/2);this.group.position.set(i.x*h*this.camera.aspect,-i.y*h,a)}this.camera.updateProjectionMatrix(),this.group.scale.setScalar(i.zoom);const c={x:B(e,"rx",t),y:B(e,"ry",t),z:B(e,"rz",t)},d=e.modelSpin||{x:0,y:0,z:0};this.group.rotation.set((c.x+d.x*((e.inPoint||0)+t))*S,(c.y+d.y*((e.inPoint||0)+t))*S,(c.z+d.z*((e.inPoint||0)+t))*S),e.modelGround&&this.group.position.add(new p(0,1,0).applyEuler(this.group.rotation).multiplyScalar(this.halfY*i.zoom)),this.pose(e,t),(e.modelBuild||this.buildOn)&&this.build(e,t),s&&this.screen?.sync(t),this.renderer.render(this.scene,this.camera),s&&this.publish(e.id)}publish(e){const t=new z().setFromObject(this.group);if(t.isEmpty())return;let s=1/0,n=1/0,o=-1/0,i=-1/0;for(const a of[t.min.x,t.max.x])for(const c of[t.min.y,t.max.y])for(const d of[t.min.z,t.max.z]){const u=new p(a,c,d).project(this.camera),h=(u.x+1)/2*this.width,f=(1-u.y)/2*this.height;s=Math.min(s,h),o=Math.max(o,h),n=Math.min(n,f),i=Math.max(i,f)}qe.set(e,{cx:(s+o)/2,cy:(n+i)/2,w:o-s,h:i-n,angle:0,W:this.width,H:this.height})}async frame(){const e=await new Promise(n=>this.canvas.toBlob(n,"image/webp",.8));if(!e)throw Error("Không xuất được frame 3D");const t=new Uint8Array(await e.arrayBuffer());let s="";for(let n=0;n<t.length;n+=16384)s+=String.fromCharCode(...t.subarray(n,n+16384));return btoa(s)}disposeObject(e){e.traverse(t=>{const s=t;s.geometry?.dispose();for(const n of s.material?Array.isArray(s.material)?s.material:[s.material]:[]){for(const o of Object.values(n))o instanceof J&&o.dispose();n.dispose()}})}dispose(){this.disposed=!0,this.screen?.dispose(),this.screen=null,this.mixer?.stopAllAction(),this.disposeObject(this.group),this.renderer.dispose(),this.canvas.remove()}}const rt=Object.freeze(Object.defineProperty({__proto__:null,Timeline3DScene:tt,modelAnimations:Qe,modelPieces:Ze,onModelAnimations:Je},Symbol.toStringTag,{value:"Module"}));export{tt as T,Ze as a,qe as l,Qe as m,Je as o,rt as t};
@@ -1 +0,0 @@
1
- import{b$ as w,eO as u,eP as D,eQ as E}from"./titleFrameBudget-3MFHWIT6.js";import{T as F}from"./timeline3d-BEuZZOxM.js";import{wantsFrame as s,SKIPPED_FRAME as x}from"./frameSink-Dj71jCRb.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./api-BsKbf3l3.js";import"./RoomEnvironment-Dmv_G5ka.js";async function A(n,m,o,c,d){const{width:l,height:p,fps:a}=w(m),f=u(D(n));for(const e of n.filter(t=>t.kind==="model")){if(!s(o,"modelFrames",e.id))continue;if(!e.gcsUri&&!e.device)throw Error("Clip 3D chưa có GLB");const t=Math.ceil(e.duration*a);if(t>3600)throw Error("Mỗi clip 3D tối đa 2 phút khi xuất MP4. Hãy chia clip dài thành nhiều đoạn.");const i=new F(l,p);try{e.device?await i.loadDevice(e):await i.load(e.gcsUri);for(let r=0;r<t;r++){if(c?.aborted)throw new DOMException("Export cancelled","AbortError");if(!s(o,"modelFrames",e.id,r)){await o.push("modelFrames",e.id,x);continue}E(f),await i.prepare(r/a),i.render(e,r/a,!1,d),await o.push("modelFrames",e.id,await i.frame()),r%8===0&&await new Promise(h=>setTimeout(h,0))}}finally{i.dispose()}}}export{A as render3DFrames};
@@ -1 +0,0 @@
1
- import{b$ as P,eO as et,eP as at,lQ as ot,eT as B,lR as rt,ea as nt,eU as it,eQ as H,ec as V,eS as st,eX as U,eW as Y,eY as X,eV as q}from"./titleFrameBudget-3MFHWIT6.js";import{l as lt,d as ht}from"./titleArt-CcTdJuOC.js";import{i as R,j as dt,s as j,d as T,l as ct,k,f as mt,e as G,a as ft,p as ut,t as pt,m as z}from"./lottieLayer-CfUPParC.js";import{wantsFrame as J,SKIPPED_FRAME as wt}from"./frameSink-Dj71jCRb.js";import{t as N}from"./api-BsKbf3l3.js";import"./textAnimators-Cihw35O8.js";import"./rigTrack-Bx9QHlFv.js";const gt=a=>st(a.title)||!!a.shape||!!a.motion||!!a.lottie||!!a.card||!!a.geo,D=4,Q=192*1024*1024,g=new Map;let A=0;function xt(a,s){if(a.geo||a.shape&&R(a.shape)||a.pin?.scene||a.space)return null;const{start:i,track:h,...n}=a;return JSON.stringify([s,n])}function Et(a,s){const i=s.reduce((h,n)=>h+n.length,0);if(!(i>Q/4)){g.delete(a),g.set(a,{frames:s,bytes:i}),A+=i;for(const[h,n]of g){if(A<=Q)break;g.delete(h),A-=n.bytes}}}function At(){g.clear(),A=0}const Mt=a=>new Promise((s,i)=>a.toBlob(h=>{if(!h)return i(Error("Cannot encode title frame"));const n=new FileReader;n.onload=()=>s(String(n.result).slice(String(n.result).indexOf(",")+1)),n.onerror=()=>i(n.error),n.readAsDataURL(h)},"image/webp",.9));async function Pt(a,s,i,h,n){const{fps:o,width:m,height:S}=P(s),f=P({...s,resolution:"720p"}),y=a.some(t=>t.shape&&R(t.shape))?et(at(a)):null,$=!!i.wants;for(const t of a.filter(u=>gt(u)&&!u.warped)){if(!J(i,"titleFrames",t.id))continue;const u=e=>J(i,"titleFrames",t.id,e),d=xt(t,s),r=d?g.get(d):void 0;if(r){g.delete(d),g.set(d,r);for(const e of r.frames){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");await i.push("titleFrames",t.id,e)}continue}const x=[],E=t.title,M=ot(t)?1:Math.ceil(t.duration*o);if(M>1&&Math.ceil(t.duration*o)>3600)throw Error("Mỗi tiêu đề động / Motion tối đa 2 phút khi xuất MP4.");E&&!t.shape&&!t.motion&&!t.lottie&&!t.card&&!t.geo&&await lt(E);const b=t.card?await dt(t.card).catch(e=>{throw Error(N("Thẻ HTML “{0}”: {1}",[t.label,e.message]))}):null,[p,w]=b?[b.width,b.height]:t.geo?[f.width,f.height]:t.lottie?[B(t.lottie).W,B(t.lottie).H]:t.motion?[f.width,f.height]:t.shape?[j(t.shape).W,j(t.shape).H]:[1280,720],C=Object.assign(document.createElement("canvas"),{width:p,height:w}),F=C.getContext("2d");if(!F)throw Error("Canvas unavailable");let I="",O=null;const L=(e,l)=>z({layer:`export:${e.id}`,motion:e.motion,t:q(e,l/o),width:p,height:w,duration:X(e),fps:o,surface:e.pin?.scene?Y(e,a,e.start+l/o,p,w):null,space:e.space?(H(a),U(e,a,e.start+l/o,p,w,n)):null}),c=[],W="\0same",_="\0skip",K=t.shape&&!t.motion&&!t.card&&!t.lottie&&!t.geo&&!R(t.shape)?rt(t.shape):null,Z=K==null?1/0:Math.max(K,...["trimStart","trimEnd"].flatMap(e=>nt(t,e).map(l=>l.time))),v=async()=>{const e=await c.shift();if(e===_){await i.push("titleFrames",t.id,wt);return}if(e===W||e===I){x.push("="),await i.push("titleFrames",t.id,"=");return}I=e,x.push(e),await i.push("titleFrames",t.id,e)};try{for(let e=0;e<M;e++){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");if(!u(e)){c.push(Promise.resolve(_)),c.length>=D&&await v();continue}if(!$&&e>0&&(e-1)/o>Z+1e-6){c.push(Promise.resolve(W)),c.length>=D&&await v();continue}if(F.clearRect(0,0,p,w),t.motion){let l;try{l=await(O??L(t,e)),O=e+1<M&&u(e+1)?L(t,e+1):null}catch(tt){throw O?.catch(()=>{}),T(`export:${t.id}`),Error(`Motion “${t.label}”: ${tt.message}`)}F.drawImage(l,0,0),l.close()}else if(t.lottie)try{await ct(`export:${t.id}`,t.url,{W:p,H:w},it(t,e/o),C)}catch(l){throw k(`export:${t.id}`),Error(`Lottie “${t.label}”: ${l.message}`)}else if(t.geo)try{await mt(`export:${t.id}`,t.geo,{W:p,H:w},e/o,C,{wait:2e4,duration:t.duration})}catch(l){throw G(`export:${t.id}`),Error(N("Bản đồ “{0}”: {1}",[t.label,l.message]))}else b?F.drawImage(b,0,0):t.shape?(y&&H(y),ft(F,ut(t,a,e/o,m,S),{start:V(t,"trimStart",e/o),end:V(t,"trimEnd",e/o),offset:pt(t.shape)},p,w,e/o)):ht(F,E,{time:e/o,duration:t.duration});c.push(Mt(C)),c.length>=D&&await v()}for(;c.length;)await v();d&&!$&&Et(d,x)}finally{for(const e of c)e.catch(()=>{})}t.motion&&T(`export:${t.id}`),t.lottie&&k(`export:${t.id}`),t.geo&&G(`export:${t.id}`)}}function Tt(a,s,i,h){const{fps:n}=P(i),{width:o,height:m}=P({...i,resolution:"720p"}),S=Math.ceil(a.duration*n)-1,f=Object.assign(document.createElement("canvas"),{width:o,height:m}),y=f.getContext("2d");if(!y)throw Error("Canvas unavailable");const $=r=>z({layer:`export:${a.id}`,motion:a.motion,t:q(a,r/n),width:o,height:m,duration:X(a),fps:n,surface:a.pin?.scene?Y(a,s,a.start+r/n,o,m):null,space:a.space?(H(s),U(a,s,a.start+r/n,o,m,h)):null});let t=null,u=-1;const d=r=>{r?.p.then(x=>x.close(),()=>{})};return{W:o,H:m,async frame(r){if(r=Math.max(0,Math.min(S,r)),r===u)return f;for(;t&&t.i<r;){const M=t;t=null,await M.p.then(b=>b.close(),()=>{})}const x=t&&t.i===r?t.p:$(r);t&&t.i!==r&&d(t),t=null;let E;try{E=await x}catch(M){throw T(`export:${a.id}`),Error(`Motion “${a.label}”: ${M.message}`)}return t=r<S?{i:r+1,p:$(r+1)}:null,y.clearRect(0,0,o,m),y.drawImage(E,0,0),E.close(),u=r,f},close(){d(t),t=null,T(`export:${a.id}`)}}}export{At as clearFrameCache,xt as frameCacheKey,Tt as liveMotion,Pt as renderTitleFrames};
@@ -1 +0,0 @@
1
- import{b as w,gD as k,j7 as v,dy as S}from"./remote-sTZauTqM.js";import{a as $}from"./shotFxAgent-CzHfe75S.js";import{a as F,V as y,b as N}from"./vfxTrack-CqiQDEYm.js";import{Vector3 as _}from"./three.module-Bx43vjkH.js";import"./api-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const A=4,C=1.25;function M(t,c,s){return t.updateMatrixWorld(),new _(c*2-1,1-s*2,.5).unproject(t).sub(t.position).normalize()}function T(t,c,s){const i=k(t),n=Math.max(1e-6,i.duration),f=t.items.find(r=>r.kind==="person"&&!r.hidden);return c.points.map(([r,u,h])=>{const m=Math.max(0,Math.min(1,r/n)),d=v(i,m),a=M(d,u,h);let p=s??NaN;if(!Number.isFinite(p)&&f){const l=S(f,i,m);p=new _(l.position[0],l.position[1]+C*Math.max(.3,l.scale[1]),l.position[2]).sub(d.position).dot(a)}(!Number.isFinite(p)||p<.3)&&(p=A);const b=d.position.clone().addScaledVector(a,p);return{t:m,d:p,position:[b.x,b.y,b.z].map(l=>Math.round(l*1e4)/1e4)}})}function K(t,c,s){const i=k(c).duration;try{if(t.track!=null)return F(t.track,i);const n=String(t.source??"");if(!y.includes(n))return`give track {fps, points} or source ${y.join(" / ")}`;const f=c.plate?.timelineClipId,r=f?s.timelineClip?.(f):void 0;return r?N(r,n,{side:t.side==="left"?"left":"right",point:typeof t.point=="string"?t.point:"palm",...typeof t.object=="string"?{object:t.object}:{},to:i}):"the Timeline clip of this VFX scene is not open in this tab: pass `track` (MCP: shot_run_tool follow_track with timeline {project_id, clip_id} fills it)"}catch(n){return n.message}}function L(t,c){const s=c.getStage();if(!s.plate)return{ok:!1,error:"follow_track needs a VFX scene: one made from a filmed Timeline clip (MCP shot_create_scene with from_clip, or the clip's 3D button)"};const i=$(s.items.filter(o=>o.kind==="fx"),String(t.name??""));if(!i?.fx)return{ok:!1,error:`no effect named '${String(t.name)}' (scene_summary lists the effects)`};const n=s.items.find(o=>o.trackAnchor?.effect===i.id);if(t.stop===!0)return n?(c.setStage(o=>({...o,items:o.items.filter(e=>e.id!==n.id).map(e=>e.id===i.id?{...e,fx:{...e.fx,...e.fx.attach?.to===n.id?{attach:void 0}:{},...e.fx.target?.to===n.id?{target:void 0}:{}}}:e),shots:o.shots.map(e=>({...e,...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([j])=>j!==n.id))}:{}}))})),{ok:!0,name:i.name,stopped:!0}):{ok:!1,error:`${i.name} follows no track`};const f=K(t,s,c);if(typeof f=="string")return{ok:!1,error:f};const r=t.depth_m==null?void 0:Number(t.depth_m);if(r!==void 0&&!(r>=.3&&r<=200))return{ok:!1,error:"depth_m must be 0.3–200 (metres from the camera)"};const u=t.offset==null?void 0:Array.isArray(t.offset)&&t.offset.length===3&&t.offset.every(o=>Number.isFinite(Number(o))&&Math.abs(Number(o))<=20)?t.offset.map(Number):null;if(u===null)return{ok:!1,error:"offset must be [x, y, z] metres (±20)"};const h=t.role==="target"?"target":"attach",m=T(s,f,r),d=t.track!=null?"given":t.source==="hand"?`hand:${t.side==="left"?"left":"right"}:${typeof t.point=="string"?t.point:"palm"}`:t.source==="object"&&typeof t.object=="string"?`object:${t.object}`:String(t.source),a=n?{...n,trackAnchor:{effect:i.id,source:d}}:{...w("sphere",s.items.length),name:`${i.name} · điểm bám`.slice(0,60),color:"#ffffff",trackAnchor:{effect:i.id,source:d}};a.position=m[0].position,a.rotation=[0,0,0],a.scale=[1,1,1];const p=m.map((o,e)=>({id:`${a.id}-t${e}`,time:o.t,position:o.position,rotation:[0,0,0],scale:[1,1,1]})),b={...i.fx,...h==="attach"?{attach:{to:a.id,follow:"position",...u?{offset:u}:{}}}:{target:{to:a.id,part:"center"}}};c.setStage(o=>({...o,items:[...o.items.filter(e=>e.id!==a.id).map(e=>e.id===i.id?{...e,fx:b}:e),a],shots:o.shots.map(e=>e.id===o.activeShot?{...e,objectKeys:{...e.objectKeys,[a.id]:p}}:e)}));const l=m.map(o=>o.d).sort((o,e)=>o-e),x=k(s).duration;return{ok:!0,name:i.name,anchor:a.name,source:d,role:h,samples:m.length,from_s:+f.points[0][0].toFixed(2),to_s:+f.points.at(-1)[0].toFixed(2),depth_m:+l[l.length>>1].toFixed(2),note:`${i.name} now ${h==="attach"?"rides on":"aims at"} the tracked point (${m.length} keys over ${x.toFixed(1)} s, ${r?`${r} m from the camera`:"at the filmed person's distance (the stand-in; run follow_plate first for a person who walks toward / away from the camera)"}). Re-run after the track changes; stop:true detaches. Export again (export_video vfx) to update the Timeline passes.`}}export{L as followTrack,T as trackWorldPoints};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShotComposer-Dprx-Yi7.js","assets/titleFrameBudget-3MFHWIT6.js","assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/tool-BhIsq238.js","assets/timelineProps-tN2YsMYN.js","assets/thumb-Cs636sYt.js","assets/shotFxAgent-CzHfe75S.js","assets/cameraPresets-B234aNzE.js","assets/weaponDuel-B2wTffPC.js","assets/skin-BkaT2QuX.js","assets/views-BdWnG2xK.js","assets/motionBlur-uAm030t9.js","assets/library-BtBrCaFk.js","assets/ShotComposer-VixLbeMe.css"])))=>i.map(i=>d[i]);
2
- import{_ as l}from"./titleFrameBudget-3MFHWIT6.js";import{R as h}from"./api-BsKbf3l3.js";import{di as w}from"./remote-sTZauTqM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";let m=Promise.resolve();const p=o=>new Promise(r=>setTimeout(r,o));function R(o,r,{timeoutMs:d=6e4}={}){const i=async()=>{const e=document.createElement("div");Object.assign(e.style,{position:"fixed",left:"-20000px",top:"0",width:"960px",height:"540px",pointerEvents:"none",contain:"strict"}),e.setAttribute("aria-hidden","true"),document.body.appendChild(e);const s=w.createRoot(e);try{const{default:u}=await l(async()=>{const{default:t}=await import("./ShotComposer-Dprx-Yi7.js");return{default:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));let n=null;s.render(h.createElement(u,{nodeId:o,background:t=>{n=t}}));const c=Date.now()+d;for(;!n?.ready();){if(Date.now()>c)throw new Error("3D Shot did not start in time");await p(60)}for(;;)try{return await r(n)}catch(t){if(!/chưa tải xong/.test(t.message)||Date.now()>c)throw t;await p(500)}}finally{s.unmount(),e.remove()}},a=m.then(i,i);return m=a.catch(()=>{}),a}export{R as withBackgroundScene};
@@ -1 +0,0 @@
1
- import{it as E,iu as A,iv as j,bc as y,iw as S,b1 as M}from"./remote-sTZauTqM.js";import{dB as v,hl as N,dE as F,dD as _,e1 as x}from"./titleFrameBudget-3MFHWIT6.js";const w=Object.freeze(["hand","roto","planar","face","object"]),T=15,b=900,D=t=>t?.crop??{left:0,right:0,top:0,bottom:0},O=(t,n,a)=>{const o=D(t);return[o.left+n*(1-o.left-o.right),o.top+a*(1-o.top-o.bottom)]},m=t=>Math.round(t*1e4)/1e4;function $(t){if(!t||t.kind!=="video")return[];const n=[];t.hands?.data&&n.push({source:"hand",label:"Tay (tracking tay)",points:E,sides:["right","left"]}),t.roto?.points?.length&&n.push({source:"roto",label:"Điểm Roto"}),t.planar?.frames?.length&&!v(t.planar)&&n.push({source:"planar",label:"Mặt phẳng (planar)"}),t.face?.f?.length&&n.push({source:"face",label:"Khuôn mặt"});for(const a of t.objectTracks??[])a?.frames?.length&&n.push({source:"object",object:a.id,label:`Vật thể 3D ${a.name||a.id}`});return n}function C(t,n,{side:a="right",point:o="palm",object:i,from:l=0,to:c,fps:f=T}={}){if(!t||t.kind!=="video")throw Error("VFX tracks come from a filmed video clip");if(!w.includes(n))throw Error(`source must be ${w.join(" / ")}`);const p=Math.min(t.duration,c??t.duration),k=1/Math.max(1,Math.min(30,f)),d=[];let h;if(n==="hand"){if(!t.hands?.data)throw Error("this clip has no hand track yet (Timeline: Track hands, or edit_timeline handAttach once)");const e=A(t.hands),r=a==="left"?1:0,s=E.includes(o)?o:"palm";h=u=>{const g=j(e,y(t,u),r);return g?S(g,s):null}}else if(n==="roto"){if(!t.roto?.points?.length)throw Error("this clip has no Roto point track");h=e=>N(t,e)}else if(n==="planar"){if(!t.planar?.frames?.length)throw Error(v(t.planar)?"this planar track is stored apart from the clip: open the Timeline in the editor and run it there":"this clip has no planar track");h=e=>{if(!F(t.planar,e))return null;const r=_(t.planar,e);return O(t,r.reduce((s,u)=>s+u[0],0)/r.length,r.reduce((s,u)=>s+u[1],0)/r.length)}}else if(n==="face"){if(!t.face?.f?.length)throw Error("this clip has no face track");h=e=>{const r=x(t,e);return r&&r.score>0?[r.cx,r.cy]:null}}else{const e=(t.objectTracks??[]).find(r=>r?.id===i)??(i==null?t.objectTracks?.[0]:null);if(!e?.frames?.length)throw Error(i==null?"this clip has no 3D-tracked object (edit_timeline trackObject3D)":`no 3D-tracked object ${i} on this clip`);h=r=>{if(r<e.frames[0][0]-1e-6||r>e.frames.at(-1)[0]+1e-6)return null;const s=M(e,[0,0,0],r);return s?[s[0]/e.w,s[1]/e.h]:null}}for(let e=Math.max(0,l);e<=p+1e-6&&d.length<b;e+=k){const r=h(Math.min(e,p));r&&Number.isFinite(r[0])&&Number.isFinite(r[1])&&r[0]>-.5&&r[0]<1.5&&r[1]>-.5&&r[1]<1.5&&d.push([m(Math.min(e,p)),m(r[0]),m(r[1])])}if(d.length<2)throw Error(`the ${n} track does not see its target in this clip (fewer than 2 samples)`);return{fps:Math.round(1/k),points:d}}function X(t,n=600){if(!t||typeof t!="object"||!Array.isArray(t.points))throw Error("track must be {fps, points: [[t, u, v], …]}");if(t.points.length<2||t.points.length>b)throw Error(`track: 2 to ${b} points`);let a=-1/0;const o=t.points.map(i=>{if(!Array.isArray(i)||i.length<3||!i.slice(0,3).every(p=>Number.isFinite(Number(p))))throw Error("each track point is [t, u, v]");const[l,c,f]=i.map(Number);if(l<0||l>n+.001||l<=a)throw Error(`track times must rise within the shot (0–${n} s)`);if(c<-.5||c>1.5||f<-.5||f>1.5)throw Error("track u / v are fractions of the picture (−0.5..1.5)");return a=l,[l,c,f]});return{fps:Number.isFinite(Number(t.fps))?Number(t.fps):T,points:o}}export{w as V,X as a,C as b,$ as v};
@@ -1 +0,0 @@
1
- import{ir as pt,is as Y,ff as ut,fe as mt,fh as Z,fj as B,hy as kt,b as gt,fk as bt,fu as tt,fv as et,hu as Mt,fL as yt,hx as wt}from"./remote-sTZauTqM.js";import{F as vt}from"./rigTrack-Bx9QHlFv.js";const z=t=>pt(t)??(Y(t)?{clip:Y(t),pack:{id:"fist"}}:null),st=Object.freeze({spear:{"spear-thrust":"thrust","spear-overhead":"high","spear-sweep":"low","spear-spin":"side","spear-dive-thrust":"thrust"},katana:{"katana-overhead":"high","katana-diagonal":"high","katana-horizontal":"side","katana-rising":"side","katana-thrust":"thrust","katana-spin-cut":"side"},staff:{"staff-jab":"thrust","staff-overhead":"high","staff-sweep":"low","staff-rising":"side","staff-spin":"side"},fist:{"fist-lunge-punch":"thrust","fist-rising-uppercut":"side","fist-flying-kick":"side","fist-ground-slam":"high","fist-low-lunge":"thrust"}}),it={high:"block-high",side:"block-side",thrust:"block-side",low:null},jt=Object.freeze({spear:1.42,katana:.98,staff:1.1,fist:0}),Ot={body:.05,blocked:.22,miss:.18},Ft=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(z(t).clip),at.set(t,e)),e},Kt=(t,e)=>t[Math.max(0,Math.min(t.length-1,Math.round(e*30)))];function ht(t){const e=z(t).clip.keys.filter(a=>a.strike).at(-1);return e?e.t:0}const At=t=>z(t).clip.keys.filter(e=>e.strike).at(-1)?.limb??"handR",ot=(t,e)=>Kt(dt(t),e).dz??0;function $t(t){const{pack:e}=z(t),a=dt(t),h=ht(t),o=At(t);let f=0;for(const l of a){if(Math.abs(l.t-h)>.1)continue;if(e.id==="fist"){const j=vt(l.pose),m=j[o.replace("foot","toe")];f=Math.max(f,m[2]-j.pelvis[2]);continue}const r=ut(l.pose),u=r.front[2]+r.dir[2]*jt[e.id];f=Math.max(f,u)}return f}function St(t){let e=t>>>0||1;return()=>{e=e+1831565813>>>0;let a=Math.imul(e^e>>>15,1|e);return a=a+Math.imul(a^a>>>7,61|a)^a,((a^a>>>14)>>>0)/4294967296}}function Tt(t,e=4,a=1){const h=St(a),o=[];let f=0,l=["",""];for(let r=0;r<e;r++){r>0&&h()<.62&&(f=1-f);const u=t[f],j=t[1-f],m=Object.keys(st[u]).filter(S=>S!==l[f]),g=m[Math.floor(h()*m.length)],C=st[u][g];l[f]=g;const i=h();let y=r===e-1?"body":i<.5?"blocked":i<.78?"miss":"body";y==="blocked"&&!it[C]&&(y="miss");const $=`${j}-${y==="blocked"?it[C]:y==="miss"?"dodge-back":"hit"}`,D=ht(g),O=z($).clip.contact??0,b=Math.max(Ft,$t(g)+Ot[y]+ot(g,D)+ot($,O));o.push({attacker:f,attack:g,defence:$,result:y,strike:D,contact:O,gap:Math.round(b*1e3)/1e3})}return o}const x=[.18,.42],nt=t=>(t.kind==="model"?(t.model?.height??2)/1.8:Mt(t))*(t.scale[1]||1),L=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const a=v(t),h=a.duration/e,o=l=>l?.map(r=>({...r,time:Math.min(1,r.time*h)})),f={...a,duration:e,cameraKeys:o(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([l,r])=>[l,o(r)||[]])),...a.impacts?{impacts:o(a.impacts)}:{},...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([l,r])=>[l,o(r)||[]]))}:{}};return{...t,shots:t.shots.map(l=>l.id===a.id?f:l)}}const ct=(t,e,a)=>{const h=v(t);return{...t,shots:t.shots.map(o=>o.id===h.id?{...o,objectKeys:{...o.objectKeys,[e]:a(o.objectKeys?.[e]||[],o)}}:o)}},T=(t,e,a)=>{const h=v(t),o=yt(t.items.find(f=>f.id===e.id),h,Math.min(1,a/h.duration));return{position:o.position,yaw:o.rotation[1]}};function zt(t,e,a){const h=t.items.find(s=>s.id===e.a),o=t.items.find(s=>s.id===e.b);if(!h||!o||!Z(h)||!Z(o))return{ok:!1,error:"two people are needed"};if(h.id===o.id)return{ok:!1,error:"two different people are needed"};const f=Math.max(1,Math.min(10,Math.round(e.exchanges))),l=Tt(e.packs,f,e.seed),r=[h,o],u=[nt(h),nt(o)],j=[],m=Math.max(0,e.start),g=v(t),C=m+.5+l.reduce((s,c)=>s+Math.max(B(c.attack).duration,c.strike-c.contact+B(c.defence).duration)+1.4+x[1],0);let i=C>g.duration?rt(t,Math.min(300,C)):t;const M=T(i,h,m),y=l[0].gap*(u[0]+u[1])/2,$=[Math.sin(L(M.yaw)),0,Math.cos(L(M.yaw))],D=[M.position[0]+$[0]*y,M.position[1],M.position[2]+$[2]*y];for(const[s,c,n]of[[h,M.position,M.yaw],[o,D,M.yaw+180]])i=ct(i,s.id,(d,k)=>[...d.filter(p=>p.time*k.duration<m-1e-6),{id:a(),time:m/k.duration,position:c.map(p=>+p.toFixed(3)),rotation:[0,+n.toFixed(1),0],scale:s.scale}]);const O=(s,c,n)=>{const d=v(i),k=B(c),p=wt(i,r[s].id,k,{start:n/d.duration,newId:a,loop:!1});if(!p.ok)throw new Error(`${r[s].name}: ${p.error}`);return i=p.stage,n+k.duration};let b=m+.35,S=m;const E=[];let q=(e.seed*9301+49297)%233280;const lt=()=>(q=(q*9301+49297)%233280,q/233280);try{l.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const F=T(i,r[0],b).position,K=T(i,r[1],b).position;return Math.hypot(K[0]-F[0],K[2]-F[2])};for(let F=0;F<3;F++){const K=p()-s.gap*k;if(Math.abs(K)<.3*k)break;K>0?b=O(n,`${e.packs[n]}-advance`,b):b=O(d,`${e.packs[d]}-retreat`,b)}const N=Math.max(0,s.contact-s.strike),w=b+N,_=w+s.strike-s.contact,P=p()-s.gap*k,G=O(n,s.attack,w),ft=O(d,s.defence,_),H=r[n],U=T(i,H,w).yaw,W=[Math.sin(L(U)),Math.cos(L(U))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,P));i=ct(i,H.id,(F,K)=>F.map(A=>{const I=A.time*K.duration;if(I<w-1e-6||I>G+1e-6)return A;const R=Math.min(1,(I-w)/Math.max(.001,s.strike)),Q=R*R*(3-2*R),X={...A,position:[+(A.position[0]+W[0]*V*Q).toFixed(3),A.position[1],+(A.position[2]+W[1]*V*Q).toFixed(3)]};return A.strike&&Math.abs(I-J)<.06?{...X,hit:s.result}:X})),E.push({...s,time:+J.toFixed(2),attackerName:H.name}),S=Math.max(G,ft),b=S+x[0]+(x[1]-x[0])*lt(),c===l.length-1&&j.push(`${r[d].name} dính đòn kết`)})}catch(s){return{ok:!1,error:s.message}}if(v(i).duration>g.duration&&(i=rt(i,Math.max(g.duration,Math.min(300,Math.ceil((S+.6)*10)/10)))),i=kt(i).stage,e.packs.includes("fist")){const s=v(i),c=[],n={};E.forEach((d,k)=>{if(d.result==="miss"||e.packs[d.attacker]!=="fist")return;const p=T(i,r[0],d.time).position,N=T(i,r[1],d.time).position,w=(u[0]+u[1])/2,_=`duelfx-${r[d.attacker].id}-${Math.round(d.time*1e3)}`,P=d.result==="body";c.push({...gt("fx",i.items.length+c.length),id:_,name:`Vòng xung kích ${c.length+1}`,position:[+((p[0]+N[0])/2).toFixed(2),0,+((p[2]+N[2])/2).toFixed(2)],color:P?"#ffd27a":"#9fdcff",fx:{preset:"vong_xung_kich",cat:"vong-xung-kich",intensity:P?.9:.75,seed:500+k,start:d.time,duration:.6,loop:!1,auto:"hit",params:{size:(P?1.05:.85)*w,height:+(1.35*w).toFixed(2),hits:1,gap:.3}}}),n[_]={start:d.time,duration:.6}}),c.length&&(i={...i,items:[...i.items,...c],shots:i.shots.map(d=>d.id===s.id?{...d,fxTiming:{...d.fxTiming,...n}}:d)})}if(e.hitStops!==!1){const s=v(i);let c=bt(s.timing,s.duration);c=tt(c,E.filter(n=>n.result==="blocked").map(n=>n.time),et.light,s.duration),c=tt(c,E.filter(n=>n.result==="body").map(n=>n.time),et.heavy,s.duration),i={...i,shots:i.shots.map(n=>n.id===s.id&&c?{...n,timing:c}:n)}}return{ok:!0,stage:i,plan:E,end:+S.toFixed(2),notes:j}}export{st as D,zt as s};