t2-model-skinner/docs/_next/static/chunks/250.10c119307e239c98.js
2024-08-26 12:48:36 -07:00

2 lines
No EOL
1.6 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[250],{9250:function(e,t,a){a.r(t),a.d(t,{default:function(){return ModelViewer}});var l=a(5893),o=a(7294);a(5848);var d=a(485);function ModelViewerKeyedByModel(e){let{modelUrl:t,environmentImageUrl:a,showEnvironment:i=!1,exposure:r=1,animationName:n,animationPaused:u=!1,timeScale:s=1,cameraOrbit:f,cameraTarget:c,fieldOfView:m,children:v}=e,[h,w]=(0,o.useState)(null),[y,g]=(0,o.useState)(!1),x=(0,o.useMemo)(()=>h&&y&&h.model?{modelViewer:h,model:h.model,isLoaded:y}:null,[h,y]);return(0,o.useEffect)(()=>{h&&(h.timeScale=s)},[h,s]),(0,o.useEffect)(()=>{if(!h)return;let e=!1,handleLoad=()=>{e||g(!0)};return h.addEventListener("load",handleLoad),()=>{e=!0,h.removeEventListener("load",handleLoad)}},[h,t]),(0,o.useEffect)(()=>{h&&h.loaded&&g(!0)},[h,t]),(0,o.useEffect)(()=>{h&&y&&(u?h.pause():h.play())},[h,y,u]),(0,o.useEffect)(()=>{h&&y&&m&&h.setAttribute("field-of-view",m)},[h,y,m]),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("model-viewer",{ref:w,alt:"Tribes 2 Model",src:t,"camera-controls":!0,"camera-orbit":f,"max-camera-orbit":a&&i?"auto 90deg auto":void 0,"camera-target":c,"min-field-of-view":"10deg","max-field-of-view":"45deg","animation-name":null!=n?n:void 0,autoplay:n?"true":"false","touch-action":"pan-y",exposure:r,"environment-image":null!=a?a:void 0,"skybox-image":a&&i?a:void 0,"skybox-height":"1.5m","shadow-intensity":a&&i?1:0,style:{width:"100%",height:"100%"}}),y?(0,l.jsx)(d.K.Provider,{value:x,children:v}):null]})}function ModelViewer(e){return(0,l.jsx)(ModelViewerKeyedByModel,{...e},e.modelUrl)}}}]);
//# sourceMappingURL=250.10c119307e239c98.js.map