1 | /*
|
2 | Copyright (c) 2020-present NAVER Corp.
|
3 | name: @egjs/view3d
|
4 | license: MIT
|
5 | author: NAVER Corp.
|
6 | repository: https://github.com/naver/egjs-view3d
|
7 | version: 1.1.0
|
8 | */
|
9 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("three"),require("three/examples/jsm/loaders/DRACOLoader"),require("three/examples/jsm/loaders/GLTFLoader"),require("three/examples/jsm/loaders/RGBELoader")):"function"==typeof define&&define.amd?define(["three","three/examples/jsm/loaders/DRACOLoader","three/examples/jsm/loaders/GLTFLoader","three/examples/jsm/loaders/RGBELoader"],t):(e=e||self).View3D=t(e.THREE,e.DRACOLoader,e.GLTFLoader$1,e.RGBELoader)}(this,function(R,n,i,r){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function s(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var _=function(){return(_=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function a(e,s,a,c){return new(a=a||Promise)(function(n,t){function i(e){try{r(c.next(e))}catch(e){t(e)}}function o(e){try{r(c.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(i,o)}r((c=c.apply(e,s||[])).next())})}function c(n,i){var o,r,s,e,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(s=2&t[0]?r.return:t[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,t[1])).done)return s;switch(r=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,r=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=i.call(n,a)}catch(e){t=[6,e],r=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,o,r=n.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(i=r.next()).done;)s.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function v(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e}var e=function(){function e(){this._listenerMap={}}var t=e.prototype;return t.on=function(e,t){var n=this._listenerMap,i=n[e];return i&&i.indexOf(t)<0?i.push(t):n[e]=[t],this},t.once=function(e,t){var n=this._listenerMap,i=n[e];return i&&i.indexOf(t)<0?i.push(t):n[e]=[t],this},t.off=function(e,t){var n=this._listenerMap;if(!e)return this._listenerMap={},this;if(!t)return delete n[e],this;var i=n[e];if(i){var o=i.indexOf(t);0<=o&&i.splice(o,1)}return this},t.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=this._listenerMap[e];return i&&i.forEach(function(e){e.apply(void 0,v(t))}),this},e}(),l=function(){function e(e){this._canvas=e,this._renderer=new R.WebGLRenderer({canvas:this._canvas,alpha:!0,antialias:!0,preserveDrawingBuffer:!0}),this._renderer.xr.enabled=!0,this._renderer.outputEncoding=R.sRGBEncoding,this._clock=new R.Clock(!1),this.enableShadow()}var t=e.prototype;return Object.defineProperty(t,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(t,"context",{get:function(){return this._renderer.context},enumerable:!1,configurable:!0}),Object.defineProperty(t,"size",{get:function(){return this._renderer.getSize(new R.Vector2)},set:function(e){this._renderer.setSize(e.x,e.y,!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"threeRenderer",{get:function(){return this._renderer},enumerable:!1,configurable:!0}),t.resize=function(){var e=this._renderer,t=this._canvas;e.xr.isPresenting||(e.setPixelRatio(window.devicePixelRatio),e.setSize(t.offsetWidth,t.offsetHeight,!1))},t.render=function(e,t){this._renderer.render(e.root,t.threeCamera)},t.setAnimationLoop=function(i){var o=this;this._clock.start(),this._renderer.setAnimationLoop(function(e,t){var n=o._clock.getDelta();i(n,t)})},t.stopAnimationLoop=function(){this._clock.stop(),this._renderer.setAnimationLoop(null)},t.enableShadow=function(){var e=this._renderer;e.shadowMap.enabled=!0,e.shadowMap.type=R.PCFSoftShadowMap},t.disableShadow=function(){this._renderer.shadowMap.enabled=!1},e}(),h=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","map","metalnessMap","normalMap","roughnessMap"],f=function(i){function o(e,t){var n=i.call(this,e)||this;return n.message=e,n.code=t,Object.setPrototypeOf(n,o.prototype),n.name="View3DError",n}return s(o,i),o}(Error),p={WRONG_TYPE:0,ELEMENT_NOT_FOUND:1,ELEMENT_NOT_CANVAS:2,WEBGL_NOT_SUPPORTED:3,ADD_CONTROL_FIRST:4,PROVIDE_WIDTH_OR_HEIGHT:5},m={WRONG_TYPE:function(e,t){return typeof e+" is not a "+t.map(function(e){return'"'+e+'"'}).join(" or ")+"."},ELEMENT_NOT_FOUND:function(e){return'Element with selector "'+e+'" not found.'},ELEMENT_NOT_CANVAS:function(e){return"Given element <"+e.tagName+"> is not a canvas."},WEBGL_NOT_SUPPORTED:"WebGL is not supported on this browser.",ADD_CONTROL_FIRST:"Control is enabled before setting a target element.",PROVIDE_WIDTH_OR_HEIGHT:"Either width or height should be given."};function b(e,t){var n=null;if("string"==typeof e){var i=(t||document).querySelector(e);if(!i)throw new f(m.ELEMENT_NOT_FOUND(e),p.ELEMENT_NOT_FOUND);n=i}else e&&e.nodeType===Node.ELEMENT_NODE&&(n=e);return n}function d(e){return!e||e<=0?[]:Array.apply(0,Array(e)).map(function(e,t){return t})}function g(e){return e*Math.PI/180}function y(e,t,n){return Math.max(Math.min(e,n),t)}function w(e,t){var n,i,o=-1;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(d(t.length)),s=r.next();!s.done;s=r.next()){var a=s.value;if(t[a]===e){o=a;break}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}return o}function E(e,t,n){return e*(1-n)+t*n}function P(e,t,n){var i=Math.abs(n-t);if(e<t)e=n-(t-e)%i;else if(n<e){e=t+(e-n)%i}return e}function O(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return e.forEach(function(n){Object.keys(n).forEach(function(e){var t=n[e];Array.isArray(i[e])&&Array.isArray(t)?i[e]=v(i[e],t):i[e]=t})}),i}function x(e){return Math.sin(e*Math.PI*2)}function T(e){return 1-Math.pow(1-e,3)}function C(e){var t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375}var S,t,I=function(){function e(){this._root=new R.Scene,this._userObjects=new R.Group,this._envObjects=new R.Group,this._envs=[];var e=this._root,t=this._userObjects,n=this._envObjects;t.name="userObjects",n.name="envObjects",e.add(t),e.add(n)}var t=e.prototype;return Object.defineProperty(t,"root",{get:function(){return this._root},enumerable:!1,configurable:!0}),Object.defineProperty(t,"environments",{get:function(){return this._envs},enumerable:!1,configurable:!0}),Object.defineProperty(t,"visible",{get:function(){return this._root.visible},enumerable:!1,configurable:!0}),t.update=function(t,n){this._envs.forEach(function(e){return e.fit(t,n)})},t.reset=function(){this.resetModel(),this.resetEnv()},t.resetModel=function(){this._removeChildsOf(this._userObjects)},t.resetEnv=function(){this._removeChildsOf(this._envObjects),this._envs=[],this._root.background=null,this._root.environment=null},t.add=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this._userObjects).add.apply(e,v(t))},t.addEnv=function(){for(var n=this,e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];e.forEach(function(e){var t;e.isObject3D?n._envObjects.add(e):(n._envs.push(e),(t=n._envObjects).add.apply(t,v(e.objects)))})},t.remove=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this._userObjects).remove.apply(e,v(t))},t.removeEnv=function(){for(var i=this,e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];e.forEach(function(e){var t;if(e.isObject3D)i._envObjects.remove(e);else{var n=w(e,i._envs);-1<n&&i._envs.splice(n,1),(t=i._envObjects).remove.apply(t,v(e.objects))}})},t.setBackground=function(e){this._root.background=e},t.setEnvMap=function(e){var t=e.texture?e.texture:e;this._root.environment=t},t.show=function(){this._root.visible=!0},t.hide=function(){this._root.visible=!1},t._removeChildsOf=function(e){for(e.traverse(function(e){if(e.isMesh){var t=e;t.geometry.dispose(),(Array.isArray(t.material)?t.material:[t.material]).forEach(function(t){h.forEach(function(e){t[e]&&t[e].dispose()})})}});0<e.children.length;)e.remove(e.children[0])},e}(),M=function(){function e(e,t){this._controls=[],this._canvas=e,this._camera=t}var t=e.prototype;return Object.defineProperty(t,"controls",{get:function(){return this._controls},enumerable:!1,configurable:!0}),t.clear=function(){this._controls.forEach(function(e){return e.destroy()}),this._controls=[]},t.add=function(e){var t=this._canvas;e.element||e.setElement(t),e.sync(this._camera),e.enable(),this._controls.push(e)},t.remove=function(e){var t=this._controls,n=w(e,t);if(n<0)return null;var i=t.splice(n,1)[0];return i.disable(),i},t.enableAll=function(){this._controls.forEach(function(e){return e.enable()}),this.syncToCamera()},t.disableAll=function(){this._controls.forEach(function(e){return e.disable()})},t.resize=function(t){this._controls.forEach(function(e){return e.resize(t)})},t.syncToCamera=function(){var t=this;this._controls.forEach(function(e){return e.sync(t._camera)})},t.update=function(e){var t=1e3*e,n=this._camera;this._controls.forEach(function(e){e.update(n,t)}),n.updatePosition()},e}(),L=function(){function e(e,t,n,i){void 0===i&&(i=new R.Vector3(0,0,0)),this.yaw=e,this.pitch=t,this.distance=n,this.pivot=i}return e.prototype.clone=function(){return new e(this.yaw,this.pitch,this.distance,this.pivot.clone())},e}(),j={__proto__:null,SINE_WAVE:x,EASE_OUT_CUBIC:T,EASE_OUT_BOUNCE:C},A=T,N=500,V={min:0,max:1},z=new L(0,0,100,new R.Vector3(0,0,0)),D={min:-1/0,max:1/0},G={min:-89.9,max:89.9},F={min:0,max:500},k=null,B="https://www.gstatic.com/draco/v1/decoders/",H=function(){function e(e){var t=void 0===e?{}:e,n=t.duration,i=void 0===n?N:n,o=t.loop,r=void 0!==o&&o,s=t.range,a=void 0===s?V:s,c=t.easing,u=void 0===c?A:c;this._duration=i,this._loop=r,this._range=a,this._easing=u,this._activated=!1,this.reset(0)}var t=e.prototype;return Object.defineProperty(t,"val",{get:function(){return this._val},enumerable:!1,configurable:!0}),Object.defineProperty(t,"start",{get:function(){return this._start},enumerable:!1,configurable:!0}),Object.defineProperty(t,"end",{get:function(){return this._end},enumerable:!1,configurable:!0}),Object.defineProperty(t,"progress",{get:function(){return this._progress},enumerable:!1,configurable:!0}),Object.defineProperty(t,"duration",{get:function(){return this._duration},set:function(e){this._duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"loop",{get:function(){return this._loop},set:function(e){this._loop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"range",{get:function(){return this._range},set:function(e){this._range=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"easing",{get:function(){return this._easing},set:function(e){this._easing=e},enumerable:!1,configurable:!0}),t.update=function(e){if(!this._activated)return 0;var t=this._start,n=this._end,i=this._duration,o=this._val,r=this._loop,s=this._progress+e/i;this._progress=(r?P:y)(s,0,1);var a=this._easing(this._progress);return this._val=E(t,n,a),!r&&1<=this._progress&&(this._activated=!1),this._val-o},t.reset=function(e){var t=this._range,n=y(e,t.min,t.max);this._start=n,this._end=n,this._val=n,this._progress=0,this._activated=!1},t.setEndDelta=function(e){var t=this._range;this._start=this._val,this._end=y(this._end+e,t.min,t.max),this._progress=0,this._activated=!0},e}(),W=function(){function e(e,t,n){var i=void 0===n?{}:n,o=i.duration,r=void 0===o?N:o,s=i.easing,a=void 0===s?A:s;this._enabled=!1,this._finishCallbacks=[],e=e.clone(),t=t.clone(),e.yaw=P(e.yaw,0,360),t.yaw=P(t.yaw,0,360),180<Math.abs(t.yaw-e.yaw)&&(t.yaw=t.yaw<e.yaw?t.yaw+360:t.yaw-360),this._motion=new H({duration:r,range:V,easing:a}),this._from=e,this._to=t}var t=e.prototype;return Object.defineProperty(t,"element",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"duration",{get:function(){return this._motion.duration},set:function(e){this._motion.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"easing",{get:function(){return this._motion.easing},set:function(e){this._motion.easing=e},enumerable:!1,configurable:!0}),t.destroy=function(){this.disable()},t.update=function(e,t){if(this._enabled){var n=this._from,i=this._to,o=this._motion;o.update(t);var r=o.val;e.yaw=E(n.yaw,i.yaw,r),e.pitch=E(n.pitch,i.pitch,r),e.distance=E(n.distance,i.distance,r),e.pivot=n.pivot.clone().lerp(i.pivot,r),1<=o.progress&&(this.disable(),this._finishCallbacks.forEach(function(e){return e()}))}},t.enable=function(){this._enabled||(this._enabled=!0,this._motion.reset(0),this._motion.setEndDelta(1))},t.disable=function(){this._enabled&&(this._enabled=!1)},t.onFinished=function(e){this._finishCallbacks.push(e)},t.clearFinished=function(){this._finishCallbacks=[]},t.resize=function(e){},t.setElement=function(e){},t.sync=function(e){},e}(),Q=function(){function e(e){this._minDistance=1,this._maxDistance=500,this._defaultPose=z,this._currentPose=this._defaultPose.clone(),this._threeCamera=new R.PerspectiveCamera,this._controller=new M(e,this)}var t=e.prototype;return Object.defineProperty(t,"threeCamera",{get:function(){return this._threeCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t,"controller",{get:function(){return this._controller},enumerable:!1,configurable:!0}),Object.defineProperty(t,"defaultPose",{get:function(){return this._defaultPose},enumerable:!1,configurable:!0}),Object.defineProperty(t,"currentPose",{get:function(){return this._currentPose.clone()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"yaw",{get:function(){return this._currentPose.yaw},set:function(e){this._currentPose.yaw=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"pitch",{get:function(){return this._currentPose.pitch},set:function(e){this._currentPose.pitch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"distance",{get:function(){return this._currentPose.distance},set:function(e){this._currentPose.distance=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"pivot",{get:function(){return this._currentPose.pivot},set:function(e){this._currentPose.pivot=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"minDistance",{get:function(){return this._minDistance},set:function(e){this._minDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"maxDistance",{get:function(){return this._maxDistance},set:function(e){this._maxDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"fov",{get:function(){return this._threeCamera.fov},set:function(e){this._threeCamera.fov=e,this._threeCamera.updateProjectionMatrix()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"renderWidth",{get:function(){return this.renderHeight*this._threeCamera.aspect},enumerable:!1,configurable:!0}),Object.defineProperty(t,"renderHeight",{get:function(){return 2*this.distance*Math.tan(g(this.fov/2))},enumerable:!1,configurable:!0}),Object.defineProperty(t,"pose",{set:function(e){this._currentPose=e,this._controller.syncToCamera()},enumerable:!1,configurable:!0}),t.reset=function(e,t){void 0===e&&(e=0),void 0===t&&(t=A);var n=this._controller,i=this._currentPose,o=this._defaultPose;if(e<=0)return this._currentPose=o.clone(),n.syncToCamera(),Promise.resolve();var r=new W(i,o);return r.duration=e,r.easing=t,new Promise(function(e){r.onFinished(function(){n.remove(r),n.syncToCamera(),e()}),n.add(r)})},t.resize=function(e){var t=this._threeCamera,n=e.x/e.y;t.aspect=n,t.updateProjectionMatrix(),this._controller.resize(e)},t.setDefaultPose=function(e){var t=this._defaultPose,n=e.yaw,i=e.pitch,o=e.distance,r=e.pivot;null!=n&&(t.yaw=n),null!=i&&(t.pitch=i),null!=o&&(t.distance=o),null!=r&&(t.pivot=r)},t.updatePosition=function(){this._clampCurrentPose();var e=this._threeCamera,t=this._currentPose,n=g(t.yaw),i=g(t.pitch),o=Math.max(t.distance+this._minDistance,1),r=new R.Vector3(0,0,0);r.y=o*Math.sin(i),r.z=o*Math.cos(i),r.x=r.z*Math.sin(-n),r.z=r.z*Math.cos(-n),r.add(t.pivot),e.position.copy(r),e.lookAt(t.pivot),e.updateProjectionMatrix()},t._clampCurrentPose=function(){var e=this._currentPose;e.yaw=P(e.yaw,0,360),e.pitch=y(e.pitch,G.min,G.max),e.distance=y(e.distance,this._minDistance,this._maxDistance)},e}(),U=function(){function e(e){this._mixer=new R.AnimationMixer(e),this._clips=[],this._actions=[]}var t=e.prototype;return Object.defineProperty(t,"clips",{get:function(){return this._clips},enumerable:!1,configurable:!0}),Object.defineProperty(t,"mixer",{get:function(){return this._mixer},enumerable:!1,configurable:!0}),t.setClips=function(e){var t=this._mixer;this._clips=e,this._actions=e.map(function(e){return t.clipAction(e)})},t.play=function(e){var t=this._actions[e];t&&t.play()},t.pause=function(e){var t=this._actions[e];t&&(t.timeScale=0)},t.resume=function(e){var t=this._actions[e];t&&(t.timeScale=1)},t.stop=function(e){var t=this._actions[e];t&&t.stop()},t.update=function(e){this._mixer.update(e)},t.reset=function(){var e=this._mixer;e.uncacheRoot(e.getRoot()),this._clips=[],this._actions=[]},e}(),q=function(){function e(e){this._view3d=e,this._sessions=[],this._currentSession=null}var t=e.prototype;return Object.defineProperty(t,"sessions",{get:function(){return this._sessions},enumerable:!1,configurable:!0}),Object.defineProperty(t,"currentSession",{get:function(){return this._currentSession},enumerable:!1,configurable:!0}),t.isAvailable=function(){return a(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return[4,Promise.all(this._sessions.map(function(e){return e.isAvailable()}))];case 1:return[2,e.sent().some(function(e){return!0===e})]}})})},t.addSession=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this._sessions).push.apply(e,v(t))},t.enter=function(){return a(this,void 0,void 0,function(){return c(this,function(e){return[2,this._enterSession(0,[])]})})},t.exit=function(){this._currentSession&&(this._currentSession.exit(this._view3d),this._currentSession=null)},t._enterSession=function(r,s){return a(this,void 0,void 0,function(){var t,n,i,o=this;return c(this,function(e){switch(e.label){case 0:return(t=this._view3d,n=this._sessions,r>=n.length)?(s.length<1&&s.push(new Error("No sessions available")),[2,Promise.reject(s)]):[4,(i=n[r]).isAvailable()];case 1:return e.sent()?[4,i.enter(t).then(function(){return i.isWebXRSession&&(o._currentSession=i).session.addEventListener("end",function(){o._currentSession=null}),s}).catch(function(e){return s.push(e),o._enterSession(r+1,s)})]:[2,this._enterSession(r+1,s)];case 2:return[2,e.sent()]}})})},e}(),Y="mousedown",Z="mousemove",X="mouseup",$="touchstart",J="touchmove",K="touchend",ee="wheel",te="resize",ne="contextmenu",ie="mouseenter",oe="mouseleave";(t=S=S||{})[t.LEFT=0]="LEFT",t[t.MIDDLE=1]="MIDDLE",t[t.RIGHT=2]="RIGHT";var re,se,ae,ce=function(n){function e(e){var r=n.call(this)||this;r.resize=function(){r._renderer.resize();var e=r._renderer.size;r._camera.resize(e),r.emit("resize",_(_({},e),{target:r}))},r.renderLoop=function(e){var t=r._renderer,n=r._scene,i=r._camera,o=r.controller;r._animator.update(e),o.update(e),r.emit("beforeRender",r),t.render(n,i),r.emit("afterRender",r)};var t=function(e){var t=b(e);if(!t)throw new f(m.WRONG_TYPE(e,["HTMLElement","string"]),p.WRONG_TYPE);if(!/^canvas$/i.test(t.tagName))throw new f(m.ELEMENT_NOT_CANVAS(t),p.ELEMENT_NOT_CANVAS);return t}(e);return r._renderer=new l(t),r._camera=new Q(t),r._scene=new I,r._animator=new U(r._scene.root),r._xr=new q(r),r._model=null,r.resize(),window.addEventListener(te,r.resize),r}s(e,n);var t=e.prototype;return Object.defineProperty(t,"renderer",{get:function(){return this._renderer},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t,"camera",{get:function(){return this._camera},enumerable:!1,configurable:!0}),Object.defineProperty(t,"controller",{get:function(){return this._camera.controller},enumerable:!1,configurable:!0}),Object.defineProperty(t,"animator",{get:function(){return this._animator},enumerable:!1,configurable:!0}),Object.defineProperty(t,"xr",{get:function(){return this._xr},enumerable:!1,configurable:!0}),Object.defineProperty(t,"model",{get:function(){return this._model},enumerable:!1,configurable:!0}),t.destroy=function(){this._scene.reset(),this.controller.clear(),this._model=null,window.removeEventListener(te,this.resize)},t.display=function(e,t){var n=void 0===t?{}:t,i=n.applySize,o=void 0===i||i,r=n.size,s=void 0===r?80:r,a=n.resetView,c=void 0===a||a,u=this._renderer,l=this._scene,h=this._camera,d=this._animator;o&&(e.size=s),l.resetModel(),c&&h.reset(),d.reset(),this._model=e,l.add(e.scene),d.setClips(e.animations),l.update(e),u.stopAnimationLoop(),u.setAnimationLoop(this.renderLoop)},e.VERSION="1.1.0",e}(e),ue=function(){function e(e){var t=e.scenes,n=e.animations,i=void 0===n?[]:n,o=e.fixSkinnedBbox,r=void 0!==o&&o,s=e.castShadow,a=void 0===s||s,c=e.receiveShadow,u=void 0!==c&&c;this._scene=new R.Group;var l=new R.Object3D;l.name="Pivot",l.add.apply(l,v(t)),this._scene.add(l),this._animations=i,this._fixSkinnedBbox=r,this._cachedLights=null,this._cachedMeshes=null,this._setInitialBbox();var h=this._initialBbox.getCenter(new R.Vector3);l.position.copy(h.negate()),this._moveInitialBboxToCenter(),this._originalSize=this.size,this.castShadow=a,this.receiveShadow=u}var t=e.prototype;return Object.defineProperty(t,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t,"animations",{get:function(){return this._animations},enumerable:!1,configurable:!0}),Object.defineProperty(t,"lights",{get:function(){return this._cachedLights?this._cachedLights:this._getAllLights()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"meshes",{get:function(){return this._cachedMeshes?this._cachedMeshes:this._getAllMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"bbox",{get:function(){return this._getTransformedBbox()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"initialBbox",{get:function(){return this._initialBbox.clone()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"size",{get:function(){return this._getTransformedBbox().getSize(new R.Vector3).length()},set:function(e){var t=this._scene,n=e/this._initialBbox.getSize(new R.Vector3).length();t.scale.setScalar(n),t.updateMatrix()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"fixSkinnedBbox",{get:function(){return this._fixSkinnedBbox},set:function(e){this._fixSkinnedBbox=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"originalSize",{get:function(){return this._originalSize},enumerable:!1,configurable:!0}),Object.defineProperty(t,"castShadow",{set:function(t){this.meshes.forEach(function(e){return e.castShadow=t})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"receiveShadow",{set:function(t){this.meshes.forEach(function(e){return e.receiveShadow=t})},enumerable:!1,configurable:!0}),t.moveToOrigin=function(){var e=this._scene,t=this._initialBbox.clone();t.min.multiply(e.scale),t.max.multiply(e.scale);var n=t.getCenter(new R.Vector3);e.position.copy(n.negate()),e.updateMatrix()},t._setInitialBbox=function(){this._scene.updateMatrixWorld(),this._fixSkinnedBbox&&this._hasSkinnedMesh()?this._initialBbox=this._getSkeletonBbox():this._initialBbox=(new R.Box3).setFromObject(this._scene)},t._getSkeletonBbox=function(){var d=new R.Box3;return this.meshes.forEach(function(s){if(s.isSkinnedMesh){var e=s.geometry,a=e.attributes.position,c=e.attributes.skinIndex,u=e.attributes.skinWeight,t=s.skeleton;t.update();for(var l=t.boneMatrices,h=new R.Matrix4,n=function(e){h.identity();var i=new R.Vector4;i.set(0,0,0,0);var o=new R.Vector4;o.set(a.getX(e),a.getY(e),a.getZ(e),1).applyMatrix4(s.bindMatrix);var t=[u.getX(e),u.getY(e),u.getZ(e),u.getW(e)],r=[c.getX(e),c.getY(e),c.getZ(e),c.getW(e)];t.forEach(function(e,t){var n=(new R.Matrix4).fromArray(l,16*r[t]);i.add(o.clone().applyMatrix4(n).multiplyScalar(e))});var n=(new R.Vector3).fromArray(i.applyMatrix4(s.bindMatrixInverse).toArray());n.applyMatrix4(s.matrixWorld),d.expandByPoint(n)},i=0;i<a.count;i++)n(i)}else d.expandByObject(s)}),d},t._moveInitialBboxToCenter=function(){var e=this._initialBbox.getCenter(new R.Vector3);this._initialBbox.translate(e.negate())},t._getAllLights=function(){var t=[];return this._scene.traverse(function(e){e.isLight&&t.push(e)}),this._cachedLights=t},t._getAllMeshes=function(){var t=[];return this._scene.traverse(function(e){e.isMesh&&t.push(e)}),this._cachedMeshes=t},t._hasSkinnedMesh=function(){return this.meshes.some(function(e){return e.isSkinnedMesh})},t._getTransformedBbox=function(){return this._initialBbox.clone().applyMatrix4(this._scene.matrix)},e}(),le={__proto__:null,ModelAnimator:U,Model:ue,Renderer:l,Scene:I,XRManager:q,Camera:Q,Controller:M,Pose:L},he=function(){function e(e){var t=this,n=void 0===e?{}:e,i=n.element,o=void 0===i?k:i,r=n.delay,s=void 0===r?2e3:r,a=n.delayOnMouseLeave,c=void 0===a?0:a,u=n.speed,l=void 0===u?1:u,h=n.pauseOnHover,d=void 0!==h&&h,_=n.canInterrupt,f=void 0===_||_,p=n.disableOnInterrupt,v=void 0!==p&&p;this._targetEl=null,this._enabled=!1,this._interrupted=!1,this._interruptionTimer=-1,this._hovering=!1,this._onMouseDown=function(e){t._canInterrupt&&(e.button!==S.LEFT&&e.button!==S.RIGHT||(t._interrupted=!0,t._clearTimeout(),window.addEventListener(X,t._onMouseUp,!1)))},this._onMouseUp=function(){window.removeEventListener(X,t._onMouseUp,!1),t._setUninterruptedAfterDelay(t._delay)},this._onTouchStart=function(){t._canInterrupt&&(t._interrupted=!0,t._clearTimeout())},this._onTouchEnd=function(){t._setUninterruptedAfterDelay(t._delay)},this._onMouseEnter=function(){t._pauseOnHover&&(t._interrupted=!0,t._hovering=!0)},this._onMouseLeave=function(){t._pauseOnHover&&(t._hovering=!1,t._setUninterruptedAfterDelay(t._delayOnMouseLeave))},this._onWheel=function(){t._canInterrupt&&(t._interrupted=!0,t._setUninterruptedAfterDelay(t._delay))};var m=b(o);m&&this.setElement(m),this._delay=s,this._delayOnMouseLeave=c,this._speed=l,this._pauseOnHover=d,this._canInterrupt=f,this._disableOnInterrupt=v}var t=e.prototype;return Object.defineProperty(t,"element",{get:function(){return this._targetEl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"delay",{get:function(){return this._delay},set:function(e){this._delay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"delayOnMouseLeave",{get:function(){return this._delayOnMouseLeave},set:function(e){this._delayOnMouseLeave=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"speed",{get:function(){return this._speed},set:function(e){this._speed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"pauseOnHover",{get:function(){return this._pauseOnHover},set:function(e){this._pauseOnHover=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"canInterrupt",{get:function(){return this._canInterrupt},set:function(e){this._canInterrupt=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"disableOnInterrupt",{get:function(){return this._disableOnInterrupt},set:function(e){this._disableOnInterrupt=e},enumerable:!1,configurable:!0}),t.destroy=function(){this.disable()},t.update=function(e,t){this._enabled&&(this._interrupted?this._disableOnInterrupt&&this.disable():e.yaw+=this._speed*t/100)},t.resize=function(e){},t.enable=function(){if(!this._enabled){if(!this._targetEl)throw new f(m.ADD_CONTROL_FIRST,p.ADD_CONTROL_FIRST);var e=this._targetEl;e.addEventListener(Y,this._onMouseDown,!1),e.addEventListener($,this._onTouchStart,!1),e.addEventListener(K,this._onTouchEnd,!1),e.addEventListener(ie,this._onMouseEnter,!1),e.addEventListener(oe,this._onMouseLeave,!1),e.addEventListener(ee,this._onWheel,!1),this._enabled=!0}},t.disable=function(){if(this._enabled&&this._targetEl){var e=this._targetEl;e.removeEventListener(Y,this._onMouseDown,!1),window.removeEventListener(X,this._onMouseUp,!1),e.removeEventListener($,this._onTouchStart,!1),e.removeEventListener(K,this._onTouchEnd,!1),e.removeEventListener(ie,this._onMouseEnter,!1),e.removeEventListener(oe,this._onMouseLeave,!1),e.removeEventListener(ee,this._onWheel,!1),this._enabled=!1,this._interrupted=!1,this._hovering=!1,this._clearTimeout()}},t.sync=function(e){},t.setElement=function(e){this._targetEl=e},t._setUninterruptedAfterDelay=function(e){var t=this;this._hovering||(this._clearTimeout(),0<e?this._interruptionTimer=window.setTimeout(function(){t._interrupted=!1,t._interruptionTimer=-1},e):(this._interrupted=!1,this._interruptionTimer=-1))},t._clearTimeout=function(){0<=this._interruptionTimer&&(window.clearTimeout(this._interruptionTimer),this._interruptionTimer=-1)},e}(),de="grab",_e="grabbing",fe=function(){function e(e){var o=this,t=void 0===e?{}:e,n=t.element,i=void 0===n?k:n,r=t.duration,s=void 0===r?N:r,a=t.easing,c=void 0===a?A:a,u=t.scale,l=void 0===u?new R.Vector2(1,1):u,h=t.useGrabCursor,d=void 0===h||h,_=t.scaleToElement,f=void 0===_||_;this._targetEl=null,this._screenScale=new R.Vector2(0,0),this._prevPos=new R.Vector2(0,0),this._enabled=!1,this._onMouseDown=function(e){if(e.button===S.LEFT){var t=o._targetEl;e.preventDefault(),t.focus?t.focus():window.focus(),o._prevPos.set(e.clientX,e.clientY),window.addEventListener(Z,o._onMouseMove,!1),window.addEventListener(X,o._onMouseUp,!1),o._setCursor(_e)}},this._onMouseMove=function(e){e.preventDefault();var t=o._prevPos,n=new R.Vector2(e.clientX,e.clientY).sub(t).multiply(o._userScale);o._scaleToElement&&n.multiply(o._screenScale),o._xMotion.setEndDelta(n.x),o._yMotion.setEndDelta(n.y),t.set(e.clientX,e.clientY)},this._onMouseUp=function(){o._prevPos.set(0,0),window.removeEventListener(Z,o._onMouseMove,!1),window.removeEventListener(X,o._onMouseUp,!1),o._setCursor(de)},this._onTouchStart=function(e){e.preventDefault();var t=e.touches[0];o._prevPos.set(t.clientX,t.clientY)},this._onTouchMove=function(e){if(!(1<e.touches.length)){!1!==e.cancelable&&e.preventDefault(),e.stopPropagation();var t=e.touches[0],n=o._prevPos,i=new R.Vector2(t.clientX,t.clientY).sub(n).multiply(o._userScale);o._scaleToElement&&i.multiply(o._screenScale),o._xMotion.setEndDelta(i.x),o._yMotion.setEndDelta(i.y),n.set(t.clientX,t.clientY)}},this._onTouchEnd=function(e){var t=e.touches[0];t?o._prevPos.set(t.clientX,t.clientY):o._prevPos.set(0,0)};var p=b(i);p&&this.setElement(p),this._userScale=l,this._useGrabCursor=d,this._scaleToElement=f,this._xMotion=new H({duration:s,range:D,easing:c}),this._yMotion=new H({duration:s,range:G,easing:c})}var t=e.prototype;return Object.defineProperty(t,"element",{get:function(){return this._targetEl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._userScale},set:function(e){this._userScale.copy(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"useGrabCursor",{get:function(){return this._useGrabCursor},set:function(e){e?(this._useGrabCursor=!0,this._setCursor(de)):(this._setCursor(""),this._useGrabCursor=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scaleToElement",{get:function(){return this._scaleToElement},set:function(e){this._scaleToElement=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),t.destroy=function(){this.disable()},t.update=function(e,t){var n=this._xMotion,i=this._yMotion,o=new R.Vector2(n.update(t),i.update(t));e.yaw+=o.x,e.pitch+=o.y},t.resize=function(e){this._screenScale.set(360/e.x,180/e.y)},t.enable=function(){if(!this._enabled){if(!this._targetEl)throw new f(m.ADD_CONTROL_FIRST,p.ADD_CONTROL_FIRST);var e=this._targetEl;e.addEventListener(Y,this._onMouseDown,!1),e.addEventListener($,this._onTouchStart,!1),e.addEventListener(J,this._onTouchMove,!1),e.addEventListener(K,this._onTouchEnd,!1),this._enabled=!0,this._setCursor(de)}},t.disable=function(){if(this._enabled&&this._targetEl){var e=this._targetEl;e.removeEventListener(Y,this._onMouseDown,!1),window.removeEventListener(Z,this._onMouseMove,!1),window.removeEventListener(X,this._onMouseUp,!1),e.removeEventListener($,this._onTouchStart,!1),e.removeEventListener(J,this._onTouchMove,!1),e.removeEventListener(K,this._onTouchEnd,!1),this._setCursor(""),this._enabled=!1}},t.sync=function(e){this._xMotion.reset(e.yaw),this._yMotion.reset(e.pitch)},t.setElement=function(e){this._targetEl=e,this.resize(new R.Vector2(e.offsetWidth,e.offsetHeight))},t._setCursor=function(e){var t=this._targetEl;this._useGrabCursor&&t&&this._enabled&&(t.style.cursor=e)},e}(),pe=function(){function e(e){var o=this,t=void 0===e?{}:e,n=t.element,i=void 0===n?k:n,r=t.easing,s=void 0===r?A:r,a=t.scale,c=void 0===a?new R.Vector2(1,1):a,u=t.useGrabCursor,l=void 0===u||u,h=t.scaleToElement,d=void 0===h||h;this._targetEl=null,this._enabled=!1,this._touchInitialized=!1,this._prevPos=new R.Vector2(0,0),this._screenSize=new R.Vector2(0,0),this._onMouseDown=function(e){if(e.button===S.RIGHT){var t=o._targetEl;e.preventDefault(),t.focus?t.focus():window.focus(),o._prevPos.set(e.clientX,e.clientY),window.addEventListener(Z,o._onMouseMove,!1),window.addEventListener(X,o._onMouseUp,!1),o._setCursor(_e)}},this._onMouseMove=function(e){e.preventDefault();var t=o._prevPos,n=new R.Vector2(e.clientX,e.clientY).sub(t).multiply(o._userScale);o._xMotion.setEndDelta(-n.x),o._yMotion.setEndDelta(n.y),t.set(e.clientX,e.clientY)},this._onMouseUp=function(){o._prevPos.set(0,0),window.removeEventListener(Z,o._onMouseMove,!1),window.removeEventListener(X,o._onMouseUp,!1),o._setCursor(de)},this._onTouchStart=function(e){2===e.touches.length&&(e.preventDefault(),o._prevPos.copy(o._getTouchesMiddle(e.touches)),o._touchInitialized=!0)},this._onTouchMove=function(e){if(2===e.touches.length){!1!==e.cancelable&&e.preventDefault(),e.stopPropagation();var t=o._prevPos,n=o._getTouchesMiddle(e.touches);if(!o._touchInitialized)return t.copy(n),void(o._touchInitialized=!0);var i=(new R.Vector2).subVectors(n,t).multiply(o._userScale);o._xMotion.setEndDelta(-i.x),o._yMotion.setEndDelta(i.y),t.copy(n)}},this._onTouchEnd=function(e){2===e.touches.length?(o._prevPos.copy(o._getTouchesMiddle(e.touches)),o._touchInitialized=!0):o._touchInitialized=!1},this._onContextMenu=function(e){e.preventDefault()};var _=b(i);_&&this.setElement(_),this._xMotion=new H({duration:0,range:D,easing:s}),this._yMotion=new H({duration:0,range:D,easing:s}),this._userScale=c,this._useGrabCursor=l,this._scaleToElement=d}var t=e.prototype;return Object.defineProperty(t,"element",{get:function(){return this._targetEl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._userScale},set:function(e){this._userScale.copy(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"useGrabCursor",{get:function(){return this._useGrabCursor},set:function(e){e?(this._useGrabCursor=!0,this._setCursor(de)):(this._setCursor(""),this._useGrabCursor=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scaleToElement",{get:function(){return this._scaleToElement},set:function(e){this._scaleToElement=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),t.destroy=function(){this.disable()},t.update=function(e,t){var n=this._screenSize,i=new R.Vector2(this._xMotion.update(t),this._yMotion.update(t)),o=new R.Vector3(1,0,0).applyQuaternion(e.threeCamera.quaternion),r=new R.Vector3(0,1,0).applyQuaternion(e.threeCamera.quaternion);if(this._scaleToElement){var s=new R.Vector2(e.renderWidth,e.renderHeight).divide(n);i.multiply(s)}e.pivot.add(o.multiplyScalar(i.x)),e.pivot.add(r.multiplyScalar(i.y))},t.resize=function(e){this._screenSize.copy(e)},t.enable=function(){if(!this._enabled){if(!this._targetEl)throw new f(m.ADD_CONTROL_FIRST,p.ADD_CONTROL_FIRST);var e=this._targetEl;e.addEventListener(Y,this._onMouseDown,!1),e.addEventListener($,this._onTouchStart,!1),e.addEventListener(J,this._onTouchMove,!1),e.addEventListener(K,this._onTouchEnd,!1),e.addEventListener(ne,this._onContextMenu,!1),this._enabled=!0,this._setCursor(de)}},t.disable=function(){if(this._enabled&&this._targetEl){var e=this._targetEl;e.removeEventListener(Y,this._onMouseDown,!1),window.removeEventListener(Z,this._onMouseMove,!1),window.removeEventListener(X,this._onMouseUp,!1),e.removeEventListener($,this._onTouchStart,!1),e.removeEventListener(J,this._onTouchMove,!1),e.removeEventListener(K,this._onTouchEnd,!1),e.removeEventListener(ne,this._onContextMenu,!1),this._setCursor(""),this._enabled=!1}},t.sync=function(e){this._xMotion.reset(0),this._yMotion.reset(0)},t.setElement=function(e){this._targetEl=e,this.resize(new R.Vector2(e.offsetWidth,e.offsetHeight))},t._setCursor=function(e){var t=this._targetEl;this._useGrabCursor&&t&&this._enabled&&(t.style.cursor=e)},t._getTouchesMiddle=function(e){return new R.Vector2(e[0].clientX+e[1].clientX,e[0].clientY+e[1].clientY).multiplyScalar(.5)},e}(),ve=function(){function e(e){var c=this,t=void 0===e?{}:e,n=t.element,i=void 0===n?k:n,o=t.duration,r=void 0===o?N:o,s=t.range,a=void 0===s?F:s,u=t.easing,l=void 0===u?A:u;this._scale=1,this._targetEl=null,this._scaleModifier=.25,this._prevTouchDistance=-1,this._enabled=!1,this._onWheel=function(e){if(0!==e.deltaY){e.preventDefault(),e.stopPropagation();var t=c._motion,n=c._scale*c._scaleModifier*e.deltaY;t.setEndDelta(n)}},this._onTouchMove=function(e){var t=e.touches;if(2===t.length){!1!==e.cancelable&&e.preventDefault(),e.stopPropagation();var n=c._motion,i=c._prevTouchDistance,o=new R.Vector2(t[0].pageX,t[0].pageY),r=new R.Vector2(t[1].pageX,t[1].pageY),s=o.sub(r).length()*c._scale*c._scaleModifier,a=-(s-i);c._prevTouchDistance=s,i<0||n.setEndDelta(a)}},this._onTouchEnd=function(){c._prevTouchDistance=-1};var h=b(i);h&&this.setElement(h),this._motion=new H({duration:r,range:a,easing:l})}var t=e.prototype;return Object.defineProperty(t,"element",{get:function(){return this._targetEl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._scale},set:function(e){this._scale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),t.destroy=function(){this.disable()},t.update=function(e,t){var n=this._motion;e.distance+=n.update(t)},t.resize=function(e){},t.enable=function(){if(!this._enabled){if(!this._targetEl)throw new f(m.ADD_CONTROL_FIRST,p.ADD_CONTROL_FIRST);var e=this._targetEl;e.addEventListener(ee,this._onWheel,!1),e.addEventListener(J,this._onTouchMove,!1),e.addEventListener(K,this._onTouchEnd,!1),this._enabled=!0}},t.disable=function(){if(this._enabled&&this._targetEl){var e=this._targetEl;e.removeEventListener(ee,this._onWheel,!1),e.removeEventListener(J,this._onTouchMove,!1),e.removeEventListener(K,this._onTouchEnd,!1),this._enabled=!1}},t.sync=function(e){this._motion.range.min=e.minDistance,this._motion.range.max=e.maxDistance,this._motion.reset(e.distance)},t.setElement=function(e){this._targetEl=e},e}(),me={__proto__:null,AnimationControl:W,AutoControl:he,Motion:H,OrbitControl:function(){function e(e){var t=void 0===e?{}:e,n=t.element,i=void 0===n?k:n,o=t.rotate,r=void 0===o?{}:o,s=t.translate,a=void 0===s?{}:s,c=t.distance,u=void 0===c?{}:c;this._enabled=!1,this._targetEl=b(i),this._rotateControl=new fe(_(_({},r),{element:r.element||this._targetEl})),this._translateControl=new pe(_(_({},a),{element:a.element||this._targetEl})),this._distanceControl=new ve(_(_({},u),{element:u.element||this._targetEl}))}var t=e.prototype;return Object.defineProperty(t,"element",{get:function(){return this._targetEl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"rotate",{get:function(){return this._rotateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"translate",{get:function(){return this._translateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"distance",{get:function(){return this._distanceControl},enumerable:!1,configurable:!0}),t.destroy=function(){this._rotateControl.destroy(),this._translateControl.destroy(),this._distanceControl.destroy()},t.update=function(e,t){this._rotateControl.update(e,t),this._translateControl.update(e,t),this._distanceControl.update(e,t)},t.resize=function(e){this._rotateControl.resize(e),this._translateControl.resize(e),this._distanceControl.resize(e)},t.enable=function(){if(!this._enabled){if(!this._targetEl)throw new f(m.ADD_CONTROL_FIRST,p.ADD_CONTROL_FIRST);this._rotateControl.enable(),this._translateControl.enable(),this._distanceControl.enable(),this._enabled=!0}},t.disable=function(){this._enabled&&this._targetEl&&(this._rotateControl.disable(),this._translateControl.disable(),this._distanceControl.disable(),this._enabled=!1)},t.sync=function(e){this._rotateControl.sync(e),this._translateControl.sync(e),this._distanceControl.sync(e)},t.setElement=function(e){this._targetEl=e,this._rotateControl.setElement(e),this._translateControl.setElement(e),this._distanceControl.setElement(e)},e}(),RotateControl:fe,TranslateControl:pe,DistanceControl:ve},be=function(){function e(){}var t=e.prototype;return t.load=function(e,i){var o=this;void 0===i&&(i={});var r=new n.DRACOLoader;return r.setCrossOrigin("anonymous"),r.setDecoderPath(B),r.manager=new R.LoadingManager,new Promise(function(n,t){r.load(e,function(e){var t=o._parseToModel(e,i);r.dispose(),n(t)},void 0,function(e){r.dispose(),t(e)})})},t._parseToModel=function(e,t){var n=void 0===t?{}:t,i=n.fixSkinnedBbox,o=void 0!==i&&i,r=n.color,s=void 0===r?16777215:r,a=n.point,c=void 0!==a&&a,u=n.pointOptions,l=void 0===u?{}:u;e.computeVertexNormals();var h=c?new R.PointsMaterial(_({color:s},l)):new R.MeshStandardMaterial({color:s}),d=c?new R.Points(e,h):new R.Mesh(e,h);return new ue({scenes:[d],fixSkinnedBbox:o})},e}(),ge=function(){function e(e,t,n){void 0===e&&(e="#ffffff"),void 0===t&&(t=1);var i=(void 0===n?{}:n).direction,o=void 0===i?new R.Vector3(-1,-1,-1):i;this._light=new R.DirectionalLight(e,t);var r=this._light;r.castShadow=!0,r.shadow.mapSize.width=2048,r.shadow.mapSize.height=2048,r.matrixAutoUpdate=!1,this._direction=o.clone().normalize()}var t=e.prototype;return Object.defineProperty(t,"objects",{get:function(){return[this._light,this._light.target]},enumerable:!1,configurable:!0}),Object.defineProperty(t,"light",{get:function(){return this._light},enumerable:!1,configurable:!0}),Object.defineProperty(t,"position",{get:function(){return this._light.position},enumerable:!1,configurable:!0}),Object.defineProperty(t,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),t.enableShadow=function(){this._light.castShadow=!0},t.disableShadow=function(){this._light.castShadow=!1},t.fit=function(e,t){var n=(void 0===t?{}:t).scale,i=void 0===n?1.5:n,o=e.bbox,r=this._light,s=this._direction,a=o.getSize(new R.Vector3).length(),c=o.getCenter(new R.Vector3),u=(new R.Vector3).addVectors(c,s.clone().negate().multiplyScalar(.5*a));r.position.copy(u),r.target.position.copy(c),r.updateMatrix();var l=r.shadow.camera;l.near=0,l.far=2*a,l.position.copy(u),l.lookAt(c),l.left=-1,l.right=1,l.top=1,l.bottom=-1,l.updateMatrixWorld(),l.updateProjectionMatrix();var h,d=[(h=o).min.clone(),new R.Vector3(h.min.x,h.min.y,h.max.z),new R.Vector3(h.min.x,h.max.y,h.min.z),new R.Vector3(h.min.x,h.max.y,h.max.z),new R.Vector3(h.max.x,h.min.y,h.min.z),new R.Vector3(h.max.x,h.min.y,h.max.z),new R.Vector3(h.max.x,h.max.y,h.min.z),h.max.clone()].map(function(e){return e.project(l)}),_=(new R.Box3).setFromPoints(d);l.left*=-i*_.min.x,l.right*=i*_.max.x,l.top*=i*_.max.y,l.bottom*=-i*_.min.y,l.updateProjectionMatrix()},e}(),ye=function(){function e(e){var t=void 0===e?{}:e,n=t.size,i=void 0===n?1e4:n,o=t.opacity,r=void 0===o?.3:o;this.geometry=new R.PlaneGeometry(i,i,100,100),this.material=new R.ShadowMaterial({opacity:r}),this.mesh=new R.Mesh(this.geometry,this.material);var s=this.mesh;s.rotateX(-Math.PI/2),s.receiveShadow=!0}var t=e.prototype;return Object.defineProperty(t,"objects",{get:function(){return[this.mesh]},enumerable:!1,configurable:!0}),Object.defineProperty(t,"opacity",{get:function(){return this.material.opacity},set:function(e){this.material.opacity=e},enumerable:!1,configurable:!0}),t.fit=function(e,t){var n=void 0===t?{}:t,i=n.floorPosition,o=n.floorRotation,r=void 0===o?new R.Quaternion(0,0,0,1):o,s=e.scene.position,a=new R.Vector3(0,1,0).applyQuaternion(r);if(i)this.mesh.position.copy(i.clone().add(a.clone().multiplyScalar(.001)));else{var c=e.bbox,u=c.getCenter(new R.Vector3).y-c.min.y,l=(new R.Vector3).addVectors(s,a.multiplyScalar(1e-4-u));this.mesh.position.copy(l)}var h=(new R.Quaternion).setFromEuler(new R.Euler(-Math.PI/2,0,0)),d=(new R.Quaternion).multiplyQuaternions(r,h);this.mesh.quaternion.copy(d),this.mesh.updateMatrix()},e}(),we={__proto__:null,AutoDirectionalLight:ge,ShadowPlane:ye},Ee={__proto__:null,GLTFLoader:function(){function e(){this._loader=new i.GLTFLoader,this._dracoLoader=new n.DRACOLoader;var e=this._loader;e.setCrossOrigin("anonymous");var t=this._dracoLoader;t.setDecoderPath(B),e.setDRACOLoader(t)}var t=e.prototype;return Object.defineProperty(t,"loader",{get:function(){return this._loader},enumerable:!1,configurable:!0}),Object.defineProperty(t,"dracoLoader",{get:function(){return this._dracoLoader},enumerable:!1,configurable:!0}),t.load=function(e,i){var o=this;void 0===i&&(i={});var r=this._loader;return r.manager=new R.LoadingManager,new Promise(function(n,t){r.load(e,function(e){var t=o._parseToModel(e,i);n(t)},void 0,function(e){t(e)})})},t.loadPreset=function(_,f,p){var v=this;void 0===p&&(p={});var m=this._loader;return(new R.FileLoader).loadAsync(f).then(function(d){return new Promise(function(i,o){var r=JSON.parse(d),s=R.LoaderUtils.extractUrlBase(f);_.scene.reset(),_.camera.reset(),_.animator.reset();var a=r.model,e=r.camera,t=r.env;_.camera.setDefaultPose({yaw:e.yaw,pitch:e.pitch}),_.camera.minDistance=e.distanceRange[0],_.camera.maxDistance=e.distanceRange[1],t.background&&_.scene.setBackground(new R.Color(t.background));var n=new ye;n.opacity=t.shadow.opacity,_.scene.addEnv(n);var c=t.ambient,u=new R.AmbientLight(new R.Color(c.color),c.intensity);_.scene.addEnv(u),[t.light1,t.light2,t.light3].forEach(function(e){var t=new R.Vector3(e.x,e.y,e.z).negate(),n=new ge(new R.Color(e.color),e.intensity,{direction:t});n.light.castShadow=e.castShadow,n.light.updateMatrixWorld(),_.scene.addEnv(n)});var l=!0,h=r.LOD.map(function(){return!1});r.LOD.forEach(function(e,n){var t=v._resolveURL(""+s+e,p.path||"");m.load(t,function(e){if(h[n]=!0,!h.slice(n+1).some(function(e){return e})){var t=v._parseToModel(e);_.display(t,{size:a.size,resetView:l}),l=!1,t.castShadow=a.castShadow,t.receiveShadow=a.receiveShadow,p.onLoad&&p.onLoad(t,n),n===r.LOD.length-1&&i(t)}},void 0,function(e){o(e)})})})})},t.loadFromFiles=function(a,c){var u=this;void 0===c&&(c={});function l(){h.forEach(function(e){URL.revokeObjectURL(e)})}var h=[];return new Promise(function(n,t){if(a.length<=0)t(new Error("No files found"));else{var e=a.find(function(e){return/\.(gltf|glb)$/i.test(e.name)});if(e){var r=new Map;a.forEach(function(e){r.set(e.name,e)});var i=URL.createObjectURL(e);h.push(i);var o=new R.LoadingManager;o.setURLModifier(function(e){var t=/[^\/|\\]+$/.exec(e),n=t&&t[0]||"";if(r.has(n)){var i=r.get(n),o=URL.createObjectURL(i);return h.push(o),o}return e});var s=u._loader;s.manager=o,s.load(i,function(e){var t=u._parseToModel(e,c);n(t),l()},void 0,function(e){t(e),l()})}else t(new Error("No glTF file found"))}})},t.parse=function(e,i,o){var r=this;void 0===o&&(o={});var s=this._loader;return s.manager=new R.LoadingManager,new Promise(function(n,t){s.parse(e,i,function(e){var t=r._parseToModel(e,o);n(t)},function(e){t(e)})})},t._parseToModel=function(e,t){var n=(void 0===t?{}:t).fixSkinnedBbox,i=void 0!==n&&n,o=new ue({scenes:e.scenes,animations:e.animations,fixSkinnedBbox:i});return o.meshes.forEach(function(e){(Array.isArray(e.material)?e.material:[e.material]).forEach(function(e){e.map&&(e.map.encoding=R.sRGBEncoding)})}),o},t._resolveURL=function(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)},e}(),DracoLoader:be,TextureLoader:function(){function e(e){this._renderer=e}var t=e.prototype;return t.load=function(n){return new Promise(function(e,t){(new R.TextureLoader).load(n,e,void 0,t)})},t.loadEquirectagularTexture=function(n){var i=this;return new Promise(function(t,e){(new R.TextureLoader).load(n,function(e){t(i._equirectToCubemap(e))},void 0,e)})},t.loadCubeTexture=function(n){return new Promise(function(e,t){(new R.CubeTextureLoader).load(n,e,void 0,t)})},t.loadHDRTexture=function(n,i){var o=this;return void 0===i&&(i=!0),new Promise(function(t,e){(new r.RGBELoader).load(n,function(e){t(i?o._equirectToCubemap(e):e)},void 0,e)})},t._equirectToCubemap=function(e){return new R.WebGLCubeRenderTarget(e.image.height).fromEquirectangularTexture(this._renderer.threeRenderer,e)},e}()},Pe=(re=document.createElement("a")).relList&&re.relList.supports&&re.relList.supports("ar"),Oe=navigator.xr&&navigator.xr.isSessionSupported,xe=window.XRSession&&window.XRSession.prototype.requestHitTestSource,Te=null!=window.XRDOMOverlayState,Ce="immersive-ar",Se="local",Ie="viewer",Me="selectstart",Re="selectend",Le="generic-touchscreen",je={requiredFeatures:["hit-test"]},Ae=function(e){return{optionalFeatures:["dom-overlay"],domOverlay:{root:e}}},Ne={},Ve=function(e,t){return"intent://arvr.google.com/scene-viewer/1.1?"+e+"#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;"+(t?"S.browser_fallback_url="+t+";":"")+"end;"},ze=function(e,t){return"intent://arvr.google.com/scene-viewer/1.1?"+e+"#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;"+(t?"S.browser_fallback_url="+t+";":"")+"end;"},De=function(e){return"https://arvr.google.com/scene-viewer?"+e},Ge=function(){function e(e){this._root=e.root,this._loadingEl=e.loadingEl}var t=e.prototype;return Object.defineProperty(t,"root",{get:function(){return this._root},enumerable:!1,configurable:!0}),Object.defineProperty(t,"loadingElement",{get:function(){return this._loadingEl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"features",{get:function(){return Ae(this._root)},enumerable:!1,configurable:!0}),t.isAvailable=function(){return Te},t.showLoading=function(){this._loadingEl&&(this._loadingEl.style.visibility="visible")},t.hideLoading=function(){this._loadingEl&&(this._loadingEl.style.visibility="hidden")},e}(),Fe=function(p){function e(e){var t=void 0===e?{}:e,n=t.features,i=void 0===n?Ne:n,o=t.maxModelSize,r=void 0===o?1/0:o,s=t.overlayRoot,a=void 0===s?k:s,c=t.loadingEl,u=void 0===c?k:c,l=t.forceOverlay,h=void 0!==l&&l,d=p.call(this)||this;d.isWebXRSession=!0,d._session=null,d._domOverlay=null;var _=b(a),f=[];return _&&(d._domOverlay=new Ge({root:_,loadingEl:b(u,_)}),f.push(d._domOverlay.features)),d._features=O.apply(void 0,v([{}],f,[i])),d._maxModelSize=r,d._forceOverlay=h,d}s(e,p);var t=e.prototype;return Object.defineProperty(t,"session",{get:function(){return this._session},enumerable:!1,configurable:!0}),Object.defineProperty(t,"features",{get:function(){return this._features},enumerable:!1,configurable:!0}),t.isAvailable=function(){var e=this._domOverlay;return!Oe||!xe||this._forceOverlay&&e&&!e.isAvailable()?Promise.resolve(!1):navigator.xr.isSessionSupported(Ce)},t.enter=function(l){var h=this;if(!l.model)return Promise.reject("3D Model is not loaded");var r=l.model;return navigator.xr.requestSession(Ce,this._features).then(function(a){var e=l.renderer,c=e.threeRenderer,u={view3d:l,model:r,session:a},t=r.scene.matrix.clone(),n=r.size,i=l.scene.root.background,o=Math.min(r.originalSize,h._maxModelSize);r.size=o,r.moveToOrigin(),l.scene.setBackground(null),c.xr.setReferenceSpaceType(Se),c.xr.setSession(a),c.setPixelRatio(1),h.onStart(u),a.addEventListener("end",function(){h.onEnd(u),r.scene.matrix.copy(t),r.scene.matrix.decompose(r.scene.position,r.scene.quaternion,r.scene.scale),r.size=n,r.moveToOrigin(),l.scene.update(r),l.scene.setBackground(i),c.xr.setSession(null),c.setPixelRatio(window.devicePixelRatio),e.stopAnimationLoop(),e.setAnimationLoop(l.renderLoop)},{once:!0}),e.stopAnimationLoop(),e.setAnimationLoop(function(e,t){var n=c.xr.getCamera(new R.PerspectiveCamera),i=c.xr.getReferenceSpace(),o=a.renderState.baseLayer,r={width:o.framebufferWidth,height:o.framebufferHeight},s=_(_({},u),{delta:e,frame:t,referenceSpace:i,xrCam:n,size:r});h._beforeRender(s),l.renderLoop(e)})})},t.exit=function(e){e.renderer.threeRenderer.xr.getSession().end()},t.onStart=function(e){var t;this._session=e.session,null!==(t=this._domOverlay)&&void 0!==t&&t.showLoading(),this.emit("start")},t.onEnd=function(e){var t;(this._session=null)!==(t=this._domOverlay)&&void 0!==t&&t.hideLoading(),this.emit("end")},e}(e),ke=function(){function e(){this._source=null}var t=e.prototype;return Object.defineProperty(t,"ready",{get:function(){return null!=this._source},enumerable:!1,configurable:!0}),Object.defineProperty(t,"features",{get:function(){return je},enumerable:!1,configurable:!0}),t.destroy=function(){this._source&&(this._source.cancel(),this._source=null)},t.init=function(t){var n=this;t.requestReferenceSpace(Ie).then(function(e){t.requestHitTestSource({space:e}).then(function(e){n._source=e})})},t.isAvailable=function(){return xe},t.getResults=function(e){return e.getHitTestResults(this._source)},e}(),Be=function(h){function e(e){var t=void 0===e?{}:e,n=t.context,i=void 0===n?window:n,o=t.repeat,r=void 0===o?0:o,s=t.duration,a=void 0===s?N:s,c=t.easing,u=void 0===c?T:c,l=h.call(this)||this;return l._loop=function(){var e=l._getDeltaTime(),t=l._duration;l._time+=e;var n=Math.floor(l._time/t);l._time=P(l._time,0,t);var i=l._time/t,o={progress:i,easedProgress:l._easing(i)};l.emit("progress",o);for(var r=0;r<n;r++){if(l._loopCount++,l._loopCount>l._repeat)return l.emit("finish"),void l.stop();l.emit("loop",_(_({},o),{loopIndex:l._loopCount}))}l._rafId=l._ctx.requestAnimationFrame(l._loop)},l._repeat=r,l._duration=a,l._easing=u,l._ctx=i,l._rafId=-1,l._time=0,l._clock=0,l._loopCount=0,l}s(e,h);var t=e.prototype;return t.start=function(){0<=this._rafId||(this._updateClock(),this._loop())},t.stop=function(){this._rafId<0||(this._time=0,this._loopCount=0,this._stopLoop())},t.pause=function(){this._rafId<0||this._stopLoop()},t._stopLoop=function(){this._ctx.cancelAnimationFrame(this._rafId),this._rafId=-1},t._getDeltaTime=function(){var e=this._clock;return this._updateClock(),this._clock-e},t._updateClock=function(){this._clock=Date.now()},e}(e),He=function(){function e(e){var t=void 0===e?{}:e,n=t.ringColor,i=void 0===n?16777215:n,o=t.axisColor,r=void 0===o?16777215:o,s=new R.RingGeometry(.99,1,150,1,0,2*Math.PI),a=new R.MeshBasicMaterial({color:i,side:R.DoubleSide});this._ring=new R.Mesh(s,a);var c=[new R.Vector3(0,0,-1e3),new R.Vector3(0,0,1e3)],u=(new R.BufferGeometry).setFromPoints(c),l=new R.LineBasicMaterial({color:r});this._axis=new R.Line(u,l),this._obj=new R.Group,this._obj.add(this._ring),this._obj.add(this._axis),this.hide()}var t=e.prototype;return Object.defineProperty(t,"object",{get:function(){return this._obj},enumerable:!1,configurable:!0}),t.show=function(){this._obj.visible=!0},t.hide=function(){this._obj.visible=!1},t.updatePosition=function(e){this._obj.position.copy(e)},t.updateScale=function(e){this._ring.scale.setScalar(e)},t.updateRotation=function(e){this._obj.quaternion.copy(e)},e}(),We=function(){function e(e){var t=void 0===e?{}:e,n=t.scale,i=void 0===n?1:n,o=t.showIndicator,r=void 0===o||o;this.rotation=new R.Quaternion,this._axis=new R.Vector3(0,1,0),this._enabled=!0,this._active=!1,this._prevPos=new R.Vector2,this._fromQuat=new R.Quaternion,this._toQuat=new R.Quaternion,this._motion=new H({range:D}),this._userScale=i,r&&(this._rotationIndicator=new He)}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._userScale},set:function(e){this._userScale=e},enumerable:!1,configurable:!0}),t.init=function(e){var t=e.view3d,n=t.model.scene.quaternion;this.updateRotation(n),this._rotationIndicator&&t.scene.add(this._rotationIndicator.object)},t.destroy=function(e){var t=e.view3d;this._rotationIndicator&&t.scene.remove(this._rotationIndicator.object)},t.updateRotation=function(e){this.rotation.copy(e),this._fromQuat.copy(e),this._toQuat.copy(e)},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1},t.activate=function(e,t){var n=e.view3d;if(this._enabled){this._active=!0;var i=n.model,o=this._rotationIndicator;o&&(o.show(),o.updatePosition(i.bbox.getCenter(new R.Vector3)),o.updateScale(i.size/2),o.updateRotation(i.scene.quaternion))}},t.deactivate=function(){this._active=!1,this._rotationIndicator&&this._rotationIndicator.hide()},t.updateAxis=function(e){this._axis.copy(e)},t.setInitialPos=function(e){this._prevPos.copy(e[0])},t.process=function(e,t){var n=e.view3d,i=e.xrCam,o=t.coords;if(this._active&&1===o.length){var r,s,a,c,u,l,h=this._prevPos,d=this._motion,_=n.model,f=o[0],p=_.scene.position.clone(),v=(new R.Vector2).fromArray(p.project(i).toArray()),m=(r=v,s=h,a=f,c=(new R.Vector2).subVectors(s,r).normalize(),u=(new R.Vector2).subVectors(a,r).normalize().angle()-c.angle(),l=-Math.sign(u)*(2*Math.PI-Math.abs(u)),(Math.abs(u)<Math.abs(l)?u:l)*this._userScale),b=(new R.Quaternion).setFromAxisAngle(this._axis,m),g=this._getInterpolatedQuaternion();this._fromQuat.copy(g),this._toQuat.premultiply(b),d.reset(0),d.setEndDelta(1),h.copy(f)}},t.update=function(e,t){var n=e.model;if(this._active){this._motion.update(t);var i=this._getInterpolatedQuaternion();this.rotation.copy(i),n.scene.quaternion.copy(i)}},t._getInterpolatedQuaternion=function(){var e=this._motion,t=this._toQuat,n=this._fromQuat,i=e.val;return(new R.Quaternion).copy(n).slerp(t,i)},e}();(ae=se=se||{})[ae.WAITING=0]="WAITING",ae[ae.TRANSLATING=1]="TRANSLATING",ae[ae.BOUNCING=2]="BOUNCING";var Qe,Ue,qe,Ye,Ze=function(){function e(e){var t=void 0===e?{}:e,n=t.hoverAmplitude,i=void 0===n?.01:n,o=t.hoverHeight,r=void 0===o?.1:o,s=t.hoverPeriod,a=void 0===s?1e3:s,c=t.hoverEasing,u=void 0===c?x:c,l=t.bounceDuration,h=void 0===l?1e3:l,d=t.bounceEasing,_=void 0===d?C:d;this._modelPosition=new R.Vector3,this._hoverPosition=new R.Vector3,this._floorPosition=new R.Vector3,this._dragPlane=new R.Plane,this._enabled=!0,this._state=se.WAITING,this._initialPos=new R.Vector2,this._hoverAmplitude=i,this._hoverHeight=r,this._hoverMotion=new H({loop:!0,duration:a,easing:u}),this._bounceMotion=new H({duration:h,easing:_,range:D})}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"modelPosition",{get:function(){return this._modelPosition.clone()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"floorPosition",{get:function(){return this._floorPosition.clone()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"hoverAmplitude",{get:function(){return this._hoverAmplitude},set:function(e){this._hoverAmplitude=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"hoverHeight",{get:function(){return this._hoverHeight},set:function(e){this._hoverHeight=e},enumerable:!1,configurable:!0}),t.initFloorPosition=function(e){this._modelPosition.copy(e),this._floorPosition.copy(e),this._hoverPosition.copy(e),this._hoverPosition.setY(e.y+this._hoverHeight)},t.init=function(e){},t.destroy=function(e){},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1,this.deactivate()},t.activate=function(e,t){var n=e.model;if(this._enabled){var i=n.bbox,o=i.getCenter(new R.Vector3).y-i.min.y;this._dragPlane.set(new R.Vector3(0,1,0),-(this._floorPosition.y+this._hoverHeight+o)),this._hoverMotion.reset(0),this._hoverMotion.setEndDelta(1),this._state=se.TRANSLATING}},t.deactivate=function(){if(this._enabled&&this._state!==se.WAITING){this._state=se.BOUNCING;var e=this._floorPosition,t=this._modelPosition,n=this._hoverPosition,i=this._bounceMotion,o=t.y-e.y;i.reset(t.y),i.setEndDelta(-o),n.copy(e),n.setY(e.y+this._hoverHeight)}else this._state=se.WAITING},t.setInitialPos=function(e){this._initialPos.copy(e[0])},t.process=function(e,t){var n=e.view3d,i=e.model,o=e.frame,r=e.referenceSpace,s=e.xrCam,a=t.hitResults,c=this._state,u=c===se.WAITING||c===se.BOUNCING;if(a&&1===a.length&&!u){var l=a[0],h=this._floorPosition.clone(),d=this._floorPosition,_=this._hoverPosition,f=this._hoverHeight,p=this._dragPlane,v=i.bbox,m=v.getCenter(new R.Vector3).y-v.min.y,b=l.results[0]&&l.results[0].getPose(r),g=b&&.75<=b.transform.matrix[5],y=(new R.Vector3).setFromMatrixPosition(s.matrixWorld);if(b&&g){var w=(new R.Matrix4).fromArray(b.transform.matrix),E=(new R.Vector3).setFromMatrixPosition(w),P=-p.constant,O=E.y+f+m;.1<O-P&&(p.constant=-O);var x=(new R.Vector3).subVectors(E,y).normalize(),T=new R.Ray(y,x).intersectPlane(p,new R.Vector3);T&&(d.copy(T),d.setY(E.y),_.copy(T),_.setY(T.y-m))}else{var C=o.getPose(l.inputSource.targetRaySpace,n.renderer.threeRenderer.xr.getReferenceSpace()),S=(new R.Vector3).copy(C.transform.position).sub(y).normalize(),I=new R.Ray(y,S).intersectPlane(p,new R.Vector3);I&&(d.copy(I),d.setY(h.y),_.copy(I),_.setY(I.y-m))}}},t.update=function(e,t){var n=e.model,i=this._state,o=this._modelPosition,r=this._hoverPosition;if(i!==se.WAITING){if(i!==se.BOUNCING){var s=this._hoverMotion;s.update(t);var a=s.val*this._hoverAmplitude;o.copy(r),o.setY(r.y+a)}else{var c=this._bounceMotion;c.update(t),o.setY(c.val),1<=c.progress&&(this._state=se.WAITING)}var u=n.bbox,l=u.getCenter(new R.Vector3).y-u.min.y;n.scene.position.copy(o.clone().setY(o.y+l))}},e}(),Xe=function(){function e(e){var t=void 0===e?{}:e,n=t.width,i=void 0===n?.1:n,o=t.padding,r=void 0===o?20:o,s=t.offset,a=void 0===s?.05:s,c=t.font,u=void 0===c?"64px sans-serif":c,l=t.color,h=void 0===l?"white":l,d=document.createElement("canvas"),_=d.getContext("2d");_.font=u;var f=_.measureText("100%"),p=f.actualBoundingBoxLeft+f.actualBoundingBoxRight,v=f.actualBoundingBoxAscent+f.actualBoundingBoxDescent,m=function(e){for(var t=1;t<e;)t*=2;return t}(p);d.width=m;var b=i*((d.height=m)/p);this._ctx=_,this._canvas=d,this._height=b*v/p,this._texture=new R.CanvasTexture(d);var g=new R.PlaneGeometry(b,b),y=new R.Mesh(g,new R.MeshBasicMaterial({map:this._texture,transparent:!0}));y.matrixAutoUpdate=!1,this._mesh=y,this._font=u,this._color=h,this._padding=r,this._offset=a}var t=e.prototype;return Object.defineProperty(t,"mesh",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),Object.defineProperty(t,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t,"visible",{get:function(){return this._mesh.visible},enumerable:!1,configurable:!0}),t.updatePosition=function(e,t){var n=this._mesh;n.lookAt(t),n.position.copy(e),n.position.setY(e.y+this._height/2+this._offset),n.updateMatrix()},t.updateScale=function(e){var t=this._ctx,n=this._canvas,i=this._padding,o=(100*e).toFixed(0);t.clearRect(0,0,n.width,n.height);var r=n.width/2,s=n.height/2,a=t.measureText(o+"%"),c=(a.actualBoundingBoxLeft+a.actualBoundingBoxRight)/2,u=(a.actualBoundingBoxAscent+a.actualBoundingBoxDescent)/2;t.beginPath(),t.moveTo(r-c,s-u-i),t.lineTo(r+c,s-u-i),t.quadraticCurveTo(r+c+i,s-u-i,r+c+i,s-u),t.lineTo(r+c+i,s+u),t.quadraticCurveTo(r+c+i,s+u+i,r+c,s+u+i),t.lineTo(r-c,s+u+i),t.quadraticCurveTo(r-c-i,s+u+i,r-c-i,s+u),t.lineTo(r-c-i,s-u),t.quadraticCurveTo(r-c-i,s-u-i,r-c,s-u-i),t.closePath(),t.lineWidth=5,t.fillStyle="rgba(0, 0, 0, 0.3)",t.fill(),t.stroke(),t.font=this._font,t.textAlign="center",t.textBaseline="middle",t.strokeStyle=this._color,t.fillStyle=this._color,t.fillText(o+"%",r,s),this._texture.needsUpdate=!0},t.show=function(){this._mesh.visible=!0},t.hide=function(){this._mesh.visible=!1},e}(),$e=function(){function e(e){var t=void 0===e?{}:e,n=t.min,i=void 0===n?.05:n,o=t.max,r=void 0===o?2:o;this._enabled=!0,this._active=!1,this._prevCoordDistance=-1,this._scaleMultiplier=1,this._initialScale=new R.Vector3,this._ui=new Xe,this._motion=new H({duration:0,range:{min:i,max:r}}),this._motion.reset(1),this._ui=new Xe}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._initialScale.clone().multiplyScalar(this._scaleMultiplier)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scaleMultiplier",{get:function(){return this._scaleMultiplier},enumerable:!1,configurable:!0}),Object.defineProperty(t,"range",{get:function(){return this._motion.range},enumerable:!1,configurable:!0}),t.init=function(e){var t=e.view3d;this._initialScale.copy(t.model.scene.scale),t.scene.add(this._ui.mesh)},t.destroy=function(e){e.view3d.scene.remove(this._ui.mesh)},t.setInitialPos=function(e){this._prevCoordDistance=(new R.Vector2).subVectors(e[0],e[1]).length()},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1,this.deactivate()},t.activate=function(e,t){this._active=!0,this._ui.show(),this._updateUIPosition(e)},t.deactivate=function(){this._active=!1,this._ui.hide(),this._prevCoordDistance=-1},t.setRange=function(e,t){this._motion.range={min:e,max:t}},t.process=function(e,t){var n=t.coords;if(2===n.length&&this._enabled&&this._active){var i=this._motion,o=(new R.Vector2).subVectors(n[0],n[1]).length(),r=o-this._prevCoordDistance;i.setEndDelta(r),this._prevCoordDistance=o,this._updateUIPosition(e)}},t.update=function(e,t){var n=e.model;if(this._enabled&&this._active){var i=this._motion;i.update(t),this._scaleMultiplier=i.val,this._ui.updateScale(this._scaleMultiplier),n.scene.scale.copy(this.scale)}},t._updateUIPosition=function(e){var t=e.view3d,n=e.xrCam,i=t.model,o=(new R.Vector3).setFromMatrixPosition(n.matrixWorld),r=i.scene.position.clone().setY(i.bbox.max.y);this._ui.updatePosition(r,o)},e}(),Je=function(){function e(e){var t=void 0===e?{}:e,n=t.ringOpacity,i=void 0===n?.3:n,o=t.dirIndicatorOpacity,r=void 0===o?1:o,s=t.fadeoutDuration,a=void 0===s?1e3:s,c=Math.PI/18,u=new R.RingGeometry(.975,1,150,1,-6*c,30*c),l=new R.CircleGeometry(.1,30,0,2*Math.PI);u.merge(l);var h=new R.RingGeometry(.96,1.015,30,1,25*c,4*c),d=h.vertices,_=d.slice(Math.floor(11*d.length/16),Math.floor(13*d.length/16)),f=_[0].y,p=Math.floor(_.length/2);_.forEach(function(e,t){var n=.025*(p-Math.abs(t-p));e.setY(f-n)});var v=(new R.Matrix4).makeRotationX(-Math.PI/2),m=new R.Geometry;m.merge(u,v,0),m.merge(h,v,1);var b=[new R.MeshBasicMaterial({transparent:!0,opacity:i,color:16777215}),new R.MeshBasicMaterial({transparent:!0,opacity:r,color:16777215})];this._mesh=new R.Mesh(m,b),this._mesh.matrixAutoUpdate=!1,this._animator=new H({duration:a}),this._opacityRange={min:i,max:r}}var t=e.prototype;return Object.defineProperty(t,"mesh",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),t.update=function(e){var t=e.delta,n=e.scale,i=e.position,o=e.rotation,r=this._mesh,s=this._animator;if(this._mesh.visible){s.update(t);var a=this._mesh.material,c=a[0],u=a[1],l=this._opacityRange;c.opacity=s.val*l.min,u.opacity=s.val*l.max,s.val<=0&&(r.visible=!1),r.scale.setScalar(n),r.position.copy(i),r.quaternion.copy(o),r.updateMatrix()}},t.show=function(){this._mesh.visible=!0,this._animator.reset(1)},t.fadeout=function(){this._animator.setEndDelta(-1)},e}();(Ue=Qe=Qe||{})[Ue.NONE=0]="NONE",Ue[Ue.ONE_FINGER_HORIZONTAL=1]="ONE_FINGER_HORIZONTAL",Ue[Ue.ONE_FINGER_VERTICAL=2]="ONE_FINGER_VERTICAL",Ue[Ue.ONE_FINGER=3]="ONE_FINGER",Ue[Ue.TWO_FINGER_HORIZONTAL=4]="TWO_FINGER_HORIZONTAL",Ue[Ue.TWO_FINGER_VERTICAL=8]="TWO_FINGER_VERTICAL",Ue[Ue.TWO_FINGER=12]="TWO_FINGER",Ue[Ue.PINCH=16]="PINCH",(Ye=qe=qe||{})[Ye.WAITING=0]="WAITING",Ye[Ye.IN_DEADZONE=1]="IN_DEADZONE",Ye[Ye.OUT_OF_DEADZONE=2]="OUT_OF_DEADZONE";var Ke,et,tt=function(){function e(e){var t=(void 0===e?{}:e).size,n=void 0===t?.1:t;this._state=qe.WAITING,this._detectedGesture=Qe.NONE,this._testingGestures=Qe.NONE,this._lastFingerCount=0,this._aspect=1,this._prevOneFingerPos=new R.Vector2,this._prevTwoFingerPos=new R.Vector2,this._initialTwoFingerDistance=0,this._prevOneFingerPosInitialized=!1,this._prevTwoFingerPosInitialized=!1,this._size=n}var t=e.prototype;return Object.defineProperty(t,"size",{get:function(){return this._size},set:function(e){this._size=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"inDeadzone",{get:function(){return this._state===qe.IN_DEADZONE},enumerable:!1,configurable:!0}),t.setAspect=function(e){this._aspect=e},t.setFirstInput=function(e){var t=e.length;1!==t||this._prevOneFingerPosInitialized?2!==t||this._prevTwoFingerPosInitialized||(this._prevTwoFingerPos.copy((new R.Vector2).addVectors(e[0],e[1]).multiplyScalar(.5)),this._initialTwoFingerDistance=(new R.Vector2).subVectors(e[0],e[1]).length(),this._prevTwoFingerPosInitialized=!0):(this._prevOneFingerPos.copy(e[0]),this._prevOneFingerPosInitialized=!0),this._lastFingerCount=t,this._state=qe.IN_DEADZONE},t.addTestingGestures=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._testingGestures=this._testingGestures|e.reduce(function(e,t){return e|t},Qe.NONE)},t.cleanup=function(){this._testingGestures=Qe.NONE,this._lastFingerCount=0,this._prevOneFingerPosInitialized=!1,this._prevTwoFingerPosInitialized=!1,this._initialTwoFingerDistance=0,this._detectedGesture=Qe.NONE,this._state=qe.WAITING},t.applyScreenAspect=function(e){var t=this._aspect;e.forEach(function(e){1<t?e.setY(e.y*t):e.setX(e.x/t)})},t.check=function(e){var t=this._state,n=this._size,i=this._testingGestures,o=this._lastFingerCount,r=e.length;if(t===qe.OUT_OF_DEADZONE)return this._detectedGesture;if(this._lastFingerCount=r,this.applyScreenAspect(e),r!==o)return this.setFirstInput(e),Qe.NONE;if(1===r){var s=e[0],a=this._prevOneFingerPos.clone();(c=(new R.Vector2).subVectors(s,a)).length()>n&&(Math.abs(c.x)>Math.abs(c.y)?Qe.ONE_FINGER_HORIZONTAL&i&&(this._detectedGesture=Qe.ONE_FINGER_HORIZONTAL):Qe.ONE_FINGER_VERTICAL&i&&(this._detectedGesture=Qe.ONE_FINGER_VERTICAL))}else if(2===r){var c,u=(new R.Vector2).addVectors(e[1],e[0]).multiplyScalar(.5);a=this._prevTwoFingerPos.clone();(c=(new R.Vector2).subVectors(u,a)).length()>n&&(Math.abs(c.x)>Math.abs(c.y)?Qe.TWO_FINGER_HORIZONTAL&i&&(this._detectedGesture=Qe.TWO_FINGER_HORIZONTAL):Qe.TWO_FINGER_VERTICAL&i&&(this._detectedGesture=Qe.TWO_FINGER_VERTICAL));var l=(new R.Vector2).subVectors(e[1],e[0]).length();Math.abs(l-this._initialTwoFingerDistance)>n&&Qe.PINCH&i&&(this._detectedGesture=Qe.PINCH)}return this._detectedGesture!==Qe.NONE&&(this._state=qe.OUT_OF_DEADZONE),this._detectedGesture},e}(),nt=function(){function e(e){var v=this;void 0===e&&(e={}),this._enabled=!0,this._initialized=!1,this._modelHit=!1,this._hitTestSource=null,this.onSelectStart=function(e){var t=e.view3d,n=e.frame,i=e.xrCam,o=e.referenceSpace,r=v._hitTestSource;if(r&&v._enabled){var s=v._deadzoneChecker,a=v._rotateControl,c=v._translateControl,u=v._scaleControl;a.enabled&&s.addTestingGestures(Qe.ONE_FINGER),c.enabled&&s.addTestingGestures(Qe.ONE_FINGER),u.enabled&&s.addTestingGestures(Qe.PINCH);var l=n.getHitTestResultsForTransientInput(r),h=v._hitResultToVector(l);if(s.applyScreenAspect(h),s.setFirstInput(h),1===h.length){var d=t.model.bbox,_=n.getPose(l[0].inputSource.targetRaySpace,o),f=(new R.Vector3).setFromMatrixPosition(i.matrixWorld),p=(new R.Vector3).copy(_.transform.position).sub(f).normalize();new R.Ray(f,p).intersectBox(d,new R.Vector3)&&(v._modelHit=!0)}v._floorIndicator.show()}},this.onSelectEnd=function(){v.deactivate(),v._floorIndicator.fadeout()},this._rotateControl=new We(_({showIndicator:!1},e.rotate)),this._translateControl=new Ze(e.translate),this._scaleControl=new $e(e.scale),this._floorIndicator=new Je(e.floorIndicator),this._deadzoneChecker=new tt(e.deadzone)}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"rotate",{get:function(){return this._rotateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"translate",{get:function(){return this._translateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._scaleControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"controls",{get:function(){return[this._rotateControl,this._translateControl,this._scaleControl]},enumerable:!1,configurable:!0}),t.init=function(t,e){var n=this,i=t.session,o=t.view3d,r=t.size;this.controls.forEach(function(e){return e.init(t)}),this._translateControl.initFloorPosition(e),this._deadzoneChecker.setAspect(r.height/r.width),o.scene.add(this._floorIndicator.mesh),this._initialized=!0,i.requestHitTestSourceForTransientInput({profile:Le}).then(function(e){n._hitTestSource=e})},t.destroy=function(t){this._initialized&&(this._hitTestSource&&(this._hitTestSource.cancel(),this._hitTestSource=null),t.view3d.scene.remove(this._floorIndicator.mesh),this.deactivate(),this.controls.forEach(function(e){return e.destroy(t)}),this._initialized=!1)},t.deactivate=function(){this._modelHit=!1,this._deadzoneChecker.cleanup(),this.controls.forEach(function(e){return e.deactivate()})},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1,this.deactivate()},t.update=function(e){var t=e.view3d,n=e.session,i=e.frame,o=this._hitTestSource;if(o&&t.model){var r=this._deadzoneChecker,s=n.inputSources,a=i.getHitTestResultsForTransientInput(o),c={coords:this._hitResultToVector(a),inputSources:s,hitResults:a};r.inDeadzone?this._checkDeadzone(e,c):this._processInput(e,c),this._updateControls(e)}},t._checkDeadzone=function(e,t){var n=t.coords,i=this._deadzoneChecker.check(n.map(function(e){return e.clone()})),o=this._rotateControl,r=this._translateControl,s=this._scaleControl;if(i!==Qe.NONE)switch(i){case Qe.ONE_FINGER_HORIZONTAL:case Qe.ONE_FINGER_VERTICAL:this._modelHit?(r.activate(e,i),r.setInitialPos(n)):(o.activate(e,i),o.setInitialPos(n));break;case Qe.PINCH:s.activate(e,i),s.setInitialPos(n)}},t._processInput=function(t,n){this.controls.forEach(function(e){return e.process(t,n)})},t._updateControls=function(t){var e=t.view3d,n=t.model,i=1e3*t.delta;this.controls.forEach(function(e){return e.update(t,i)}),n.scene.updateMatrix();var o=this._rotateControl.rotation,r=this._translateControl.floorPosition;e.scene.update(n,{floorPosition:r});var s=this._scaleControl,a=n.initialBbox;a.min.multiply(s.scale),a.max.multiply(s.scale);var c=this._floorIndicator,u=a.getBoundingSphere(new R.Sphere);c.update({delta:i,scale:u.radius,position:r,rotation:o})},t._hitResultToVector=function(e){return e.map(function(e){return(new R.Vector2).set(e.inputSource.gamepad.axes[0],-e.inputSource.gamepad.axes[1])})},e}(),it=function(o){function e(e){void 0===e&&(e={});var i=o.call(this,e)||this;return i.onStart=function(e){var t=e.view3d,n=e.session;o.prototype.onStart.call(i,e),i._control=new nt(i._options),t.scene.hide(),i._hitTest.init(n)},i.onEnd=function(e){var t=e.view3d,n=e.session;o.prototype.onEnd.call(i,e),i._renderContext=null,i._modelPlaced=!1,n.removeEventListener(Me,i._onSelectStart),n.removeEventListener(Re,i._onSelectEnd),i._hitTest.destroy(),i._control.destroy(e),i._control=null,t.scene.show()},i._beforeRender=function(e){i._renderContext=e,i._modelPlaced?i._control.update(e):i._initModelPosition(e)},i._onSelectStart=function(e){i._control.onSelectStart(_(_({},i._renderContext),{frame:e.frame}))},i._onSelectEnd=function(){i._control.onSelectEnd()},i._control=null,i._renderContext=null,i._modelPlaced=!1,i._hitTest=new ke,i._features=O(i._features,i._hitTest.features),i._options=e,i}s(e,o);var t=e.prototype;return Object.defineProperty(t,"control",{get:function(){return this._control},enumerable:!1,configurable:!0}),t._initModelPosition=function(e){var t,n=e.view3d,i=e.frame,o=e.session,r=n.model,s=this._hitTest;if(s.ready&&r){var a=this._control,c=n.renderer.threeRenderer.xr.getReferenceSpace(),u=s.getResults(i);if(!(u.length<=0)){var l=u[0],h=(new R.Matrix4).fromArray(l.getPose(c).transform.matrix);if(!(h.elements[5]<.75)){var d=r.scene,_=(new R.Vector3).setFromMatrixPosition(h);d.quaternion.set(0,0,0,1),d.position.copy(_),d.position.setY(d.position.y-r.bbox.min.y),d.updateMatrix(),n.scene.update(r),n.scene.show(),this.emit("canPlace"),s.destroy(),o.addEventListener(Me,this._onSelectStart),o.addEventListener(Re,this._onSelectEnd),null!==(t=this._domOverlay)&&void 0!==t&&t.hideLoading(),this._modelPlaced=!0,this.emit("modelPlaced");var f=d.scale.clone(),p=new Be({context:o});p.on("progress",function(e){var t=f.clone().multiplyScalar(e.easedProgress);d.scale.copy(t)}),p.on("finish",function(){d.scale.copy(f),a.init(e,_)}),p.start()}}}},e}(Fe),ot=function(){function e(e){var n=this,t=(void 0===e?{}:e).color,i=void 0===t?16777215:t,o=new R.CylinderBufferGeometry(.1,.1,1),r=new R.CylinderBufferGeometry(0,.5,1,30,1);o.translate(0,.5,0),r.translate(0,1.5,0);var s=new R.Mesh(o,new R.MeshBasicMaterial({color:i})),a=new R.Mesh(r,new R.MeshBasicMaterial({color:i})),c=new R.Group;c.add(s),c.add(a),this._arrows=[c],this._obj=new R.Group,this._obj.add(c),d(3).forEach(function(e){var t=c.clone(!0);t.rotateZ(Math.PI/2*(e+1)),n._obj.add(t),n._arrows.push(t)}),this.hide()}var t=e.prototype;return Object.defineProperty(t,"object",{get:function(){return this._obj},enumerable:!1,configurable:!0}),t.show=function(){this._obj.visible=!0},t.hide=function(){this._obj.visible=!1},t.updatePosition=function(e){this._obj.position.copy(e)},t.updateOffset=function(i){this._arrows.forEach(function(e,t){var n=new R.Vector3(0,1,0).applyQuaternion(e.quaternion).multiply(i);e.position.copy(n)})},t.updateScale=function(t){this._arrows.forEach(function(e){return e.scale.setScalar(t)})},t.updateRotation=function(e){this._obj.quaternion.copy(e)},e}(),rt=function(){function e(e){void 0===e&&(e={}),this.position=new R.Vector3,this.wallPosition=new R.Vector3,this.hitRotation=new R.Quaternion,this.wallRotation=new R.Quaternion,this._dragPlane=new R.Plane,this._enabled=!0,this._active=!1,this._initialPos=new R.Vector2,this._arrowIndicator=new ot(e.arrow)}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),t.initWallTransform=function(e){var t=e.hitPosition,n=e.hitRotation,i=e.modelPosition,o=e.wallRotation;this.position.copy(i),this.hitRotation.copy(n),this.wallPosition.copy(t),this.wallRotation.copy(o);var r=new R.Vector3(0,1,0).applyQuaternion(o);this._dragPlane.set(r,-r.dot(i))},t.init=function(e){e.view3d.scene.add(this._arrowIndicator.object)},t.destroy=function(e){e.view3d.scene.remove(this._arrowIndicator.object)},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1,this.deactivate()},t.activate=function(e,t){var n=e.model;if(this._enabled){this._active=!0;var i=this._arrowIndicator,o=n.initialBbox;o.min.multiply(n.scene.scale),o.max.multiply(n.scene.scale),o.translate(n.scene.position),i.show(),i.updatePosition(o.getCenter(new R.Vector3)),i.updateScale(n.size/16);var r=n.scene.quaternion.clone();i.updateRotation(r),i.updateOffset((new R.Vector3).subVectors(o.max,o.min).multiplyScalar(.5))}},t.deactivate=function(){this._active=!1,this._arrowIndicator.hide()},t.setInitialPos=function(e){this._initialPos.copy(e[0])},t.process=function(e,t){var n=e.view3d,i=e.model,o=e.frame,r=e.referenceSpace,s=e.xrCam,a=t.hitResults;if(a&&1===a.length&&this._active){var c=this._dragPlane,u=i.scene,l=-i.initialBbox.min.z*u.scale.z,h=(new R.Vector3).setFromMatrixPosition(s.matrixWorld),d=a[0],_=d.results[0]&&d.results[0].getPose(r),f=_&&_.transform.matrix[5]<.25;if(_&&f){var p=(new R.Matrix4).fromArray(_.transform.matrix),v=(new R.Quaternion).copy(_.transform.orientation),m=(new R.Vector3).setFromMatrixPosition(p),b=new R.Vector3(0,1,0),g=new R.Vector3(0,1,0).applyQuaternion(v).normalize(),y=(new R.Vector3).crossVectors(b,g),w=g.clone().applyAxisAngle(y,-Math.PI/2),E=(new R.Matrix4).makeBasis(y,w,g),P=m.clone().add(g.clone().multiplyScalar(l));this.position.copy(P),this.wallPosition.copy(m);var O=new R.Vector3(0,1,0).applyQuaternion(this.hitRotation).normalize();if(Math.acos(Math.abs(O.dot(g)))>=Math.PI/18){var x=this.wallRotation.clone(),T=(new R.Quaternion).setFromRotationMatrix(E),C=x.inverse().premultiply(T);u.quaternion.premultiply(C),this.wallRotation.copy(T),this.hitRotation.copy(v),this._arrowIndicator.updateRotation(u.quaternion),c.set(g,-P.dot(g))}}else{var S=o.getPose(d.inputSource.targetRaySpace,n.renderer.threeRenderer.xr.getReferenceSpace()),I=(new R.Vector3).copy(S.transform.position).sub(h).normalize(),M=new R.Ray(h,I).intersectPlane(c,new R.Vector3);M&&(this.wallPosition.copy(M.clone().sub(c.normal.clone().multiplyScalar(l))),this.position.copy(M))}}},t.update=function(e,t){var n=e.model;n.scene.position.copy(this.position),this._arrowIndicator.updatePosition(this.position),n.scene.updateMatrix()},e}(),st=function(){function e(e){var m=this;void 0===e&&(e={}),this._enabled=!0,this._initialized=!1,this._modelHit=!1,this._hitTestSource=null,this.onSelectStart=function(e){var t=e.view3d,n=e.session,i=e.frame,o=e.referenceSpace,r=e.xrCam,s=m._hitTestSource;if(s&&m._enabled){var a=m._deadzoneChecker,c=m._rotateControl,u=m._translateControl,l=m._scaleControl;c.enabled&&a.addTestingGestures(Qe.ONE_FINGER),u.enabled&&a.addTestingGestures(Qe.ONE_FINGER),l.enabled&&a.addTestingGestures(Qe.PINCH);var h=i.getHitTestResultsForTransientInput(s),d=m._hitResultToVector(h);if(a.applyScreenAspect(d),a.setFirstInput(d),1===d.length){var _=t.model.bbox,f=i.getPose(n.inputSources[0].targetRaySpace,o),p=(new R.Vector3).setFromMatrixPosition(r.matrixWorld),v=(new R.Vector3).copy(f.transform.position).sub(p).normalize();new R.Ray(p,v).intersectBox(_,new R.Vector3)&&(m._modelHit=!0)}m._floorIndicator.show()}},this.onSelectEnd=function(){m.deactivate(),m._floorIndicator.fadeout()},this._rotateControl=new We(_(_({},e.rotate),{showIndicator:!1})),this._translateControl=new rt(e.translate),this._scaleControl=new $e(e.scale),this._floorIndicator=new Je(e.floorIndicator),this._deadzoneChecker=new tt(e.deadzone)}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"rotate",{get:function(){return this._rotateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"translate",{get:function(){return this._translateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._scaleControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"controls",{get:function(){return[this._rotateControl,this._translateControl,this._scaleControl]},enumerable:!1,configurable:!0}),t.init=function(t,e){var n=this,i=t.session,o=t.view3d,r=t.size;this.controls.forEach(function(e){return e.init(t)}),this._translateControl.initWallTransform(e),this._deadzoneChecker.setAspect(r.height/r.width),o.scene.add(this._floorIndicator.mesh),this._initialized=!0,i.requestHitTestSourceForTransientInput({profile:Le}).then(function(e){n._hitTestSource=e})},t.destroy=function(t){this._initialized&&(this._hitTestSource&&(this._hitTestSource.cancel(),this._hitTestSource=null),t.view3d.scene.remove(this._floorIndicator.mesh),this.deactivate(),this.controls.forEach(function(e){return e.destroy(t)}),this._initialized=!1)},t.deactivate=function(){this._modelHit=!1,this._deadzoneChecker.cleanup(),this.controls.forEach(function(e){return e.deactivate()})},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1,this.deactivate()},t.update=function(e){var t=e.view3d,n=e.session,i=e.frame,o=this._hitTestSource;if(o&&t.model){var r=this._deadzoneChecker,s=n.inputSources,a=i.getHitTestResultsForTransientInput(o),c={coords:this._hitResultToVector(a),inputSources:s,hitResults:a};r.inDeadzone?this._checkDeadzone(e,c):this._processInput(e,c),this._updateControls(e)}},t._checkDeadzone=function(e,t){var n=t.coords,i=e.model,o=this._deadzoneChecker.check(n.map(function(e){return e.clone()})),r=this._rotateControl,s=this._translateControl,a=this._scaleControl;if(o!==Qe.NONE)switch(o){case Qe.ONE_FINGER_HORIZONTAL:case Qe.ONE_FINGER_VERTICAL:this._modelHit?(s.activate(e,o),s.setInitialPos(n)):(r.activate(e,o),r.updateAxis(new R.Vector3(0,1,0).applyQuaternion(s.hitRotation)),r.updateRotation(i.scene.quaternion),r.setInitialPos(n));break;case Qe.PINCH:a.activate(e,o),a.setInitialPos(n)}},t._processInput=function(t,n){this.controls.forEach(function(e){return e.process(t,n)})},t._updateControls=function(t){var e=t.view3d,n=t.model,i=1e3*t.delta;this.controls.forEach(function(e){return e.update(t,i)}),n.scene.updateMatrix();var o=this._translateControl,r=o.wallPosition;e.scene.update(n,{floorPosition:r,floorRotation:o.hitRotation});var s=this._scaleControl,a=n.initialBbox;a.min.multiply(s.scale),a.max.multiply(s.scale);var c=this._floorIndicator,u=a.getBoundingSphere(new R.Sphere),l=(new R.Quaternion).setFromEuler(new R.Euler(Math.PI/2,0,0)),h=n.scene.quaternion.clone().multiply(l);c.update({delta:i,scale:u.radius,position:r,rotation:h})},t._hitResultToVector=function(e){return e.map(function(e){return(new R.Vector2).set(e.inputSource.gamepad.axes[0],-e.inputSource.gamepad.axes[1])})},e}(),at=function(o){function e(e){void 0===e&&(e={});var i=o.call(this,e)||this;return i.onStart=function(e){var t=e.view3d,n=e.session;o.prototype.onStart.call(i,e),i._control=new st(i._options),t.scene.hide(),i._hitTest.init(n)},i.onEnd=function(e){var t=e.view3d,n=e.session;o.prototype.onEnd.call(i,e),i._renderContext=null,i._modelPlaced=!1,n.removeEventListener(Me,i._onSelectStart),n.removeEventListener(Re,i._onSelectEnd),i._hitTest.destroy(),i._control.destroy(e),i._control=null,t.scene.show()},i._beforeRender=function(e){i._renderContext=e,i._modelPlaced?i._control.update(e):i._initModelPosition(e)},i._onSelectStart=function(e){i._control.onSelectStart(_(_({},i._renderContext),{frame:e.frame}))},i._onSelectEnd=function(){i._control.onSelectEnd()},i._control=null,i._renderContext=null,i._modelPlaced=!1,i._hitTest=new ke,i._features=O(i._features,i._hitTest.features),i._options=e,i}s(e,o);var t=e.prototype;return Object.defineProperty(t,"control",{get:function(){return this._control},enumerable:!1,configurable:!0}),t._initModelPosition=function(e){var t,n=e.view3d,i=e.frame,o=e.session,r=n.model,s=this._hitTest;if(s.ready&&r){var a=this._control,c=n.renderer.threeRenderer.xr.getReferenceSpace(),u=s.getResults(i);if(!(u.length<=0)){var l=u[0].getPose(c),h=(new R.Matrix4).fromArray(l.transform.matrix);if(!(.25<=h.elements[5]||h.elements[5]<=-.25)){var d=r.scene,_=(new R.Quaternion).copy(l.transform.orientation),f=(new R.Vector3).setFromMatrixPosition(h),p=-r.initialBbox.min.z*d.scale.z,v=f.clone().setZ(f.z+p),m=new R.Vector3(0,1,0),b=new R.Vector3(0,1,0).applyQuaternion(_).normalize(),g=(new R.Vector3).crossVectors(m,b),y=b.clone().applyAxisAngle(g,-Math.PI/2),w=(new R.Matrix4).makeBasis(g,y,b),E=(new R.Quaternion).setFromRotationMatrix(w),P=r.scene.quaternion.clone().premultiply(E);d.quaternion.copy(P),d.position.copy(v),d.updateMatrix(),n.scene.update(r),n.scene.show(),s.destroy(),o.addEventListener(Me,this._onSelectStart),o.addEventListener(Re,this._onSelectEnd),null!==(t=this._domOverlay)&&void 0!==t&&t.hideLoading(),this._modelPlaced=!0;var O=r.scene.scale.clone(),x=new Be({context:o});x.on("progress",function(e){var t=O.clone().multiplyScalar(e.easedProgress);r.scene.scale.copy(t)}),x.on("finish",function(){r.scene.scale.copy(O),a.init(e,{hitPosition:f,hitRotation:_,wallRotation:E,modelPosition:v})}),x.start()}}}},e}(Fe);(et=Ke=Ke||{})[et.WAITING=0]="WAITING",et[et.ROTATE_HORIZONTAL=1]="ROTATE_HORIZONTAL",et[et.ROTATE_VERTICAL=2]="ROTATE_VERTICAL";var ct=function(){function e(e){var t=(void 0===e?{}:e).scale,n=void 0===t?1:t;this.rotation=new R.Quaternion,this._state=Ke.WAITING,this._enabled=!0,this._active=!1,this._prevPos=new R.Vector2,this._fromQuat=new R.Quaternion,this._toQuat=new R.Quaternion,this._horizontalAxis=new R.Vector3,this._verticalAxis=new R.Vector3,this._motion=new H({range:D}),this._rotationIndicator=new He,this._userScale=n}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._userScale},set:function(e){this._userScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"horizontalAxis",{get:function(){return this._horizontalAxis},enumerable:!1,configurable:!0}),Object.defineProperty(t,"verticalAxis",{get:function(){return this._verticalAxis},enumerable:!1,configurable:!0}),t.init=function(e){var t=e.view3d,n=t.model.scene.quaternion;this.updateRotation(n),t.scene.add(this._rotationIndicator.object)},t.destroy=function(e){e.view3d.scene.remove(this._rotationIndicator.object)},t.updateRotation=function(e){this.rotation.copy(e),this._fromQuat.copy(e),this._toQuat.copy(e)},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1},t.updateAxis=function(e,t){this._horizontalAxis.copy(e),this._verticalAxis.copy(t)},t.activate=function(e,t){var n=e.view3d;if(this._enabled){var i=n.model,o=this._rotationIndicator;this._active=!0,o.show(),o.updatePosition(i.bbox.getCenter(new R.Vector3)),o.updateScale(i.size/2),t===Qe.TWO_FINGER_HORIZONTAL?(o.updateRotation(i.scene.quaternion.clone().multiply((new R.Quaternion).setFromEuler(new R.Euler(-Math.PI/2,0,0)))),this._state=Ke.ROTATE_HORIZONTAL):t===Qe.TWO_FINGER_VERTICAL&&(o.updateRotation(i.scene.quaternion.clone().multiply((new R.Quaternion).setFromEuler(new R.Euler(0,Math.PI/2,0)))),this._state=Ke.ROTATE_VERTICAL)}},t.deactivate=function(){this._active=!1,this._rotationIndicator.hide(),this._state=Ke.WAITING},t.setInitialPos=function(e){e.length<2||this._prevPos.set((e[0].x+e[1].x)/2,(e[0].y+e[1].y)/2)},t.process=function(e,t){var n=t.coords;if(this._active&&2===n.length){var i=this._state,o=this._prevPos,r=this._motion,s=this._userScale,a=new R.Vector2((n[0].x+n[1].x)/2,(n[0].y+n[1].y)/2),c=(new R.Vector2).subVectors(o,a),u=i===Ke.ROTATE_HORIZONTAL?this._horizontalAxis:this._verticalAxis,l=i===Ke.ROTATE_HORIZONTAL?c.x*s:-c.y*s,h=(new R.Quaternion).setFromAxisAngle(u,l),d=this._getInterpolatedQuaternion();this._fromQuat.copy(d),this._toQuat.premultiply(h),r.reset(0),r.setEndDelta(1),o.copy(a)}},t.update=function(e,t){var n=e.model;this._motion.update(t);var i=this._getInterpolatedQuaternion();this.rotation.copy(i),n.scene.quaternion.copy(this.rotation)},t._getInterpolatedQuaternion=function(){var e=this._motion,t=this._toQuat,n=this._fromQuat,i=e.val;return(new R.Quaternion).copy(n).slerp(t,i)},e}(),ut=function(){function e(e){void 0===e&&(e={}),this.rotation=new R.Quaternion,this._zRotationControl=new We(e.swirl),this._xyRotationControl=new ct(e.swipe),this._activatedControl=null}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._zRotationControl.enabled||this._xyRotationControl.enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"swirl",{get:function(){return this._zRotationControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"swipe",{get:function(){return this._xyRotationControl},enumerable:!1,configurable:!0}),t.init=function(e){var t=e.view3d.model.scene.quaternion;this.rotation.copy(t),this._zRotationControl.init(e),this._xyRotationControl.init(e)},t.destroy=function(e){this._zRotationControl.destroy(e),this._xyRotationControl.destroy(e)},t.enable=function(){this._zRotationControl.enable(),this._xyRotationControl.enable()},t.disable=function(){this._zRotationControl.disable(),this._xyRotationControl.disable()},t.activate=function(e,t){var n=this._zRotationControl,i=this._xyRotationControl;t&Qe.ONE_FINGER?(n.activate(e,t),n.updateRotation(this.rotation),this._activatedControl=n):t&Qe.TWO_FINGER&&(i.activate(e,t),i.updateRotation(this.rotation),this._activatedControl=i)},t.deactivate=function(){this._zRotationControl.deactivate(),this._xyRotationControl.deactivate()},t.process=function(e,t){this._zRotationControl.process(e,t),this._xyRotationControl.process(e,t)},t.setInitialPos=function(e){this._zRotationControl.setInitialPos(e),this._xyRotationControl.setInitialPos(e)},t.update=function(e,t){this._activatedControl&&(this._activatedControl.update(e,t),this.rotation.copy(this._activatedControl.rotation))},t.updateRotateAxis=function(e){var t=e.view3d,n=e.xrCam,i=t.model,o=new R.Vector3,r=new R.Vector3,s=new R.Vector3,a=(new R.Quaternion).setFromRotationMatrix(n.matrixWorld),c=[new R.Vector3(1,0,0),new R.Vector3(0,1,0),new R.Vector3(0,0,1)].map(function(e){return e.applyQuaternion(a).normalize()}),u=[new R.Vector3(1,0,0),new R.Vector3(0,1,0),new R.Vector3(0,0,1)].map(function(e){return e.applyQuaternion(i.scene.quaternion)});o.copy(u[2]),r.copy(u[1]),s.copy(u[0]),o.dot(c[2])<0&&o.negate(),0<r.dot(c[1])&&r.negate(),0<s.dot(c[0])&&s.negate(),this._zRotationControl.updateAxis(o),this._xyRotationControl.updateAxis(r,s)},e}(),lt=function(){function e(e){void 0===e&&(e={}),this._position=new R.Vector3,this._dragPlane=new R.Plane,this._enabled=!0,this._active=!1,this._initialPos=new R.Vector2,this._arrowIndicator=new ot(e.arrow)}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"position",{get:function(){return this._position.clone()},enumerable:!1,configurable:!0}),t.init=function(e){var t=e.view3d;this._position.copy(t.model.scene.position),t.scene.add(this._arrowIndicator.object)},t.destroy=function(e){e.view3d.scene.remove(this._arrowIndicator.object)},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1,this.deactivate()},t.activate=function(e,t){var n=e.model,i=e.xrCam;if(this._enabled){var o=n.scene.position,r=(new R.Vector3).setFromMatrixPosition(i.matrixWorld),s=[new R.Vector3,new R.Vector3,new R.Vector3];n.scene.matrixWorld.extractBasis(s[0],s[1],s[2]),s.forEach(function(e){return e.normalize()});var a,c,u,l=(new R.Vector3).subVectors(o,r).clone().normalize(),h=(a=l,u=c=0,s.forEach(function(e,t){var n=Math.abs(a.dot(e));u<n&&(c=t,u=n)}),c),d=s[h];d.dot(l)<0&&d.negate();var _=new R.Plane(d,0).distanceToPoint(o);this._dragPlane.set(d,-_),this._active=!0;var f=this._arrowIndicator,p=n.initialBbox;p.min.multiply(n.scene.scale),p.max.multiply(n.scene.scale),p.translate(o),f.show(),f.updatePosition(p.getCenter(new R.Vector3)),f.updateScale(n.size/16);var v=n.scene.quaternion.clone();0===h?v.multiply((new R.Quaternion).setFromEuler(new R.Euler(0,Math.PI/2,0))):1===h&&v.multiply((new R.Quaternion).setFromEuler(new R.Euler(Math.PI/2,0,0))),f.updateRotation(v),f.updateOffset((new R.Vector3).subVectors(p.max,p.min).multiplyScalar(.5))}},t.deactivate=function(){this._active=!1,this._arrowIndicator.hide()},t.setInitialPos=function(e){this._initialPos.copy(e[0])},t.process=function(e,t){var n=e.view3d,i=e.frame,o=e.referenceSpace,r=e.xrCam,s=t.inputSources;if(1===s.length&&this._active){var a=s[0],c=this._dragPlane,u=i.getPose(a.targetRaySpace,o),l=(new R.Vector3).setFromMatrixPosition(r.matrixWorld),h=(new R.Vector3).copy(u.transform.position).sub(l).normalize(),d=new R.Ray(l,h).intersectPlane(c,new R.Vector3);if(d){this._position.copy(d);var _=n.model,f=_.initialBbox.getCenter(new R.Vector3).multiply(_.scene.scale).y,p=(new R.Vector3).applyQuaternion(_.scene.quaternion),v=d.add(p.multiplyScalar(f));this._arrowIndicator.updatePosition(v)}}},t.update=function(e,t){e.model.scene.position.copy(this._position)},e}(),ht=function(){function e(e){var p=this;void 0===e&&(e={}),this._enabled=!0,this._initialized=!1,this._modelHit=!1,this.onSelectStart=function(e){var t=e.view3d,n=e.session,i=e.frame,o=e.referenceSpace,r=e.xrCam;if(p._enabled){var s=p._deadzoneChecker,a=p._rotateControl,c=p._translateControl,u=p._scaleControl;a.enabled&&a.updateRotateAxis(e),a.swirl.enabled&&s.addTestingGestures(Qe.ONE_FINGER),a.swipe.enabled&&s.addTestingGestures(Qe.TWO_FINGER),c.enabled&&s.addTestingGestures(Qe.ONE_FINGER),u.enabled&&s.addTestingGestures(Qe.PINCH);var l=p._inputSourceToVector(n.inputSources);if(s.applyScreenAspect(l),s.setFirstInput(l),1===l.length){var h=t.model.bbox,d=i.getPose(n.inputSources[0].targetRaySpace,o),_=(new R.Vector3).setFromMatrixPosition(r.matrixWorld),f=(new R.Vector3).copy(d.transform.position).sub(_).normalize();new R.Ray(_,f).intersectBox(h,new R.Vector3)&&(p._modelHit=!0)}}},this.onSelectEnd=function(){p.deactivate()},this._rotateControl=new ut(e.rotate),this._translateControl=new lt(e.translate),this._scaleControl=new $e(e.scale),this._deadzoneChecker=new tt}var t=e.prototype;return Object.defineProperty(t,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t,"rotate",{get:function(){return this._rotateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"translate",{get:function(){return this._translateControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"scale",{get:function(){return this._scaleControl},enumerable:!1,configurable:!0}),Object.defineProperty(t,"controls",{get:function(){return[this._rotateControl,this._translateControl,this._scaleControl]},enumerable:!1,configurable:!0}),t.init=function(t){var e=t.size;this.controls.forEach(function(e){return e.init(t)}),this._deadzoneChecker.setAspect(e.height/e.width),this._initialized=!0},t.destroy=function(t){this._initialized&&(this.deactivate(),this.controls.forEach(function(e){return e.destroy(t)}),this._initialized=!1)},t.deactivate=function(){this._modelHit=!1,this._deadzoneChecker.cleanup(),this.controls.forEach(function(e){return e.deactivate()})},t.enable=function(){this._enabled=!0},t.disable=function(){this._enabled=!1,this.deactivate()},t.update=function(e){var t=e.session;if(this._initialized){var n=this._deadzoneChecker,i=t.inputSources;n.inDeadzone?this._checkDeadzone(e,i):this._processInput(e,i),this._updateControls(e)}},t._checkDeadzone=function(e,t){var n=this._inputSourceToVector(t),i=this._deadzoneChecker.check(n.map(function(e){return e.clone()})),o=this._rotateControl,r=this._translateControl,s=this._scaleControl;if(i!==Qe.NONE)switch(i){case Qe.ONE_FINGER_HORIZONTAL:case Qe.ONE_FINGER_VERTICAL:this._modelHit?(r.activate(e,i),r.setInitialPos(n)):(o.activate(e,i),o.setInitialPos(n));break;case Qe.TWO_FINGER_HORIZONTAL:case Qe.TWO_FINGER_VERTICAL:o.activate(e,i),o.setInitialPos(n);break;case Qe.PINCH:s.activate(e,i),s.setInitialPos(n)}},t._processInput=function(t,n){var i=this._inputSourceToVector(n);this.controls.forEach(function(e){return e.process(t,{coords:i,inputSources:n})})},t._updateControls=function(t){var e=t.view3d,n=t.model,i=1e3*t.delta;this.controls.forEach(function(e){return e.update(t,i)}),n.scene.updateMatrix(),e.scene.update(n)},t._inputSourceToVector=function(e){return Array.from(e).map(function(e){var t=e.gamepad.axes;return new R.Vector2(t[0],-t[1])})},e}(),dt=function(o){function e(e){void 0===e&&(e={});var i=o.call(this,e)||this;return i.onStart=function(e){var t=e.view3d;o.prototype.onStart.call(i,e),i._control=new ht(i._options),t.scene.hide()},i.onEnd=function(e){var t=e.view3d,n=e.session;o.prototype.onEnd.call(i,e),i._renderContext=null,i._modelPlaced=!1,n.removeEventListener(Me,i._onSelectStart),n.removeEventListener(Re,i._onSelectEnd),i._control.destroy(e),i._control=null,t.scene.show()},i._beforeRender=function(e){i._renderContext=e,i._modelPlaced?i._control.update(e):i._initModelPosition(e)},i._onSelectStart=function(e){i._control.onSelectStart(_(_({},i._renderContext),{frame:e.frame}))},i._onSelectEnd=function(){i._control.onSelectEnd()},i._control=null,i._renderContext=null,i._modelPlaced=!1,i._options=e,i}s(e,o);var t=e.prototype;return Object.defineProperty(t,"control",{get:function(){return this._control},enumerable:!1,configurable:!0}),t.placeModel=function(){var e=this._renderContext;if(e&&e.view3d.scene.visible&&!this._modelPlaced){var t=e.session,n=e.view3d.model.scene,i=this._control;t.addEventListener(Me,this._onSelectStart),t.addEventListener(Re,this._onSelectEnd),this._modelPlaced=!0,this.emit("modelPlaced");var o=n.scale.clone(),r=new Be({context:t});r.on("progress",function(e){var t=o.clone().multiplyScalar(e.easedProgress);n.scale.copy(t)}),r.on("finish",function(){n.scale.copy(o),i.init(e)}),r.start()}},t._initModelPosition=function(e){var t=e.view3d,n=e.xrCam,i=t.model;if(i){var o=i.scene,r=(new R.Vector3).setFromMatrixPosition(n.matrixWorld),s=(new R.Quaternion).setFromRotationMatrix(n.matrixWorld),a=new R.Vector3(0,0,-1).applyQuaternion(s),c=i.bbox,u=(new R.Vector3).subVectors(c.max,c.min),l=Math.max(u.x,u.y,u.z);o.position.copy(r),o.position.add(a.multiplyScalar(y(l,.5,3))),o.lookAt(r.setY(o.position.y)),o.updateMatrix(),t.scene.update(i),t.scene.visible||(t.scene.show(),this.emit("canPlace"))}},e}(Fe),_t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&1<navigator.maxTouchPoints,ft=/android/i.test(navigator.userAgent),pt=/safari/i.test(navigator.userAgent),vt={__proto__:null,WebARSession:Fe,FloorARSession:it,WallARSession:at,HoverARSession:dt,SceneViewerSession:function(){function e(e){this.params=e,this.isWebXRSession=!1,this.params.mode||(this.params.mode="ar_only")}var t=e.prototype;return t.isAvailable=function(){return Promise.resolve(ft)},t.enter=function(){var t=Object.assign({},this.params),e=t.browser_fallback_url;delete t.browser_fallback_url;var n=t.resizable;delete t.resizable,!0===n?t.resizable="true":!1===n?t.resizable="false":n&&(t.resizable=n);var i=Object.keys(t).filter(function(e){return null!=t[e]}).map(function(e){return e+"="+t[e]}).join("&"),o="ar_only"===t.mode?Ve(i,e):ze(i,e||De(i)),r=document.createElement("a");return r.href=o,r.click(),Promise.resolve()},t.exit=function(){},e}(),QuickLookSession:function(){function e(e){var t=e.file,n=e.allowsContentScaling,i=void 0===n||n;this.isWebXRSession=!1,this._file=t,this._allowsContentScaling=i}var t=e.prototype;return t.isAvailable=function(){return Promise.resolve(Pe&&_t&&pt)},t.enter=function(){var e=document.createElement("a");e.setAttribute("rel","ar"),e.appendChild(document.createElement("img"));var t=new URL(this._file,window.location.toString());return this._allowsContentScaling||(t.hash="allowsContentScaling=0"),e.setAttribute("href",t.toString()),e.click(),Promise.resolve()},t.exit=function(){},e}()},mt={__proto__:null,TextureModel:function(_){function e(e){var t=e.image,n=e.width,i=e.height,o=e.billboard,r=void 0!==o&&o,s=this,a=t.isTexture?t:new R.Texture(t),c=a.image.width/a.image.height;if(null==n&&null==i)throw new f(m.PROVIDE_WIDTH_OR_HEIGHT,p.PROVIDE_WIDTH_OR_HEIGHT);null==n?n=i*c:null==i&&(i=n/c),a.encoding=R.sRGBEncoding;var u=new R.PlaneGeometry(n,i),l=new R.MeshBasicMaterial({map:a,side:R.DoubleSide}),h=new R.Mesh(u,l);if((s=_.call(this,{scenes:[h]})||this)._texture=a,s._mesh=h,r){var d=h;d.onBeforeRender=function(e,t,n){var i=d.getWorldPosition(new R.Vector3),o=(new R.Vector3).setFromMatrixPosition(n.matrixWorld);d.lookAt(o.setY(i.y)),h.updateMatrix()}}return s}s(e,_);var t=e.prototype;return Object.defineProperty(t,"texture",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(t,"mesh",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),e}(ue)},bt={__proto__:null,THREE:R};return O(ce,le),O(ce,we),O(ce,me),O(ce,Ee),O(ce,vt),O(ce,mt),O(ce,bt),ce.View3DError=f,ce.ERROR_CODES=p,ce.EASING=j,ce});
|
10 | //# sourceMappingURL=view3d.min.js.map
|