diff --git a/docs/742.65077f70.iframe.bundle.js b/docs/742.b7cddfe9.iframe.bundle.js similarity index 65% rename from docs/742.65077f70.iframe.bundle.js rename to docs/742.b7cddfe9.iframe.bundle.js index 573abb13..43afc189 100644 --- a/docs/742.65077f70.iframe.bundle.js +++ b/docs/742.b7cddfe9.iframe.bundle.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_readyplayerme_visage=self.webpackChunk_readyplayerme_visage||[]).push([[742],{"./src/components/Background/Box/Box.component.tsx":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{x:function(){return Box}});var _home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js"),react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/react/index.js"),three__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("./node_modules/three/build/three.module.js"),_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/react/jsx-runtime.js"),_excluded=["src"],Box=function Box(_ref){var _ref$src=_ref.src,src=void 0===_ref$src?"":_ref$src,baseProps=(0,_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2__.Z)(_ref,_excluded),ref=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null),texture=(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__.D)(three__WEBPACK_IMPORTED_MODULE_4__.TextureLoader,src);return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("mesh",(0,_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_5__.Z)((0,_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_5__.Z)({ref:ref,castShadow:!0,receiveShadow:!0},baseProps),{},{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("boxBufferGeometry",{}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("meshPhysicalMaterial",{map:texture})]}))};Box.__docgenInfo={description:"",methods:[],displayName:"Box",props:{src:{defaultValue:{value:"''",computed:!1},required:!1}}}},"./src/components/Background/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{l:function(){return BackgroundColor}});__webpack_require__("./node_modules/react/index.js");var jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),BackgroundColor=function BackgroundColor(_ref){var color=_ref.color;return(0,jsx_runtime.jsx)("color",{attach:"background",args:[color]})};BackgroundColor.__docgenInfo={description:"",methods:[],displayName:"BackgroundColor"};__webpack_require__("./src/components/Background/Box/Box.component.tsx")},"./src/components/BaseCanvas/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{u:function(){return BaseCanvas}});var objectSpread2=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),react_three_fiber_esm=(__webpack_require__("./node_modules/react/index.js"),__webpack_require__("./node_modules/@react-three/fiber/dist/react-three-fiber.esm.js")),three_module=__webpack_require__("./node_modules/three/build/three.module.js"),Client_service=__webpack_require__("./src/services/Client.service.ts"),BaseCanvas_module_base_canvas="BaseCanvas_base-canvas__7RHH3",jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),BASE_DPR=Client_service.Y?window.devicePixelRatio:1,BaseCanvas=function BaseCanvas(_ref){var _ref$children=_ref.children,children=void 0===_ref$children?void 0:_ref$children,_ref$fov=_ref.fov,fov=void 0===_ref$fov?50:_ref$fov,_ref$position=_ref.position,position=void 0===_ref$position?new three_module.Vector3(0,0,5):_ref$position,style=_ref.style,_ref$dpr=_ref.dpr,dpr=void 0===_ref$dpr?[.5*BASE_DPR,2]:_ref$dpr,className=_ref.className;return(0,jsx_runtime.jsx)(react_three_fiber_esm.Xz,{className:"".concat(BaseCanvas_module_base_canvas," ").concat(null!=className?className:""),shadows:"soft",gl:{preserveDrawingBuffer:!0,alpha:!0,toneMappingExposure:1.6,toneMapping:three_module.ACESFilmicToneMapping},dpr:dpr,camera:{fov:fov,position:position},resize:{scroll:!0,debounce:{scroll:50,resize:0}},style:(0,objectSpread2.Z)((0,objectSpread2.Z)({},style),{},{background:"transparent"}),children:children},fov)};BaseCanvas.__docgenInfo={description:"",methods:[],displayName:"BaseCanvas",props:{children:{defaultValue:{value:"undefined",computed:!0},required:!1},fov:{defaultValue:{value:"50",computed:!1},required:!1},position:{defaultValue:{value:"new Vector3(0, 0, 5)",computed:!1},required:!1},dpr:{defaultValue:{value:"[BASE_DPR * 0.5, 2]",computed:!1},required:!1}}}},"./src/components/Capture/Capture.component.tsx":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/react/index.js"),_react_three_fiber__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/react/jsx-runtime.js"),Capture=function Capture(_ref){var trigger=_ref.trigger,settings=_ref.settings,callBack=_ref.callBack,gl=(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_2__.z)((function(state){return state.gl})),type=(null==settings?void 0:settings.type)||"image/png",quality=(null==settings?void 0:settings.quality)||.1;return(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)((function(){if(trigger){var _capture=gl.domElement.toDataURL(type,quality);callBack(_capture)}}),[trigger]),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.Fragment,{})};Capture.__docgenInfo={description:"",methods:[],displayName:"Capture"},__webpack_exports__.Z=Capture},"./src/components/Models/FloatingModel/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{q:function(){return FloatingModelContainer}});var objectSpread2=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),slicedToArray=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),react=__webpack_require__("./node_modules/react/index.js"),index_673ef987_esm=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),Model=__webpack_require__("./src/components/Models/Model/index.ts"),services=__webpack_require__("./src/services/index.ts"),jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),FloatingModel=function FloatingModel(_ref){var modelSrc=_ref.modelSrc,_ref$scale=_ref.scale,scale=void 0===_ref$scale?1:_ref$scale,onLoaded=_ref.onLoaded,bloom=_ref.bloom,ref=(0,react.useRef)(null),scene=(0,services.Jr)(modelSrc).scene;return(0,index_673ef987_esm.A)((function(state){var t=state.clock.getElapsedTime();null!=ref&&ref.current&&(ref.current.rotation.y=Math.sin(t/2)/8,ref.current.position.y=(1+Math.sin(t/1.5))/-9)})),(0,jsx_runtime.jsx)(Model.H,{modelRef:ref,scale:scale,scene:scene,onLoaded:onLoaded,bloom:bloom})};FloatingModel.__docgenInfo={description:"",methods:[],displayName:"FloatingModel",props:{scale:{defaultValue:{value:"1.0",computed:!1},required:!1}}};var FloatingModelContainer=function FloatingModelContainer(props){var _useState=(0,react.useState)((0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})),_useState2=(0,slicedToArray.Z)(_useState,2),fallback=_useState2[0],setFallback=_useState2[1];return(0,jsx_runtime.jsx)(react.Suspense,{fallback:fallback,children:(0,jsx_runtime.jsx)(FloatingModel,(0,objectSpread2.Z)((0,objectSpread2.Z)({},props),{},{setModelFallback:setFallback}))})};FloatingModelContainer.__docgenInfo={description:"Contains model to handle suspense fallback.",methods:[],displayName:"FloatingModelContainer"}},"./src/components/Models/Model/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{H:function(){return Model}});var slicedToArray=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),react=__webpack_require__("./node_modules/react/index.js"),services=__webpack_require__("./src/services/index.ts"),index_673ef987_esm=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),Client_service=__webpack_require__("./src/services/Client.service.ts"),esm_react=__webpack_require__("./node_modules/jotai/esm/react.mjs"),regeneratorRuntime=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js"),asyncToGenerator=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"),three_module=__webpack_require__("./node_modules/three/build/three.module.js"),Animation_service=__webpack_require__("./src/services/Animation.service.ts"),jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),SpawnEffect=function SpawnEffect(_ref){var onLoadedEffect=_ref.onLoadedEffect,onLoadedEffectFinish=_ref.onLoadedEffectFinish,ref=(0,react.useRef)(null),_React$useState=react.useState(!0),_React$useState2=(0,slicedToArray.Z)(_React$useState,2),effectRunning=_React$useState2[0],setEffectRunning=_React$useState2[1],mountEffectScene=(0,services.Jr)(onLoadedEffect.src).scene,mountEffectNode=(0,index_673ef987_esm.C)(mountEffectScene).nodes;(0,react.useEffect)((function(){effectRunning||(0,services.DK)(onLoadedEffectFinish)}),[onLoadedEffectFinish,effectRunning]);var animationLoadedEffect=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee(){return(0,regeneratorRuntime.Z)().wrap((function _callee$(_context){for(;;)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",(0,Animation_service.$)((null==onLoadedEffect?void 0:onLoadedEffect.animationSrc)||onLoadedEffect.src));case 1:case"end":return _context.stop()}}),_callee)}))),[null==onLoadedEffect?void 0:onLoadedEffect.animationSrc,onLoadedEffect.src]),spawnEffectMixer=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee2(){var mixer,loadedEffect,animation;return(0,regeneratorRuntime.Z)().wrap((function _callee2$(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:return mixer=new three_module.AnimationMixer(mountEffectNode.Scene),_context2.next=3,animationLoadedEffect;case 3:if(loadedEffect=_context2.sent){_context2.next=7;break}return setEffectRunning(!1),_context2.abrupt("return",mixer);case 7:return(animation=mixer.clipAction(loadedEffect)).setLoop(three_module.LoopRepeat,(null==onLoadedEffect?void 0:onLoadedEffect.loop)||1),animation.clampWhenFinished=!0,animation.play(),mixer.addEventListener("finished",(function(){animation.fadeOut(.5),setEffectRunning(!1)})),_context2.abrupt("return",mixer);case 13:case"end":return _context2.stop()}}),_callee2)}))),[mountEffectNode.Scene,animationLoadedEffect,null==onLoadedEffect?void 0:onLoadedEffect.loop]);return(0,index_673ef987_esm.A)(function(){var _ref4=(0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee3(state,delta){var _yield$spawnEffectMix;return(0,regeneratorRuntime.Z)().wrap((function _callee3$(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:return _context3.next=2,spawnEffectMixer;case 2:if(_context3.t1=_yield$spawnEffectMix=_context3.sent,_context3.t0=null===_context3.t1,_context3.t0){_context3.next=6;break}_context3.t0=void 0===_yield$spawnEffectMix;case 6:if(!_context3.t0){_context3.next=10;break}_context3.next=11;break;case 10:_yield$spawnEffectMix.update(delta);case 11:case"end":return _context3.stop()}}),_callee3)})));return function(_x,_x2){return _ref4.apply(this,arguments)}}()),(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:effectRunning&&(0,jsx_runtime.jsx)("primitive",{modelRef:ref,object:mountEffectScene})})};SpawnEffect.__docgenInfo={description:"",methods:[],displayName:"SpawnEffect"};var SpawnAnimation=function SpawnAnimation(_ref){var avatar=_ref.avatar,onLoadedAnimationFinish=_ref.onLoadedAnimationFinish,onLoadedAnimation=_ref.onLoadedAnimation,_React$useState=react.useState(!0),_React$useState2=(0,slicedToArray.Z)(_React$useState,2),animationRunning=_React$useState2[0],setAnimationRunning=_React$useState2[1];(0,react.useEffect)((function(){animationRunning||(0,services.DK)(onLoadedAnimationFinish)}),[onLoadedAnimationFinish,animationRunning]);var avatarNode=(0,index_673ef987_esm.C)(avatar).nodes,animationClip=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee(){return(0,regeneratorRuntime.Z)().wrap((function _callee$(_context){for(;;)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",(0,Animation_service.$)((null==onLoadedAnimation?void 0:onLoadedAnimation.src)||""));case 1:case"end":return _context.stop()}}),_callee)}))),[null==onLoadedAnimation?void 0:onLoadedAnimation.src]),animationMixerAvatar=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee2(){var mixer,animation;return(0,regeneratorRuntime.Z)().wrap((function _callee2$(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:if(mixer=new three_module.AnimationMixer(avatarNode.Armature),avatarNode.Armature){_context2.next=3;break}return _context2.abrupt("return",mixer);case 3:return _context2.t0=mixer,_context2.next=6,animationClip;case 6:return _context2.t1=_context2.sent,(animation=_context2.t0.clipAction.call(_context2.t0,_context2.t1)).setLoop(three_module.LoopRepeat,(null==onLoadedAnimation?void 0:onLoadedAnimation.loop)||1),animation.clampWhenFinished=!0,animation.play(),mixer.addEventListener("finished",(function(){animation.fadeOut(.5),setAnimationRunning(!1)})),_context2.abrupt("return",mixer);case 13:case"end":return _context2.stop()}}),_callee2)}))),[avatarNode.Armature,null==onLoadedAnimation?void 0:onLoadedAnimation.loop,animationClip]);return(0,index_673ef987_esm.A)(function(){var _ref4=(0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee3(state,delta){var _yield$animationMixer;return(0,regeneratorRuntime.Z)().wrap((function _callee3$(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:return _context3.next=2,animationMixerAvatar;case 2:if(_context3.t1=_yield$animationMixer=_context3.sent,_context3.t0=null===_context3.t1,_context3.t0){_context3.next=6;break}_context3.t0=void 0===_yield$animationMixer;case 6:if(!_context3.t0){_context3.next=10;break}_context3.next=11;break;case 10:_yield$animationMixer.update(delta);case 11:case"end":return _context3.stop()}}),_callee3)})));return function(_x,_x2){return _ref4.apply(this,arguments)}}()),(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})};SpawnAnimation.__docgenInfo={description:"",methods:[],displayName:"SpawnAnimation"};var spawnAtom=__webpack_require__("./src/state/spawnAtom.ts"),Spawn=function Spawn(_ref){var _animationProps$onLoa,_animationProps$onLoa2,avatar=_ref.avatar,onSpawnFinish=_ref.onSpawnFinish,animationProps=(0,esm_react.Dv)(spawnAtom.O),usesMountEffect=(0,services.w9)(null==animationProps||null===(_animationProps$onLoa=animationProps.onLoadedEffect)||void 0===_animationProps$onLoa?void 0:_animationProps$onLoa.src),usesMountAnimation=(0,services.w9)(null==animationProps||null===(_animationProps$onLoa2=animationProps.onLoadedAnimation)||void 0===_animationProps$onLoa2?void 0:_animationProps$onLoa2.src),_React$useState=react.useState(usesMountEffect),_React$useState2=(0,slicedToArray.Z)(_React$useState,2),effectRunning=_React$useState2[0],setEffectRunning=_React$useState2[1],_React$useState3=react.useState(usesMountAnimation),_React$useState4=(0,slicedToArray.Z)(_React$useState3,2),animationRunning=_React$useState4[0],setAnimationRunning=_React$useState4[1];(0,react.useEffect)((function(){animationRunning||effectRunning||(0,services.DK)(onSpawnFinish)}),[onSpawnFinish,effectRunning,animationRunning]);return(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[usesMountEffect&&(0,jsx_runtime.jsx)(SpawnEffect,{onLoadedEffect:animationProps.onLoadedEffect,onLoadedEffectFinish:function onLoadedEffectFinish(){setEffectRunning(!1)}}),usesMountAnimation&&(0,jsx_runtime.jsx)(SpawnAnimation,{onLoadedAnimation:animationProps.onLoadedAnimation,avatar:avatar,onLoadedAnimationFinish:function onLoadedAnimationFinish(){setAnimationRunning(!1)}})]})};Spawn.__docgenInfo={description:"",methods:[],displayName:"Spawn"};var Model=function Model(_ref){var scene=_ref.scene,_ref$scale=_ref.scale,scale=void 0===_ref$scale?1:_ref$scale,modelRef=_ref.modelRef,onLoaded=_ref.onLoaded,onSpawnAnimationFinish=_ref.onSpawnAnimationFinish,bloom=_ref.bloom,materials=(0,index_673ef987_esm.C)(scene).materials,gl=(0,index_673ef987_esm.z)().gl,_useState=(0,react.useState)(!1),_useState2=(0,slicedToArray.Z)(_useState,2),isTouching=_useState2[0],setIsTouching=_useState2[1],_useState3=(0,react.useState)(null),_useState4=(0,slicedToArray.Z)(_useState3,2),touchEvent=_useState4[0],setTouchEvent=_useState4[1],setTouchingOn=function setTouchingOn(e){Client_service.Y&&window.TouchEvent&&e instanceof TouchEvent&&setTouchEvent(e),setIsTouching(!0)},setTouchingOff=function setTouchingOff(e){Client_service.Y&&window.TouchEvent&&e instanceof TouchEvent&&setTouchEvent(null),setIsTouching(!1)};(0,services._U)(scene);var onTouchMove=(0,react.useCallback)((function(event){if(isTouching&&event instanceof MouseEvent&&(scene.rotation.y+=.005*event.movementX),Client_service.Y&&isTouching&&window.TouchEvent&&event instanceof TouchEvent){var movementX=Math.round(event.touches[0].pageX-touchEvent.touches[0].pageX);scene.rotation.y+=.005*movementX,setTouchEvent(event)}}),[isTouching,touchEvent,scene]);(0,services.Zm)(materials,bloom),scene.traverse((function(object){var node=object;node.isMesh&&(node.castShadow=!0),"SkinnedMesh"===node.type&&(node.receiveShadow=!0)})),(0,react.useEffect)((function(){return(0,services.DK)(onLoaded)}),[scene,materials,onLoaded]),(0,react.useEffect)((function(){return gl.domElement.addEventListener("mousedown",setTouchingOn),gl.domElement.addEventListener("touchstart",setTouchingOn,{passive:!0}),window.addEventListener("mouseup",setTouchingOff),gl.domElement.addEventListener("touchend",setTouchingOff),gl.domElement.addEventListener("touchcancel",setTouchingOff),window.addEventListener("mousemove",onTouchMove),gl.domElement.addEventListener("touchmove",onTouchMove,{passive:!0}),function(){gl.domElement.removeEventListener("mousedown",setTouchingOn),gl.domElement.removeEventListener("touchstart",setTouchingOn),window.removeEventListener("mouseup",setTouchingOff),gl.domElement.removeEventListener("touchend",setTouchingOff),gl.domElement.removeEventListener("touchcancel",setTouchingOff),window.removeEventListener("mousemove",onTouchMove),gl.domElement.removeEventListener("touchmove",onTouchMove)}}));var spawnComponent=(0,react.useMemo)((function(){return(0,jsx_runtime.jsx)(Spawn,{avatar:scene,onSpawnFinish:onSpawnAnimationFinish})}),[onSpawnAnimationFinish]);return(0,jsx_runtime.jsxs)("group",{ref:modelRef,dispose:null,rotation:[0,0,0],children:[(0,jsx_runtime.jsx)("primitive",{object:scene,scale:scale}),spawnComponent]})};Model.__docgenInfo={description:"",methods:[],displayName:"Model",props:{scale:{defaultValue:{value:"1",computed:!1},required:!1}}}},"./src/components/Models/StaticModel/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{P:function(){return StaticModelContainer}});var objectSpread2=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),slicedToArray=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),react=__webpack_require__("./node_modules/react/index.js"),Model=__webpack_require__("./src/components/Models/Model/index.ts"),services=__webpack_require__("./src/services/index.ts"),index_673ef987_esm=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),StaticModel=function StaticModel(_ref){var modelSrc=_ref.modelSrc,modelRef=_ref.modelRef,_ref$scale=_ref.scale,scale=void 0===_ref$scale?1:_ref$scale,setModelFallback=_ref.setModelFallback,onLoaded=_ref.onLoaded,emotion=_ref.emotion,bloom=_ref.bloom,scene=(0,services.Jr)(modelSrc).scene,nodes=(0,index_673ef987_esm.C)(scene).nodes;return(0,services.Kx)(nodes,emotion),(0,services.xD)(nodes,setModelFallback),(0,jsx_runtime.jsx)(Model.H,{modelRef:modelRef,scene:scene,scale:scale,onLoaded:onLoaded,bloom:bloom})};StaticModel.__docgenInfo={description:"",methods:[],displayName:"StaticModel",props:{scale:{defaultValue:{value:"1",computed:!1},required:!1}}};var StaticModelContainer=function StaticModelContainer(props){var _useState=(0,react.useState)((0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})),_useState2=(0,slicedToArray.Z)(_useState,2),fallback=_useState2[0],setFallback=_useState2[1];return(0,jsx_runtime.jsx)(react.Suspense,{fallback:fallback,children:(0,jsx_runtime.jsx)(StaticModel,(0,objectSpread2.Z)({setModelFallback:setFallback},props))})};StaticModelContainer.__docgenInfo={description:"Contains model to handle suspense fallback.",methods:[],displayName:"StaticModelContainer"}},"./src/components/Scene/Environment.component.tsx":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{q:function(){return Environment}});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/react/index.js"),_react_three_drei__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./node_modules/@react-three/drei/core/Environment.js"),src_services_Environment_service__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./src/services/Environment.service.ts"),react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/react/jsx-runtime.js"),Environment=function Environment(_ref){var environment=_ref.environment,config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)((function(){return{files:environment in src_services_Environment_service__WEBPACK_IMPORTED_MODULE_1__.s$?(0,src_services_Environment_service__WEBPACK_IMPORTED_MODULE_1__.G2)(environment):environment}}),[environment]);return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_react_three_drei__WEBPACK_IMPORTED_MODULE_3__.qA,{files:config.files})};Environment.__docgenInfo={description:"",methods:[],displayName:"Environment"}},"./src/services/Animation.service.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:function(){return loadAnimationClip}});var _home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js"),_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"),three_stdlib__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/three-stdlib/loaders/FBXLoader.js"),three_stdlib__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/three-stdlib/loaders/GLTFLoader.js"),fbxLoader=new three_stdlib__WEBPACK_IMPORTED_MODULE_0__.y,gltfLoader=new three_stdlib__WEBPACK_IMPORTED_MODULE_1__.E;function normaliseFbxAnimation(fbx){for(var index=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,tracks=fbx.animations[index].tracks,i=0;i0&&source.every(validateSource);if("string"==typeof source){var fileEndExpression=new RegExp(/(.glb|.fbx|.fbx[?].*|.glb[?].*)$/g),uploadFileExpression=new RegExp(/^data:application\/octet-stream;base64,/g),gltfModelExpression=new RegExp(/^data:model\/gltf-binary;base64,/g);return fileEndExpression.test(source)||uploadFileExpression.test(source)||gltfModelExpression.test(source)}return source instanceof Blob&&"model/gltf-binary"===source.type},isValidFormat=function isValidFormat(source){var isValid=validateSource(source);return source&&!isValid&&console.warn("Provided GLB/FBX is invalid. Check docs for supported formats: https://github.com/readyplayerme/visage"),isValid},clamp=function clamp(value,max,min){return Math.min(Math.max(min,value),max)},lerp=function lerp(start,end){var time=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.05;return start*(1-time)+end*time},normaliseMaterialsConfig=function normaliseMaterialsConfig(materials,bloomConfig){Object.values(materials).forEach((function(material){var mat=material;mat.map&&(mat.map.minFilter=three__WEBPACK_IMPORTED_MODULE_2__.LinearFilter,mat.depthWrite=!0),mat.name.toLowerCase().includes("hair")&&(mat.roughness=.9),mat.emissiveMap&&(mat.emissiveIntensity=(null==bloomConfig?void 0:bloomConfig.materialIntensity)||3.3,mat.toneMapped=!1)}))},useHeadMovement=function useHeadMovement(_ref){var nodes=_ref.nodes,_ref$isHalfBody=_ref.isHalfBody,isHalfBody=void 0!==_ref$isHalfBody&&_ref$isHalfBody,_ref$distance=_ref.distance,distance=void 0===_ref$distance?2:_ref$distance,_ref$activeRotation=_ref.activeRotation,activeRotation=void 0===_ref$activeRotation?.2:_ref$activeRotation,_ref$rotationMargin=_ref.rotationMargin,rotationMargin=void 0===_ref$rotationMargin?new three__WEBPACK_IMPORTED_MODULE_2__.Vector2(5,10):_ref$rotationMargin,_ref$enabled=_ref.enabled,enabled=void 0!==_ref$enabled&&_ref$enabled,rad=Math.PI/180,currentPos=new three__WEBPACK_IMPORTED_MODULE_2__.Vector2(0,0),targetPos=new three__WEBPACK_IMPORTED_MODULE_2__.Vector2(0,0),activeDistance=distance-(isHalfBody?1:0),eyeRotationOffsetX=isHalfBody?90*rad:0,neckBoneRotationOffsetX=(isHalfBody?-5:10)*rad,mapRange=function mapRange(value,inMin,inMax,outMin,outMax){return(clamp(value,inMax,inMin)-inMin)*(outMax-outMin)/(inMax-inMin)+outMin};(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__.A)((function(state){if(enabled&&nodes.Neck&&nodes.Head&&nodes.RightEye&&nodes.LeftEye){var cameraToHeadDistance=state.camera.position.distanceTo(nodes.Head.position),cameraRotation=Math.abs(state.camera.rotation.z);cameraToHeadDistance1&&void 0!==arguments[1]?arguments[1]:new Transform;return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("group",{children:Object.keys(nodes).map((function(key){var node=nodes[key];return"SkinnedMesh"===node.type?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("skinnedMesh",{castShadow:!0,receiveShadow:!0,scale:transform.scale,position:transform.position,rotation:transform.rotation,geometry:node.geometry,material:node.material,skeleton:node.skeleton,morphTargetInfluences:node.morphTargetInfluences||[]},node.name):"Mesh"===node.type?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("mesh",{castShadow:!0,receiveShadow:!0,scale:transform.scale,position:transform.position,rotation:transform.rotation,geometry:node.geometry,material:node.material,morphTargetInfluences:node.morphTargetInfluences||[]},node.name):null}))})}(nodes))}),[setter,nodes])},triggerCallback=function triggerCallback(callback){"function"==typeof callback&&callback()},expressions={blink:[{morphTarget:"eyesClosed",morphTargetIndex:-1,offset:0,duration:.2},{morphTarget:"eyeSquintLeft",morphTargetIndex:-1,offset:0,duration:.2},{morphTarget:"eyeSquintRight",morphTargetIndex:-1,offset:0,duration:.2}]},useIdleExpression=function useIdleExpression(expression,nodes){var headMesh=nodes.Wolf3D_Head||nodes.Wolf3D_Avatar,selectedExpression=expression in expressions?expressions[expression]:void 0,timeout=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(),duration=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(Number.POSITIVE_INFINITY);(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)((function(){if(null!=headMesh&&headMesh.morphTargetDictionary&&selectedExpression)for(var i=0;isection.offset){var pivot=(duration.current-section.offset)/section.duration*Math.PI,morphInfluence=Math.sin(pivot);headMesh.morphTargetInfluences[section.morphTargetIndex]=morphInfluence}}else headMesh.morphTargetInfluences[section.morphTargetIndex]=0}}}),[null==headMesh?void 0:headMesh.morphTargetInfluences,selectedExpression,duration.current,timeout.current]),setNextInterval=function setNextInterval(){duration.current=0;var delay=3e3*Math.random()+3e3;clearTimeout(timeout.current),timeout.current=setTimeout(setNextInterval,delay)};(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)((function(){return selectedExpression&&(timeout.current=setTimeout(setNextInterval,3e3)),function(){clearTimeout(timeout.current)}}),[selectedExpression]),(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__.A)((function(_,delta){headMesh&&selectedExpression&&animateExpression(delta)}))}},"./src/services/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{DK:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.DK},FB:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.FB},Jr:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.Jr},Kx:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.Kx},Zm:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.Zm},_U:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__._U},bu:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.bu},bx:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.bx},gT:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.gT},t7:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.t7},uZ:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.uZ},w9:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.w9},wx:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.wx},xD:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.xD}});var _Models_service__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./src/services/Models.service.tsx")},"./src/state/spawnAtom.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:function(){return spawnState}});var spawnState=(0,__webpack_require__("./node_modules/jotai/esm/vanilla.mjs").cn)({onLoadedEffect:null,onLoadedAnimation:null})}}]); \ No newline at end of file +"use strict";(self.webpackChunk_readyplayerme_visage=self.webpackChunk_readyplayerme_visage||[]).push([[742],{"./src/components/Background/Box/Box.component.tsx":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{x:function(){return Box}});var _home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js"),react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/react/index.js"),three__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("./node_modules/three/build/three.module.js"),_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/react/jsx-runtime.js"),_excluded=["src"],Box=function Box(_ref){var _ref$src=_ref.src,src=void 0===_ref$src?"":_ref$src,baseProps=(0,_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2__.Z)(_ref,_excluded),ref=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null),texture=(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__.D)(three__WEBPACK_IMPORTED_MODULE_4__.TextureLoader,src);return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("mesh",(0,_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_5__.Z)((0,_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_5__.Z)({ref:ref,castShadow:!0,receiveShadow:!0},baseProps),{},{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("boxBufferGeometry",{}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("meshPhysicalMaterial",{map:texture})]}))};Box.__docgenInfo={description:"",methods:[],displayName:"Box",props:{src:{defaultValue:{value:"''",computed:!1},required:!1}}}},"./src/components/Background/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{l:function(){return BackgroundColor}});__webpack_require__("./node_modules/react/index.js");var jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),BackgroundColor=function BackgroundColor(_ref){var color=_ref.color;return(0,jsx_runtime.jsx)("color",{attach:"background",args:[color]})};BackgroundColor.__docgenInfo={description:"",methods:[],displayName:"BackgroundColor"};__webpack_require__("./src/components/Background/Box/Box.component.tsx")},"./src/components/BaseCanvas/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{u:function(){return BaseCanvas}});var objectSpread2=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),react_three_fiber_esm=(__webpack_require__("./node_modules/react/index.js"),__webpack_require__("./node_modules/@react-three/fiber/dist/react-three-fiber.esm.js")),three_module=__webpack_require__("./node_modules/three/build/three.module.js"),Client_service=__webpack_require__("./src/services/Client.service.ts"),BaseCanvas_module_base_canvas="BaseCanvas_base-canvas__7RHH3",jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),BASE_DPR=Client_service.Y?window.devicePixelRatio:1,BaseCanvas=function BaseCanvas(_ref){var _ref$children=_ref.children,children=void 0===_ref$children?void 0:_ref$children,_ref$fov=_ref.fov,fov=void 0===_ref$fov?50:_ref$fov,_ref$position=_ref.position,position=void 0===_ref$position?new three_module.Vector3(0,0,5):_ref$position,style=_ref.style,_ref$dpr=_ref.dpr,dpr=void 0===_ref$dpr?[.5*BASE_DPR,2]:_ref$dpr,className=_ref.className;return(0,jsx_runtime.jsx)(react_three_fiber_esm.Xz,{className:"".concat(BaseCanvas_module_base_canvas," ").concat(null!=className?className:""),shadows:"soft",gl:{preserveDrawingBuffer:!0,alpha:!0,toneMappingExposure:1.6,toneMapping:three_module.ACESFilmicToneMapping},dpr:dpr,camera:{fov:fov,position:position},resize:{scroll:!0,debounce:{scroll:50,resize:0}},style:(0,objectSpread2.Z)((0,objectSpread2.Z)({},style),{},{background:"transparent"}),children:children},fov)};BaseCanvas.__docgenInfo={description:"",methods:[],displayName:"BaseCanvas",props:{children:{defaultValue:{value:"undefined",computed:!0},required:!1},fov:{defaultValue:{value:"50",computed:!1},required:!1},position:{defaultValue:{value:"new Vector3(0, 0, 5)",computed:!1},required:!1},dpr:{defaultValue:{value:"[BASE_DPR * 0.5, 2]",computed:!1},required:!1}}}},"./src/components/Capture/Capture.component.tsx":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/react/index.js"),_react_three_fiber__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/react/jsx-runtime.js"),Capture=function Capture(_ref){var trigger=_ref.trigger,settings=_ref.settings,callBack=_ref.callBack,gl=(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_2__.z)((function(state){return state.gl})),type=(null==settings?void 0:settings.type)||"image/png",quality=(null==settings?void 0:settings.quality)||.1;return(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)((function(){if(trigger){var _capture=gl.domElement.toDataURL(type,quality);callBack(_capture)}}),[trigger]),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.Fragment,{})};Capture.__docgenInfo={description:"",methods:[],displayName:"Capture"},__webpack_exports__.Z=Capture},"./src/components/Models/FloatingModel/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{q:function(){return FloatingModelContainer}});var objectSpread2=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),slicedToArray=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),react=__webpack_require__("./node_modules/react/index.js"),index_673ef987_esm=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),Model=__webpack_require__("./src/components/Models/Model/index.ts"),services=__webpack_require__("./src/services/index.ts"),jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),FloatingModel=function FloatingModel(_ref){var modelSrc=_ref.modelSrc,_ref$scale=_ref.scale,scale=void 0===_ref$scale?1:_ref$scale,onLoaded=_ref.onLoaded,bloom=_ref.bloom,ref=(0,react.useRef)(null),scene=(0,services.Jr)(modelSrc).scene;return(0,index_673ef987_esm.A)((function(state){var t=state.clock.getElapsedTime();null!=ref&&ref.current&&(ref.current.rotation.y=Math.sin(t/2)/8,ref.current.position.y=(1+Math.sin(t/1.5))/-9)})),(0,jsx_runtime.jsx)(Model.H,{modelRef:ref,scale:scale,scene:scene,onLoaded:onLoaded,bloom:bloom})};FloatingModel.__docgenInfo={description:"",methods:[],displayName:"FloatingModel",props:{scale:{defaultValue:{value:"1.0",computed:!1},required:!1}}};var FloatingModelContainer=function FloatingModelContainer(props){var _useState=(0,react.useState)((0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})),_useState2=(0,slicedToArray.Z)(_useState,2),fallback=_useState2[0],setFallback=_useState2[1];return(0,jsx_runtime.jsx)(react.Suspense,{fallback:fallback,children:(0,jsx_runtime.jsx)(FloatingModel,(0,objectSpread2.Z)((0,objectSpread2.Z)({},props),{},{setModelFallback:setFallback}))})};FloatingModelContainer.__docgenInfo={description:"Contains model to handle suspense fallback.",methods:[],displayName:"FloatingModelContainer"}},"./src/components/Models/Model/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{H:function(){return Model}});var slicedToArray=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),react=__webpack_require__("./node_modules/react/index.js"),services=__webpack_require__("./src/services/index.ts"),index_673ef987_esm=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),Client_service=__webpack_require__("./src/services/Client.service.ts"),esm_react=__webpack_require__("./node_modules/jotai/esm/react.mjs"),regeneratorRuntime=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js"),asyncToGenerator=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"),three_module=__webpack_require__("./node_modules/three/build/three.module.js"),Animation_service=__webpack_require__("./src/services/Animation.service.ts"),jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),SpawnEffect=function SpawnEffect(_ref){var onLoadedEffect=_ref.onLoadedEffect,onLoadedEffectFinish=_ref.onLoadedEffectFinish,ref=(0,react.useRef)(null),_React$useState=react.useState(!0),_React$useState2=(0,slicedToArray.Z)(_React$useState,2),effectRunning=_React$useState2[0],setEffectRunning=_React$useState2[1],mountEffectScene=(0,services.Jr)(onLoadedEffect.src).scene,mountEffectNode=(0,index_673ef987_esm.C)(mountEffectScene).nodes;(0,react.useEffect)((function(){effectRunning||(0,services.DK)(onLoadedEffectFinish)}),[onLoadedEffectFinish,effectRunning]);var animationLoadedEffect=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee(){return(0,regeneratorRuntime.Z)().wrap((function _callee$(_context){for(;;)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",(0,Animation_service.$)((null==onLoadedEffect?void 0:onLoadedEffect.animationSrc)||onLoadedEffect.src));case 1:case"end":return _context.stop()}}),_callee)}))),[null==onLoadedEffect?void 0:onLoadedEffect.animationSrc,onLoadedEffect.src]),spawnEffectMixer=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee2(){var mixer,loadedEffect,animation;return(0,regeneratorRuntime.Z)().wrap((function _callee2$(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:return mixer=new three_module.AnimationMixer(mountEffectNode.Scene),_context2.next=3,animationLoadedEffect;case 3:if(loadedEffect=_context2.sent){_context2.next=7;break}return setEffectRunning(!1),_context2.abrupt("return",mixer);case 7:return(animation=mixer.clipAction(loadedEffect)).setLoop(three_module.LoopRepeat,(null==onLoadedEffect?void 0:onLoadedEffect.loop)||1),animation.clampWhenFinished=!0,animation.play(),mixer.addEventListener("finished",(function(){animation.fadeOut(.5),setEffectRunning(!1)})),_context2.abrupt("return",mixer);case 13:case"end":return _context2.stop()}}),_callee2)}))),[mountEffectNode.Scene,animationLoadedEffect,null==onLoadedEffect?void 0:onLoadedEffect.loop]);return(0,index_673ef987_esm.A)(function(){var _ref4=(0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee3(state,delta){var _yield$spawnEffectMix;return(0,regeneratorRuntime.Z)().wrap((function _callee3$(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:return _context3.next=2,spawnEffectMixer;case 2:if(_context3.t1=_yield$spawnEffectMix=_context3.sent,_context3.t0=null===_context3.t1,_context3.t0){_context3.next=6;break}_context3.t0=void 0===_yield$spawnEffectMix;case 6:if(!_context3.t0){_context3.next=10;break}_context3.next=11;break;case 10:_yield$spawnEffectMix.update(delta);case 11:case"end":return _context3.stop()}}),_callee3)})));return function(_x,_x2){return _ref4.apply(this,arguments)}}()),(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:effectRunning&&(0,jsx_runtime.jsx)("primitive",{modelRef:ref,object:mountEffectScene})})};SpawnEffect.__docgenInfo={description:"",methods:[],displayName:"SpawnEffect"};var SpawnAnimation=function SpawnAnimation(_ref){var avatar=_ref.avatar,onLoadedAnimationFinish=_ref.onLoadedAnimationFinish,onLoadedAnimation=_ref.onLoadedAnimation,_React$useState=react.useState(!0),_React$useState2=(0,slicedToArray.Z)(_React$useState,2),animationRunning=_React$useState2[0],setAnimationRunning=_React$useState2[1];(0,react.useEffect)((function(){animationRunning||(0,services.DK)(onLoadedAnimationFinish)}),[onLoadedAnimationFinish,animationRunning]);var avatarNode=(0,index_673ef987_esm.C)(avatar).nodes,animationClip=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee(){return(0,regeneratorRuntime.Z)().wrap((function _callee$(_context){for(;;)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",(0,Animation_service.$)((null==onLoadedAnimation?void 0:onLoadedAnimation.src)||""));case 1:case"end":return _context.stop()}}),_callee)}))),[null==onLoadedAnimation?void 0:onLoadedAnimation.src]),animationMixerAvatar=(0,react.useMemo)((0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee2(){var mixer,animation;return(0,regeneratorRuntime.Z)().wrap((function _callee2$(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:if(mixer=new three_module.AnimationMixer(avatarNode.Armature),avatarNode.Armature){_context2.next=3;break}return _context2.abrupt("return",mixer);case 3:return _context2.t0=mixer,_context2.next=6,animationClip;case 6:return _context2.t1=_context2.sent,(animation=_context2.t0.clipAction.call(_context2.t0,_context2.t1)).setLoop(three_module.LoopRepeat,(null==onLoadedAnimation?void 0:onLoadedAnimation.loop)||1),animation.clampWhenFinished=!0,animation.play(),mixer.addEventListener("finished",(function(){animation.fadeOut(.5),setAnimationRunning(!1)})),_context2.abrupt("return",mixer);case 13:case"end":return _context2.stop()}}),_callee2)}))),[avatarNode.Armature,null==onLoadedAnimation?void 0:onLoadedAnimation.loop,animationClip]);return(0,index_673ef987_esm.A)(function(){var _ref4=(0,asyncToGenerator.Z)((0,regeneratorRuntime.Z)().mark((function _callee3(state,delta){var _yield$animationMixer;return(0,regeneratorRuntime.Z)().wrap((function _callee3$(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:return _context3.next=2,animationMixerAvatar;case 2:if(_context3.t1=_yield$animationMixer=_context3.sent,_context3.t0=null===_context3.t1,_context3.t0){_context3.next=6;break}_context3.t0=void 0===_yield$animationMixer;case 6:if(!_context3.t0){_context3.next=10;break}_context3.next=11;break;case 10:_yield$animationMixer.update(delta);case 11:case"end":return _context3.stop()}}),_callee3)})));return function(_x,_x2){return _ref4.apply(this,arguments)}}()),(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})};SpawnAnimation.__docgenInfo={description:"",methods:[],displayName:"SpawnAnimation"};var spawnAtom=__webpack_require__("./src/state/spawnAtom.ts"),Spawn=function Spawn(_ref){var _animationProps$onLoa,_animationProps$onLoa2,avatar=_ref.avatar,onSpawnFinish=_ref.onSpawnFinish,animationProps=(0,esm_react.Dv)(spawnAtom.O),usesMountEffect=(0,services.w9)(null==animationProps||null===(_animationProps$onLoa=animationProps.onLoadedEffect)||void 0===_animationProps$onLoa?void 0:_animationProps$onLoa.src),usesMountAnimation=(0,services.w9)(null==animationProps||null===(_animationProps$onLoa2=animationProps.onLoadedAnimation)||void 0===_animationProps$onLoa2?void 0:_animationProps$onLoa2.src),_React$useState=react.useState(usesMountEffect),_React$useState2=(0,slicedToArray.Z)(_React$useState,2),effectRunning=_React$useState2[0],setEffectRunning=_React$useState2[1],_React$useState3=react.useState(usesMountAnimation),_React$useState4=(0,slicedToArray.Z)(_React$useState3,2),animationRunning=_React$useState4[0],setAnimationRunning=_React$useState4[1];(0,react.useEffect)((function(){animationRunning||effectRunning||(0,services.DK)(onSpawnFinish)}),[onSpawnFinish,effectRunning,animationRunning]);return(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[usesMountEffect&&(0,jsx_runtime.jsx)(SpawnEffect,{onLoadedEffect:animationProps.onLoadedEffect,onLoadedEffectFinish:function onLoadedEffectFinish(){setEffectRunning(!1)}}),usesMountAnimation&&(0,jsx_runtime.jsx)(SpawnAnimation,{onLoadedAnimation:animationProps.onLoadedAnimation,avatar:avatar,onLoadedAnimationFinish:function onLoadedAnimationFinish(){setAnimationRunning(!1)}})]})};Spawn.__docgenInfo={description:"",methods:[],displayName:"Spawn"};var Model=function Model(_ref){var scene=_ref.scene,_ref$scale=_ref.scale,scale=void 0===_ref$scale?1:_ref$scale,modelRef=_ref.modelRef,onLoaded=_ref.onLoaded,onSpawnAnimationFinish=_ref.onSpawnAnimationFinish,bloom=_ref.bloom,materials=(0,index_673ef987_esm.C)(scene).materials,gl=(0,index_673ef987_esm.z)().gl,_useState=(0,react.useState)(!1),_useState2=(0,slicedToArray.Z)(_useState,2),isTouching=_useState2[0],setIsTouching=_useState2[1],_useState3=(0,react.useState)(null),_useState4=(0,slicedToArray.Z)(_useState3,2),touchEvent=_useState4[0],setTouchEvent=_useState4[1],setTouchingOn=function setTouchingOn(e){Client_service.Y&&window.TouchEvent&&e instanceof TouchEvent&&setTouchEvent(e),setIsTouching(!0)},setTouchingOff=function setTouchingOff(e){Client_service.Y&&window.TouchEvent&&e instanceof TouchEvent&&setTouchEvent(null),setIsTouching(!1)};(0,services._U)(scene);var onTouchMove=(0,react.useCallback)((function(event){if(isTouching&&event instanceof MouseEvent&&(scene.rotation.y+=.005*event.movementX),Client_service.Y&&isTouching&&window.TouchEvent&&event instanceof TouchEvent){var movementX=Math.round(event.touches[0].pageX-touchEvent.touches[0].pageX);scene.rotation.y+=.005*movementX,setTouchEvent(event)}}),[isTouching,touchEvent,scene]);(0,services.Zm)(materials,bloom),scene.traverse((function(object){var node=object;node.isMesh&&(node.castShadow=!0),"SkinnedMesh"===node.type&&(node.receiveShadow=!0)})),(0,react.useEffect)((function(){return(0,services.DK)(onLoaded)}),[scene,materials,onLoaded]),(0,react.useEffect)((function(){return gl.domElement.addEventListener("mousedown",setTouchingOn),gl.domElement.addEventListener("touchstart",setTouchingOn,{passive:!0}),window.addEventListener("mouseup",setTouchingOff),gl.domElement.addEventListener("touchend",setTouchingOff),gl.domElement.addEventListener("touchcancel",setTouchingOff),window.addEventListener("mousemove",onTouchMove),gl.domElement.addEventListener("touchmove",onTouchMove,{passive:!0}),function(){gl.domElement.removeEventListener("mousedown",setTouchingOn),gl.domElement.removeEventListener("touchstart",setTouchingOn),window.removeEventListener("mouseup",setTouchingOff),gl.domElement.removeEventListener("touchend",setTouchingOff),gl.domElement.removeEventListener("touchcancel",setTouchingOff),window.removeEventListener("mousemove",onTouchMove),gl.domElement.removeEventListener("touchmove",onTouchMove)}}));var spawnComponent=(0,react.useMemo)((function(){return(0,jsx_runtime.jsx)(Spawn,{avatar:scene,onSpawnFinish:onSpawnAnimationFinish})}),[onSpawnAnimationFinish]);return(0,jsx_runtime.jsxs)("group",{ref:modelRef,dispose:null,rotation:[0,0,0],children:[(0,jsx_runtime.jsx)("primitive",{object:scene,scale:scale}),spawnComponent]})};Model.__docgenInfo={description:"",methods:[],displayName:"Model",props:{scale:{defaultValue:{value:"1",computed:!1},required:!1}}}},"./src/components/Models/StaticModel/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{P:function(){return StaticModelContainer}});var objectSpread2=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/objectSpread2.js"),slicedToArray=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),react=__webpack_require__("./node_modules/react/index.js"),Model=__webpack_require__("./src/components/Models/Model/index.ts"),services=__webpack_require__("./src/services/index.ts"),index_673ef987_esm=__webpack_require__("./node_modules/@react-three/fiber/dist/index-673ef987.esm.js"),jsx_runtime=__webpack_require__("./node_modules/react/jsx-runtime.js"),StaticModel=function StaticModel(_ref){var modelSrc=_ref.modelSrc,modelRef=_ref.modelRef,_ref$scale=_ref.scale,scale=void 0===_ref$scale?1:_ref$scale,setModelFallback=_ref.setModelFallback,onLoaded=_ref.onLoaded,emotion=_ref.emotion,bloom=_ref.bloom,scene=(0,services.Jr)(modelSrc).scene,nodes=(0,index_673ef987_esm.C)(scene).nodes;return(0,services.Kx)(nodes,emotion),(0,services.xD)(nodes,setModelFallback),(0,jsx_runtime.jsx)(Model.H,{modelRef:modelRef,scene:scene,scale:scale,onLoaded:onLoaded,bloom:bloom})};StaticModel.__docgenInfo={description:"",methods:[],displayName:"StaticModel",props:{scale:{defaultValue:{value:"1",computed:!1},required:!1}}};var StaticModelContainer=function StaticModelContainer(props){var _useState=(0,react.useState)((0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})),_useState2=(0,slicedToArray.Z)(_useState,2),fallback=_useState2[0],setFallback=_useState2[1];return(0,jsx_runtime.jsx)(react.Suspense,{fallback:fallback,children:(0,jsx_runtime.jsx)(StaticModel,(0,objectSpread2.Z)({setModelFallback:setFallback},props))})};StaticModelContainer.__docgenInfo={description:"Contains model to handle suspense fallback.",methods:[],displayName:"StaticModelContainer"}},"./src/components/Scene/Environment.component.tsx":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{q:function(){return Environment}});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/react/index.js"),_react_three_drei__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./node_modules/@react-three/drei/core/Environment.js"),src_services_Environment_service__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./src/services/Environment.service.ts"),react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/react/jsx-runtime.js"),Environment=function Environment(_ref){var environment=_ref.environment,config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)((function(){return{files:environment in src_services_Environment_service__WEBPACK_IMPORTED_MODULE_1__.s$?(0,src_services_Environment_service__WEBPACK_IMPORTED_MODULE_1__.G2)(environment):environment}}),[environment]);return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_react_three_drei__WEBPACK_IMPORTED_MODULE_3__.qA,{files:config.files})};Environment.__docgenInfo={description:"",methods:[],displayName:"Environment"}},"./src/services/Animation.service.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:function(){return loadAnimationClip}});var _home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js"),_home_runner_work_visage_visage_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"),three_stdlib__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/three-stdlib/loaders/FBXLoader.js"),three_stdlib__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/three-stdlib/loaders/GLTFLoader.js"),fbxLoader=new three_stdlib__WEBPACK_IMPORTED_MODULE_0__.y,gltfLoader=new three_stdlib__WEBPACK_IMPORTED_MODULE_1__.E;function normaliseFbxAnimation(fbx){for(var index=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,tracks=fbx.animations[index].tracks,i=0;i0&&source.every(validateSource);if("string"==typeof source){var fileEndExpression=new RegExp(/(.glb|.fbx|.fbx[?].*|.glb[?].*)$/g),uploadFileExpression=new RegExp(/^data:application\/octet-stream;base64,/g),gltfModelExpression=new RegExp(/^data:model\/gltf-binary;base64,/g);return fileEndExpression.test(source)||uploadFileExpression.test(source)||gltfModelExpression.test(source)}return source instanceof Blob&&"model/gltf-binary"===source.type},isValidFormat=function isValidFormat(source){var isValid=validateSource(source);return source&&!isValid&&console.warn("Provided GLB/FBX is invalid. Check docs for supported formats: https://github.com/readyplayerme/visage"),isValid},clamp=function clamp(value,max,min){return Math.min(Math.max(min,value),max)},lerp=function lerp(start,end){var time=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.05;return start*(1-time)+end*time},normaliseMaterialsConfig=function normaliseMaterialsConfig(materials,bloomConfig){Object.values(materials).forEach((function(material){var mat=material;mat.map&&(mat.map.minFilter=three__WEBPACK_IMPORTED_MODULE_2__.LinearFilter,mat.depthWrite=!0),mat.name.toLowerCase().includes("hair")&&(mat.roughness=.9),mat.emissiveMap&&(mat.emissiveIntensity=(null==bloomConfig?void 0:bloomConfig.materialIntensity)||3.3,mat.toneMapped=!1)}))},useHeadMovement=function useHeadMovement(_ref){var nodes=_ref.nodes,_ref$isHalfBody=_ref.isHalfBody,isHalfBody=void 0!==_ref$isHalfBody&&_ref$isHalfBody,_ref$distance=_ref.distance,distance=void 0===_ref$distance?2:_ref$distance,_ref$activeRotation=_ref.activeRotation,activeRotation=void 0===_ref$activeRotation?.2:_ref$activeRotation,_ref$rotationMargin=_ref.rotationMargin,rotationMargin=void 0===_ref$rotationMargin?new three__WEBPACK_IMPORTED_MODULE_2__.Vector2(5,10):_ref$rotationMargin,_ref$enabled=_ref.enabled,enabled=void 0!==_ref$enabled&&_ref$enabled,rad=Math.PI/180,currentPos=new three__WEBPACK_IMPORTED_MODULE_2__.Vector2(0,0),targetPos=new three__WEBPACK_IMPORTED_MODULE_2__.Vector2(0,0),activeDistance=distance-(isHalfBody?1:0),eyeRotationOffsetX=isHalfBody?90*rad:0,neckBoneRotationOffsetX=(isHalfBody?-5:10)*rad,mapRange=function mapRange(value,inMin,inMax,outMin,outMax){return(clamp(value,inMax,inMin)-inMin)*(outMax-outMin)/(inMax-inMin)+outMin};(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__.A)((function(state){if(enabled&&nodes.Neck&&nodes.Head&&nodes.RightEye&&nodes.LeftEye){var cameraToHeadDistance=state.camera.position.distanceTo(nodes.Head.position),cameraRotation=Math.abs(state.camera.rotation.z);cameraToHeadDistance1&&void 0!==arguments[1]?arguments[1]:new Transform;return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("group",{children:Object.keys(nodes).map((function(key){var node=nodes[key];return"SkinnedMesh"===node.type?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("skinnedMesh",{castShadow:!0,receiveShadow:!0,scale:transform.scale,position:transform.position,rotation:transform.rotation,geometry:node.geometry,material:node.material,skeleton:node.skeleton,morphTargetInfluences:node.morphTargetInfluences||[]},node.name):"Mesh"===node.type?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("mesh",{castShadow:!0,receiveShadow:!0,scale:transform.scale,position:transform.position,rotation:transform.rotation,geometry:node.geometry,material:node.material,morphTargetInfluences:node.morphTargetInfluences||[]},node.name):null}))})}(nodes))}),[setter,nodes])},triggerCallback=function triggerCallback(callback){"function"==typeof callback&&callback()},expressions={blink:[{morphTarget:"eyesClosed",morphTargetIndex:-1,offset:0,duration:.2},{morphTarget:"eyeSquintLeft",morphTargetIndex:-1,offset:0,duration:.2},{morphTarget:"eyeSquintRight",morphTargetIndex:-1,offset:0,duration:.2}]},useIdleExpression=function useIdleExpression(expression,nodes){var headMesh=nodes.Wolf3D_Head||nodes.Wolf3D_Avatar,selectedExpression=expression in expressions?expressions[expression]:void 0,timeout=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(),duration=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(Number.POSITIVE_INFINITY);(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)((function(){if(null!=headMesh&&headMesh.morphTargetDictionary&&selectedExpression)for(var i=0;isection.offset){var pivot=(duration.current-section.offset)/section.duration*Math.PI,morphInfluence=Math.sin(pivot);headMesh.morphTargetInfluences[section.morphTargetIndex]=morphInfluence}}else headMesh.morphTargetInfluences[section.morphTargetIndex]=0}}}),[null==headMesh?void 0:headMesh.morphTargetInfluences,selectedExpression,duration.current,timeout.current]),setNextInterval=function setNextInterval(){duration.current=0;var delay=3e3*Math.random()+3e3;clearTimeout(timeout.current),timeout.current=setTimeout(setNextInterval,delay)};(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)((function(){return selectedExpression&&(timeout.current=setTimeout(setNextInterval,3e3)),function(){clearTimeout(timeout.current)}}),[selectedExpression]),(0,_react_three_fiber__WEBPACK_IMPORTED_MODULE_3__.A)((function(_,delta){headMesh&&selectedExpression&&animateExpression(delta)}))}},"./src/services/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{DK:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.DK},FB:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.FB},Jr:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.Jr},Kx:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.Kx},Zm:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.Zm},_U:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__._U},bu:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.bu},bx:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.bx},gT:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.gT},t7:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.t7},uZ:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.uZ},w9:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.w9},wx:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.wx},xD:function(){return _Models_service__WEBPACK_IMPORTED_MODULE_0__.xD}});var _Models_service__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./src/services/Models.service.tsx")},"./src/state/spawnAtom.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:function(){return spawnState}});var spawnState=(0,__webpack_require__("./node_modules/jotai/esm/vanilla.mjs").cn)({onLoadedEffect:null,onLoadedAnimation:null})}}]); \ No newline at end of file diff --git a/docs/iframe.html b/docs/iframe.html index e800b79d..69f58f68 100644 --- a/docs/iframe.html +++ b/docs/iframe.html @@ -348,7 +348,7 @@ window['DOCS_OPTIONS'] = {"defaultName":"Docs","autodocs":true};