1(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?(module.exports=factory()):typeof define==="function"&&define.amd?define(factory):((global=typeof globalThis!=="undefined"?globalThis:global||self),((global.eg=global.eg||{}),(global.eg.view360=factory())))})(this,function(){"use strict";var VERSION="3.6.4";/*! ***************************************************************************** 2 Copyright (c) Microsoft Corporation. 3 4 Permission to use, copy, modify, and/or distribute this software for any 5 purpose with or without fee is hereby granted. 6 7 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 9 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 12 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 13 PERFORMANCE OF THIS SOFTWARE. 14 ***************************************************************************** */ 15var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||({__proto__:[],}instanceof Array&&function(d,b){d.__proto__=b})||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return extendStatics(d,b);};function __extends(d,b){extendStatics(d,b);function __(){this.constructor=d} 16d.prototype=b===null?Object.create(b):((__.prototype=b.prototype),new __())} 17var __assign=function(){__assign=Object.assign||function __assign(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]} 18return t};return __assign.apply(this,arguments)};function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})} 19return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}} 20function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}} 21function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)} 22step((generator=generator.apply(thisArg,_arguments||[])).next())})} 23function __generator(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[],},f,y,t,g;return((g={next:verb(0),throw:verb(1),return:verb(2),}),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g);function verb(n){return function(v){return step([n,v])}} 24function step(op){if(f)throw new TypeError("Generator is already executing.");while(_) 25try{if(((f=1),y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done))return t;if(((y=0),t))op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:!1,};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!((t=_.trys),(t=t.length>0&&t[t.length-1]))&&(op[0]===6||op[0]===2)){_=0;continue} 26if(op[0]===3&&(!t||(op[1]>t[0]&&op[1]<t[3]))){_.label=op[1];break} 27if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break} 28if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break} 29if(t[2])_.ops.pop();_.trys.pop();continue} 30op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0} 31if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:!0,}}} 32function __values(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number") 33return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o,}},};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")} 34function __read(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m)return o;var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-->0)&&!(r=i.next()).done)ar.push(r.value);}catch(error){e={error:error,}}finally{try{if(r&&!r.done&&(m=i["return"]))m.call(i);}finally{if(e)throw e.error}} 35return ar} 36function __spread(){for(var ar=[],i=0;i<arguments.length;i++)ar=ar.concat(__read(arguments[i]));return ar}/*! ***************************************************************************** 37 Copyright (c) Microsoft Corporation. 38 39 Permission to use, copy, modify, and/or distribute this software for any 40 purpose with or without fee is hereby granted. 41 42 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 43 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 44 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
45 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 46 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 47 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 48 PERFORMANCE OF THIS SOFTWARE. 49 ***************************************************************************** */ 50function __values$1(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number") 51return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o,}},};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")} 52function __read$1(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m)return o;var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-->0)&&!(r=i.next()).done)ar.push(r.value);}catch(error){e={error:error,}}finally{try{if(r&&!r.done&&(m=i["return"]))m.call(i);}finally{if(e)throw e.error}} 53return ar} 54function __spread$1(){for(var ar=[],i=0;i<arguments.length;i++)ar=ar.concat(__read$1(arguments[i]));return ar} 55var isUndefined=function(value){return typeof value==="undefined"};var ComponentEvent=(function(){function ComponentEvent(eventType,props){var e_1,_a;this._canceled=!1;if(props){try{for(var _b=__values$1(Object.keys(props)),_c=_b.next();!_c.done;_c=_b.next()){var key=_c.value;this[key]=props[key]}}catch(e_1_1){e_1={error:e_1_1,}}finally{try{if(_c&&!_c.done&&(_a=_b.return))_a.call(_b);}finally{if(e_1)throw e_1.error}}} 56this.eventType=eventType} 57var __proto=ComponentEvent.prototype;__proto.stop=function(){this._canceled=!0};__proto.isCanceled=function(){return this._canceled};return ComponentEvent})();var Component=(function(){function Component(){this._eventHandler={}} 58var __proto=Component.prototype;__proto.trigger=function(event){var params=[];for(var _i=1;_i<arguments.length;_i++){params[_i-1]=arguments[_i]} 59var eventName=event instanceof ComponentEvent?event.eventType:event;var handlers=__spread$1(this._eventHandler[eventName]||[]);if(handlers.length<=0){return this} 60if(event instanceof ComponentEvent){event.currentTarget=this;handlers.forEach(function(handler){handler(event)})}else{handlers.forEach(function(handler){handler.apply(void 0,__spread$1(params))})} 61return this};__proto.once=function(eventName,handlerToAttach){var _this=this;if(typeof eventName==="object"&&isUndefined(handlerToAttach)){var eventHash=eventName;for(var key in eventHash){this.once(key,eventHash[key])} 62return this}else if(typeof eventName==="string"&&typeof handlerToAttach==="function"){var listener_1=function(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i]} 63handlerToAttach.apply(void 0,__spread$1(args));_this.off(eventName,listener_1)};this.on(eventName,listener_1)} 64return this};__proto.hasOn=function(eventName){return!!this._eventHandler[eventName]};__proto.on=function(eventName,handlerToAttach){if(typeof eventName==="object"&&isUndefined(handlerToAttach)){var eventHash=eventName;for(var name in eventHash){this.on(name,eventHash[name])} 65return this}else if(typeof eventName==="string"&&typeof handlerToAttach==="function"){var handlerList=this._eventHandler[eventName];if(isUndefined(handlerList)){this._eventHandler[eventName]=[];handlerList=this._eventHandler[eventName]} 66handlerList.push(handlerToAttach)} 67return this};__proto.off=function(eventName,handlerToDetach){var e_1,_a;if(isUndefined(eventName)){this._eventHandler={};return this} 68if(isUndefined(handlerToDetach)){if(typeof eventName==="string"){delete this._eventHandler[eventName];return this}else{var eventHash=eventName;for(var name in eventHash){this.off(name,eventHash[name])} 69return this}} 70var handlerList=this._eventHandler[eventName];if(handlerList){var idx=0;try{for(var handlerList_1=__values$1(handlerList),handlerList_1_1=handlerList_1.next();!handlerList_1_1.done;handlerList_1_1=handlerList_1.next()){var handlerFunction=handlerList_1_1.value;if(handlerFunction===handlerToDetach){handlerList.splice(idx,1);if(handlerList.length<=0){delete this._eventHandler[eventName]} 71break} 72idx++}}catch(e_1_1){e_1={error:e_1_1,}}finally{try{if(handlerList_1_1&&!handlerList_1_1.done&&(_a=handlerList_1.return))_a.call(handlerList_1);}finally{if(e_1)throw e_1.error}}} 73return this};Component.VERSION="3.0.2";return Component})();
73var ComponentEvent$1=ComponentEvent;function finallyConstructor(callback){var constructor=this.constructor;return this.then(function(value){return constructor.resolve(callback()).then(function(){return value})},function(reason){return constructor.resolve(callback()).then(function(){return constructor.reject(reason)})})} 74function allSettled(arr){var P=this;return new P(function(resolve,reject){if(!(arr&&typeof arr.length!=="undefined")){return reject(new TypeError(typeof arr+" "+arr+" is not iterable(cannot read property Symbol(Symbol.iterator))"))} 75var args=Array.prototype.slice.call(arr);if(args.length===0)return resolve([]);var remaining=args.length;function res(i,val){if(val&&(typeof val==="object"||typeof val==="function")){var then=val.then;if(typeof then==="function"){then.call(val,function(val){res(i,val)},function(e){args[i]={status:"rejected",reason:e};if(--remaining===0){resolve(args)}});return}} 76args[i]={status:"fulfilled",value:val};if(--remaining===0){resolve(args)}} 77for(var i=0;i<args.length;i++){res(i,args[i])}})} 78var setTimeoutFunc=setTimeout;function isArray(x){return Boolean(x&&typeof x.length!=="undefined")} 79function noop(){} 80function bind(fn,thisArg){return function(){fn.apply(thisArg,arguments)}} 81function Promise$1(fn){if(!(this instanceof Promise$1))throw new TypeError("Promises must be constructed via new");if(typeof fn!=="function")throw new TypeError("not a function");this._state=0;this._handled=!1;this._value=undefined;this._deferreds=[];doResolve(fn,this)} 82function handle(self,deferred){while(self._state===3){self=self._value} 83if(self._state===0){self._deferreds.push(deferred);return} 84self._handled=!0;Promise$1._immediateFn(function(){var cb=self._state===1?deferred.onFulfilled:deferred.onRejected;if(cb===null){(self._state===1?resolve:reject)(deferred.promise,self._value);return} 85var ret;try{ret=cb(self._value)}catch(e){reject(deferred.promise,e);return} 86resolve(deferred.promise,ret)})} 87function resolve(self,newValue){try{if(newValue===self)throw new TypeError("A promise cannot be resolved with itself.");if(newValue&&(typeof newValue==="object"||typeof newValue==="function")){var then=newValue.then;if(newValue instanceof Promise$1){self._state=3;self._value=newValue;finale(self);return}else if(typeof then==="function"){doResolve(bind(then,newValue),self);return}} 88self._state=1;self._value=newValue;finale(self)}catch(e){reject(self,e)}} 89function reject(self,newValue){self._state=2;self._value=newValue;finale(self)} 90function finale(self){if(self._state===2&&self._deferreds.length===0){Promise$1._immediateFn(function(){if(!self._handled){Promise$1._unhandledRejectionFn(self._value)}})} 91for(var i=0,len=self._deferreds.length;i<len;i++){handle(self,self._deferreds[i])} 92self._deferreds=null} 93function Handler(onFulfilled,onRejected,promise){this.onFulfilled=typeof onFulfilled==="function"?onFulfilled:null;this.onRejected=typeof onRejected==="function"?onRejected:null;this.promise=promise} 94function doResolve(fn,self){var done=!1;try{fn(function(value){if(done)return;done=!0;resolve(self,value)},function(reason){if(done)return;done=!0;reject(self,reason)})}catch(ex){if(done)return;done=!0;reject(self,ex)}} 95Promise$1.prototype["catch"]=function(onRejected){return this.then(null,onRejected)};Promise$1.prototype.then=function(onFulfilled,onRejected){var prom=new this.constructor(noop);handle(this,new Handler(onFulfilled,onRejected,prom));return prom};Promise$1.prototype["finally"]=finallyConstructor;Promise$1.all=function(arr){return new Promise$1(function(resolve,reject){if(!isArray(arr)){return reject(new TypeError("Promise.all accepts an array"))} 96var args=Array.prototype.slice.call(arr);if(args.length===0)return resolve([]);var remaining=args.length;function res(i,val){try{if(val&&(typeof val==="object"||typeof val==="function")){var then=val.then;if(typeof then==="function"){then.call(val,function(val){res(i,val)},reject);return}} 97args[i]=val;if(--remaining===0){resolve(args)}}catch(ex){reject(ex)}} 98for(var i=0;i<args.length;i++){res(i,args[i])}})};Promise$1.allSettled=allSettled;Promise$1.resolve=function(value){if(value&&typeof value==="object"&&value.constructor===Promise$1){return value} 99return new Promise$1(function(resolve){resolve(value)})};Promise$1.reject=function(value){return new Promise$1(function(resolve,reject){reject(value)})};Promise$1.race=function(arr){return new Promise$1(function(resolve,reject){if(!isArray(arr)){return reject(new TypeError("Promise.race accepts an array"))} 100for(var i=0,len=arr.length;i<len;i++){Promise$1.resolve(arr[i]).then(resolve,reject)}})};Promise$1._immediateFn=(typeof setImmediate==="function"&&function(fn){setImmediate(fn)})||function(fn){setTimeoutFunc(fn,0)};Promise$1._unhandledRejectionFn=function _unhandledRejectionFn(err){if(typeof console!=="undefined"&&console){console.warn("Possible Unhandled Promise Rejection:",err)}};function some(arr,callback){var length=arr.length;for(var i=0;i<length;++i){if(callback(arr[i],i)){return!0}} 101return!1} 102function find(arr,callback){var length=arr.length;for(var i=0;i<length;++i){if(callback(arr[i],i)){return arr[i]}} 103return null} 104function getUserAgent(agent){var userAgent=agent;if(typeof userAgent==="undefined"){if(typeof navigator==="undefined"||!navigator){return""} 105userAgent=navigator.userAgent||""} 106return userAgent.toLowerCase()} 107function execRegExp(pattern,text){try{return new RegExp(pattern,"g").exec(text)}catch(e){return null}} 108function hasUserAgentData(){if(typeof navigator==="undefined"||!navigator||!navigator.userAgentData){return!1} 109var userAgentData=navigator.userAgentData;var brands=userAgentData.brands||userAgentData.uaList;return!!(brands&&brands.length)} 110function findVersion(versionTest,userAgent){var result=execRegExp("("+versionTest+")((?:\\/|\\s|:)([0-9|\\.|_]+))?",userAgent);return result?result[3]:""} 111function convertVersion(text){return text.replace(/_/g,".")} 112function findPreset(presets,userAgent){var userPreset=null;var version="-1";
112some(presets,function(preset){var result=execRegExp("("+preset.test+")((?:\\/|\\s|:)([0-9|\\.|_]+))?",userAgent);if(!result||preset.brand){return!1} 113userPreset=preset;version=result[3]||"-1";if(preset.versionAlias){version=preset.versionAlias}else if(preset.versionTest){version=findVersion(preset.versionTest.toLowerCase(),userAgent)||version} 114version=convertVersion(version);return!0});return{preset:userPreset,version:version,}} 115function findBrand(brands,preset){return find(brands,function(_a){var brand=_a.brand;return execRegExp(""+preset.test,brand.toLowerCase())})} 116var BROWSER_PRESETS=[{test:"phantomjs",id:"phantomjs",},{test:"whale",id:"whale",},{test:"edgios|edge|edg",id:"edge",},{test:"msie|trident|windows phone",id:"ie",versionTest:"iemobile|msie|rv",},{test:"miuibrowser",id:"miui browser",},{test:"samsungbrowser",id:"samsung internet",},{test:"samsung",id:"samsung internet",versionTest:"version",},{test:"chrome|crios",id:"chrome",},{test:"firefox|fxios",id:"firefox",},{test:"android",id:"android browser",versionTest:"version",},{test:"safari|iphone|ipad|ipod",id:"safari",versionTest:"version",},];var CHROMIUM_PRESETS=[{test:"(?=.*applewebkit/(53[0-7]|5[0-2]|[0-4]))(?=.*\\schrome)",id:"chrome",},{test:"chromium",id:"chrome",},{test:"whale",id:"chrome",brand:!0,},];var WEBKIT_PRESETS=[{test:"applewebkit",id:"webkit",},];var WEBVIEW_PRESETS=[{test:"(?=(iphone|ipad))(?!(.*version))",id:"webview",},{test:"(?=(android|iphone|ipad))(?=.*(naver|daum|; wv))",id:"webview",},{test:"webview",id:"webview",},];var OS_PRESETS=[{test:"windows phone",id:"windows phone",},{test:"windows 2000",id:"window",versionAlias:"5.0",},{test:"windows nt",id:"window",},{test:"iphone|ipad|ipod",id:"ios",versionTest:"iphone os|cpu os",},{test:"mac os x",id:"mac",},{test:"android",id:"android",},{test:"tizen",id:"tizen",},{test:"webos|web0s",id:"webos",},];function parseUserAgentData(osData){var userAgentData=navigator.userAgentData;var brands=(userAgentData.uaList||userAgentData.brands).slice();var isMobile=userAgentData.mobile||!1;var firstBrand=brands[0];var browser={name:firstBrand.brand,version:firstBrand.version,majorVersion:-1,webkit:!1,webview:some(WEBVIEW_PRESETS,function(preset){return findBrand(brands,preset)}),chromium:some(CHROMIUM_PRESETS,function(preset){return findBrand(brands,preset)}),};var os={name:"unknown",version:"-1",majorVersion:-1,};browser.webkit=!browser.chromium&&some(WEBKIT_PRESETS,function(preset){return findBrand(brands,preset)});if(osData){var platform_1=osData.platform.toLowerCase();var result=find(OS_PRESETS,function(preset){return new RegExp(""+preset.test,"g").exec(platform_1)});os.name=result?result.id:platform_1;os.version=osData.platformVersion} 117some(BROWSER_PRESETS,function(preset){var result=findBrand(brands,preset);if(!result){return!1} 118browser.name=preset.id;browser.version=osData?osData.uaFullVersion:result.version;return!0});if(navigator.platform==="Linux armv8l"){os.name="android"}else if(browser.webkit){os.name=isMobile?"ios":"mac"} 119if(os.name==="ios"&&browser.webview){browser.version="-1"} 120os.version=convertVersion(os.version);browser.version=convertVersion(browser.version);os.majorVersion=parseInt(os.version,10);browser.majorVersion=parseInt(browser.version,10);return{browser:browser,os:os,isMobile:isMobile,isHints:!0,}} 121function parseUserAgent(userAgent){var nextAgent=getUserAgent(userAgent);var isMobile=!!/mobi/g.exec(nextAgent);var browser={name:"unknown",version:"-1",majorVersion:-1,webview:!!findPreset(WEBVIEW_PRESETS,nextAgent).preset,chromium:!!findPreset(CHROMIUM_PRESETS,nextAgent).preset,webkit:!1,};var os={name:"unknown",version:"-1",majorVersion:-1,};var _a=findPreset(BROWSER_PRESETS,nextAgent),browserPreset=_a.preset,browserVersion=_a.version;var _b=findPreset(OS_PRESETS,nextAgent),osPreset=_b.preset,osVersion=_b.version;browser.webkit=!browser.chromium&&!!findPreset(WEBKIT_PRESETS,nextAgent).preset;if(osPreset){os.name=osPreset.id;os.version=osVersion;os.majorVersion=parseInt(osVersion,10)} 122if(browserPreset){browser.name=browserPreset.id;browser.version=browserVersion;if(browser.webview&&os.name==="ios"&&browser.name!=="safari"){browser.webview=!1}} 123browser.majorVersion=parseInt(browser.version,10);return{browser:browser,os:os,isMobile:isMobile,isHints:!1,}} 124function agent(userAgent){if(typeof userAgent==="undefined"&&hasUserAgentData()){return parseUserAgentData()}else{return parseUserAgent(userAgent)}} 125var win=typeof window!=="undefined"&&window.Math===Math?window:typeof self!=="undefined"&&self.Math===Math?self:Function("return this")();var doc=win.document;var nav=win.navigator;var agent$1=agent();var osName=agent$1.os.name;var browserName=agent$1.browser.name;var IS_IOS=osName==="ios";var IS_SAFARI_ON_DESKTOP=osName==="mac"&&browserName==="safari";win.Float32Array=typeof win.Float32Array!=="undefined"?win.Float32Array:win.Array;var Float32Array$1=win.Float32Array;var getComputedStyle=win.getComputedStyle;var userAgent=win.navigator&&win.navigator.userAgent;var SUPPORT_TOUCH="ontouchstart" in win;var SUPPORT_DEVICEMOTION="ondevicemotion" in win;var DeviceMotionEvent=win.DeviceMotionEvent;var devicePixelRatio=win.devicePixelRatio;var TRANSFORM=(function(){var _a;var docStyle=(_a=doc===null||doc===void 0?void 0:doc.documentElement.style)!==null&&_a!==void 0?_a:{};var target=["transform","webkitTransform","msTransform","mozTransform"];for(var i=0,len=target.length;i<len;i++){if(target[i]in docStyle){return target[i]}} 126return""})();var SUPPORT_WILLCHANGE=win.CSS&&win.CSS.supports&&win.CSS.supports("will-change","transform");var WEBXR_SUPPORTED=!1;var checkXRSupport=function(){var navigator=window.navigator;if(!navigator.xr){return} 127if(navigator.xr.isSessionSupported){navigator.xr.isSessionSupported("immersive-vr").then(function(res){WEBXR_SUPPORTED=res}).catch(function(){return void 0})}else if(navigator.xr.supportsSession){navigator.xr.supportsSession("immersive-vr").then(function(res){WEBXR_SUPPORTED=res}).catch(function(){return void 0})}};function keys(obj){return Object.keys(obj)} 128var OBSERVERS_PATH="__observers__";var Observer=(function(){function Observer(value){this._emitter=new Component();this._current=value} 129var __proto=Observer.prototype;Object.defineProperty(__proto,"current",{get:function(){return this._current},set:function(value){var isUpdate=value!==this._current;this._current=value;if(isUpdate){this._emitter.trigger("update",value)}}
129,enumerable:!1,configurable:!0,});__proto.subscribe=function(callback){this._emitter.on("update",callback)};__proto.unsubscribe=function(callback){this._emitter.off("update",callback)};return Observer})();function observe(defaultValue){return new Observer(defaultValue)} 130function getObservers(instance){if(!instance[OBSERVERS_PATH]){instance[OBSERVERS_PATH]={}} 131return instance[OBSERVERS_PATH]} 132function getObserver(instance,name,defaultValue){var observers=getObservers(instance);if(!observers[name]){observers[name]=observe(defaultValue)} 133return observers[name]} 134function injectReactiveSubscribe(object){object.subscribe=function(name,callback){getObserver(this,name).subscribe(callback)};object.unsubscribe=function(name,callback){var _this=this;if(!name){keys(getObservers(this)).forEach(function(observerName){_this.unsubscribe(observerName)});return} 135if(!(name in this)){return} 136getObserver(this,name).unsubscribe(callback)}} 137function ReactiveSubscribe(Constructor){var prototype=Constructor.prototype;injectReactiveSubscribe(prototype)}/*! ***************************************************************************** 138 Copyright (c) Microsoft Corporation. All rights reserved. 139 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 140 this file except in compliance with the License. You may obtain a copy of the 141 License at http://www.apache.org/licenses/LICENSE-2.0 142 143 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 144 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 145 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 146 MERCHANTABLITY OR NON-INFRINGEMENT. 147 148 See the Apache Version 2.0 License for specific language governing permissions 149 and limitations under the License. 150 ***************************************************************************** */ 151var extendStatics$1=function(d,b){extendStatics$1=Object.setPrototypeOf||({__proto__:[],}instanceof Array&&function(d,b){d.__proto__=b})||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return extendStatics$1(d,b);};function __extends$1(d,b){extendStatics$1(d,b);function __(){this.constructor=d} 152d.prototype=b===null?Object.create(b):((__.prototype=b.prototype),new __())} 153var __assign$1=function(){__assign$1=Object.assign||function __assign(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]} 154return t};return __assign$1.apply(this,arguments)};function __decorate(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?(desc=Object.getOwnPropertyDescriptor(target,key)):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if((d=decorators[i]))r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r} 155var win$1;if(typeof window==="undefined"){win$1={navigator:{userAgent:"",},}}else{win$1=window} 156var DIRECTION_NONE=1;var DIRECTION_LEFT=2;var DIRECTION_RIGHT=4;var DIRECTION_HORIZONTAL=2|4;var DIRECTION_UP=8;var DIRECTION_DOWN=16;var DIRECTION_VERTICAL=8|16;var DIRECTION_ALL=2|4|8|16;var MOUSE_LEFT="left";var MOUSE_RIGHT="right";var MOUSE_MIDDLE="middle";var ANY="any";var NONE="none";var SHIFT="shift";var CTRL="ctrl";var ALT="alt";var META="meta";var VELOCITY_INTERVAL=16;var IOS_EDGE_THRESHOLD=30;var IS_IOS_SAFARI="ontouchstart" in win$1&&agent().browser.name==="safari";var TRANSFORM$1=(function(){if(typeof document==="undefined"){return""} 157var bodyStyle=(document.head||document.getElementsByTagName("head")[0]).style;var target=["transform","webkitTransform","msTransform","mozTransform"];for(var i=0,len=target.length;i<len;i++){if(target[i]in bodyStyle){return target[i]}} 158return""})();var PREVENT_DRAG_CSSPROPS={"user-select":"none","-webkit-user-drag":"none",};var toArray=function(nodes){var el=[];for(var i=0,len=nodes.length;i<len;i++){el.push(nodes[i])} 159return el};var $=function(param,multi){if(multi===void 0){multi=!1} 160var el;if(typeof param==="string"){var match=param.match(/^<([a-z]+)\s*([^>]*)>/);if(match){var dummy=document.createElement("div");dummy.innerHTML=param;el=toArray(dummy.childNodes)}else{el=toArray(document.querySelectorAll(param))} 161if(!multi){el=el.length>=1?el[0]:undefined}}else if(param===win$1){el=param}else if("value" in param||"current" in param){el=param.value||param.current}else if(param.nodeName&&(param.nodeType===1||param.nodeType===9)){el=param}else if(("jQuery" in win$1&¶m instanceof jQuery)||param.constructor.prototype.jquery){el=multi?param.toArray():param.get(0)}else if(Array.isArray(param)){el=param.map(function(v){return $(v)});if(!multi){el=el.length>=1?el[0]:undefined}} 162return el};var raf=win$1.requestAnimationFrame||win$1.webkitRequestAnimationFrame;var caf=win$1.cancelAnimationFrame||win$1.webkitCancelAnimationFrame;if(raf&&!caf){var keyInfo_1={};var oldraf_1=raf;raf=function(callback){var wrapCallback=function(timestamp){if(keyInfo_1[key]){callback(timestamp)}};var key=oldraf_1(wrapCallback);keyInfo_1[key]=!0;return key};caf=function(key){delete keyInfo_1[key]}}else if(!(raf&&caf)){raf=function(callback){return win$1.setTimeout(function(){callback((win$1.performance&&win$1.performance.now&&win$1.performance.now())||new Date().getTime())},16)};caf=win$1.clearTimeout} 163var requestAnimationFrame=function(fp){return raf(fp)};var cancelAnimationFrame=function(key){caf(key)};var map=function(obj,callback){var tranformed={};for(var k in obj){if(k){tranformed[k]=callback(obj[k],k)}} 164return tranformed};var filter=function(obj,callback){var filtered={};for(var k in obj){if(k&&callback(obj[k],k)){filtered[k]=obj[k]}} 165return filtered};var every=function(obj,callback){for(var k in obj){if(k&&!callback(obj[k],k)){return!1}} 166return!0};var equal=function(target,base){return every(target,function(v,k){return v===base[k]})};var roundNumFunc={};var roundNumber=function(num,roundUnit){if(!roundNumFunc[roundUnit]){roundNumFunc[roundUnit]=getRoundFunc(roundUnit)} 167return roundNumFunc[roundUnit](num)};var roundNumbers=function(num,roundUnit){if(!num||!roundUnit){return num} 168return map(num,function(value,key){return roundNumber(value,typeof roundUnit==="number"?roundUnit:roundUnit[key])})};var getDecimalPlace=function(val){if(!isFinite(val)){return 0} 169var v="".concat(val);if(v.indexOf("e")>=0){var p=0;var e=1;while(Math.round(val*e)/e!==val){e*=10;p++} 170return p} 171return v.indexOf(".")>=0?v.length-v.indexOf(".")-1:0};var inversePow=function(n){return 1/Math.pow(10,n)};var getRoundFunc=function(v){var p=v<1?Math.pow(10,getDecimalPlace(v)):1;return function(n){if(v===0){return 0} 172return Math.round(Math.round(n/v)*v*p)/p}};
172var getAngle=function(posX,posY){return(Math.atan2(posY,posX)*180)/Math.PI};var isCssPropsFromAxes=function(originalCssProps){var same=!0;Object.keys(PREVENT_DRAG_CSSPROPS).forEach(function(prop){if(!originalCssProps||originalCssProps[prop]!==PREVENT_DRAG_CSSPROPS[prop]){same=!1}});return same};var getDirection=function(useHorizontal,useVertical){if(useHorizontal&&useVertical){return DIRECTION_ALL}else if(useHorizontal){return DIRECTION_HORIZONTAL}else if(useVertical){return DIRECTION_VERTICAL}else{return DIRECTION_NONE}};var useDirection=function(checkType,direction,userDirection){if(userDirection){return!!(direction===DIRECTION_ALL||(direction&checkType&&userDirection&checkType))}else{return!!(direction&checkType)}};var setCssProps=function(element,option,direction){var _a;var touchActionMap=((_a={}),(_a[DIRECTION_NONE]="auto"),(_a[DIRECTION_ALL]="none"),(_a[DIRECTION_VERTICAL]="pan-x"),(_a[DIRECTION_HORIZONTAL]="pan-y"),_a);var oldCssProps={};if(element&&element.style){var touchAction=option.touchAction?option.touchAction:touchActionMap[direction];var newCssProps_1=__assign$1(__assign$1({},PREVENT_DRAG_CSSPROPS),{"touch-action":element.style["touch-action"]==="none"?"none":touchAction,});Object.keys(newCssProps_1).forEach(function(prop){oldCssProps[prop]=element.style[prop];element.style[prop]=newCssProps_1[prop]})} 173return oldCssProps};var revertCssProps=function(element,originalCssProps){if(element&&element.style&&originalCssProps){Object.keys(originalCssProps).forEach(function(prop){element.style[prop]=originalCssProps[prop]})} 174return};var EventManager=(function(){function EventManager(_axes){this._axes=_axes} 175var __proto=EventManager.prototype;__proto.hold=function(pos,option){var roundPos=this._getRoundPos(pos).roundPos;this._axes.trigger(new ComponentEvent$1("hold",{pos:roundPos,input:option.input||null,inputEvent:option.event||null,isTrusted:!0,}))};__proto.triggerRelease=function(param){var _a=this._getRoundPos(param.destPos,param.depaPos),roundPos=_a.roundPos,roundDepa=_a.roundDepa;param.destPos=roundPos;param.depaPos=roundDepa;param.setTo=this._createUserControll(param.destPos,param.duration);this._axes.trigger(new ComponentEvent$1("release",__assign$1(__assign$1({},param),{bounceRatio:this._getBounceRatio(roundPos),})))};__proto.triggerChange=function(pos,depaPos,option,holding){var _this=this;if(holding===void 0){holding=!1} 176var animationManager=this.animationManager;var axisManager=animationManager.axisManager;var eventInfo=animationManager.getEventInfo();var _a=this._getRoundPos(pos,depaPos),roundPos=_a.roundPos,roundDepa=_a.roundDepa;var moveTo=axisManager.moveTo(roundPos,roundDepa);var inputEvent=(option===null||option===void 0?void 0:option.event)||(eventInfo===null||eventInfo===void 0?void 0:eventInfo.event)||null;var param={pos:moveTo.pos,delta:moveTo.delta,bounceRatio:this._getBounceRatio(moveTo.pos),holding:holding,inputEvent:inputEvent,isTrusted:!!inputEvent,input:(option===null||option===void 0?void 0:option.input)||(eventInfo===null||eventInfo===void 0?void 0:eventInfo.input)||null,set:inputEvent?this._createUserControll(moveTo.pos):function(){},};var event=new ComponentEvent$1("change",param);this._axes.trigger(event);Object.keys(moveTo.pos).forEach(function(axis){var p=moveTo.pos[axis];getObserver(_this._axes,axis,p).current=p});if(inputEvent){axisManager.set(param.set().destPos)} 177return!event.isCanceled()};__proto.triggerAnimationStart=function(param){var _a=this._getRoundPos(param.destPos,param.depaPos),roundPos=_a.roundPos,roundDepa=_a.roundDepa;param.destPos=roundPos;param.depaPos=roundDepa;param.setTo=this._createUserControll(param.destPos,param.duration);var event=new ComponentEvent$1("animationStart",param);this._axes.trigger(event);return!event.isCanceled()};__proto.triggerAnimationEnd=function(isTrusted){if(isTrusted===void 0){isTrusted=!1} 178this._axes.trigger(new ComponentEvent$1("animationEnd",{isTrusted:isTrusted,}))};__proto.triggerFinish=function(isTrusted){if(isTrusted===void 0){isTrusted=!1} 179this._axes.trigger(new ComponentEvent$1("finish",{isTrusted:isTrusted,}))};__proto.setAnimationManager=function(animationManager){this.animationManager=animationManager};__proto.destroy=function(){this._axes.off()};__proto._createUserControll=function(pos,duration){if(duration===void 0){duration=0} 180var userControl={destPos:__assign$1({},pos),duration:duration,};return function(toPos,userDuration){if(toPos){userControl.destPos=__assign$1({},toPos)}
181if(userDuration!==undefined){userControl.duration=userDuration} 182return userControl}};__proto._getRoundPos=function(pos,depaPos){var roundUnit=this._axes.options.round;return{roundPos:roundNumbers(pos,roundUnit),roundDepa:roundNumbers(depaPos,roundUnit),}};__proto._getBounceRatio=function(pos){return this._axes.axisManager.map(pos,function(v,opt){if(v<opt.range[0]&&opt.bounce[0]!==0){return(opt.range[0]-v)/opt.bounce[0]}else if(v>opt.range[1]&&opt.bounce[1]!==0){return(v-opt.range[1])/opt.bounce[1]}else{return 0}})};return EventManager})();var InterruptManager=(function(){function InterruptManager(_options){this._options=_options;this._prevented=!1} 183var __proto=InterruptManager.prototype;__proto.isInterrupting=function(){return this._options.interruptable||this._prevented};__proto.isInterrupted=function(){return!this._options.interruptable&&this._prevented};__proto.setInterrupt=function(prevented){if(!this._options.interruptable){this._prevented=prevented}};return InterruptManager})();var getInsidePosition=function(destPos,range,circular,bounce){var toDestPos=destPos;var targetRange=[circular[0]?range[0]:bounce?range[0]-bounce[0]:range[0],circular[1]?range[1]:bounce?range[1]+bounce[1]:range[1]];toDestPos=Math.max(targetRange[0],toDestPos);toDestPos=Math.min(targetRange[1],toDestPos);return toDestPos};var isOutside=function(pos,range){return pos<range[0]||pos>range[1]};var isEndofBounce=function(pos,range,bounce,circular){return(!circular[0]&&pos===range[0]-bounce[0])||(!circular[1]&&pos===range[1]+bounce[1])};var getDuration=function(distance,deceleration){var duration=Math.sqrt((distance/deceleration)*2);return duration<100?0:duration};var isCircularable=function(destPos,range,circular){return(circular[1]&&destPos>range[1])||(circular[0]&&destPos<range[0])};var getCirculatedPos=function(pos,range,circular){var toPos=pos;var min=range[0];var max=range[1];var length=max-min;if(circular[1]&&pos>max){toPos=((toPos-max)%length)+min} 184if(circular[0]&&pos<min){toPos=((toPos-min)%length)+max} 185return toPos};var AxisManager=(function(){function AxisManager(_axis){var _this=this;this._axis=_axis;this._complementOptions();this._pos=Object.keys(this._axis).reduce(function(pos,v){pos[v]=_this._axis[v].startPos;return pos},{})} 186var __proto=AxisManager.prototype;__proto.getDelta=function(depaPos,destPos){var fullDepaPos=this.get(depaPos);return map(this.get(destPos),function(v,k){return v-fullDepaPos[k]})};__proto.get=function(axes){var _this=this;if(axes&&Array.isArray(axes)){return axes.reduce(function(acc,v){if(v&&v in _this._pos){acc[v]=_this._pos[v]} 187return acc},{})}else{return __assign$1(__assign$1({},this._pos),axes||{})}};__proto.moveTo=function(pos,depaPos){if(depaPos===void 0){depaPos=this._pos} 188var delta=map(this._pos,function(v,key){return key in pos&&key in depaPos?pos[key]-depaPos[key]:0});this.set(this.map(pos,function(v,opt){return opt?getCirculatedPos(v,opt.range,opt.circular):0}));return{pos:__assign$1({},this._pos),delta:delta,}};__proto.set=function(pos){for(var k in pos){if(k&&k in this._pos){this._pos[k]=pos[k]}}};__proto.every=function(pos,callback){var axisOptions=this._axis;return every(pos,function(value,key){return callback(value,axisOptions[key],key)})};__proto.filter=function(pos,callback){var axisOptions=this._axis;return filter(pos,function(value,key){return callback(value,axisOptions[key],key)})};__proto.map=function(pos,callback){var axisOptions=this._axis;return map(pos,function(value,key){return callback(value,axisOptions[key],key)})};__proto.isOutside=function(axes){return!this.every(axes?this.get(axes):this._pos,function(v,opt){return!isOutside(v,opt.range)})};__proto.getAxisOptions=function(key){return this._axis[key]};__proto.setAxis=function(axis){var _this=this;Object.keys(axis).forEach(function(key){if(!_this._axis[key]){throw new Error("Axis ".concat(key," does not exist in Axes instance"))} 189_this._axis[key]=__assign$1(__assign$1({},_this._axis[key]),axis[key])});this._complementOptions()};__proto._complementOptions=function(){var _this=this;
189Object.keys(this._axis).forEach(function(axis){_this._axis[axis]=__assign$1({range:[0,100],startPos:_this._axis[axis].range[0],bounce:[0,0],circular:[!1,!1],},_this._axis[axis]);["bounce","circular"].forEach(function(v){var axisOption=_this._axis;var key=axisOption[axis][v];if(/string|number|boolean/.test(typeof key)){axisOption[axis][v]=[key,key]}})})};return AxisManager})();var SUPPORT_TOUCH$1="ontouchstart" in win$1;var SUPPORT_POINTER="PointerEvent" in win$1;var SUPPORT_MSPOINTER="MSPointerEvent" in win$1;var SUPPORT_POINTER_EVENTS=SUPPORT_POINTER||SUPPORT_MSPOINTER;var isValidKey=function(event,inputKey){if(!inputKey||inputKey.indexOf(ANY)>-1||(inputKey.indexOf(NONE)>-1&&!event.shiftKey&&!event.ctrlKey&&!event.altKey&&!event.metaKey)||(inputKey.indexOf(SHIFT)>-1&&event.shiftKey)||(inputKey.indexOf(CTRL)>-1&&event.ctrlKey)||(inputKey.indexOf(ALT)>-1&&event.altKey)||(inputKey.indexOf(META)>-1&&event.metaKey)){return!0} 190return!1};var EventInput=(function(){function EventInput(){var _this=this;this._stopContextMenu=function(event){event.preventDefault();win$1.removeEventListener("contextmenu",_this._stopContextMenu)}} 191var __proto=EventInput.prototype;__proto.extendEvent=function(event){var _a;var prevEvent=this.prevEvent;var center=this._getCenter(event);var movement=prevEvent?this._getMovement(event):{x:0,y:0,};var scale=prevEvent?this._getScale(event):1;var angle=prevEvent?getAngle(center.x-prevEvent.center.x,center.y-prevEvent.center.y):0;var deltaX=prevEvent?prevEvent.deltaX+movement.x:movement.x;var deltaY=prevEvent?prevEvent.deltaY+movement.y:movement.y;var offsetX=movement.x;var offsetY=movement.y;var latestInterval=this._latestInterval;var timeStamp=Date.now();var deltaTime=latestInterval?timeStamp-latestInterval.timestamp:0;var velocityX=prevEvent?prevEvent.velocityX:0;var velocityY=prevEvent?prevEvent.velocityY:0;if(!latestInterval||deltaTime>=VELOCITY_INTERVAL){if(latestInterval){(_a=[(deltaX-latestInterval.deltaX)/deltaTime,(deltaY-latestInterval.deltaY)/deltaTime]),(velocityX=_a[0]),(velocityY=_a[1])} 192this._latestInterval={timestamp:timeStamp,deltaX:deltaX,deltaY:deltaY,}} 193return{srcEvent:event,scale:scale,angle:angle,center:center,deltaX:deltaX,deltaY:deltaY,offsetX:offsetX,offsetY:offsetY,velocityX:velocityX,velocityY:velocityY,preventSystemEvent:!0,}};__proto._getDistance=function(start,end){var x=end.clientX-start.clientX;var y=end.clientY-start.clientY;return Math.sqrt(x*x+y*y)};__proto._getButton=function(event){var buttonCodeMap={1:MOUSE_LEFT,2:MOUSE_RIGHT,4:MOUSE_MIDDLE,};var button=this._isTouchEvent(event)?MOUSE_LEFT:buttonCodeMap[event.buttons];return button?button:null};__proto._isTouchEvent=function(event){return event.type&&event.type.indexOf("touch")>-1};__proto._isValidButton=function(button,inputButton){return inputButton.indexOf(button)>-1};__proto._isValidEvent=function(event,inputKey,inputButton){return(!inputKey||isValidKey(event,inputKey))&&(!inputButton||this._isValidButton(this._getButton(event),inputButton))};__proto._preventMouseButton=function(event,button){if(button===MOUSE_RIGHT){win$1.addEventListener("contextmenu",this._stopContextMenu)}else if(button===MOUSE_MIDDLE){event.preventDefault()}};return EventInput})();var MouseEventInput=(function(_super){__extends$1(MouseEventInput,_super);function MouseEventInput(){var _this=(_super!==null&&_super.apply(this,arguments))||this;_this.start=["mousedown"];_this.move=["mousemove"];_this.end=["mouseup"];return _this} 194var __proto=MouseEventInput.prototype;__proto.onEventStart=function(event,inputKey,inputButton){var button=this._getButton(event);if(!this._isValidEvent(event,inputKey,inputButton)){return null} 195this._preventMouseButton(event,button);return this.extendEvent(event)};__proto.onEventMove=function(event,inputKey,inputButton){if(!this._isValidEvent(event,inputKey,inputButton)){return null} 196return this.extendEvent(event)};__proto.onEventEnd=function(){return};__proto.onRelease=function(){this.prevEvent=null;return};__proto.getTouches=function(event,inputButton){if(inputButton){var buttonCodeMap={1:MOUSE_LEFT,2:MOUSE_MIDDLE,3:MOUSE_RIGHT,};return this._isValidButton(buttonCodeMap[event.which],inputButton)&&this.end.indexOf(event.type)===-1?1:0} 197return 0};__proto._getScale=function(){return 1};__proto._getCenter=function(event){return{x:event.clientX,y:event.clientY,}};__proto._getMovement=function(event){var prev=this.prevEvent.srcEvent;return{x:event.clientX-prev.clientX,y:event.clientY-prev.clientY,}};return MouseEventInput})(EventInput);var TouchEventInput=(function(_super){__extends$1(TouchEventInput,_super);function TouchEventInput(){var _this=(_super!==null&&_super.apply(this,arguments))||this;_this.start=["touchstart"];_this.move=["touchmove"];_this.end=["touchend","touchcancel"];return _this} 198var __proto=TouchEventInput.prototype;
198__proto.onEventStart=function(event,inputKey){this._baseTouches=event.touches;if(!this._isValidEvent(event,inputKey)){return null} 199return this.extendEvent(event)};__proto.onEventMove=function(event,inputKey){if(!this._isValidEvent(event,inputKey)){return null} 200return this.extendEvent(event)};__proto.onEventEnd=function(event){this._baseTouches=event.touches;return};__proto.onRelease=function(){this.prevEvent=null;this._baseTouches=null;return};__proto.getTouches=function(event){return event.touches.length};__proto._getScale=function(event){if(event.touches.length!==2||this._baseTouches.length<2){return null} 201return this._getDistance(event.touches[0],event.touches[1])/this._getDistance(this._baseTouches[0],this._baseTouches[1])};__proto._getCenter=function(event){return{x:event.touches[0].clientX,y:event.touches[0].clientY,}};__proto._getMovement=function(event){var prev=this.prevEvent.srcEvent;if(event.touches[0].identifier!==prev.touches[0].identifier){return{x:0,y:0,}} 202return{x:event.touches[0].clientX-prev.touches[0].clientX,y:event.touches[0].clientY-prev.touches[0].clientY,}};return TouchEventInput})(EventInput);var PointerEventInput=(function(_super){__extends$1(PointerEventInput,_super);function PointerEventInput(){var _this=(_super!==null&&_super.apply(this,arguments))||this;_this.start=SUPPORT_POINTER?["pointerdown"]:["MSPointerDown"];_this.move=SUPPORT_POINTER?["pointermove"]:["MSPointerMove"];_this.end=SUPPORT_POINTER?["pointerup","pointercancel"]:["MSPointerUp","MSPointerCancel"];_this._firstInputs=[];_this._recentInputs=[];return _this} 203var __proto=PointerEventInput.prototype;__proto.onEventStart=function(event,inputKey,inputButton){var button=this._getButton(event);if(!this._isValidEvent(event,inputKey,inputButton)){return null} 204this._preventMouseButton(event,button);this._updatePointerEvent(event);return this.extendEvent(event)};__proto.onEventMove=function(event,inputKey,inputButton){if(!this._isValidEvent(event,inputKey,inputButton)){return null} 205this._updatePointerEvent(event);return this.extendEvent(event)};__proto.onEventEnd=function(event){this._removePointerEvent(event)};__proto.onRelease=function(){this.prevEvent=null;this._firstInputs=[];this._recentInputs=[];return};__proto.getTouches=function(){return this._recentInputs.length};__proto._getScale=function(){if(this._recentInputs.length!==2){return null} 206return this._getDistance(this._recentInputs[0],this._recentInputs[1])/this._getDistance(this._firstInputs[0],this._firstInputs[1])};__proto._getCenter=function(event){return{x:event.clientX,y:event.clientY,}};__proto._getMovement=function(event){var prev=this.prevEvent.srcEvent;if(event.pointerId!==prev.pointerId){return{x:0,y:0,}} 207return{x:event.clientX-prev.clientX,y:event.clientY-prev.clientY,}};__proto._updatePointerEvent=function(event){var _this=this;var addFlag=!1;this._recentInputs.forEach(function(e,i){if(e.pointerId===event.pointerId){addFlag=!0;_this._recentInputs[i]=event}});if(!addFlag){this._firstInputs.push(event);this._recentInputs.push(event)}};__proto._removePointerEvent=function(event){this._firstInputs=this._firstInputs.filter(function(x){return x.pointerId!==event.pointerId});this._recentInputs=this._recentInputs.filter(function(x){return x.pointerId!==event.pointerId})};return PointerEventInput})(EventInput);var TouchMouseEventInput=(function(_super){__extends$1(TouchMouseEventInput,_super);function TouchMouseEventInput(){var _this=(_super!==null&&_super.apply(this,arguments))||this;_this.start=["mousedown","touchstart"];_this.move=["mousemove","touchmove"];_this.end=["mouseup","touchend","touchcancel"];return _this} 208var __proto=TouchMouseEventInput.prototype;__proto.onEventStart=function(event,inputKey,inputButton){var button=this._getButton(event);if(this._isTouchEvent(event)){this._baseTouches=event.touches} 209if(!this._isValidEvent(event,inputKey,inputButton)){return null} 210this._preventMouseButton(event,button);return this.extendEvent(event)};__proto.onEventMove=function(event,inputKey,inputButton){if(!this._isValidEvent(event,inputKey,inputButton)){return null} 211return this.extendEvent(event)};__proto.onEventEnd=function(event){if(this._isTouchEvent(event)){this._baseTouches=event.touches} 212return};__proto.onRelease=function(){this.prevEvent=null;this._baseTouches=null;return};__proto.getTouches=function(event){return this._isTouchEvent(event)?event.touches.length:0};__proto._getScale=function(event){if(this._isTouchEvent(event)){if(event.touches.length!==2||this._baseTouches.length<2){return 1} 213return this._getDistance(event.touches[0],event.touches[1])/this._getDistance(this._baseTouches[0],this._baseTouches[1])} 214return this.prevEvent.scale};__proto._getCenter=function(event){if(this._isTouchEvent(event)){return{x:event.touches[0].clientX,y:event.touches[0].clientY,}} 215return{x:event.clientX,y:event.clientY,}};__proto._getMovement=function(event){var _this=this;var prev=this.prevEvent.srcEvent;var _a=[event,prev].map(function(e){if(_this._isTouchEvent(e)){return{id:e.touches[0].identifier,x:e.touches[0].clientX,y:e.touches[0].clientY,}} 216return{id:null,x:e.clientX,y:e.clientY,}}),nextSpot=_a[0],prevSpot=_a[1];return nextSpot.id===prevSpot.id?{x:nextSpot.x-prevSpot.x,y:nextSpot.y-prevSpot.y,}:{x:0,y:0,}};return TouchMouseEventInput})(EventInput);var toAxis=function(source,offset){return offset.reduce(function(acc,v,i){if(source[i]){acc[source[i]]=v} 217return acc},{})};var convertInputType=function(inputType){if(inputType===void 0){inputType=[]} 218var hasTouch=!1;var hasMouse=!1;var hasPointer=!1;inputType.forEach(function(v){switch(v){case "mouse":hasMouse=!0;break;case "touch":hasTouch=SUPPORT_TOUCH$1;break;case "pointer":hasPointer=SUPPORT_POINTER_EVENTS}});if(hasPointer){return new PointerEventInput()}else if(hasTouch&&hasMouse){return new TouchMouseEventInput()}else if(hasTouch){return new TouchEventInput()}else if(hasMouse){return new MouseEventInput()} 219return null};function getAddEventOptions(eventName){return eventName.indexOf("touch")>-1?{passive:!1,}:!1} 220var InputObserver=(function(){function InputObserver(_a){var options=_a.options,interruptManager=_a.interruptManager,eventManager=_a.eventManager,axisManager=_a.axisManager,animationManager=_a.animationManager;this._isOutside=!1;this._moveDistance=null;this._isStopped=!1;this.options=options;this._interruptManager=interruptManager;this._eventManager=eventManager;this._axisManager=axisManager;this._animationManager=animationManager} 221var __proto=InputObserver.prototype;__proto.get=function(input){return this._axisManager.get(input.axes)};__proto.hold=function(input,event){if(this._interruptManager.isInterrupted()||!input.axes.length){return} 222var changeOption={input:input,event:event,};this._isStopped=!1;this._interruptManager.setInterrupt(!0);
222this._animationManager.stopAnimation(changeOption);if(!this._moveDistance){this._eventManager.hold(this._axisManager.get(),changeOption)} 223this._isOutside=this._axisManager.isOutside(input.axes);this._moveDistance=this._axisManager.get(input.axes)};__proto.change=function(input,event,offset,useAnimation){if(this._isStopped||!this._interruptManager.isInterrupting()||this._axisManager.every(offset,function(v){return v===0})){return} 224var nativeEvent=event.srcEvent?event.srcEvent:event;if(nativeEvent.__childrenAxesAlreadyChanged){return} 225var depaPos=this._moveDistance||this._axisManager.get(input.axes);var destPos;destPos=map(depaPos,function(v,k){return v+(offset[k]||0)});if(this._moveDistance){this._moveDistance=this._axisManager.map(destPos,function(v,_a){var circular=_a.circular,range=_a.range;return circular&&(circular[0]||circular[1])?getCirculatedPos(v,range,circular):v})} 226if(this._isOutside&&this._axisManager.every(depaPos,function(v,opt){return!isOutside(v,opt.range)})){this._isOutside=!1} 227depaPos=this._atOutside(depaPos);destPos=this._atOutside(destPos);if(!this.options.nested||!this._isEndofAxis(offset,depaPos,destPos)){nativeEvent.__childrenAxesAlreadyChanged=!0} 228var changeOption={input:input,event:event,};if(useAnimation){var duration=this._animationManager.getDuration(destPos,depaPos);this._animationManager.animateTo(destPos,duration,changeOption)}else{var isCanceled=!this._eventManager.triggerChange(destPos,depaPos,changeOption,!0);if(isCanceled){this._isStopped=!0;this._moveDistance=null;this._animationManager.finish(!1)}}};__proto.release=function(input,event,velocity,inputDuration){if(this._isStopped||!this._interruptManager.isInterrupting()||!this._moveDistance){return} 229var nativeEvent=event.srcEvent?event.srcEvent:event;if(nativeEvent.__childrenAxesAlreadyReleased){velocity=velocity.map(function(){return 0})} 230var pos=this._axisManager.get(input.axes);var depaPos=this._axisManager.get();var displacement=this._animationManager.getDisplacement(velocity);var offset=toAxis(input.axes,displacement);var destPos=this._axisManager.get(this._axisManager.map(offset,function(v,opt,k){if
230(opt.circular&&(opt.circular[0]||opt.circular[1])){return pos[k]+v}else{return getInsidePosition(pos[k]+v,opt.range,opt.circular,opt.bounce)}}));nativeEvent.__childrenAxesAlreadyReleased=!0;var duration=this._animationManager.getDuration(destPos,pos,inputDuration);if(duration===0){destPos=__assign$1({},depaPos)} 231var param={depaPos:depaPos,destPos:destPos,duration:duration,delta:this._axisManager.getDelta(depaPos,destPos),inputEvent:event,input:input,isTrusted:!0,};this._eventManager.triggerRelease(param);this._moveDistance=null;var userWish=this._animationManager.getUserControl(param);var isEqual=equal(userWish.destPos,depaPos);var changeOption={input:input,event:event,};if(isEqual||userWish.duration===0){if(!isEqual){this._eventManager.triggerChange(userWish.destPos,depaPos,changeOption,!0)} 232this._interruptManager.setInterrupt(!1);if(this._axisManager.isOutside()){this._animationManager.restore(changeOption)}else{this._eventManager.triggerFinish(!0)}}else{this._animationManager.animateTo(userWish.destPos,userWish.duration,changeOption)}};__proto._atOutside=function(pos){var _this=this;if(this._isOutside){return this._axisManager.map(pos,function(v,opt){var tn=opt.range[0]-opt.bounce[0];var tx=opt.range[1]+opt.bounce[1];return v>tx?tx:v<tn?tn:v})}else{return this._axisManager.map(pos,function(v,opt){var min=opt.range[0];var max=opt.range[1];var out=opt.bounce;var circular=opt.circular;if((circular[0]&&v<min)||(circular[1]&&v>max)){return v}else if(v<min){return min-_this._animationManager.interpolate(min-v,out[0])}else if(v>max){return max+_this._animationManager.interpolate(v-max,out[1])} 233return v})}};__proto._isEndofAxis=function(offset,depaPos,destPos){return this._axisManager.every(depaPos,function(value,option,key){return offset[key]===0||(depaPos[key]===destPos[key]&&isEndofBounce(value,option.range,option.bounce,option.circular))})};return InputObserver})();var clamp=function(value,min,max){return Math.max(Math.min(value,max),min)};var AnimationManager=(function(){function AnimationManager(_a){var options=_a.options,interruptManager=_a.interruptManager,eventManager=_a.eventManager,axisManager=_a.axisManager;this._options=options;this.interruptManager=interruptManager;this.eventManager=eventManager;this.axisManager=axisManager;this.animationEnd=this.animationEnd.bind(this)} 234var __proto=AnimationManager.prototype;__proto.getDuration=function(depaPos,destPos,wishDuration){var _this=this;var duration;if(typeof wishDuration!=="undefined"){duration=wishDuration}else{var durations_1=map(destPos,function(v,k){return getDuration(Math.abs(v-depaPos[k]),_this._options.deceleration)});duration=Object.keys(durations_1).reduce(function(max,v){return Math.max(max,durations_1[v])},-Infinity)} 235return clamp(duration,this._options.minimumDuration,this._options.maximumDuration)};__proto.getDisplacement=function(velocity){var totalVelocity=Math.pow(velocity.reduce(function(total,v){return total+v*v},0),1/velocity.length);var duration=Math.abs(totalVelocity/-this._options.deceleration);return velocity.map(function(v){return(v/2)*duration})};__proto.stopAnimation=function(option){if(this._animateParam){var orgPos_1=this.axisManager.get();var pos=this.axisManager.map(orgPos_1,function(v,opt){return getCirculatedPos(v,opt.range,opt.circular)});if(!every(pos,function(v,k){return orgPos_1[k]===v})){this.eventManager.triggerChange(pos,orgPos_1,option,!!option)} 236this._animateParam=null;if(this._raf){cancelAnimationFrame(this._raf)} 237this._raf=null;this.eventManager.triggerAnimationEnd(!!(option===null||option===void 0?void 0:option.event))}};__proto.getEventInfo=function(){if(this._animateParam&&this._animateParam.input&&this._animateParam.inputEvent){return{input:this._animateParam.input,event:this._animateParam.inputEvent,}}else{return null}};__proto.restore=function(option){var pos=this.axisManager.get();var destPos=this.axisManager.map(pos,function(v,opt){return Math.min(opt.range[1],Math.max(opt.range[0],v))});this.stopAnimation();this.animateTo(destPos,this.getDuration(pos,destPos),option)};__proto.animationEnd=function(){var beforeParam=this.getEventInfo();this._animateParam=null;var circularTargets=this.axisManager.filter(this.axisManager.get(),function(v,opt){return isCircularable(v,opt.range,opt.circular)});if(Object.keys(circularTargets).length>0){this.setTo(this.axisManager.map(circularTargets,function(v,opt){return getCirculatedPos(v,opt.range,opt.circular)}))} 238this.interruptManager.setInterrupt(!1);this.eventManager.triggerAnimationEnd(!!beforeParam);if(this.axisManager.isOutside()){this.restore(beforeParam)}else{this.finish(!!beforeParam)}};__proto.finish=function(isTrusted){this._animateParam=null;this.interruptManager.setInterrupt(!1);this.eventManager.triggerFinish(isTrusted)};__proto.getUserControl=function(param){var userWish=param.setTo();userWish.destPos=this.axisManager.get(userWish.destPos);userWish.duration=clamp(userWish.duration,this._options.minimumDuration,this._options.maximumDuration);return userWish};__proto.animateTo=function(destPos,duration,option){var _this=this;this.stopAnimation();var param=this._createAnimationParam(destPos,duration,option);var depaPos=__assign$1({},param.depaPos);var retTrigger=this.eventManager.triggerAnimationStart(param);var userWish=this.getUserControl(param);if(!retTrigger&&this.axisManager.every(userWish.destPos,function(v,opt){return isCircularable(v,opt.range,opt.circular)})){console.warn("You can't stop the 'animation' event when 'circular' is true.")} 239if(retTrigger&&!equal(userWish.destPos,depaPos)){var inputEvent=(option===null||option===void 0?void 0:option.event)||null;this._animateLoop({depaPos:depaPos,destPos:userWish.destPos,duration:userWish.duration,delta:this.axisManager.getDelta(depaPos,userWish.destPos),isTrusted:!!inputEvent,inputEvent:inputEvent,input:(option===null||option===void 0?void 0:option.input)||null,},function(){return _this.animationEnd()})}};__proto.setTo=function(pos,duration){if(duration===void 0){duration=0} 240var axes=Object.keys(pos);var orgPos=this.axisManager.get(axes);if(equal(pos,orgPos)){return this} 241this.interruptManager.setInterrupt(!0);var movedPos=filter(pos,function(v,k){return orgPos[k]!==v});if(!Object.keys(movedPos).length){return this} 242movedPos=this.axisManager.map(movedPos,function(v,opt){var range=opt.range,circular=opt.circular;if(circular&&(circular[0]||circular[1])){return v}else{return getInsidePosition(v,range,circular)}});if(equal(movedPos,orgPos)){return this} 243if(duration>0){this.animateTo(movedPos,duration)}else{this.stopAnimation();this.eventManager.triggerChange(movedPos);this.finish(!1)} 244return this};__proto.setBy=function(pos,duration){if(duration===void 0){duration=0} 245return this.setTo(map(this.axisManager.get(Object.keys(pos)),function(v,k){return v+pos[k]}),duration)};__proto._createAnimationParam=function(pos,duration,option){var depaPos=this.axisManager.get();var destPos=pos;var inputEvent=(option===null||option===void 0?void 0:option.event)||null;return{depaPos:depaPos,destPos:destPos,duration:clamp(duration,this._options.minimumDuration,this._options.maximumDuration),delta:this.axisManager.getDelta(depaPos,destPos),inputEvent:inputEvent,input:(option===null||option===void 0?void 0:option.input)||null,isTrusted:!!inputEvent,done:this.animationEnd,}};__proto._animateLoop=function(param,complete){var _this=this;if(param.duration){this._animateParam=__assign$1(__assign$1({},param),{startTime:new Date().getTime(),});var originalIntendedPos_1=map(param.destPos,function(v){return v});var state_1=this._initState(this._animateParam);var loop_1=function(){_this._raf=null;var animateParam=_this._animateParam;var nextState=_this._getNextState(state_1);var isCanceled=!_this.eventManager.triggerChange(nextState.pos,state_1.pos);state_1=nextState;if(nextState.finished){animateParam.destPos=_this._getFinalPos(animateParam.destPos,originalIntendedPos_1);if(!equal(animateParam.destPos,_this.axisManager.get(Object.keys(animateParam.destPos)))){_this.eventManager.triggerChange(animateParam.destPos,nextState.pos)} 246complete();return}else if(isCanceled){_this.finish(!1)}else{_this._raf=requestAnimationFrame(loop_1)}};loop_1()}else{this.eventManager.triggerChange(param.destPos);complete()}};__proto._getFinalPos=function(destPos,originalIntendedPos){var _this=this;var ERROR_LIMIT=0.000001;var finalPos=map(destPos,function(value,key){if(value>=originalIntendedPos[key]-ERROR_LIMIT&&value<=originalIntendedPos[key]+ERROR_LIMIT){return originalIntendedPos[key]}else{var roundUnit=_this._getRoundUnit(value,key);var result=roundNumber(value,roundUnit);return result}});return finalPos};__proto._getRoundUnit=function(val,key){var roundUnit=this._options.round;var minRoundUnit=null;if(!roundUnit){var options=this.axisManager.getAxisOptions(key);minRoundUnit=inversePow(Math.max(getDecimalPlace(options.range[0]),getDecimalPlace(options.range[1]),getDecimalPlace(val)))} 247return minRoundUnit||roundUnit};return AnimationManager})();var EasingManager=(function(_super){__extends$1(EasingManager,_super);function EasingManager(){var _this=(_super!==null&&_super.apply(this,arguments))||this;_this._useDuration=!0;return _this} 248var __proto=EasingManager.prototype;__proto.interpolate=function(displacement,threshold){var initSlope=this._easing(0.00001)/0.00001;return this._easing(displacement/(threshold*initSlope))*threshold};__proto.updateAnimation=function(options){var _a;var animateParam=this._animateParam;if(!animateParam){return} 249var diffTime=new Date().getTime()-animateParam.startTime;var pos=(options===null||options===void 0?void 0:options.destPos)||animateParam.destPos;var duration=(_a=options===null||options===void 0?void 0:options.duration)!==null&&_a!==void 0?_a:animateParam.duration;if((options===null||options===void 0?void 0:options.restart)||duration<=diffTime){this.setTo(pos,duration-diffTime);return} 250if(options===null||options===void 0?void 0:options.destPos){var currentPos=this.axisManager.get();this._initialEasingPer=this._prevEasingPer;animateParam.delta=this.axisManager.getDelta(currentPos,pos);animateParam.destPos=pos} 251if(options===null||options===void 0?void 0:options.duration){var ratio=(diffTime+this._durationOffset)/animateParam.duration;this._durationOffset=ratio*duration-diffTime;animateParam.duration=duration}};__proto._initState=function(info){this._initialEasingPer=0;this._prevEasingPer=0;this._durationOffset=0;return{pos:info.depaPos,easingPer:0,finished:!1,}};__proto._getNextState=function(prevState){var _this=this;var animateParam=this._animateParam;var prevPos=prevState.pos;var destPos=animateParam.destPos;var directions=map(prevPos,function(value,key){return value<=destPos[key]?1:-1});var diffTime=new Date().getTime()-animateParam.startTime;var ratio=(diffTime+this._durationOffset)/animateParam.duration;var easingPer=this._easing(ratio);var toPos=this.axisManager.map(prevPos,function(pos,options,key){var nextPos=ratio>=1?destPos[key]:pos+(animateParam.delta[key]*(easingPer-_this._prevEasingPer))/(1-_this._initialEasingPer);var circulatedPos=getCirculatedPos(nextPos,options.range,options.circular);if(nextPos!==circulatedPos){var rangeOffset=directions[key]*(options.range[1]-options.range[0]);destPos[key]-=rangeOffset;prevPos[key]-=rangeOffset}
252return circulatedPos});this._prevEasingPer=easingPer;return{pos:toPos,easingPer:easingPer,finished:easingPer>=1,}};__proto._easing=function(p){return p>1?1:this._options.easing(p)};return EasingManager})(AnimationManager);var Axes=(function(_super){__extends$1(Axes,_super);function Axes(axis,options,startPos){if(axis===void 0){axis={}} 253if(options===void 0){options={}} 254if(startPos===void 0){startPos={}} 255var _this=_super.call(this)||this;_this.axis=axis;_this._inputs=[];_this.options=__assign$1({easing:function(x){return 1-Math.pow(1-x,3)},interruptable:!0,maximumDuration:Infinity,minimumDuration:0,deceleration:0.0006,round:null,nested:!1,},options);Object.keys(startPos).forEach(function(key){_this.axis[key].startPos=startPos[key]});_this.interruptManager=new InterruptManager(_this.options);_this.axisManager=new AxisManager(_this.axis);_this.eventManager=new EventManager(_this);_this.animationManager=new EasingManager(_this);_this.inputObserver=new InputObserver(_this);_this.eventManager.setAnimationManager(_this.animationManager);_this.eventManager.triggerChange(_this.axisManager.get());return _this} 256var __proto=Axes.prototype;__proto.connect=function(axes,inputType){var mapped;if(typeof axes==="string"){mapped=axes.split(" ")}else{mapped=axes.concat()} 257if(~this._inputs.indexOf(inputType)){this.disconnect(inputType)} 258inputType.mapAxes(mapped);inputType.connect(this.inputObserver);this._inputs.push(inputType);return this};__proto.disconnect=function(inputType){if(inputType){var index=this._inputs.indexOf(inputType);if(index>=0){this._inputs[index].disconnect();this._inputs.splice(index,1)}}else{this._inputs.forEach(function(v){return v.disconnect()});this._inputs=[]} 259return this};__proto.get=function(axes){return this.axisManager.get(axes)};__proto.setTo=function(pos,duration){if(duration===void 0){duration=0} 260this.animationManager.setTo(pos,duration);return this};__proto.setBy=function(pos,duration){if(duration===void 0){duration=0} 261this.animationManager.setBy(pos,duration);return this};__proto.setOptions=function(options){this.options=__assign$1(__assign$1({},this.options),options);return this};__proto.setAxis=function(axis){this.axisManager.setAxis(axis);return this};__proto.stopAnimation=function(){this.animationManager.stopAnimation();this.animationManager.finish(!1);return this};__proto.updateAnimation=function(options){this.animationManager.updateAnimation(options);return this};__proto.isBounceArea=function(axes){return this.axisManager.isOutside(axes)};__proto.destroy=function(){this.disconnect();this.eventManager.destroy()};Axes.VERSION="3.8.3";Axes.TRANSFORM=TRANSFORM$1;Axes.DIRECTION_NONE=DIRECTION_NONE;Axes.DIRECTION_LEFT=DIRECTION_LEFT;Axes.DIRECTION_RIGHT=DIRECTION_RIGHT;Axes.DIRECTION_UP=DIRECTION_UP;Axes.DIRECTION_DOWN=DIRECTION_DOWN;Axes.DIRECTION_HORIZONTAL=DIRECTION_HORIZONTAL;Axes.DIRECTION_VERTICAL=DIRECTION_VERTICAL;Axes.DIRECTION_ALL=DIRECTION_ALL;Axes=__decorate([ReactiveSubscribe],Axes);return Axes})(Component);var getDirectionByAngle=function(angle,thresholdAngle){if(thresholdAngle<0||thresholdAngle>90){return DIRECTION_NONE} 262var toAngle=Math.abs(angle);return toAngle>thresholdAngle&&toAngle<180-thresholdAngle?DIRECTION_VERTICAL:DIRECTION_HORIZONTAL};var PanInput=(function(){function PanInput(el,options){var _this=this;this.axes=[];this.element=null;this._enabled=!1;this._activeEvent=null;this._atRightEdge=!1;this._rightEdgeTimer=0;this._dragged=!1;this._isOverThreshold=!1;this._preventClickWhenDragged=function(e){if(_this._dragged){e.preventDefault();e.stopPropagation()} 263_this._dragged=!1};this._voidFunction=function(){};this.element=$(el);this.options=__assign$1({inputType:["touch","mouse","pointer"],inputKey:[ANY],inputButton:[MOUSE_LEFT],scale:[1,1],thresholdAngle:45,threshold:0,preventClickOnDrag:!1,iOSEdgeSwipeThreshold:IOS_EDGE_THRESHOLD,releaseOnScroll:!1,touchAction:null,},options);this._onPanstart=this._onPanstart.bind(this);this._onPanmove=this._onPanmove.bind(this);this._onPanend=this._onPanend.bind(this)} 264var __proto=PanInput.prototype;__proto.mapAxes=function(axes){this._direction=getDirection(!!axes[0],!!axes[1]);this.axes=axes};__proto.connect=function(observer){if(this._activeEvent){this._detachElementEvent();this._detachWindowEvent(this._activeEvent)} 265this._attachElementEvent(observer);this._originalCssProps=setCssProps(this.element,this.options,this._direction);return this};__proto.disconnect=function(){this._detachElementEvent();this._detachWindowEvent(this._activeEvent);if(!isCssPropsFromAxes(this._originalCssProps)){revertCssProps(this.element,this._originalCssProps)} 266this._direction=DIRECTION_NONE;return this};__proto.destroy=function(){this.disconnect();this.element=null};__proto.enable=function(){this._enabled=!0;return this};__proto.disable=function(){this._enabled=!1;return this};__proto.isEnabled=function(){return this._enabled};__proto.release=function(){var activeEvent=this._activeEvent;var prevEvent=activeEvent.prevEvent;activeEvent.onRelease();this._observer.release(this,prevEvent,[0,0]);this._detachWindowEvent(activeEvent);return this};__proto._onPanstart=function(event){var _a=this.options,inputKey=_a.inputKey,inputButton=_a.inputButton;var activeEvent=this._activeEvent;var panEvent=activeEvent.onEventStart(event,inputKey,inputButton);if(!panEvent||!this._enabled||activeEvent.getTouches(event,inputButton)>1){return} 267if(panEvent.srcEvent.cancelable!==!1){var edgeThreshold=this.options.iOSEdgeSwipeThreshold;this._dragged=!1;this._isOverThreshold=!1;this._observer.hold(this,panEvent);this._atRightEdge=IS_IOS_SAFARI&&panEvent.center.x>window.innerWidth-edgeThreshold;this._attachWindowEvent(activeEvent);activeEvent.prevEvent=panEvent}};__proto._onPanmove=function(event){var _this=this;var _a=this.options,iOSEdgeSwipeThreshold=_a.iOSEdgeSwipeThreshold,preventClickOnDrag=_a.preventClickOnDrag,releaseOnScroll=_a.releaseOnScroll,inputKey=_a.inputKey,inputButton=_a.inputButton,threshold=_a.threshold,thresholdAngle=_a.thresholdAngle;var activeEvent=this._activeEvent;var panEvent=activeEvent.onEventMove(event,inputKey,inputButton);var touches=activeEvent.getTouches(event,inputButton);if(touches===0||(releaseOnScroll&&panEvent&&!panEvent.srcEvent.cancelable)){this._onPanend(event);return} 268if(!panEvent||!this._enabled||touches>1){return} 269var userDirection=getDirectionByAngle(panEvent.angle,thresholdAngle);var useHorizontal=useDirection(DIRECTION_HORIZONTAL,this._direction,userDirection);var useVertical=useDirection(DIRECTION_VERTICAL,this._direction,userDirection);if(activeEvent.prevEvent&&IS_IOS_SAFARI){var swipeLeftToRight=panEvent.center.x<0;if(swipeLeftToRight){this.release();return}else if(this._atRightEdge){clearTimeout(this._rightEdgeTimer);var swipeRightToLeft=panEvent.deltaX<-iOSEdgeSwipeThreshold;if(swipeRightToLeft){this._atRightEdge=!1}else{this._rightEdgeTimer=window.setTimeout(function(){return _this.release()},100)}}} 270var distance=this._getDistance([panEvent.deltaX,panEvent.deltaY],[useHorizontal,useVertical]);var offset=this._getOffset([panEvent.offsetX,panEvent.offsetY],[useHorizontal,useVertical]);var prevent=offset.some(function(v){return v!==0});if(prevent){if(panEvent.srcEvent.cancelable!==!1){panEvent.srcEvent.preventDefault()} 271panEvent.srcEvent.stopPropagation()} 272panEvent.preventSystemEvent=prevent;if(prevent&&(this._isOverThreshold||distance>=threshold)){this._dragged=preventClickOnDrag;this._isOverThreshold=!0;this._observer.change(this,panEvent,toAxis(this.axes,offset))} 273activeEvent.prevEvent=panEvent};__proto._onPanend=function(event){var inputButton=this.options.inputButton;var activeEvent=this._activeEvent;activeEvent.onEventEnd(event);if(!this._enabled||activeEvent.getTouches(event,inputButton)!==0){return} 274this._detachWindowEvent(activeEvent);clearTimeout(this._rightEdgeTimer);var prevEvent=activeEvent.prevEvent;var velocity=this._isOverThreshold?this._getOffset([Math.abs(prevEvent.velocityX)*(prevEvent.offsetX<0?-1:1),Math.abs(prevEvent.velocityY)*(prevEvent.offsetY<0?-1:1)],[useDirection(DIRECTION_HORIZONTAL,this._direction),useDirection(DIRECTION_VERTICAL,this._direction)]):[0,0];activeEvent.onRelease();this._observer.release(this,prevEvent,velocity)};__proto._attachWindowEvent=function(activeEvent){var _this=this;activeEvent===null||activeEvent===void 0?void 0:activeEvent.move.forEach(function(event){window.addEventListener(event,_this._onPanmove,getAddEventOptions(event))});activeEvent===null||activeEvent===void 0?void 0:activeEvent.end.forEac
274h(function(event){window.addEventListener(event,_this._onPanend,getAddEventOptions(event))})};__proto._detachWindowEvent=function(activeEvent){var _this=this;activeEvent===null||activeEvent===void 0?void 0:activeEvent.move.forEach(function(event){window.removeEventListener(event,_this._onPanmove)});activeEvent===null||activeEvent===void 0?void 0:activeEvent.end.forEach(function(event){window.removeEventListener(event,_this._onPanend)})};__proto._getOffset=function(properties,direction){var scale=this.options.scale;return[direction[0]?properties[0]*scale[0]:0,direction[1]?properties[1]*scale[1]:0]};__proto._getDistance=function(delta,direction){return Math.sqrt(Number(direction[0])*Math.pow(delta[0],2)+Number(direction[1])*Math.pow(delta[1],2))};__proto._attachElementEvent=function(observer){var _this=this;var activeEvent=convertInputType(this.options.inputType);var element=this.element;if(!activeEvent){return} 275if(!element){throw new Error("Element to connect input does not exist.")} 276this._observer=observer;this._enabled=!0;this._activeEvent=activeEvent;element.addEventListener("click",this._preventClickWhenDragged,!0);activeEvent.start.forEach(function(event){element.addEventListener(event,_this._onPanstart)});activeEvent.move.forEach(function(event){element.addEventListener(event,_this._voidFunction)})};__proto._detachElementEvent=function(){var _this=this;var activeEvent=this._activeEvent;var element=this.element;if(element){element.removeEventListener("click",this._preventClickWhenDragged,!0);activeEvent===null||activeEvent===void 0?void 0:activeEvent.start.forEach(function(event){element.removeEventListener(event,_this._onPanstart)});activeEvent===null||activeEvent===void 0?void 0:activeEvent.move.forEach(function(event){element.removeEventListener(event,_this._voidFunction)})} 277this._enabled=!1;this._observer=null};return PanInput})();var PinchInput=(function(){function PinchInput(el,options){this.axes=[];this.element=null;this._pinchFlag=!1;this._enabled=!1;this._activeEvent=null;this._isOverThreshold=!1;this.element=$(el);this.options=__assign$1({scale:1,threshold:0,inputType:["touch","pointer"],touchAction:"none",},options);this._onPinchStart=this._onPinchStart.bind(this);this._onPinchMove=this._onPinchMove.bind(this);this._onPinchEnd=this._onPinchEnd.bind(this)} 278var __proto=PinchInput.prototype;__proto.mapAxes=function(axes){this.axes=axes};__proto.connect=function(observer){if(this._activeEvent){this._detachEvent()} 279this._attachEvent(observer);this._originalCssProps=setCssProps(this.element,this.options,DIRECTION_ALL);return this};__proto.disconnect=function(){this._detachEvent();if(!isCssPropsFromAxes(this._originalCssProps)){revertCssProps(this.element,this._originalCssProps)} 280return this};__proto.destroy=function(){this.disconnect();this.element=null};__proto.enable=function(){this._enabled=!0;return this};__proto.disable=function(){this._enabled=!1;return this};__proto.isEnabled=function(){return this._enabled};__proto._onPinchStart=function(event){var activeEvent=this._activeEvent;var pinchEvent=activeEvent.onEventStart(event);if(!pinchEvent||!this._enabled||activeEvent.getTouches(event)!==2){return} 281this._baseValue=this._observer.get(this)[this.axes[0]];this._observer.hold(this,event);this._pinchFlag=!0;this._isOverThreshold=!1;activeEvent.prevEvent=pinchEvent};__proto._onPinchMove=function(event){var threshold=this.options.threshold;var activeEvent=this._activeEvent;var pinchEvent=activeEvent.onEventMove(event);if(!pinchEvent||!this._pinchFlag||!this._enabled||activeEvent.getTouches(event)!==2){return} 282var distance=this._getDistance(pinchEvent.scale);var offset=this._getOffset(pinchEvent.scale,activeEvent.prevEvent.scale);if(this._isOverThreshold||distance>=threshold){this._isOverThreshold=!0;this._observer.change(this,event,toAxis(this.axes,[offset]))} 283activeEvent.prevEvent=pinchEvent};__proto._onPinchEnd=function(event){var activeEvent=this._activeEvent;activeEvent.onEventEnd(event);if(!this._pinchFlag||!this._enabled||activeEvent.getTouches(event)>=2){return} 284activeEvent.onRelease();this._observer.release(this,event,[0],0);this._baseValue=null;this._pinchFlag=!1};__proto._attachEvent=function(observer){var _this=this;var activeEvent=convertInputType(this.options.inputType);var element=this.element;if(!activeEvent){return} 285if(!element){throw new Error("Element to connect input does not exist.")} 286this._observer=observer;this._enabled=!0;this._activeEvent=activeEvent;activeEvent.start.forEach(function(event){element.addEventListener(event,_this._onPinchStart,!1)});activeEvent.move.forEach(function(event){element.addEventListener(event,_this._onPinchMove,!1)});
286activeEvent.end.forEach(function(event){element.addEventListener(event,_this._onPinchEnd,!1)})};__proto._detachEvent=function(){var _this=this;var activeEvent=this._activeEvent;var element=this.element;if(element){activeEvent===null||activeEvent===void 0?void 0:activeEvent.start.forEach(function(event){element.removeEventListener(event,_this._onPinchStart,!1)});activeEvent===null||activeEvent===void 0?void 0:activeEvent.move.forEach(function(event){element.removeEventListener(event,_this._onPinchMove,!1)});activeEvent===null||activeEvent===void 0?void 0:activeEvent.end.forEach(function(event){element.removeEventListener(event,_this._onPinchEnd,!1)})} 287this._enabled=!1;this._observer=null};__proto._getOffset=function(pinchScale,prev){if(prev===void 0){prev=1} 288return this._baseValue*(pinchScale-prev)*this.options.scale};__proto._getDistance=function(pinchScale){return Math.abs(pinchScale-1)};return PinchInput})();var WheelInput=(function(){function WheelInput(el,options){this.axes=[];this.element=null;this._enabled=!1;this._holding=!1;this._timer=null;this.element=$(el);this.options=__assign$1({inputKey:[ANY],scale:1,releaseDelay:300,useNormalized:!0,useAnimation:!1,},options);this._onWheel=this._onWheel.bind(this)} 289var __proto=WheelInput.prototype;__proto.mapAxes=function(axes){this._direction=getDirection(!!axes[1],!!axes[0]);this.axes=axes};__proto.connect=function(observer){this._detachEvent();this._attachEvent(observer);return this};__proto.disconnect=function(){this._detachEvent();return this};__proto.destroy=function(){this.disconnect();this.element=null};__proto.enable=function(){this._enabled=!0;return this};__proto.disable=function(){this._enabled=!1;return this};__proto.isEnabled=function(){return this._enabled};__proto._onWheel=function(event){var _this=this;if(!this._enabled||!isValidKey(event,this.options.inputKey)){return} 290var offset=this._getOffset([event.deltaY,event.deltaX],[useDirection(DIRECTION_VERTICAL,this._direction),useDirection(DIRECTION_HORIZONTAL,this._direction)]);if(offset[0]===0&&offset[1]===0){return} 291event.preventDefault();if(!this._holding){this._observer.hold(this,event);this._holding=!0} 292this._observer.change(this,event,toAxis(this.axes,offset),this.options.useAnimation);clearTimeout(this._timer);this._timer=setTimeout(function(){if(_this._holding){_this._holding=!1;_this._observer.release(_this,event,[0])}},this.options.releaseDelay)};__proto._getOffset=function(properties,direction){var scale=this.options.scale;var useNormalized=this.options.useNormalized;return[direction[0]&&properties[0]?(properties[0]>0?-1:1)*(useNormalized?1:Math.abs(properties[0]))*scale:0,direction[1]&&properties[1]?(properties[1]>0?-1:1)*(useNormalized?1:Math.abs(properties[1]))*scale:0]};__proto._attachEvent=function(observer){var element=this.element;if(!element){throw new Error("Element to connect input does not exist.")} 293this._observer=observer;element.addEventListener("wheel",this._onWheel);this._enabled=!0};__proto._detachEvent=function(){var element=this.element;if(element){this.element.removeEventListener("wheel",this._onWheel)} 294this._enabled=!1;this._observer=null;if(this._timer){clearTimeout(this._timer);this._timer=null}};return WheelInput})();var KEY_LEFT_ARROW=37;var KEY_A=65;var KEY_UP_ARROW=38;var KEY_W=87;var KEY_RIGHT_ARROW=39;var KEY_D=68;var KEY_DOWN_ARROW=40;var KEY_S=83;var DIRECTION_REVERSE=-1;var DIRECTION_FORWARD=1;var DIRECTION_HORIZONTAL$1=-1;var DIRECTION_VERTICAL$1=1;var DELAY=80;var MoveKeyInput=(function(){function MoveKeyInput(el,options){this.axes=[];this.element=null;this._enabled=!1;this._holding=!1;this._timer=null;this.element=$(el);this.options=__assign$1({scale:[1,1],},options);this._onKeydown=this._onKeydown.bind(this);this._onKeyup=this._onKeyup.bind(this)} 295var __proto=MoveKeyInput.prototype;__proto.mapAxes=function(axes){this.axes=axes};__proto.connect=function(observer){this._detachEvent();if(this.element.getAttribute("tabindex")!=="0"){this.element.setAttribute("tabindex","0")} 296this._attachEvent(observer);return this};__proto.disconnect=function(){this._detachEvent();return this};__proto.destroy=function(){this.disconnect();this.element=null};__proto.enable=function(){this._enabled=!0;return this};__proto.disable=function(){this._enabled=!1;return this};__proto.isEnabled=function(){return this._enabled};__proto._onKeydown=function(event){if(!this._enabled){return} 297var isMoveKey=!0;var direction=DIRECTION_FORWARD;var move=DIRECTION_HORIZONTAL$1;switch(event.keyCode){case KEY_LEFT_ARROW:case KEY_A:direction=DIRECTION_REVERSE;break;case KEY_RIGHT_ARROW:case KEY_D:break;case KEY_DOWN_ARROW:case KEY_S:direction=DIRECTION_REVERSE;move=DIRECTION_VERTICAL$1;break;case KEY_UP_ARROW:case KEY_W:move=DIRECTION_VERTICAL$1;break;default:isMoveKey=!1} 298if((move===DIRECTION_HORIZONTAL$1&&!this.axes[0])||(move===DIRECTION_VERTICAL$1&&!this.axes[1])){isMoveKey=!1} 299if(!isMoveKey){return} 300event.preventDefault();var offsets=move===DIRECTION_HORIZONTAL$1?[+this.options.scale[0]*direction,0]:[0,+this.options.scale[1]*direction];if(!this._holding){this._observer.hold(this,event);this._holding=!0} 301clearTimeout(this._timer);this._observer.change(this,event,toAxis(this.axes,offsets))};__proto._onKeyup=function(event){var _this=this;if(!this._holding){return} 302clearTimeout(this._timer);this._timer=setTimeout(function(){_this._observer.release(_this,event,[0,0]);_this._holding=!1},DELAY)};__proto._attachEvent=function(observer){var element=this.element;if(!element){throw new Error("Element to connect input does not exist.")} 303this._observer=observer;element.addEventListener("keydown",this._onKeydown,!1);element.addEventListener("keypress",this._onKeydown,!1);element.addEventListener("keyup",this._onKeyup,!1);this._enabled=!0};__proto._detachEvent=function(){var element=this.element;if(element){element.removeEventListener("keydown",this._onKeydown,!1);element.removeEventListener("keypress",this._onKeydown,!1);element.removeEventListener("keyup",this._onKeyup,!1)} 304this._enabled=!1;this._observer=null};return MoveKeyInput})();
304var EPSILON=0.000001;var ARRAY_TYPE=typeof Float32Array!=="undefined"?Float32Array:Array;var degree=Math.PI/180;function toRadian(a){return a*degree} 305if(!Math.hypot) 306Math.hypot=function(){var y=0,i=arguments.length;while(i--){y+=arguments[i]*arguments[i]} 307return Math.sqrt(y)};function create(){var out=new ARRAY_TYPE(9);if(ARRAY_TYPE!=Float32Array){out[1]=0;out[2]=0;out[3]=0;out[5]=0;out[6]=0;out[7]=0} 308out[0]=1;out[4]=1;out[8]=1;return out} 309function fromMat4(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[4];out[4]=a[5];out[5]=a[6];out[6]=a[8];out[7]=a[9];out[8]=a[10];return out} 310function invert(out,a){var a00=a[0],a01=a[1],a02=a[2];var a10=a[3],a11=a[4],a12=a[5];var a20=a[6],a21=a[7],a22=a[8];var b01=a22*a11-a12*a21;var b11=-a22*a10+a12*a20;var b21=a21*a10-a11*a20;var det=a00*b01+a01*b11+a02*b21;if(!det){return null} 311det=1.0/det;out[0]=b01*det;out[1]=(-a22*a01+a02*a21)*det;out[2]=(a12*a01-a02*a11)*det;out[3]=b11*det;out[4]=(a22*a00-a02*a20)*det;out[5]=(-a12*a00+a02*a10)*det;out[6]=b21*det;out[7]=(-a21*a00+a01*a20)*det;out[8]=(a11*a00-a01*a10)*det;return out} 312function create$1(){var out=new ARRAY_TYPE(16);if(ARRAY_TYPE!=Float32Array){out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[11]=0;out[12]=0;out[13]=0;out[14]=0} 313out[0]=1;out[5]=1;out[10]=1;out[15]=1;return out} 314function identity(out){out[0]=1;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=1;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=1;out[11]=0;out[12]=0;out[13]=0;out[14]=0;out[15]=1;return out} 315function rotateX(out,a,rad){var s=Math.sin(rad);var c=Math.cos(rad);var a10=a[4];var a11=a[5];var a12=a[6];var a13=a[7];var a20=a[8];var a21=a[9];var a22=a[10];var a23=a[11];if(a!==out){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15]} 316out[4]=a10*c+a20*s;out[5]=a11*c+a21*s;out[6]=a12*c+a22*s;out[7]=a13*c+a23*s;out[8]=a20*c-a10*s;out[9]=a21*c-a11*s;out[10]=a22*c-a12*s;out[11]=a23*c-a13*s;return out} 317function rotateY(out,a,rad){var s=Math.sin(rad);var c=Math.cos(rad);var a00=a[0];var a01=a[1];var a02=a[2];var a03=a[3];var a20=a[8];var a21=a[9];var a22=a[10];var a23=a[11];if(a!==out){out[4]=a[4];out[5]=a[5];out[6]=a[6];out[7]=a[7];out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15]} 318out[0]=a00*c-a20*s;out[1]=a01*c-a21*s;out[2]=a02*c-a22*s;out[3]=a03*c-a23*s;out[8]=a00*s+a20*c;out[9]=a01*s+a21*c;out[10]=a02*s+a22*c;out[11]=a03*s+a23*c;return out} 319function fromQuat(out,q){var x=q[0],y=q[1],z=q[2],w=q[3];
319var x2=x+x;var y2=y+y;var z2=z+z;var xx=x*x2;var yx=y*x2;var yy=y*y2;var zx=z*x2;var zy=z*y2;var zz=z*z2;var wx=w*x2;var wy=w*y2;var wz=w*z2;out[0]=1-yy-zz;out[1]=yx+wz;out[2]=zx-wy;out[3]=0;out[4]=yx-wz;out[5]=1-xx-zz;out[6]=zy+wx;out[7]=0;out[8]=zx+wy;out[9]=zy-wx;out[10]=1-xx-yy;out[11]=0;out[12]=0;out[13]=0;out[14]=0;out[15]=1;return out} 320function perspective(out,fovy,aspect,near,far){var f=1.0/Math.tan(fovy/2),nf;out[0]=f/aspect;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=f;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[11]=-1;out[12]=0;out[13]=0;out[15]=0;if(far!=null&&far!==Infinity){nf=1/(near-far);out[10]=(far+near)*nf;out[14]=2*far*near*nf}else{out[10]=-1;out[14]=-2*near} 321return out} 322function create$2(){var out=new ARRAY_TYPE(3);if(ARRAY_TYPE!=Float32Array){out[0]=0;out[1]=0;out[2]=0} 323return out} 324function length(a){var x=a[0];var y=a[1];var z=a[2];return Math.hypot(x,y,z)} 325function fromValues(x,y,z){var out=new ARRAY_TYPE(3);out[0]=x;out[1]=y;out[2]=z;return out} 326function copy(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];return out} 327function set(out,x,y,z){out[0]=x;out[1]=y;out[2]=z;return out} 328function subtract(out,a,b){out[0]=a[0]-b[0];out[1]=a[1]-b[1];out[2]=a[2]-b[2];return out} 329function scale(out,a,b){out[0]=a[0]*b;out[1]=a[1]*b;out[2]=a[2]*b;return out} 330function normalize(out,a){var x=a[0];var y=a[1];var z=a[2];var len=x*x+y*y+z*z;if(len>0){len=1/Math.sqrt(len)} 331out[0]=a[0]*len;out[1]=a[1]*len;out[2]=a[2]*len;return out} 332function dot(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]} 333function cross(out,a,b){var ax=a[0],ay=a[1],az=a[2];var bx=b[0],by=b[1],bz=b[2];out[0]=ay*bz-az*by;out[1]=az*bx-ax*bz;out[2]=ax*by-ay*bx;return out} 334function transformMat3(out,a,m){var x=a[0],y=a[1],z=a[2];out[0]=x*m[0]+y*m[3]+z*m[6];out[1]=x*m[1]+y*m[4]+z*m[7];out[2]=x*m[2]+y*m[5]+z*m[8];return out} 335function transformQuat(out,a,q){var qx=q[0],qy=q[1],qz=q[2],qw=q[3];var x=a[0],y=a[1],z=a[2];var uvx=qy*z-qz*y,uvy=qz*x-qx*z,uvz=qx*y-qy*x;var uuvx=qy*uvz-qz*uvy,uuvy=qz*uvx-qx*uvz,uuvz=qx*uvy-qy*uvx;var w2=qw*2;uvx*=w2;uvy*=w2;uvz*=w2;uuvx*=2;uuvy*=2;uuvz*=2;out[0]=x+uvx+uuvx;out[1]=y+uvy+uuvy;out[2]=z+uvz+uuvz;return out} 336var len=length;
336var forEach=(function(){var vec=create$2();return function(a,stride,offset,count,fn,arg){var i,l;if(!stride){stride=3} 337if(!offset){offset=0} 338if(count){l=Math.min(count*stride+offset,a.length)}else{l=a.length} 339for(i=offset;i<l;i+=stride){vec[0]=a[i];vec[1]=a[i+1];vec[2]=a[i+2];fn(vec,vec,arg);a[i]=vec[0];a[i+1]=vec[1];a[i+2]=vec[2]} 340return a}})();function create$3(){var out=new ARRAY_TYPE(4);if(ARRAY_TYPE!=Float32Array){out[0]=0;out[1]=0;out[2]=0;out[3]=0} 341return out} 342function clone(a){var out=new ARRAY_TYPE(4);out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out} 343function fromValues$1(x,y,z,w){var out=new ARRAY_TYPE(4);out[0]=x;out[1]=y;out[2]=z;out[3]=w;return out} 344function copy$1(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out} 345function normalize$1(out,a){var x=a[0];var y=a[1];var z=a[2];var w=a[3];var len=x*x+y*y+z*z+w*w;if(len>0){len=1/Math.sqrt(len)} 346out[0]=x*len;out[1]=y*len;out[2]=z*len;out[3]=w*len;return out} 347function exactEquals(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]} 348function equals(a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3];var b0=b[0],b1=b[1],b2=b[2],b3=b[3];return Math.abs(a0-b0)<=EPSILON*Math.max(1.0,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1.0,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1.0,Math.abs(a2),Math.abs(b2))&&Math.abs(a3-b3)<=EPSILON*Math.max(1.0,Math.abs(a3),Math.abs(b3))} 349var forEach$1=(function(){var vec=create$3();return function(a,stride,offset,count,fn,arg){var i,l;if(!stride){stride=4} 350if(!offset){offset=0} 351if(count){l=Math.min(count*stride+offset,a.length)}else{l=a.length} 352for(i=offset;i<l;i+=stride){vec[0]=a[i];vec[1]=a[i+1];vec[2]=a[i+2];vec[3]=a[i+3];fn(vec,vec,arg);a[i]=vec[0];a[i+1]=vec[1];a[i+2]=vec[2];a[i+3]=vec[3]} 353return a}})();function create$4(){var out=new ARRAY_TYPE(4);if(ARRAY_TYPE!=Float32Array){out[0]=0;out[1]=0;out[2]=0} 354out[3]=1;return out} 355function setAxisAngle(out,axis,rad){rad=rad*0.5;var s=Math.sin(rad);out[0]=s*axis[0];out[1]=s*axis[1];out[2]=s*axis[2];out[3]=Math.cos(rad);return out} 356function multiply(out,a,b){var ax=a[0],ay=a[1],az=a[2],aw=a[3];var bx=b[0],by=b[1],bz=b[2],bw=b[3];out[0]=ax*bw+aw*bx+ay*bz-az*by;out[1]=ay*bw+aw*by+az*bx-ax*bz;out[2]=az*bw+aw*bz+ax*by-ay*bx;out[3]=aw*bw-ax*bx-ay*by-az*bz;return out} 357function slerp(out,a,b,t){var ax=a[0],ay=a[1],az=a[2],aw=a[3];var bx=b[0],by=b[1],bz=b[2],bw=b[3];var omega,cosom,sinom,scale0,scale1;cosom=ax*bx+ay*by+az*bz+aw*bw;if(cosom<0.0){cosom=-cosom;bx=-bx;by=-by;bz=-bz;bw=-bw} 358if(1.0-cosom>EPSILON){omega=Math.acos(cosom);sinom=Math.sin(omega);scale0=Math.sin((1.0-t)*omega)/sinom;scale1=Math.sin(t*omega)/sinom}else{scale0=1.0-t;scale1=t} 359out[0]=scale0*ax+scale1*bx;out[1]=scale0*ay+scale1*by;out[2]=scale0*az+scale1*bz;out[3]=scale0*aw+scale1*bw;return out} 360function conjugate(out,a){out[0]=-a[0];out[1]=-a[1];out[2]=-a[2];out[3]=a[3];return out} 361function fromMat3(out,m){var fTrace=m[0]+m[4]+m[8];var fRoot;if(fTrace>0.0){fRoot=Math.sqrt(fTrace+1.0);out[3]=0.5*fRoot;fRoot=0.5/fRoot;out[0]=(m[5]-m[7])*fRoot;out[1]=(m[6]-m[2])*fRoot;out[2]=(m[1]-m[3])*fRoot}else{var i=0;if(m[4]>m[0])i=1;if(m[8]>m[i*3+i])i=2;var j=(i+1)%3;var k=(i+2)%3;fRoot=Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k]+1.0);out[i]=0.5*fRoot;fRoot=0.5/fRoot;out[3]=(m[j*3+k]-m[k*3+j])*fRoot;out[j]=(m[j*3+i]+m[i*3+j])*fRoot;out[k]=(m[k*3+i]+m[i*3+k])*fRoot} 362return out} 363var clone$1=clone;var fromValues$2=fromValues$1;var copy$2=copy$1;var normalize$2=normalize$1;var exactEquals$1=exactEquals;var equals$1=equals;var rotationTo=(function(){var tmpvec3=create$2();var xUnitVec3=fromValues(1,0,0);var yUnitVec3=fromValues(0,1,0);return function(out,a,b){var dot$1=dot(a,b);if(dot$1<-0.999999){cross(tmpvec3,xUnitVec3,a);
363if(len(tmpvec3)<0.000001)cross(tmpvec3,yUnitVec3,a);normalize(tmpvec3,tmpvec3);setAxisAngle(out,tmpvec3,Math.PI);return out}else if(dot$1>0.999999){out[0]=0;out[1]=0;out[2]=0;out[3]=1;return out}else{cross(tmpvec3,a,b);out[0]=tmpvec3[0];out[1]=tmpvec3[1];out[2]=tmpvec3[2];out[3]=1+dot$1;return normalize$2(out,out)}}})();var sqlerp=(function(){var temp1=create$4();var temp2=create$4();return function(out,a,b,c,d,t){slerp(temp1,a,d,t);slerp(temp2,b,c,t);slerp(out,temp1,temp2,2*t*(1-t));return out}})();var setAxes=(function(){var matr=create();return function(out,view,right,up){matr[0]=right[0];matr[3]=right[1];matr[6]=right[2];matr[1]=up[0];matr[4]=up[1];matr[7]=up[2];matr[2]=-view[0];matr[5]=-view[1];matr[8]=-view[2];return normalize$2(out,fromMat3(out,matr))}})();function create$5(){var out=new ARRAY_TYPE(2);if(ARRAY_TYPE!=Float32Array){out[0]=0;out[1]=0} 364return out} 365function fromValues$3(x,y){var out=new ARRAY_TYPE(2);out[0]=x;out[1]=y;return out} 366function copy$3(out,a){out[0]=a[0];out[1]=a[1];return out} 367function normalize$3(out,a){var x=a[0],y=a[1];var len=x*x+y*y;if(len>0){len=1/Math.sqrt(len)} 368out[0]=a[0]*len;out[1]=a[1]*len;return out} 369function dot$1(a,b){return a[0]*b[0]+a[1]*b[1]} 370var forEach$2=(function(){var vec=create$5();return function(a,stride,offset,count,fn,arg){var i,l;if(!stride){stride=2} 371if(!offset){offset=0} 372if(count){l=Math.min(count*stride+offset,a.length)}else{l=a.length} 373for(i=offset;i<l;i+=stride){vec[0]=a[i];vec[1]=a[i+1];fn(vec,vec,arg);a[i]=vec[0];a[i+1]=vec[1]} 374return a}})();var quatToVec3=function(quaternion){var baseV=fromValues(0,0,1);transformQuat(baseV,baseV,quaternion);return baseV};var toDegree=function(a){return(a*180)/Math.PI};var util={};util.isPowerOfTwo=function(n){return n&&(n&(n-1))===0};util.extractPitchFromQuat=function(quaternion){var baseV=quatToVec3(quaternion);return-1*Math.atan2(baseV[1],Math.sqrt(Math.pow(baseV[0],2)+Math.pow(baseV[2],2)))};util.hypot=Math.hypot||function(x,y){return Math.sqrt(x*x+y*y)};var ROTATE_CONSTANT={PITCH_DELTA:1,YAW_DELTA_BY_ROLL:2,YAW_DELTA_BY_YAW:3,};ROTATE_CONSTANT[ROTATE_CONSTANT.PITCH_DELTA]={targetAxis:[0,1,0],meshPoint:[0,0,1],};ROTATE_CONSTANT[ROTATE_CONSTANT.YAW_DELTA_BY_ROLL]={targetAxis:[0,1,0],meshPoint:[1,0,0],};ROTATE_CONSTANT[ROTATE_CONSTANT.YAW_DELTA_BY_YAW]={targetAxis:[1,0,0],meshPoint:[0,0,1],};var getRotationDelta=function(prevQ,curQ,rotateKind){var targetAxis=fromValues(ROTATE_CONSTANT[rotateKind].targetAxis[0],ROTATE_CONSTANT[rotateKind].targetAxis[1],ROTATE_CONSTANT[rotateKind].targetAxis[2]);var meshPoint=ROTATE_CONSTANT[rotateKind].meshPoint;var prevQuaternion=clone$1(prevQ);var curQuaternion=clone$1(curQ);normalize$2(prevQuaternion,prevQuaternion);normalize$2(curQuaternion,curQuaternion);var prevPoint=fromValues(0,0,1);var curPoint=fromValues(0,0,1);transformQuat(prevPoint,prevPoint,prevQuaternion);transformQuat(curPoint,curPoint,curQuaternion);transformQuat(targetAxis,targetAxis,curQuaternion);var rotateDistance=dot(targetAxis,cross(create$2(),prevPoint,curPoint));var rotateDirection=rotateDistance>0?1:-1;var meshPoint2=fromValues(meshPoint[0],meshPoint[1],meshPoint[2]);var meshPoint3;if(rotateKind!==ROTATE_CONSTANT.YAW_DELTA_BY_YAW){meshPoint3=fromValues(0,rotateDirection,0)}else{meshPoint3=fromValues(rotateDirection,0,0)} 375transformQuat(meshPoint2,meshPoint2,curQuaternion);transformQuat(meshPoint3,meshPoint3,curQuaternion);var vecU=meshPoint2;var vecV=meshPoint3;var vecN=create$2();cross(vecN,vecU,vecV);normalize(vecN,vecN);var coefficientA=vecN[0];var coefficientB=vecN[1];var coefficientC=vecN[2];curPoint=fromValues(meshPoint[0],meshPoint[1],meshPoint[2]);transformQuat(curPoint,curPoint,curQuaternion);prevPoint=fromValues(meshPoint[0],meshPoint[1],meshPoint[2]);transformQuat(prevPoint,prevPoint,prevQuaternion);var distance=Math.abs(prevPoint[0]*coefficientA+prevPoint[1]*coefficientB+prevPoint[2]*coefficientC);var projectedPrevPoint=create$2();subtract(projectedPrevPoint,prevPoint,scale(create$2(),vecN,distance));var trigonometricRatio=(projectedPrevPoint[0]*curPoint[0]+projectedPrevPoint[1]*curPoint[1]+projectedPrevPoint[2]*curPoint[2])/(length(projectedPrevPoint)*length(curPoint));if(trigonometricRatio>1){trigonometricRatio=1} 376var theta=Math.acos(trigonometricRatio);var crossVec=cross(create$2(),curPoint,projectedPrevPoint);distance=coefficientA*crossVec[0]+coefficientB*crossVec[1]+coefficientC*crossVec[2];var thetaDirection;if(rotateKind!==ROTATE_CONSTANT.YAW_DELTA_BY_YAW){thetaDirection=distance>0?1:-1}else{thetaDirection=distance<0?1:-1} 377var deltaRadian=theta*thetaDirection*rotateDirection;return toDegree(deltaRadian)};var angleBetweenVec2=function(v1,v2){var det=v1[0]*v2[1]-v2[0]*v1[1];var theta=-Math.atan2(det,dot$1(v1,v2));return theta};util.yawOffsetBetween=function(viewDir,targetDir){var viewDirXZ=fromValues$3(viewDir[0],viewDir[2]);var targetDirXZ=fromValues$3(targetDir[0],targetDir[2]);normalize$3(viewDirXZ,viewDirXZ);normalize$3(targetDirXZ,targetDirXZ);var theta=-angleBetweenVec2(viewDirXZ,targetDirXZ);return theta};util.sign=function(x){return Math.sign?Math.sign(x):Number(x>0)-Number(x<0)||+x};util.toDegree=toDegree;util.getRotationDelta=getRotationDelta;util.angleBetweenVec2=angleBetweenVec2;var toAxis$1=function(source,offset){return offset.reduce(function(acc,v,i){if(source[i]){acc[source[i]]=v} 378return acc},{})};var version=-1;var branch=null;var build=null;var match=/Chrome\/([0-9]+)\.(?:[0-9]*)\.([0-9]*)\.([0-9]*)/i.exec(userAgent);if(match){version=parseInt(match[1],10);branch=match[2];build=match[3]} 379var CHROME_VERSION=version;var IS_CHROME_WITHOUT_DEVICE_MOTION=version===65&&branch==="3325"&&parseInt(build,10)<148;var IS_ANDROID=/Android/i.test(userAgent);var CONTROL_MODE_VR=1;var CONTROL_MODE_YAWPITCH=2;var TOUCH_DIRECTION_NONE=1;var TOUCH_DIRECTION_YAW=2;var TOUCH_DIRECTION_PITCH=4;var TOUCH_DIRECTION_ALL=TOUCH_DIRECTION_YAW|TOUCH_DIRECTION_PITCH;var MC_DECELERATION=0.0014;var MC_MAXIMUM_DURATION=1000;var MC_BIND_SCALE=[0.2,0.2];var MAX_FIELD_OF_VIEW=110;var PAN_SCALE=320;var YAW_RANGE_HALF=180;var PITCH_RANGE_HALF=90;var CIRCULAR_PITCH_RANGE_HALF=180;var GYRO_MODE={NONE:"none",YAWPITCH:"yawPitch",VR:"VR",};var MathUtil=win.MathUtil||{};MathUtil.degToRad=Math.PI/180;MathUtil.radToDeg=180/Math.PI;MathUtil.Vector2=function(x,y){this.x=x||0;
379this.y=y||0};MathUtil.Vector2.prototype={constructor:MathUtil.Vector2,set:function(x,y){this.x=x;this.y=y;return this},copy:function(v){this.x=v.x;this.y=v.y;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},};MathUtil.Vector3=function(x,y,z){this.x=x||0;this.y=y||0;this.z=z||0};MathUtil.Vector3.prototype={constructor:MathUtil.Vector3,set:function(x,y,z){this.x=x;this.y=y;this.z=z;return this},copy:function(v){this.x=v.x;this.y=v.y;this.z=v.z;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},normalize:function(){var scalar=this.length();if(scalar!==0){var invScalar=1/scalar;this.multiplyScalar(invScalar)}else{this.x=0;this.y=0;this.z=0} 380return this},multiplyScalar:function(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar},applyQuaternion:function(q){var x=this.x;var y=this.y;var z=this.z;var qx=q.x;var qy=q.y;var qz=q.z;var qw=q.w;var ix=qw*x+qy*z-qz*y;var iy=qw*y+qz*x-qx*z;var iz=qw*z+qx*y-qy*x;var iw=-qx*x-qy*y-qz*z;this.x=ix*qw+iw*-qx+iy*-qz-iz*-qy;this.y=iy*qw+iw*-qy+iz*-qx-ix*-qz;this.z=iz*qw+iw*-qz+ix*-qy-iy*-qx;return this},dot:function(v){return this.x*v.x+this.y*v.y+this.z*v.z},crossVectors:function(a,b){var ax=a.x;var ay=a.y;var az=a.z;var bx=b.x;var by=b.y;var bz=b.z;this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this},};MathUtil.Quaternion=function(x,y,z,w){this.x=x||0;this.y=y||0;this.z=z||0;this.w=w!==undefined?w:1};MathUtil.Quaternion.prototype={constructor:MathUtil.Quaternion,set:function(x,y,z,w){this.x=x;this.y=y;this.z=z;this.w=w;return this},copy:function(quaternion){this.x=quaternion.x;this.y=quaternion.y;this.z=quaternion.z;this.w=quaternion.w;return this},setFromEulerXYZ:function(x,y,z){var c1=Math.cos(x/2);var c2=Math.cos(y/2);var c3=Math.cos(z/2);var s1=Math.sin(x/2);var s2=Math.sin(y/2);var s3=Math.sin(z/2);this.x=s1*c2*c3+c1*s2*s3;this.y=c1*s2*c3-s1*c2*s3;this.z=c1*c2*s3+s1*s2*c3;this.w=c1*c2*c3-s1*s2*s3;return this},setFromEulerYXZ:function(x,y,z){var c1=Math.cos(x/2);var c2=Math.cos(y/2);var c3=Math.cos(z/2);var s1=Math.sin(x/2);var s2=Math.sin(y/2);var s3=Math.sin(z/2);this.x=s1*c2*c3+c1*s2*s3;this.y=c1*s2*c3-s1*c2*s3;this.z=c1*c2*s3-s1*s2*c3;this.w=c1*c2*c3+s1*s2*s3;return this},setFromAxisAngle:function(axis,angle){var halfAngle=angle/2;var s=Math.sin(halfAngle);this.x=axis.x*s;this.y=axis.y*s;this.z=axis.z*s;this.w=Math.cos(halfAngle);return this},multiply:function(q){return this.multiplyQuaternions(this,q)},multiplyQuaternions:function(a,b){var qax=a.x;var qay=a.y;var qaz=a.z;var qaw=a.w;var qbx=b.x;var qby=b.y;var qbz=b.z;var qbw=b.w;this.x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;this.y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;this.z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;this.w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;this.normalize();return this},normalize:function(){var l=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(l===0){this.x=0;this.y=0;this.z=0;this.w=1}else{l=1/l;this.x=this.x*l;this.y=this.y*l;this.z=this.z*l;this.w=this.w*l} 381return this},slerp:function(qb,t){if(t===0)return this;if(t===1)return this.copy(qb);var x=this.x;var y=this.y;var z=this.z;var w=this.w;var cosHalfTheta=w*qb.w+x*qb.x+y*qb.y+z*qb.z;if(cosHalfTheta<0){this.w=-qb.w;this.x=-qb.x;this.y=-qb.y;this.z=-qb.z;cosHalfTheta=-cosHalfTheta}else{this.copy(qb)} 382if(cosHalfTheta>=1.0){this.w=w;this.x=x;this.y=y;this.z=z;return this} 383var halfTheta=Math.acos(cosHalfTheta);var sinHalfTheta=Math.sqrt(1.0-cosHalfTheta*cosHalfTheta);if(Math.abs(sinHalfTheta)<0.001){this.w=0.5*(w+this.w);this.x=0.5*(x+this.x);this.y=0.5*(y+this.y);this.z=0.5*(z+this.z);return this} 384var ratioA=Math.sin((1-t)*halfTheta)/sinHalfTheta;var ratioB=Math.sin(t*halfTheta)/sinHalfTheta;this.w=w*ratioA+this.w*ratioB;this.x=x*ratioA+this.x*ratioB;this.y=y*ratioA+this.y*ratioB;this.z=z*ratioA+this.z*ratioB;return this},setFromUnitVectors:(function(){var v1;var r;var EPS=0.000001;return function(vFrom,vTo){if(v1===undefined)v1=new MathUtil.Vector3();r=vFrom.dot(vTo)+1;if(r<EPS){r=0;if(Math.abs(vFrom.x)>Math.abs(vFrom.z)){v1.set(-vFrom.y,vFrom.x,0)}else{v1.set(0,-vFrom.z,vFrom.y)}}else{v1.crossVectors(vFrom,vTo)} 385this.x=v1.x;this.y=v1.y;this.z=v1.z;this.w=r;this.normalize();return this}})(),};var _a;var userAgent$1=(_a=nav===null||nav===void 0?void 0:nav.userAgent)!==null&&_a!==void 0?_a:"";var Util=win.Util||{};Util.MIN_TIMESTEP=0.001;Util.MAX_TIMESTEP=1;Util.base64=function(mimeType,base64){return"data:"+mimeType+";base64,"+base64};Util.clamp=function(value,min,max){return Math.min(Math.max(min,value),max)};Util.lerp=function(a,b,t){return a+(b-a)*t};Util.isIOS=(function(){var isIOS=/iPad|iPhone|iPod/.test(nav===null||nav===void 0?void 0:nav.platform);return function(){return isIOS}})();Util.isWebViewAndroid=(function(){var isWebViewAndroid=userAgent$1.indexOf("Version")!==-1&&userAgent$1.indexOf("Android")!==-1&&userAgent$1.indexOf("Chrome")!==-1;return function(){return isWebViewAndroid}})();Util.isSafari=(function(){var isSafari=/^((?!chrome|android).)*safari/i.test(userAgent$1);return function(){return isSafari}})();Util.isFirefoxAndroid=(function(){var isFirefoxAndroid=userAgent$1.indexOf("Firefox")!==-1&&userAgent$1.indexOf("Android")!==-1;return function(){return isFirefoxAndroid}})();Util.isR7=(function(){var isR7=userAgent$1.indexOf("R7 Build")!==-1;return function(){return isR7}})();Util.isLandscapeMode=function(){var rtn=win.orientation===90||win.orientation===-90;return Util.isR7()?!rtn:rtn};Util.isTimestampDeltaValid=function(timestampDeltaS){if(isNaN(timestampDeltaS)){return!1} 386if(timestampDeltaS<=Util.MIN_TIMESTEP){return!1} 387if(timestampDeltaS>Util.MAX_TIMESTEP){return!1} 388return!0};Util.getScreenWidth=function(){return Math.max(win.screen.width,win.screen.height)*win.devicePixelRatio};Util.getScreenHeight=function(){return Math.min(win.screen.width,win.screen.height)*win.devicePixelRatio};Util.requestFullscreen=function(element){if(Util.isWebViewAndroid()){return!1} 389if(element.requestFullscreen){element.requestFullscreen()}else if(element.webkitRequestFullscreen){element.webkitRequestFullscreen()}else if(element.mozRequestFullScreen){element.mozRequestFullScreen()}else if(element.msRequestFullscreen){element.msRequestFullscreen()}else{return!1} 390return!0};Util.exitFullscreen=function(){if(doc.exitFullscreen){doc.exitFullscreen()}else if(doc.webkitExitFullscreen){doc.webkitExitFullscreen()}else if(doc.mozCancelFullScreen){doc.mozCancelFullScreen()}else if(doc.msExitFullscreen){doc.msExitFullscreen()}else{return!1} 391return!0};Util.getFullscreenElement=function(){return doc.fullscreenElement||doc.webkitFullscreenElement||doc.mozFullScreenElement||doc.msFullscreenElement};Util.linkProgram=function(gl,vertexSource,fragmentSource,attribLocationMap){var vertexShader=gl.createShader(gl.VERTEX_SHADER);gl.shaderSource(vertexShader,vertexSource);gl.compileShader(vertexShader);var fragmentShader=gl.createShader(gl.FRAGMENT_SHADER);gl.shaderSource(fragmentShader,fragmentSource);gl.compileShader(fragmentShader);var program=gl.createProgram();gl.attachShader(program,vertexShader);gl.attachShader(program,fragmentShader);for(var attribName in attribLocationMap)gl.bindAttribLocation(program,attribLocationMap[attribName],attribName);gl.linkProgram(program);gl.deleteShader(vertexShader);gl.deleteShader(fragmentShader);return program};Util.getProgramUniforms=function(gl,program){var uniforms={};var uniformCount=gl.getProgramParameter(program,gl.ACTIVE_UNIFORMS);var uniformName="";for(var i=0;i<uniformCount;i++){var uniformInfo=gl.getActiveUniform(program,i);uniformName=uniformInfo.name.replace("[0]","");uniforms[uniformName]=gl.getUniformLocation(program,uniformName)} 392return uniforms};Util.orthoMatrix=function(out,left,right,bottom,top,near,far){var lr=1/(left-right);var bt=1/(bottom-top);var nf=1/(near-far);out[0]=-2*lr;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=-2*bt;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=2*nf;out[11]=0;out[12]=(left+right)*lr;out[13]=(top+bottom)*bt;out[14]=(far+near)*nf;out[15]=1;return out};Util.copyArray=function(source,dest){for(var i=0,n=source.length;i<n;i++){dest[i]=source[i]}};Util.isMobile=function(){var check=!1;
392(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) 393check=!0})(userAgent$1||(nav===null||nav===void 0?void 0:nav.vendor)||win.opera);return check};Util.extend=function(dest,src){for(var key in src){if(src.hasOwnProperty(key)){dest[key]=src[key]}} 394return dest};Util.safariCssSizeWorkaround=function(canvas){if(Util.isIOS()){var width_1=canvas.style.width;var height_1=canvas.style.height;canvas.style.width=parseInt(width_1)+1+"px";canvas.style.height=parseInt(height_1)+"px";setTimeout(function(){canvas.style.width=width_1;canvas.style.height=height_1},100)} 395win.Util=Util;win.canvas=canvas};Util.isDebug=function(){return Util.getQueryParameter("debug")};Util.getQueryParameter=function(name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^&#]*)");var results=regex.exec(location.search);return results===null?"":decodeURIComponent(results[1].replace(/\+/g," "))};Util.frameDataFromPose=(function(){var piOver180=Math.PI/180.0;var rad45=Math.PI*0.25;function mat4_perspectiveFromFieldOfView(out,fov,near,far){var upTan=Math.tan(fov?fov.upDegrees*piOver180:rad45);var downTan=Math.tan(fov?fov.downDegrees*piOver180:rad45);var leftTan=Math.tan(fov?fov.leftDegrees*piOver180:rad45);var rightTan=Math.tan(fov?fov.rightDegrees*piOver180:rad45);var xScale=2.0/(leftTan+rightTan);var yScale=2.0/(upTan+downTan);out[0]=xScale;out[1]=0.0;out[2]=0.0;out[3]=0.0;out[4]=0.0;out[5]=yScale;out[6]=0.0;out[7]=0.0;out[8]=-((leftTan-rightTan)*xScale*0.5);out[9]=(upTan-downTan)*yScale*0.5;out[10]=far/(near-far);out[11]=-1.0;out[12]=0.0;out[13]=0.0;out[14]=(far*near)/(near-far);out[15]=0.0;return out} 396function mat4_fromRotationTranslation(out,q,v){var x=q[0];var y=q[1];var z=q[2];var w=q[3];
396var x2=x+x;var y2=y+y;var z2=z+z;var xx=x*x2;var xy=x*y2;var xz=x*z2;var yy=y*y2;var yz=y*z2;var zz=z*z2;var wx=w*x2;var wy=w*y2;var wz=w*z2;out[0]=1-(yy+zz);out[1]=xy+wz;out[2]=xz-wy;out[3]=0;out[4]=xy-wz;out[5]=1-(xx+zz);out[6]=yz+wx;out[7]=0;out[8]=xz+wy;out[9]=yz-wx;out[10]=1-(xx+yy);out[11]=0;out[12]=v[0];out[13]=v[1];out[14]=v[2];out[15]=1;return out} 397function mat4_translate(out,a,v){var x=v[0];var y=v[1];var z=v[2];var a00;var a01;var a02;var a03;var a10;var a11;var a12;var a13;var a20;var a21;var a22;var a23;if(a===out){out[12]=a[0]*x+a[4]*y+a[8]*z+a[12];out[13]=a[1]*x+a[5]*y+a[9]*z+a[13];out[14]=a[2]*x+a[6]*y+a[10]*z+a[14];out[15]=a[3]*x+a[7]*y+a[11]*z+a[15]}else{a00=a[0];a01=a[1];a02=a[2];a03=a[3];a10=a[4];a11=a[5];a12=a[6];a13=a[7];a20=a[8];a21=a[9];a22=a[10];a23=a[11];out[0]=a00;out[1]=a01;out[2]=a02;out[3]=a03;out[4]=a10;out[5]=a11;out[6]=a12;out[7]=a13;out[8]=a20;out[9]=a21;out[10]=a22;out[11]=a23;out[12]=a00*x+a10*y+a20*z+a[12];out[13]=a01*x+a11*y+a21*z+a[13];out[14]=a02*x+a12*y+a22*z+a[14];out[15]=a03*x+a13*y+a23*z+a[15]} 398return out} 399function mat4_invert(out,a){var a00=a[0];var a01=a[1];var a02=a[2];var a03=a[3];var a10=a[4];var a11=a[5];var a12=a[6];var a13=a[7];var a20=a[8];var a21=a[9];var a22=a[10];var a23=a[11];var a30=a[12];var a31=a[13];var a32=a[14];var a33=a[15];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;if(!det){return null} 400det=1.0/det;out[0]=(a11*b11-a12*b10+a13*b09)*det;out[1]=(a02*b10-a01*b11-a03*b09)*det;out[2]=(a31*b05-a32*b04+a33*b03)*det;out[3]=(a22*b04-a21*b05-a23*b03)*det;out[4]=(a12*b08-a10*b11-a13*b07)*det;out[5]=(a00*b11-a02*b08+a03*b07)*det;out[6]=(a32*b02-a30*b05-a33*b01)*det;out[7]=(a20*b05-a22*b02+a23*b01)*det;out[8]=(a10*b10-a11*b08+a13*b06)*det;out[9]=(a01*b08-a00*b10-a03*b06)*det;out[10]=(a30*b04-a31*b02+a33*b00)*det;out[11]=(a21*b02-a20*b04-a23*b00)*det;out[12]=(a11*b07-a10*b09-a12*b06)*det;out[13]=(a00*b09-a01*b07+a02*b06)*det;out[14]=(a31*b01-a30*b03-a32*b00)*det;out[15]=(a20*b03-a21*b01+a22*b00)*det;return out} 401var defaultOrientation=new Float32Array([0,0,0,1]);var defaultPosition=new Float32Array([0,0,0]);function updateEyeMatrices(projection,view,pose,parameters,vrDisplay){mat4_perspectiveFromFieldOfView(projection,parameters?parameters.fieldOfView:null,vrDisplay.depthNear,vrDisplay.depthFar);var orientation=pose.orientation||defaultOrientation;var position=pose.position||defaultPosition;mat4_fromRotationTranslation(view,orientation,position);if(parameters)mat4_translate(view,view,parameters.offset);mat4_invert(view,view)} 402return function(frameData,pose,vrDisplay){if(!frameData||!pose)return!1;frameData.pose=pose;frameData.timestamp=pose.timestamp;updateEyeMatrices(frameData.leftProjectionMatrix,frameData.leftViewMatrix,pose,vrDisplay.getEyeParameters("left"),vrDisplay);updateEyeMatrices(frameData.rightProjectionMatrix,frameData.rightViewMatrix,pose,vrDisplay.getEyeParameters("right"),vrDisplay);return!0}})();Util.isInsideCrossDomainIFrame=function(){var isFramed=win.self!==win.top;var refDomain=Util.getDomainFromUrl(doc.referrer);var thisDomain=Util.getDomainFromUrl(win.location.href);return isFramed&&refDomain!==thisDomain};Util.getDomainFromUrl=function(url){var domain;if(url.indexOf("://")>-1){domain=url.split("/")[2]}else{domain=url.split("/")[0]} 403domain=domain.split(":")[0];return domain};var PosePredictor=(function(){function PosePredictor(predictionTimeS){this.predictionTimeS=predictionTimeS;this.previousQ=new MathUtil.Quaternion();this.previousTimestampS=null;this.deltaQ=new MathUtil.Quaternion();this.outQ=new MathUtil.Quaternion()} 404var __proto=PosePredictor.prototype;__proto.getPrediction=function(currentQ,gyro,timestampS){if(!this.previousTimestampS){this.previousQ.copy(currentQ);this.previousTimestampS=timestampS;return currentQ} 405var axis=new MathUtil.Vector3();axis.copy(gyro);axis.normalize();var angularSpeed=gyro.length();if(angularSpeed<MathUtil.degToRad*20){if(Util.isDebug()){console.log("Moving slowly, at %s deg/s: no prediction",(MathUtil.radToDeg*angularSpeed).toFixed(1))} 406this.outQ.copy(currentQ);this.previousQ.copy(currentQ);return this.outQ} 407var deltaT=timestampS-this.previousTimestampS;var predictAngle=angularSpeed*this.predictionTimeS;this.deltaQ.setFromAxisAngle(axis,predictAngle);this.outQ.copy(this.previousQ);this.outQ.multiply(this.deltaQ);this.previousQ.copy(currentQ);this.previousTimestampS=timestampS;return this.outQ};return PosePredictor})();var STILLNESS_THRESHOLD=200;var DeviceMotion=(function(_super){__extends(DeviceMotion,_super);
407function DeviceMotion(){var _this=_super.call(this)||this;_this._onDeviceMotion=_this._onDeviceMotion.bind(_this);_this._onDeviceOrientation=_this._onDeviceOrientation.bind(_this);_this._onChromeWithoutDeviceMotion=_this._onChromeWithoutDeviceMotion.bind(_this);_this.isWithoutDeviceMotion=IS_CHROME_WITHOUT_DEVICE_MOTION;_this.isAndroid=IS_ANDROID;_this.stillGyroVec=create$2();_this.rawGyroVec=create$2();_this.adjustedGyroVec=create$2();_this._timer=-1;_this.lastDevicemotionTimestamp=0;_this._isEnabled=!1;_this.enable();return _this} 408var __proto=DeviceMotion.prototype;__proto.enable=function(){if(this.isAndroid){win.addEventListener("deviceorientation",this._onDeviceOrientation)} 409if(this.isWithoutDeviceMotion){win.addEventListener("deviceorientation",this._onChromeWithoutDeviceMotion)}else{win.addEventListener("devicemotion",this._onDeviceMotion)} 410this._isEnabled=!0};__proto.disable=function(){win.removeEventListener("deviceorientation",this._onDeviceOrientation);win.removeEventListener("deviceorientation",this._onChromeWithoutDeviceMotion);win.removeEventListener("devicemotion",this._onDeviceMotion);this._isEnabled=!1};__proto._onChromeWithoutDeviceMotion=function(e){var alpha=e.alpha,beta=e.beta,gamma=e.gamma;if(alpha===null){return} 411alpha=((alpha||0)*Math.PI)/180;beta=((beta||0)*Math.PI)/180;gamma=((gamma||0)*Math.PI)/180;this.trigger(new ComponentEvent$1("devicemotion",{inputEvent:{deviceorientation:{alpha:alpha,beta:beta,gamma:-gamma,},},}))};__proto._onDeviceOrientation=function(){var _this=this;if(this._timer){clearTimeout(this._timer)} 412this._timer=win.setTimeout(function(){if(new Date().getTime()-_this.lastDevicemotionTimestamp<STILLNESS_THRESHOLD){copy(_this.stillGyroVec,_this.rawGyroVec)}},STILLNESS_THRESHOLD)};__proto._onDeviceMotion=function(e){var isGyroSensorAvailable=!(e.rotationRate.alpha==null);var isGravitySensorAvailable=!(e.accelerationIncludingGravity.x==null);if(e.interval===0||!(isGyroSensorAvailable&&isGravitySensorAvailable)){return} 413var devicemotionEvent=__assign({},e);devicemotionEvent.interval=e.interval;devicemotionEvent.timeStamp=e.timeStamp;devicemotionEvent.type=e.type;devicemotionEvent.rotationRate={alpha:e.rotationRate.alpha,beta:e.rotationRate.beta,gamma:e.rotationRate.gamma,};devicemotionEvent.accelerationIncludingGravity={x:e.accelerationIncludingGravity.x,y:e.accelerationIncludingGravity.y,z:e.accelerationIncludingGravity.z,};devicemotionEvent.acceleration={x:e.acceleration.x,y:e.acceleration.y,z:e.acceleration.z,};if(this.isAndroid){set(this.rawGyroVec,e.rotationRate.alpha||0,e.rotationRate.beta||0,e.rotationRate.gamma||0);subtract(this.adjustedGyroVec,this.rawGyroVec,this.stillGyroVec);this.lastDevicemotionTimestamp=new Date().getTime();devicemotionEvent.adjustedRotationRate={alpha:this.adjustedGyroVec[0],beta:this.adjustedGyroVec[1],gamma:this.adjustedGyroVec[2],}} 414this.trigger(new ComponentEvent$1("devicemotion",{inputEvent:devicemotionEvent,}))};return DeviceMotion})(Component);var SensorSample=(function(){function SensorSample(sample,timestampS){this.set(sample,timestampS)} 415var __proto=SensorSample.prototype;__proto.set=function(sample,timestampS){this.sample=sample;this.timestampS=timestampS};__proto.copy=function(sensorSample){this.set(sensorSample.sample,sensorSample.timestampS)};return SensorSample})();var ComplementaryFilter=(function(){function ComplementaryFilter(kFilter){this.addGyroMeasurement=function(vector,timestampS){this.currentGyroMeasurement.set(vector,timestampS);var deltaT=timestampS-this.previousGyroMeasurement.timestampS;if(Util.isTimestampDeltaValid(deltaT)){this.run_()} 416this.previousGyroMeasurement.copy(this.currentGyroMeasurement)};this.kFilter=kFilter;this.currentAccelMeasurement=new SensorSample();this.currentGyroMeasurement=new SensorSample();this.previousGyroMeasurement=new SensorSample();if(Util.isIOS()){this.filterQ=new MathUtil.Quaternion(-1,0,0,1)}else{this.filterQ=new MathUtil.Quaternion(1,0,0,1)} 417this.previousFilterQ=new MathUtil.Quaternion();this.previousFilterQ.copy(this.filterQ);this.accelQ=new MathUtil.Quaternion();this.isOrientationInitialized=!1;this.estimatedGravity=new MathUtil.Vector3();this.measuredGravity=new MathUtil.Vector3();this.gyroIntegralQ=new MathUtil.Quaternion()} 418var __proto=ComplementaryFilter.prototype;__proto.addAccelMeasurement=function(vector,timestampS){this.currentAccelMeasurement.set(vector,timestampS)};__proto.getOrientation=function(){return this.filterQ};__proto.run_=function(){if(!this.isOrientationInitialized){this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample);this.previousFilterQ.copy(this.accelQ);this.isOrientationInitialized=!0;return} 419var deltaT=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS;var gyroDeltaQ=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,deltaT);this.gyroIntegralQ.multiply(gyroDeltaQ);this.filterQ.copy(this.previousFilterQ);this.filterQ.multiply(gyroDeltaQ);var invFilterQ=new MathUtil.Quaternion();invFilterQ.copy(this.filterQ);invFilterQ.inverse();this.estimatedGravity.set(0,0,-1);this.estimatedGravity.applyQuaternion(invFilterQ);this.estimatedGravity.normalize();this.measuredGravity.copy(this.currentAccelMeasurement.sample);this.measuredGravity.normalize();var deltaQ=new MathUtil.Quaternion();deltaQ.setFromUnitVectors(this.estimatedGravity,this.measuredGravity);deltaQ.inverse();if(Util.isDebug()){console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",MathUtil.radToDeg*Util.getQuaternionAngle(deltaQ),this.estimatedGravity.x.toFixed(1),this.estimatedGravity.y.toFixed(1),this.estimatedGravity.z.toFixed(1),this.measuredGravity.x.toFixed(1),this.measuredGravity.y.toFixed(1),this.measuredGravity.z.toFixed(1))} 420var targetQ=new MathUtil.Quaternion();targetQ.copy(this.filterQ);targetQ.multiply(deltaQ);this.filterQ.slerp(targetQ,1-this.kFilter);this.previousFilterQ.copy(this.filterQ)};__proto.accelToQuaternion_=function(accel){var normAccel=new MathUtil.Vector3();normAccel.copy(accel);normAccel.normalize();var quat=new MathUtil.Quaternion();quat.setFromUnitVectors(new MathUtil.Vector3(0,0,-1),normAccel);quat.inverse();return quat};__proto.gyroToQuaternionDelta_=function(gyro,dt){var quat=new MathUtil.Quaternion();var axis=new MathUtil.Vector3();axis.copy(gyro);axis.normalize();quat.setFromAxisAngle(axis,gyro.length()*dt);return quat};return ComplementaryFilter})();ComplementaryFilter.prototype.run_=function(){if(!this.isOrientationInitialized){this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample);this.previousFilterQ.copy(this.accelQ);this.isOrientationInitialized=!0;return} 421var deltaT=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS;var gyroDeltaQ=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,deltaT);this.gyroIntegralQ.multiply(gyroDeltaQ);this.filterQ.copy(this.previousFilterQ);this.filterQ.multiply(gyroDeltaQ);var invFilterQ=new MathUtil.Quaternion();invFilterQ.copy(this.filterQ);invFilterQ.inverse();this.estimatedGravity.set(0,0,-1);this.estimatedGravity.applyQuaternion(invFilterQ);this.estimatedGravity.normalize();this.measuredGravity.copy(this.currentAccelMeasurement.sample);this.measuredGravity.normalize();var deltaQ=new MathUtil.Quaternion();deltaQ.setFromUnitVectors(this.estimatedGravity,this.measuredGravity);deltaQ.inverse();var targetQ=new MathUtil.Quaternion();targetQ.copy(this.filterQ);targetQ.multiply(deltaQ);this.filterQ.slerp(targetQ,1-this.kFilter);this.previousFilterQ.copy(this.filterQ);if(!this.isFilterQuaternionInitialized){this.isFilterQuaternionInitialized=!0}};ComplementaryFilter.prototype.getOrientation=function(){if(this.isFilterQuaternionInitialized){return this.filterQ}else{return null}};var K_FILTER=0.98;var PREDICTION_TIME_S=0.04;var FusionPoseSensor=(function(_super){__extends(FusionPoseSensor,_super);
421function FusionPoseSensor(){var _this=_super.call(this)||this;_this.deviceMotion=new DeviceMotion();_this.accelerometer=new MathUtil.Vector3();_this.gyroscope=new MathUtil.Vector3();_this._onDeviceMotionChange=_this._onDeviceMotionChange.bind(_this);_this._onScreenOrientationChange=_this._onScreenOrientationChange.bind(_this);_this.filter=new ComplementaryFilter(K_FILTER);_this.posePredictor=new PosePredictor(PREDICTION_TIME_S);_this.filterToWorldQ=new MathUtil.Quaternion();_this.isFirefoxAndroid=Util.isFirefoxAndroid();_this.isIOS=IS_IOS||IS_SAFARI_ON_DESKTOP;_this.isChromeUsingDegrees=CHROME_VERSION>=66;_this._isEnabled=!1;if(_this.isIOS){_this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1,0,0),Math.PI/2)}else{_this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1,0,0),-Math.PI/2)} 422_this.inverseWorldToScreenQ=new MathUtil.Quaternion();_this.worldToScreenQ=new MathUtil.Quaternion();_this.originalPoseAdjustQ=new MathUtil.Quaternion();_this.originalPoseAdjustQ.setFromAxisAngle(new MathUtil.Vector3(0,0,1),(-win.orientation*Math.PI)/180);_this._setScreenTransform();if(Util.isLandscapeMode()){_this.filterToWorldQ.multiply(_this.inverseWorldToScreenQ)} 423_this.resetQ=new MathUtil.Quaternion();_this.deviceMotion.on("devicemotion",_this._onDeviceMotionChange);_this.enable();return _this} 424var __proto=FusionPoseSensor.prototype;__proto.enable=function(){if(this.isEnabled()){return} 425this.deviceMotion.enable();this._isEnabled=!0;win.addEventListener("orientationchange",this._onScreenOrientationChange)};__proto.disable=function(){if(!this.isEnabled()){return} 426this.deviceMotion.disable();this._isEnabled=!1;win.removeEventListener("orientationchange",this._onScreenOrientationChange)};__proto.isEnabled=function(){return this._isEnabled};__proto.destroy=function(){this.disable();this.deviceMotion=null};__proto.getOrientation=function(){var _this=this;var orientation;if(this.deviceMotion.isWithoutDeviceMotion&&this._deviceOrientationQ){this.deviceOrientationFixQ=this.deviceOrientationFixQ||(function(){var y=new MathUtil.Quaternion().setFromAxisAngle(new MathUtil.Vector3(0,1,0),-_this._alpha);return y})();orientation=this._deviceOrientationQ;var out=new MathUtil.Quaternion();out.copy(orientation);out.multiply(this.filterToWorldQ);out.multiply(this.resetQ);out.multiply(this.worldToScreenQ);out.multiplyQuaternions(this.deviceOrientationFixQ,out);var outQuat=fromValues$2(out.x,out.y,out.z,out.w);return normalize$2(outQuat,outQuat)}else{orientation=this.filter.getOrientation();if(!orientation){return null} 427var out=this._convertFusionToPredicted(orientation);var outQuat=fromValues$2(out.x,out.y,out.z,out.w);return normalize$2(outQuat,outQuat)}};__proto._triggerChange=function(){var orientation=this.getOrientation();if(!orientation){return} 428if(!this._prevOrientation){this._prevOrientation=orientation;return} 429if(equals$1(this._prevOrientation,orientation)){return} 430this.trigger(new ComponentEvent$1("change",{quaternion:orientation,}))};__proto._convertFusionToPredicted=function(orientation){this.predictedQ=this.posePredictor.getPrediction(orientation,this.gyroscope,this.previousTimestampS);var out=new MathUtil.Quaternion();out.copy(this.filterToWorldQ);out.multiply(this.resetQ);out.multiply(this.predictedQ);out.multiply(this.worldToScreenQ);return out};__proto._onDeviceMotionChange=function(_a){var inputEvent=_a.inputEvent;var deviceorientation=inputEvent.deviceorientation;var deviceMotion=inputEvent;var accGravity=deviceMotion.accelerationIncludingGravity;var rotRate=deviceMotion.adjustedRotationRate||deviceMotion.rotationRate;var timestampS=deviceMotion.timeStamp/1000;if(deviceorientation){if(!this._alpha){this._alpha=deviceorientation.alpha} 431this._deviceOrientationQ=this._deviceOrientationQ||new MathUtil.Quaternion();this._deviceOrientationQ.setFromEulerYXZ(deviceorientation.beta,deviceorientation.alpha,deviceorientation.gamma);this._triggerChange()}else{if(this.isFirefoxAndroid){timestampS/=1000} 432this.accelerometer.set(-accGravity.x,-accGravity.y,-accGravity.z);this.gyroscope.set(rotRate.alpha,rotRate.beta,rotRate.gamma);if(this.isIOS||this.isFirefoxAndroid||this.isChromeUsingDegrees){this.gyroscope.multiplyScalar(Math.PI/180)} 433this.filter.addAccelMeasurement(this.accelerometer,timestampS);this.filter.addGyroMeasurement(this.gyroscope,timestampS);this._triggerChange();this.previousTimestampS=timestampS}};__proto._onScreenOrientationChange=function(){this._setScreenTransform()};__proto._setScreenTransform=function(){this.worldToScreenQ.set(0,0,0,1);var orientation=win.orientation;switch(orientation){case 0:break;case 90:case-90:case 180:this.worldToScreenQ.setFromAxisAngle(new MathUtil.Vector3(0,0,1),(orientation/-180)*Math.PI);break} 434this.inverseWorldToScreenQ.copy(this.worldToScreenQ);this.inverseWorldToScreenQ.inverse()};return FusionPoseSensor})(Component);var getDeltaYaw=function(prvQ,curQ){var yawDeltaByYaw=util.getRotationDelta(prvQ,curQ,ROTATE_CONSTANT.YAW_DELTA_BY_YAW);var yawDeltaByRoll=util.getRotationDelta(prvQ,curQ,ROTATE_CONSTANT.YAW_DELTA_BY_ROLL)*Math.sin(util.extractPitchFromQuat(curQ));return yawDeltaByRoll+yawDeltaByYaw};var getDeltaPitch=function(prvQ,curQ){var pitchDelta=util.getRotationDelta(prvQ,curQ,ROTATE_CONSTANT.PITCH_DELTA);return pitchDelta};var TiltMotionInput=(function(_super){__extends(TiltMotionInput,_super);function TiltMotionInput(el,options){if(options===void 0){options={}}
435var _this=_super.call(this)||this;_this.element=el;_this._prevQuaternion=null;_this._quaternion=null;_this.fusionPoseSensor=null;_this.options=__assign({scale:1,threshold:0,},options);_this._onPoseChange=_this._onPoseChange.bind(_this);return _this} 436var __proto=TiltMotionInput.prototype;__proto.mapAxes=function(axes){this.axes=axes};__proto.connect=function(observer){if(this.observer){return this} 437this.observer=observer;this.fusionPoseSensor=new FusionPoseSensor();this.fusionPoseSensor.enable();this._attachEvent();return this};__proto.disconnect=function(){if(!this.observer){return this} 438this._dettachEvent();this.fusionPoseSensor.disable();this.fusionPoseSensor.destroy();this.fusionPoseSensor=null;this.observer=null;return this};__proto.destroy=function(){this.disconnect();this.element=null;this.options=null;this.axes=null;this._prevQuaternion=null;this._quaternion=null};__proto._onPoseChange=function(event){if(!this._prevQuaternion){this._prevQuaternion=clone$1(event.quaternion);this._quaternion=clone$1(event.quaternion);return} 439copy$2(this._prevQuaternion,this._quaternion);copy$2(this._quaternion,event.quaternion);this.observer.change(this,event,toAxis$1(this.axes,[getDeltaYaw(this._prevQuaternion,this._quaternion),getDeltaPitch(this._prevQuaternion,this._quaternion)]))};__proto._attachEvent=function(){this.fusionPoseSensor.on("change",this._onPoseChange)};__proto._dettachEvent=function(){this.fusionPoseSensor.off("change",this._onPoseChange)};return TiltMotionInput})(Component);var screenRotationAngleInst=null;var refCount=0;var ScreenRotationAngle=(function(){function ScreenRotationAngle(){refCount++;if(screenRotationAngleInst){return screenRotationAngleInst} 440screenRotationAngleInst=this;this._onDeviceOrientation=this._onDeviceOrientation.bind(this);this._onOrientationChange=this._onOrientationChange.bind(this);this._spinR=0;this._screenOrientationAngle=0;win.addEventListener("deviceorientation",this._onDeviceOrientation);win.addEventListener("orientationchange",this._onOrientationChange)} 441var __proto=ScreenRotationAngle.prototype;__proto.getRadian=function(){return this._spinR+toRadian(this._screenOrientationAngle)};__proto.unref=function(){if(--refCount>0){return} 442win.removeEventListener("deviceorientation",this._onDeviceOrientation);win.removeEventListener("orientationchange",this._onOrientationChange);this._spinR=0;this._screenOrientationAngle=0;screenRotationAngleInst=null;refCount=0};__proto._onDeviceOrientation=function(e){if(e.beta===null||e.gamma===null){return} 443var betaR=toRadian(e.beta);var gammaR=toRadian(e.gamma);this._spinR=Math.atan2(Math.cos(betaR)*Math.sin(gammaR),Math.sin(betaR))};__proto._onOrientationChange=function(){if(win.screen&&win.screen.orientation&&win.screen.orientation.angle!==undefined){this._screenOrientationAngle=screen.orientation.angle}else if(win.orientation!==undefined){this._screenOrientationAngle=win.orientation>=0?win.orientation:360+win.orientation}};return ScreenRotationAngle})();var RotationPanInput=(function(_super){__extends(RotationPanInput,_super);function RotationPanInput(el,options){if(options===void 0){options={}} 444var _this=_super.call(this,el,options)||this;_this._useRotation=!1;_this._screenRotationAngle=null;_this.setUseRotation(!!(options&&options.useRotation));_this._userDirection=Axes.DIRECTION_ALL;return _this} 445var __proto=RotationPanInput.prototype;__proto.setUseRotation=function(useRotation){this._useRotation=useRotation;if(this._screenRotationAngle){this._screenRotationAngle.unref();this._screenRotationAngle=null} 446if(this._useRotation){this._screenRotationAngle=new ScreenRotationAngle()}};__proto.connect=function(observer){this._userDirection=this._direction;if(this._useRotation&&this._direction&Axes.DIRECTION_ALL){this._direction=Axes.DIRECTION_HORIZONTAL} 447return _super.prototype.connect.call(this,observer)};__proto.destroy=function(){if(this._useRotation&&this._screenRotationAngle){this._screenRotationAngle.unref()} 448_super.prototype.destroy.call(this)};__proto._getOffset=function(properties,useDirection){if(this._useRotation===!1){return _super.prototype._getOffset.call(this,properties,useDirection)} 449var offset=_super.prototype._getOffset.call(this,properties,[!0,!0]);var newOffset=[0,0];var theta=this._screenRotationAngle.getRadian();var cosTheta=Math.cos(theta);var sinTheta=Math.sin(theta);newOffset[0]=offset[0]*cosTheta-offset[1]*sinTheta;
449newOffset[1]=offset[1]*cosTheta+offset[0]*sinTheta;if(!(this._userDirection&Axes.DIRECTION_HORIZONTAL)){newOffset[0]=0}else if(!(this._userDirection&Axes.DIRECTION_VERTICAL)){newOffset[1]=0} 450return newOffset};return RotationPanInput})(PanInput);var Y_AXIS_VECTOR=fromValues(0,1,0);var DeviceQuaternion=(function(_super){__extends(DeviceQuaternion,_super);function DeviceQuaternion(){var _this=_super.call(this)||this;_this._fusionPoseSensor=new FusionPoseSensor();_this._quaternion=create$4();_this._fusionPoseSensor.enable();_this._fusionPoseSensor.on("change",function(e){_this._quaternion=e.quaternion;_this.trigger(new ComponentEvent$1("change",{isTrusted:!0,}))});return _this} 451var __proto=DeviceQuaternion.prototype;__proto.getCombinedQuaternion=function(yaw){var yawQ=setAxisAngle(create$4(),Y_AXIS_VECTOR,toRadian(-yaw));var conj=conjugate(create$4(),this._quaternion);var outQ=multiply(create$4(),conj,yawQ);return outQ};__proto.destroy=function(){this.off();if(this._fusionPoseSensor){this._fusionPoseSensor.off();this._fusionPoseSensor.destroy();this._fusionPoseSensor=null}};return DeviceQuaternion})(Component);var DEFAULT_YAW_RANGE=[-YAW_RANGE_HALF,YAW_RANGE_HALF];var DEFAULT_PITCH_RANGE=[-PITCH_RANGE_HALF,PITCH_RANGE_HALF];var CIRCULAR_PITCH_RANGE=[-CIRCULAR_PITCH_RANGE_HALF,CIRCULAR_PITCH_RANGE_HALF];var YawPitchControl=(function(_super){__extends(YawPitchControl,_super);function YawPitchControl(options){var _this=_super.call(this)||this;_this.options={};var opt=__assign({element:null,yaw:0,pitch:0,fov:65,showPolePoint:!1,useZoom:!0,useKeyboard:!0,gyroMode:GYRO_MODE.YAWPITCH,touchDirection:TOUCH_DIRECTION_ALL,yawRange:DEFAULT_YAW_RANGE,pitchRange:DEFAULT_PITCH_RANGE,fovRange:[30,110],aspectRatio:1,},options);_this._element=opt.element;_this._initialFov=opt.fov;_this._enabled=!1;_this._isAnimating=!1;_this._deviceQuaternion=null;_this._initAxes(opt);_this.option(opt);return _this} 452var __proto=YawPitchControl.prototype;__proto.updatePanScale=function(param){if(param===void 0){param={}} 453var fov=this._axes.get().fov;var areaHeight=param.height||parseInt(window.getComputedStyle(this._element).height,10);var scale=(((MC_BIND_SCALE[0]*fov)/this._initialFov)*PAN_SCALE)/areaHeight;this._axesPanInput.options.scale=[scale,scale];this._axes.options.deceleration=(MC_DECELERATION*fov)/MAX_FIELD_OF_VIEW;return this};__proto.option=function(key,newValue){if(!key){return this._getOptions()}else if(key&&typeof key==="string"&&typeof newValue==="undefined"){return this._getOptions(key)} 454var newOptions={};var changedKeyList=[];if(typeof key==="string"){changedKeyList.push(key);newOptions[key]=newValue}else{var options=key;changedKeyList=Object.keys(options);newOptions=__assign({},options)} 455this._setOptions(this._getValidatedOptions(newOptions));this._applyOptions(changedKeyList);return this};__proto.enable=function(){if(this._enabled){return this} 456this._enabled=!0;this._applyOptions(Object.keys(this.options));this.updatePanScale();return this};__proto.disable=function(persistOrientation){if(persistOrientation===void 0){persistOrientation=!1} 457if(!this._enabled){return this} 458if(!persistOrientation){this._resetOrientation()} 459this._axes.disconnect();this._enabled=!1;return this};__proto.lookAt=function(_a,duration){var yaw=_a.yaw,pitch=_a.pitch,fov=_a.fov;var pos=this._axes.get();var y=yaw===undefined?0:yaw-pos.yaw;var p=pitch===undefined?0:pitch-pos.pitch;var f=fov===undefined?0:fov-pos.fov;this._axes.options.maximumDuration=Infinity;this._axes.setBy({yaw:y,pitch:p,fov:f,},duration)};__proto.getYawPitch=function(){var yawPitch=this._axes.get();return{yaw:yawPitch.yaw,pitch:yawPitch.pitch,}};__proto.getFov=function(){return this._axes.get().fov};__proto.getQuaternion=function(){var pos=this._axes.get();return this._deviceQuaternion.getCombinedQuaternion(pos.yaw)};__proto.shouldRenderWithQuaternion=function(){return this.options.gyroMode===GYRO_MODE.VR};__proto.destroy=function(){this._axes&&this._axes.destroy();this._axesPanInput&&this._axesPanInput.destroy();this._axesWheelInput&&this._axesWheelInput.destroy();this._axesTiltMotionInput&&this._axesTiltMotionInput.destroy();this._axesPinchInput&&this._axesPinchInput.destroy();this._axesMoveKeyInput&&this._axesMoveKeyInput.destroy();this._deviceQuaternion&&this._deviceQuaternion.destroy()};__proto._initAxes=function(opt){var _this=this;var yRange=this._updateYawRange(opt.yawRange,opt.fov,opt.aspectRatio);var pRange=this._updatePitchRange(opt.pitchRange,opt.fov,opt.showPolePoint);
459var useRotation=opt.gyroMode===GYRO_MODE.VR;this._axesPanInput=new RotationPanInput(this._element,{useRotation:useRotation,});this._axesWheelInput=new WheelInput(this._element,{scale:-4,});this._axesTiltMotionInput=null;this._axesPinchInput=SUPPORT_TOUCH?new PinchInput(this._element,{scale:-1,}):null;this._axesMoveKeyInput=new MoveKeyInput(this._element,{scale:[-6,6],});this._axes=new Axes({yaw:{range:yRange,circular:this._isCircular(yRange),bounce:[0,0],},pitch:{range:pRange,circular:this._isCircular(pRange),bounce:[0,0],},fov:{range:opt.fovRange,circular:[!1,!1],bounce:[0,0],},},{deceleration:MC_DECELERATION,maximumDuration:MC_MAXIMUM_DURATION,},{yaw:opt.yaw,pitch:opt.pitch,fov:opt.fov,}).on({hold:function(evt){_this._axes.options.maximumDuration=MC_MAXIMUM_DURATION;_this.trigger(new ComponentEvent$1("hold",{isTrusted:evt.isTrusted,}))},change:function(evt){if(evt.delta.fov!==0){_this._updateControlScale(evt);_this.updatePanScale()} 460_this._triggerChange(evt)},release:function(evt){_this._triggerChange(evt)},animationEnd:function(evt){_this.trigger(new ComponentEvent$1("animationEnd",{isTrusted:evt.isTrusted,}))},})};__proto._getValidatedOptions=function(newOptions){if(newOptions.yawRange){newOptions.yawRange=this._getValidYawRange(newOptions.yawRange,newOptions.fov,newOptions.aspectRatio)} 461if(newOptions.pitchRange){newOptions.pitchRange=this._getValidPitchRange(newOptions.pitchRange,newOptions.fov)} 462return newOptions};__proto._getOptions=function(key){var value;if(typeof key==="string"){value=this.options[key]}else if(arguments.length===0){value=this.options} 463return value};__proto._setOptions=function(options){for(var key in options){this.options[key]=options[key]}};__proto._applyOptions=function(keys){var options=this.options;var axes=this._axes;var isVR=options.gyroMode===GYRO_MODE.VR;var isYawPitch=options.gyroMode===GYRO_MODE.YAWPITCH;var touchDirection=isVR?TOUCH_DIRECTION_YAW&options.touchDirection:options.touchDirection;if(keys.some(function(key){return key==="showPolePoint"||key==="fov"||key==="aspectRatio"||key==="yawRange"||key==="pitchRange"})){if(keys.indexOf("fov")>=0){axes.setTo({fov:options.fov,});this.updatePanScale()} 464this._updateControlScale()} 465if(keys.some(function(key){return key==="fovRange"})){var fovRange=options.fovRange;var prevFov=axes.get().fov;var nextFov=axes.get().fov;copy$3(axes.axis.fov.range,fovRange);if(nextFov<fovRange[0]){nextFov=fovRange[0]}else if(prevFov>fovRange[1]){nextFov=fovRange[1]} 466if(prevFov!==nextFov){axes.setTo({fov:nextFov,},0);this._updateControlScale();this.updatePanScale()}} 467if(keys.some(function(key){return key==="gyroMode"})&&SUPPORT_DEVICEMOTION){if(this._axesTiltMotionInput){this._axes.disconnect(this._axesTiltMotionInput);this._axesTiltMotionInput.destroy();this._axesTiltMotionInput=null} 468if(this._deviceQuaternion){this._deviceQuaternion.destroy();this._deviceQuaternion=null} 469if(isVR){this._initDeviceQuaternion()}else if(isYawPitch){this._axesTiltMotionInput=new TiltMotionInput(this._element);this._axes.connect(["yaw","pitch"],this._axesTiltMotionInput)} 470this._axesPanInput.setUseRotation(isVR)} 471if(keys.some(function(key){return key==="useKeyboard"})){var useKeyboard=options.useKeyboard;if(useKeyboard){axes.connect(["yaw","pitch"],this._axesMoveKeyInput)}else{axes.disconnect(this._axesMoveKeyInput)}} 472if(keys.some(function(key){return key==="useZoom"})){var useZoom=options.useZoom;axes.disconnect(this._axesWheelInput);if(useZoom){axes.connect(["fov"],this._axesWheelInput)}} 473this._togglePinchInputByOption(options.touchDirection,options.useZoom);if(keys.some(function(key){return key==="touchDirection"})&&this._enabled){this._enableTouch(touchDirection)}};__proto._togglePinchInputByOption=function(touchDirection,useZoom){if(this._axesPinchInput){this._axes.disconnect(this._axesPinchInput);if(useZoom&&touchDirection===TOUCH_DIRECTION_ALL&&this._axes._inputs.indexOf(this._axesPinchInput)===-1){this._axes.connect(["fov"],this._axesPinchInput)}}};__proto._enableTouch=function(direction){if(this._axesPanInput){this._axes.disconnect(this._axesPanInput)} 474var yawEnabled=direction&TOUCH_DIRECTION_YAW?"yaw":null;var pitchEnabled=direction&TOUCH_DIRECTION_PITCH?"pitch":null;this._axes.connect([yawEnabled,pitchEnabled],this._axesPanInput)};__proto._initDeviceQuaternion=function(){var _this=this;this._deviceQuaternion=new DeviceQuaternion();this._deviceQuaternion.on("change",function(e){_this._triggerChange(e)}
474)};__proto._getValidYawRange=function(newYawRange,newFov,newAspectRatio){var ratio=this._adjustAspectRatio(newAspectRatio||this.options.aspectRatio||1);var fov=newFov||this._axes.get().fov;var horizontalFov=fov*ratio;var isValid=newYawRange[1]-newYawRange[0]>=horizontalFov;if(isValid){return newYawRange}else{return this.options.yawRange||DEFAULT_YAW_RANGE}};__proto._getValidPitchRange=function(newPitchRange,newFov){var fov=newFov||this._axes.get().fov;var isValid=newPitchRange[1]-newPitchRange[0]>=fov;if(isValid){return newPitchRange}else{return this.options.pitchRange||DEFAULT_PITCH_RANGE}};__proto._isCircular=function(range){return range[1]-range[0]<360?[!1,!1]:[!0,!0]};__proto._updateControlScale=function(changeEvt){var opt=this.options;var fov=this._axes.get().fov;var pRange=this._updatePitchRange(opt.pitchRange,fov,opt.showPolePoint);var yRange=this._updateYawRange(opt.yawRange,fov,opt.aspectRatio);var pos=this._axes.get();var y=pos.yaw;var p=pos.pitch;copy$3(this._axes.axis.yaw.range,yRange);copy$3(this._axes.axis.pitch.range,pRange);this._axes.axis.yaw.circular=this._isCircular(yRange);this._axes.axis.pitch.circular=this._isCircular(pRange);if(y<yRange[0]){y=yRange[0]}else if(y>yRange[1]){y=yRange[1]} 475if(p<pRange[0]){p=pRange[0]}else if(p>pRange[1]){p=pRange[1]} 476if(changeEvt){changeEvt.set({yaw:y,pitch:p,})} 477this._axes.setTo({yaw:y,pitch:p,},0);return this};__proto._updatePitchRange=function(pitchRange,fov,showPolePoint){if(this.options.gyroMode===GYRO_MODE.VR){return CIRCULAR_PITCH_RANGE} 478var verticalAngle=pitchRange[1]-pitchRange[0];var halfFov=fov/2;var isPanorama=verticalAngle<180;if(showPolePoint&&!isPanorama){return pitchRange.concat()} 479return[pitchRange[0]+halfFov,pitchRange[1]-halfFov]};__proto._updateYawRange=function(yawRange,fov,aspectRatio){if(this.options.gyroMode===GYRO_MODE.VR){return DEFAULT_YAW_RANGE} 480var horizontalAngle=yawRange[1]-yawRange[0];if(horizontalAngle>=360){return yawRange.concat()} 481var halfHorizontalFov=util.toDegree(Math.atan2(aspectRatio,1/Math.tan(toRadian(fov/2))));return[yawRange[0]+halfHorizontalFov,yawRange[1]-halfHorizontalFov]};__proto._triggerChange=function(evt){var pos=this._axes.get();var opt=this.options;var event={targetElement:opt.element,isTrusted:evt.isTrusted,yaw:pos.yaw,pitch:pos.pitch,fov:pos.fov,quaternion:null,};if(opt.gyroMode===GYRO_MODE.VR&&this._deviceQuaternion){event.quaternion=this._deviceQuaternion.getCombinedQuaternion(pos.yaw)} 482this.trigger(new ComponentEvent$1("change",event))};__proto._adjustAspectRatio=function(input){var inputRange=[0.52,0.54,0.563,0.57,0.584,0.59,0.609,0.67,0.702,0.72,0.76,0.78,0.82,0.92,0.97,1.0,1.07,1.14,1.19,1.25,1.32,1.38,1.4,1.43,1.53,1.62,1.76,1.77,1.86,1.96,2.26,2.3,2.6,3.0,5.0,6.0];var outputRange=[0.51,0.54,0.606,0.56,0.628,0.63,0.647,0.71,0.736,0.757,0.78,0.77,0.8,0.89,0.975,1.0,1.07,1.1,1.15,1.18,1.22,1.27,1.3,1.33,1.39,1.45,1.54,1.55,1.58,1.62,1.72,1.82,1.92,2.0,2.24,2.3];var rangeIdx=-1;for(var i=0;i<inputRange.length-1;i++){if(inputRange[i]<=input&&inputRange[i+1]>=input){rangeIdx=i;break}} 483if(rangeIdx===-1){if(inputRange[0]>input){return outputRange[0]}else{return outputRange[outputRange[0].length-1]}} 484var inputA=inputRange[rangeIdx];var inputB=inputRange[rangeIdx+1];var outputA=outputRange[rangeIdx];var outputB=outputRange[rangeIdx+1];return this._lerp(outputA,outputB,(input-inputA)/(inputB-inputA))};__proto._lerp=function(a,b,fraction){return a+fraction*(b-a)};__proto._resetOrientation=function(){var opt=this.options;this._axes.setTo({yaw:opt.yaw,pitch:opt.pitch,fov:opt.fov,},0);return this};YawPitchControl.VERSION=VERSION;YawPitchControl.CONTROL_MODE_VR=CONTROL_MODE_VR;YawPitchControl.CONTROL_MODE_YAWPITCH=CONTROL_MODE_YAWPITCH;YawPitchControl.TOUCH_DIRECTION_ALL=TOUCH_DIRECTION_ALL;YawPitchControl.TOUCH_DIRECTION_YAW=TOUCH_DIRECTION_YAW;YawPitchControl.TOUCH_DIRECTION_PITCH=TOUCH_DIRECTION_PITCH;YawPitchControl.TOUCH_DIRECTION_NONE=TOUCH_DIRECTION_NONE;return YawPitchControl})(Component);/*! ***************************************************************************** 485 Copyright (c) Microsoft Corporation. 486 487 Permission to use, copy, modify, and/or distribute this software for any 488 purpose with or without fee is hereby granted. 489 490 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 491 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 492 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
493 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 494 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 495 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 496 PERFORMANCE OF THIS SOFTWARE. 497 ***************************************************************************** */ 498function __values$2(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number") 499return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o,}},};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")} 500function isUndefined$1(value){return typeof value==="undefined"} 501var Component$1=(function(){function Component(){this.options={};this._eventHandler={}} 502var __proto=Component.prototype;__proto.trigger=function(eventName){var _this=this;var params=[];for(var _i=1;_i<arguments.length;_i++){params[_i-1]=arguments[_i]} 503var handlerList=this._eventHandler[eventName]||[];var hasHandlerList=handlerList.length>0;if(!hasHandlerList){return!0} 504var customEvent=params[0]||{};var restParams=params.slice(1);handlerList=handlerList.concat();var isCanceled=!1;customEvent.eventType=eventName;customEvent.stop=function(){isCanceled=!0};customEvent.currentTarget=this;var arg=[customEvent];if(restParams.length>=1){arg=arg.concat(restParams)} 505handlerList.forEach(function(handler){handler.apply(_this,arg)});return!isCanceled};__proto.once=function(eventName,handlerToAttach){var _this=this;if(typeof eventName==="object"&&isUndefined$1(handlerToAttach)){var eventHash=eventName;for(var key in eventHash){this.once(key,eventHash[key])} 506return this}else if(typeof eventName==="string"&&typeof handlerToAttach==="function"){var listener_1=function(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i]} 507handlerToAttach.apply(_this,args);_this.off(eventName,listener_1)};this.on(eventName,listener_1)} 508return this};__proto.hasOn=function(eventName){return!!this._eventHandler[eventName]};__proto.on=function(eventName,handlerToAttach){if(typeof eventName==="object"&&isUndefined$1(handlerToAttach)){var eventHash=eventName;for(var name in eventHash){this.on(name,eventHash[name])} 509return this}else if(typeof eventName==="string"&&typeof handlerToAttach==="function"){var handlerList=this._eventHandler[eventName];if(isUndefined$1(handlerList)){this._eventHandler[eventName]=[];handlerList=this._eventHandler[eventName]} 510handlerList.push(handlerToAttach)} 511return this};__proto.off=function(eventName,handlerToDetach){var e_1,_a;if(isUndefined$1(eventName)){this._eventHandler={};return this} 512if(isUndefined$1(handlerToDetach)){if(typeof eventName==="string"){delete this._eventHandler[eventName];return this}else{var eventHash=eventName;for(var name in eventHash){this.off(name,eventHash[name])} 513return this}} 514var handlerList=this._eventHandler[eventName];if(handlerList){var idx=0;try{for(var handlerList_1=__values$2(handlerList),handlerList_1_1=handlerList_1.next();!handlerList_1_1.done;handlerList_1_1=handlerList_1.next()){var handlerFunction=handlerList_1_1.value;if(handlerFunction===handlerToDetach){handlerList.splice(idx,1);break} 515idx++}}catch(e_1_1){e_1={error:e_1_1,}}finally{try{if(handlerList_1_1&&!handlerList_1_1.done&&(_a=handlerList_1.return))_a.call(handlerList_1);}finally{if(e_1)throw e_1.error}}} 516return this};Component.VERSION="2.2.2";return Component})();/*! ***************************************************************************** 517 Copyright (c) Microsoft Corporation. 518 519 Permission to use, copy, modify, and/or distribute this software for any 520 purpose with or without fee is hereby granted. 521 522 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 523 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 524 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 525 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 526 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 527 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 528 PERFORMANCE OF THIS SOFTWARE. 529 ***************************************************************************** */ 530var extendStatics$2=function(d,b){extendStatics$2=Object.setPrototypeOf||({__proto__:[],}instanceof Array&&function(d,b){d.__proto__=b})||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics$2(d,b);};function __extends$2(d,b){extendStatics$2(d,b);function __(){this.constructor=d}
531d.prototype=b===null?Object.create(b):((__.prototype=b.prototype),new __())} 532var __assign$2=function(){__assign$2=Object.assign||function __assign(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]} 533return t};return __assign$2.apply(this,arguments)};function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;for(var r=Array(s),k=0,i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r} 534var isWindow=typeof window!=="undefined";var ua=isWindow?window.navigator.userAgent:"";var SUPPORT_COMPUTEDSTYLE=isWindow?!!("getComputedStyle" in window):!1;var IS_IE=/MSIE|Trident|Windows Phone|Edge/.test(ua);var SUPPORT_ADDEVENTLISTENER=isWindow?!!("addEventListener" in document):!1;var WIDTH="width";var HEIGHT="height";function getAttribute(el,name){return el.getAttribute(name)||""} 535function toArray$1(arr){return[].slice.call(arr)} 536function hasSizeAttribute(target,prefix){if(prefix===void 0){prefix="data-"} 537return!!target.getAttribute(prefix+"width")} 538function hasLoadingAttribute(target){return"loading" in target&&target.getAttribute("loading")==="lazy"} 539function hasSkipAttribute(target,prefix){if(prefix===void 0){prefix="data-"} 540return!!target.getAttribute(prefix+"skip")} 541function addEvent(element,type,handler){if(SUPPORT_ADDEVENTLISTENER){element.addEventListener(type,handler,!1)}else if(element.attachEvent){element.attachEvent("on"+type,handler)}else{element["on"+type]=handler}} 542function removeEvent(element,type,handler){if(element.removeEventListener){element.removeEventListener(type,handler,!1)}else if(element.detachEvent){element.detachEvent("on"+type,handler)}else{element["on"+type]=null}} 543function innerWidth(el){return getSize(el,"Width")}
544function innerHeight(el){return getSize(el,"Height")} 545function getStyles(el){return(SUPPORT_COMPUTEDSTYLE?window.getComputedStyle(el):el.currentStyle)||{}} 546function getSize(el,name){var size=el["client"+name]||el["offset"+name];return parseFloat(size||getStyles(el)[name.toLowerCase()])||0} 547function getContentElements(element,tags,prefix){var skipElements=toArray$1(element.querySelectorAll(__spreadArrays(["["+prefix+"skip] ["+prefix+"width]"],tags.map(function(tag){return["["+prefix+"skip] "+tag,tag+"["+prefix+"skip]","["+prefix+"width] "+tag].join(", ")})).join(", ")));return toArray$1(element.querySelectorAll("["+prefix+"width], "+tags.join(", "))).filter(function(el){return skipElements.indexOf(el)===-1})} 548var elements=[];function addAutoSizer(element,prefix){!elements.length&&addEvent(window,"resize",resizeAllAutoSizers);element.__PREFIX__=prefix;elements.push(element);resize(element)} 549function removeAutoSizer(element,prefix){var index=elements.indexOf(element);if(index<0){return} 550var fixed=getAttribute(element,prefix+"fixed");delete element.__PREFIX__;element.style[fixed===HEIGHT?WIDTH:HEIGHT]="";elements.splice(index,1);!elements.length&&removeEvent(window,"resize",resizeAllAutoSizers)} 551function resize(element,prefix){if(prefix===void 0){prefix="data-"} 552var elementPrefix=element.__PREFIX__||prefix;var dataWidth=parseInt(getAttribute(element,""+elementPrefix+WIDTH),10)||0;var dataHeight=parseInt(getAttribute(element,""+elementPrefix+HEIGHT),10)||0;var fixed=getAttribute(element,elementPrefix+"fixed");if(fixed===HEIGHT){var size=innerHeight(element)||dataHeight;element.style[WIDTH]=(dataWidth/dataHeight)*size+"px"}else{var size=innerWidth(element)||dataWidth;element.style[HEIGHT]=(dataHeight/dataWidth)*size+"px"}} 553function resizeAllAutoSizers(){elements.forEach(function(element){resize(element)})} 554var Loader=(function(_super){__extends$2(Loader,_super);function Loader(element,options){if(options===void 0){options={}} 555var _this=_super.call(this)||this;_this.isReady=!1;_this.isPreReady=!1;_this.hasDataSize=!1;_this.hasLoading=!1;_this.isSkip=!1;_this.onCheck=function(e){_this.clear();if(e&&e.type==="error"){_this.onError(_this.element)} 556var withPreReady=!_this.hasDataSize&&!_this.hasLoading;_this.onReady(withPreReady)};_this.options=__assign$2({prefix:"data-",},options);_this.element=element;_this.hasDataSize=hasSizeAttribute(element,_this.options.prefix);_this.hasLoading=hasLoadingAttribute(element);_this.isSkip=hasSkipAttribute(_this.element);return _this} 557var __proto=Loader.prototype;__proto.check=function(){if(this.isSkip||!this.checkElement()){this.onAlreadyReady(!0);return!1} 558if(this.hasDataSize){addAutoSizer(this.element,this.options.prefix)} 559if(this.hasDataSize||this.hasLoading){this.onAlreadyPreReady()} 560return!0};__proto.addEvents=function(){var _this=this;var element=this.element;this.constructor.EVENTS.forEach(function(name){addEvent(element,name,_this.onCheck)})};__proto.clear=function(){var _this=this;var element=this.element;this.constructor.EVENTS.forEach(function(name){removeEvent(element,name,_this.onCheck)});this.removeAutoSizer()};__proto.destroy=function(){this.clear();this.off()};__proto.removeAutoSizer=function(){if(this.hasDataSize){var prefix=this.options.prefix;removeAutoSizer(this.element,prefix)}};__proto.onError=function(target){this.trigger("error",{element:this.element,target:target,})};__proto.onPreReady=function(){if(this.isPreReady){return} 561this.isPreReady=!0;this.trigger("preReady",{element:this.element,hasLoading:this.hasLoading,isSkip:this.isSkip,})};__proto.onReady=function(withPreReady){if(this.isReady){return} 562if(withPreReady){this.isPreReady=!0} 563this.removeAutoSizer();this.isReady=!0;this.trigger("ready",{element:this.element,withPreReady:withPreReady,hasLoading:this.hasLoading,isSkip:this.isSkip,})};__proto.onAlreadyError=function(target){var _this=this;setTimeout(function(){_this.onError(target)})};__proto.onAlreadyPreReady=function(){var _this=this;setTimeout(function(){_this.onPreReady()})};__proto.onAlreadyReady=function(withPreReady){var _this=this;setTimeout(function(){_this.onReady(withPreReady)})};Loader.EVENTS=[];return Loader})(Component$1);var ElementLoader=(function(_super){__extends$2(ElementLoader,_super);function ElementLoader(){return(_super!==null&&_super.apply(this,arguments))||this} 564var __proto=ElementLoader.prototype;__proto.setHasLoading=function(hasLoading){this.hasLoading=hasLoading};__proto.check=function(){if(this.isSkip){this.onAlreadyReady(!0);return!1} 565if(this.hasDataSize){addAutoSizer(this.element,this.options.prefix);this.onAlreadyPreReady()}else{this.trigger("requestChildren")} 566return!0};__proto.checkElement=function(){return!0};__proto.destroy=function(){this.clear();this.trigger("requestDestroy");this.off()};__proto.onAlreadyPreReady=function(){_super.prototype.onAlreadyPreReady.call(this);this.trigger("reqeustReadyChildren")};ElementLoader.EVENTS=[];return ElementLoader})(Loader);var ImReadyManager=(function(_super){__extends$2(ImReadyManager,_super);function ImReadyManager(options){if(options===void 0){options={}}
567var _this=_super.call(this)||this;_this.readyCount=0;_this.preReadyCount=0;_this.totalCount=0;_this.totalErrorCount=0;_this.isPreReadyOver=!0;_this.elementInfos=[];_this.options=__assign$2({loaders:{},prefix:"data-",},options);return _this} 568var __proto=ImReadyManager.prototype;__proto.check=function(elements){var _this=this;var prefix=this.options.prefix;this.clear();this.elementInfos=toArray$1(elements).map(function(element,index){var loader=_this.getLoader(element,{prefix:prefix,});loader.check();loader.on("error",function(e){_this.onError(index,e.target)}).on("preReady",function(e){var info=_this.elementInfos[index];info.hasLoading=e.hasLoading;info.isSkip=e.isSkip;var isPreReady=_this.checkPreReady(index);_this.onPreReadyElement(index);isPreReady&&_this.onPreReady()}).on("ready",function(_a){var withPreReady=_a.withPreReady,hasLoading=_a.hasLoading,isSkip=_a.isSkip;var info=_this.elementInfos[index];info.hasLoading=hasLoading;info.isSkip=isSkip;var isPreReady=withPreReady&&_this.checkPreReady(index);var isReady=_this.checkReady(index);withPreReady&&_this.onPreReadyElement(index);_this.onReadyElement(index);isPreReady&&_this.onPreReady();isReady&&_this.onReady()});return{loader:loader,element:element,hasLoading:!1,hasError:!1,isPreReady:!1,isReady:!1,isSkip:!1,}});var length=this.elementInfos.length;this.totalCount=length;if(!length){setTimeout(function(){_this.onPreReady();_this.onReady()})} 569return this};__proto.getTotalCount=function(){return this.totalCount};__proto.isPreReady=function(){return this.elementInfos.every(function(info){return info.isPreReady})};__proto.isReady=function(){return this.elementInfos.every(function(info){return info.isReady})};__proto.hasError=function(){return this.totalErrorCount>0};__proto.clear=function(){this.isPreReadyOver=!1;this.totalCount=0;this.preReadyCount=0;this.readyCount=0;this.totalErrorCount=0;this.elementInfos.forEach(function(info){if(!info.isReady&&info.loader){info.loader.destroy()}});this.elementInfos=[]};__proto.destroy=function(){this.clear();this.off()};__proto.getLoader=function(element,options){var _this=this;var tagName=element.tagName.toLowerCase();var loaders=this.options.loaders;var tags=Object.keys(loaders);if(loaders[tagName]){return new loaders[tagName](element,options)} 570var loader=new ElementLoader(element,options);var children=toArray$1(element.querySelectorAll(tags.join(", ")));loader.setHasLoading(children.some(function(el){return hasLoadingAttribute(el)}));var withPreReady=!1;var childrenImReady=this.clone().on("error",function(e){loader.onError(e.target)}).on("ready",function(){loader.onReady(withPreReady)});loader.on("requestChildren",function(){var contentElements=getContentElements(element,tags,_this.options.prefix);childrenImReady.check(contentElements).on("preReady",function(e){withPreReady=e.isReady;if(!withPreReady){loader.onPreReady()}})}).on("reqeustReadyChildren",function(){childrenImReady.check(children)}).on("requestDestroy",function(){childrenImReady.destroy()});return loader};__proto.clone=function(){return new ImReadyManager(__assign$2({},this.options))};__proto.checkPreReady=function(index){this.elementInfos[index].isPreReady=!0;++this.preReadyCount;if(this.preReadyCount<this.totalCount){return!1} 571return!0};__proto.checkReady=function(index){this.elementInfos[index].isReady=!0;++this.readyCount;if(this.readyCount<this.totalCount){return!1} 572return!0};__proto.onError=function(index,target){var info=this.elementInfos[index];info.hasError=!0;this.trigger("error",{element:info.element,index:index,target:target,errorCount:this.getErrorCount(),totalErrorCount:++this.totalErrorCount,})};__proto.onPreReadyElement=function(index){var info=this.elementInfos[index];this.trigger("preReadyElement",{element:info.element,index:index,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:info.hasLoading,isSkip:info.isSkip,})};__proto.onPreReady=function(){this.isPreReadyOver=!0;this.trigger("preReady",{readyCount:this.readyCount,totalCount:this.totalCount,isReady:this.isReady(),hasLoading:this.hasLoading(),})};__proto.onReadyElement=function(index){var info=this.elementInfos[index];this.trigger("readyElement",{index:index,element:info.element,hasError:info.hasError,errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:info.hasLoading,isPreReadyOver:this.isPreReadyOver,isSkip:info.isSkip,})};__proto.onReady=function(){this.trigger("ready",{errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,totalCount:this.totalCount,})};__proto.getErrorCount=function(){return this.elementInfos.filter(function(info){return info.hasError}).length};__proto.hasLoading=function(){return this.elementInfos.some(function(info){return info.hasLoading})};return ImReadyManager})(Component$1);var ImageLoader=(function(_super){__extends$2(ImageLoader,_super);function ImageLoader(){return(_super!==null&&_super.apply(this,arguments))||this} 573var __proto=ImageLoader.prototype;__proto.checkElement=function(){var element=this.element;var src=element.getAttribute("src");
573if(element.complete&&src){if(!element.naturalWidth){this.onAlreadyError(element)} 574return!1} 575this.addEvents();IS_IE&&element.setAttribute("src",src);return!0};ImageLoader.EVENTS=["load","error"];return ImageLoader})(Loader);var VideoLoader=(function(_super){__extends$2(VideoLoader,_super);function VideoLoader(){return(_super!==null&&_super.apply(this,arguments))||this} 576var __proto=VideoLoader.prototype;__proto.checkElement=function(){var element=this.element;if(element.readyState>=1){return!1} 577if(element.error){this.onAlreadyError(element);return!1} 578this.addEvents();return!0};VideoLoader.EVENTS=["loadedmetadata","error"];return VideoLoader})(Loader);var ImReady=(function(_super){__extends$2(ImReady,_super);function ImReady(options){if(options===void 0){options={}} 579return(_super.call(this,__assign$2({loaders:{img:ImageLoader,video:VideoLoader,},},options))||this)} 580return ImReady})(ImReadyManager);var ERROR_TYPE={INVALID_DEVICE:10,NO_WEBGL:11,FAIL_IMAGE_LOAD:12,FAIL_BIND_TEXTURE:13,INVALID_RESOURCE:14,RENDERING_CONTEXT_LOST:15,};var PANOVIEWER_EVENTS={READY:"ready",VIEW_CHANGE:"viewChange",ANIMATION_END:"animationEnd",ERROR:"error",};var PROJECTION_TYPE={EQUIRECTANGULAR:"equirectangular",CUBEMAP:"cubemap",CUBESTRIP:"cubestrip",PANORAMA:"panorama",STEREOSCOPIC_EQUI:"stereoequi",};var STEREO_FORMAT={TOP_BOTTOM:"3dv",LEFT_RIGHT:"3dh",NONE:"",};var PANOVIEWER_OPTIONS={image:!0,video:!0,projectionType:!0,cubemapConfig:!0,stereoFormat:!0,width:!0,height:!0,yaw:!0,pitch:!0,fov:!0,showPolePoint:!0,useZoom:!0,useKeyboard:!0,gyroMode:!0,yawRange:!0,pitchRange:!0,fovRange:!0,touchDirection:!0,canvasClass:!0,};var DEFAULT_CANVAS_CLASS="view360-canvas";var merge=function(target){var srcs=[];for(var _i=1;_i<arguments.length;_i++){srcs[_i-1]=arguments[_i]} 581srcs.forEach(function(source){Object.keys(source).forEach(function(key){var value=source[key];if(Array.isArray(target[key])&&Array.isArray(value)){target[key]=__spread(target[key],value)}else{target[key]=value}})});return target};var toImageElement=function(image){var images=image instanceof Array?image:[image];var parsedImages=images.map(function(img){var imgEl=img;if(typeof img==="string"){imgEl=new Image();imgEl.crossOrigin="anonymous";imgEl.src=img} 582return imgEl});return parsedImages.length===1?parsedImages[0]:parsedImages};var toVideoElement=function(videoCandidate){if(videoCandidate instanceof HTMLVideoElement){return videoCandidate}else{var video_1=document.createElement("video");video_1.setAttribute("crossorigin","anonymous");video_1.setAttribute("webkit-playsinline","");video_1.setAttribute("playsinline","");if(videoCandidate instanceof Array){videoCandidate.forEach(function(v){return appendSourceElement(video_1,v)})}else{appendSourceElement(video_1,videoCandidate)} 583var sourceCount=video_1.querySelectorAll("source").length;if(sourceCount>0){if(video_1.readyState<1){video_1.load()}} 584return video_1}};var appendSourceElement=function(video,videoUrl){var videoSrc;var videoType;if(typeof videoUrl==="object"){videoSrc=videoUrl.src;videoType=videoUrl.type}else if(typeof videoUrl==="string"){videoSrc=videoUrl} 585if(!videoSrc){return!1} 586var sourceElement=document.createElement("source");sourceElement.src=videoSrc;if(videoType){sourceElement.type=videoType} 587video.appendChild(sourceElement)};var WEBGL_ERROR_CODE={0:"NO_ERROR",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",37442:"CONTEXT_LOST_WEBGL",};var webglAvailability=null;var WebGLUtils=(function(){function WebGLUtils(){} 588WebGLUtils.createShader=function(gl,type,source){var shader=gl.createShader(type);gl.shaderSource(shader,source);gl.compileShader(shader);var success=gl.getShaderParameter(shader,gl.COMPILE_STATUS);if(success){return shader} 589console.error(gl.getShaderInfoLog(shader));return null};WebGLUtils.createProgram=function(gl,vertexShader,fragmentShader){var program=gl.createProgram();gl.attachShader(program,vertexShader);gl.attachShader(program,fragmentShader);gl.linkProgram(program);gl.deleteShader(vertexShader);gl.deleteShader(fragmentShader);var success=gl.getProgramParameter(program,gl.LINK_STATUS);if(success){return program} 590gl.deleteProgram(program);return null};WebGLUtils.initBuffer=function(gl,target,data,itemSize,attr){var buffer=gl.createBuffer();gl.bindBuffer(target,buffer);gl.bufferData(target,data,gl.STATIC_DRAW);if(buffer){buffer.itemSize=itemSize;buffer.numItems=data.length/itemSize} 591if(attr!==undefined){gl.enableVertexAttribArray(attr);gl.vertexAttribPointer(attr,buffer.itemSize,gl.FLOAT,!1,0,0)} 592return buffer};WebGLUtils.getWebglContext=function(canvas,userContextAttributes){var e_1,_a;var webglIdentifiers=["webgl","experimental-webgl","webkit-3d","moz-webgl"];var context=null;var contextAttributes=__assign({preserveDrawingBuffer:!1,antialias:!1,},userContextAttributes);var onWebglcontextcreationerror=function(e){return e.statusMessage};canvas.addEventListener("webglcontextcreationerror",onWebglcontextcreationerror);try{for(var webglIdentifiers_1=__values(webglIdentifiers),webglIdentifiers_1_1=webglIdentifiers_1.next();!webglIdentifiers_1_1.done;webglIdentifiers_1_1=webglIdentifiers_1.next()){var identifier=webglIdentifiers_1_1.value;try{context=canvas.getContext(identifier,contextAttributes)}catch(t){} 593if(context){break}}}catch(e_1_1){e_1={error:e_1_1,}}finally{try{if(webglIdentifiers_1_1&&!webglIdentifiers_1_1.done&&(_a=webglIdentifiers_1.return))_a.call(webglIdentifiers_1);}finally{if(e_1)throw e_1.error}} 594canvas.removeEventListener("webglcontextcreationerror",onWebglcontextcreationerror);return context};WebGLUtils.createTexture=function(gl,textureTarget){var texture=gl.createTexture();gl.bindTexture(textureTarget,texture);gl.texParameteri(textureTarget,gl.TEXTURE_MAG_FILTER,gl.LINEAR);gl.texParameteri(textureTarget,gl.TEXTURE_MIN_FILTER,gl.LINEAR);gl.texParameteri(textureTarget,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(textureTarget,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);gl.bindTexture(textureTarget,null);return texture};WebGLUtils.isWebGLAvailable=function(){if(webglAvailability===null){var canvas=document.createElement("canvas");var webglContext=WebGLUtils.getWebglContext(canvas);webglAvailability=!!webglContext;if(webglContext){var loseContextExtension=webglContext.getExtension("WEBGL_lose_context");if(loseContextExtension){loseContextExtension.loseContext()}}} 595return!!webglAvailability};WebGLUtils.isStableWebGL=function(){var agentInfo=agent();var isStableWebgl=!0;if(agentInfo.os.name==="android"){var version=parseFloat(agentInfo.os.version);if(version<=4.3&&version>=1){isStableWebgl=!1}else if(version===4.4){if(agentInfo.browser.name!=="chrome"){isStableWebgl=!1}}} 596return isStableWebgl};WebGLUtils.getErrorNameFromWebGLErrorCode=function(code){if(!(code in WEBGL_ERROR_CODE)){return"UNKNOWN_ERROR"} 597return WEBGL_ERROR_CODE[code]};WebGLUtils.texImage2D=function(gl,target,pixels){try{gl.texImage2D(target,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,pixels)}catch(error){console.error("WebGLUtils.texImage2D error:",error)}};WebGLUtils.getMaxTextureSize=function(gl){return gl.getParameter(gl.MAX_TEXTURE_SIZE)};return WebGLUtils})();var agentInfo=agent();var isIE11=agentInfo.browser.name==="ie"&&agentInfo.browser.majorVersion===11;var EVENTS={ERROR:"error",};var Renderer=(function(_super){__extends(Renderer,_super);
597function Renderer(){var _this=_super.call(this)||this;_this._forceDimension=null;_this._pixelCanvas=null;_this._pixelContext=null;return _this} 598var __proto=Renderer.prototype;__proto.render=function(_a){var gl=_a.gl,shaderProgram=_a.shaderProgram,indexBuffer=_a.indexBuffer,mvMatrix=_a.mvMatrix,pMatrix=_a.pMatrix;gl.uniformMatrix4fv(shaderProgram.pMatrixUniform,!1,pMatrix);gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform,!1,mvMatrix);if(indexBuffer){gl.drawElements(gl.TRIANGLES,indexBuffer.numItems,gl.UNSIGNED_SHORT,0)}};__proto.getDimension=function(pixelSource){var width=pixelSource.naturalWidth||pixelSource.videoWidth;var height=pixelSource.naturalHeight||pixelSource.videoHeight;return{width:width,height:height,}};__proto.updateShaderData=function(param){};__proto._initPixelSource=function(image,forceDimension){if(forceDimension===void 0){forceDimension=null} 599var isIE11Video=isIE11&&image instanceof HTMLVideoElement;if(isIE11Video||forceDimension){var _a=forceDimension||this.getDimension(image),width=_a.width,height=_a.height;this._pixelCanvas=document.createElement("canvas");this._pixelCanvas.width=width;this._pixelCanvas.height=height;this._pixelContext=this._pixelCanvas.getContext("2d")} 600this._forceDimension=forceDimension};__proto._getPixelSource=function(image){if(!this._pixelCanvas){return image} 601var contentDimension=this.getDimension(image);var textureDimension=this._forceDimension||contentDimension;if(this._pixelCanvas.width!==textureDimension.width){this._pixelCanvas.width=textureDimension.width} 602if(this._pixelCanvas.height!==textureDimension.height){this._pixelCanvas.height=textureDimension.height} 603if(this._forceDimension){this._pixelContext.drawImage(image,0,0,contentDimension.width,contentDimension.height,0,0,textureDimension.width,textureDimension.height)}
603else{this._pixelContext.drawImage(image,0,0)} 604return this._pixelCanvas};__proto._extractTileConfig=function(imageConfig){var tileConfig=Array.isArray(imageConfig.tileConfig)?imageConfig.tileConfig:Array.apply(void 0,__spread(Array(6))).map(function(){return imageConfig.tileConfig});tileConfig=tileConfig.map(function(config){return __assign({flipHorizontal:!1,rotation:0,},config)});return tileConfig};__proto._triggerError=function(error){console.error("Renderer Error:",error);this.trigger(new ComponentEvent$1(EVENTS.ERROR,{message:typeof error==="string"?error:error.message,}))};Renderer.EVENTS=EVENTS;return Renderer})(Component);var CubeRenderer=(function(_super){__extends(CubeRenderer,_super);function CubeRenderer(){return(_super!==null&&_super.apply(this,arguments))||this} 605var __proto=CubeRenderer.prototype;CubeRenderer.extractOrder=function(imageConfig){return imageConfig.order||"RLUDBF"};__proto.getVertexPositionData=function(){CubeRenderer._VERTEX_POSITION_DATA=CubeRenderer._VERTEX_POSITION_DATA!==null?CubeRenderer._VERTEX_POSITION_DATA:[1,-1,1,-1,-1,1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,];return CubeRenderer._VERTEX_POSITION_DATA};__proto.getIndexData=function(){if(CubeRenderer._INDEX_DATA){return CubeRenderer._INDEX_DATA} 606var indexData=[];var vertexPositionData=this.getVertexPositionData();for(var i=0;i<vertexPositionData.length/3;i+=4){indexData.push(i,i+2,i+1,i,i+3,i+2)} 607CubeRenderer._INDEX_DATA=indexData;return indexData};__proto.getTextureCoordData=function(_a){var _this=this;var image=_a.image,imageConfig=_a.imageConfig;var vertexOrder="BFUDRL";var order=CubeRenderer.extractOrder(imageConfig);var base=this.getVertexPositionData();var tileConfig=this._extractTileConfig(imageConfig);var elemSize=3;var vertexPerTile=4;var trim=imageConfig.trim;var texCoords=vertexOrder.split("").map(function(face){return tileConfig[order.indexOf(face)]}).map(function(config,i){var rotation=Math.floor(config.rotation/90);var ordermap=config.flipHorizontal?[0,1,2,3]:[1,0,3,2];for(var r=0;r<Math.abs(rotation);r++){if((config.flipHorizontal&&rotation>0)||(!config.flipHorizontal&&rotation<0)){ordermap.push(ordermap.shift())}else{ordermap.unshift(ordermap.pop())}} 608var elemPerTile=elemSize*vertexPerTile;var tileVertex=base.slice(i*elemPerTile,i*elemPerTile+elemPerTile);var tileTemp=[];for(var j=0;j<vertexPerTile;j++){tileTemp[ordermap[j]]=tileVertex.splice(0,elemSize)} 609return tileTemp}).map(function(coord){return _this._shrinkCoord({image:image,faceCoords:coord,trim:trim,})}).reduce(function(acc,val){return __spread(acc,val.reduce(function(coords,coord){return __spread(coords,coord)},[]))},[]);return texCoords};__proto.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec3 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec3 vVertexDirectionVector;\nvoid main(void) {\n vVertexDirectionVector = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0
609);\n}"};__proto.getFragmentShaderSource=function(){return"\nprecision highp float;\nuniform samplerCube uSampler;\nvarying highp vec3 vVertexDirectionVector;\nvoid main(void) {\n gl_FragColor = textureCube(uSampler, vVertexDirectionVector);\n}"};__proto.updateTexture=function(gl,image,imageConfig){var baseOrder="RLUDBF";var order=CubeRenderer.extractOrder(imageConfig);var orderMap={};order.split("").forEach(function(v,i){orderMap[v]=i});try{if(image instanceof Array){for(var surfaceIdx=0;surfaceIdx<6;surfaceIdx++){var tileIdx=orderMap[baseOrder[surfaceIdx]];WebGLUtils.texImage2D(gl,gl.TEXTURE_CUBE_MAP_POSITIVE_X+surfaceIdx,image[tileIdx])}}else{var maxCubeMapTextureSize=this.getMaxCubeMapTextureSize(gl,image);for(var surfaceIdx=0;surfaceIdx<6;surfaceIdx++){var tileIdx=orderMap[baseOrder[surfaceIdx]];var tile=this.extractTileFromImage(image,tileIdx,maxCubeMapTextureSize);WebGLUtils.texImage2D(gl,gl.TEXTURE_CUBE_MAP_POSITIVE_X+surfaceIdx,tile)}}}catch(e){this._triggerError(e)}};__proto.bindTexture=function(gl,texture,image,imageConfig){gl.bindTexture(gl.TEXTURE_CUBE_MAP,texture);this.updateTexture(gl,image,imageConfig)};__proto.getSourceTileSize=function(image){var _a=this.getDimension(image),width=_a.width,height=_a.height;var aspectRatio=width/height;var inputTextureSize;if(aspectRatio===1/6){inputTextureSize=width}else if(aspectRatio===6){inputTextureSize=height}else if(aspectRatio===2/3){inputTextureSize=width/2}else{inputTextureSize=width/3} 610return inputTextureSize};__proto.extractTileFromImage=function(image,tileIdx,outputTextureSize){var width=this.getDimension(image).width;var inputTextureSize=this.getSourceTileSize(image);var canvas=document.createElement("canvas");canvas.width=outputTextureSize;canvas.height=outputTextureSize;var context=canvas.getContext("2d");var tilePerRow=width/inputTextureSize;var x=(inputTextureSize*tileIdx)%(inputTextureSize*tilePerRow);var y=Math.floor(tileIdx/tilePerRow)*inputTextureSize;context.drawImage(image,x,y,inputTextureSize,inputTextureSize,0,0,outputTextureSize,outputTextureSize);return canvas};__proto.getMaxCubeMapTextureSize=function(gl,image){var agentInfo=agent();var maxCubeMapTextureSize=gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE);var imageWidth=this.getSourceTileSize(image);if(agentInfo.browser.name==="ie"&&agentInfo.browser.majorVersion===11){if(!util.isPowerOfTwo(imageWidth)){for(var i=1;i<maxCubeMapTextureSize;i*=2){if(i<imageWidth){continue}else{imageWidth=i;break}}}} 611if(agentInfo.os.name==="ios"){var majorVersion=agentInfo.os.majorVersion;if(majorVersion===9){imageWidth=1024} 612if(majorVersion===8){imageWidth=512}} 613return Math.min(maxCubeMapTextureSize,imageWidth)};__proto._shrinkCoord=function(coordData){var image=coordData.image,faceCoords=coordData.faceCoords,trim=coordData.trim;var inputTextureSize=Array.isArray(image)?this.getDimension(image[0]).width:this.getSourceTileSize(image);var SHRINK_MULTIPLIER=1-trim*(2/inputTextureSize);var axisMultipliers=[0,1,2].map(function(axisIndex){var axisDir=util.sign(faceCoords[0][axisIndex]);var notSameDir=faceCoords.some(function(coord){return util.sign(coord[axisIndex])!==axisDir});return notSameDir}).map(function(notSameDir){return notSameDir?SHRINK_MULTIPLIER:1});return faceCoords.map(function(coords){return coords.map(function(coord,axisIndex){return coord*axisMultipliers[axisIndex]})})};CubeRenderer._VERTEX_POSITION_DATA=null;CubeRenderer._INDEX_DATA=null;return CubeRenderer})(Renderer);var CubeStripRenderer=(function(_super){__extends(CubeStripRenderer,_super);function CubeStripRenderer(){return(_super!==null&&_super.apply(this,arguments))||this} 614var __proto=CubeStripRenderer.prototype;__proto.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec2 vTextureCoord;\nvoid main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0
614);\n}"};__proto.getFragmentShaderSource=function(){return"\n#define PI 3.14159265359\nprecision highp float;\nvarying highp vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform bool uIsEAC;\nconst vec2 OPERATE_COORDS_RANGE = vec2(-1.0, 1.0);\nconst vec2 TEXTURE_COORDS_RANGE = vec2(0.0, 1.0);\n// vector type is used for initializing values instead of array.\nconst vec4 TEXTURE_DIVISION_X = vec4(0.0, 1.0 / 3.0, 2.0 / 3.0, 1.0);\nconst vec3 TEXTURE_DIVISION_Y = vec3(0.0, 1.0 / 2.0, 1.0);\nconst float EAC_CONST = 2.0 / PI;\nfloat scale(vec2 domainRange, vec2 targetRange, float val) {\n float unit = 1.0 / (domainRange[1] - domainRange[0]);\n return targetRange[0] + (targetRange[1] - targetRange[0]) * (val - domainRange[0]) * unit;\n}\nvoid main(void) {\n float transformedCoordX;\n float transformedCoordY;\n\n if (uIsEAC) {\n vec2 orgTextureRangeX;\n vec2 orgTextureRangeY;\n\n // Apply EAC transform\n if (vTextureCoord.s >= TEXTURE_DIVISION_X[2]) {\n orgTextureRangeX = vec2(TEXTURE_DIVISION_X[2], TEXTURE_DIVISION_X[3]);\n } else if (vTextureCoord.s >= TEXTURE_DIVISION_X[1]) {\n orgTextureRangeX = vec2(TEXTURE_DIVISION_X[1], TEXTURE_DIVISION_X[2]);\n } else {\n orgTextureRangeX = vec2(TEXTURE_DIVISION_X[0], TEXTURE_DIVISION_X[1]);\n }\n\n if (vTextureCoord.t >= TEXTURE_DIVISION_Y[1]) {\n orgTextureRangeY = vec2(TEXTURE_DIVISION_Y[1], TEXTURE_DIVISION_Y[2]);\n } else {\n orgTextureRangeY = vec2(TEXTURE_DIVISION_Y[0], TEXTURE_DIVISION_Y[1]);\n }\n\n // scaling coors by the coordinates following the range from -1.0 to 1.0.\n float px = scale(orgTextureRangeX, OPERATE_COORDS_RANGE, vTextureCoord.s);\n float py = scale(orgTextureRangeY, OPERATE_COORDS_RANGE, vTextureCoord.t);\n\n float qu = EAC_CONST * atan(px) + 0.5;\n float qv = EAC_CONST * atan(py) + 0.5;\n\n // re-scaling coors by original coordinates ranges\n transformedCoordX = scale(TEXTURE_COORDS_RANGE, orgTextureRangeX, qu);\n transformedCoordY = scale(TEXTURE_COORDS_RANGE, orgTextureRangeY, qv);\n } else {\n // normal cubemap\n transformedCoordX = vTextureCoord.s;\n transformedCoordY = vTextureCoord.t;\n }\n\n gl_FragColor = texture2D(uSampler, vec2(transformedCoordX, transformedCoordY));\n}"};__proto.getVertexPositionData=function(){if(!this._vertices){this._vertices=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,]} 615return this._vertices};__proto.getIndexData=function(){var _this=this;var indices=(function(){var indexData=[];for(var i=0;i<_this._vertices.length/3;i+=4){indexData.push(i,i+1,i+2,i,i+2,i+3)} 616return indexData})();return indices};__proto.getTextureCoordData=function(_a){var _this=this;var image=_a.image,imageConfig=_a.imageConfig;var cols=3;var rows=2;var textureSize=this.getDimension(image);var trim=imageConfig.trim;var order=imageConfig.order||"RLUDFB";var coords=[];for(var r=rows-1;r>=0;r--){for(var c=0;c<cols;c++){var coord=[c/cols,r/rows,(c+1)/cols,r/rows,(c+1)/cols,(r+1)/rows,c/cols,(r+1)/rows];coords.push(coord)}} 617var tileConfigs=this._extractTileConfig(imageConfig);coords=coords.map(function(coord){return _this._shrinkCoord(coord,textureSize,trim)}).map(function(coord,i){return _this._transformCoord(coord,tileConfigs[i])});return"BFUDRL".split("").map(function(face){return order.indexOf(face)}).map(function(index){return coords[index]}).reduce(function(acc,val){return acc.concat(val)},[])};__proto.updateTexture=function(gl,image){WebGLUtils.texImage2D(gl,gl.TEXTURE_2D,this._getPixelSource(image))};__proto.bindTexture=function(gl,texture,image){var _a=this.getDimension(image),width=_a.width,height=_a.height;var size=Math.max(width,height);var maxSize=WebGLUtils.getMaxTextureSize(gl);if(size>maxSize){this._triggerError("Image width("+width+") exceeds device limit("+maxSize+"))");return} 618this._initPixelSource(image);gl.activeTexture(gl.TEXTURE0);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,!0);gl.bindTexture(gl.TEXTURE_2D,texture);this.updateTexture(gl,image)};__proto._transformCoord=function(coord,tileConfig){var newCoord=coord.slice();if(tileConfig.flipHorizontal){newCoord=this._flipHorizontalCoord(newCoord)} 619if(tileConfig.rotation){newCoord=this._rotateCoord(newCoord,tileConfig.rotation)} 620return newCoord};__proto._shrinkCoord=function(coord,textureSize,trim){var width=textureSize.width,height=textureSize.height;var SHRINK_Y=trim*(1/height);var SHRINK_X=trim*(1/width);
620return[coord[0]+SHRINK_X,coord[1]+SHRINK_Y,coord[2]-SHRINK_X,coord[3]+SHRINK_Y,coord[4]-SHRINK_X,coord[5]-SHRINK_Y,coord[6]+SHRINK_X,coord[7]-SHRINK_Y]};__proto._rotateCoord=function(coord,rotationAngle){var SIZE=2;var shiftCount=Math.floor(rotationAngle/90)%4;if(shiftCount===0){return coord} 621var moved;var rotatedCoord=[];if(shiftCount>0){moved=coord.splice(0,shiftCount*SIZE);rotatedCoord=coord.concat(moved)}else{moved=coord.splice((4+shiftCount)*SIZE,-shiftCount*SIZE);rotatedCoord=moved.concat(coord)} 622return rotatedCoord};__proto._flipHorizontalCoord=function(coord){return[coord[2],coord[3],coord[0],coord[1],coord[6],coord[7],coord[4],coord[5]]};return CubeStripRenderer})(Renderer);var latitudeBands=60;var longitudeBands=60;var radius=2;var ANGLE_CORRECTION_FOR_CENTER_ALIGN=-0.5*Math.PI;var textureCoordData=[];var vertexPositionData=[];var indexData=[];var latIdx;var lngIdx;for(latIdx=0;latIdx<=latitudeBands;latIdx++){var theta=(latIdx/latitudeBands-0.5)*Math.PI;var sinTheta=Math.sin(theta);var cosTheta=Math.cos(theta);for(lngIdx=0;lngIdx<=longitudeBands;lngIdx++){var phi=(lngIdx/longitudeBands-0.5)*2*Math.PI+ANGLE_CORRECTION_FOR_CENTER_ALIGN;var sinPhi=Math.sin(phi);var cosPhi=Math.cos(phi);var x=cosPhi*cosTheta;var y=sinTheta;var z=sinPhi*cosTheta;var u=lngIdx/longitudeBands;var v=latIdx/latitudeBands;textureCoordData.push(u,v);vertexPositionData.push(radius*x,radius*y,radius*z);if(lngIdx!==longitudeBands&&latIdx!==latitudeBands){var a=latIdx*(longitudeBands+1)+lngIdx;var b=a+longitudeBands+1;indexData.push(a,b,a+1,b,b+1,a+1)}}} 623var SphereRenderer=(function(_super){__extends(SphereRenderer,_super);function SphereRenderer(format){var _this=_super.call(this)||this;_this._stereoFormat=format;return _this} 624var __proto=SphereRenderer.prototype;__proto.render=function(ctx){var gl=ctx.gl,shaderProgram=ctx.shaderProgram;var leftEyeScaleOffset;var rightEyeScaleOffset;switch(this._stereoFormat){case STEREO_FORMAT.TOP_BOTTOM:leftEyeScaleOffset=[1,0.5,0,0];rightEyeScaleOffset=[1,0.5,0,0.5];break;case STEREO_FORMAT.LEFT_RIGHT:leftEyeScaleOffset=[0.5,1,0,0];rightEyeScaleOffset=[0.5,1,0.5,0];break;default:leftEyeScaleOffset=[1,1,0,0];rightEyeScaleOffset=[1,1,0,0]} 625var uTexScaleOffset=gl.getUniformLocation(shaderProgram,"uTexScaleOffset");gl.uniform4fv(uTexScaleOffset,__spread(leftEyeScaleOffset,rightEyeScaleOffset));_super.prototype.render.call(this,ctx)};__proto.getVertexPositionData=function(){return SphereRenderer._VERTEX_POSITION_DATA};__proto.getIndexData=function(){return SphereRenderer._INDEX_DATA};__proto.getTextureCoordData=function(){return SphereRenderer._TEXTURE_COORD_DATA};__proto.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nuniform float uEye;\nuniform vec4 uTexScaleOffset[2];\nvarying highp vec2 vTextureCoord;\nvoid main(void) {\n vec4 scaleOffset = uTexScaleOffset[int(uEye)];\n vTextureCoord = aTextureCoord.xy * scaleOffset.xy + scaleOffset.zw;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0
625);\n}"};__proto.getFragmentShaderSource=function(){return"\nprecision highp float;\nvarying highp vec2 vTextureCoord;\nuniform sampler2D uSampler;\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vTextureCoord.st);\n}"};__proto.updateTexture=function(gl,image){WebGLUtils.texImage2D(gl,gl.TEXTURE_2D,this._getPixelSource(image))};__proto.bindTexture=function(gl,texture,image){var _a=this.getDimension(image),width=_a.width,height=_a.height;var size=Math.max(width,height);var maxSize=WebGLUtils.getMaxTextureSize(gl);if(size>maxSize){this._triggerError("Image width("+width+") exceeds device limit("+maxSize+"))");return} 626this._initPixelSource(image);gl.activeTexture(gl.TEXTURE0);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,!0);gl.bindTexture(gl.TEXTURE_2D,texture);this.updateTexture(gl,image)};SphereRenderer._VERTEX_POSITION_DATA=vertexPositionData;SphereRenderer._TEXTURE_COORD_DATA=textureCoordData;SphereRenderer._INDEX_DATA=indexData;return SphereRenderer})(Renderer);var MIN_ASPECT_RATIO_FOR_FULL_PANORAMA=6;var longitudeBands$1=60;var textureCoordData$1=[];var vertexPositionData$1=[];var indexData$1=[];var CylinderRenderer=(function(_super){__extends(CylinderRenderer,_super);function CylinderRenderer(){return(_super!==null&&_super.apply(this,arguments))||this} 627var __proto=CylinderRenderer.prototype;__proto.getVertexPositionData=function(){return CylinderRenderer._VERTEX_POSITION_DATA};__proto.getIndexData=function(){return CylinderRenderer._INDEX_DATA};__proto.getTextureCoordData=function(){return CylinderRenderer._TEXTURE_COORD_DATA};__proto.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec2 vTextureCoord;\nvoid main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0
627);\n}"};__proto.getFragmentShaderSource=function(){return"\nprecision highp float;\nvarying highp vec2 vTextureCoord;\nuniform sampler2D uSampler;\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));\n}"};__proto.updateTexture=function(gl,image){WebGLUtils.texImage2D(gl,gl.TEXTURE_2D,this._getPixelSource(image))};__proto.bindTexture=function(gl,texture,image){var _a=this.getDimension(image),width=_a.width,height=_a.height;var size=Math.max(width,height);var maxSize=WebGLUtils.getMaxTextureSize(gl);var resizeDimension;if(size>maxSize){this._triggerError("Image width("+width+") exceeds device texture limit("+maxSize+"))");resizeDimension=width>height?{width:maxSize,height:(maxSize*height)/width,}:{width:(maxSize*width)/height,height:maxSize,}} 628this._initPixelSource(image,resizeDimension);gl.activeTexture(gl.TEXTURE0);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,!0);gl.bindTexture(gl.TEXTURE_2D,texture);this.updateTexture(gl,image)};__proto.updateShaderData=function(_a){var _b=_a.imageAspectRatio,imageAspectRatio=_b===void 0?MIN_ASPECT_RATIO_FOR_FULL_PANORAMA:_b;var lngIdx;var cylinderMaxRadian;var halfCylinderY;var rotated;var aspectRatio;if(imageAspectRatio<1){rotated=!0;aspectRatio=1/imageAspectRatio}else{rotated=!1;aspectRatio=imageAspectRatio} 629if(aspectRatio>=MIN_ASPECT_RATIO_FOR_FULL_PANORAMA){var fov=360/aspectRatio;cylinderMaxRadian=2*Math.PI;halfCylinderY=Math.tan(toRadian(fov/2))}else{cylinderMaxRadian=aspectRatio;halfCylinderY=0.5} 630textureCoordData$1.length=0;vertexPositionData$1.length=0;indexData$1.length=0;var CYLIDER_Y=[-halfCylinderY,halfCylinderY];var startAngleForCenterAlign=Math.PI/2+(2*Math.PI-cylinderMaxRadian)/2;
630for(var yIdx=0,yLength=CYLIDER_Y.length;yIdx<yLength;yIdx++){for(lngIdx=0;lngIdx<=longitudeBands$1;lngIdx++){var angle=startAngleForCenterAlign+(lngIdx/longitudeBands$1)*cylinderMaxRadian;var x=Math.cos(angle);var y=CYLIDER_Y[yIdx];var z=Math.sin(angle);var u=void 0;var v=void 0;if(rotated){u=1-yIdx;v=lngIdx/longitudeBands$1}else{u=lngIdx/longitudeBands$1;v=yIdx} 631textureCoordData$1.push(u,v);vertexPositionData$1.push(x,y,z);if(yIdx===0&&lngIdx<longitudeBands$1){var a=lngIdx;var b=a+longitudeBands$1+1;indexData$1.push(a,b,a+1,b,b+1,a+1)}}}};CylinderRenderer._VERTEX_POSITION_DATA=vertexPositionData$1;CylinderRenderer._TEXTURE_COORD_DATA=textureCoordData$1;CylinderRenderer._INDEX_DATA=indexData$1;return CylinderRenderer})(Renderer);var VR_DISPLAY_PRESENT_CHANGE="vrdisplaypresentchange";var DEFAULT_LEFT_BOUNDS=[0,0,0.5,1];var DEFAULT_RIGHT_BOUNDS=[0.5,0,0.5,1];var EYES={LEFT:"left",RIGHT:"right",};var VRManager=(function(){function VRManager(){var _this=this;this.destroy=function(){var vrDisplay=_this._vrDisplay;_this.removeEndCallback(_this.destroy);if(vrDisplay&&vrDisplay.isPresenting){void vrDisplay.exitPresent()} 632_this._clear()};this._frameData=new window.VRFrameData();this._clear()} 633var __proto=VRManager.prototype;Object.defineProperty(__proto,"context",{get:function(){return this._vrDisplay},enumerable:!1,configurable:!0,});__proto.canRender=function(){return Boolean(this._vrDisplay)};__proto.beforeRender=function(gl){gl.bindFramebuffer(gl.FRAMEBUFFER,null)};__proto.afterRender=function(){this._vrDisplay.submitFrame()};__proto.getEyeParams=function(gl){var display=this._vrDisplay;var halfWidth=gl.drawingBufferWidth*0.5;var height=gl.drawingBufferHeight;var frameData=this._frameData;display.getFrameData(frameData);var leftMVMatrix=frameData.leftViewMatrix;var rightMVMatrix=frameData.rightViewMatrix;rotateY(leftMVMatrix,leftMVMatrix,this._yawOffset);rotateY(rightMVMatrix,rightMVMatrix,this._yawOffset);return[{viewport:[0,0,halfWidth,height],mvMatrix:leftMVMatrix,pMatrix:frameData.leftProjectionMatrix,},{viewport:[halfWidth,0,halfWidth,height],mvMatrix:rightMVMatrix,pMatrix:frameData.rightProjectionMatrix,},]};__proto.isPresenting=function(){return Boolean(this._vrDisplay&&this._vrDisplay.isPresenting)};__proto.addEndCallback=function(callback){window.addEventListener(VR_DISPLAY_PRESENT_CHANGE,callback)};__proto.removeEndCallback=function(callback){window.removeEventListener(VR_DISPLAY_PRESENT_CHANGE,callback)};__proto.requestPresent=function(canvas){var _this=this;return navigator.getVRDisplays().then(function(displays){var vrDisplay=displays.length&&displays[0];if(!vrDisplay){return Promise$1.reject(new Error("No displays available."))} 634if(!vrDisplay.capabilities.canPresent){return Promise$1.reject(new Error("Display lacking capability to present."))} 635return vrDisplay.requestPresent([{source:canvas,},]).then(function(){var leftEye=vrDisplay.getEyeParameters(EYES.LEFT);var rightEye=vrDisplay.getEyeParameters(EYES.RIGHT);canvas.width=Math.max(leftEye.renderWidth,rightEye.renderWidth)*2;canvas.height=Math.max(leftEye.renderHeight,rightEye.renderHeight);_this._setDisplay(vrDisplay)})})};__proto.setYawOffset=function(offset){this._yawOffset=offset};__proto._setDisplay=function(vrDisplay){this._vrDisplay=vrDisplay;var layers=vrDisplay.getLayers();if(layers.length){var layer=layers[0];this._leftBounds=layer.leftBounds;this._rightBounds=layer.rightBounds} 636this.addEndCallback(this.destroy)};__proto._clear=function(){this._vrDisplay=null;this._leftBounds=DEFAULT_LEFT_BOUNDS;this._rightBounds=DEFAULT_RIGHT_BOUNDS;this._yawOffset=0};return VRManager})();var XR_REFERENCE_SPACE="local";var XRManager=(function(){function XRManager(options){var _this=this;if(options===void 0){options={}} 637this.destroy=function(){var xrSession=_this._xrSession;_this.removeEndCallback(_this.destroy);if(xrSession){xrSession.end().then(function(){return void 0},function(){return void 0})} 638_this._clear()};this._clear();this._options=options} 639var __proto=XRManager.prototype;Object.defineProperty(__proto,"context",{get:function(){return this._xrSession}
639,enumerable:!1,configurable:!0,});__proto.canRender=function(frame){var pose=frame.getViewerPose(this._xrRefSpace);return Boolean(pose)};__proto.beforeRender=function(gl,frame){var session=frame.session;var baseLayer=session.renderState.baseLayer;gl.bindFramebuffer(gl.FRAMEBUFFER,baseLayer.framebuffer)};__proto.afterRender=function(){};__proto.getEyeParams=function(gl,frame){var _this=this;var session=frame.session;var pose=frame.getViewerPose(this._xrRefSpace);if(!pose){return null} 640var glLayer=session.renderState.baseLayer;return pose.views.map(function(view){var viewport=glLayer.getViewport(view);var mvMatrix=view.transform.inverse.matrix;if(IS_SAFARI_ON_DESKTOP){rotateX(mvMatrix,mvMatrix,toRadian(180))} 641rotateY(mvMatrix,mvMatrix,_this._yawOffset);return{viewport:[viewport.x,viewport.y,viewport.width,viewport.height],mvMatrix:mvMatrix,pMatrix:view.projectionMatrix,}})};__proto.isPresenting=function(){return this._presenting};__proto.addEndCallback=function(callback){var _a;(_a=this._xrSession)===null||_a===void 0?void 0:_a.addEventListener("end",callback)};__proto.removeEndCallback=function(callback){var _a;(_a=this._xrSession)===null||_a===void 0?void 0:_a.removeEventListener("end",callback)};__proto.requestPresent=function(canvas,gl){return __awaiter(this,void 0,void 0,function(){var options,attributes;var _this=this;return __generator(this,function(_a){switch(_a.label){case 0:options=merge({requiredFeatures:[XR_REFERENCE_SPACE],},this._options);attributes=gl.getContextAttributes();if(!(attributes&&attributes.xrCompatible!==!0)) 642return[3,2,];return[4,gl.makeXRCompatible(),];case 1:_a.sent();_a.label=2;case 2:return[2,navigator.xr.requestSession("immersive-vr",options).then(function(session){var xrLayer=new window.XRWebGLLayer(session,gl);session.updateRenderState({baseLayer:xrLayer,});return session.requestReferenceSpace(XR_REFERENCE_SPACE).then(function(refSpace){_this._setSession(session,xrLayer,refSpace)})}),]}})})};__proto.setYawOffset=function(offset){this._yawOffset=offset};__proto._setSession=function(session,xrLayer,refSpace){this._xrSession=session;this._xrLayer=xrLayer;this._xrRefSpace=refSpace;this._presenting=!0;this.addEndCallback(this.destroy)};__proto._clear=function(){this._xrSession=null;this._xrLayer=null;this._xrRefSpace=null;this._presenting=!1;this._yawOffset=0;this._options={}};return XRManager})();var WebGLAnimator=(function(){function WebGLAnimator(){var _this=this;this._onLoop=function(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i]} 643_this._callback.apply(_this,__spread(args));_this._rafId=_this._context.requestAnimationFrame(_this._onLoop)};this._onLoopNextTick=function(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i]} 644var before=performance.now();_this._callback.apply(_this,__spread(args));var diff=performance.now()-before;if(_this._rafTimer>=0){clearTimeout(_this._rafTimer);_this._rafTimer=-1} 645if(diff<16){_this._rafId=_this._context.requestAnimationFrame(_this._onLoop)}else{_this._rafTimer=window.setTimeout(_this._onLoop,0)}};this._callback=null;this._context=window;this._rafId=-1;this._rafTimer=-1} 646var __proto=WebGLAnimator.prototype;__proto.setCallback=function(callback){this._callback=callback};__proto.setContext=function(context){this._context=context};__proto.start=function(){var context=this._context;var callback=this._callback;if(!context||!callback)return;if(this._rafId>=0||this._rafTimer>=0)return;if(IS_SAFARI_ON_DESKTOP){this._rafId=context.requestAnimationFrame(this._onLoopNextTick)}else{this._rafId=context.requestAnimationFrame(this._onLoop)}};__proto.stop=function(){if(this._rafId>=0){this._context.cancelAnimationFrame(this._rafId)} 647if(this._rafTimer>=0){clearTimeout(this._rafTimer)} 648this._rafId=-1;this._rafTimer=-1};return WebGLAnimator})();var ImageType=PROJECTION_TYPE;var DEVICE_PIXEL_RATIO=devicePixelRatio||1;if(DEVICE_PIXEL_RATIO>2){DEVICE_PIXEL_RATIO=2} 649var EVENTS$1={BIND_TEXTURE:"bindTexture",IMAGE_LOADED:"imageLoaded",ERROR:"error",RENDERING_CONTEXT_LOST:"renderingContextLost",RENDERING_CONTEXT_RESTORE:"renderingContextRestore",};var ERROR_TYPE$1={INVALID_DEVICE:10,NO_WEBGL:11,FAIL_IMAGE_LOAD:12,RENDERER_ERROR:13,};
649var PanoImageRenderer=(function(_super){__extends(PanoImageRenderer,_super);function PanoImageRenderer(image,width,height,isVideo,container,canvasClass,sphericalConfig,renderingContextAttributes){var _this=_super.call(this)||this;_this.textureCoordBuffer=null;_this.vertexBuffer=null;_this.indexBuffer=null;_this.exitVR=function(){var vr=_this._vr;var gl=_this.context;var animator=_this._animator;if(!vr)return;vr.removeEndCallback(_this.exitVR);vr.destroy();_this._vr=null;if(IS_IOS){_this._restoreStyle()} 650_this.updateViewportDimensions(_this.width,_this.height);_this._updateViewport();gl.bindFramebuffer(gl.FRAMEBUFFER,null);_this._bindBuffers();_this._shouldForceDraw=!0;animator.stop();animator.setContext(window);animator.setCallback(_this._render.bind(_this));animator.start()};_this._renderStereo=function(time,frame){var e_1,_a;var vr=_this._vr;var gl=_this.context;var eyeParams=vr.getEyeParams(gl,frame);if(!eyeParams)return;vr.beforeRender(gl,frame);try{for(var _b=__values([0,1]),_c=_b.next();!_c.done;_c=_b.next()){var eyeIndex=_c.value;var eyeParam=eyeParams[eyeIndex];_this.mvMatrix=eyeParam.mvMatrix;_this.pMatrix=eyeParam.pMatrix;gl.viewport.apply(gl,__spread(eyeParam.viewport));gl.uniform1f(_this.shaderProgram.uEye,eyeIndex);_this._bindBuffers();_this._draw()}}catch(e_1_1){e_1={error:e_1_1,}}finally{try{if(_c&&!_c.done&&(_a=_b.return))_a.call(_b);}finally{if(e_1)throw e_1.error}} 651vr.afterRender()};_this._onFirstVRFrame=function(time,frame){var vr=_this._vr;var gl=_this.context;var animator=_this._animator;if(!vr.canRender(frame))return;var minusZDir=fromValues(0,0,-1);var eyeParam=vr.getEyeParams(gl,frame)[0];var mvMatrix=fromMat4(create(),eyeParam.mvMatrix);var pMatrix=fromMat4(create(),eyeParam.pMatrix);var mvInv=invert(create(),mvMatrix);var pInv=invert(create(),pMatrix);var viewDir=transformMat3(create$2(),minusZDir,pInv);transformMat3(viewDir,viewDir,mvInv);var yawOffset=util.yawOffsetBetween(viewDir,fromValues(0,0,1));if(yawOffset===0){return} 652vr.setYawOffset(yawOffset);animator.setCallback(_this._renderStereo)};_this.sphericalConfig=sphericalConfig;_this.fieldOfView=sphericalConfig.fieldOfView;_this.width=width;_this.height=height;_this._lastQuaternion=null;_this._lastYaw=null;_this._lastPitch=null;_this._lastFieldOfView=null;_this.pMatrix=create$1();_this.mvMatrix=create$1();perspective(_this.pMatrix,toRadian(_this.fieldOfView),width/height,0.1,100);_this.textureCoordBuffer=null;_this.vertexBuffer=null;_this.indexBuffer=null;_this.canvas=_this._initCanvas(container,canvasClass,width,height);_this._setDefaultCanvasStyle();_this._wrapper=null;_this._wrapperOrigStyle=null;_this._renderingContextAttributes=renderingContextAttributes;_this._image=null;_this._imageConfig=null;_this._imageIsReady=!1;_this._shouldForceDraw=!1;_this._keepUpdate=!1;_this._onContentLoad=_this._onContentLoad.bind(_this);_this._onContentError=_this._onContentError.bind(_this);_this._animator=new WebGLAnimator();_this._vr=null;if(image){_this.setImage({image:image,imageType:sphericalConfig.imageType,isVideo:isVideo,cubemapConfig:sphericalConfig.cubemapConfig,})} 653return _this} 654var __proto=PanoImageRenderer.prototype;__proto.setYawPitchControl=function(yawPitchControl){this._yawPitchControl=yawPitchControl};__proto.getContent=function(){return this._image};__proto.setImage=function(_a){var image=_a.image,imageType=_a.imageType,_b=_a.isVideo,isVideo=_b===void 0?!1:_b,cubemapConfig=_a.cubemapConfig;this._imageIsReady=!1;this._isVideo=isVideo;this._imageConfig=__assign({order:imageType===ImageType.CUBEMAP?"RLUDBF":"RLUDFB",tileConfig:{flipHorizontal:!1,rotation:0,},trim:0,},cubemapConfig);this._setImageType(imageType);if(this._contentLoader){this._contentLoader.destroy()} 655this._contentLoader=new ImReady().on("ready",this._onContentLoad).on("error",this._onContentError);if(isVideo){this._image=toVideoElement(image);this._contentLoader.check([this._image]);this._keepUpdate=!0}else{this._image=toImageElement(image);this._contentLoader.check(Array.isArray(this._image)?this._image:[this._image]);this._keepUpdate=!1}};__proto.isImageLoaded=function(){return(!!this._image&&this._imageIsReady&&(!this._isVideo||this._image.readyState>=2))};__proto.bindTexture=function(){var _this=this;return new Promise$1(function(res,rej){var contentLoader=_this._contentLoader;if(!_this._image){return rej("Image is not defined")} 656if(!contentLoader){return rej("ImageLoader is not initialized")} 657if(contentLoader.isReady()){_this._bindTexture();res()}else{contentLoader.check(Array.isArray(_this._image)?_this._image:[_this._image]);contentLoader.once("ready",function(e){if(e.errorCount>0){rej("Failed to load images.")}else{_this._bindTexture();res()}})}})};__proto.attachTo=function(parentElement){if(!this._hasExternalCanvas){this.detach();parentElement.appendChild(this.canvas)} 658this._wrapper=parentElement};__proto.forceContextLoss=function(){if(this.hasRenderingContext()){var loseContextExtension=this.context.getExtension("WEBGL_lose_context");if(loseContextExtension){loseContextExtension.loseContext()}}};__proto.detach=function(){if(!this._hasExternalCanvas&&this.canvas.parentElement){this.canvas.parentElement.removeChild(this.canvas)}};__proto.destroy=function(){if(this._contentLoader){this._contentLoader.destroy()} 659this._animator.stop();this.detach();this.forceContextLoss();this.off();this.canvas.removeEventListener("webglcontextlost",this._onWebglcontextlost);this.canvas.removeEventListener("webglcontextrestored",this._onWebglcontextrestored)};__proto.hasRenderingContext=function(){var ctx=this.context;if(!ctx||ctx.isContextLost()||!ctx.getProgramParameter(this.shaderProgram,ctx.LINK_STATUS)){return!1} 660return!0};__proto.updateFieldOfView=function(fieldOfView){this.fieldOfView=fieldOfView;this._updateViewport()};__proto.updateViewportDimensions=function(width,height){var viewPortChanged=!1;this.width=width;this.height=height;var w=width*DEVICE_PIXEL_RATIO;var h=height*DEVICE_PIXEL_RATIO;if(w!==this.canvas.width){this.canvas.width=w;viewPortChanged=!0} 661if(h!==this.canvas.height){this.canvas.height=h;viewPortChanged=!0} 662if(!viewPortChanged){return} 663this._updateViewport();this._shouldForceDraw=!0};__proto.keepUpdate=function(doUpdate){if(doUpdate&&this.isImageLoaded()===!1){this._shouldForceDraw=!0} 664this._keepUpdate=doUpdate};__proto.startRender=function(){this._animator.setCallback(this._render.bind(this));this._animator.start()};__proto.stopRender=function(){this._animator.stop()};__proto.renderWithQuaternion=function(quaternion,fieldOfView){if(!this.isImageLoaded()){return} 665if(this._keepUpdate===!1&&this._lastQuaternion&&exactEquals$1(this._lastQuaternion,quaternion)&&this.fieldOfView&&this.fieldOfView===fieldOfView&&this._shouldForceDraw===!1){return} 666if(fieldOfView!==undefined&&fieldOfView!==this.fieldOfView){this.updateFieldOfView(fieldOfView)} 667this.mvMatrix=fromQuat(create$1(),quaternion);this._draw();this._lastQuaternion=clone$1(quaternion);if(this._shouldForceDraw){this._shouldForceDraw=!1}};__proto.renderWithYawPitch=function(yaw,pitch,fieldOfView){if(!this.isImageLoaded()){return} 668if(this._keepUpdate===!1&&this._lastYaw!==null&&this._lastYaw===yaw&&this._lastPitch!==null&&this._lastPitch===pitch&&this.fieldOfView&&this.fieldOfView===fieldOfView&&this._shouldForceDraw===!1){return} 669if(fieldOfView!==undefined&&fieldOfView!==this.fieldOfView){this.updateFieldOfView(fieldOfView)} 670identity(this.mvMatrix);rotateX(this.mvMatrix,this.mvMatrix,-toRadian(pitch));rotateY(this.mvMatrix,this.mvMatrix,-toRadian(yaw));this._draw();this._lastYaw=yaw;this._lastPitch=pitch;if(this._shouldForceDraw){this._shouldForceDraw=!1}};__proto.getProjectionRenderer=function(){return this._renderer};__proto.enterVR=function(options){var vr=this._vr;if(!WEBXR_SUPPORTED&&!navigator.getVRDisplays){return Promise$1.reject("VR is not available on this browser.")} 671if(vr&&vr.isPresenting()){return Promise$1.resolve("VR already enabled.")} 672return this._requestPresent(options)};__proto._setImageType=function(imageType){var _this=this;if(!imageType||this._imageType===imageType){return} 673this._imageType=imageType;this._isCubeMap=imageType===ImageType.CUBEMAP;if(this._renderer){this._renderer.off()} 674switch(imageType){case ImageType.CUBEMAP:this._renderer=new CubeRenderer();break;case ImageType.CUBESTRIP:this._renderer=new CubeStripRenderer();break;case ImageType.PANORAMA:this._renderer=new CylinderRenderer();break;case ImageType.STEREOSCOPIC_EQUI:this._renderer=new SphereRenderer(this.sphericalConfig.stereoFormat);break;default:this._renderer=new SphereRenderer(STEREO_FORMAT.NONE);break} 675this._renderer.on(Renderer.EVENTS.ERROR,function(e){_this.trigger(new ComponentEvent$1(EVENTS$1.ERROR,{type:ERROR_TYPE$1.RENDERER_ERROR,message:e.message,}))});this._initWebGL()};__proto._initCanvas=function(container,canvasClass,width,height){var canvasInContainer=container.querySelector("."+canvasClass);var canvas=canvasInContainer||this._createCanvas(canvasClass);this._hasExternalCanvas=!!canvasInContainer;canvas.width=width;canvas.height=height;this._onWebglcontextlost=this._onWebglcontextlost.bind(this);this._onWebglcontextrestored=this._onWebglcontextrestored.bind(this);canvas.addEventListener("webglcontextlost",this._onWebglcontextlost);canvas.addEventListener("webglcontextrestored",this._onWebglcontextrestored);return canvas};__proto._createCanvas=function(className){var canvas=document.createElement("canvas");canvas.className=className;return canvas};__proto._setDefaultCanvasStyle=function(){var canvas=this.canvas;canvas.style.bottom="0";canvas.style.left="0";canvas.style.right="0";canvas.style.top="0";canvas.style.margin="auto";canvas.style.maxHeight="100%";canvas.style.maxWidth="100%";canvas.style.outline="none";canvas.style.position="absolute"};__proto._onContentError=function(){this._imageIsReady=!1;this._image=null;this.trigger(new ComponentEvent$1(EVENTS$1.ERROR,{type:ERROR_TYPE$1.FAIL_IMAGE_LOAD,message:"failed to load image",}));return!1};__proto._triggerContentLoad=function(){this.trigger(new ComponentEvent$1(EVENTS$1.IMAGE_LOADED,{content:this._image,isVideo:this._isVideo,projectionType:this._imageType,}))};__proto._onContentLoad=function(e){if(e.errorCount>0)return;this._imageIsReady=!0;this._triggerContentLoad()};__proto._initShaderProgram=function(){var gl=this.context;if(this.shaderProgram){gl.deleteProgram(this.shaderProgram);this.shaderProgram=null} 676var renderer=this._renderer;var vsSource=renderer.getVertexShaderSource();var fsSource=renderer.getFragmentShaderSource();var vertexShader=WebGLUtils.createShader(gl,gl.VERTEX_SHADER,vsSource);var fragmentShader=WebGLUtils.createShader(gl,gl.FRAGMENT_SHADER,fsSource);var shaderProgram=WebGLUtils.createProgram(gl,vertexShader,fragmentShader);if(!shaderProgram){throw new Error("Failed to initialize shaders: "+WebGLUtils.getErrorNameFromWebGLErrorCode(gl.getError()))} 677gl.useProgram(shaderProgram);shaderProgram.vertexPositionAttribute=gl.getAttribLocation(shaderProgram,"aVertexPosition");shaderProgram.pMatrixUniform=gl.getUniformLocation(shaderProgram,"uPMatrix");shaderProgram.mvMatrixUniform=gl.getUniformLocation(shaderProgram,"uMVMatrix");shaderProgram.samplerUniform=gl.getUniformLocation(shaderProgram,"uSampler");shaderProgram.textureCoordAttribute=gl.getAttribLocation(shaderProgram,"aTextureCoord");shaderProgram.uEye=gl.getUniformLocation(shaderProgram,"uEye");gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);gl.enableVertexAttribArray(shaderProgram.textureCoordAttribute);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT|gl.STENCIL_BUFFER_BIT);gl.uniform1i(shaderProgram.samplerUniform,0);this.shaderProgram=shaderProgram};__proto._onWebglcontextlost=function(e){e.preventDefault();this.trigger(new ComponentEvent$1(EVENTS$1.RENDERING_CONTEXT_LOST))};__proto._onWebglcontextrestored=function(){this._initWebGL();this.trigger(new ComponentEvent$1(EVENTS$1.RENDERING_CONTEXT_RESTORE))};__proto._updateViewport=function(){perspective(this.pMatrix,toRadian(this.fieldOfView),this.canvas.width/this.canvas.height,0.1,100);this.context.viewport(0,0,this.context.drawingBufferWidth,this.context.drawingBufferHeight)};__proto._initWebGL=function(){var gl;try{this._initRenderingContext();gl=this.context;this.updateViewportDimensions(this.width,this.height);this._initShaderProgram()}catch(e){this.trigger(new ComponentEvent$1(EVENTS$1.ERROR,{type:ERROR_TYPE$1.NO_WEBGL,message:"no webgl support",}));this.destroy();console.error(e);return} 678gl.clearColor(0,0,0,0);var textureTarget=this._isCubeMap?gl.TEXTURE_CUBE_MAP:gl.TEXTURE_2D;if(this.texture){gl.deleteTexture(this.texture)} 679this.texture=WebGLUtils.createTexture(gl,textureTarget);if(this._imageType===ImageType.CUBESTRIP){gl.enable(gl.CULL_FACE)}};__proto._initRenderingContext=function(){if(this.hasRenderingContext()){return} 680if(!window.WebGLRenderingContext){throw new Error("WebGLRenderingContext not available.")} 681this.context=WebGLUtils.getWebglContext(this.canvas,this._renderingContextAttributes);if(!this.context){throw new Error("Failed to acquire 3D rendering context")}};__proto._initBuffers=function(){var image=this._image;var vertexPositionData=this._renderer.getVertexPositionData();var indexData=this._renderer.getIndexData();var textureCoordData=this._renderer.getTextureCoordData({image:image,imageConfig:this._imageConfig,});var gl=this.context;this.vertexBuffer=WebGLUtils.initBuffer(gl,gl.ARRAY_BUFFER,new Float32Array(vertexPositionData),3,this.shaderProgram.vertexPositionAttribute);this.indexBuffer=WebGLUtils.initBuffer(gl,gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(indexData),1);this.textureCoordBuffer=WebGLUtils.initBuffer(gl,gl.ARRAY_BUFFER,new Float32Array(textureCoordData),this._isCubeMap?3:2,this.shaderProgram.textureCoordAttribute);this._bindBuffers()};__proto._bindTexture=function(){if(this._imageType===ImageType.CUBESTRIP){var _a=this._renderer.getDimension(this._image),width=_a.width,height=_a.height;var isEAC=width&&height&&width/height!==1.5?1:0;this.context.uniform1f(this.context.getUniformLocation(this.shaderProgram,"uIsEAC"),isEAC)}else if(this._imageType===ImageType.PANORAMA){var _b=this._renderer.getDimension(this._image),width=_b.width,height=_b.he
681ight;var imageAspectRatio=width&&height&&width/height;this._renderer.updateShaderData({imageAspectRatio:imageAspectRatio,})} 682this._initBuffers();this._renderer.bindTexture(this.context,this.texture,this._image,this._imageConfig);this._shouldForceDraw=!0;this.trigger(new ComponentEvent$1(EVENTS$1.BIND_TEXTURE))};__proto._updateTexture=function(){this._renderer.updateTexture(this.context,this._image,this._imageConfig)};__proto._render=function(){var yawPitchControl=this._yawPitchControl;var fov=yawPitchControl.getFov();if(yawPitchControl.shouldRenderWithQuaternion()){var quaternion=yawPitchControl.getQuaternion();this.renderWithQuaternion(quaternion,fov)}else{var yawPitch=yawPitchControl.getYawPitch();this.renderWithYawPitch(yawPitch.yaw,yawPitch.pitch,fov)}};__proto._bindBuffers=function(){var gl=this.context;var program=this.shaderProgram;var vertexBuffer=this.vertexBuffer;var textureCoordBuffer=this.textureCoordBuffer;gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer);gl.enableVertexAttribArray(program.vertexPositionAttribute);gl.vertexAttribPointer(program.vertexPositionAttribute,vertexBuffer.itemSize,gl.FLOAT,!1,0,0);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);gl.bindBuffer(gl.ARRAY_BUFFER,textureCoordBuffer);gl.enableVertexAttribArray(program.textureCoordAttribute);gl.vertexAttribPointer(program.textureCoordAttribute,textureCoordBuffer.itemSize,gl.FLOAT,!1,0,0)};__proto._draw=function(){if(this._isVideo&&this._keepUpdate){this._updateTexture()} 683this._renderer.render({gl:this.context,shaderProgram:this.shaderProgram,indexBuffer:this.indexBuffer,mvMatrix:this.mvMatrix,pMatrix:this.pMatrix,})};__proto._requestPresent=function(options){var _this=this;var gl=this.context;var canvas=this.canvas;var animator=this._animator;this._vr=WEBXR_SUPPORTED?new XRManager(options):new VRManager();var vr=this._vr;animator.stop();return new Promise$1(function(resolve,reject){vr.requestPresent(canvas,gl).then(function(){vr.addEndCallback(_this.exitVR);animator.setContext(vr.context);animator.setCallback(_this._onFirstVRFrame);if(IS_IOS){_this._setWrapperFullscreen()} 684_this._shouldForceDraw=!0;animator.start();resolve("success")}).catch(function(e){vr.destroy();_this._vr=null;animator.start();reject(e)})})};__proto._setWrapperFullscreen=function(){var wrapper=this._wrapper;if(!wrapper)return;this._wrapperOrigStyle=wrapper.getAttribute("style");var wrapperStyle=wrapper.style;wrapperStyle.width="100vw";wrapperStyle.height="100vh";wrapperStyle.position="fixed";wrapperStyle.left="0";wrapperStyle.top="0";wrapperStyle.zIndex="9999"};__proto._restoreStyle=function(){var wrapper=this._wrapper;var canvas=this.canvas;if(!wrapper)return;if(this._wrapperOrigStyle){wrapper.setAttribute("style",this._wrapperOrigStyle)}else{wrapper.removeAttribute("style")} 685this._wrapperOrigStyle=null;canvas.removeAttribute("style");this._setDefaultCanvasStyle()};PanoImageRenderer.EVENTS=EVENTS$1;PanoImageRenderer.ERROR_TYPE=ERROR_TYPE$1;return PanoImageRenderer})(Component);var PanoViewer=(function(_super){__extends(PanoViewer,_super);function PanoViewer(container,options){if(options===void 0){options={}} 686var _this=_super.call(this)||this;if(!WebGLUtils.isWebGLAvailable()){setTimeout(function(){_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.ERROR,{type:ERROR_TYPE.NO_WEBGL,message:"no webgl support",}))},0);return _this} 687if(!WebGLUtils.isStableWebGL()){setTimeout(function(){_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.ERROR,{type:ERROR_TYPE.INVALID_DEVICE,message:"blacklisted browser",}))},0);return _this} 688if(!!options.image&&!!options.video){setTimeout(function(){_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.ERROR,{type:ERROR_TYPE.INVALID_RESOURCE,message:"Specifying multi resouces(both image and video) is not valid.",}))},0);return _this} 689checkXRSupport();_this._container=container;_this._image=options.image||options.video;_this._isVideo=!!options.video;_this._projectionType=options.projectionType||PROJECTION_TYPE.EQUIRECTANGULAR;_this._cubemapConfig=__assign({order:_this._projectionType===PROJECTION_TYPE.CUBEMAP?"RLUDBF":"RLUDFB",tileConfig:{flipHorizontal:!1,rotation:0,},trim:0,},options.cubemapConfig);_this._stereoFormat=options.stereoFormat||STEREO_FORMAT.TOP_BOTTOM;_this._width=options.width||parseInt(window.getComputedStyle(container).width,10);_this._height=options.height||parseInt(window.getComputedStyle(container).height,10);_this._yaw=options.yaw||0;_this._pitch=options.pitch||0;_this._fov=options.fov||65;_this._gyroMode=options.gyroMode||GYRO_MODE.YAWPITCH;_this._quaternion=null;_this._aspectRatio=_this._height!==0?_this._width/_this._height:1;_this._canvasClass=options.canvasClass||DEFAULT_CANVAS_CLASS;var fovRange=options.fovRange||[30,110];var touchDirection=PanoViewer._isValidTouchDirection(options.touchDirection)?options.touchDirection:YawPitchControl.TOUC
689H_DIRECTION_ALL;var yawPitchConfig=__assign(__assign({},options),{element:container,yaw:_this._yaw,pitch:_this._pitch,fov:_this._fov,gyroMode:_this._gyroMode,fovRange:fovRange,aspectRatio:_this._aspectRatio,touchDirection:touchDirection,});_this._isReady=!1;_this._initYawPitchControl(yawPitchConfig);_this._initRenderer(_this._yaw,_this._pitch,_this._fov,_this._projectionType,_this._cubemapConfig);return _this} 690var __proto=PanoViewer.prototype;PanoViewer.isSupported=function(){return WebGLUtils.isWebGLAvailable()&&WebGLUtils.isStableWebGL()};PanoViewer.isWebGLAvailable=function(){return WebGLUtils.isWebGLAvailable()};PanoViewer.isGyroSensorAvailable=function(callback){if(!DeviceMotionEvent&&callback){callback(!1);return} 691var onDeviceMotionChange;var checkGyro=function(){return new Promise$1(function(res){onDeviceMotionChange=function(deviceMotion){var isGyroSensorAvailable=!(deviceMotion.rotationRate.alpha==null);res(isGyroSensorAvailable)};window.addEventListener("devicemotion",onDeviceMotionChange)})};var timeout=function(){return new Promise$1(function(res){setTimeout(function(){return res(!1)},1000)})};Promise$1.race([checkGyro(),timeout()]).then(function(isGyroSensorAvailable){window.removeEventListener("devicemotion",onDeviceMotionChange);if(callback){callback(isGyroSensorAvailable)} 692PanoViewer.isGyroSensorAvailable=function(fb){if(fb){fb(isGyroSensorAvailable)} 693return isGyroSensorAvailable}})};PanoViewer._isValidTouchDirection=function(direction){return direction===PanoViewer.TOUCH_DIRECTION.NONE||direction===PanoViewer.TOUCH_DIRECTION.YAW||direction===PanoViewer.TOUCH_DIRECTION.PITCH||direction===PanoViewer.TOUCH_DIRECTION.ALL};__proto.getVideo=function(){if(!this._isVideo){return null} 694return this._photoSphereRenderer.getContent()};__proto.setVideo=function(video,param){if(param===void 0){param={}} 695if(video){this.setImage(video,{projectionType:param.projectionType,isVideo:!0,cubemapConfig:param.cubemapConfig,stereoFormat:param.stereoFormat,})} 696return this};__proto.getImage=function(){if(this._isVideo){return null} 697return this._photoSphereRenderer.getContent()};__proto.setImage=function(image,param){if(param===void 0){param={}} 698var cubemapConfig=__assign({order:"RLUDBF",tileConfig:{flipHorizontal:!1,rotation:0,},trim:0,},param.cubemapConfig);var stereoFormat=param.stereoFormat||STEREO_FORMAT.TOP_BOTTOM;var isVideo=!!param.isVideo;if(this._image&&this._isVideo!==isVideo){console.warn("PanoViewer is not currently supporting content type changes. (Image <--> Video)");return this} 699if(image){this._deactivate();this._image=image;this._isVideo=isVideo;this._projectionType=param.projectionType||PROJECTION_TYPE.EQUIRECTANGULAR;this._cubemapConfig=cubemapConfig;this._stereoFormat=stereoFormat;this._initRenderer(this._yaw,this._pitch,this._fov,this._projectionType,this._cubemapConfig)}
699 700return this};__proto.keepUpdate=function(doUpdate){this._photoSphereRenderer.keepUpdate(doUpdate);return this};__proto.getProjectionType=function(){return this._projectionType};__proto.enableSensor=function(){return new Promise$1(function(resolve,reject){if(DeviceMotionEvent&&typeof DeviceMotionEvent.requestPermission==="function"){DeviceMotionEvent.requestPermission().then(function(permissionState){if(permissionState==="granted"){resolve()}else{reject(new Error("permission denied"))}}).catch(function(e){reject(e)})}else{resolve()}})};__proto.disableSensor=function(){return this};__proto.enterVR=function(options){var _this=this;if(options===void 0){options={}} 701if(!this._isReady){return Promise$1.reject(new Error("PanoViewer is not ready to show image."))} 702return new Promise$1(function(resolve,reject){_this.enableSensor().then(function(){return _this._photoSphereRenderer.enterVR(options)}).then(function(res){return resolve(res)}).catch(function(e){return reject(e)})})};__proto.exitVR=function(){this._photoSphereRenderer.exitVR();return this};__proto.setUseZoom=function(useZoom){if(typeof useZoom==="boolean"){this._yawPitchControl.option("useZoom",useZoom)} 703return this};__proto.setUseKeyboard=function(useKeyboard){this._yawPitchControl.option("useKeyboard",useKeyboard);return this};__proto.setGyroMode=function(gyroMode){this._yawPitchControl.option("gyroMode",gyroMode);return this};__proto.setFovRange=function(range){this._yawPitchControl.option("fovRange",range);return this};__proto.getFovRange=function(){return this._yawPitchControl.option("fovRange")};__proto.updateViewportDimensions=function(size){if(size===void 0){size={}} 704if(!this._isReady){return this} 705var containerSize;if(size.width===undefined||size.height===undefined){containerSize=window.getComputedStyle(this._container)} 706var width=size.width||parseInt(containerSize.width,10);var height=size.height||parseInt(containerSize.height,10);if(width===this._width&&height===this._height){return this} 707this._width=width;this._height=height;this._aspectRatio=width/height;this._photoSphereRenderer.updateViewportDimensions(width,height);this._yawPitchControl.option("aspectRatio",this._aspectRatio);this._yawPitchControl.updatePanScale({height:height,});this.lookAt({},0);return this};__proto.getFov=function(){return this._fov};__proto.getYaw=function(){return this._yaw};__proto.getPitch=function(){return this._pitch};__proto.getYawRange=function(){return this._yawPitchControl.option("yawRange")};__proto.getPitchRange=function(){return this._yawPitchControl.option("pitchRange")};__proto.setYawRange=function(yawRange){this._yawPitchControl.option("yawRange",yawRange);return this};__proto.setPitchRange=function(pitchRange){this._yawPitchControl.option("pitchRange",pitchRange);return this};__proto.setShowPolePoint=function(showPolePoint){this._yawPitchControl.option("showPolePoint",showPolePoint);return this};__proto.lookAt=function(orientation,duration){if(duration===void 0){duration=0} 708if(!this._isReady){return this}
709var yaw=orientation.yaw!==undefined?orientation.yaw:this._yaw;var pitch=orientation.pitch!==undefined?orientation.pitch:this._pitch;var pitchRange=this._yawPitchControl.option("pitchRange");var verticalAngleOfImage=pitchRange[1]-pitchRange[0];var fov=orientation.fov!==undefined?orientation.fov:this._fov;if(verticalAngleOfImage<fov){fov=verticalAngleOfImage} 710this._yawPitchControl.lookAt({yaw:yaw,pitch:pitch,fov:fov,},duration);if(duration===0){this._photoSphereRenderer.renderWithYawPitch(yaw,pitch,fov)} 711return this};__proto.setTouchDirection=function(direction){if(PanoViewer._isValidTouchDirection(direction)){this._yawPitchControl.option("touchDirection",direction)} 712return this};__proto.getTouchDirection=function(){return this._yawPitchControl.option("touchDirection")};__proto.destroy=function(){this._deactivate();if(this._yawPitchControl){this._yawPitchControl.destroy();this._yawPitchControl=null} 713return this};__proto._initRenderer=function(yaw,pitch,fov,projectionType,cubemapConfig){var _this=this;this._photoSphereRenderer=new PanoImageRenderer(this._image,this._width,this._height,this._isVideo,this._container,this._canvasClass,{initialYaw:yaw,initialPitch:pitch,fieldOfView:fov,imageType:projectionType,cubemapConfig:cubemapConfig,stereoFormat:this._stereoFormat,});this._photoSphereRenderer.setYawPitchControl(this._yawPitchControl);this._bindRendererHandler();this._photoSphereRenderer.bindTexture().then(function(){return _this._activate()}).catch(function(){_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.ERROR,{type:ERROR_TYPE.FAIL_BIND_TEXTURE,message:"failed to bind texture",}))})};__proto._updateYawPitchIfNeeded=function(){if(this._projectionType===PanoViewer.ProjectionType.PANORAMA){var image=this._photoSphereRenderer.getContent();var imageAspectRatio=image.naturalWidth/image.naturalHeight;var yawSize=void 0;var maxFov=void 0;if(imageAspectRatio<1){imageAspectRatio=1/imageAspectRatio} 714if(imageAspectRatio<6){yawSize=util.toDegree(imageAspectRatio);maxFov=util.toDegree(Math.atan(0.5))*2}else{yawSize=360;maxFov=360/imageAspectRatio} 715var minFov=this._yawPitchControl.option("fovRange")[0];this._yawPitchControl.option({fov:maxFov,yawRange:[-yawSize/2,yawSize/2],pitchRange:[-maxFov/2,maxFov/2],fovRange:[minFov,maxFov],});this.lookAt({fov:maxFov,})}};__proto._bindRendererHandler=function(){var _this=this;this._photoSphereRenderer.on(PanoImageRenderer.EVENTS.ERROR,function(e){_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.ERROR,e))});this._photoSphereRenderer.on(PanoImageRenderer.EVENTS.RENDERING_CONTEXT_LOST,function(){_this._deactivate();_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.ERROR,{type:ERROR_TYPE.RENDERING_CONTEXT_LOST,message:"webgl rendering context lost",}))})};__proto._initYawPitchControl=function(yawPitchConfig){var _this=this;this._yawPitchControl=new YawPitchControl(yawPitchConfig);this._yawPitchControl.on(PANOVIEWER_EVENTS.ANIMATION_END,function(e){_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.ANIMATION_END,e))});this._yawPitchControl.on("change",function(e){_this._yaw=e.yaw;_this._pitch=e.pitch;_this._fov=e.fov;_this._quaternion=e.quaternion;_this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.VIEW_CHANGE,{yaw:e.yaw,pitch:e.pitch,fov:e.fov,quaternion:e.quaternion,isTrusted:e.isTrusted,}))})};__proto._activate=function(){this._photoSphereRenderer.attachTo(this._container);this._yawPitchControl.enable();this.updateViewportDimensions();this._isReady=!0;this._updateYawPitchIfNeeded();this.trigger(new ComponentEvent$1(PANOVIEWER_EVENTS.READY));this._photoSphereRenderer.startRender()};__proto._deactivate=function(){var video=this.getVideo();if(video){video.pause()} 716if(this._isReady){this._photoSphereRenderer.stopRender();this._yawPitchControl.disable();this._isReady=!1} 717if(this._photoSphereRenderer){this._photoSphereRenderer.destroy();this._photoSphereRenderer=null}};PanoViewer.VERSION=VERSION;PanoViewer.ERROR_TYPE=ERROR_TYPE;PanoViewer.EVENTS=PANOVIEWER_EVENTS;PanoViewer.PROJECTION_TYPE=PROJECTION_TYPE;PanoViewer.GYRO_MODE=GYRO_MODE;PanoViewer.ProjectionType=PROJECTION_TYPE;PanoViewer.STEREO_FORMAT=STEREO_FORMAT;
717PanoViewer.TOUCH_DIRECTION={NONE:YawPitchControl.TOUCH_DIRECTION_NONE,YAW:YawPitchControl.TOUCH_DIRECTION_YAW,PITCH:YawPitchControl.TOUCH_DIRECTION_PITCH,ALL:YawPitchControl.TOUCH_DIRECTION_ALL,};return PanoViewer})(Component);var PanoViewer$1={__proto__:null,PanoViewer:PanoViewer,VERSION:VERSION,GYRO_MODE:GYRO_MODE,PANOVIEWER_EVENTS:PANOVIEWER_EVENTS,ERROR_TYPE:ERROR_TYPE,PROJECTION_TYPE:PROJECTION_TYPE,STEREO_FORMAT:STEREO_FORMAT,PANOVIEWER_OPTIONS:PANOVIEWER_OPTIONS,DEFAULT_CANVAS_CLASS:DEFAULT_CANVAS_CLASS,};var SPINVIEWER_OPTIONS={imageUrl:!0,rowCount:!0,colCount:!0,width:!0,height:!0,autoHeight:!0,colRow:!0,scale:!0,frameIndex:!0,wrapperClass:!0,imageClass:!0,};var SPINVIEWER_EVENTS={LOAD:"load",IMAGE_ERROR:"imageError",CHANGE:"change",ANIMATION_END:"animationEnd",};var DEFAULT_WRAPPER_CLASS="view360-wrapper";var DEFAULT_IMAGE_CLASS="view360-image";var SpriteImage=(function(_super){__extends(SpriteImage,_super);function SpriteImage(element,options){if(options===void 0){options={}} 718var _this=_super.call(this)||this;var opt=options||{};_this._el=element;_this._rowCount=opt.rowCount||1;_this._colCount=opt.colCount||1;_this._totalCount=_this._rowCount*_this._colCount;_this._width=opt.width||"auto";_this._height=opt.height||"auto";_this._autoHeight=opt.autoHeight!=null?opt.autoHeight:!0;_this._colRow=[0,0];if(opt.colRow){_this._colRow=opt.colRow}else if(opt.frameIndex){_this.setFrameIndex(opt.frameIndex)} 719_this._el.style.width=SpriteImage._getSizeString(_this._width);_this._el.style.height=SpriteImage._getSizeString(_this._height);var wrapperClass=opt.wrapperClass||DEFAULT_WRAPPER_CLASS;var imageClass=opt.imageClass||DEFAULT_IMAGE_CLASS;if(!opt.imageUrl){setTimeout(function(){_this.trigger(new ComponentEvent$1("imageError",{imageUrl:opt.imageUrl,}))},0);return _this} 720var imageInContainer=element.querySelector("."+imageClass);var wrapperInContainer=element.querySelector("."+wrapperClass);if(wrapperInContainer&&imageInContainer){imageInContainer.style.display="none"} 721_this._image=imageInContainer||new Image();var image=_this._image;image.onload=function(){if(wrapperInContainer&&imageInContainer){imageInContainer.style.display=""} 722_this._bg=SpriteImage._createBgDiv(wrapperInContainer,image,_this._rowCount,_this._colCount,_this._autoHeight);_this._el.appendChild(_this._bg);_this.setColRow(_this._colRow[0],_this._colRow[1]);_this.trigger(new ComponentEvent$1("load",{target:_this._el,bgElement:_this._bg,}));if(_this._autoPlayReservedInfo){_this.play(_this._autoPlayReservedInfo);_this._autoPlayReservedInfo=null}};image.onerror=function(){_this.trigger(new ComponentEvent$1("imageError",{imageUrl:opt.imageUrl,}))};image.src=opt.imageUrl;return _this} 723var __proto=SpriteImage.prototype;SpriteImage._createBgDiv=function(wrapperInContainer,img,rowCount,colCount,autoHeight){var el=wrapperInContainer||document.createElement("div");el.style.position="relative";el.style.overflow="hidden";img.style.position="absolute";img.style.width=colCount*100+"%";img.style.height=rowCount*100+"%";img.ondragstart=function(){return!1};if(SUPPORT_WILLCHANGE){img.style.willChange="transform"} 724el.appendChild(img);var unitWidth=img.naturalWidth/colCount;var unitHeight=img.naturalHeight/rowCount;if(autoHeight){var r=unitHeight/unitWidth;el.style.paddingBottom=r*100+"%"}else{el.style.height="100%"} 725return el};SpriteImage._getSizeString=function(size){if(typeof size==="number"){return size+"px"} 726return size};__proto.setFrameIndex=function(index){var colRow=this.toColRow(index);this.setColRow(colRow[0],colRow[1])};__proto.getFrameIndex=function(){return this._colRow[1]*this._colCount+this._colRow[0]};__proto.setColRow=function(col,row){if(row>this._rowCount-1||col>this._colCount-1){return} 727if(this._image&&TRANSFORM){this._image.style[TRANSFORM]="translate("+ -((col/this._colCount)*100)+"%, "+ -((row/this._rowCount)*100)+"%)"} 728this._colRow=[col,row]};__proto.getColRow=function(){return this._colRow};__proto.stop=function(){if(this._autoPlayTimer){clearInterval(this._autoPlayTimer);this._autoPlayTimer=-1}};__proto.play=function(_a){var _this=this;var _b=_a===void 0?{interval:1000/this._totalCount,playCount:0,}:_a,interval=_b.interval,playCount=_b.playCount;if(!this._bg){this._autoPlayReservedInfo={interval:interval,playCount:playCount,};return} 729if(this._autoPlayTimer){clearInterval(this._autoPlayTimer);this._autoPlayTimer=-1} 730var frameIndex=this.getFrameIndex();var count=0;var frameCount=0;this._autoPlayTimer=window.setInterval(function(){frameIndex%=_this._totalCount;var colRow=_this.toColRow(frameIndex);_this.setColRow(colRow[0],colRow[1]);frameIndex++;
730if(++frameCount===_this._totalCount){frameCount=0;count++} 731if(playCount>0&&count===playCount){clearInterval(_this._autoPlayTimer)}},interval)};__proto.toColRow=function(frameIndex){var colCount=this._colCount;var rowCount=this._rowCount;if(frameIndex<0){return[0,0]}else if(frameIndex>=this._totalCount){return[colCount-1,rowCount-1]} 732var col=frameIndex%colCount;var row=Math.floor(frameIndex/colCount);return[col,row]};SpriteImage.VERSION=VERSION;return SpriteImage})(Component);var DEFAULT_PAN_SCALE=0.21;var SpinViewer=(function(_super){__extends(SpinViewer,_super);function SpinViewer(element,options){if(options===void 0){options={}} 733var _this=_super.call(this)||this;_this._el=element;var opt=__assign({},options);var colCount=opt.colCount||1;var rowCount=opt.rowCount||1;_this._scale=opt.scale||1;_this._panScale=_this._scale*DEFAULT_PAN_SCALE;_this._frameCount=colCount*rowCount;_this._sprites=new SpriteImage(element,opt).on({load:function(evt){_this.trigger(new ComponentEvent$1("load",evt))},imageError:function(evt){_this.trigger(new ComponentEvent$1("imageError",{imageUrl:evt.imageUrl,}))},});_this._panInput=new PanInput(_this._el,{scale:[_this._panScale,_this._panScale],});_this._axes=new Axes({angle:{range:[0,359],circular:!0,},}).on({change:function(evt){var curr=Math.floor(evt.pos.angle/(360/_this._frameCount));var frameIndex=_this._frameCount-curr-1;_this._sprites.setFrameIndex(frameIndex);_this.trigger(new ComponentEvent$1("change",{frameIndex:frameIndex,colRow:_this._sprites.getColRow(),angle:evt.pos.angle,}))},animationEnd:function(evt){_this.trigger(new ComponentEvent$1("animationEnd",{isTrusted:evt.isTrusted,}))},});_this._axes.connect("angle",_this._panInput);return _this} 734var __proto=SpinViewer.prototype;__proto.setScale=function(scale){if(isNaN(scale)||scale<0){return this} 735this._scale=scale;this._panScale=scale*DEFAULT_PAN_SCALE;this._panInput.options.scale=[this._panScale,this._panScale];return this};__proto.getScale=function(){return this._scale};__proto.spinBy=function(angle,param){if(angle===void 0){angle=0} 736if(param===void 0){param={duration:0,}} 737this._axes.setBy({angle:angle,},param.duration);return this};__proto.spinTo=function(angle,param){if(angle===void 0){angle=0} 738if(param===void 0){param={duration:0,}} 739this._axes.setTo({angle:angle,},param.duration);return this};__proto.getAngle=function(){return this._axes.get().angle||0};SpinViewer.VERSION=VERSION;return SpinViewer})(Component);var SpinViewer$1={__proto__:null,SpinViewer:SpinViewer,SpriteImage:SpriteImage,VERSION:VERSION,SPINVIEWER_OPTIONS:SPINVIEWER_OPTIONS,SPINVIEWER_EVENTS:SPINVIEWER_EVENTS,DEFAULT_WRAPPER_CLASS:DEFAULT_WRAPPER_CLASS,DEFAULT_IMAGE_CLASS:DEFAULT_IMAGE_CLASS,};var withMethods=function(component,prototype,vanillaInstance){[Component.prototype,component.prototype].forEach(function(proto){Object.getOwnPropertyNames(proto).filter(function(name){return!prototype[name]&&!name.startsWith("_")&&name!=="constructor"}).forEach(function(name){var descriptor=Object.getOwnPropertyDescriptor(proto,name);if(descriptor.value){Object.defineProperty(prototype,name,{value:function(){var _a;var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i]} 740return(_a=descriptor.value).call.apply(_a,__spread([this[vanillaInstance]],args))},})}else{var getterDescriptor={};if(descriptor.get){getterDescriptor.get=function(){var _a;return(_a=descriptor.get)===null||_a===void 0?void 0:_a.call(this[vanillaInstance])}} 741if(descriptor.set){getterDescriptor.set=function(){var _a;var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i]} 742return(_a=descriptor.set)===null||_a===void 0?void 0:_a.call.apply(_a,__spread([this[vanillaInstance]],args))}} 743Object.defineProperty(prototype,name,getterDescriptor)}})})};var withPanoViewerMethods=function(prototype,name){withMethods(PanoViewer,prototype,name)};var withSpinViewerMethods=function(prototype,name){withMethods(SpinViewer,prototype,name)};var updatePanoViewer=function(panoViewer,newProps,prevProps){if(isPropChanged(newProps.image,prevProps.image)){panoViewer.setImage(newProps.image,{projectionType:newProps.projectionType,cubemapConfig:newProps.cubemapConfig,stereoFormat:newProps.stereoFormat,isVideo:!1,})}else if(isPropChanged(newProps.video,prevProps.video)){panoViewer.setVideo(newProps.video,{projectionType:newProps.projectionType,cubemapConfig:newProps.cubemapConfig,stereoFormat:newProps.stereoFormat,})} 744var singleUpdateOptions=["fovRange","gyroMode","pitchRange","showPolePoint","touchDirection","useKeyboard","useZoom","yawRange"];singleUpdateOptions.forEach(function(optionName){updateOption(panoViewer,optionName,newProps,prevProps)})};var isPropChanged=function(val,prevVal){return val!=null&&val!==prevVal};var updateOption=function(panoViewer,optionName,newProps,prevProps){if(isPropChanged(newProps[optionName],prevProps[optionName])){panoViewer["set"+optionName[0].toUpperCase()+optionName.slice(1)](newProps[optionName])}};var getValidProps=function(propsObj){return Object.keys(propsObj).reduce(function(props,propName){if(propsObj[propName]!=null){props[propName]=propsObj[propName]} 745return props},{})};var generateCanvasKey=function(oldKey){var newKey;do{var array=new Uint32Array(1);crypto.getRandomValues(array);newKey=array[0]}while(newKey===oldKey);return newKey};
745var CFC={__proto__:null,withMethods:withMethods,withPanoViewerMethods:withPanoViewerMethods,withSpinViewerMethods:withSpinViewerMethods,updatePanoViewer:updatePanoViewer,getValidProps:getValidProps,generateCanvasKey:generateCanvasKey,};var View360={};merge(View360,PanoViewer$1);merge(View360,SpinViewer$1);merge(View360,CFC);return View360})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.