clipoox-render 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/scripts/render-local.mjs +5160 -1446
- package/web/assets/FxEmbed-DbfuM8Yo.js +1 -0
- package/web/assets/MotionEmbed-CBQ-8Tzh.js +1 -0
- package/web/assets/PluginStore-OOEx0lP5.js +3 -0
- package/web/assets/ShotComposer-Cng515xa.js +287 -0
- package/web/assets/{ShotComposer-VixLbeMe.css → ShotComposer-deLi4grZ.css} +1 -1
- package/web/assets/TemplateEmbed-hjwM2b0o.js +2 -0
- package/web/assets/{TimelinePlugins-BYZ9y4m3.js → TimelinePlugins-D-NakABP.js} +4 -4
- package/web/assets/TimelineShotFx-D3kGhHN3.js +2 -0
- package/web/assets/TransitionEmbed-DR26yI3a.js +1 -0
- package/web/assets/{Whiteboard-BP_DvIAV.js → Whiteboard-BhxY0D0Z.js} +3 -3
- package/web/assets/aerial-BisYSXzG.js +2 -0
- package/web/assets/agentTools-CPFQeiDP.js +2 -0
- package/web/assets/aiInbetween-AOOM1e6p.js +2 -0
- package/web/assets/analyzerRun-Dtp2o7gT.js +1 -0
- package/web/assets/analyzerSandbox-BG_3Cea1.js +33 -0
- package/web/assets/api-BFN7blbw.js +3158 -0
- package/web/assets/auraTrack-D_gxHNVe.js +1 -0
- package/web/assets/breakthrough-0qFpZW-V.js +2 -0
- package/web/assets/{cameraPresets-CYw0OdM3.js → cameraPresets-eK3mP7qb.js} +1 -1
- package/web/assets/cameraTracker-BAQHuTV-.js +72 -0
- package/web/assets/captionLayout-CWPcbid-.js +1 -0
- package/web/assets/clientExport-DvpTTndR.js +1 -0
- package/web/assets/clientJobs-CIrYTMpn.js +2 -0
- package/web/assets/clientJobs-CuuUyhEy.js +1 -0
- package/web/assets/cutoutClean-CLYYAuXg.js +1 -0
- package/web/assets/depthEstimate-B7D7cGCl.js +1 -0
- package/web/assets/directorTools-CJD4Huqk.js +1 -0
- package/web/assets/distortFrames-BLt1icUb.js +2 -0
- package/web/assets/{distortGL-QalhICvi.js → distortGL-BA5molk-.js} +3 -3
- package/web/assets/draco_decoder-C32yEggz.wasm +0 -0
- package/web/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
- package/web/assets/draco_decoder-fzg4nYZr.js +34 -0
- package/web/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
- package/web/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
- package/web/assets/editTools-NKLsWZD1.js +1 -0
- package/web/assets/{engine-BedcnK45.js → engine-DioUF2mX.js} +1 -1
- package/web/assets/exportGlb-BOdI9cVS.js +2 -0
- package/web/assets/faceTracker-D7CbF-qX.js +1 -0
- package/web/assets/fightDirector-CYP8jxo8.js +1 -0
- package/web/assets/fightDrama-DIPcRKnc.js +2 -0
- package/web/assets/focusTool-vfabPqQ5.js +1 -0
- package/web/assets/{frameSink-DeM8xC8_.js → frameSink-DYs2gTzq.js} +3 -3
- package/web/assets/glTransitionSources.generated-DM5sRMX2.js +3695 -0
- package/web/assets/gltfLoader-U0Eebg7v.js +2 -0
- package/web/assets/{gpuCompose-CA3UmOl4.js → gpuCompose-DbnZuelB.js} +1 -1
- package/web/assets/gpuExport-CQ7ZhpsX.js +198 -0
- package/web/assets/handMatte-DIbMuqCu.js +1 -0
- package/web/assets/handTracker-DY_g5Xmg.js +2 -0
- package/web/assets/i18n-BJppIrtF.js +3 -0
- package/web/assets/index-BfrDwjDI.js +4247 -0
- package/web/assets/index-CKtv7gGE.js +9 -0
- package/web/assets/{index-D5oyVCRl.js → index-DxdDhmLR.js} +2 -2
- package/web/assets/layer-worker-DK67WH1a.js +5 -0
- package/web/assets/library-B6KsZUKq.js +1 -0
- package/web/assets/lottieLayer-C2YbiXhK.js +161 -0
- package/web/assets/{lottie_light_canvas-B-d7-ATe.js → lottie_light_canvas-DX9Wf-DS.js} +1 -1
- package/web/assets/main-B27kf5aL.css +1 -0
- package/web/assets/main-BKatDoGw.js +309 -0
- package/web/assets/mapBake-C-G7WpFM.js +1 -0
- package/web/assets/maskTrack-LMrwm5ub.js +1 -0
- package/web/assets/matteFixRun-B38CbeEt.js +1 -0
- package/web/assets/matteQuality-9X-jgJrH.js +1 -0
- package/web/assets/objectLocate-CKi3OTnL.js +1 -0
- package/web/assets/objectSegmenter-CziPuM61.js +1 -0
- package/web/assets/{objectTrack.worker-BlZkgpOX.js → objectTrack.worker-b7DJ-ub6.js} +196 -196
- package/web/assets/pathTracer-bqau16sX.js +2 -0
- package/web/assets/pendingMatte-CQb7jPg1.js +2 -0
- package/web/assets/personAi-CQntGDqK.js +2 -0
- package/web/assets/personHq-B1c0QVJT.js +2 -0
- package/web/assets/plateCamera-D7iLiNBy.js +1 -0
- package/web/assets/plateCameraMatch-BM88dx-a.js +2 -0
- package/web/assets/plateFollow-4iGUDTu1.js +2 -0
- package/web/assets/plateMatte-zTyuHHqh.js +2 -0
- package/web/assets/plugin-guide.en-DO_fHbzT.js +1 -0
- package/web/assets/plugin-guide.vi-CMJDxOhi.js +1 -0
- package/web/assets/pluginAutomation-DSg-sYLF.js +1 -0
- package/web/assets/poseTracker-DZl8l2qS.js +1 -0
- package/web/assets/productTools-B-jh8ukh.js +2 -0
- package/web/assets/remote-DJd9xWjn.js +963 -0
- package/web/assets/{rigTrack-urT3nDK0.js → rigTrack-XaMj1yaH.js} +1 -1
- package/web/assets/rotoMaskStore-DdpmT9C3.js +1 -0
- package/web/assets/{rotoMatte-C-2o3vv0.js → rotoMatte-i-cJTYmK.js} +1 -1
- package/web/assets/rotoscope-DqRSWmHR.js +1 -0
- package/web/assets/sceneTrack-Bbov7zET.js +1 -0
- package/web/assets/sceneTrack-DIPzBmMK.js +1 -0
- package/web/assets/{sceneTrack.worker-CT4uoTKn.js → sceneTrack.worker-Bav9h0pv.js} +180 -180
- package/web/assets/shot-worker-m-q77W9f.js +1 -0
- package/web/assets/{shotFxAgent-BFLkqs8v.js → shotFxAgent-DIMS7BGA.js} +2 -2
- package/web/assets/{skin-DY4QLaBI.js → skin-DrUzJE1u.js} +1 -1
- package/web/assets/{spark.module-DzziUgOj.js → spark.module-Y1SEI8Xz.js} +10 -10
- package/web/assets/spellDuel-DNnyQDVr.js +2 -0
- package/web/assets/store-GFMJzaWS.js +1 -0
- package/web/assets/surfaceLight-C--moyc9.js +1 -0
- package/web/assets/surfacePin-B4-1UqXD.js +2 -0
- package/web/assets/{textAnimators-DUZjhVGO.js → textAnimators-BVXTl8bU.js} +1 -1
- package/web/assets/{thumb-CS0ZuiGS.js → thumb-CTfDJgLp.js} +1 -1
- package/web/assets/timeline3d-Dn7PqmEe.js +2 -0
- package/web/assets/timeline3dExport-DCOr6ARB.js +1 -0
- package/web/assets/timelineComp-Dx_kED5V.js +1 -0
- package/web/assets/timelineOps-afzSo188.js +525 -0
- package/web/assets/timelineProps-eYgO6gs5.js +1 -0
- package/web/assets/timelineText-RKyRP988.js +1 -0
- package/web/assets/{titleArt-Drsrtfiv.js → titleArt-CUtA0C3I.js} +4 -4
- package/web/assets/{titleFrameBudget-CLZWaFHO.js → titleFrameBudget-X7HLSDre.js} +721 -704
- package/web/assets/titleFrames-aMG7HdVe.js +1 -0
- package/web/assets/{tool-DktQYmS6.js → tool-DpFjybaq.js} +1 -1
- package/web/assets/{tools-Co9aRDiT.js → tools-CeOU0p13.js} +1 -1
- package/web/assets/toonTools-DLmo37Z_.js +2 -0
- package/web/assets/trackAnchor-hAOtEhKO.js +1 -0
- package/web/assets/userFonts-1kuRjWOo.js +1 -0
- package/web/assets/{vfxAlpha-71tSN86T.js → vfxAlpha-DxS5-QwY.js} +2 -2
- package/web/assets/vfxBackground-CYpaQaTa.js +2 -0
- package/web/assets/videoExport-Cg4B2Nyh.js +1 -0
- package/web/assets/views-CUXyRb9x.js +1 -0
- package/web/assets/weaponDuel-nFECu9nk.js +1 -0
- package/web/assets/windowFrames-1wAkkWnv.js +1 -0
- package/web/layer-worker.html +3 -3
- package/web/shot-worker.html +41 -0
- package/web/assets/FxEmbed-BCmj9Q5C.js +0 -1
- package/web/assets/GLTFLoader-BHWu1lKg.js +0 -1
- package/web/assets/MotionEmbed-CEmbcq8Z.js +0 -1
- package/web/assets/PluginStore-C5hyahvG.js +0 -3
- package/web/assets/ShotComposer-0DUtMTVI.js +0 -287
- package/web/assets/TemplateEmbed-ANxSs7H5.js +0 -2
- package/web/assets/TimelineShotFx-q5PQwq-V.js +0 -2
- package/web/assets/TransitionEmbed-O6LInGWq.js +0 -1
- package/web/assets/aerial-CGLDKKtP.js +0 -2
- package/web/assets/agentTools-2Ghb80VH.js +0 -2
- package/web/assets/analyzerRun-DRgxrcJA.js +0 -1
- package/web/assets/analyzerSandbox-DuIVFnsk.js +0 -33
- package/web/assets/api-CJ8PdbfZ.js +0 -3168
- package/web/assets/auraTrack-DQw9sVU6.js +0 -1
- package/web/assets/breakthrough-BNj_iTDr.js +0 -2
- package/web/assets/captionLayout-DvDPTwO9.js +0 -1
- package/web/assets/clientExport-xhoXY6Dh.js +0 -1
- package/web/assets/depthEstimate-DEpeCojm.js +0 -1
- package/web/assets/directorTools-C5CpTmci.js +0 -1
- package/web/assets/distortFrames-Dia8O1NM.js +0 -2
- package/web/assets/editTools-CY_JrQfw.js +0 -1
- package/web/assets/exportEncode-QYsT9JBO.js +0 -1
- package/web/assets/exportGlb-TSj09XoV.js +0 -2
- package/web/assets/faceTracker-CnCWOwnJ.js +0 -1
- package/web/assets/fightDirector-DCI_FWTh.js +0 -1
- package/web/assets/fightDrama-Bg7uP_2Q.js +0 -2
- package/web/assets/gpuExport-D31azOQA.js +0 -198
- package/web/assets/handMatte-Dl-xVXFR.js +0 -1
- package/web/assets/handTracker-CplBsAFg.js +0 -2
- package/web/assets/layer-worker-DFuo32bk.js +0 -5
- package/web/assets/library-BufgA-Pl.js +0 -1
- package/web/assets/lottieLayer-DzbA3bHV.js +0 -158
- package/web/assets/main-Ca_CVxMz.css +0 -1
- package/web/assets/main-VVYiW8XD.js +0 -309
- package/web/assets/mapBake-BKOcEd0w.js +0 -1
- package/web/assets/maskTrack-CHGXtBRy.js +0 -1
- package/web/assets/matteFixRun-vgYrINet.js +0 -1
- package/web/assets/objectLocate-BJltm8Ob.js +0 -1
- package/web/assets/pendingMatte-BPyzzx4y.js +0 -2
- package/web/assets/personAi-gJu03SjU.js +0 -2
- package/web/assets/plateCamera-B2JvhjJw.js +0 -1
- package/web/assets/plateCameraMatch-ByB9nVQT.js +0 -2
- package/web/assets/plateFollow-C9S-l7RH.js +0 -2
- package/web/assets/plateMatte-J4qlNHnY.js +0 -2
- package/web/assets/plugin-guide.en-CGYh_9Su.js +0 -1
- package/web/assets/plugin-guide.vi-DMphSELb.js +0 -1
- package/web/assets/pluginAutomation-CkP3tA9r.js +0 -1
- package/web/assets/poseTracker-DGLbouqt.js +0 -1
- package/web/assets/productTools-CkaWF1bM.js +0 -2
- package/web/assets/remote-C7J0Tqhb.js +0 -1433
- package/web/assets/rotoMaskStore-DPziPKAN.js +0 -1
- package/web/assets/rotoscope-GvPFRUBg.js +0 -1
- package/web/assets/shot-worker-6dYkHPoL.js +0 -1
- package/web/assets/spellDuel-BD3m2ebA.js +0 -2
- package/web/assets/store-DW4E9xnW.js +0 -1
- package/web/assets/surfaceLight-aDSYU8Jg.js +0 -1
- package/web/assets/surfacePin-m83hCgGP.js +0 -2
- package/web/assets/timeline3d-DOw-CpZI.js +0 -2
- package/web/assets/timeline3dExport-BtYLU1pw.js +0 -1
- package/web/assets/timelineComp-B4GtoH2f.js +0 -1
- package/web/assets/timelineProps-D7MVutxu.js +0 -1
- package/web/assets/timelineText-BH09jfSM.js +0 -1
- package/web/assets/titleFrames-BI1DnLBn.js +0 -1
- package/web/assets/toonTools-CD9clJvN.js +0 -2
- package/web/assets/trackAnchor-sOjTtd3I.js +0 -1
- package/web/assets/userFonts-CwlKh9NR.js +0 -1
- package/web/assets/vfxBackground-Bq7lJvmZ.js +0 -2
- package/web/assets/videoExport-D4KbireJ.js +0 -1
- package/web/assets/views-ozVF4ABO.js +0 -1
- package/web/assets/weaponDuel-ZhX-tjGZ.js +0 -1
- package/web/assets/windowFrames-CpqX3kOM.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./titleFrameBudget-X7HLSDre.js";import{R as N}from"./index-CKtv7gGE.js";import{W as _,X as I,n as T,Y as L,c as C,V as j,Z as k}from"./remote-DJd9xWjn.js";import A from"./ShotComposer-Cng515xa.js";import{u as F}from"./store-GFMJzaWS.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./tool-DpFjybaq.js";import"./timelineProps-eYgO6gs5.js";import"./thumb-CTfDJgLp.js";import"./shotFxAgent-DIMS7BGA.js";import"./cameraPresets-eK3mP7qb.js";import"./weaponDuel-nFECu9nk.js";import"./skin-DrUzJE1u.js";import"./views-CUXyRb9x.js";import"./motionBlur-uAm030t9.js";import"./library-B6KsZUKq.js";globalThis.__CLIPOOX_THUMB_LIMIT=0;const M="shot-worker";let R=null,m=null,U=0;const b=(t,e)=>window.shotWorkerRpc?window.shotWorkerRpc(t,e):Promise.reject(new Error("no account bridge")),W=t=>({...t,saveSet:(e,r,a)=>b("saveSet",{id:e,name:r,recipe:a}),loadSet:async e=>await b("loadSet",{id:e}),listLibrary:async()=>await b("listLibrary",{}),uploadFile:async()=>{throw new Error("uploads are not available to the 3D Shot worker")}}),B=async(t,e,r)=>{const a=Date.now()+e;for(;!t();){if(Date.now()>a)throw new Error(`${r} timed out`);await new Promise(o=>setTimeout(o,50))}},u=()=>{const t=k();if(!t)throw new Error("no scene open");return t},O={async open(t,e,r={}){t||(t=T(),t.items=[]),L(r.regionClips===!0),F.setState({user:{uid:e},saveState:"saved"}),m={id:M,type:"placeholder",position:{x:0,y:0},data:{tool:"3d-shot",label:"3D Shot",shotScene:t}},C.current={nodes:()=>m?[m]:[],getNode:o=>o===M?m:void 0,addNode:()=>"",updateNodeData:(o,i)=>{m&&o===M&&(m.data={...m.data,...i})}};const a=k();return R??=j.createRoot(document.getElementById("root")),R.render(N.createElement(A,{key:++U,nodeId:M,headless:!0})),await B(()=>{const o=k();return!!o&&o!==a&&!!o.engine()},6e4,"opening the scene"),{ok:!0}},async run(t){const e=[];for(const r of t){let a;try{a=await _(r.tool,r.args||{},W(u()))}catch(h){a={ok:!1,error:String(h?.message||h).slice(0,500)}}const{_image:o,...i}=a;if(e.push({tool:r.tool,ok:a.ok!==!1,result:I(i),...typeof o=="string"?{image:o}:{}}),a.ok===!1)break}return e},stage:()=>u().getStage(),async frames(t){const e=u(),r=e.engine(),a=e.getStage(),o=a.shots.find(n=>n.id===a.activeShot);if(!r||!o)throw new Error("renderer not ready");const i=(t.times||[]).slice(0,720).map(n=>Math.max(0,Math.min(o.duration,Number(n)||0)));r.sync(a,null);const h=[];let c=0,g=0;return await r.renderFrames(o,i,Math.max(240,Math.min(1080,Number(t.height)||720)),t.quality==="draft"?"draft":"high",n=>{c=n.width,g=n.height,h.push(n.toDataURL("image/jpeg",.92))}),{width:c,height:g,duration:o.duration,frames:h}},shotInfo(){const t=u().getStage(),e=t.shots.find(r=>r.id===t.activeShot);return{duration:e?.duration??0,aspect:e?.aspect??"16:9",name:e?.name??"Shot"}},async clip(t={}){const e=u(),r=e.engine(),a=e.getStage(),o=a.shots.find(l=>l.id===a.activeShot);if(!r||!o)throw new Error("renderer not ready");const i=Math.max(2,Math.min(12,Number(t.fps)||8)),h=Math.max(.25,Math.min(4,Number(t.seconds)||2)),c=Math.max(0,Math.min(o.duration,Number(t.from)||0)),g=Math.max(1,Math.min(48,Math.round(h*i))),n=Array.from({length:g},(l,p)=>Math.min(o.duration,c+p/i));r.sync(a,null);const d=await r.renderFrames(o,n,Math.max(180,Math.min(480,Number(t.height)||270)),t.quality==="high"?"high":"draft");if(!t.sheet)return{fps:i,from:c,times:n,frames:d.map(l=>l.toDataURL("image/jpeg",.7))};const f=Math.min(4,d.length),D=Math.ceil(d.length/f),v=d[0].width,w=d[0].height,y=document.createElement("canvas");y.width=f*v,y.height=D*w;const s=y.getContext("2d");return s.font=`${Math.max(12,Math.round(w/14))}px sans-serif`,s.textBaseline="top",d.forEach((l,p)=>{const S=p%f*v,x=Math.floor(p/f)*w;s.drawImage(l,S,x);const E=`${n[p].toFixed(2)} s`;s.fillStyle="rgba(0,0,0,0.55)",s.fillRect(S+4,x+4,s.measureText(E).width+8,Math.round(w/14)+6),s.fillStyle="#fff",s.fillText(E,S+8,x+7)}),{fps:i,from:c,times:n,sheet:y.toDataURL("image/jpeg",.72)}}};window.__shotWorker=O;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{fJ as B,ie as T,ev as Q,fN as N,eN as z,fi as H,fO as U,fP as X,eB as Y,fR as C,eL as v,fT as Z,ex as O,ig as V,ih as g,eu as tt,eq as ot,ii as et,dB as nt,ij as it,ik as rt}from"./remote-C7J0Tqhb.js";const D=Math.PI/180,G=t=>[Math.sin(t*D),0,Math.cos(t*D)],_=t=>t.map(o=>+o.toFixed(2)),S=t=>t.kind==="person";function I(t,o){const e=t.filter(i=>S(i)&&!i.hidden&&i.id!==o.id);if(!e.length)return null;const r=G(o.rotation?.[1]??0),n=i=>Math.hypot(i.position[0]-o.position[0],i.position[2]-o.position[2]),l=e.filter(i=>(i.position[0]-o.position[0])*r[0]+(i.position[2]-o.position[2])*r[2]>0);return(l.length?l:e).sort((i,s)=>n(i)-n(s))[0]}function q(t,{items:o=[],selected:e=null,ground:r=[0,0,0],reach:n=8,anchor:l=null}={}){const i=(u,c)=>l?.(u,c)??N(u,c),s=e&&e.kind!=="fx"&&!e.hidden?e:null,f=s&&S(s)?s:null;let m=[...r],d=[0,0,0],a,p;if(t.wantsTarget&&s&&!S(s))return{position:[...s.position],rotation:d,attach:{to:s.id,offset:[0,0,0]},target:{to:s.id,part:"center"}};if(t.attach==="gun"&&f){const u=I(o,f);return{position:[...f.position],rotation:d,attach:{to:f.id,hand:"R",tip:!0},...u?{target:{to:u.id,part:"chest"}}:{}}}switch(t.attach){case"hand":f?(a={to:f.id,hand:"R"},m=[...f.position]):m=[r[0],1.2,r[2]];break;case"body":case"ground":s&&(a={to:s.id,offset:[0,0,0]},m=[...s.position]);break;case"path":case"sky":case"gun":{const u=f?I(o,f):null;let c,x;if(f){c=i(f,t.attach==="sky"?"head":"hand_right");const b=G(f.rotation?.[1]??0);x=u?i(u,"chest"):[c[0]+b[0]*n,Math.max(.6,c[1]-.2),c[2]+b[2]*n]}else s?(c=i(s,"chest"),x=[c[0]+n,c[1],c[2]]):(c=[r[0]-n/2,1.2,r[2]],x=[r[0]+n/2,1,r[2]]);t.attach==="sky"&&(c=[x[0],x[1]+8,x[2]]),p=[_(c),_(x)],m=_(t.attach==="sky"?x:c);break}default:m=[r[0],t.attach==="free"?1.2:0,r[2]]}return{position:m,rotation:d,...a?{attach:a}:{},...p?{path:p}:{}}}const at=[...T.map(t=>t.id),...g.filter(t=>!tt[t].internal&&!T.some(o=>o.id===t))];T.map(t=>`${t.id} (${t.preset}${t.attach==="path"?", needs from/to":t.attach==="sky"?', strikes the "to" point from above':""}: ${t.desc})`).join("; ");const P=/^(.*?)(?:\.(feet|chest|head|hand_right|hand_left|center))?$/,A=t=>P.exec(String(t??"").trim())?.[1]?.trim()??"",F=t=>Array.isArray(t)&&t.length===3&&t.every(o=>typeof o=="number"&&Number.isFinite(o)&&Math.abs(o)<=1e3),J=t=>typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t),y=(t,o)=>{const e=String(o??"").trim().toLowerCase();return t.find(r=>r.id===o||r.name===o)??t.find(r=>r.name.toLowerCase()===e)};function st(t,o,e){const r=[];if(t.from!=null&&r.push(t.from),Array.isArray(t.via)&&r.push(...t.via),t.to!=null&&r.push(t.to),!r.length)return null;if(r.length<2)throw new Error("give both from and to for a flight path (or neither)");return V(r,{find:n=>y(o.items.filter(l=>l.kind!=="fx"),n),at:n=>o.at(n,e),anchor:o.anchor?(n,l)=>o.anchor(n,l,e):void 0})}function ut(t,o){try{const e=B(t.effect)??T.find(h=>h.preset===t.effect);if(!e)throw new Error(`unknown effect '${String(t.effect)}'; use one of ${at.join(", ")}`);const r=o.shot.duration,n=t.start==null?0:Number(t.start);if(!Number.isFinite(n)||n<0||n>=r)throw new Error(`start must be 0..${r} s (the shot is ${r} s long)`);const l=q(e,{items:o.items,selected:t.attach_to?y(o.items,t.attach_to)??null:null,ground:[0,0,0]}),i={preset:e.preset,cat:e.id,intensity:t.intensity??1,seed:t.seed??Math.abs(W(`${t.name??e.id}${n}`))%1e9+1,start:n,duration:t.duration??(e.fill?Math.max(e.duration,r-n):e.duration),loop:t.loop===!0,params:{...Q(e.preset),...e.params||{},...t.params&&typeof t.params=="object"?t.params:{}}};if(t.attach_to!=null){const h=y(o.items.filter(M=>M.kind!=="fx"),t.attach_to);if(!h)throw new Error(`unknown object '${t.attach_to}' to attach to`);const w=t.hand==="right"?"R":t.hand==="left"?"L":void 0;if(t.hand&&t.hand!=="none"&&!w)throw new Error("hand must be 'right', 'left' or 'none'");if(w&&!S(h))throw new Error(`'${h.name}' is not a person: hands exist only on mannequins`);i.attach={to:h.id,...w?{hand:w}:{},...F(t.offset)?{offset:t.offset}:{}},e.attach==="gun"&&S(h)?(i.attach.hand??="R",i.attach.tip=t.tip!==!1):t.tip===!0&&i.attach.hand&&(i.attach.tip=!0)}const s=typeof t.to=="string"?t.to:null,f=s?y(o.items.filter(h=>h.kind!=="fx"),A(s)):null;if(e.wantsTarget){const h=f??(t.attach_to?y(o.items.filter(w=>w.kind!=="fx"),t.attach_to):null);if(h)i.target={to:h.id,part:"center",...t.target_part?{name:String(t.target_part).slice(0,60)}:{}};else if(s)throw new Error(`unknown object '${s}' for to`)}else if(f)i.target={to:f.id,part:P.exec(s)?.[2]??"chest"};else if(s&&!e.wantsTarget)throw new Error(`unknown object '${s}' for to`);const m=t.from!=null?st(t,o,n):null;if(m)i.path=m;else if(e.attach==="gun"&&i.attach?.tip){if(!i.target){const h=I(o.items,o.items.find(w=>w.id===i.attach.to));h&&(i.target={to:h.id,part:"chest"})}}else if(!(t.from==null&&t.to!=null&&!(e.attach==="path"||e.attach==="sky"))){if(e.attach==="path"||e.attach==="sky"){const h=i.attach?o.items.find(E=>E.id===i.attach.to):null;if(!h||!S(h))throw new Error(`${e.id} flies between two points: give from and to (an object name, "Name.hand_right", "Name.chest", or [x, y, z]) or attach_to a person`);const w=o.at(h,n),M=q(e,{items:o.items.map(E=>E.id===h.id?{...E,position:w.position??E.position,rotation:w.rotation??E.rotation}:E),selected:{...h,position:w.position??h.position,rotation:w.rotation??h.rotation},anchor:o.anchor?(E,R)=>o.anchor(E,R,n):null});i.path=M.path,f&&(i.path=[M.path[0],_(N(f,i.target.part,o.at(f,n)))])}}const d=z(i,{strict:!0});if(!d.ok)throw new Error(d.errors.join("; "));const a=J(t.color)?t.color:e.color,p=t.size==null?1:Number(t.size);if(!Number.isFinite(p)||p<.1||p>6)throw new Error("size must be 0.1..6");let u=t.at==null?i.path?e.attach==="sky"?i.path[1]:i.path[0]:F(t.to)&&t.from==null?t.to:f&&!i.attach?_(N(f,"feet",o.at(f,n))):l.position:null;if(t.at!=null)if(F(t.at))u=t.at;else{const h=y(o.items.filter(w=>w.kind!=="fx"),A(t.at));if(!h)throw new Error(`unknown object '${String(t.at)}' for at`);u=N(h,P.exec(String(t.at))?.[2]??"feet",o.at(h,n))}const c=ft(o.items,String(t.name||e.name).slice(0,60)),x={id:o.uid(),name:c,kind:"fx",position:_(u),rotation:[0,Number(t.yaw_deg)||0,0],scale:[p,p,p],color:a,hidden:!1,locked:!1,pose:o.restPose??{},reference:null,fx:d.fx},b=H(o.items,d.fx);if(!b.ok)throw new Error(b.errors.join("; "));const $=U({start:n,duration:d.fx.duration,...d.fx.loop?{loop:!0}:{}},r);return x.fx={...d.fx,start:$.start??n,duration:$.duration??d.fx.duration},{ok:!0,item:x,timing:{start:$.start??n,duration:$.duration??d.fx.duration,...d.fx.loop?{loop:!0}:{}}}}catch(e){return{ok:!1,error:e.message||String(e)}}}const W=t=>{let o=0;for(let e=0;e<t.length;e++)o=Math.imul(o,31)+t.charCodeAt(e)|0;return o},ft=(t,o)=>{let e=o,r=2;for(;t.some(n=>n.name===e);)e=`${o} ${r++}`;return e};function pt(t,o,e){try{const r={...t.fx},n={},i={...e.timing??{start:r.start,duration:r.duration,loop:r.loop}};if(o.start!=null&&(i.start=Number(o.start),!(i.start>=0&&i.start<e.shot.duration)))throw new Error(`start must be 0..${e.shot.duration} s`);if(o.duration!=null&&(i.duration=Number(o.duration)),o.loop!=null&&(i.loop=o.loop===!0),o.color!=null){if(!J(o.color))throw new Error("color must be a CSS hex like #7fe9ff");n.color=o.color}if(o.intensity!=null&&(r.intensity=o.intensity),o.seed!=null&&(r.seed=o.seed),o.params&&typeof o.params=="object"&&(r.params={...r.params,...o.params}),o.size!=null){const a=Number(o.size);if(!(a>=.1&&a<=6))throw new Error("size must be 0.1..6");n.scale=[a,a,a]}o.yaw_deg!=null&&(n.rotation=[t.rotation[0],Number(o.yaw_deg)||0,t.rotation[2]]);const s=e.items.filter(a=>a.kind!=="fx"&&a.id!==t.id);if(o.attach_to!=null)if(o.attach_to==="none")delete r.attach;else{const a=y(s,o.attach_to);if(!a)throw new Error(`unknown object '${o.attach_to}' to attach to`);const p=o.hand==="right"?"R":o.hand==="left"?"L":void 0;if(p&&!S(a))throw new Error(`'${a.name}' is not a person`);r.attach={to:a.id,...p?{hand:p}:{},...F(o.offset)?{offset:o.offset}:{}}}else if(o.hand!=null&&r.attach){const a=o.hand==="right"?"R":o.hand==="left"?"L":void 0;r.attach={...r.attach,hand:a},a||delete r.attach.hand}if(o.at!=null)if(F(o.at))n.position=o.at;else{const a=y(s,A(o.at));if(!a)throw new Error(`unknown object '${String(o.at)}' for at`);n.position=_(N(a,P.exec(String(o.at))?.[2]??"feet",e.at(a,i.start)))}if(o.from!=null||o.to!=null||o.via!=null){const a=r.path??[],p=[o.from??a[0],...Array.isArray(o.via)?o.via:a.slice(1,-1),o.to??a.at(-1)];if(p.some(u=>u==null))throw new Error("give both from and to the first time you set a path");r.path=V(p,{find:u=>y(s,u),at:u=>e.at(u,i.start),anchor:e.anchor?(u,c)=>e.anchor(u,c,i.start):void 0})}if(typeof o.to=="string"){const a=y(s,A(o.to));a&&(r.target={to:a.id,part:P.exec(o.to)?.[2]??"chest"})}o.clear_path===!0&&delete r.path;const f=z({...r,start:i.start,duration:i.duration,loop:i.loop},{strict:!0});if(!f.ok)throw new Error(f.errors.join("; "));const m=H(e.items.filter(a=>a.id!==t.id),f.fx);if(!m.ok)throw new Error(m.errors.join("; "));const d=U(i,e.shot.duration);return{ok:!0,itemPatch:n,fx:{...f.fx,start:d.start??i.start,duration:d.duration??i.duration},timing:{...d,start:d.start??i.start,duration:d.duration??i.duration}}}catch(r){return{ok:!1,error:r.message||String(r)}}}function lt(t){const[o,e,r]=it(rt(t)),n=o*360;return r>.88||e<.12?r<.3?"dark grey":"white":r<.2?"dark":n<15||n>=345?"red":n<40?"orange":n<62?"golden":n<95?"lime green":n<160?"green":n<195?"cyan":n<225?"sky blue":n<255?"blue":n<285?"purple":n<330?"magenta":"pink"}function mt(t,o){const e=n=>{let l=null,i=2;for(const s of t){if(s.kind==="fx"||s.hidden)continue;const f=nt.dist(N(s,"chest"),n);f<i&&(i=f,l=s)}return l?.name},r=[];for(const n of t){if(n.kind!=="fx"||!n.fx||n.hidden)continue;const l=ot(n,o);if(l.off)continue;if(n.fx.preset===v){const a=n.fx.target&&t.find(p=>p.id===n.fx.target.to);a&&r.push(et(n,a.name,l));continue}const i=B(n.fx.cat)??T.find(a=>a.preset===n.fx.preset);if(!i)continue;const s=n.fx.attach?t.find(a=>a.id===n.fx.attach.to):null,f=n.fx.path?e(n.fx.path[0]):null,m=n.fx.path?e(n.fx.path.at(-1)):null,d=f&&m&&f!==m?` from ${f} to ${m}`:n.fx.path&&m?` toward ${m}`:s?` on ${s.name}${n.fx.attach.hand?`'s ${n.fx.attach.hand==="R"?"right":"left"} hand`:""}`:"";r.push(`${i.prompt} (${lt(n.color)} tint)${d}, from ${l.start.toFixed(1)}s to ${(l.start+l.duration).toFixed(1)}s`)}return r.length?`VISUAL EFFECTS
|
|
2
|
-
The previs shows each effect as glowing placeholder light. Recreate them as real, high-quality cinematic VFX with the same colour, timing, size and path (never render text or UI): ${r.slice(0,12).join("; ")}.`:""}const ht=["model","proxy","box","wall","platform","floor","sphere","cylinder","set","prop"];function dt(t){const o=t.scale??[1,1,1];if(t.kind==="proxy"&&t.proxy?.dims)return t.proxy.dims.map((e,r)=>e*o[r]);if(t.kind==="model"){const e=(t.model?.height??2)*o[1];return[e*.6,e,e*.6]}return[...o]}function wt(t,o){try{const e=y(o.items.filter(
|
|
1
|
+
import{cb as q,eP as T,aZ as Z,cf as j,bf as z,bM as H,cg as V,ch as C,b3 as J,cj as L,bd as A,cl as K,a$ as D,eQ as G,eR as g,aY as tt,aU as ot,eS as et,a2 as nt,eT as it,eU as rt}from"./remote-DJd9xWjn.js";const O=Math.PI/180,B=t=>[Math.sin(t*O),0,Math.cos(t*O)],_=t=>t.map(o=>+o.toFixed(2)),S=t=>t.kind==="person";function I(t,o){const e=t.filter(i=>S(i)&&!i.hidden&&i.id!==o.id);if(!e.length)return null;const r=B(o.rotation?.[1]??0),n=i=>Math.hypot(i.position[0]-o.position[0],i.position[2]-o.position[2]),l=e.filter(i=>(i.position[0]-o.position[0])*r[0]+(i.position[2]-o.position[2])*r[2]>0);return(l.length?l:e).sort((i,s)=>n(i)-n(s))[0]}function U(t,{items:o=[],selected:e=null,ground:r=[0,0,0],reach:n=8,anchor:l=null}={}){const i=(u,c)=>l?.(u,c)??j(u,c),s=e&&e.kind!=="fx"&&!e.hidden?e:null,f=s&&S(s)?s:null;let m=[...r],d=[0,0,0],a,p;if(t.wantsTarget&&s&&!S(s))return{position:[...s.position],rotation:d,attach:{to:s.id,offset:[0,0,0]},target:{to:s.id,part:"center"}};if(t.attach==="gun"&&f){const u=I(o,f);return{position:[...f.position],rotation:d,attach:{to:f.id,hand:"R",tip:!0},...u?{target:{to:u.id,part:"chest"}}:{}}}switch(t.attach){case"hand":f?(a={to:f.id,hand:"R"},m=[...f.position]):m=[r[0],1.2,r[2]];break;case"body":case"ground":s&&(a={to:s.id,offset:[0,0,0]},m=[...s.position]);break;case"path":case"sky":case"gun":{const u=f?I(o,f):null;let c,k;if(f){c=i(f,t.attach==="sky"?"head":"hand_right");const x=B(f.rotation?.[1]??0);k=u?i(u,"chest"):[c[0]+x[0]*n,Math.max(.6,c[1]-.2),c[2]+x[2]*n]}else s?(c=i(s,"chest"),k=[c[0]+n,c[1],c[2]]):(c=[r[0]-n/2,1.2,r[2]],k=[r[0]+n/2,1,r[2]]);t.attach==="sky"&&(c=[k[0],k[1]+8,k[2]]),p=[_(c),_(k)],m=_(t.attach==="sky"?k:c);break}default:m=[r[0],t.attach==="free"?1.2:0,r[2]]}return{position:m,rotation:d,...a?{attach:a}:{},...p?{path:p}:{}}}const at=[...T.map(t=>t.id),...g.filter(t=>!tt[t].internal&&!T.some(o=>o.id===t))];T.map(t=>`${t.id} (${t.preset}${t.attach==="path"?", needs from/to":t.attach==="sky"?', strikes the "to" point from above':""}: ${t.desc})`).join("; ");const P=/^(.*?)(?:\.(feet|chest|head|hand_right|hand_left|center))?$/,v=t=>P.exec(String(t??"").trim())?.[1]?.trim()??"",F=t=>Array.isArray(t)&&t.length===3&&t.every(o=>typeof o=="number"&&Number.isFinite(o)&&Math.abs(o)<=1e3),Q=t=>typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t),y=(t,o)=>{const e=String(o??"").trim().toLowerCase();return t.find(r=>r.id===o||r.name===o)??t.find(r=>r.name.toLowerCase()===e)};function st(t,o,e){const r=[];if(t.from!=null&&r.push(t.from),Array.isArray(t.via)&&r.push(...t.via),t.to!=null&&r.push(t.to),!r.length)return null;if(r.length<2)throw new Error("give both from and to for a flight path (or neither)");return G(r,{find:n=>y(o.items.filter(l=>l.kind!=="fx"),n),at:n=>o.at(n,e),anchor:o.anchor?(n,l)=>o.anchor(n,l,e):void 0})}function ut(t,o){try{const e=q(t.effect)??T.find(h=>h.preset===t.effect);if(!e)throw new Error(`unknown effect '${String(t.effect)}'; use one of ${at.join(", ")}`);const r=o.shot.duration,n=t.start==null?0:Number(t.start);if(!Number.isFinite(n)||n<0||n>=r)throw new Error(`start must be 0..${r} s (the shot is ${r} s long)`);const l=U(e,{items:o.items,selected:t.attach_to?y(o.items,t.attach_to)??null:null,ground:[0,0,0]}),i={preset:e.preset,cat:e.id,intensity:t.intensity??1,seed:t.seed??Math.abs(W(`${t.name??e.id}${n}`))%1e9+1,start:n,duration:t.duration??(e.fill?Math.max(e.duration,r-n):e.duration),loop:t.loop===!0,params:{...Z(e.preset),...e.params||{},...t.params&&typeof t.params=="object"?t.params:{}}};if(t.attach_to!=null){const h=y(o.items.filter(M=>M.kind!=="fx"),t.attach_to);if(!h)throw new Error(`unknown object '${t.attach_to}' to attach to`);const w=t.hand==="right"?"R":t.hand==="left"?"L":void 0;if(t.hand&&t.hand!=="none"&&!w)throw new Error("hand must be 'right', 'left' or 'none'");if(w&&!S(h))throw new Error(`'${h.name}' is not a person: hands exist only on mannequins`);i.attach={to:h.id,...w?{hand:w}:{},...F(t.offset)?{offset:t.offset}:{}},e.attach==="gun"&&S(h)?(i.attach.hand??="R",i.attach.tip=t.tip!==!1):t.tip===!0&&i.attach.hand&&(i.attach.tip=!0)}const s=typeof t.to=="string"?t.to:null,f=s?y(o.items.filter(h=>h.kind!=="fx"),v(s)):null;if(e.wantsTarget){const h=f??(t.attach_to?y(o.items.filter(w=>w.kind!=="fx"),t.attach_to):null);if(h)i.target={to:h.id,part:"center",...t.target_part?{name:String(t.target_part).slice(0,60)}:{}};else if(s)throw new Error(`unknown object '${s}' for to`)}else if(f)i.target={to:f.id,part:P.exec(s)?.[2]??"chest"};else if(s&&!e.wantsTarget)throw new Error(`unknown object '${s}' for to`);const m=t.from!=null?st(t,o,n):null;if(m)i.path=m;else if(e.attach==="gun"&&i.attach?.tip){if(!i.target){const h=I(o.items,o.items.find(w=>w.id===i.attach.to));h&&(i.target={to:h.id,part:"chest"})}}else if(!(t.from==null&&t.to!=null&&!(e.attach==="path"||e.attach==="sky"))){if(e.attach==="path"||e.attach==="sky"){const h=i.attach?o.items.find(E=>E.id===i.attach.to):null;if(!h||!S(h))throw new Error(`${e.id} flies between two points: give from and to (an object name, "Name.hand_right", "Name.chest", or [x, y, z]) or attach_to a person`);const w=o.at(h,n),M=U(e,{items:o.items.map(E=>E.id===h.id?{...E,position:w.position??E.position,rotation:w.rotation??E.rotation}:E),selected:{...h,position:w.position??h.position,rotation:w.rotation??h.rotation},anchor:o.anchor?(E,R)=>o.anchor(E,R,n):null});i.path=M.path,f&&(i.path=[M.path[0],_(j(f,i.target.part,o.at(f,n)))])}}const d=z(i,{strict:!0});if(!d.ok)throw new Error(d.errors.join("; "));const a=Q(t.color)?t.color:e.color,p=t.size==null?1:Number(t.size);if(!Number.isFinite(p)||p<.1||p>6)throw new Error("size must be 0.1..6");let u=t.at==null?i.path?e.attach==="sky"?i.path[1]:i.path[0]:F(t.to)&&t.from==null?t.to:f&&!i.attach?_(j(f,"feet",o.at(f,n))):l.position:null;if(t.at!=null)if(F(t.at))u=t.at;else{const h=y(o.items.filter(w=>w.kind!=="fx"),v(t.at));if(!h)throw new Error(`unknown object '${String(t.at)}' for at`);u=j(h,P.exec(String(t.at))?.[2]??"feet",o.at(h,n))}const c=ft(o.items,String(t.name||e.name).slice(0,60)),k={id:o.uid(),name:c,kind:"fx",position:_(u),rotation:[0,Number(t.yaw_deg)||0,0],scale:[p,p,p],color:a,hidden:!1,locked:!1,pose:o.restPose??{},reference:null,fx:d.fx},x=H(o.items,d.fx);if(!x.ok)throw new Error(x.errors.join("; "));const $=V({start:n,duration:d.fx.duration,...d.fx.loop?{loop:!0}:{}},r);return k.fx={...d.fx,start:$.start??n,duration:$.duration??d.fx.duration},{ok:!0,item:k,timing:{start:$.start??n,duration:$.duration??d.fx.duration,...d.fx.loop?{loop:!0}:{}}}}catch(e){return{ok:!1,error:e.message||String(e)}}}const W=t=>{let o=0;for(let e=0;e<t.length;e++)o=Math.imul(o,31)+t.charCodeAt(e)|0;return o},ft=(t,o)=>{let e=o,r=2;for(;t.some(n=>n.name===e);)e=`${o} ${r++}`;return e};function pt(t,o,e){try{const r={...t.fx},n={},i={...e.timing??{start:r.start,duration:r.duration,loop:r.loop}};if(o.start!=null&&(i.start=Number(o.start),!(i.start>=0&&i.start<e.shot.duration)))throw new Error(`start must be 0..${e.shot.duration} s`);if(o.duration!=null&&(i.duration=Number(o.duration)),o.loop!=null&&(i.loop=o.loop===!0),o.color!=null){if(!Q(o.color))throw new Error("color must be a CSS hex like #7fe9ff");n.color=o.color}if(o.intensity!=null&&(r.intensity=o.intensity),o.seed!=null&&(r.seed=o.seed),o.params&&typeof o.params=="object"&&(r.params={...r.params,...o.params}),o.size!=null){const a=Number(o.size);if(!(a>=.1&&a<=6))throw new Error("size must be 0.1..6");n.scale=[a,a,a]}o.yaw_deg!=null&&(n.rotation=[t.rotation[0],Number(o.yaw_deg)||0,t.rotation[2]]);const s=e.items.filter(a=>a.kind!=="fx"&&a.id!==t.id);if(o.attach_to!=null)if(o.attach_to==="none")delete r.attach;else{const a=y(s,o.attach_to);if(!a)throw new Error(`unknown object '${o.attach_to}' to attach to`);const p=o.hand==="right"?"R":o.hand==="left"?"L":void 0;if(p&&!S(a))throw new Error(`'${a.name}' is not a person`);r.attach={to:a.id,...p?{hand:p}:{},...F(o.offset)?{offset:o.offset}:{}}}else if(o.hand!=null&&r.attach){const a=o.hand==="right"?"R":o.hand==="left"?"L":void 0;r.attach={...r.attach,hand:a},a||delete r.attach.hand}if(o.at!=null)if(F(o.at))n.position=o.at;else{const a=y(s,v(o.at));if(!a)throw new Error(`unknown object '${String(o.at)}' for at`);n.position=_(j(a,P.exec(String(o.at))?.[2]??"feet",e.at(a,i.start)))}if(o.from!=null||o.to!=null||o.via!=null){const a=r.path??[],p=[o.from??a[0],...Array.isArray(o.via)?o.via:a.slice(1,-1),o.to??a.at(-1)];if(p.some(u=>u==null))throw new Error("give both from and to the first time you set a path");r.path=G(p,{find:u=>y(s,u),at:u=>e.at(u,i.start),anchor:e.anchor?(u,c)=>e.anchor(u,c,i.start):void 0})}if(typeof o.to=="string"){const a=y(s,v(o.to));a&&(r.target={to:a.id,part:P.exec(o.to)?.[2]??"chest"})}o.clear_path===!0&&delete r.path;const f=z({...r,start:i.start,duration:i.duration,loop:i.loop},{strict:!0});if(!f.ok)throw new Error(f.errors.join("; "));const m=H(e.items.filter(a=>a.id!==t.id),f.fx);if(!m.ok)throw new Error(m.errors.join("; "));const d=V(i,e.shot.duration);return{ok:!0,itemPatch:n,fx:{...f.fx,start:d.start??i.start,duration:d.duration??i.duration},timing:{...d,start:d.start??i.start,duration:d.duration??i.duration}}}catch(r){return{ok:!1,error:r.message||String(r)}}}function lt(t){const[o,e,r]=it(rt(t)),n=o*360;return r>.88||e<.12?r<.3?"dark grey":"white":r<.2?"dark":n<15||n>=345?"red":n<40?"orange":n<62?"golden":n<95?"lime green":n<160?"green":n<195?"cyan":n<225?"sky blue":n<255?"blue":n<285?"purple":n<330?"magenta":"pink"}function mt(t,o){const e=n=>{let l=null,i=2;for(const s of t){if(s.kind==="fx"||s.hidden)continue;const f=nt.dist(j(s,"chest"),n);f<i&&(i=f,l=s)}return l?.name},r=[];for(const n of t){if(n.kind!=="fx"||!n.fx||n.hidden)continue;const l=ot(n,o);if(l.off)continue;if(n.fx.preset===A){const a=n.fx.target&&t.find(p=>p.id===n.fx.target.to);a&&r.push(et(n,a.name,l));continue}const i=q(n.fx.cat)??T.find(a=>a.preset===n.fx.preset);if(!i)continue;const s=n.fx.attach?t.find(a=>a.id===n.fx.attach.to):null,f=n.fx.path?e(n.fx.path[0]):null,m=n.fx.path?e(n.fx.path.at(-1)):null,d=f&&m&&f!==m?` from ${f} to ${m}`:n.fx.path&&m?` toward ${m}`:s?` on ${s.name}${n.fx.attach.hand?`'s ${n.fx.attach.hand==="R"?"right":"left"} hand`:""}`:"";r.push(`${i.prompt} (${lt(n.color)} tint)${d}, from ${l.start.toFixed(1)}s to ${(l.start+l.duration).toFixed(1)}s`)}return r.length?`VISUAL EFFECTS
|
|
2
|
+
The previs shows each effect as glowing placeholder light. Recreate them as real, high-quality cinematic VFX with the same colour, timing, size and path (never render text or UI): ${r.slice(0,12).join("; ")}.`:""}const ht=["model","proxy","box","wall","platform","floor","sphere","cylinder","set","prop"];function dt(t){const o=t.scale??[1,1,1];if(t.kind==="proxy"&&t.proxy?.dims)return t.proxy.dims.map((e,r)=>e*o[r]);if(t.kind==="model"){const e=(t.model?.height??2)*o[1];return[e*.6,e,e*.6]}return[...o]}function wt(t,o){try{const e=y(o.items.filter(b=>ht.includes(b.kind)&&!b.hidden),t.target);if(!e)throw new Error(`unknown target '${String(t.target)}': use the name of a model, proxy, box, wall or platform from scene_summary`);const r=t.recipe??"collapse";if(!C.includes(r))throw new Error(`recipe must be one of ${C.join(", ")}`);const n=J.has(r),l=o.shot.duration,i=t.start==null?0:Number(t.start),s=t.end==null?Math.min(l,i+(n?4:Math.max(1,l*.5))):Number(t.end);if(!(i>=0&&i<l))throw new Error(`start must be 0..${l} s`);if(!(s>i&&s<=l+1e-6))throw new Error(`end must be after start and at most ${l} s`);if(t.mode!=null&&!L.includes(t.mode))throw new Error(`mode must be one of ${L.join(", ")}`);const f=dt(e),m=t.radius??Math.min(6,Math.max(.6,Math.max(...f)/5)),d=o.items.find(b=>b.fx?.preset===A&&b.fx.target?.to===e.id),a={radius:m,...Object.fromEntries(["strength","chunks","debris","collapse","falloff","shake","mode"].filter(b=>t[b]!=null).map(b=>[b,t[b]])),...t.direction!=null?{yaw:Number(t.direction)}:{}};d&&t.chunks==null&&(a.chunks=d.fx.params.chunks);const p=t.seed??d?.fx.seed??Math.abs(W(`${e.name}${i}`))%1e9+1,u=K({target:e.id,recipe:r,seed:p,start:i,duration:n?s-i:l-i,params:a}),c=z(u,{strict:!0});if(!c.ok)throw new Error(c.errors.join("; "));if(n){const b=o.items.filter(Y=>Y.fx?.preset===A).length,N=e.position;return{ok:!0,item:{id:o.uid(),name:t.name?String(t.name).slice(0,60):`Mix FX ${b+1}`,kind:"fx",position:[N[0],+(N[1]+f[1]+.6).toFixed(2),N[2]],rotation:[0,0,0],scale:[1,1,1],color:D[r].color,hidden:!1,locked:!1,pose:o.restPose,reference:null,fx:c.fx},timing:{start:i,duration:+(s-i).toFixed(2)},keys:[]}}const k=c.fx.params.radius+c.fx.params.falloff+.3,x=e.position,$=+(x[1]+f[1]/2).toFixed(2),h=F(t.from)?t.from.map(Number):[+(x[0]-f[0]/2-k).toFixed(2),$,x[2]],w=F(t.to)?t.to.map(Number):[+(x[0]+f[0]/2+k).toFixed(2),$,x[2]],M=o.items.filter(b=>b.fx?.preset===A).length,E={id:o.uid(),name:t.name?String(t.name).slice(0,60):`Mix FX ${M+1}`,kind:"fx",position:h,rotation:[0,0,0],scale:[1,1,1],color:D[r].color,hidden:!1,locked:!1,pose:o.restPose,reference:null,fx:c.fx},R=(b,N,X)=>({id:b,time:+N.toFixed(4),position:X,rotation:[0,0,0],scale:[1,1,1]});return{ok:!0,item:E,timing:{start:i,duration:+(l-i).toFixed(2)},keys:[R(o.uid(),i/l,h),R(o.uid(),s/l,w)]}}catch(e){return{ok:!1,error:e.message}}}export{y as a,ut as b,wt as c,pt as d,mt as f,U as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ip as N,iq as C,dV as Q,ir as V,is as X,it as Y,iu as Z,iv as K,dT as W,iw as ee}from"./remote-C7J0Tqhb.js";import{Vector3 as w,Line as F,SphereGeometry as te,Mesh as B,BufferGeometry as ne,Euler as oe,MathUtils as re,Box3 as _,LineBasicMaterial as se,MeshBasicMaterial as ie,Matrix4 as H,Bone as ae,Object3D as ce,Skeleton as ue,Uint16BufferAttribute as le,Float32BufferAttribute as de,SkinnedMesh as fe,Quaternion as pe,Sphere as he}from"./three.module-Bx43vjkH.js";const ye="clipoox-rig-weights",k="weights",ge=8;function R(){return new Promise(e=>{try{if(typeof indexedDB>"u")return e(null);const t=indexedDB.open(ye,1);t.onupgradeneeded=()=>{try{t.result.createObjectStore(k)}catch{}},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch{e(null)}})}async function me(e){const t=await R();if(!t)return null;try{return await new Promise(n=>{try{const r=t.transaction(k,"readonly").objectStore(k).get(e);r.onsuccess=()=>{const o=r.result;n(o?.data?.skinIndex instanceof Uint16Array?o.data:null)},r.onerror=()=>n(null)}catch{n(null)}})}finally{try{t.close()}catch{}}}async function we(e,t){const n=await R();if(n)try{await new Promise(r=>{try{const o=n.transaction(k,"readwrite"),i=o.objectStore(k);i.put({at:Date.now(),data:t},e);const s=[],c=i.openCursor();c.onsuccess=()=>{const u=c.result;u?(s.push({key:u.key,at:u.value.at||0}),u.continue()):s.sort((a,p)=>p.at-a.at).slice(ge).forEach(a=>i.delete(a.key))},o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()}catch{r()}})}finally{try{n.close()}catch{}}}async function be(){const e=await R();if(e)try{await new Promise(t=>{try{const n=e.transaction(k,"readwrite");n.objectStore(k).clear(),n.oncomplete=()=>t(),n.onerror=()=>t()}catch{t()}})}finally{try{e.close()}catch{}}}async function xe(e,t,n=!0){const r=`${N(e.positions,e.index)}|${e.rigKey}`;if(n){const i=await me(r).catch(()=>null);if(i)return t?.(1),{...i,source:"disk",key:r}}const o=C({positions:e.positions,index:e.index,joints:e.joints,onProgress:t});return n&&await we(r,o).catch(()=>{}),{...o,source:"computed",key:r}}function ve(e,t,n=!0){const r=async()=>({...await xe(e,t,n),via:"main"});if(typeof Worker>"u")return new Promise((s,c)=>setTimeout(()=>r().then(s,c),0));let o;try{o=new Worker(new URL("/assets/weights.worker-r1GBeQWE.js",import.meta.url),{type:"module"})}catch{return r()}const i={...e,positions:e.positions.slice(),index:e.index.slice()};return new Promise((s,c)=>{let u=!1;const a=()=>{if(!u){u=!0;try{o.terminate()}catch{}r().then(s,c)}};o.onmessage=p=>{p.data.type==="progress"?t?.(p.data.fraction??0):p.data.type==="done"&&!u?(u=!0,o.terminate(),s({...p.data.result,via:"worker"})):p.data.type==="error"&&a()},o.onerror=p=>{p.preventDefault?.(),a()};try{o.postMessage({input:i,disk:n},[i.positions.buffer,i.index.buffer])}catch{a()}})}const M=new Map,Me=12,ke=3e4,j=new Map,O=new Set,S=()=>O.forEach(e=>{try{e()}catch{}});function Be(e){return O.add(e),()=>{O.delete(e)}}function Oe(e){for(const n of j.values())if(n.modelKey===e)return{progress:n.progress,vertices:n.vertices};const t=L.get(e);return t&&Date.now()-t.at<G?{progress:1,vertices:t.vertices,done:!0}:null}const L=new Map,G=6e3;function Re(e){if(!e)M.clear();else for(const t of[...M.keys()])t.startsWith(`${e}|`)&&M.delete(t);be()}function A(e){e.updateMatrixWorld(!0);const t=e.matrixWorld.clone().invert(),n=[];return e.traverse(r=>{r instanceof B&&!r.userData.rigOverlay&&r.geometry?.getAttribute("position")&&n.push({mesh:r,matrix:t.clone().multiply(r.matrixWorld)})}),n}function je(e){const t=new _,n=new w;for(const{mesh:r,matrix:o}of A(e)){const i=r.geometry.getAttribute("position"),s=Math.max(1,Math.floor(i.count/2e4));for(let c=0;c<i.count;c+=s)t.expandByPoint(n.fromBufferAttribute(i,c).applyMatrix4(o))}return t}function Ie(e){let t=null,n=null;const r=new w;for(const{mesh:o,matrix:i}of A(e)){const s=o.geometry.getAttribute("position");for(let c=0;c<s.count;c++)r.fromBufferAttribute(s,c).applyMatrix4(i),(!t||r.x<t[0])&&(t=[r.x,r.y,r.z]),(!n||r.x>n[0])&&(n=[r.x,r.y,r.z])}return t&&n?{L:t,R:n}:null}function Se(e,t=A(e)){const n=t.reduce((a,{mesh:p})=>a+p.geometry.getAttribute("position").count,0),r=t.reduce((a,{mesh:p})=>a+(p.geometry.index?.count??p.geometry.getAttribute("position").count),0),o=new Float32Array(n*3),i=new Uint32Array(r),s=new w;let c=0,u=0;for(const{mesh:a,matrix:p}of t){const l=a.geometry,g=l.getAttribute("position");for(let y=0;y<g.count;y++)s.fromBufferAttribute(g,y).applyMatrix4(p),o[(c+y)*3]=s.x,o[(c+y)*3+1]=s.y,o[(c+y)*3+2]=s.z;if(l.index)for(let y=0;y<l.index.count;y++)i[u++]=c+l.index.getX(y);else for(let y=0;y<g.count;y++)i[u++]=c+y;c+=g.count}return{positions:o,index:i}}function E(e,t,n,r,o){const i=[];let s=0;for(const{mesh:u}of t){const a=u.geometry.getAttribute("position").count;i.push({skinIndex:n.skinIndex.slice(s*4,(s+a)*4),skinWeight:n.skinWeight.slice(s*4,(s+a)*4)}),s+=a}const c={perMesh:i,radius:n.boneRadius,spheres:n.boneSpheres,vertices:n.vertices,ms:n.ms,source:r,via:o};for(M.set(e,c);M.size>Me;)M.delete(M.keys().next().value);return c}function Ae(e,t,n,r={}){const o=A(e),i=o.map(({mesh:f})=>`${f.geometry.getAttribute("position").count}:${f.geometry.index?.count??0}`).join(","),s=`${n}|${i}|${W(t)}`,c=M.get(s);if(c)return{meshes:o,weights:c,cached:!0,key:s,job:null};const u=j.get(s);if(u)return{meshes:o,weights:null,cached:!1,key:s,job:u.promise};const a=o.reduce((f,{mesh:h})=>f+h.geometry.getAttribute("position").count,0),p=Se(e,o),l=W(t);if(o.length&&o.every(({mesh:f})=>f.geometry.userData.rigWeights===l&&f.geometry.getAttribute("skinIndex"))){const f=new Uint16Array(a*4),h=new Float32Array(a*4);let d=0;for(const{mesh:m}of o){const v=m.geometry;f.set(v.getAttribute("skinIndex").array,d*4),h.set(v.getAttribute("skinWeight").array,d*4),d+=v.getAttribute("position").count}const x=ee({positions:p.positions,skinIndex:f,skinWeight:h,joints:t.joints});return{meshes:o,weights:E(s,o,{skinIndex:f,skinWeight:h,...x,vertices:a,ms:0},"computed","main"),cached:!1,key:s,job:null}}if(a<=ke&&r.background!==!0){const f=C({...p,joints:t.joints});return f.vertices,Math.round(f.ms),{meshes:o,weights:E(s,o,f,"computed","main"),cached:!1,key:s,job:null}}const g={promise:Promise.resolve(),progress:0,vertices:a,modelKey:n};let y=0;return g.promise=ve({...p,joints:t.joints,rigKey:W(t)},f=>{g.progress=f,y++,S()}).then(f=>{E(s,o,f,f.source,f.via),g.via=f.via,f.via,f.source,f.vertices,Math.round(f.ms)}).catch(f=>{console.warn("[rig] weights",f.message)}).finally(()=>{j.delete(s),L.set(n,{at:Date.now(),vertices:a}),S(),setTimeout(S,G+50)}),j.set(s,g),S(),{meshes:o,weights:null,cached:!1,key:s,job:g.promise}}function Pe(e,t,n,r){if(!t.joints.length)return null;const{meshes:o,weights:i,cached:s,key:c,job:u}=Ae(e,t,n);if(!o.length)return null;u&&r?.(`rig:${c}`,u);const a=t.joints.map(h=>{const d=new ae;return d.name=h.name,d.userData.rigBone=h.name,d});if(t.joints.forEach((h,d)=>{const x=h.parent?t.joints.findIndex(v=>v.name===h.parent):-1,m=new w(...h.pos);x<0?(a[d].position.copy(m),e.add(a[d])):(a[d].position.copy(m.sub(new w(...t.joints[x].pos))),a[x].add(a[d]))}),t.kind==="humanoid")for(const h of["L","R"]){const d=Y(t,h),x=t.joints.findIndex(v=>v.name===`wrist${h}`);if(!d||x<0)continue;const m=new ce;m.name=`rigHold${h}`,m.userData.rigHold=h,m.position.copy(d.position),m.quaternion.copy(d.quaternion),m.scale.setScalar(d.scale),a[x].add(m)}e.updateMatrixWorld(!0);const p=[];if(i){const h=new ue(a);o.forEach(({mesh:d},x)=>{const m=d.geometry,v=i.perMesh[x];m.setAttribute("skinIndex",new le(v.skinIndex,4)),m.setAttribute("skinWeight",new de(v.skinWeight,4));const b=new fe(m,d.material);b.name=d.name,b.castShadow=d.castShadow,b.receiveShadow=d.receiveShadow,b.position.copy(d.position),b.quaternion.copy(d.quaternion),b.scale.copy(d.scale),b.frustumCulled=!0,b.userData.rigSkinned=!0,b.userData.slots=d.userData.slots;const I=d.parent;I.add(b),I.remove(d);for(const J of[...d.children])b.add(J);p.push(b)}),e.updateMatrixWorld(!0);for(const d of p)d.bind(h,d.matrixWorld)}const l=je(e),g=Math.max(.001,...l.getSize(new w).toArray()),y=i?void 0:[...j.values()].find(h=>h.promise===u),f={rig:t,bones:a,poser:Z(t,i?.radius??null),meshes:p,rootRest:a[0].position.clone(),size:g,center:l.getCenter(new w),info:i?{vertices:i.vertices,ms:Math.round(i.ms),cached:s,source:s?i.source==="disk"?"disk":"memory":i.source,via:i.via}:{vertices:y?.vertices??0,ms:0,cached:!1,source:"pending",progress:y?.progress??0},spheres:i?.spheres??null};return e.userData.rig=f,f}const D=new H,P=new H,q=new w,We=new w;function U(e){const t=e.spheres;if(!(!t||!e.meshes.length))for(const n of e.meshes){n.updateMatrixWorld(!0),P.copy(n.matrixWorld).invert();const r=[],o=[];if(e.bones.forEach((u,a)=>{const p=t[a*4+3];if(!(p>0))return;const l=e.rig.joints[a].pos;D.multiplyMatrices(P,u.matrixWorld),r.push(We.set(t[a*4]-l[0],t[a*4+1]-l[1],t[a*4+2]-l[2]).applyMatrix4(D).clone()),o.push(p*D.getMaxScaleOnAxis())}),!r.length)continue;const i=new _;r.forEach((u,a)=>{i.expandByPoint(q.copy(u).addScalar(o[a])),i.expandByPoint(q.copy(u).addScalar(-o[a]))});const s=i.getCenter(new w);let c=0;r.forEach((u,a)=>{c=Math.max(c,u.distanceTo(s)+o[a])}),n.boundingSphere=new he(s,c),n.boundingBox=i}}function qe(e,t,n,r=!1){if(r)e.bones.forEach(o=>o.quaternion.identity()),e.bones[0].position.copy(e.rootRest);else{const{local:o,shift:i}=e.poser.solve(t,n||{});e.bones.forEach((s,c)=>s.quaternion.copy(o[c])),e.bones[0].position.copy(e.rootRest),e.bones[0].position.y+=i}e.bones[0].updateMatrixWorld(!0),U(e)}function Te(e,t){const n=X(e.rig),r=l=>l?e.bones[e.rig.joints.findIndex(g=>g.name===l)]:void 0,o=r(n.head),i=e.rig.joints.find(l=>l.name==="headTop"),s=e.rig.joints.find(l=>l.name===n.head),c=i&&s?Math.max(.05,i.pos[1]-s.pos[1]):.25,u=new w(0,.55*c,.3*c),a=(l,g,y,f,h)=>{if(!l)return;l.updateWorldMatrix(!0,!1);const d=l.worldToLocal(t.clone()).sub(h);l.quaternion.multiply(new pe().setFromEuler(K(d,y,f,g))),l.updateMatrixWorld(!0)},p=r(n.neck);p&&a(p,.4,30,15,u.clone().add(new w(0,.3*c,0))),a(o,1,70,35,u);for(const l of n.eyes)a(r(l),1,45,35,new w);U(e)}function $e(e,t,n){const r=e.rig.joints.findIndex(c=>c.name===t);if(r<0)return[0,0,0];const i=e.poser.solve(n,{}).local[r].clone().invert().multiply(e.bones[r].quaternion),s=new oe().setFromQuaternion(i,"XYZ");return[s.x,s.y,s.z].map(c=>Math.round(re.radToDeg(c)*10)/10)}const T=new Map;function $(e){let t=T.get(e);return t||(t=e==="line"?new se({color:"#b8df78",depthTest:!1,transparent:!0,opacity:.9}):new ie({color:e==="picked"?"#ffad52":e==="end"?"#7fd6ff":"#b8df78",depthTest:!1,transparent:!0,opacity:.95}),t.userData.shared=!0,t.dispose=()=>{},T.set(e,t)),t}let z=null;function ze(e){const t=[];e.traverse(n=>{n.userData.rigOverlay&&t.push(n)});for(const n of t)n.parent?.remove(n),n instanceof F&&n.geometry.dispose()}function Ce(e,t,n=1){const r=e.size*.014*n;z??=(()=>{const o=new te(1,12,8);return o.userData.shared=!0,o.dispose=()=>{},o})(),e.rig.joints.forEach((o,i)=>{const s=e.bones[i],c=Q(e.rig.joints,o),u=new B(z,$(o.name===t?"picked":c?"end":"joint")),a=V(o.name)?.3:1;u.scale.setScalar(a*(o.name===t?r*1.5:c?r*.75:r)),u.userData.rigOverlay=!0,u.userData.rigJoint=o.name,u.renderOrder=1e3,u.layers.set(1),u.raycast=B.prototype.raycast,s.add(u);for(const p of e.bones.filter(l=>l.parent===s)){const l=new F(new ne().setFromPoints([new w,p.position.clone()]),$("line"));l.userData.rigOverlay=!0,l.renderOrder=999,l.layers.set(1),l.raycast=()=>{},s.add(l)}})}export{Ce as a,$e as b,Re as c,Ie as d,Se as e,je as f,Te as g,Pe as h,Be as o,qe as p,ze as r,Oe as w};
|
|
1
|
+
import{eY as N,eZ as C,am as Q,e_ as X,e$ as Y,f0 as V,f1 as Z,f2 as K,ak as W,f3 as ee}from"./remote-DJd9xWjn.js";import{Vector3 as w,Line as _,SphereGeometry as te,Mesh as B,BufferGeometry as ne,Euler as oe,MathUtils as re,Box3 as F,LineBasicMaterial as se,MeshBasicMaterial as ie,Matrix4 as H,Bone as ae,Object3D as ce,Skeleton as ue,Uint16BufferAttribute as le,Float32BufferAttribute as de,SkinnedMesh as fe,Quaternion as pe,Sphere as he}from"./three.module-Bx43vjkH.js";const ye="clipoox-rig-weights",k="weights",ge=8;function R(){return new Promise(e=>{try{if(typeof indexedDB>"u")return e(null);const t=indexedDB.open(ye,1);t.onupgradeneeded=()=>{try{t.result.createObjectStore(k)}catch{}},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch{e(null)}})}async function me(e){const t=await R();if(!t)return null;try{return await new Promise(n=>{try{const r=t.transaction(k,"readonly").objectStore(k).get(e);r.onsuccess=()=>{const o=r.result;n(o?.data?.skinIndex instanceof Uint16Array?o.data:null)},r.onerror=()=>n(null)}catch{n(null)}})}finally{try{t.close()}catch{}}}async function we(e,t){const n=await R();if(n)try{await new Promise(r=>{try{const o=n.transaction(k,"readwrite"),i=o.objectStore(k);i.put({at:Date.now(),data:t},e);const s=[],c=i.openCursor();c.onsuccess=()=>{const u=c.result;u?(s.push({key:u.key,at:u.value.at||0}),u.continue()):s.sort((a,p)=>p.at-a.at).slice(ge).forEach(a=>i.delete(a.key))},o.oncomplete=()=>r(),o.onerror=()=>r(),o.onabort=()=>r()}catch{r()}})}finally{try{n.close()}catch{}}}async function be(){const e=await R();if(e)try{await new Promise(t=>{try{const n=e.transaction(k,"readwrite");n.objectStore(k).clear(),n.oncomplete=()=>t(),n.onerror=()=>t()}catch{t()}})}finally{try{e.close()}catch{}}}async function xe(e,t,n=!0){const r=`${N(e.positions,e.index)}|${e.rigKey}`;if(n){const i=await me(r).catch(()=>null);if(i)return t?.(1),{...i,source:"disk",key:r}}const o=C({positions:e.positions,index:e.index,joints:e.joints,onProgress:t});return n&&await we(r,o).catch(()=>{}),{...o,source:"computed",key:r}}function ve(e,t,n=!0){const r=async()=>({...await xe(e,t,n),via:"main"});if(typeof Worker>"u")return new Promise((s,c)=>setTimeout(()=>r().then(s,c),0));let o;try{o=new Worker(new URL("/assets/weights.worker-r1GBeQWE.js",import.meta.url),{type:"module"})}catch{return r()}const i={...e,positions:e.positions.slice(),index:e.index.slice()};return new Promise((s,c)=>{let u=!1;const a=()=>{if(!u){u=!0;try{o.terminate()}catch{}r().then(s,c)}};o.onmessage=p=>{p.data.type==="progress"?t?.(p.data.fraction??0):p.data.type==="done"&&!u?(u=!0,o.terminate(),s({...p.data.result,via:"worker"})):p.data.type==="error"&&a()},o.onerror=p=>{p.preventDefault?.(),a()};try{o.postMessage({input:i,disk:n},[i.positions.buffer,i.index.buffer])}catch{a()}})}const M=new Map,Me=12,ke=3e4,j=new Map,O=new Set,S=()=>O.forEach(e=>{try{e()}catch{}});function Be(e){return O.add(e),()=>{O.delete(e)}}function Oe(e){for(const n of j.values())if(n.modelKey===e)return{progress:n.progress,vertices:n.vertices};const t=L.get(e);return t&&Date.now()-t.at<G?{progress:1,vertices:t.vertices,done:!0}:null}const L=new Map,G=6e3;function Re(e){if(!e)M.clear();else for(const t of[...M.keys()])t.startsWith(`${e}|`)&&M.delete(t);be()}function A(e){e.updateMatrixWorld(!0);const t=e.matrixWorld.clone().invert(),n=[];return e.traverse(r=>{r instanceof B&&!r.userData.rigOverlay&&r.geometry?.getAttribute("position")&&n.push({mesh:r,matrix:t.clone().multiply(r.matrixWorld)})}),n}function je(e){const t=new F,n=new w;for(const{mesh:r,matrix:o}of A(e)){const i=r.geometry.getAttribute("position"),s=Math.max(1,Math.floor(i.count/2e4));for(let c=0;c<i.count;c+=s)t.expandByPoint(n.fromBufferAttribute(i,c).applyMatrix4(o))}return t}function Ie(e){let t=null,n=null;const r=new w;for(const{mesh:o,matrix:i}of A(e)){const s=o.geometry.getAttribute("position");for(let c=0;c<s.count;c++)r.fromBufferAttribute(s,c).applyMatrix4(i),(!t||r.x<t[0])&&(t=[r.x,r.y,r.z]),(!n||r.x>n[0])&&(n=[r.x,r.y,r.z])}return t&&n?{L:t,R:n}:null}function Se(e,t=A(e)){const n=t.reduce((a,{mesh:p})=>a+p.geometry.getAttribute("position").count,0),r=t.reduce((a,{mesh:p})=>a+(p.geometry.index?.count??p.geometry.getAttribute("position").count),0),o=new Float32Array(n*3),i=new Uint32Array(r),s=new w;let c=0,u=0;for(const{mesh:a,matrix:p}of t){const l=a.geometry,g=l.getAttribute("position");for(let y=0;y<g.count;y++)s.fromBufferAttribute(g,y).applyMatrix4(p),o[(c+y)*3]=s.x,o[(c+y)*3+1]=s.y,o[(c+y)*3+2]=s.z;if(l.index)for(let y=0;y<l.index.count;y++)i[u++]=c+l.index.getX(y);else for(let y=0;y<g.count;y++)i[u++]=c+y;c+=g.count}return{positions:o,index:i}}function E(e,t,n,r,o){const i=[];let s=0;for(const{mesh:u}of t){const a=u.geometry.getAttribute("position").count;i.push({skinIndex:n.skinIndex.slice(s*4,(s+a)*4),skinWeight:n.skinWeight.slice(s*4,(s+a)*4)}),s+=a}const c={perMesh:i,radius:n.boneRadius,spheres:n.boneSpheres,vertices:n.vertices,ms:n.ms,source:r,via:o};for(M.set(e,c);M.size>Me;)M.delete(M.keys().next().value);return c}function Ae(e,t,n,r={}){const o=A(e),i=o.map(({mesh:f})=>`${f.geometry.getAttribute("position").count}:${f.geometry.index?.count??0}`).join(","),s=`${n}|${i}|${W(t)}`,c=M.get(s);if(c)return{meshes:o,weights:c,cached:!0,key:s,job:null};const u=j.get(s);if(u)return{meshes:o,weights:null,cached:!1,key:s,job:u.promise};const a=o.reduce((f,{mesh:h})=>f+h.geometry.getAttribute("position").count,0),p=Se(e,o),l=W(t);if(o.length&&o.every(({mesh:f})=>f.geometry.userData.rigWeights===l&&f.geometry.getAttribute("skinIndex"))){const f=new Uint16Array(a*4),h=new Float32Array(a*4);let d=0;for(const{mesh:m}of o){const v=m.geometry;f.set(v.getAttribute("skinIndex").array,d*4),h.set(v.getAttribute("skinWeight").array,d*4),d+=v.getAttribute("position").count}const x=ee({positions:p.positions,skinIndex:f,skinWeight:h,joints:t.joints});return{meshes:o,weights:E(s,o,{skinIndex:f,skinWeight:h,...x,vertices:a,ms:0},"computed","main"),cached:!1,key:s,job:null}}if(a<=ke&&r.background!==!0){const f=C({...p,joints:t.joints});return f.vertices,Math.round(f.ms),{meshes:o,weights:E(s,o,f,"computed","main"),cached:!1,key:s,job:null}}const g={promise:Promise.resolve(),progress:0,vertices:a,modelKey:n};let y=0;return g.promise=ve({...p,joints:t.joints,rigKey:W(t)},f=>{g.progress=f,y++,S()}).then(f=>{E(s,o,f,f.source,f.via),g.via=f.via,f.via,f.source,f.vertices,Math.round(f.ms)}).catch(f=>{console.warn("[rig] weights",f.message)}).finally(()=>{j.delete(s),L.set(n,{at:Date.now(),vertices:a}),S(),setTimeout(S,G+50)}),j.set(s,g),S(),{meshes:o,weights:null,cached:!1,key:s,job:g.promise}}function Pe(e,t,n,r){if(!t.joints.length)return null;const{meshes:o,weights:i,cached:s,key:c,job:u}=Ae(e,t,n);if(!o.length)return null;u&&r?.(`rig:${c}`,u);const a=t.joints.map(h=>{const d=new ae;return d.name=h.name,d.userData.rigBone=h.name,d});if(t.joints.forEach((h,d)=>{const x=h.parent?t.joints.findIndex(v=>v.name===h.parent):-1,m=new w(...h.pos);x<0?(a[d].position.copy(m),e.add(a[d])):(a[d].position.copy(m.sub(new w(...t.joints[x].pos))),a[x].add(a[d]))}),t.kind==="humanoid")for(const h of["L","R"]){const d=V(t,h),x=t.joints.findIndex(v=>v.name===`wrist${h}`);if(!d||x<0)continue;const m=new ce;m.name=`rigHold${h}`,m.userData.rigHold=h,m.position.copy(d.position),m.quaternion.copy(d.quaternion),m.scale.setScalar(d.scale),a[x].add(m)}e.updateMatrixWorld(!0);const p=[];if(i){const h=new ue(a);o.forEach(({mesh:d},x)=>{const m=d.geometry,v=i.perMesh[x];m.setAttribute("skinIndex",new le(v.skinIndex,4)),m.setAttribute("skinWeight",new de(v.skinWeight,4));const b=new fe(m,d.material);b.name=d.name,b.castShadow=d.castShadow,b.receiveShadow=d.receiveShadow,b.position.copy(d.position),b.quaternion.copy(d.quaternion),b.scale.copy(d.scale),b.frustumCulled=!0,b.userData.rigSkinned=!0,b.userData.slots=d.userData.slots;const I=d.parent;I.add(b),I.remove(d);for(const J of[...d.children])b.add(J);p.push(b)}),e.updateMatrixWorld(!0);for(const d of p)d.bind(h,d.matrixWorld)}const l=je(e),g=Math.max(.001,...l.getSize(new w).toArray()),y=i?void 0:[...j.values()].find(h=>h.promise===u),f={rig:t,bones:a,poser:Z(t,i?.radius??null),meshes:p,rootRest:a[0].position.clone(),size:g,center:l.getCenter(new w),info:i?{vertices:i.vertices,ms:Math.round(i.ms),cached:s,source:s?i.source==="disk"?"disk":"memory":i.source,via:i.via}:{vertices:y?.vertices??0,ms:0,cached:!1,source:"pending",progress:y?.progress??0},spheres:i?.spheres??null};return e.userData.rig=f,f}const D=new H,P=new H,$=new w,We=new w;function U(e){const t=e.spheres;if(!(!t||!e.meshes.length))for(const n of e.meshes){n.updateMatrixWorld(!0),P.copy(n.matrixWorld).invert();const r=[],o=[];if(e.bones.forEach((u,a)=>{const p=t[a*4+3];if(!(p>0))return;const l=e.rig.joints[a].pos;D.multiplyMatrices(P,u.matrixWorld),r.push(We.set(t[a*4]-l[0],t[a*4+1]-l[1],t[a*4+2]-l[2]).applyMatrix4(D).clone()),o.push(p*D.getMaxScaleOnAxis())}),!r.length)continue;const i=new F;r.forEach((u,a)=>{i.expandByPoint($.copy(u).addScalar(o[a])),i.expandByPoint($.copy(u).addScalar(-o[a]))});const s=i.getCenter(new w);let c=0;r.forEach((u,a)=>{c=Math.max(c,u.distanceTo(s)+o[a])}),n.boundingSphere=new he(s,c),n.boundingBox=i}}function $e(e,t,n,r=!1){if(r)e.bones.forEach(o=>o.quaternion.identity()),e.bones[0].position.copy(e.rootRest);else{const{local:o,shift:i}=e.poser.solve(t,n||{});e.bones.forEach((s,c)=>s.quaternion.copy(o[c])),e.bones[0].position.copy(e.rootRest),e.bones[0].position.y+=i}e.bones[0].updateMatrixWorld(!0),U(e)}function qe(e,t){const n=Y(e.rig),r=l=>l?e.bones[e.rig.joints.findIndex(g=>g.name===l)]:void 0,o=r(n.head),i=e.rig.joints.find(l=>l.name==="headTop"),s=e.rig.joints.find(l=>l.name===n.head),c=i&&s?Math.max(.05,i.pos[1]-s.pos[1]):.25,u=new w(0,.55*c,.3*c),a=(l,g,y,f,h)=>{if(!l)return;l.updateWorldMatrix(!0,!1);const d=l.worldToLocal(t.clone()).sub(h);l.quaternion.multiply(new pe().setFromEuler(K(d,y,f,g))),l.updateMatrixWorld(!0)},p=r(n.neck);p&&a(p,.4,30,15,u.clone().add(new w(0,.3*c,0))),a(o,1,70,35,u);for(const l of n.eyes)a(r(l),1,45,35,new w);U(e)}function Te(e,t,n){const r=e.rig.joints.findIndex(c=>c.name===t);if(r<0)return[0,0,0];const i=e.poser.solve(n,{}).local[r].clone().invert().multiply(e.bones[r].quaternion),s=new oe().setFromQuaternion(i,"XYZ");return[s.x,s.y,s.z].map(c=>Math.round(re.radToDeg(c)*10)/10)}const q=new Map;function T(e){let t=q.get(e);return t||(t=e==="line"?new se({color:"#b8df78",depthTest:!1,transparent:!0,opacity:.9}):new ie({color:e==="picked"?"#ffad52":e==="end"?"#7fd6ff":"#b8df78",depthTest:!1,transparent:!0,opacity:.95}),t.userData.shared=!0,t.dispose=()=>{},q.set(e,t)),t}let z=null;function ze(e){const t=[];e.traverse(n=>{n.userData.rigOverlay&&t.push(n)});for(const n of t)n.parent?.remove(n),n instanceof _&&n.geometry.dispose()}function Ce(e,t,n=1){const r=e.size*.014*n;z??=(()=>{const o=new te(1,12,8);return o.userData.shared=!0,o.dispose=()=>{},o})(),e.rig.joints.forEach((o,i)=>{const s=e.bones[i],c=Q(e.rig.joints,o),u=new B(z,T(o.name===t?"picked":c?"end":"joint")),a=X(o.name)?.3:1;u.scale.setScalar(a*(o.name===t?r*1.5:c?r*.75:r)),u.userData.rigOverlay=!0,u.userData.rigJoint=o.name,u.renderOrder=1e3,u.layers.set(1),u.raycast=B.prototype.raycast,s.add(u);for(const p of e.bones.filter(l=>l.parent===s)){const l=new _(new ne().setFromPoints([new w,p.position.clone()]),T("line"));l.userData.rigOverlay=!0,l.renderOrder=999,l.layers.set(1),l.raycast=()=>{},s.add(l)}})}export{Ce as a,Te as b,Re as c,Ie as d,Se as e,je as f,qe as g,Pe as h,Be as o,$e as p,ze as r,Oe as w};
|