clipoox-render 0.4.6 → 0.4.8

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 (142) hide show
  1. package/package.json +2 -2
  2. package/scripts/render-local.mjs +2656 -1672
  3. package/shared/photocraft/LICENSE.txt +206 -0
  4. package/shared/photocraft/clipoox_photo.js +396 -0
  5. package/shared/photocraft/clipoox_photo_bg.wasm +0 -0
  6. package/web/assets/{FxEmbed-ROS6C_HI.js → FxEmbed-adbxHEBi.js} +1 -1
  7. package/web/assets/ImageStudio-CMxiT1jp.js +3 -0
  8. package/web/assets/ImageStudio-De_DCTrz.css +1 -0
  9. package/web/assets/{MotionEmbed-E2hCysi-.js → MotionEmbed-CDUIyjk0.js} +1 -1
  10. package/web/assets/{PluginStore-CwUSpwPp.js → PluginStore-By_pdOOg.js} +2 -2
  11. package/web/assets/ShotComposer-DcwWZ-eP.css +1 -0
  12. package/web/assets/ShotComposer-XIbJ4nNm.js +287 -0
  13. package/web/assets/{TemplateEmbed-qG1AXdtf.js → TemplateEmbed-a01nKECT.js} +1 -1
  14. package/web/assets/{TimelinePlugins-CB1b6-Cb.js → TimelinePlugins-CqLMVjuh.js} +4 -4
  15. package/web/assets/TimelineShotFx-QmkyCg31.js +2 -0
  16. package/web/assets/{TransitionEmbed-Dym9P7--.js → TransitionEmbed-Cbwlxfl2.js} +1 -1
  17. package/web/assets/{Whiteboard-BdGjJZXW.js → Whiteboard-ChYqIr3v.js} +1 -1
  18. package/web/assets/{aerial-yLD_gDzw.js → aerial-CZeCeacv.js} +2 -2
  19. package/web/assets/{agentTools-B7g6tXTR.js → agentTools-DW2ETnxE.js} +2 -2
  20. package/web/assets/{aiInbetween-6eKDYbYS.js → aiInbetween-De98iM4m.js} +2 -2
  21. package/web/assets/analyzerRun-D5-g-Vxe.js +1 -0
  22. package/web/assets/{analyzerSandbox-N92T6amg.js → analyzerSandbox-E3CdovIk.js} +1 -1
  23. package/web/assets/{api-Dnl2uaKO.js → api-CZoVJ9Fy.js} +87 -87
  24. package/web/assets/auraTrack-ClhHuqlf.js +1 -0
  25. package/web/assets/{breakthrough-DSiuVwEX.js → breakthrough-DTpiUIZd.js} +2 -2
  26. package/web/assets/{cameraPresets-Cfn7qhXK.js → cameraPresets-DD0WmxiI.js} +1 -1
  27. package/web/assets/{cameraTracker-DHdF8Zqx.js → cameraTracker-Df9jWmz6.js} +2 -2
  28. package/web/assets/{captionLayout-cckQ7p-t.js → captionLayout-eiu9QPJu.js} +1 -1
  29. package/web/assets/{clientExport-pkLbOmEF.js → clientExport-BXegTdNc.js} +1 -1
  30. package/web/assets/{clientJobs-CcsLDqFM.js → clientJobs-eB-lNyin.js} +2 -2
  31. package/web/assets/clipoox_photo_bg-BQ0aVNY0.wasm +0 -0
  32. package/web/assets/depthEstimate-CfwX-tXP.js +1 -0
  33. package/web/assets/{directorTools-DMsatulF.js → directorTools-ABbI8m0e.js} +1 -1
  34. package/web/assets/distortFrames-DMnZ8OYh.js +2 -0
  35. package/web/assets/distortGL-DQu0Df2c.js +18 -0
  36. package/web/assets/{domino-DBrinEUu.js → domino-trmDBvfH.js} +1 -1
  37. package/web/assets/{editTools-BNnAvCw-.js → editTools-DEFo9Ahv.js} +1 -1
  38. package/web/assets/{engine-Co-ivzlQ.js → engine-Y-GotDIy.js} +1 -1
  39. package/web/assets/exportGlb-BeLpJKJT.js +2 -0
  40. package/web/assets/{faceTracker-ClR-lS6Y.js → faceTracker-BeSFnLM8.js} +1 -1
  41. package/web/assets/{fightDirector-BlpVAURl.js → fightDirector-Dfz3vu5-.js} +1 -1
  42. package/web/assets/{fightDrama-BK0QidpM.js → fightDrama-CNVn69s0.js} +2 -2
  43. package/web/assets/{focusTool-sVOb2GGS.js → focusTool-Dd2UDkiO.js} +1 -1
  44. package/web/assets/{frameSink-CSRqCnwI.js → frameSink-Rj02YES5.js} +3 -3
  45. package/web/assets/{glTransitionSources.generated-q0H-ZbnZ.js → glTransitionSources.generated-Cs8lVRqs.js} +438 -2
  46. package/web/assets/{gpuCompose-B5bgbHdQ.js → gpuCompose-DkkKH1Ab.js} +1 -1
  47. package/web/assets/gpuExport-DwrXpVGF.js +199 -0
  48. package/web/assets/{handMatte-Dj2taFoC.js → handMatte-B5sUeqKi.js} +1 -1
  49. package/web/assets/{handTracker-c6_rvuwA.js → handTracker-CQV-D7va.js} +2 -2
  50. package/web/assets/i18n-ClNt3LKg.js +3 -0
  51. package/web/assets/{index-Ds_8isyf.js → index-D2u6mD-8.js} +1 -1
  52. package/web/assets/layer-worker-DP0N05Ua.js +5 -0
  53. package/web/assets/library-cb43ZEmy.js +1 -0
  54. package/web/assets/{lottieLayer-Cv8ub9f6.js → lottieLayer-DEw0c3to.js} +4 -4
  55. package/web/assets/main-C_XcvNyC.js +311 -0
  56. package/web/assets/{main-B_MAOvi6.css → main-DlzdW5C4.css} +1 -1
  57. package/web/assets/{mapBake-DtQboFIX.js → mapBake-BUWz0cSx.js} +1 -1
  58. package/web/assets/maskTrack-GYpJyKFw.js +1 -0
  59. package/web/assets/matteFixRun-BCVsuSxf.js +1 -0
  60. package/web/assets/{objectLocate-XuAcemlO.js → objectLocate-CjIlo_u0.js} +1 -1
  61. package/web/assets/{objectSegmenter-D66spD7o.js → objectSegmenter-C4T9qgUL.js} +1 -1
  62. package/web/assets/{objectTrack.worker-BZS6WZ6l.js → objectTrack.worker-BVvsDmR0.js} +1450 -908
  63. package/web/assets/{pathTracer-DykgPkkh.js → pathTracer-DgL1_83l.js} +2 -2
  64. package/web/assets/{pendingMatte-BWBIWajI.js → pendingMatte-DPTe6xoZ.js} +2 -2
  65. package/web/assets/peopleMatte-C1hruEM6.js +1 -0
  66. package/web/assets/{personAi-EhBknW6X.js → personAi-Cjg9KKeH.js} +2 -2
  67. package/web/assets/{personHq-Ca351o06.js → personHq-CBP8v_cw.js} +2 -2
  68. package/web/assets/photo.worker-DK_ulTzR.js +1 -0
  69. package/web/assets/photoRun-lZ2BdSEk.js +2 -0
  70. package/web/assets/photoTools-DmUh69Qk.js +1 -0
  71. package/web/assets/plateCamera-DLqlXhMp.js +1 -0
  72. package/web/assets/{plateCameraMatch-GPZl1fQQ.js → plateCameraMatch-4VUlUMi-.js} +2 -2
  73. package/web/assets/{plateFollow-CJUilsNV.js → plateFollow-D2rjnmZA.js} +2 -2
  74. package/web/assets/plateMatte-0tTG7oeO.js +2 -0
  75. package/web/assets/{pluginAutomation-DAPHWZPN.js → pluginAutomation-ClFdpcCR.js} +1 -1
  76. package/web/assets/popTools-B38V4wub.js +1 -0
  77. package/web/assets/{poseTracker-CzEKvJph.js → poseTracker-qtuytI-L.js} +1 -1
  78. package/web/assets/{productTools-ce-zyZO0.js → productTools-DlC5vWjx.js} +2 -2
  79. package/web/assets/remote-CpkPQOQH.js +989 -0
  80. package/web/assets/{rigTrack-DMyqb0pb.js → rigTrack-BbKqZGs7.js} +1 -1
  81. package/web/assets/{rotoMaskStore-pE1AIt3I.js → rotoMaskStore-BZBJLcCp.js} +1 -1
  82. package/web/assets/{rotoMatte-7b7Ow64f.js → rotoMatte-BI-vjjrv.js} +1 -1
  83. package/web/assets/rotoscope-DuNcCxQy.js +1 -0
  84. package/web/assets/{sceneTrack-DlAH5s74.js → sceneTrack-CO4fTjft.js} +1 -1
  85. package/web/assets/{sceneTrack-CA21MCOP.js → sceneTrack-_n6WKKQv.js} +1 -1
  86. package/web/assets/{sceneTrack.worker-COlhlHRe.js → sceneTrack.worker-f2d-WOzw.js} +1496 -954
  87. package/web/assets/{shot-worker-DL1ZoIym.js → shot-worker-BSmfIXHO.js} +1 -1
  88. package/web/assets/{shotFxAgent-DqngnGFb.js → shotFxAgent-L2GG88W3.js} +1 -1
  89. package/web/assets/{skin-xFScwS3T.js → skin-CirUiqcr.js} +1 -1
  90. package/web/assets/{spark.module-DjaIF6J1.js → spark.module-3Q8DniuL.js} +1 -1
  91. package/web/assets/{spellDuel-BYNtnE8f.js → spellDuel-2CDLbiLQ.js} +2 -2
  92. package/web/assets/{store-CpqHUcA2.js → store-D3Y663py.js} +1 -1
  93. package/web/assets/{surfaceLight-C7YI9SV8.js → surfaceLight--HQj7xhO.js} +1 -1
  94. package/web/assets/{surfacePin-CzpUj1Cw.js → surfacePin-BCmgw-40.js} +2 -2
  95. package/web/assets/{textAnimators-B9vO_hbP.js → textAnimators-C4eMnVRD.js} +1 -1
  96. package/web/assets/{thumb-BTFsBS1u.js → thumb-M9B_goj-.js} +1 -1
  97. package/web/assets/{timeline3d-DrFaMPPB.js → timeline3d-BcW68fQr.js} +2 -2
  98. package/web/assets/{timeline3dExport-Uo0S0CR0.js → timeline3dExport-DgnorHLm.js} +1 -1
  99. package/web/assets/timelineComp-Ciu9JCWJ.js +1 -0
  100. package/web/assets/timelineOps-f1WsVbgS.js +526 -0
  101. package/web/assets/{timelineProps-0v-s69pw.js → timelineProps-CE1R11Hx.js} +1 -1
  102. package/web/assets/{timelineText-DurRhyuh.js → timelineText-Cppd4KB7.js} +1 -1
  103. package/web/assets/{titleArt-CnC0A7x7.js → titleArt-D0YI5xT2.js} +3 -3
  104. package/web/assets/{titleFrameBudget-DsM0V482.js → titleFrameBudget-h4nOQ5u9.js} +1717 -1175
  105. package/web/assets/titleFrames-DnCzi_AI.js +1 -0
  106. package/web/assets/{tool-D1FpErrX.js → tool-tp6gat1J.js} +1 -1
  107. package/web/assets/{tools-DIvrRu-5.js → tools-C07G9KUM.js} +1 -1
  108. package/web/assets/{toonTools-D9MNdRty.js → toonTools-Cazx2CL7.js} +2 -2
  109. package/web/assets/{trackAnchor-XvUuvkWP.js → trackAnchor-DoqFDcJB.js} +1 -1
  110. package/web/assets/{userFonts-Djka6RJX.js → userFonts-BlVEJfDk.js} +1 -1
  111. package/web/assets/{vfxAlpha-B-JzzRI1.js → vfxAlpha-Bp6VgIGN.js} +1 -1
  112. package/web/assets/vfxBackground-BFq44Srn.js +2 -0
  113. package/web/assets/{videoExport-NN-QijHd.js → videoExport-Cz02XKtX.js} +1 -1
  114. package/web/assets/{views-RQBs4zva.js → views-CNF3Afse.js} +1 -1
  115. package/web/assets/{weaponDuel-DKAEYJjO.js → weaponDuel-ChqBQo_b.js} +1 -1
  116. package/web/assets/{windowFrames-DhhJLIs-.js → windowFrames-dBMXwGek.js} +1 -1
  117. package/web/layer-worker.html +3 -3
  118. package/web/shot-worker.html +24 -24
  119. package/web/assets/ShotComposer-DLxWpdYH.js +0 -287
  120. package/web/assets/ShotComposer-deLi4grZ.css +0 -1
  121. package/web/assets/TimelineShotFx-CyHTgJHj.js +0 -2
  122. package/web/assets/analyzerRun-Cr-_79RH.js +0 -1
  123. package/web/assets/auraTrack-C8eAEIWQ.js +0 -1
  124. package/web/assets/depthEstimate-Cav4MmQ1.js +0 -1
  125. package/web/assets/distortFrames-D_v-aSVO.js +0 -2
  126. package/web/assets/distortGL-vhnBRB59.js +0 -12
  127. package/web/assets/exportGlb-D3PrWUvi.js +0 -2
  128. package/web/assets/gpuExport-oA2mUsdm.js +0 -198
  129. package/web/assets/i18n-C9zFX25m.js +0 -3
  130. package/web/assets/layer-worker-ClVZG6ZW.js +0 -5
  131. package/web/assets/library-BK0QVG4O.js +0 -1
  132. package/web/assets/main-CwrkBJ63.js +0 -309
  133. package/web/assets/maskTrack-D4QZfMWc.js +0 -1
  134. package/web/assets/matteFixRun-CytaeRzS.js +0 -1
  135. package/web/assets/plateCamera-BcdXD1uI.js +0 -1
  136. package/web/assets/plateMatte-CoEoVjxZ.js +0 -2
  137. package/web/assets/remote-8XzEAnAJ.js +0 -974
  138. package/web/assets/rotoscope-BUqNTKLd.js +0 -1
  139. package/web/assets/timelineComp-i-zdaoB2.js +0 -1
  140. package/web/assets/timelineOps-DSSaDsU2.js +0 -525
  141. package/web/assets/titleFrames-C8kvflgT.js +0 -1
  142. package/web/assets/vfxBackground-b053ziDK.js +0 -2
@@ -0,0 +1 @@
1
+ import{b_ as P,eC as it,eD as nt,ju as st,eH as B,jv as lt,dZ as ht,eI as dt,eE as I,d$ as G,eG as z,eL as Q,eK as X,eM as tt,eJ as et}from"./titleFrameBudget-h4nOQ5u9.js";import{l as mt,d as ct}from"./titleArt-D0YI5xT2.js";import{i as L,j as ut,s as J,d as D,l as pt,k as V,f as ft,e as N,a as wt,p as gt,t as xt,m as at}from"./lottieLayer-DEw0c3to.js";import{wantsFrame as q,SKIPPED_FRAME as Et}from"./frameSink-Rj02YES5.js";import{t as U}from"./i18n-ClNt3LKg.js";import"./textAnimators-C4eMnVRD.js";import"./rigTrack-BbKqZGs7.js";import"./api-CZoVJ9Fy.js";import"./index-CKtv7gGE.js";const Mt=e=>z(e.title)||!!e.shape||!!e.motion||!!e.lottie||!!e.card||!!e.geo,Y=e=>e.kind==="image"&&!!e.title?.text&&!e.url&&!z(e.title),R=4,Z=192*1024*1024,x=new Map;let T=0;function bt(e,h){if(e.geo||e.shape&&L(e.shape)||e.pin?.scene||e.space)return null;const{start:n,track:m,...l}=e;return JSON.stringify([h,l])}function yt(e,h){const n=h.reduce((m,l)=>m+l.length,0);if(!(n>Z/4)){x.delete(e),x.set(e,{frames:h,bytes:n}),T+=n;for(const[m,l]of x){if(T<=Z)break;x.delete(m),T-=l.bytes}}}function Ot(){x.clear(),T=0}const Ft=(e,h=!1)=>new Promise((n,m)=>e.toBlob(l=>{if(!l)return m(Error("Cannot encode title frame"));const i=new FileReader;i.onload=()=>n(String(i.result).slice(String(i.result).indexOf(",")+1)),i.onerror=()=>m(i.error),i.readAsDataURL(l)},h?"image/png":"image/webp",.9));async function Rt(e,h,n,m,l,{local:i=!1}={}){const{fps:o,width:v,height:y}=P(h),f=P({...h,resolution:"720p"}),F=e.some(t=>t.shape&&L(t.shape))?it(nt(e)):null,s=!!n.wants;for(const t of e.filter(u=>(Mt(u)||Y(u))&&!u.warped)){if(!q(n,"titleFrames",t.id))continue;const u=a=>q(n,"titleFrames",t.id,a),r=bt(t,h),c=r&&i?`png:${r}`:r,E=c?x.get(c):void 0;if(E){x.delete(c),x.set(c,E);for(const a of E.frames){if(m?.aborted)throw new DOMException("Export cancelled","AbortError");await n.push("titleFrames",t.id,a)}continue}const M=[],$=t.title,H=st(t)||Y(t)?1:Math.ceil(t.duration*o);if(H>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.");$&&!t.shape&&!t.motion&&!t.lottie&&!t.card&&!t.geo&&await mt($);const S=t.card?await ut(t.card).catch(a=>{throw Error(U("Thẻ HTML “{0}”: {1}",[t.label,a.message]))}):null,[w,g]=S?[S.width,S.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:w,height:g}),b=C.getContext("2d",i?{willReadFrequently:!0}:void 0);if(!b)throw Error("Canvas unavailable");let _="",O=null;const K=(a,d)=>at({layer:`export:${a.id}`,motion:a.motion,t:et(a,d/o),width:w,height:g,duration:tt(a),fps:o,surface:a.pin?.scene?X(a,e,a.start+d/o,w,g):null,space:a.space?(I(e),Q(a,e,a.start+d/o,w,g,l)):null,cpu:i}),p=[],W="\0same",j="\0skip",k=t.shape&&!t.motion&&!t.card&&!t.lottie&&!t.geo&&!L(t.shape)?lt(t.shape):null,ot=k==null?1/0:Math.max(k,...["trimStart","trimEnd"].flatMap(a=>ht(t,a).map(d=>d.time))),A=async()=>{const a=await p.shift();if(a===j){await n.push("titleFrames",t.id,Et);return}if(a===W||a===_){M.push("="),await n.push("titleFrames",t.id,"=");return}_=a,M.push(a),await n.push("titleFrames",t.id,a)};try{for(let a=0;a<H;a++){if(m?.aborted)throw new DOMException("Export cancelled","AbortError");if(!u(a)){p.push(Promise.resolve(j)),p.length>=R&&await A();continue}if(!s&&a>0&&(a-1)/o>ot+1e-6){p.push(Promise.resolve(W)),p.length>=R&&await A();continue}if(b.clearRect(0,0,w,g),t.motion){let d;try{d=await(O??K(t,a)),O=a+1<H&&u(a+1)?K(t,a+1):null}catch(rt){throw O?.catch(()=>{}),D(`export:${t.id}`),Error(`Motion “${t.label}”: ${rt.message}`)}b.drawImage(d,0,0),d.close()}else if(t.lottie)try{await pt(`export:${t.id}`,t.url,{W:w,H:g},dt(t,a/o),C)}catch(d){throw V(`export:${t.id}`),Error(`Lottie “${t.label}”: ${d.message}`)}else if(t.geo)try{await ft(`export:${t.id}`,t.geo,{W:w,H:g},a/o,C,{wait:2e4,duration:t.duration})}catch(d){throw N(`export:${t.id}`),Error(U("Bản đồ “{0}”: {1}",[t.label,d.message]))}else S?b.drawImage(S,0,0):t.shape?(F&&I(F),wt(b,gt(t,e,a/o,v,y),{start:G(t,"trimStart",a/o),end:G(t,"trimEnd",a/o),offset:xt(t.shape)},w,g,a/o)):ct(b,$,{time:a/o,duration:t.duration});p.push(Ft(C,i)),p.length>=R&&await A()}for(;p.length;)await A();c&&!s&&yt(c,M)}finally{for(const a of p)a.catch(()=>{})}t.motion&&D(`export:${t.id}`),t.lottie&&V(`export:${t.id}`),t.geo&&N(`export:${t.id}`)}}function It(e,h,n,m){const{fps:l}=P(n),{width:i,height:o}=P({...n,resolution:"720p"}),v=Math.ceil(e.duration*l)-1,y=Object.assign(document.createElement("canvas"),{width:i,height:o}),f=y.getContext("2d");if(!f)throw Error("Canvas unavailable");const F=r=>at({layer:`export:${e.id}`,motion:e.motion,t:et(e,r/l),width:i,height:o,duration:tt(e),fps:l,surface:e.pin?.scene?X(e,h,e.start+r/l,i,o):null,space:e.space?(I(h),Q(e,h,e.start+r/l,i,o,m)):null});let s=null,t=-1;const u=r=>{r?.p.then(c=>c.close(),()=>{})};return{W:i,H:o,async frame(r){if(r=Math.max(0,Math.min(v,r)),r===t)return y;for(;s&&s.i<r;){const M=s;s=null,await M.p.then($=>$.close(),()=>{})}const c=s&&s.i===r?s.p:F(r);s&&s.i!==r&&u(s),s=null;let E;try{E=await c}catch(M){throw D(`export:${e.id}`),Error(`Motion “${e.label}”: ${M.message}`)}return s=r<v?{i:r+1,p:F(r+1)}:null,f.clearRect(0,0,i,o),f.drawImage(E,0,0),E.close(),t=r,y},close(){u(s),s=null,D(`export:${e.id}`)}}}export{Ot as clearFrameCache,bt as frameCacheKey,It as liveMotion,Rt as renderTitleFrames};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GLTFExporter-BuGYM-Ik.js","assets/three.module-Bx43vjkH.js"])))=>i.map(i=>d[i]);
2
- import{al as P}from"./remote-8XzEAnAJ.js";import{_ as R}from"./titleFrameBudget-DsM0V482.js";import{Vector3 as S,WebGLRenderer as O,NeutralToneMapping as D,SRGBColorSpace as B,Scene as F,Color as k,HemisphereLight as G,DirectionalLight as C,PerspectiveCamera as $,Mesh as q,Group as _,BufferGeometry as U,BufferAttribute as x,InstancedMesh as W,Matrix4 as Z,MeshPhysicalMaterial as V,DoubleSide as Y,FrontSide as X}from"./three.module-Bx43vjkH.js";const f=Object.freeze({code:24e3,triangles:3e5,instanceTriangles:3e6,meshes:64,instances:2e4,params:12,timeoutMs:8e3,size:500}),J=String.raw`
2
+ import{al as P}from"./remote-CpkPQOQH.js";import{_ as R}from"./titleFrameBudget-h4nOQ5u9.js";import{Vector3 as S,WebGLRenderer as O,NeutralToneMapping as D,SRGBColorSpace as B,Scene as F,Color as k,HemisphereLight as G,DirectionalLight as C,PerspectiveCamera as $,Mesh as q,Group as _,BufferGeometry as U,BufferAttribute as x,InstancedMesh as W,Matrix4 as Z,MeshPhysicalMaterial as V,DoubleSide as Y,FrontSide as X}from"./three.module-Bx43vjkH.js";const f=Object.freeze({code:24e3,triangles:3e5,instanceTriangles:3e6,meshes:64,instances:2e4,params:12,timeoutMs:8e3,size:500}),J=String.raw`
3
3
  const __codeModel = (() => {
4
4
  const LIM = ${JSON.stringify(f)}
5
5
  let seed = 1, noiseSeed = 1
@@ -1 +1 @@
1
- import{b as N,c as E,a as _,d as D}from"./shotFxAgent-DqngnGFb.js";import{ft as P,fu as B,de as h,bd as U,aU as A,aa as L,a8 as X}from"./remote-8XzEAnAJ.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const w=(s,n)=>{const o=h(s);return{anchor:n?(c,d,x)=>n.partPointAt(o,x,c.id,d):void 0,items:s.items,shot:o,at:(c,d)=>{const x=s.items.find(b=>b.id===c.id),k=X(x,o,o.duration?Math.max(0,Math.min(1,d/o.duration)):0);return{position:k.position,rotation:k.rotation}},uid:()=>crypto.randomUUID(),restPose:{...L.Đứng}}},v=(s,n,o)=>({...s,shots:s.shots.map(c=>c.id===s.activeShot?{...c,fxTiming:{...c.fxTiming,[n]:o}}:c)}),j=(s,n)=>{const o=A(s,h(n));return{name:s.name,id:s.id,effect:s.fx.cat??s.fx.preset,preset:s.fx.preset,start_s:o.start,end_s:+(o.start+o.duration).toFixed(2),...s.fx.attach?{attach:s.fx.attach}:{},...s.fx.path?{path:s.fx.path}:{}}};function ot(s,n,o){const c=o.engine();c&&c.sync(o.getStage(),null);const d=o.getStage();if(s==="add_effect"){const t=N(n,w(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;if(e.fx&&e.fx.preset in P&&o.userText!=null&&!B(o.userText))return{ok:!1,error:"blood effects are only used when the user asks for blood (máu / blood) in their message — leave it out"};o.setStage(i=>v({...i,items:[...i.items,e]},e.id,t.timing));const f=h(o.getStage());return{ok:!0,...j(e,o.getStage()),...t.timing.start+t.timing.duration>f.duration+.01?{note:"the effect runs past the end of the shot; shorten it or extend the shot with set_duration"}:{},hint:"render_preview / preview_motion at the effect time to check it is readable"}}if(s==="add_destruction"){const t=E(n,w(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;o.setStage(i=>{const a=v({...i,items:[...i.items,e]},e.id,t.timing);return{...a,shots:a.shots.map(p=>p.id===a.activeShot?{...p,objectKeys:{...p.objectKeys,[e.id]:t.keys}}:p)}});const f=d.items.filter(i=>i.fx?.preset===e.fx.preset&&i.fx?.target?.to===e.fx?.target?.to&&i.id!==e.id).map(i=>i.name);return{ok:!0,...j(e,o.getStage()),target:d.items.find(i=>i.id===e.fx?.target?.to)?.name,recipe:e.fx.params.recipe,...t.keys.length?{sphere_path:t.keys.map(i=>({at_s:+(i.time*h(d).duration).toFixed(2),position:i.position}))}:{mode:e.fx.params.mode},...f.length?{combines_with:f}:{},hint:"render_preview after the sweep / collapse time to see the destruction; remove_effect removes it"}}if(s==="edit_destruction"){const t=_(d.items.filter(m=>m.kind==="fx"&&m.fx?.preset===U),String(n.name));if(!t?.fx)return{ok:!1,error:`no Mix FX named '${String(n.name)}' (add_destruction makes one; scene_summary lists effects)`};const e=h(d),f=e.duration||1,i=[];let a=d;const p=m=>m.map((r,u)=>({id:`${t.id}-k${u}-${Math.round(r.time*1e6)}`,time:r.time,position:r.position,rotation:[...t.rotation],scale:[...t.scale]})),T=m=>{a={...a,shots:a.shots.map(r=>r.id===a.activeShot?{...r,objectKeys:{...r.objectKeys,[t.id]:m}}:r)}};if(n.target!=null){const m=d.items.find(r=>r.name.toLowerCase()===String(n.target).toLowerCase()&&r.kind!=="fx");if(!m)return{ok:!1,error:`no object '${String(n.target)}' to break`};a={...a,items:a.items.map(r=>r.id===t.id?{...r,fx:{...r.fx,target:{to:m.id,part:"center"}}}:r)},i.push(`target ${m.name}`)}if(Array.isArray(n.points)){if(n.points.length<2||n.points.length>24)return{ok:!1,error:"points: 2 to 24 path points"};const m=[];for(const r of n.points){const u=Number(r.time_s),l=r.position;if(!Number.isFinite(u)||u<0||u>f+1e-6)return{ok:!1,error:`time_s ${String(r.time_s)} is outside the shot (0–${f} s)`};if(!Array.isArray(l)||l.length!==3||!l.every(y=>Number.isFinite(Number(y))))return{ok:!1,error:"each point needs position [x, y, z]"};m.push({time:Math.min(1,u/f),position:l.map(Number)})}T(p(m.sort((r,u)=>r.time-u.time))),i.push(`path of ${m.length} points`)}else if(n.sweep===!0){const m=a.items.find(M=>M.id===t.id).fx,r=m.target?.to?c?.objectBounds()[m.target.to]:null;if(!r)return{ok:!1,error:"sweep measures the target: it needs the 3D view (a scene open in the composer or the render machine) and a target"};const u=m.params,l=Number(u.radius)*t.scale[0]+Number(u.falloff)+.3,y=(r.min[1]+r.max[1])/2,K=(r.min[2]+r.max[2])/2,S=A(t,e),O=Math.min(1,S.start/f),F=Math.min(1,(S.start+S.duration)/f);T(p([{time:O,position:[r.min[0]-l,y,K]},{time:F,position:[r.max[0]+l,y,K]}])),i.push("sweep through the target")}if(!i.length)return{ok:!1,error:"give points, sweep or target"};const $=a;return o.setStage(()=>$),{ok:!0,name:t.name,changed:i,path_s:(h($).objectKeys?.[t.id]||[]).map(m=>+(m.time*f).toFixed(3))}}if(s==="update_effect"){const t=_(d.items.filter(a=>a.kind==="fx"),String(n.name));if(!t?.fx)return{ok:!1,error:`no effect named '${String(n.name)}'; use remove_effect / update_effect with the name returned by add_effect (see scene_summary effects)`};const e=h(d),f=A(t,e),i=D(t,n,{...w(d,c),timing:f});return i.ok?(o.setStage(a=>v({...a,items:a.items.map(p=>p.id===t.id?{...p,...i.itemPatch,fx:i.fx}:p)},t.id,{start:i.timing.start,duration:i.timing.duration,...i.timing.loop?{loop:!0}:{}})),{ok:!0,...j(o.getStage().items.find(a=>a.id===t.id),o.getStage())}):{ok:!1,error:i.error}}const x=Array.isArray(n.names)?n.names.map(String):n.name!=null?[String(n.name)]:[],k=[],b=[],g=new Set;for(const t of x){const e=_(d.items.filter(f=>f.kind==="fx"),t);e?(g.add(e.id),k.push(e.name)):b.push(t)}for(const t of d.items)t.trackAnchor&&g.has(t.trackAnchor.effect)&&g.add(t.id);return o.setStage(t=>({...t,items:t.items.filter(e=>!g.has(e.id)),shots:t.shots.map(e=>({...e,...e.fxTiming?{fxTiming:Object.fromEntries(Object.entries(e.fxTiming).filter(([f])=>!g.has(f)))}:{},...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([f])=>!g.has(f)))}:{}}))})),{ok:!b.length,removed:k,missing:b}}export{ot as runFxTool};
1
+ import{b as N,c as E,a as _,d as D}from"./shotFxAgent-L2GG88W3.js";import{ft as P,fu as B,de as h,bd as U,aU as A,aa as L,a8 as X}from"./remote-CpkPQOQH.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";const w=(s,n)=>{const o=h(s);return{anchor:n?(c,d,x)=>n.partPointAt(o,x,c.id,d):void 0,items:s.items,shot:o,at:(c,d)=>{const x=s.items.find(b=>b.id===c.id),k=X(x,o,o.duration?Math.max(0,Math.min(1,d/o.duration)):0);return{position:k.position,rotation:k.rotation}},uid:()=>crypto.randomUUID(),restPose:{...L.Đứng}}},v=(s,n,o)=>({...s,shots:s.shots.map(c=>c.id===s.activeShot?{...c,fxTiming:{...c.fxTiming,[n]:o}}:c)}),j=(s,n)=>{const o=A(s,h(n));return{name:s.name,id:s.id,effect:s.fx.cat??s.fx.preset,preset:s.fx.preset,start_s:o.start,end_s:+(o.start+o.duration).toFixed(2),...s.fx.attach?{attach:s.fx.attach}:{},...s.fx.path?{path:s.fx.path}:{}}};function ot(s,n,o){const c=o.engine();c&&c.sync(o.getStage(),null);const d=o.getStage();if(s==="add_effect"){const t=N(n,w(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;if(e.fx&&e.fx.preset in P&&o.userText!=null&&!B(o.userText))return{ok:!1,error:"blood effects are only used when the user asks for blood (máu / blood) in their message — leave it out"};o.setStage(i=>v({...i,items:[...i.items,e]},e.id,t.timing));const f=h(o.getStage());return{ok:!0,...j(e,o.getStage()),...t.timing.start+t.timing.duration>f.duration+.01?{note:"the effect runs past the end of the shot; shorten it or extend the shot with set_duration"}:{},hint:"render_preview / preview_motion at the effect time to check it is readable"}}if(s==="add_destruction"){const t=E(n,w(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;o.setStage(i=>{const a=v({...i,items:[...i.items,e]},e.id,t.timing);return{...a,shots:a.shots.map(p=>p.id===a.activeShot?{...p,objectKeys:{...p.objectKeys,[e.id]:t.keys}}:p)}});const f=d.items.filter(i=>i.fx?.preset===e.fx.preset&&i.fx?.target?.to===e.fx?.target?.to&&i.id!==e.id).map(i=>i.name);return{ok:!0,...j(e,o.getStage()),target:d.items.find(i=>i.id===e.fx?.target?.to)?.name,recipe:e.fx.params.recipe,...t.keys.length?{sphere_path:t.keys.map(i=>({at_s:+(i.time*h(d).duration).toFixed(2),position:i.position}))}:{mode:e.fx.params.mode},...f.length?{combines_with:f}:{},hint:"render_preview after the sweep / collapse time to see the destruction; remove_effect removes it"}}if(s==="edit_destruction"){const t=_(d.items.filter(m=>m.kind==="fx"&&m.fx?.preset===U),String(n.name));if(!t?.fx)return{ok:!1,error:`no Mix FX named '${String(n.name)}' (add_destruction makes one; scene_summary lists effects)`};const e=h(d),f=e.duration||1,i=[];let a=d;const p=m=>m.map((r,u)=>({id:`${t.id}-k${u}-${Math.round(r.time*1e6)}`,time:r.time,position:r.position,rotation:[...t.rotation],scale:[...t.scale]})),T=m=>{a={...a,shots:a.shots.map(r=>r.id===a.activeShot?{...r,objectKeys:{...r.objectKeys,[t.id]:m}}:r)}};if(n.target!=null){const m=d.items.find(r=>r.name.toLowerCase()===String(n.target).toLowerCase()&&r.kind!=="fx");if(!m)return{ok:!1,error:`no object '${String(n.target)}' to break`};a={...a,items:a.items.map(r=>r.id===t.id?{...r,fx:{...r.fx,target:{to:m.id,part:"center"}}}:r)},i.push(`target ${m.name}`)}if(Array.isArray(n.points)){if(n.points.length<2||n.points.length>24)return{ok:!1,error:"points: 2 to 24 path points"};const m=[];for(const r of n.points){const u=Number(r.time_s),l=r.position;if(!Number.isFinite(u)||u<0||u>f+1e-6)return{ok:!1,error:`time_s ${String(r.time_s)} is outside the shot (0–${f} s)`};if(!Array.isArray(l)||l.length!==3||!l.every(y=>Number.isFinite(Number(y))))return{ok:!1,error:"each point needs position [x, y, z]"};m.push({time:Math.min(1,u/f),position:l.map(Number)})}T(p(m.sort((r,u)=>r.time-u.time))),i.push(`path of ${m.length} points`)}else if(n.sweep===!0){const m=a.items.find(M=>M.id===t.id).fx,r=m.target?.to?c?.objectBounds()[m.target.to]:null;if(!r)return{ok:!1,error:"sweep measures the target: it needs the 3D view (a scene open in the composer or the render machine) and a target"};const u=m.params,l=Number(u.radius)*t.scale[0]+Number(u.falloff)+.3,y=(r.min[1]+r.max[1])/2,K=(r.min[2]+r.max[2])/2,S=A(t,e),O=Math.min(1,S.start/f),F=Math.min(1,(S.start+S.duration)/f);T(p([{time:O,position:[r.min[0]-l,y,K]},{time:F,position:[r.max[0]+l,y,K]}])),i.push("sweep through the target")}if(!i.length)return{ok:!1,error:"give points, sweep or target"};const $=a;return o.setStage(()=>$),{ok:!0,name:t.name,changed:i,path_s:(h($).objectKeys?.[t.id]||[]).map(m=>+(m.time*f).toFixed(3))}}if(s==="update_effect"){const t=_(d.items.filter(a=>a.kind==="fx"),String(n.name));if(!t?.fx)return{ok:!1,error:`no effect named '${String(n.name)}'; use remove_effect / update_effect with the name returned by add_effect (see scene_summary effects)`};const e=h(d),f=A(t,e),i=D(t,n,{...w(d,c),timing:f});return i.ok?(o.setStage(a=>v({...a,items:a.items.map(p=>p.id===t.id?{...p,...i.itemPatch,fx:i.fx}:p)},t.id,{start:i.timing.start,duration:i.timing.duration,...i.timing.loop?{loop:!0}:{}})),{ok:!0,...j(o.getStage().items.find(a=>a.id===t.id),o.getStage())}):{ok:!1,error:i.error}}const x=Array.isArray(n.names)?n.names.map(String):n.name!=null?[String(n.name)]:[],k=[],b=[],g=new Set;for(const t of x){const e=_(d.items.filter(f=>f.kind==="fx"),t);e?(g.add(e.id),k.push(e.name)):b.push(t)}for(const t of d.items)t.trackAnchor&&g.has(t.trackAnchor.effect)&&g.add(t.id);return o.setStage(t=>({...t,items:t.items.filter(e=>!g.has(e.id)),shots:t.shots.map(e=>({...e,...e.fxTiming?{fxTiming:Object.fromEntries(Object.entries(e.fxTiming).filter(([f])=>!g.has(f)))}:{},...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([f])=>!g.has(f)))}:{}}))})),{ok:!b.length,removed:k,missing:b}}export{ot as runFxTool};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sceneTrack-DlAH5s74.js","assets/titleFrameBudget-DsM0V482.js","assets/domino-DBrinEUu.js"])))=>i.map(i=>d[i]);
2
- import{_ as R}from"./titleFrameBudget-DsM0V482.js";import{de as E,fg as j,bU as K,cv as L,al as F,fv as B,fw as z,fx as q,cm as T,ct as P,cu as U}from"./remote-8XzEAnAJ.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const H=["twos","snap","anticipation","exaggerate","squash","smear"],O=t=>Array.isArray(t)&&t.length===3&&t.every(f=>Number.isFinite(Number(f)))?t.map(Number):null,V=t=>t==="left"?"L":t==="both"?"both":"R",g=t=>Math.round(t*1e3)/1e3;function dt(t,f){const h=f.getStage(),p=E(h),r=t.on!==!1&&t.on!=="false",s={on:r};if(t.amount!=null){const a=Number(t.amount);if(!Number.isFinite(a))return{ok:!1,error:"amount must be a number 0–1"};s.amount=Math.max(0,Math.min(1,a))}for(const a of H)typeof t[a]=="boolean"&&(s[a]=t[a]);if(t.shot_default){const a=P({...p.toon||U,...s});return f.setStage(d=>({...d,shots:d.shots.map(b=>b.id===p.id?{...b,toon:a}:b)})),{ok:!0,shot_default:a,note:"every person / prop without its own setting uses it (set_toon on a name overrides one object)"}}const o=Array.isArray(t.names)?t.names.map(String):t.name!=null?[String(t.name)]:[];if(!o.length)return{ok:!1,error:"give names (people / props) or shot_default:true"};let m;try{m=o.map(a=>j(h,a))}catch(a){return{ok:!1,error:a.message}}const _=m.filter(a=>!["person","prop","box","sphere","cylinder","model"].includes(a.kind));if(_.length)return{ok:!1,error:`the cartoon style works on people, props and simple objects, not on ${_.map(a=>`'${a.name}' (${a.kind})`).join(", ")}`};const c={};return f.setStage(a=>({...a,items:a.items.map(d=>{if(!m.some(u=>u.id===d.id))return d;const b=P({...P(d.toon)||U,...s});return c[d.name]=b,{...d,toon:b}})})),{ok:!0,toon:c,note:r?"applied at render time on top of the keyed motion (anticipation before strong moves, overshoot + settle after stops, snappy key poses, exaggerated angles, squash & stretch, smears); keys are unchanged":"off: the keyed motion plays exactly as keyed"}}async function mt(t,f){const h=f.getStage(),p=E(h),r=String(t.action||"drop");if(!["drop","bounce","hold","throw","catch","dribble"].includes(r))return{ok:!1,error:`unknown action '${r}'; use drop, bounce, hold, throw, catch or dribble`};const s=Math.max(0,Math.min(p.duration,Number(t.time??0)||0));let o;if(t.person!=null){try{o=j(h,String(t.person))}catch(e){return{ok:!1,error:e.message}}if(!K(o))return{ok:!1,error:`'${o.name}' is not a person`}}if(["hold","throw","dribble","catch"].includes(r)&&!o&&r!=="throw")return{ok:!1,error:`${r} needs person`};let m=t.name!=null?h.items.find(e=>e.name===String(t.name)&&e.kind==="prop"&&e.prop?.kind==="ball"):void 0;const _=!m,c=O(t.position),a=L.radius;if(!m){const e=o?[o.position[0]+Math.sin(o.rotation[1]*Math.PI/180)*.6,o.position[1]+a,o.position[2]+Math.cos(o.rotation[1]*Math.PI/180)*.6]:[0,a,0];m=F(h,{kind:"prop",name:String(t.name||"Bóng rổ"),prop:{kind:"ball"},color:"#d8641c",position:c?[c[0],Math.max(a,c[1]),c[2]]:e})}t.toon!==!1&&!m.toon&&(m={...m,toon:{on:!0,amount:Math.max(0,Math.min(1,Number(t.amount??.6)))}}),t.bounciness!=null&&(m={...m,ball:{restitution:Math.max(.3,Math.min(.95,Number(t.bounciness)||L.restitution))}});const d=V(t.hand),b=(p.ball?.[m.id]||[]).filter(e=>e.t<s-1e-6),u=[],y=O(t.velocity);let x=O(t.target),v=null;if(r==="throw"&&!y&&!x&&t.target_person==null){if(v=B((await z(f,h)).colliders,o?.position??m.position),!v&&t.target==="hoop")return{ok:!1,error:"no hoop in the scene: build_set a court with parts named rim / vành rổ and backboard / bảng rổ, or give target [x,y,z]"};v&&(x=[...v.rim])}let w;if(t.target_person!=null)try{w=j(h,String(t.target_person))}catch(e){return{ok:!1,error:e.message}}if(r==="drop"||r==="bounce")u.push({t:s,kind:"launch",from:c??[...m.position],vel:y??(r==="bounce"?[0,3.5,0]:[0,0,0])});else if(r==="hold")u.push({t:s,kind:"hold",by:o.id,hand:d});else if(r==="dribble")u.push({t:s,kind:"dribble",by:o.id,hand:d==="both"?"R":d,period:Math.max(.3,Math.min(1.2,Number(t.period)||.55))});else if(r==="throw"){const e=[...b].reverse().find(D=>D.kind==="hold"||D.kind==="dribble");if(o&&!(e&&"by"in e&&e.by===o.id))u.push({t:Math.max(0,s-.001),kind:"hold",by:o.id,hand:d});else if(!o&&!e)return{ok:!1,error:"throw needs person (or an earlier hold / dribble of this ball)"};const n=t.arrive!=null?Math.max(.2,Number(t.arrive)):void 0;u.push({t:s,kind:"throw",...y?{vel:y}:w?{to:{by:w.id,hand:"both"},arrive:n??.9}:{to:x??[m.position[0],3.05,m.position[2]+4],...n?{arrive:n}:{},apex:Number(t.apex)||(v?1:.9),...v?{net:!0}:{}}}),w&&u.push({t:s+(n??.9),kind:"hold",by:w.id,hand:"both"})}else if(r==="catch"){const e=Math.max(.3,Math.min(3,Number(t.flight)||.9)),n=c??(o?[o.position[0]+Math.sin(o.rotation[1]*Math.PI/180)*4.5,o.position[1]+1.5,o.position[2]+Math.cos(o.rotation[1]*Math.PI/180)*4.5]:[...m.position]);u.push({t:Math.max(0,s-e),kind:"launch",from:n,to:{by:o.id,hand:d}},{t:s,kind:"hold",by:o.id,hand:d})}const S=[...b.filter(e=>!u.some(n=>n.t<=e.t+1e-6)),...u].sort((e,n)=>e.t-n.t),A=m.id,M=m;f.setStage(e=>({...e,items:_?[...e.items,M]:e.items.map(n=>n.id===A?M:n),shots:e.shots.map(n=>n.id===p.id?{...n,ball:{...n.ball,[A]:S}}:n)}));const k=u.find(e=>e.kind==="launch"&&Array.isArray(e.vel)),i=k&&k.kind==="launch"?q(k.from??M.position,k.vel,k.t,p.duration,{radius:a,restitution:M.ball?.restitution}).impacts.slice(0,8).map(e=>g(e.time)):void 0;return{ok:!0,name:M.name,created:_,...v?{hoop:"aimed through the rim centre, drops through the net"}:{},events:S.map(e=>({...e,t:g(e.t)})),...i?{bounce_times:i}:{},note:"the ball moves analytically (ballistic arcs, bounces losing height by its bounciness, squash on each bounce with the cartoon style on); it follows the hand while held / dribbled"}}async function ct(t,f){const h=f.getStage(),p=E(h),r=await R(()=>import("./sceneTrack-DlAH5s74.js").then(i=>i.$),__vite__mapDeps([0,1]));let s;if(t.all_props===!0)s=h.items.filter(i=>!i.hidden&&["box","sphere","cylinder","prop","proxy","model"].includes(i.kind)&&!r.dropUnavailable(i));else{const i=Array.isArray(t.objects)?t.objects.map(String):Array.isArray(t.names)?t.names.map(String):[];if(!i.length)return{ok:!1,error:"give objects (names) or all_props:true"};try{s=i.map(n=>j(h,n))}catch(n){return{ok:!1,error:n.message}}const e=s.map(n=>[n,r.dropUnavailable(n)]).filter(([,n])=>n);if(e.length)return{ok:!1,error:`cannot drop ${e.map(([n])=>`'${n.name}' (${n.kind}${n.locked?", locked":n.hold?", held":""})`).join(", ")}: physics_drop moves objects and props, not people, effects, sets or the floor`}}if(s=s.filter(i=>!(i.kind==="prop"&&i.prop?.kind==="ball"&&p.ball?.[i.id]?.length)),!s.length)return{ok:!1,error:"nothing to drop (a ball with add_ball motion keeps its own motion)"};if(s.length>r.MAX_PHYSICS_BODIES)return{ok:!1,error:`at most ${r.MAX_PHYSICS_BODIES} objects per drop`};const o=Math.max(0,Math.min(p.duration,Number(t.time??0)||0)),m=p.duration-o;if(m<r.DROP_SECONDS.min)return{ok:!1,error:`time ${g(o)} s is too close to the end of the shot (${p.duration} s)`};const _=Math.min(m,Math.max(1,Math.min(r.DROP_SECONDS.max,Number(t.duration)||r.DROP_SECONDS.default))),c=o/p.duration,a=r.DROP_MODES.includes(t.mode)?t.mode:"above",d=t.bounciness,b=typeof d=="number"||d==="bouncy"||d==="heavy"?d:"normal",u=f.engine(),y=s.map(i=>i.id);u&&u.sync(h,null);const x=u?.physicsShapes(y)??{},v=(await z(f,h)).colliders.filter(i=>!y.includes(i.itemId)),w={},S=s.map(i=>{const e=T(i,p,c),n=[...p.objectKeys?.[i.id]||[]].filter(D=>D.time<c-1e-6).sort((D,I)=>D.time-I.time).pop();return w[i.id]=n,{id:i.id,position:e.position,rotation:e.rotation,shape:r.shapeKind(i),...x[i.id]??r.fallbackShape(i)}}),A=await r.bakeDrop({bodies:S,statics:v,mode:a,bounciness:b,duration:_,start:o,shotDuration:p.duration,height:Number(t.height)||void 0,strength:Number(t.strength)||void 0,velocity:O(t.velocity)??void 0,seed:t.seed!=null?String(t.seed):y.join(","),before:w,seam:p.lockUntil?p.lockUntil/p.duration:null}),M=Object.fromEntries(s.map(i=>[i.id,T(i,p,c).scale]));f.setStage(i=>r.applyDropKeys(i,p.id,A.tracks,{scale:M,lifted:a==="above"}));const k={};for(const i of s){const e=A.tracks[i.id];e&&(k[i.name]={keys:e.keys.length,rest:e.rest,settled_at:e.settledAt==null?null:g(o+e.settledAt)})}return{ok:!0,mode:a,from:g(o),until:g(o+_),objects:k,settled:A.settled,note:"baked into ordinary keys (no physics at playback); their keys after `from` were replaced. Run again with another seed for a different tumble."}}async function ht(t,f){const h=await R(()=>import("./domino-DBrinEUu.js"),__vite__mapDeps([2,0,1])),p=await R(()=>import("./sceneTrack-DlAH5s74.js").then(l=>l.$),__vite__mapDeps([0,1])),r=f.getStage(),s=E(r),o=typeof t.text=="string"&&t.text.trim()?t.text:null,m=Array.isArray(t.path)?t.path.filter(l=>Array.isArray(l)&&l.length>=2&&l.every(N=>typeof N=="number"&&Number.isFinite(N))):null;if(!o&&!(m&&m.length>=2))return{ok:!1,error:"give text (a word, A–Z 0–9) or path ([[x, z], …] at least 2 points on the floor)"};const _=O(t.position)??[0,0,0],c=h.layoutDominoes({text:o??void 0,path:o?void 0:m,height:Number(t.height)||void 0,letterHeight:Number(t.letter_height)||void 0,spacing:Number(t.spacing)||void 0,position:_,yaw:Number(t.yaw_deg)||0,floor:_[1]});if(c.error)return{ok:!1,error:c.error,...c.count?{dominoes:c.count}:{}};const a=t.push==="together"?"together":"sequence",d=Math.max(0,Math.min(s.duration,Number(t.time??h.DOMINO_DEFAULTS.time)||0)),b=h.dominoSeconds(c,a),u=s.duration-d;if(u<h.DOMINO_SECONDS.min)return{ok:!1,error:`time ${g(d)} s is too close to the end of the shot (${s.duration} s)`};const y=(typeof t.group=="string"&&t.group.trim()?t.group.trim():`Domino${o?` ${h.dominoText(o)}`:""}`).slice(0,40),x=(Array.isArray(t.colors)?t.colors:[]).map(String).filter(l=>/^#[0-9a-f]{6}$/i.test(l)).slice(0,8),v=x.length?x:[...h.DOMINO_DEFAULTS.colors],w=l=>l.startsWith(`${y} `)&&/^\d+$/.test(l.slice(y.length+1)),S=new Set(r.items.filter(l=>w(l.name)&&!l.locked).map(l=>l.id)),A={...r,items:r.items.filter(l=>!S.has(l.id))};let M=0;const k=c.runs.flatMap(l=>l.map(N=>(M++,F(A,{kind:"box",name:`${y} ${M}`,position:N.position,rotation:N.rotation,scale:c.size,color:v[(M-1)%v.length]})))),i=(await z(f,r)).colliders.filter(l=>!S.has(l.itemId)),e=Math.min(u,b),n=await h.bakeDominoes({runs:c.runs,size:c.size,ids:k.map(l=>l.id),push:a,duration:e,start:d,shotDuration:s.duration,statics:i,floor:_[1],seam:s.lockUntil?s.lockUntil/s.duration:null});f.setStage(l=>{const N={...l,items:[...l.items.filter($=>!S.has($.id)),...k],shots:l.shots.map($=>({...$,objectKeys:Object.fromEntries(Object.entries($.objectKeys||{}).filter(([C])=>!S.has(C)))}))};return p.applyDropKeys(N,s.id,n.tracks,{scale:Object.fromEntries(k.map($=>[$.id,$.scale]))})});const D=Math.max(d,...Object.values(n.tracks).map(l=>l.fellAt??0)),I=b>u+1e-6;return{ok:!0,group:y,dominoes:k.length,runs:c.runs.length,push:a,from:g(d),last_falls_at:g(D),fallen:`${n.fallen}/${n.total}`,domino_size_m:c.size.map(g),...S.size?{replaced:S.size}:{},...n.stalled.length?{stalled_runs:n.stalled,hint:"some runs stopped part-way (a gap too wide or something in the way): smaller spacing, taller dominoes or a clear floor"}:{},...I?{warning:`the run needs about ${b} s after time but the shot leaves ${g(u)} s: set_duration ≥ ${g(d+b)} s and run again, or push:"together"`}:{},note:"baked into ordinary keys (no physics at playback); frame the word from above at an angle (camera ~3 m up, looking down 40–60°) so the letters read"}}export{mt as addBall,ht as dominoRun,ct as physicsDrop,dt as setToon};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sceneTrack-CO4fTjft.js","assets/titleFrameBudget-h4nOQ5u9.js","assets/domino-trmDBvfH.js"])))=>i.map(i=>d[i]);
2
+ import{_ as R}from"./titleFrameBudget-h4nOQ5u9.js";import{de as E,fg as j,bU as K,cv as L,al as F,fv as B,fw as z,fx as q,cm as T,ct as P,cu as U}from"./remote-CpkPQOQH.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";const H=["twos","snap","anticipation","exaggerate","squash","smear"],O=t=>Array.isArray(t)&&t.length===3&&t.every(f=>Number.isFinite(Number(f)))?t.map(Number):null,V=t=>t==="left"?"L":t==="both"?"both":"R",g=t=>Math.round(t*1e3)/1e3;function dt(t,f){const h=f.getStage(),p=E(h),r=t.on!==!1&&t.on!=="false",s={on:r};if(t.amount!=null){const a=Number(t.amount);if(!Number.isFinite(a))return{ok:!1,error:"amount must be a number 0–1"};s.amount=Math.max(0,Math.min(1,a))}for(const a of H)typeof t[a]=="boolean"&&(s[a]=t[a]);if(t.shot_default){const a=P({...p.toon||U,...s});return f.setStage(d=>({...d,shots:d.shots.map(b=>b.id===p.id?{...b,toon:a}:b)})),{ok:!0,shot_default:a,note:"every person / prop without its own setting uses it (set_toon on a name overrides one object)"}}const o=Array.isArray(t.names)?t.names.map(String):t.name!=null?[String(t.name)]:[];if(!o.length)return{ok:!1,error:"give names (people / props) or shot_default:true"};let m;try{m=o.map(a=>j(h,a))}catch(a){return{ok:!1,error:a.message}}const _=m.filter(a=>!["person","prop","box","sphere","cylinder","model"].includes(a.kind));if(_.length)return{ok:!1,error:`the cartoon style works on people, props and simple objects, not on ${_.map(a=>`'${a.name}' (${a.kind})`).join(", ")}`};const c={};return f.setStage(a=>({...a,items:a.items.map(d=>{if(!m.some(u=>u.id===d.id))return d;const b=P({...P(d.toon)||U,...s});return c[d.name]=b,{...d,toon:b}})})),{ok:!0,toon:c,note:r?"applied at render time on top of the keyed motion (anticipation before strong moves, overshoot + settle after stops, snappy key poses, exaggerated angles, squash & stretch, smears); keys are unchanged":"off: the keyed motion plays exactly as keyed"}}async function mt(t,f){const h=f.getStage(),p=E(h),r=String(t.action||"drop");if(!["drop","bounce","hold","throw","catch","dribble"].includes(r))return{ok:!1,error:`unknown action '${r}'; use drop, bounce, hold, throw, catch or dribble`};const s=Math.max(0,Math.min(p.duration,Number(t.time??0)||0));let o;if(t.person!=null){try{o=j(h,String(t.person))}catch(e){return{ok:!1,error:e.message}}if(!K(o))return{ok:!1,error:`'${o.name}' is not a person`}}if(["hold","throw","dribble","catch"].includes(r)&&!o&&r!=="throw")return{ok:!1,error:`${r} needs person`};let m=t.name!=null?h.items.find(e=>e.name===String(t.name)&&e.kind==="prop"&&e.prop?.kind==="ball"):void 0;const _=!m,c=O(t.position),a=L.radius;if(!m){const e=o?[o.position[0]+Math.sin(o.rotation[1]*Math.PI/180)*.6,o.position[1]+a,o.position[2]+Math.cos(o.rotation[1]*Math.PI/180)*.6]:[0,a,0];m=F(h,{kind:"prop",name:String(t.name||"Bóng rổ"),prop:{kind:"ball"},color:"#d8641c",position:c?[c[0],Math.max(a,c[1]),c[2]]:e})}t.toon!==!1&&!m.toon&&(m={...m,toon:{on:!0,amount:Math.max(0,Math.min(1,Number(t.amount??.6)))}}),t.bounciness!=null&&(m={...m,ball:{restitution:Math.max(.3,Math.min(.95,Number(t.bounciness)||L.restitution))}});const d=V(t.hand),b=(p.ball?.[m.id]||[]).filter(e=>e.t<s-1e-6),u=[],y=O(t.velocity);let x=O(t.target),v=null;if(r==="throw"&&!y&&!x&&t.target_person==null){if(v=B((await z(f,h)).colliders,o?.position??m.position),!v&&t.target==="hoop")return{ok:!1,error:"no hoop in the scene: build_set a court with parts named rim / vành rổ and backboard / bảng rổ, or give target [x,y,z]"};v&&(x=[...v.rim])}let w;if(t.target_person!=null)try{w=j(h,String(t.target_person))}catch(e){return{ok:!1,error:e.message}}if(r==="drop"||r==="bounce")u.push({t:s,kind:"launch",from:c??[...m.position],vel:y??(r==="bounce"?[0,3.5,0]:[0,0,0])});else if(r==="hold")u.push({t:s,kind:"hold",by:o.id,hand:d});else if(r==="dribble")u.push({t:s,kind:"dribble",by:o.id,hand:d==="both"?"R":d,period:Math.max(.3,Math.min(1.2,Number(t.period)||.55))});else if(r==="throw"){const e=[...b].reverse().find(D=>D.kind==="hold"||D.kind==="dribble");if(o&&!(e&&"by"in e&&e.by===o.id))u.push({t:Math.max(0,s-.001),kind:"hold",by:o.id,hand:d});else if(!o&&!e)return{ok:!1,error:"throw needs person (or an earlier hold / dribble of this ball)"};const n=t.arrive!=null?Math.max(.2,Number(t.arrive)):void 0;u.push({t:s,kind:"throw",...y?{vel:y}:w?{to:{by:w.id,hand:"both"},arrive:n??.9}:{to:x??[m.position[0],3.05,m.position[2]+4],...n?{arrive:n}:{},apex:Number(t.apex)||(v?1:.9),...v?{net:!0}:{}}}),w&&u.push({t:s+(n??.9),kind:"hold",by:w.id,hand:"both"})}else if(r==="catch"){const e=Math.max(.3,Math.min(3,Number(t.flight)||.9)),n=c??(o?[o.position[0]+Math.sin(o.rotation[1]*Math.PI/180)*4.5,o.position[1]+1.5,o.position[2]+Math.cos(o.rotation[1]*Math.PI/180)*4.5]:[...m.position]);u.push({t:Math.max(0,s-e),kind:"launch",from:n,to:{by:o.id,hand:d}},{t:s,kind:"hold",by:o.id,hand:d})}const S=[...b.filter(e=>!u.some(n=>n.t<=e.t+1e-6)),...u].sort((e,n)=>e.t-n.t),A=m.id,M=m;f.setStage(e=>({...e,items:_?[...e.items,M]:e.items.map(n=>n.id===A?M:n),shots:e.shots.map(n=>n.id===p.id?{...n,ball:{...n.ball,[A]:S}}:n)}));const k=u.find(e=>e.kind==="launch"&&Array.isArray(e.vel)),i=k&&k.kind==="launch"?q(k.from??M.position,k.vel,k.t,p.duration,{radius:a,restitution:M.ball?.restitution}).impacts.slice(0,8).map(e=>g(e.time)):void 0;return{ok:!0,name:M.name,created:_,...v?{hoop:"aimed through the rim centre, drops through the net"}:{},events:S.map(e=>({...e,t:g(e.t)})),...i?{bounce_times:i}:{},note:"the ball moves analytically (ballistic arcs, bounces losing height by its bounciness, squash on each bounce with the cartoon style on); it follows the hand while held / dribbled"}}async function ct(t,f){const h=f.getStage(),p=E(h),r=await R(()=>import("./sceneTrack-CO4fTjft.js").then(i=>i.$),__vite__mapDeps([0,1]));let s;if(t.all_props===!0)s=h.items.filter(i=>!i.hidden&&["box","sphere","cylinder","prop","proxy","model"].includes(i.kind)&&!r.dropUnavailable(i));else{const i=Array.isArray(t.objects)?t.objects.map(String):Array.isArray(t.names)?t.names.map(String):[];if(!i.length)return{ok:!1,error:"give objects (names) or all_props:true"};try{s=i.map(n=>j(h,n))}catch(n){return{ok:!1,error:n.message}}const e=s.map(n=>[n,r.dropUnavailable(n)]).filter(([,n])=>n);if(e.length)return{ok:!1,error:`cannot drop ${e.map(([n])=>`'${n.name}' (${n.kind}${n.locked?", locked":n.hold?", held":""})`).join(", ")}: physics_drop moves objects and props, not people, effects, sets or the floor`}}if(s=s.filter(i=>!(i.kind==="prop"&&i.prop?.kind==="ball"&&p.ball?.[i.id]?.length)),!s.length)return{ok:!1,error:"nothing to drop (a ball with add_ball motion keeps its own motion)"};if(s.length>r.MAX_PHYSICS_BODIES)return{ok:!1,error:`at most ${r.MAX_PHYSICS_BODIES} objects per drop`};const o=Math.max(0,Math.min(p.duration,Number(t.time??0)||0)),m=p.duration-o;if(m<r.DROP_SECONDS.min)return{ok:!1,error:`time ${g(o)} s is too close to the end of the shot (${p.duration} s)`};const _=Math.min(m,Math.max(1,Math.min(r.DROP_SECONDS.max,Number(t.duration)||r.DROP_SECONDS.default))),c=o/p.duration,a=r.DROP_MODES.includes(t.mode)?t.mode:"above",d=t.bounciness,b=typeof d=="number"||d==="bouncy"||d==="heavy"?d:"normal",u=f.engine(),y=s.map(i=>i.id);u&&u.sync(h,null);const x=u?.physicsShapes(y)??{},v=(await z(f,h)).colliders.filter(i=>!y.includes(i.itemId)),w={},S=s.map(i=>{const e=T(i,p,c),n=[...p.objectKeys?.[i.id]||[]].filter(D=>D.time<c-1e-6).sort((D,I)=>D.time-I.time).pop();return w[i.id]=n,{id:i.id,position:e.position,rotation:e.rotation,shape:r.shapeKind(i),...x[i.id]??r.fallbackShape(i)}}),A=await r.bakeDrop({bodies:S,statics:v,mode:a,bounciness:b,duration:_,start:o,shotDuration:p.duration,height:Number(t.height)||void 0,strength:Number(t.strength)||void 0,velocity:O(t.velocity)??void 0,seed:t.seed!=null?String(t.seed):y.join(","),before:w,seam:p.lockUntil?p.lockUntil/p.duration:null}),M=Object.fromEntries(s.map(i=>[i.id,T(i,p,c).scale]));f.setStage(i=>r.applyDropKeys(i,p.id,A.tracks,{scale:M,lifted:a==="above"}));const k={};for(const i of s){const e=A.tracks[i.id];e&&(k[i.name]={keys:e.keys.length,rest:e.rest,settled_at:e.settledAt==null?null:g(o+e.settledAt)})}return{ok:!0,mode:a,from:g(o),until:g(o+_),objects:k,settled:A.settled,note:"baked into ordinary keys (no physics at playback); their keys after `from` were replaced. Run again with another seed for a different tumble."}}async function ht(t,f){const h=await R(()=>import("./domino-trmDBvfH.js"),__vite__mapDeps([2,0,1])),p=await R(()=>import("./sceneTrack-CO4fTjft.js").then(l=>l.$),__vite__mapDeps([0,1])),r=f.getStage(),s=E(r),o=typeof t.text=="string"&&t.text.trim()?t.text:null,m=Array.isArray(t.path)?t.path.filter(l=>Array.isArray(l)&&l.length>=2&&l.every(N=>typeof N=="number"&&Number.isFinite(N))):null;if(!o&&!(m&&m.length>=2))return{ok:!1,error:"give text (a word, A–Z 0–9) or path ([[x, z], …] at least 2 points on the floor)"};const _=O(t.position)??[0,0,0],c=h.layoutDominoes({text:o??void 0,path:o?void 0:m,height:Number(t.height)||void 0,letterHeight:Number(t.letter_height)||void 0,spacing:Number(t.spacing)||void 0,position:_,yaw:Number(t.yaw_deg)||0,floor:_[1]});if(c.error)return{ok:!1,error:c.error,...c.count?{dominoes:c.count}:{}};const a=t.push==="together"?"together":"sequence",d=Math.max(0,Math.min(s.duration,Number(t.time??h.DOMINO_DEFAULTS.time)||0)),b=h.dominoSeconds(c,a),u=s.duration-d;if(u<h.DOMINO_SECONDS.min)return{ok:!1,error:`time ${g(d)} s is too close to the end of the shot (${s.duration} s)`};const y=(typeof t.group=="string"&&t.group.trim()?t.group.trim():`Domino${o?` ${h.dominoText(o)}`:""}`).slice(0,40),x=(Array.isArray(t.colors)?t.colors:[]).map(String).filter(l=>/^#[0-9a-f]{6}$/i.test(l)).slice(0,8),v=x.length?x:[...h.DOMINO_DEFAULTS.colors],w=l=>l.startsWith(`${y} `)&&/^\d+$/.test(l.slice(y.length+1)),S=new Set(r.items.filter(l=>w(l.name)&&!l.locked).map(l=>l.id)),A={...r,items:r.items.filter(l=>!S.has(l.id))};let M=0;const k=c.runs.flatMap(l=>l.map(N=>(M++,F(A,{kind:"box",name:`${y} ${M}`,position:N.position,rotation:N.rotation,scale:c.size,color:v[(M-1)%v.length]})))),i=(await z(f,r)).colliders.filter(l=>!S.has(l.itemId)),e=Math.min(u,b),n=await h.bakeDominoes({runs:c.runs,size:c.size,ids:k.map(l=>l.id),push:a,duration:e,start:d,shotDuration:s.duration,statics:i,floor:_[1],seam:s.lockUntil?s.lockUntil/s.duration:null});f.setStage(l=>{const N={...l,items:[...l.items.filter($=>!S.has($.id)),...k],shots:l.shots.map($=>({...$,objectKeys:Object.fromEntries(Object.entries($.objectKeys||{}).filter(([C])=>!S.has(C)))}))};return p.applyDropKeys(N,s.id,n.tracks,{scale:Object.fromEntries(k.map($=>[$.id,$.scale]))})});const D=Math.max(d,...Object.values(n.tracks).map(l=>l.fellAt??0)),I=b>u+1e-6;return{ok:!0,group:y,dominoes:k.length,runs:c.runs.length,push:a,from:g(d),last_falls_at:g(D),fallen:`${n.fallen}/${n.total}`,domino_size_m:c.size.map(g),...S.size?{replaced:S.size}:{},...n.stalled.length?{stalled_runs:n.stalled,hint:"some runs stopped part-way (a gap too wide or something in the way): smaller spacing, taller dominoes or a clear floor"}:{},...I?{warning:`the run needs about ${b} s after time but the shot leaves ${g(u)} s: set_duration ≥ ${g(d+b)} s and run again, or push:"together"`}:{},note:"baked into ordinary keys (no physics at playback); frame the word from above at an angle (camera ~3 m up, looking down 40–60°) so the letters read"}}export{mt as addBall,ht as dominoRun,ct as physicsDrop,dt as setToon};
@@ -1 +1 @@
1
- import{b as M,de as b,fr as _,a8 as $}from"./remote-8XzEAnAJ.js";import{a as F}from"./shotFxAgent-DqngnGFb.js";import{d3 as N,d4 as y,d5 as A}from"./timelineOps-DSSaDsU2.js";import{Vector3 as j}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./rigTrack-DMyqb0pb.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./clientJobs-CuuUyhEy.js";const C=4,T=1.25;function w(t,c,r){return t.updateMatrixWorld(),new j(c*2-1,1-r*2,.5).unproject(t).sub(t.position).normalize()}function S(t,c,r){const o=b(t),s=Math.max(1e-6,o.duration),f=t.items.find(n=>n.kind==="person"&&!n.hidden);return c.points.map(([n,d,l])=>{const m=Math.max(0,Math.min(1,n/s)),p=_(o,m),a=w(p,d,l);let u=r??NaN;if(!Number.isFinite(u)&&f){const h=$(f,o,m);u=new j(h.position[0],h.position[1]+T*Math.max(.3,h.scale[1]),h.position[2]).sub(p.position).dot(a)}(!Number.isFinite(u)||u<.3)&&(u=C);const k=p.position.clone().addScaledVector(a,u);return{t:m,d:u,position:[k.x,k.y,k.z].map(h=>Math.round(h*1e4)/1e4)}})}function J(t,c,r,o,s){const f=b(t),n=Math.max(1e-6,f.duration),d=_(f,Math.max(0,Math.min(1,c/n))),l=w(d,r,o);if(s&&l.y<-.01){const m=-d.position.y/l.y;if(m>.3&&m<80){const p=d.position.clone().addScaledVector(l,m);return[p.x,0,p.z].map(a=>Math.round(a*1e4)/1e4)}}return S(t,{points:[[Math.max(0,Math.min(n,c)),r,o]]})[0].position}function K(t,c,r){const o=b(c).duration;try{if(t.track!=null)return N(t.track,o);const s=String(t.source??"");if(!y.includes(s))return`give track {fps, points} or source ${y.join(" / ")}`;const f=c.plate?.timelineClipId,n=f?r.timelineClip?.(f):void 0;return n?A(n,s,{side:t.side==="left"?"left":"right",point:typeof t.point=="string"?t.point:"palm",...typeof t.object=="string"?{object:t.object}:{},to:o}):"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(s){return s.message}}function Q(t,c){const r=c.getStage();if(!r.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 o=F(r.items.filter(i=>i.kind==="fx"),String(t.name??""));if(!o?.fx)return{ok:!1,error:`no effect named '${String(t.name)}' (scene_summary lists the effects)`};const s=r.items.find(i=>i.trackAnchor?.effect===o.id);if(t.stop===!0)return s?(c.setStage(i=>({...i,items:i.items.filter(e=>e.id!==s.id).map(e=>e.id===o.id?{...e,fx:{...e.fx,...e.fx.attach?.to===s.id?{attach:void 0}:{},...e.fx.target?.to===s.id?{target:void 0}:{}}}:e),shots:i.shots.map(e=>({...e,...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([v])=>v!==s.id))}:{}}))})),{ok:!0,name:o.name,stopped:!0}):{ok:!1,error:`${o.name} follows no track`};const f=K(t,r,c);if(typeof f=="string")return{ok:!1,error:f};const n=t.depth_m==null?void 0:Number(t.depth_m);if(n!==void 0&&!(n>=.3&&n<=200))return{ok:!1,error:"depth_m must be 0.3–200 (metres from the camera)"};const d=t.offset==null?void 0:Array.isArray(t.offset)&&t.offset.length===3&&t.offset.every(i=>Number.isFinite(Number(i))&&Math.abs(Number(i))<=20)?t.offset.map(Number):null;if(d===null)return{ok:!1,error:"offset must be [x, y, z] metres (±20)"};const l=t.role==="target"?"target":"attach",m=S(r,f,n),p=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=s?{...s,trackAnchor:{effect:o.id,source:p}}:{...M("sphere",r.items.length),name:`${o.name} · điểm bám`.slice(0,60),color:"#ffffff",trackAnchor:{effect:o.id,source:p}};a.position=m[0].position,a.rotation=[0,0,0],a.scale=[1,1,1];const u=m.map((i,e)=>({id:`${a.id}-t${e}`,time:i.t,position:i.position,rotation:[0,0,0],scale:[1,1,1]})),k={...o.fx,...l==="attach"?{attach:{to:a.id,follow:"position",...d?{offset:d}:{}}}:{target:{to:a.id,part:"center"}}};c.setStage(i=>({...i,items:[...i.items.filter(e=>e.id!==a.id).map(e=>e.id===o.id?{...e,fx:k}:e),a],shots:i.shots.map(e=>e.id===i.activeShot?{...e,objectKeys:{...e.objectKeys,[a.id]:u}}:e)}));const h=m.map(i=>i.d).sort((i,e)=>i-e),x=b(r).duration;return{ok:!0,name:o.name,anchor:a.name,source:p,role:l,samples:m.length,from_s:+f.points[0][0].toFixed(2),to_s:+f.points.at(-1)[0].toFixed(2),depth_m:+h[h.length>>1].toFixed(2),note:`${o.name} now ${l==="attach"?"rides on":"aims at"} the tracked point (${m.length} keys over ${x.toFixed(1)} s, ${n?`${n} 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{Q as followTrack,J as scenePoint,S as trackWorldPoints};
1
+ import{b as M,de as b,fr as _,a8 as $}from"./remote-CpkPQOQH.js";import{a as F}from"./shotFxAgent-L2GG88W3.js";import{d8 as N,d9 as y,da as A}from"./timelineOps-f1WsVbgS.js";import{Vector3 as j}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./rigTrack-BbKqZGs7.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./clientJobs-CuuUyhEy.js";const C=4,T=1.25;function w(t,c,r){return t.updateMatrixWorld(),new j(c*2-1,1-r*2,.5).unproject(t).sub(t.position).normalize()}function S(t,c,r){const o=b(t),a=Math.max(1e-6,o.duration),f=t.items.find(n=>n.kind==="person"&&!n.hidden);return c.points.map(([n,d,l])=>{const m=Math.max(0,Math.min(1,n/a)),p=_(o,m),s=w(p,d,l);let u=r??NaN;if(!Number.isFinite(u)&&f){const h=$(f,o,m);u=new j(h.position[0],h.position[1]+T*Math.max(.3,h.scale[1]),h.position[2]).sub(p.position).dot(s)}(!Number.isFinite(u)||u<.3)&&(u=C);const k=p.position.clone().addScaledVector(s,u);return{t:m,d:u,position:[k.x,k.y,k.z].map(h=>Math.round(h*1e4)/1e4)}})}function J(t,c,r,o,a){const f=b(t),n=Math.max(1e-6,f.duration),d=_(f,Math.max(0,Math.min(1,c/n))),l=w(d,r,o);if(a&&l.y<-.01){const m=-d.position.y/l.y;if(m>.3&&m<80){const p=d.position.clone().addScaledVector(l,m);return[p.x,0,p.z].map(s=>Math.round(s*1e4)/1e4)}}return S(t,{points:[[Math.max(0,Math.min(n,c)),r,o]]})[0].position}function K(t,c,r){const o=b(c).duration;try{if(t.track!=null)return N(t.track,o);const a=String(t.source??"");if(!y.includes(a))return`give track {fps, points} or source ${y.join(" / ")}`;const f=c.plate?.timelineClipId,n=f?r.timelineClip?.(f):void 0;return n?A(n,a,{side:t.side==="left"?"left":"right",point:typeof t.point=="string"?t.point:"palm",...typeof t.object=="string"?{object:t.object}:{},to:o}):"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(a){return a.message}}function Q(t,c){const r=c.getStage();if(!r.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 o=F(r.items.filter(i=>i.kind==="fx"),String(t.name??""));if(!o?.fx)return{ok:!1,error:`no effect named '${String(t.name)}' (scene_summary lists the effects)`};const a=r.items.find(i=>i.trackAnchor?.effect===o.id);if(t.stop===!0)return a?(c.setStage(i=>({...i,items:i.items.filter(e=>e.id!==a.id).map(e=>e.id===o.id?{...e,fx:{...e.fx,...e.fx.attach?.to===a.id?{attach:void 0}:{},...e.fx.target?.to===a.id?{target:void 0}:{}}}:e),shots:i.shots.map(e=>({...e,...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([v])=>v!==a.id))}:{}}))})),{ok:!0,name:o.name,stopped:!0}):{ok:!1,error:`${o.name} follows no track`};const f=K(t,r,c);if(typeof f=="string")return{ok:!1,error:f};const n=t.depth_m==null?void 0:Number(t.depth_m);if(n!==void 0&&!(n>=.3&&n<=200))return{ok:!1,error:"depth_m must be 0.3–200 (metres from the camera)"};const d=t.offset==null?void 0:Array.isArray(t.offset)&&t.offset.length===3&&t.offset.every(i=>Number.isFinite(Number(i))&&Math.abs(Number(i))<=20)?t.offset.map(Number):null;if(d===null)return{ok:!1,error:"offset must be [x, y, z] metres (±20)"};const l=t.role==="target"?"target":"attach",m=S(r,f,n),p=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),s=a?{...a,trackAnchor:{effect:o.id,source:p}}:{...M("sphere",r.items.length),name:`${o.name} · điểm bám`.slice(0,60),color:"#ffffff",trackAnchor:{effect:o.id,source:p}};s.position=m[0].position,s.rotation=[0,0,0],s.scale=[1,1,1];const u=m.map((i,e)=>({id:`${s.id}-t${e}`,time:i.t,position:i.position,rotation:[0,0,0],scale:[1,1,1]})),k={...o.fx,...l==="attach"?{attach:{to:s.id,follow:"position",...d?{offset:d}:{}}}:{target:{to:s.id,part:"center"}}};c.setStage(i=>({...i,items:[...i.items.filter(e=>e.id!==s.id).map(e=>e.id===o.id?{...e,fx:k}:e),s],shots:i.shots.map(e=>e.id===i.activeShot?{...e,objectKeys:{...e.objectKeys,[s.id]:u}}:e)}));const h=m.map(i=>i.d).sort((i,e)=>i-e),x=b(r).duration;return{ok:!0,name:o.name,anchor:s.name,source:p,role:l,samples:m.length,from_s:+f.points[0][0].toFixed(2),to_s:+f.points.at(-1)[0].toFixed(2),depth_m:+h[h.length>>1].toFixed(2),note:`${o.name} now ${l==="attach"?"rides on":"aims at"} the tracked point (${m.length} keys over ${x.toFixed(1)} s, ${n?`${n} 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{Q as followTrack,J as scenePoint,S as trackWorldPoints};
@@ -1 +1 @@
1
- import{r as p}from"./index-CKtv7gGE.js";import{bQ as b,bR as S,u as U,bS as _}from"./api-Dnl2uaKO.js";import{u as C}from"./store-CpqHUcA2.js";import{i as w}from"./textAnimators-B9vO_hbP.js";import{t as f}from"./i18n-C9zFX25m.js";import"./titleFrameBudget-DsM0V482.js";let r={fonts:[],loaded:!1,error:null};const l=new Set,u=t=>{r={...r,...t},l.forEach(o=>o())},E=t=>(l.add(t),()=>{l.delete(t)}),$=()=>p.useSyncExternalStore(E,()=>r),v=()=>r,x={ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2"},B=".ttf,.otf,.woff,.woff2,font/ttf,font/otf,font/woff,font/woff2",d=10,c=new Map;function h(t){if(!t.url||c.has(t.family)||typeof FontFace>"u")return;const o=new FontFace(t.family,`url(${JSON.stringify(t.url)})`,{weight:t.wght?`${t.wght[0]} ${t.wght[1]}`:"1 1000",style:"normal",display:"block"});document.fonts.add(o),c.set(t.family,o)}function m(t){const o=c.get(t);o&&(document.fonts.delete(o),c.delete(t))}let a=null,g=!1;function y(t=!1){return g||(g=!0,C.subscribe((o,e)=>{const n=o.user?.uid??null,i=e.user?.uid??null;if(n!==i)if(n)y(!0);else{for(const s of r.fonts)m(s.family);a=Promise.resolve(),u({fonts:[],loaded:!0,error:null})}})),a&&!t||(a=b().then(o=>{const e=(Array.isArray(o?.fonts)?o.fonts:[]).filter(n=>n&&w(n.family)&&typeof n.name=="string");for(const n of r.fonts)e.some(i=>i.family===n.family)||m(n.family);for(const n of e)try{h(n)}catch{}u({fonts:e,loaded:!0,error:null})}).catch(o=>{u({loaded:!0,error:o?.message||"fonts"})})),a}const P=()=>y();function z(t){return t?w(t)?r.fonts.find(o=>o.family===t)?.name??f("Font đã xoá"):t:"Arial"}const L=t=>!!t&&w(t)&&r.loaded&&!r.error&&!r.fonts.some(o=>o.family===t);function R(t){const o=t?.code;return o==="bad_font"?f("File này không phải font dùng được (.ttf, .otf, .woff, .woff2 · không nhận bộ .ttc · tối đa {0} MB).",[String(d)]):o==="font_limit"?f("Tối đa 50 font — xoá bớt font không dùng rồi tải lên lại."):o==="font_rights"?f("Cần xác nhận bạn có quyền dùng font trước khi tải lên."):o==="font_not_found"?f("Không tìm thấy font."):t?.message||String(t)}async function q(t,o){const e=(t.name.match(/\.([a-z0-9]+)$/i)?.[1]||"").toLowerCase(),n=x[e];if(!n)throw new Error(f("Chỉ nhận file font .ttf, .otf, .woff hoặc .woff2"));if(t.size>d*1024*1024)throw new Error(f("Font tối đa {0} MB",[String(d)]));const i=await U(new File([t],t.name,{type:n}),o,"font"),s=await _({gcsUri:i.gcsUri,rightsConfirmed:!0});return h(s.font),u({fonts:[s.font,...r.fonts.filter(F=>F.family!==s.font.family)]}),s}async function J(t){await S(t.id),m(t.family),u({fonts:r.fonts.filter(o=>o.id!==t.id)})}export{B as FONT_ACCEPT,d as FONT_MAX_MB,x as FONT_TYPES,R as fontError,z as fontLabel,L as isMissingCustomFont,y as loadUserFonts,J as removeUserFont,q as uploadUserFont,$ as useUserFonts,P as userFontsReady,v as userFontsState};
1
+ import{r as p}from"./index-CKtv7gGE.js";import{bU as b,bV as S,u as U,bW as _}from"./api-CZoVJ9Fy.js";import{u as C}from"./store-D3Y663py.js";import{i as w}from"./textAnimators-C4eMnVRD.js";import{t as f}from"./i18n-ClNt3LKg.js";import"./titleFrameBudget-h4nOQ5u9.js";let r={fonts:[],loaded:!1,error:null};const l=new Set,u=t=>{r={...r,...t},l.forEach(o=>o())},E=t=>(l.add(t),()=>{l.delete(t)}),$=()=>p.useSyncExternalStore(E,()=>r),v=()=>r,x={ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2"},B=".ttf,.otf,.woff,.woff2,font/ttf,font/otf,font/woff,font/woff2",d=10,c=new Map;function h(t){if(!t.url||c.has(t.family)||typeof FontFace>"u")return;const o=new FontFace(t.family,`url(${JSON.stringify(t.url)})`,{weight:t.wght?`${t.wght[0]} ${t.wght[1]}`:"1 1000",style:"normal",display:"block"});document.fonts.add(o),c.set(t.family,o)}function m(t){const o=c.get(t);o&&(document.fonts.delete(o),c.delete(t))}let a=null,g=!1;function y(t=!1){return g||(g=!0,C.subscribe((o,e)=>{const n=o.user?.uid??null,i=e.user?.uid??null;if(n!==i)if(n)y(!0);else{for(const s of r.fonts)m(s.family);a=Promise.resolve(),u({fonts:[],loaded:!0,error:null})}})),a&&!t||(a=b().then(o=>{const e=(Array.isArray(o?.fonts)?o.fonts:[]).filter(n=>n&&w(n.family)&&typeof n.name=="string");for(const n of r.fonts)e.some(i=>i.family===n.family)||m(n.family);for(const n of e)try{h(n)}catch{}u({fonts:e,loaded:!0,error:null})}).catch(o=>{u({loaded:!0,error:o?.message||"fonts"})})),a}const P=()=>y();function z(t){return t?w(t)?r.fonts.find(o=>o.family===t)?.name??f("Font đã xoá"):t:"Arial"}const L=t=>!!t&&w(t)&&r.loaded&&!r.error&&!r.fonts.some(o=>o.family===t);function q(t){const o=t?.code;return o==="bad_font"?f("File này không phải font dùng được (.ttf, .otf, .woff, .woff2 · không nhận bộ .ttc · tối đa {0} MB).",[String(d)]):o==="font_limit"?f("Tối đa 50 font — xoá bớt font không dùng rồi tải lên lại."):o==="font_rights"?f("Cần xác nhận bạn có quyền dùng font trước khi tải lên."):o==="font_not_found"?f("Không tìm thấy font."):t?.message||String(t)}async function J(t,o){const e=(t.name.match(/\.([a-z0-9]+)$/i)?.[1]||"").toLowerCase(),n=x[e];if(!n)throw new Error(f("Chỉ nhận file font .ttf, .otf, .woff hoặc .woff2"));if(t.size>d*1024*1024)throw new Error(f("Font tối đa {0} MB",[String(d)]));const i=await U(new File([t],t.name,{type:n}),o,"font"),s=await _({gcsUri:i.gcsUri,rightsConfirmed:!0});return h(s.font),u({fonts:[s.font,...r.fonts.filter(F=>F.family!==s.font.family)]}),s}async function K(t){await S(t.id),m(t.family),u({fonts:r.fonts.filter(o=>o.id!==t.id)})}export{B as FONT_ACCEPT,d as FONT_MAX_MB,x as FONT_TYPES,q as fontError,z as fontLabel,L as isMissingCustomFont,y as loadUserFonts,K as removeUserFont,J as uploadUserFont,$ as useUserFonts,P as userFontsReady,v as userFontsState};
@@ -1,4 +1,4 @@
1
- import{eK as D}from"./remote-8XzEAnAJ.js";import{FramebufferTexture as F,ShaderMaterial as S,Color as w,WebGLRenderTarget as k,NoColorSpace as O,HalfFloatType as A,UnsignedByteType as I}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const U=new S({uniforms:{tC:{value:null},tB:{value:null},tW:{value:null},uOcc:{value:0}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:`uniform sampler2D tC, tB, tW; uniform float uOcc; varying vec2 vUv;
1
+ import{eK as D}from"./remote-CpkPQOQH.js";import{FramebufferTexture as F,ShaderMaterial as S,Color as w,WebGLRenderTarget as k,NoColorSpace as O,HalfFloatType as A,UnsignedByteType as I}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";const U=new S({uniforms:{tC:{value:null},tB:{value:null},tW:{value:null},uOcc:{value:0}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:`uniform sampler2D tC, tB, tW; uniform float uOcc; varying vec2 vUv;
2
2
  void main() {
3
3
  vec3 b = texture2D(tB, vUv).rgb, w = texture2D(tW, vUv).rgb;
4
4
  float occ = clamp(1.0 - max(max(w.r - b.r, w.g - b.g), w.b - b.b), 0.0, 1.0);
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShotComposer-XIbJ4nNm.js","assets/titleFrameBudget-h4nOQ5u9.js","assets/remote-CpkPQOQH.js","assets/index-CKtv7gGE.js","assets/i18n-ClNt3LKg.js","assets/api-CZoVJ9Fy.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-D3Y663py.js","assets/rotoMaskStore-BZBJLcCp.js","assets/sceneTrack-CO4fTjft.js","assets/timelineOps-f1WsVbgS.js","assets/cameraTracker-Df9jWmz6.js","assets/textAnimators-C4eMnVRD.js","assets/timelineComp-Ciu9JCWJ.js","assets/rigTrack-BbKqZGs7.js","assets/clientJobs-CuuUyhEy.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/tool-tp6gat1J.js","assets/timelineProps-CE1R11Hx.js","assets/thumb-M9B_goj-.js","assets/shotFxAgent-L2GG88W3.js","assets/cameraPresets-DD0WmxiI.js","assets/weaponDuel-ChqBQo_b.js","assets/skin-CirUiqcr.js","assets/views-CNF3Afse.js","assets/motionBlur-uAm030t9.js","assets/library-cb43ZEmy.js","assets/ShotComposer-DcwWZ-eP.css"])))=>i.map(i=>d[i]);
2
+ import{_ as l}from"./titleFrameBudget-h4nOQ5u9.js";import{R as h}from"./index-CKtv7gGE.js";import{V as w}from"./remote-CpkPQOQH.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";let p=Promise.resolve();const c=o=>new Promise(r=>setTimeout(r,o));function T(o,r,{timeoutMs:d=6e4}={}){const n=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 m=w.createRoot(e);try{const{default:u}=await l(async()=>{const{default:t}=await import("./ShotComposer-XIbJ4nNm.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,23,24,25,26,27,28]));let i=null;m.render(h.createElement(u,{nodeId:o,background:t=>{i=t}}));const s=Date.now()+d;for(;!i?.ready();){if(Date.now()>s)throw new Error("3D Shot did not start in time");await c(60)}for(;;)try{return await r(i)}catch(t){if(!/chưa tải xong/.test(t.message)||Date.now()>s)throw t;await c(500)}}finally{m.unmount(),e.remove()}},a=p.then(n,n);return p=a.catch(()=>{}),a}export{T as withBackgroundScene};
@@ -1 +1 @@
1
- import{dc as S}from"./remote-8XzEAnAJ.js";import{s as U}from"./motionBlur-uAm030t9.js";import{M as ot}from"./motionBlur-uAm030t9.js";import{bF as C,c as M}from"./id3-arvEpAg7.js";import{S as O,B as D,O as H,W as P,a as B,C as I}from"./output-p-Q7qous.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";async function et(s,T,m){const{start:u,end:F,fps:r,signal:d,progress:w}=m,a=F-u,n=Math.ceil(a*r);if(!(a>0)||!Number.isFinite(a)||!S.includes(r))throw new Error("Khoảng thời gian hoặc FPS không hợp lệ");const f=new C({bitrate:m.height>=1080?6e6:3e6}),o=m.alpha===!0,g=o?"vp9":"avc",k=o?"webm":"mp4";if(!await M(g,{width:s.width,height:s.height,quality:f}))throw new Error(o?"Trình duyệt chưa hỗ trợ xuất VP9 có kênh trong suốt. Hãy dùng Chrome/Edge mới.":"Trình duyệt chưa hỗ trợ xuất H.264. Hãy dùng Chrome/Edge mới, hoặc thử 720p.");let h,c;const l=`camera-export-${crypto.randomUUID()}.${k}`;let t;const y=async()=>{h&&await h.removeEntry(l).catch(()=>{})};try{let i;if(navigator.storage?.getDirectory)h=await navigator.storage.getDirectory(),c=await h.getFileHandle(l,{create:!0}),i=new O(await c.createWritable(),{chunked:!0,chunkSize:1024*1024});else{if(a*(m.height>=1080?6e6:3e6)/8>1e8)throw new Error("Trình duyệt này thiếu bộ nhớ tạm cho video dài. Dùng Chrome/Edge hoặc xuất một đoạn ngắn hơn.");i=new D}t=new H({format:o?new P:new B({fastStart:"reserve"}),target:i});const p=new I(s,{codec:g,quality:f,...o?{alpha:"keep"}:{}});t.addVideoTrack(p,{frameRate:r,maximumPacketCount:n}),await t.start();for(let e=0;e<n;e++){d.throwIfAborted();const b=e/r,x=Math.min(1/r,a-b);await T(u+(n>1?e/(n-1):0)*a),await p.add(b,x,{keyFrame:e%r===0}),e%6===0&&(w(Math.round((e+1)/n*95)),await new Promise(E=>setTimeout(E,0)))}d.throwIfAborted(),p.close(),await t.finalize();const v=c?await c.getFile():new Blob([i.buffer],{type:o?"video/webm":"video/mp4"});return w(100),{blob:v,cleanup:y}}catch(i){throw t&&t.state!=="finalized"&&t.state!=="canceled"&&await t.cancel().catch(()=>{}),await y(),i}}export{ot as MOTION_BLUR,et as encodeCameraVideo,U as shutterTimes};
1
+ import{dc as S}from"./remote-CpkPQOQH.js";import{s as U}from"./motionBlur-uAm030t9.js";import{M as ot}from"./motionBlur-uAm030t9.js";import{bF as C,c as M}from"./id3-arvEpAg7.js";import{S as O,B as D,O as H,W as P,a as B,C as I}from"./output-p-Q7qous.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";async function et(s,T,m){const{start:u,end:F,fps:r,signal:d,progress:w}=m,a=F-u,n=Math.ceil(a*r);if(!(a>0)||!Number.isFinite(a)||!S.includes(r))throw new Error("Khoảng thời gian hoặc FPS không hợp lệ");const f=new C({bitrate:m.height>=1080?6e6:3e6}),o=m.alpha===!0,g=o?"vp9":"avc",k=o?"webm":"mp4";if(!await M(g,{width:s.width,height:s.height,quality:f}))throw new Error(o?"Trình duyệt chưa hỗ trợ xuất VP9 có kênh trong suốt. Hãy dùng Chrome/Edge mới.":"Trình duyệt chưa hỗ trợ xuất H.264. Hãy dùng Chrome/Edge mới, hoặc thử 720p.");let h,c;const l=`camera-export-${crypto.randomUUID()}.${k}`;let t;const y=async()=>{h&&await h.removeEntry(l).catch(()=>{})};try{let i;if(navigator.storage?.getDirectory)h=await navigator.storage.getDirectory(),c=await h.getFileHandle(l,{create:!0}),i=new O(await c.createWritable(),{chunked:!0,chunkSize:1024*1024});else{if(a*(m.height>=1080?6e6:3e6)/8>1e8)throw new Error("Trình duyệt này thiếu bộ nhớ tạm cho video dài. Dùng Chrome/Edge hoặc xuất một đoạn ngắn hơn.");i=new D}t=new H({format:o?new P:new B({fastStart:"reserve"}),target:i});const p=new I(s,{codec:g,quality:f,...o?{alpha:"keep"}:{}});t.addVideoTrack(p,{frameRate:r,maximumPacketCount:n}),await t.start();for(let e=0;e<n;e++){d.throwIfAborted();const b=e/r,x=Math.min(1/r,a-b);await T(u+(n>1?e/(n-1):0)*a),await p.add(b,x,{keyFrame:e%r===0}),e%6===0&&(w(Math.round((e+1)/n*95)),await new Promise(E=>setTimeout(E,0)))}d.throwIfAborted(),p.close(),await t.finalize();const v=c?await c.getFile():new Blob([i.buffer],{type:o?"video/webm":"video/mp4"});return w(100),{blob:v,cleanup:y}}catch(i){throw t&&t.state!=="finalized"&&t.state!=="canceled"&&await t.cancel().catch(()=>{}),await y(),i}}export{ot as MOTION_BLUR,et as encodeCameraVideo,U as shutterTimes};
@@ -1 +1 @@
1
- import{Bone as k,SkinnedMesh as g,Vector3 as a,Scene as L,Color as M,MeshLambertMaterial as b,HemisphereLight as S,DirectionalLight as h,WebGLRenderer as z,OrthographicCamera as C}from"./three.module-Bx43vjkH.js";import{a as D}from"./gltfLoader-U0Eebg7v.js";import{f as E}from"./skin-xFScwS3T.js";import"./remote-8XzEAnAJ.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const B=640;function N(y,p=B){const t=D(y);t.position.set(0,0,0),t.quaternion.identity(),t.scale.set(1,1,1);const c=[];t.traverse(e=>{e.userData.rigOverlay&&c.push(e),e instanceof k&&e.quaternion.identity()}),c.forEach(e=>e.parent?.remove(e)),t.traverse(e=>{e instanceof g&&e.skeleton.pose()});const m=E(t),n=m.getCenter(new a),f=m.getSize(new a),r=Math.max(f.x,f.y,f.z)/2*1.08,o=new L;o.background=new M("#ffffff");const d=new b({color:"#8d949b"});o.overrideMaterial=d,o.add(new S("#ffffff","#5a6066",2.2));const l=new h("#ffffff",1.4);l.position.set(.4,1,1),o.add(l);const u=new h("#ffffff",.6);u.position.set(1,.5,.3),o.add(u),o.add(t);const i=new z({antialias:!0,preserveDrawingBuffer:!0});i.setSize(p,p,!1);const s=new C(-r,r,r,-r,.01,100),w=e=>(s.position.copy(n).add(e),s.up.set(0,1,0),s.lookAt(n),s.updateProjectionMatrix(),i.render(o,s),i.domElement.toDataURL("image/jpeg",.88));try{const e=r*4,x=w(new a(0,0,e)),v=w(new a(e,0,0));return{front:x,side:v,frame:{cx:n.x,cy:n.y,cz:n.z,half:r}}}finally{d.dispose(),i.dispose(),i.forceContextLoss(),t.traverse(e=>{e instanceof g&&e.skeleton.dispose()})}}export{B as VIEW_SIZE,N as renderRigViews};
1
+ import{Bone as k,SkinnedMesh as g,Vector3 as a,Scene as L,Color as M,MeshLambertMaterial as b,HemisphereLight as S,DirectionalLight as h,WebGLRenderer as z,OrthographicCamera as C}from"./three.module-Bx43vjkH.js";import{a as D}from"./gltfLoader-U0Eebg7v.js";import{f as E}from"./skin-CirUiqcr.js";import"./remote-CpkPQOQH.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";const B=640;function N(y,p=B){const t=D(y);t.position.set(0,0,0),t.quaternion.identity(),t.scale.set(1,1,1);const c=[];t.traverse(e=>{e.userData.rigOverlay&&c.push(e),e instanceof k&&e.quaternion.identity()}),c.forEach(e=>e.parent?.remove(e)),t.traverse(e=>{e instanceof g&&e.skeleton.pose()});const m=E(t),n=m.getCenter(new a),f=m.getSize(new a),r=Math.max(f.x,f.y,f.z)/2*1.08,o=new L;o.background=new M("#ffffff");const d=new b({color:"#8d949b"});o.overrideMaterial=d,o.add(new S("#ffffff","#5a6066",2.2));const l=new h("#ffffff",1.4);l.position.set(.4,1,1),o.add(l);const u=new h("#ffffff",.6);u.position.set(1,.5,.3),o.add(u),o.add(t);const i=new z({antialias:!0,preserveDrawingBuffer:!0});i.setSize(p,p,!1);const s=new C(-r,r,r,-r,.01,100),w=e=>(s.position.copy(n).add(e),s.up.set(0,1,0),s.lookAt(n),s.updateProjectionMatrix(),i.render(o,s),i.domElement.toDataURL("image/jpeg",.88));try{const e=r*4,x=w(new a(0,0,e)),v=w(new a(e,0,0));return{front:x,side:v,frame:{cx:n.x,cy:n.y,cz:n.z,half:r}}}finally{d.dispose(),i.dispose(),i.forceContextLoss(),t.traverse(e=>{e instanceof g&&e.skeleton.dispose()})}}export{B as VIEW_SIZE,N as renderRigViews};
@@ -1 +1 @@
1
- import{f6 as pt,f7 as Y,bS as ut,bR as mt,bU as Z,bW as U,ei as kt,b as bt,bX as gt,c5 as tt,c6 as et,ee as Mt,cm as yt,eh as wt}from"./remote-8XzEAnAJ.js";import{m as vt}from"./rigTrack-DMyqb0pb.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},Kt=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(z(t).clip),at.set(t,e)),e},At=(t,e)=>t[Math.max(0,Math.min(t.length-1,Math.round(e*30)))];function lt(t){const e=z(t).clip.keys.filter(i=>i.strike).at(-1);return e?e.t:0}const Ft=t=>z(t).clip.keys.filter(e=>e.strike).at(-1)?.limb??"handR",ot=(t,e)=>At(dt(t),e).dz??0;function St(t){const{pack:e}=z(t),i=dt(t),l=lt(t),o=Ft(t);let f=0;for(const h of i){if(Math.abs(h.t-l)>.1)continue;if(e.id==="fist"){const j=vt(h.pose),m=j[o.replace("foot","toe")];f=Math.max(f,m[2]-j.pelvis[2]);continue}const r=ut(h.pose),u=r.front[2]+r.dir[2]*jt[e.id];f=Math.max(f,u)}return f}function $t(t){let e=t>>>0||1;return()=>{e=e+1831565813>>>0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}function Tt(t,e=4,i=1){const l=$t(i),o=[];let f=0,h=["",""];for(let r=0;r<e;r++){r>0&&l()<.62&&(f=1-f);const u=t[f],j=t[1-f],m=Object.keys(st[u]).filter($=>$!==h[f]),b=m[Math.floor(l()*m.length)],C=st[u][b];h[f]=b;const a=l();let y=r===e-1?"body":a<.5?"blocked":a<.78?"miss":"body";y==="blocked"&&!it[C]&&(y="miss");const S=`${j}-${y==="blocked"?it[C]:y==="miss"?"dodge-back":"hit"}`,D=lt(b),O=z(S).clip.contact??0,g=Math.max(Kt,St(b)+Ot[y]+ot(b,D)+ot(S,O));o.push({attacker:f,attack:b,defence:S,result:y,strike:D,contact:O,gap:Math.round(g*1e3)/1e3})}return o}const R=[.18,.42],nt=t=>(t.kind==="model"?(t.model?.height??2)/1.8:Mt(t))*(t.scale[1]||1),q=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const i=v(t),l=i.duration/e,o=h=>h?.map(r=>({...r,time:Math.min(1,r.time*l)})),f={...i,duration:e,cameraKeys:o(i.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(i.objectKeys||{}).map(([h,r])=>[h,o(r)||[]])),...i.impacts?{impacts:o(i.impacts)}:{},...i.flight?{flight:Object.fromEntries(Object.entries(i.flight).map(([h,r])=>[h,o(r)||[]]))}:{},...i.focus?.keys?{focus:{...i.focus,keys:o(i.focus.keys)}}:{}};return{...t,shots:t.shots.map(h=>h.id===i.id?f:h)}}const ct=(t,e,i)=>{const l=v(t);return{...t,shots:t.shots.map(o=>o.id===l.id?{...o,objectKeys:{...o.objectKeys,[e]:i(o.objectKeys?.[e]||[],o)}}:o)}},T=(t,e,i)=>{const l=v(t),o=yt(t.items.find(f=>f.id===e.id),l,Math.min(1,i/l.duration));return{position:o.position,yaw:o.rotation[1]}};function zt(t,e,i){const l=t.items.find(s=>s.id===e.a),o=t.items.find(s=>s.id===e.b);if(!l||!o||!Z(l)||!Z(o))return{ok:!1,error:"two people are needed"};if(l.id===o.id)return{ok:!1,error:"two different people are needed"};const f=Math.max(1,Math.min(10,Math.round(e.exchanges))),h=Tt(e.packs,f,e.seed),r=[l,o],u=[nt(l),nt(o)],j=[],m=Math.max(0,e.start),b=v(t),C=m+.5+h.reduce((s,c)=>s+Math.max(U(c.attack).duration,c.strike-c.contact+U(c.defence).duration)+1.4+R[1],0);let a=C>b.duration?rt(t,Math.min(300,C)):t;const M=T(a,l,m),y=h[0].gap*(u[0]+u[1])/2,S=[Math.sin(q(M.yaw)),0,Math.cos(q(M.yaw))],D=[M.position[0]+S[0]*y,M.position[1],M.position[2]+S[2]*y];for(const[s,c,n]of[[l,M.position,M.yaw],[o,D,M.yaw+180]])a=ct(a,s.id,(d,k)=>[...d.filter(p=>p.time*k.duration<m-1e-6),{id:i(),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(a),k=U(c),p=wt(a,r[s].id,k,{start:n/d.duration,newId:i,loop:!1});if(!p.ok)throw new Error(`${r[s].name}: ${p.error}`);return a=p.stage,n+k.duration};let g=m+.35,$=m;const E=[];let x=(e.seed*9301+49297)%233280;const ht=()=>(x=(x*9301+49297)%233280,x/233280);try{h.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const K=T(a,r[0],g).position,A=T(a,r[1],g).position;return Math.hypot(A[0]-K[0],A[2]-K[2])};for(let K=0;K<3;K++){const A=p()-s.gap*k;if(Math.abs(A)<.3*k)break;A>0?g=O(n,`${e.packs[n]}-advance`,g):g=O(d,`${e.packs[d]}-retreat`,g)}const N=Math.max(0,s.contact-s.strike),w=g+N,_=w+s.strike-s.contact,P=p()-s.gap*k,W=O(n,s.attack,w),ft=O(d,s.defence,_),H=r[n],B=T(a,H,w).yaw,G=[Math.sin(q(B)),Math.cos(q(B))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,P));a=ct(a,H.id,(K,A)=>K.map(F=>{const I=F.time*A.duration;if(I<w-1e-6||I>W+1e-6)return F;const L=Math.min(1,(I-w)/Math.max(.001,s.strike)),X=L*L*(3-2*L),Q={...F,position:[+(F.position[0]+G[0]*V*X).toFixed(3),F.position[1],+(F.position[2]+G[1]*V*X).toFixed(3)]};return F.strike&&Math.abs(I-J)<.06?{...Q,hit:s.result}:Q})),E.push({...s,time:+J.toFixed(2),attackerName:H.name}),$=Math.max(W,ft),g=$+R[0]+(R[1]-R[0])*ht(),c===h.length-1&&j.push(`${r[d].name} dính đòn kết`)})}catch(s){return{ok:!1,error:s.message}}if(v(a).duration>b.duration&&(a=rt(a,Math.max(b.duration,Math.min(300,Math.ceil(($+.6)*10)/10)))),a=kt(a).stage,e.packs.includes("fist")){const s=v(a),c=[],n={};E.forEach((d,k)=>{if(d.result==="miss"||e.packs[d.attacker]!=="fist")return;const p=T(a,r[0],d.time).position,N=T(a,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({...bt("fx",a.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&&(a={...a,items:[...a.items,...c],shots:a.shots.map(d=>d.id===s.id?{...d,fxTiming:{...d.fxTiming,...n}}:d)})}if(e.hitStops!==!1){const s=v(a);let c=gt(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),a={...a,shots:a.shots.map(n=>n.id===s.id&&c?{...n,timing:c}:n)}}return{ok:!0,stage:a,plan:E,end:+$.toFixed(2),notes:j}}export{st as D,zt as s};
1
+ import{f6 as pt,f7 as Y,bS as ut,bR as mt,bU as Z,bW as U,ei as kt,b as bt,bX as gt,c5 as tt,c6 as et,ee as Mt,cm as yt,eh as wt}from"./remote-CpkPQOQH.js";import{m as vt}from"./rigTrack-BbKqZGs7.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},Kt=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(z(t).clip),at.set(t,e)),e},At=(t,e)=>t[Math.max(0,Math.min(t.length-1,Math.round(e*30)))];function lt(t){const e=z(t).clip.keys.filter(i=>i.strike).at(-1);return e?e.t:0}const Ft=t=>z(t).clip.keys.filter(e=>e.strike).at(-1)?.limb??"handR",ot=(t,e)=>At(dt(t),e).dz??0;function St(t){const{pack:e}=z(t),i=dt(t),l=lt(t),o=Ft(t);let f=0;for(const h of i){if(Math.abs(h.t-l)>.1)continue;if(e.id==="fist"){const j=vt(h.pose),m=j[o.replace("foot","toe")];f=Math.max(f,m[2]-j.pelvis[2]);continue}const r=ut(h.pose),u=r.front[2]+r.dir[2]*jt[e.id];f=Math.max(f,u)}return f}function $t(t){let e=t>>>0||1;return()=>{e=e+1831565813>>>0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}function Tt(t,e=4,i=1){const l=$t(i),o=[];let f=0,h=["",""];for(let r=0;r<e;r++){r>0&&l()<.62&&(f=1-f);const u=t[f],j=t[1-f],m=Object.keys(st[u]).filter($=>$!==h[f]),b=m[Math.floor(l()*m.length)],C=st[u][b];h[f]=b;const a=l();let y=r===e-1?"body":a<.5?"blocked":a<.78?"miss":"body";y==="blocked"&&!it[C]&&(y="miss");const S=`${j}-${y==="blocked"?it[C]:y==="miss"?"dodge-back":"hit"}`,D=lt(b),O=z(S).clip.contact??0,g=Math.max(Kt,St(b)+Ot[y]+ot(b,D)+ot(S,O));o.push({attacker:f,attack:b,defence:S,result:y,strike:D,contact:O,gap:Math.round(g*1e3)/1e3})}return o}const R=[.18,.42],nt=t=>(t.kind==="model"?(t.model?.height??2)/1.8:Mt(t))*(t.scale[1]||1),q=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const i=v(t),l=i.duration/e,o=h=>h?.map(r=>({...r,time:Math.min(1,r.time*l)})),f={...i,duration:e,cameraKeys:o(i.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(i.objectKeys||{}).map(([h,r])=>[h,o(r)||[]])),...i.impacts?{impacts:o(i.impacts)}:{},...i.flight?{flight:Object.fromEntries(Object.entries(i.flight).map(([h,r])=>[h,o(r)||[]]))}:{},...i.focus?.keys?{focus:{...i.focus,keys:o(i.focus.keys)}}:{}};return{...t,shots:t.shots.map(h=>h.id===i.id?f:h)}}const ct=(t,e,i)=>{const l=v(t);return{...t,shots:t.shots.map(o=>o.id===l.id?{...o,objectKeys:{...o.objectKeys,[e]:i(o.objectKeys?.[e]||[],o)}}:o)}},T=(t,e,i)=>{const l=v(t),o=yt(t.items.find(f=>f.id===e.id),l,Math.min(1,i/l.duration));return{position:o.position,yaw:o.rotation[1]}};function zt(t,e,i){const l=t.items.find(s=>s.id===e.a),o=t.items.find(s=>s.id===e.b);if(!l||!o||!Z(l)||!Z(o))return{ok:!1,error:"two people are needed"};if(l.id===o.id)return{ok:!1,error:"two different people are needed"};const f=Math.max(1,Math.min(10,Math.round(e.exchanges))),h=Tt(e.packs,f,e.seed),r=[l,o],u=[nt(l),nt(o)],j=[],m=Math.max(0,e.start),b=v(t),C=m+.5+h.reduce((s,c)=>s+Math.max(U(c.attack).duration,c.strike-c.contact+U(c.defence).duration)+1.4+R[1],0);let a=C>b.duration?rt(t,Math.min(300,C)):t;const M=T(a,l,m),y=h[0].gap*(u[0]+u[1])/2,S=[Math.sin(q(M.yaw)),0,Math.cos(q(M.yaw))],D=[M.position[0]+S[0]*y,M.position[1],M.position[2]+S[2]*y];for(const[s,c,n]of[[l,M.position,M.yaw],[o,D,M.yaw+180]])a=ct(a,s.id,(d,k)=>[...d.filter(p=>p.time*k.duration<m-1e-6),{id:i(),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(a),k=U(c),p=wt(a,r[s].id,k,{start:n/d.duration,newId:i,loop:!1});if(!p.ok)throw new Error(`${r[s].name}: ${p.error}`);return a=p.stage,n+k.duration};let g=m+.35,$=m;const E=[];let x=(e.seed*9301+49297)%233280;const ht=()=>(x=(x*9301+49297)%233280,x/233280);try{h.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const K=T(a,r[0],g).position,A=T(a,r[1],g).position;return Math.hypot(A[0]-K[0],A[2]-K[2])};for(let K=0;K<3;K++){const A=p()-s.gap*k;if(Math.abs(A)<.3*k)break;A>0?g=O(n,`${e.packs[n]}-advance`,g):g=O(d,`${e.packs[d]}-retreat`,g)}const N=Math.max(0,s.contact-s.strike),w=g+N,_=w+s.strike-s.contact,P=p()-s.gap*k,W=O(n,s.attack,w),ft=O(d,s.defence,_),H=r[n],B=T(a,H,w).yaw,G=[Math.sin(q(B)),Math.cos(q(B))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,P));a=ct(a,H.id,(K,A)=>K.map(F=>{const I=F.time*A.duration;if(I<w-1e-6||I>W+1e-6)return F;const L=Math.min(1,(I-w)/Math.max(.001,s.strike)),X=L*L*(3-2*L),Q={...F,position:[+(F.position[0]+G[0]*V*X).toFixed(3),F.position[1],+(F.position[2]+G[1]*V*X).toFixed(3)]};return F.strike&&Math.abs(I-J)<.06?{...Q,hit:s.result}:Q})),E.push({...s,time:+J.toFixed(2),attackerName:H.name}),$=Math.max(W,ft),g=$+R[0]+(R[1]-R[0])*ht(),c===h.length-1&&j.push(`${r[d].name} dính đòn kết`)})}catch(s){return{ok:!1,error:s.message}}if(v(a).duration>b.duration&&(a=rt(a,Math.max(b.duration,Math.min(300,Math.ceil(($+.6)*10)/10)))),a=kt(a).stage,e.packs.includes("fist")){const s=v(a),c=[],n={};E.forEach((d,k)=>{if(d.result==="miss"||e.packs[d.attacker]!=="fist")return;const p=T(a,r[0],d.time).position,N=T(a,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({...bt("fx",a.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&&(a={...a,items:[...a.items,...c],shots:a.shots.map(d=>d.id===s.id?{...d,fxTiming:{...d.fxTiming,...n}}:d)})}if(e.hitStops!==!1){const s=v(a);let c=gt(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),a={...a,shots:a.shots.map(n=>n.id===s.id&&c?{...n,timing:c}:n)}}return{ok:!0,stage:a,plan:E,end:+$.toFixed(2),notes:j}}export{st as D,zt as s};
@@ -1 +1 @@
1
- import{k9 as P,a7 as b,U as W,$ as y,Z as E,a0 as F,j1 as x}from"./titleFrameBudget-DsM0V482.js";import"./rotoMatte-7b7Ow64f.js";import"./api-Dnl2uaKO.js";import"./i18n-C9zFX25m.js";import"./index-CKtv7gGE.js";import"./store-CpqHUcA2.js";const _=t=>P(t).length>0,O=new Map;function D(t){const r=t.face??t.colorPerson??t.person??t.roto??t.mask;if(r?.mw&&r?.mh)return Promise.resolve(r.mh/r.mw);let o=O.get(t.url);return o||(o=new Promise(n=>{if(t.kind==="image"){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a.naturalHeight/Math.max(1,a.naturalWidth)),a.onerror=()=>n(9/16),a.src=t.url;return}const e=document.createElement("video");e.preload="metadata",e.muted=!0,e.crossOrigin="anonymous",e.onloadedmetadata=()=>{n(e.videoHeight/Math.max(1,e.videoWidth)),e.removeAttribute("src"),e.load()},e.onerror=()=>n(9/16),e.src=t.url}),O.set(t.url,o)),o}function I(t,r,o,n,e,a,g){const i=W(t.grade)[r],h=t.colorPerson?E(t.colorPerson):null,p=F(i,t,o,a,h),c=g??document.createElement("canvas");(c.width!==n||c.height!==e)&&Object.assign(c,{width:n,height:e});const l=c.getContext("2d"),d=l.createImageData(n,e);for(let w=0;w<e;w++)for(let u=0;u<n;u++){const m=(w*n+u)*4,s=Math.round(p((u+.5)/n,(w+.5)/e,0,0,0)*255);d.data[m]=d.data[m+1]=d.data[m+2]=s,d.data[m+3]=255}return l.putImageData(d,0,0),c}async function B(t,r,o,n){const e=document.createElement("canvas");for(const{key:a,k:g,clip:i}of P(t)){if(o.wants&&!o.wants("windowFrames",a))continue;i.colorPerson&&await b(i.colorPerson);const h=await D(i),p=x,c=Math.max(2,Math.min(x*2,Math.round(p*h))),l=W(i.grade)[g],d=Math.ceil(i.duration*r),w=!!l.motion;let u="",m="";for(let s=0;s<d;s++){if(n?.aborted)throw new DOMException("Export cancelled","AbortError");if(o.wants&&!o.wants("windowFrames",a,s)){await o.push("windowFrames",a,""),m="";continue}if(w){const f=JSON.stringify(y(l,i,s/r));if(s&&f===m){await o.push("windowFrames",a,"=");continue}m=f}I(i,g,s/r,p,c,h,e);const M=e.toDataURL("image/webp",.9),v=M.slice(M.indexOf(",")+1);if(v===u){await o.push("windowFrames",a,"=");continue}u=v,await o.push("windowFrames",a,v),s%5===0&&await new Promise(f=>setTimeout(f,0))}}}export{_ as hasMovingWindows,D as pictureAspect,B as renderWindowFrames,I as windowMatteImage};
1
+ import{kg as P,a7 as b,U as W,$ as y,Z as E,a0 as F,j5 as x}from"./titleFrameBudget-h4nOQ5u9.js";import"./rotoMatte-BI-vjjrv.js";import"./api-CZoVJ9Fy.js";import"./i18n-ClNt3LKg.js";import"./index-CKtv7gGE.js";import"./store-D3Y663py.js";const _=t=>P(t).length>0,O=new Map;function D(t){const r=t.face??t.colorPerson??t.person??t.roto??t.mask;if(r?.mw&&r?.mh)return Promise.resolve(r.mh/r.mw);let o=O.get(t.url);return o||(o=new Promise(n=>{if(t.kind==="image"){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a.naturalHeight/Math.max(1,a.naturalWidth)),a.onerror=()=>n(9/16),a.src=t.url;return}const e=document.createElement("video");e.preload="metadata",e.muted=!0,e.crossOrigin="anonymous",e.onloadedmetadata=()=>{n(e.videoHeight/Math.max(1,e.videoWidth)),e.removeAttribute("src"),e.load()},e.onerror=()=>n(9/16),e.src=t.url}),O.set(t.url,o)),o}function I(t,r,o,n,e,a,g){const i=W(t.grade)[r],h=t.colorPerson?E(t.colorPerson):null,p=F(i,t,o,a,h),c=g??document.createElement("canvas");(c.width!==n||c.height!==e)&&Object.assign(c,{width:n,height:e});const l=c.getContext("2d"),d=l.createImageData(n,e);for(let w=0;w<e;w++)for(let u=0;u<n;u++){const m=(w*n+u)*4,s=Math.round(p((u+.5)/n,(w+.5)/e,0,0,0)*255);d.data[m]=d.data[m+1]=d.data[m+2]=s,d.data[m+3]=255}return l.putImageData(d,0,0),c}async function B(t,r,o,n){const e=document.createElement("canvas");for(const{key:a,k:g,clip:i}of P(t)){if(o.wants&&!o.wants("windowFrames",a))continue;i.colorPerson&&await b(i.colorPerson);const h=await D(i),p=x,c=Math.max(2,Math.min(x*2,Math.round(p*h))),l=W(i.grade)[g],d=Math.ceil(i.duration*r),w=!!l.motion;let u="",m="";for(let s=0;s<d;s++){if(n?.aborted)throw new DOMException("Export cancelled","AbortError");if(o.wants&&!o.wants("windowFrames",a,s)){await o.push("windowFrames",a,""),m="";continue}if(w){const f=JSON.stringify(y(l,i,s/r));if(s&&f===m){await o.push("windowFrames",a,"=");continue}m=f}I(i,g,s/r,p,c,h,e);const M=e.toDataURL("image/webp",.9),v=M.slice(M.indexOf(",")+1);if(v===u){await o.push("windowFrames",a,"=");continue}u=v,await o.push("windowFrames",a,v),s%5===0&&await new Promise(f=>setTimeout(f,0))}}}export{_ as hasMovingWindows,D as pictureAspect,B as renderWindowFrames,I as windowMatteImage};
@@ -4,9 +4,9 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="robots" content="noindex" />
6
6
  <title>Timeline layer worker</title>
7
- <script type="module" crossorigin src="/assets/layer-worker-ClVZG6ZW.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-DsM0V482.js">
9
- <link rel="modulepreload" crossorigin href="/assets/frameSink-CSRqCnwI.js">
7
+ <script type="module" crossorigin src="/assets/layer-worker-DP0N05Ua.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-h4nOQ5u9.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/frameSink-Rj02YES5.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
@@ -4,36 +4,36 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="robots" content="noindex" />
6
6
  <title>3D Shot worker</title>
7
- <script type="module" crossorigin src="/assets/shot-worker-DL1ZoIym.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-DsM0V482.js">
7
+ <script type="module" crossorigin src="/assets/shot-worker-BSmfIXHO.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-h4nOQ5u9.js">
9
9
  <link rel="modulepreload" crossorigin href="/assets/index-CKtv7gGE.js">
10
- <link rel="modulepreload" crossorigin href="/assets/i18n-C9zFX25m.js">
11
- <link rel="modulepreload" crossorigin href="/assets/api-Dnl2uaKO.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/i18n-ClNt3LKg.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/api-CZoVJ9Fy.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/three.module-Bx43vjkH.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/gltfLoader-U0Eebg7v.js">
14
- <link rel="modulepreload" crossorigin href="/assets/store-CpqHUcA2.js">
15
- <link rel="modulepreload" crossorigin href="/assets/sceneTrack-DlAH5s74.js">
16
- <link rel="modulepreload" crossorigin href="/assets/rotoMaskStore-pE1AIt3I.js">
17
- <link rel="modulepreload" crossorigin href="/assets/textAnimators-B9vO_hbP.js">
18
- <link rel="modulepreload" crossorigin href="/assets/cameraTracker-DHdF8Zqx.js">
19
- <link rel="modulepreload" crossorigin href="/assets/timelineComp-i-zdaoB2.js">
20
- <link rel="modulepreload" crossorigin href="/assets/rigTrack-DMyqb0pb.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/store-D3Y663py.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/sceneTrack-CO4fTjft.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/rotoMaskStore-BZBJLcCp.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/textAnimators-C4eMnVRD.js">
18
+ <link rel="modulepreload" crossorigin href="/assets/cameraTracker-Df9jWmz6.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/timelineComp-Ciu9JCWJ.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/rigTrack-BbKqZGs7.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/clientJobs-CuuUyhEy.js">
22
- <link rel="modulepreload" crossorigin href="/assets/timelineOps-DSSaDsU2.js">
23
- <link rel="modulepreload" crossorigin href="/assets/remote-8XzEAnAJ.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/timelineOps-f1WsVbgS.js">
23
+ <link rel="modulepreload" crossorigin href="/assets/remote-CpkPQOQH.js">
24
24
  <link rel="modulepreload" crossorigin href="/assets/RoomEnvironment-Dmv_G5ka.js">
25
- <link rel="modulepreload" crossorigin href="/assets/tool-D1FpErrX.js">
26
- <link rel="modulepreload" crossorigin href="/assets/timelineProps-0v-s69pw.js">
27
- <link rel="modulepreload" crossorigin href="/assets/thumb-BTFsBS1u.js">
28
- <link rel="modulepreload" crossorigin href="/assets/shotFxAgent-DqngnGFb.js">
29
- <link rel="modulepreload" crossorigin href="/assets/cameraPresets-Cfn7qhXK.js">
30
- <link rel="modulepreload" crossorigin href="/assets/weaponDuel-DKAEYJjO.js">
31
- <link rel="modulepreload" crossorigin href="/assets/skin-xFScwS3T.js">
32
- <link rel="modulepreload" crossorigin href="/assets/views-RQBs4zva.js">
25
+ <link rel="modulepreload" crossorigin href="/assets/tool-tp6gat1J.js">
26
+ <link rel="modulepreload" crossorigin href="/assets/timelineProps-CE1R11Hx.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/thumb-M9B_goj-.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/shotFxAgent-L2GG88W3.js">
29
+ <link rel="modulepreload" crossorigin href="/assets/cameraPresets-DD0WmxiI.js">
30
+ <link rel="modulepreload" crossorigin href="/assets/weaponDuel-ChqBQo_b.js">
31
+ <link rel="modulepreload" crossorigin href="/assets/skin-CirUiqcr.js">
32
+ <link rel="modulepreload" crossorigin href="/assets/views-CNF3Afse.js">
33
33
  <link rel="modulepreload" crossorigin href="/assets/motionBlur-uAm030t9.js">
34
- <link rel="modulepreload" crossorigin href="/assets/library-BK0QVG4O.js">
35
- <link rel="modulepreload" crossorigin href="/assets/ShotComposer-DLxWpdYH.js">
36
- <link rel="stylesheet" crossorigin href="/assets/ShotComposer-deLi4grZ.css">
34
+ <link rel="modulepreload" crossorigin href="/assets/library-cb43ZEmy.js">
35
+ <link rel="modulepreload" crossorigin href="/assets/ShotComposer-XIbJ4nNm.js">
36
+ <link rel="stylesheet" crossorigin href="/assets/ShotComposer-DcwWZ-eP.css">
37
37
  </head>
38
38
  <body>
39
39
  <div id="root"></div>