PageSourceSearch

https://tesana.com/assets/ModelOrbitViewer-B5v3ssr6.js

js tesana.com collected 2026-10-09 22:41:30 UTC 4,632 bytes, 1 lines download raw bytes

1import{j as i}from"./vendor-motion-hRg_q8lq.js";import{r as s}from"./vendor-react-E98sgxjj.js";import{du as z}from"./vendor-fa-Bn2dnpnC.js";import{V}from"./ViewerScene-R0lCmUu4.js";import{u as F}from"./Gltf-kFBePvvf.js";import{u as L}from"./useAnimations-CPqp3P7o.js";import{c as p,d as M,b as _,B as O,V as P}from"./vendor-three-Cz2JVrfJ.js";import{_ as I}from"./Grid-CXpTWUo7.js";import{u as D}from"./index-BKzE8EQ8.js";import"./vendor-query-bOUN_gKe.js";const T=s.forwardRef(({makeDefault:l,camera:m,regress:r,domElement:x,enableDamping:u=!0,keyEvents:e=!1,onChange:o,onStart:n,onEnd:d,...b},h)=>{const g=p(t=>t.invalidate),C=p(t=>t.camera),a=p(t=>t.gl),f=p(t=>t.events),E=p(t=>t.setEvents),w=p(t=>t.set),A=p(t=>t.get),v=p(t=>t.performance),R=m||C,y=x||f.connected||a.domElement,c=s.useMemo(()=>new M(R),[R]);return _(()=>{c.enabled&&c.update()},-1),s.useEffect(()=>(e&&c.connect(e===!0?y:e),c.connect(y),()=>void c.dispose()),[e,y,r,c,g]),s.useEffect(()=>{const t=j=>{g(),r&&v.regress(),o&&o(j)},S=j=>{n&&n(j)},N=j=>{d&&d(j)};return c.addEventListener("change",t),c.addEventListener("start",S),c.addEventListener("end",N),()=>{c.removeEventListener("start",S),c.removeEventListener("end",N),c.removeEventListener("change",t)}},[o,n,d,c,g,E]),s.useEffect(()=>{if(l){const t=A().controls;return w({controls:c}),()=>w({controls:t})}},[l,c]),s.createElement("primitive",I({ref:h,object:c,enableDamping:u},b))});function q({url:l}){const m=s.useRef(null),{scene:r,animations:x}=F(l),u=s.useMemo(()=>r.clone(!0),[r]),{actions:e,names:o}=L(x,m),[n,d]=s.useState(null),[b,h]=s.useState(!0);s.useEffect(()=>{const a=new O().setFromObject(u),f=a.getSize(new P),E=a.getCenter(new P),w=Math.max(f.x,f.y,f.z),v=w>0?2/w:1;u.scale.setScalar(v),u.position.set(-E.x*v,-a.min.y*v,-E.z*v)},[u]),s.useEffect(()=>{if(o.length>0&&!n){const a=o[0];d(a);const f=e[a];f&&f.reset().fadeIn(.3).play()}},[o,e,n]);const g=s.useCallback(a=>{n&&e[n]&&e[n].fadeOut(.3);const f=e[a];f&&(f.reset().fadeIn(.3).play(),d(a),h(!0))},[n,e]),C=s.useCallback(()=>{if(!n||!e[n])return;const a=e[n];b?(a.paused=!0,h(!1)):(a.paused=!1,h(!0))},[n,e,b]);return s.useEffect(()=>{const a=m.current;a&&(a.__animationControls={names:o,activeClip:n,isPlaying:b,switchAnimation:g,togglePlayPause:C})},[o,n,b,g,C]),i.jsx("group",{ref:m,children:i.jsx("primitive",{object:u})})}function k({enabled:l}){const m=s.useRef(null);return _(()=>{m.current&&l&&m.current.update()}),i.jsx(T,{ref:m,autoRotate:l,autoRotateSpeed:1.5,enablePan:!0,enableZoom:!0,enableRotate:!0,minDistance:1,maxDistance:15,maxPolarAngle:Math.PI/2+.1,target:[0,1,0]})}function B({names:l,activeClip:m,isPlaying:r,onSwitch:x,onToggle:u}){const{t:e}=D("studio");return l.length===0?null:i.jsxs("div",{className:"absolute bottom-4 left-4 right-4 flex items-center gap-2 z-10",children:[i.jsx("button",{onClick:u,className:"w-8 h-8 flex items-center justify-center rounded-md bg-[#2d2d2d]/90 border border-white/15 text-white/80 hover:bg-[#454545]/90 transition-colors",title:e(r?"assetViewer.pause":"assetViewer.play"),"aria-label":e(r?"assetViewer.pause":"assetViewer.play"),children:i.jsx(z,{icon:["far",r?"pause":"play"],className:"text-xs"})}),i.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:l.map(o=>i.jsx("button",{onClick:()=>x(o),className:`px-2.5 py-1 rounded-md text-xs border transition-colors ${m===o?"bg-orange-900/90 border-accent/50 text-white":"bg-[#2d2d2d]/90 border-white/15 text-white/70 hover:bg-[#454545]/90"}`,children:o},o))})]})}function Y({asset:l,autoRotate:m=!0}){const[r,x]=s.useState(null),u=s.useRef();return s.useEffect(()=>{const e=()=>{const o=document.querySelector("[data-orbit-viewer] canvas");if(!o){u.current=requestAnimationFrame(e);return}const n=o.__r3f?.store?.getState()?.scene;n&&n.traverse(d=>{d.__animationControls&&x(d.__animationControls)}),u.current=requestAnimationFrame(e)};return e(),()=>{u.current&&cancelAnimationFrame(u.current)}},[l.url]),i.jsxs("div",{className:"relative w-full h-full","data-orbit-viewer":!0,children:[i.jsxs(V,{cameraPosition:[0,1.5,4],bloom:!0,children:[i.jsx(q,{url:l.url}),i.jsx(k,{enabled:m})]}),i.jsx("div",{className:"absolute top-4 left-4 z-10",children:i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md bg-[#2d2d2d]/90 border border-white/15",children:[i.jsx("span",{className:"text-xs text-accent uppercase font-medium tracking-wide",children:l.type}),i.jsx("span",{className:"text-sm text-white/90",children:l.name})]})}),r&&r.names.length>0&&i.jsx(B,{names:r.names,activeClip:r.activeClip,isPlaying:r.isPlaying,onSwitch:r.switchAnimation,onToggle:r.togglePlayPause})]})}
1export{Y as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.