UNPKG

@xeokit/xeokit-sdk

Version:

3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision

7 lines (6 loc) 2.51 MB
/** * xeokit-sdk v2.6.78 * Commit: 17c76751873b26ec38b03ae632f1d2003dc7a98a * Built: 2025-06-18T11:34:41.515Z */ var e,t,i,r=l().mark(HP),n=l().mark(jP),s=l().mark(CE);function o(e){var t="function"==typeof Map?new Map:void 0;return o=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return a(e,arguments,x(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_(r,e)},o(e)}function a(e,t,i){return a=B()?Reflect.construct.bind():function(e,t,i){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return i&&_(n,i.prototype),n},a.apply(null,arguments)}function l(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */l=function(){return e};var e={},t=Object.prototype,i=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function a(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,i){return e[t]=i}}function u(e,t,i,r){var n=t&&t.prototype instanceof h?t:h,s=Object.create(n.prototype),o=new x(r||[]);return s._invoke=function(e,t,i){var r="suspendedStart";return function(n,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===n)throw s;return M()}for(i.method=n,i.arg=s;;){var o=i.delegate;if(o){var a=b(o,i);if(a){if(a===A)continue;return a}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===r)throw r="completed",i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r="executing";var l=c(e,t,i);if("normal"===l.type){if(r=i.done?"completed":"suspendedYield",l.arg===A)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r="completed",i.method="throw",i.arg=l.arg)}}}(e,i,o),s}function c(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var A={};function h(){}function d(){}function p(){}var f={};a(f,n,(function(){return this}));var v=Object.getPrototypeOf,g=v&&v(v(C([])));g&&g!==t&&i.call(g,n)&&(f=g);var m=p.prototype=h.prototype=Object.create(f);function _(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function r(n,s,o,a){var l=c(e[n],e,s);if("throw"!==l.type){var u=l.arg,A=u.value;return A&&"object"==P(A)&&i.call(A,"__await")?t.resolve(A.__await).then((function(e){r("next",e,o,a)}),(function(e){r("throw",e,o,a)})):t.resolve(A).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,a)}))}a(l.arg)}var n;this._invoke=function(e,i){function s(){return new t((function(t,n){r(e,i,t,n)}))}return n=n?n.then(s,s):s()}}function b(e,t){var i=e.iterator[t.method];if(void 0===i){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return A;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return A}var r=c(i,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,A;var n=r.arg;return n?n.done?(t[e.resultName]=n.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,A):n:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,A)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function B(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function C(e){if(e){var t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,s=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return s.next=s}}return{next:M}}function M(){return{value:void 0,done:!0}}return d.prototype=p,a(m,"constructor",p),a(p,"constructor",d),d.displayName=a(p,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,a(e,o,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},_(y.prototype),a(y.prototype,s,(function(){return this})),e.AsyncIterator=y,e.async=function(t,i,r,n,s){void 0===s&&(s=Promise);var o=new y(u(t,i,r,n),s);return e.isGeneratorFunction(i)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},_(m),a(m,o,"Generator"),a(m,n,(function(){return this})),a(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var i in e)t.push(i);return t.reverse(),function i(){for(;t.length;){var r=t.pop();if(r in e)return i.value=r,i.done=!1,i}return i.done=!0,i}},e.values=C,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(B),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(i,r){return o.type="throw",o.arg=e,t.next=i,r&&(t.method="next",t.arg=void 0),!!r}for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var a=i.call(s,"catchLoc"),l=i.call(s,"finallyLoc");if(a&&l){if(this.prev<s.catchLoc)return r(s.catchLoc,!0);if(this.prev<s.finallyLoc)return r(s.finallyLoc)}else if(a){if(this.prev<s.catchLoc)return r(s.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return r(s.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var s=n;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=e,o.arg=t,s?(this.method="next",this.next=s.finallyLoc,A):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),A},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),B(i),A}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;B(i)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,i){return this.delegate={iterator:C(e),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=void 0),A}},e}function u(e,t,i,r,n,s,o){try{var a=e[s](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,n)}function c(e){return function(){var t=this,i=arguments;return new Promise((function(r,n){var s=e.apply(t,i);function o(e){u(s,r,n,o,a,"next",e)}function a(e){u(s,r,n,o,a,"throw",e)}o(void 0)}))}}function A(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function h(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?A(Object(i),!0).forEach((function(t){d(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):A(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function d(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function p(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=M(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,a=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return o=e.done,e},e:function(e){a=!0,s=e},f:function(){try{o||null==i.return||i.return()}finally{if(a)throw s}}}}function f(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||M(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var r=g(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},v.apply(this,arguments)}function g(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=x(e)););return e}function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_(e,t)}function _(e,t){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_(e,t)}function y(e){var t=B();return function(){var i,r=x(e);if(t){var n=x(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return b(this,i)}}function b(e,t){if(t&&("object"===P(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var r,n,s=[],o=!0,a=!1;try{for(i=i.call(e);!(o=(r=i.next()).done)&&(s.push(r.value),!t||s.length!==t);o=!0);}catch(e){a=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(a)throw n}}return s}(e,t)||M(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e,t){if(e){if("string"==typeof e)return k(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function E(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function I(e,t,i){return t&&F(e.prototype,t),i&&F(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e){return new R(e)}function D(e){return function(){return new S(e.apply(this,arguments))}}function S(e){var t,i;function r(t,i){try{var s=e[t](i),o=s.value,a=o instanceof R;Promise.resolve(a?o.wrapped:o).then((function(e){a?r("return"===t?"return":"next",e):n(s.done?"return":"normal",e)}),(function(e){r("throw",e)}))}catch(e){n("throw",e)}}function n(e,n){switch(e){case"return":t.resolve({value:n,done:!0});break;case"throw":t.reject(n);break;default:t.resolve({value:n,done:!1})}(t=t.next)?r(t.key,t.arg):i=null}this._invoke=function(e,n){return new Promise((function(s,o){var a={key:e,arg:n,resolve:s,reject:o,next:null};i?i=i.next=a:(t=i=a,r(e,n))}))},"function"!=typeof e.return&&(this.return=void 0)}function R(e){this.wrapped=e}function U(e){var t,i,r,n=2;for("undefined"!=typeof Symbol&&(i=Symbol.asyncIterator,r=Symbol.iterator);n--;){if(i&&null!=(t=e[i]))return t.call(e);if(r&&null!=(t=e[r]))return new L(t.call(e));i="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function L(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return L=function(e){this.s=e,this.n=e.next},L.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var i=this.s.return;return void 0===i?Promise.resolve({value:e,done:!0}):t(i.apply(this.s,arguments))},throw:function(e){var i=this.s.return;return void 0===i?Promise.reject(e):t(i.apply(this.s,arguments))}},new L(e)}S.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},S.prototype.next=function(e){return this._invoke("next",e)},S.prototype.throw=function(e){return this._invoke("throw",e)},S.prototype.return=function(e){return this._invoke("return",e)};var O,N,V,Q,H,j,G,z,W,X,K,Z=function(){function e(t,i){E(this,e),this.items=t||[],this._lastUniqueId=(i||0)+1}return I(e,[{key:"addItem",value:function(){var e;if(2===arguments.length){var t=arguments[0];if(e=arguments[1],this.items[t])throw"ID clash: '"+t+"'";return this.items[t]=e,t}for(e=arguments[0]||{};;){var i=this._lastUniqueId++;if(!this.items[i])return this.items[i]=e,i}}},{key:"removeItem",value:function(e){var t=this.items[e];return delete this.items[e],t}}]),e}(),J=new Z,Y=I((function e(t){E(this,e),this.id=t,this.parentItem=null,this.groups=[],this.menuElement=null,this.shown=!1,this.mouseOver=0})),q=I((function e(){E(this,e),this.items=[]})),$=I((function e(t,i,r,n,s){E(this,e),this.id=t,this.getTitle=i,this.doAction=r,this.getEnabled=n,this.getShown=s,this.itemElement=null,this.subMenu=null,this.enabled=!0})),ee=function(){function e(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,e),this._id=J.addItem(),this._context=null,this._enabled=!1,this._itemsCfg=[],this._rootMenu=null,this._menuList=[],this._menuMap={},this._itemList=[],this._itemMap={},this._shown=!1,this._nextId=0,this._parentNode=i.parentNode||document.body,this._offsetParent=this._parentNode instanceof ShadowRoot?this._parentNode.host:this._parentNode,this._eventSubs={},!1!==i.hideOnMouseDown&&(this._parentNode.addEventListener("mousedown",(function(e){e.target.classList.contains("xeokit-context-menu-item")||t.hide()})),this._parentNode.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){e.target.classList.contains("xeokit-context-menu-item")||t.hide()})),i.items&&(this.items=i.items),this._hideOnAction=!1!==i.hideOnAction,this.context=i.context,this.enabled=!1!==i.enabled,this.hide()}return I(e,[{key:"on",value:function(e,t){var i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}},{key:"fire",value:function(e,t){var i=this._eventSubs[e];if(i)for(var r=0,n=i.length;r<n;r++)i[r](t)}},{key:"items",get:function(){return this._itemsCfg},set:function(e){this._clear(),this._itemsCfg=e||[],this._parseItems(e),this._createUI()}},{key:"enabled",get:function(){return this._enabled},set:function(e){(e=!!e)!==this._enabled&&(this._enabled=e,this._enabled||this.hide())}},{key:"context",get:function(){return this._context},set:function(e){this._context=e}},{key:"show",value:function(e,t){this._context?this._enabled&&(this._shown||(this._hideAllMenus(),this._updateItemsTitles(),this._updateItemsEnabledStatus(),this._showMenu(this._rootMenu.id,e,t),this._updateSubMenuInfo(),this._shown=!0,this.fire("shown",{}))):console.error("ContextMenu cannot be shown without a context - set context first")}},{key:"shown",get:function(){return this._shown}},{key:"hide",value:function(){this._enabled&&this._shown&&(this._hideAllMenus(),this._shown=!1,this.fire("hidden",{}))}},{key:"destroy",value:function(){this._context=null,this._clear(),null!==this._id&&(J.removeItem(this._id),this._id=null)}},{key:"_clear",value:function(){for(var e=0,t=this._menuList.length;e<t;e++){this._menuList[e].menuElement.remove()}this._itemsCfg=[],this._rootMenu=null,this._menuList=[],this._menuMap={},this._itemList=[],this._itemMap={}}},{key:"_parseItems",value:function(e){var t=this;this._rootMenu=function e(i){for(var r=t._getNextId(),n=new Y(r),s=0,o=i.length;s<o;s++){var a=i[s],l=new q;n.groups.push(l);for(var u=function(i,r){var s=a[i],o=s.items,u=o&&o.length>0,c=t._getNextId(),A=s.getTitle||function(){return s.title||""},h=s.doAction||s.callback||function(){},d=s.getEnabled||function(){return!0},p=s.getShown||function(){return!0},f=new $(c,A,h,d,p);if(f.parentMenu=n,l.items.push(f),u){var v=e(o);f.subMenu=v,v.parentItem=f}t._itemList.push(f),t._itemMap[f.id]=f},c=0,A=a.length;c<A;c++)u(c)}return t._menuList.push(n),t._menuMap[n.id]=n,n}(e)}},{key:"_getNextId",value:function(){return"ContextMenu_"+this._id+"_"+this._nextId++}},{key:"_createUI",value:function(){var e=this;!function t(i){e._createMenuUI(i);for(var r=i.groups,n=0,s=r.length;n<s;n++)for(var o=r[n].items,a=0,l=o.length;a<l;a++){var u=o[a].subMenu;u&&t(u)}}(this._rootMenu)}},{key:"_createMenuUI",value:function(e){var t=this,i=e.groups,r=[],n=document.createElement("div");if(n.classList.add("xeokit-context-menu",e.id),n.style.zIndex=3e5,n.style.position="absolute",r.push("<ul>"),i)for(var s=0,o=i.length;s<o;s++){var a=s,l=o,u=i[s].items;if(u)for(var c=0,A=u.length;c<A;c++){var h=u[c],d=h.subMenu,p=h.title||"";d?(r.push('<li id="'+h.id+'" class="xeokit-context-menu-item xeokit-context-menu-submenu">'+p+"</li>"),a===l-1||c<A-1||r.push('<li id="'+h.id+'" class="xeokit-context-menu-item-separator"></li>')):(r.push('<li id="'+h.id+'" class="xeokit-context-menu-item">'+p+"</li>"),a===l-1||c<A-1||r.push('<li id="'+h.id+'" class="xeokit-context-menu-item-separator"></li>'))}}r.push("</ul>");var f=r.join("");n.innerHTML=f,this._parentNode.appendChild(n),e.menuElement=n,n.style["border-radius"]="4px",n.style.display="none",n.style["z-index"]=3e5,n.style.background="white",n.style.border="1px solid black",n.style["box-shadow"]="0 4px 5px 0 gray",n.oncontextmenu=function(e){e.preventDefault()};var v=this,g=null;if(i)for(var m=0,_=i.length;m<_;m++){var y=i[m].items;if(y)for(var b=function(e,i){var r=y[e],n=r.subMenu;if(r.itemElement=t._parentNode.querySelector("#".concat(r.id)),!r.itemElement)return console.error("ContextMenu item element not found: "+r.id),"continue";r.itemElement.addEventListener("mouseenter",(function(e){e.preventDefault();var t=r.subMenu;if(t){if(g&&g.id!==t.id&&(v._hideMenu(g.id),g=null),!1!==r.enabled){var i=r.itemElement,n=t.menuElement,s=i.getBoundingClientRect();n.getBoundingClientRect();var o=v._offsetParent.getBoundingClientRect(),a=200,l=s.right+a<o.right,u=s.left-a>o.left;if(l)v._showMenu(t.id,s.right+window.scrollX-5,s.top+window.scrollY-1);else if(u)v._showMenu(t.id,s.left-a+window.scrollX,s.top+window.scrollY-1);else{var c=s.left-o.left,A=o.right-s.right;A>c?v._showMenu(t.id,s.right-5-(a-A),s.top+window.scrollY-1):v._showMenu(t.id,s.left-c,s.top+window.scrollY-1)}g=t}}else g&&(v._hideMenu(g.id),g=null)})),n||(r.itemElement.addEventListener("click",(function(e){e.preventDefault(),v._context&&!1!==r.enabled&&(r.doAction&&r.doAction(v._context),t._hideOnAction?v.hide():(v._updateItemsTitles(),v._updateItemsEnabledStatus()))})),r.itemElement.addEventListener("mouseup",(function(e){3===e.which&&(e.preventDefault(),v._context&&!1!==r.enabled&&(r.doAction&&r.doAction(v._context),t._hideOnAction?v.hide():(v._updateItemsTitles(),v._updateItemsEnabledStatus())))})),r.itemElement.addEventListener("mouseenter",(function(e){e.preventDefault(),!1!==r.enabled&&r.doHover&&r.doHover(v._context)})))},w=0,B=y.length;w<B;w++)b(w)}}},{key:"_updateItemsTitles",value:function(){if(this._context)for(var e=0,t=this._itemList.length;e<t;e++){var i=this._itemList[e],r=i.itemElement;if(r){var n=i.getShown;if(n&&n(this._context)){var s=i.getTitle(this._context);i.subMenu,r.innerText=s}}}}},{key:"_updateItemsEnabledStatus",value:function(){if(this._context)for(var e=0,t=this._itemList.length;e<t;e++){var i=this._itemList[e],r=i.itemElement;if(r){var n=i.getEnabled;if(n){var s=i.getShown;if(s){var o=s(this._context);if(i.shown=o,o){r.style.display="";var a=n(this._context);i.enabled=a,a?r.classList.remove("disabled"):r.classList.add("disabled")}else r.style.display="none"}}}}}},{key:"_updateSubMenuInfo",value:function(){var e,t,i,r,n,s;this._context&&this._itemList.forEach((function(o){o.subMenu&&(e=o.itemElement,t=e.getBoundingClientRect(),i=o.subMenu.menuElement,r={visibility:i.style.visibility,display:i.style.display},i.style.display="block",i.style.visibility="hidden",s=o.subMenu.menuElement.getBoundingClientRect().width,i.style.visibility=r.visibility,i.style.display=r.display,n=t.right+s>window.innerWidth,e.setAttribute("data-submenuposition",n?"left":"right"))}))}},{key:"_showMenu",value:function(e,t,i){var r=this._menuMap[e];if(r){if(!r.shown){var n=r.menuElement;n&&(this._showMenuElement(n,t,i),r.shown=!0)}}else console.error("Menu not found: "+e)}},{key:"_hideMenu",value:function(e){var t=this._menuMap[e];if(t){if(t.shown){var i=t.menuElement;i&&(this._hideMenuElement(i),t.shown=!1)}}else console.error("Menu not found: "+e)}},{key:"_hideAllMenus",value:function(){for(var e=0,t=this._menuList.length;e<t;e++){var i=this._menuList[e];this._hideMenu(i.id)}}},{key:"_showMenuElement",value:function(e,t,i){e.style.display="block";var r=e.offsetHeight,n=e.offsetWidth,s=this._offsetParent.getBoundingClientRect(),o=s.bottom+window.scrollY,a=s.right+window.scrollX;i+r>o&&(i=o-r),t+n>a&&(t=a-n),e.style.left=t-s.left-window.scrollX+"px",e.style.top=i-s.top-window.scrollY+"px"}},{key:"_hideMenuElement",value:function(e){e.style.display="none"}}]),e}(),te=function(){function e(t){var i=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};E(this,e),this.viewer=t,this.scene=this.viewer.scene,this._lensCursorDiv=document.createElement("div"),this._lensParams={canvasSize:300,cursorBorder:2,cursorSize:10},this._lensCursorDiv.style.borderRadius="50%",this._lensCursorDiv.style.width=this._lensParams.cursorSize+"px",this._lensCursorDiv.style.height=this._lensParams.cursorSize+"px",this._lensCursorDiv.style.zIndex="100000",this._lensCursorDiv.style.position="absolute",this._lensCursorDiv.style.pointerEvents="none",this._lensContainer=document.createElement("div"),this._lensContainerId=r.containerId||"xeokit-lens",this._lensContainer.setAttribute("id",this._lensContainerId),this._lensContainer.style.border="1px solid black",this._lensContainer.style.background="white",this._lensContainer.style.borderRadius="50%",this._lensContainer.style.width=this._lensParams.canvasSize+"px",this._lensContainer.style.height=this._lensParams.canvasSize+"px",this._lensContainer.style.zIndex="15000",this._lensContainer.style.position="absolute",this._lensContainer.style.pointerEvents="none",this._lensContainer.style.visibility="hidden",this._lensCanvas=document.createElement("canvas"),this._lensCanvas.id="".concat(this._lensContainerId,"-canvas"),this._lensCanvas.style.borderRadius="50%",this._lensCanvas.style.width=this._lensParams.canvasSize+"px",this._lensCanvas.style.height=this._lensParams.canvasSize+"px",this._lensCanvas.style.zIndex="15000",this._lensCanvas.style.pointerEvents="none",document.body.appendChild(this._lensContainer),this._lensContainer.appendChild(this._lensCanvas),this._lensContainer.appendChild(this._lensCursorDiv),this._lensCanvasContext=this._lensCanvas.getContext("2d"),this._canvasElement=this.viewer.scene.canvas.canvas,this._canvasPos=null,this._snappedCanvasPos=null,this._lensPosToggle=r.lensPosToggle||!0,this._lensPosToggleAmount=r.lensPosToggleAmount||85,this._lensPosMarginLeft=r.lensPosMarginLeft||85,this._lensPosMarginTop=r.lensPosMarginTop||25,this._lensContainer.style.marginTop="".concat(this._lensPosMarginTop,"px"),this._lensContainer.style.marginLeft="".concat(this._lensPosMarginLeft,"px"),this._zoomLevel=r.zoomLevel||2,this._active=!1!==r.active,this._visible=!1,this.snapped=!1,this._onViewerRendering=this.viewer.scene.on("rendering",(function(){i._active&&i._visible&&i.update()}))}return I(e,[{key:"update",value:function(){if(this._active&&this._visible&&this._canvasPos){var e=this._lensContainer.getBoundingClientRect(),t=this._canvasElement.getBoundingClientRect(),i=this._canvasPos[0]<e.right&&this._canvasPos[0]>e.left&&this._canvasPos[1]<e.bottom&&this._canvasPos[1]>e.top;this._lensContainer.style.marginLeft="".concat(this._lensPosMarginLeft,"px"),i&&(this._lensPosToggle?this._lensContainer.style.marginTop="".concat(t.bottom-t.top-this._lensCanvas.height-this._lensPosToggleAmount,"px"):this._lensContainer.style.marginTop="".concat(this._lensPosMarginTop,"px"),this._lensPosToggle=!this._lensPosToggle),this._lensCanvasContext.clearRect(0,0,this._lensCanvas.width,this._lensCanvas.height);var r=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,this._canvasPos[0]-r/2,this._canvasPos[1]-r/2,r,r,0,0,this._lensCanvas.width,this._lensCanvas.height);var n=this._lensParams.canvasSize/2-this._lensParams.cursorSize/2-this._lensParams.cursorBorder,s=this._snappedCanvasPos?this._snappedCanvasPos[0]-this._canvasPos[0]:0,o=this._snappedCanvasPos?this._snappedCanvasPos[1]-this._canvasPos[1]:0;this._lensCursorDiv.style.left="".concat(n+s*this._zoomLevel,"px"),this._lensCursorDiv.style.top="".concat(n+o*this._zoomLevel,"px")}}},{key:"zoomFactor",get:function(){return this._zoomFactor},set:function(e){this._zoomFactor=e,this.update()}},{key:"canvasPos",get:function(){return this._canvasPos},set:function(e){this._canvasPos=e,this.update()}},{key:"snappedCanvasPos",get:function(){return this._snappedCanvasPos},set:function(e){this._snappedCanvasPos=e,this.update()}},{key:"snapped",get:function(){return this._snapped},set:function(e){this._snapped=e;var t=C(e?["greenyellow","green"]:["pink","red"],2),i=t[0],r=t[1];this._lensCursorDiv.style.background=i,this._lensCursorDiv.style.border=this._lensParams.cursorBorder+"px solid "+r}},{key:"_updateActiveVisible",value:function(){this._lensContainer.style.visibility=this._active&&this._visible?"visible":"hidden",this.update()}},{key:"active",get:function(){return this._active},set:function(e){this._active=e,this._updateActiveVisible()}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible=e,this._updateActiveVisible()}},{key:"destroy",value:function(){this._destroyed||(this.viewer.scene.off(this._onViewerRendering),this._lensContainer.removeChild(this._lensCanvas),document.body.removeChild(this._lensContainer),this._destroyed=!0)}}]),e}(),ie=!0,re=ie?Float64Array:Float32Array,ne=new re(3),se=new re(16),oe=new re(16),ae=new re(4),le={setDoublePrecisionEnabled:function(e){re=(ie=e)?Float64Array:Float32Array},getDoublePrecisionEnabled:function(){return ie},MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:1e7,DEGTORAD:.0174532925,RADTODEG:57.295779513,unglobalizeObjectId:function(e,t){var i=t.indexOf("#");return i===e.length&&t.startsWith(e)?t.substring(i+1):t},globalizeObjectId:function(e,t){return e+"#"+t},safeInv:function(e){var t=1/e;return isNaN(t)||!isFinite(t)?1:t},vec2:function(e){return new re(e||2)},vec3:function(e){return new re(e||3)},vec4:function(e){return new re(e||4)},mat3:function(e){return new re(e||9)},mat3ToMat4:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new re(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=0,t[4]=e[3],t[5]=e[4],t[6]=e[5],t[7]=0,t[8]=e[6],t[9]=e[7],t[10]=e[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},mat4:function(e){return new re(e||16)},mat4ToMat3:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new re(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},doublesToFloats:function(e,t,i){for(var r=new re(2),n=0,s=e.length;n<s;n++)le.splitDouble(e[n],r),t[n]=r[0],i[n]=r[1]},splitDouble:function(e,t){var i=re.from([e])[0],r=e-i;t[0]=i,t[1]=r},createUUID:function(){for(var e=[],t=0;t<256;t++)e[t]=(t<16?"0":"")+t.toString(16);return function(){var t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return"".concat(e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255],"-").concat(e[255&i]).concat(e[i>>8&255],"-").concat(e[i>>16&15|64]).concat(e[i>>24&255],"-").concat(e[63&r|128]).concat(e[r>>8&255],"-").concat(e[r>>16&255]).concat(e[r>>24&255]).concat(e[255&n]).concat(e[n>>8&255]).concat(e[n>>16&255]).concat(e[n>>24&255])}}(),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},fmod:function(e,t){if(e<t)return console.error("math.fmod : Attempting to find modulus within negative range - would be infinite loop - ignoring"),e;for(;t<=e;)e-=t;return e},compareVec3:function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},compareVec4:function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},negateVec3:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},negateVec4:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},addVec4:function(e,t,i){return i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i},addVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i},addVec3:function(e,t,i){return i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i},addVec3Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i},subVec4:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i},subVec3:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i},subVec2:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i},geometricMeanVec2:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(var r=new re(t[0]),n=1;n<t.length;n++)r[0]+=t[n][0],r[1]+=t[n][1];return r[0]/=t.length,r[1]/=t.length,r},subVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i},subScalarVec4:function(e,t,i){return i||(i=e),i[0]=t-e[0],i[1]=t-e[1],i[2]=t-e[2],i[3]=t-e[3],i},mulVec4:function(e,t,i){return i||(i=e),i[0]=e[0]*t[0],i[1]=e[1]*t[1],i[2]=e[2]*t[2],i[3]=e[3]*t[3],i},mulVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i},mulVec3Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i},mulVec2Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i},divVec3:function(e,t,i){return i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i},divVec4:function(e,t,i){return i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i[3]=e[3]/t[3],i},divScalarVec3:function(e,t,i){return i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i},divVec3Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i},divVec4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i[3]=e[3]/t,i},divScalarVec4:function(e,t,i){return i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i[3]=e/t[3],i},dotVec4:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},cross3Vec4:function(e,t){var i=e[0],r=e[1],n=e[2],s=t[0],o=t[1],a=t[2];return[r*a-n*o,n*s-i*a,i*o-r*s,0]},cross3Vec3:function(e,t,i){i||(i=e);var r=e[0],n=e[1],s=e[2],o=t[0],a=t[1],l=t[2];return i[0]=n*l-s*a,i[1]=s*o-r*l,i[2]=r*a-n*o,i},sqLenVec4:function(e){return le.dotVec4(e,e)},lenVec4:function(e){return Math.sqrt(le.sqLenVec4(e))},dotVec3:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},dotVec2:function(e,t){return e[0]*t[0]+e[1]*t[1]},sqLenVec3:function(e){return le.dotVec3(e,e)},sqLenVec2:function(e){return le.dotVec2(e,e)},lenVec3:function(e){return Math.sqrt(le.sqLenVec3(e))},distVec3:(K=new re(3),function(e,t){return le.lenVec3(le.subVec3(e,t,K))}),lenVec2:function(e){return Math.sqrt(le.sqLenVec2(e))},distVec2:function(){var e=new re(2);return function(t,i){return le.lenVec2(le.subVec2(t,i,e))}}(),rcpVec3:function(e,t){return le.divScalarVec3(1,e,t)},normalizeVec4:function(e,t){var i=1/le.lenVec4(e);return le.mulVec4Scalar(e,i,t)},normalizeVec3:function(e,t){var i=1/le.lenVec3(e);return le.mulVec3Scalar(e,i,t)},normalizeVec2:function(e,t){var i=1/le.lenVec2(e);return le.mulVec2Scalar(e,i,t)},angleVec3:function(e,t){var i=le.dotVec3(e,t)/Math.sqrt(le.sqLenVec3(e)*le.sqLenVec3(t));return i=i<-1?-1:i>1?1:i,Math.acos(i)},vec3FromMat4Scale:function(){var e=new re(3);return function(t,i){return e[0]=t[0],e[1]=t[1],e[2]=t[2],i[0]=le.lenVec3(e),e[0]=t[4],e[1]=t[5],e[2]=t[6],i[1]=le.lenVec3(e),e[0]=t[8],e[1]=t[9],e[2]=t[10],i[2]=le.lenVec3(e),i}}(),vecToArray:function(){function e(e){return Math.round(1e5*e)/1e5}return function(t){for(var i=0,r=(t=Array.prototype.slice.call(t)).length;i<r;i++)t[i]=e(t[i]);return t}}(),xyzArrayToObject:function(e){return{x:e[0],y:e[1],z:e[2]}},xyzObjectToArray:function(e,t){return(t=t||le.vec3())[0]=e.x,t[1]=e.y,t[2]=e.z,t},dupMat4:function(e){return e.slice(0,16)},mat4To3:function(e){return[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]]},m4s:function(e){return[e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e]},setMat4ToZeroes:function(){return le.m4s(0)},setMat4ToOnes:function(){return le.m4s(1)},diagonalMat4v:function(e){return new re([e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,e[3]])},diagonalMat4c:function(e,t,i,r){return le.diagonalMat4v([e,t,i,r])},diagonalMat4s:function(e){return le.diagonalMat4c(e,e,e,e)},identityMat4:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new re(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},identityMat3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new re(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},isIdentityMat4:function(e){return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]},negateMat4:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=-e[7],t[8]=-e[8],t[9]=-e[9],t[10]=-e[10],t[11]=-e[11],t[12]=-e[12],t[13]=-e[13],t[14]=-e[14],t[15]=-e[15],t},addMat4:function(e,t,i){return i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i[4]=e[4]+t[4],i[5]=e[5]+t[5],i[6]=e[6]+t[6],i[7]=e[7]+t[7],i[8]=e[8]+t[8],i[9]=e[9]+t[9],i[10]=e[10]+t[10],i[11]=e[11]+t[11],i[12]=e[12]+t[12],i[13]=e[13]+t[13],i[14]=e[14]+t[14],i[15]=e[15]+t[15],i},addMat4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i[4]=e[4]+t,i[5]=e[5]+t,i[6]=e[6]+t,i[7]=e[7]+t,i[8]=e[8]+t,i[9]=e[9]+t,i[10]=e[10]+t,i[11]=e[11]+t,i[12]=e[12]+t,i[13]=e[13]+t,i[14]=e[14]+t,i[15]=e[15]+t,i},addScalarMat4:function(e,t,i){return le.addMat4Scalar(t,e,i)},subMat4:function(e,t,i){return i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i[4]=e[4]-t[4],i[5]=e[5]-t[5],i[6]=e[6]-t[6],i[7]=e[7]-t[7],i[8]=e[8]-t[8],i[9]=e[9]-t[9],i[10]=e[10]-t[10],i[11]=e[11]-t[11],i[12]=e[12]-t[12],i[13]=e[13]-t[13],i[14]=e[14]-t[14],i[15]=e[15]-t[15],i},subMat4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i[4]=e[4]-t,i[5]=e[5]-t,i[6]=e[6]-t,i[7]=e[7]-t,i[8]=e[8]-t,i[9]=e[9]-t,i[10]=e[10]-t,i[11]=e[11]-t,i[12]=e[12]-t,i[13]=e[13]-t,i[14]=e[14]-t,i[15]=e[15]-t,i},subScalarMat4:function(e,t,i){return i||(i=t),i[0]=e-t[0],i[1]=e-t[1],i[2]=e-t[2],i[3]=e-t[3],i[4]=e-t[4],i[5]=e-t[5],i[6]=e-t[6],i[7]=e-t[7],i[8]=e-t[8],i[9]=e-t[9],i[10]=e-t[10],i[11]=e-t[11],i[12]=e-t[12],i[13]=e-t[13],i[14]=e-t[14],i[15]=e-t[15],i},mulMat4:function(e,t,i){i||(i=e);var r=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],u=e[6],c=e[7],A=e[8],h=e[9],d=e[10],p=e[11],f=e[12],v=e[13],g=e[14],m=e[15],_=t[0],y=t[1],b=t[2],w=t[3],B=t[4],x=t[5],P=t[6],C=t[7],M=t[8],k=t[9],E=t[10],F=t[11],I=t[12],T=t[13],D=t[14],S=t[15];return i[0]=_*r+y*a+b*A+w*f,i[1]=_*n+y*l+b*h+w*v,i[2]=_*s+y*u+b*d+w*g,i[3]=_*o+y*c+b*p+w*m,i[4]=B*r+x*a+P*A+C*f,i[5]=B*n+x*l+P*h+C*v,i[6]=B*s+x*u+P*d+C*g,i[7]=B*o+x*c+P*p+C*m,i[8]=M*r+k*a+E*A+F*f,i[9]=M*n+k*l+E*h+F*v,i[10]=M*s+k*u+E*d+F*g,i[11]=M*o+k*c+E*p+F*m,i[12]=I*r+T*a+D*A+S*f,i[13]=I*n+T*l+D*h+S*v,i[14]=I*s+T*u+D*d+S*g,i[15]=I*o+T*c+D*p+S*m,i},mulMat3:function(e,t,i){i||(i=new re(9));var r=e[0],n=e[3],s=e[6],o=e[1],a=e[4],l=e[7],u=e[2],c=e[5],A=e[8],h=t[0],d=t[3],p=t[6],f=t[1],v=t[4],g=t[7],m=t[2],_=t[5],y=t[8];return i[0]=r*h+n*f+s*m,i[3]=r*d+n*v+s*_,i[6]=r*p+n*g+s*y,i[1]=o*h+a*f+l*m,i[4]=o*d+a*v+l*_,i[7]=o*p+a*g+l*y,i[2]=u*h+c*f+A*m,i[5]=u*d+c*v+A*_,i[8]=u*p+c*g+A*y,i},mulMat4Scalar:function(e,t,i){return i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i[4]=e[4]*t,i[5]=e[5]*t,i[6]=e[6]*t,i[7]=e[7]*t,i[8]=e[8]*t,i[9]=e[9]*t,i[10]=e[10]*t,i[11]=e[11]*t,i[12]=e[12]*t,i[13]=e[13]*t,i[14]=e[14]*t,i[15]=e[15]*t,i},mulMat4v4:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:le.vec4(),r=t[0],n=t[1],s=t[2],o=t[3];return i[0]=e[0]*r+e[4]*n+e[8]*s+e[12]*o,i[1]=e[1]*r+e[5]*n+e[9]*s+e[13]*o,i[2]=e[2]*r+e[6]*n+e[10]*s+e[14]*o,i[3]=e[3]*r+e[7]*n+e[11]*s+e[15]*o,i},transposeMat4:function(e,t){var i=e[4],r=e[14],n=e[8],s=e[13],o=e[12],a=e[9];if(!t||e===t){var l=e[1],u=e[2],c=e[3],A=e[6],h=e[7],d=e[11];return e[1]=i,e[2]=n,e[3]=o,e[4]=l,e[6]=a,e[7]=s,e[8]=u,e[9]=A,e[11]=r,e[12]=c,e[13]=h,e[14]=d,e}return t[0]=e[0],t[1]=i,t[2]=n,t[3]=o,t[4]=e[1],t[5]=e[5],t[6]=a,t[7]=s,t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=r,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3:function(e,t){if(t===e){var i=e[1],r=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=r,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},determinantMat4:function(e){var t=e[0],i=e[1],r=e[2],n=e[3],s=e[4],o=e[5],a=e[6],l=e[7],u=e[8],c=e[9],A=e[10],h=e[11],d=e[12],p=e[13],f=e[14],v=e[15];return d*c*a*n-u*p*a*n-d*o*A*n+s*p*A*n+u*o*f*n-s*c*f*n-d*c*r*l+u*p*r*l+d*i*A*l-t*p*A*l-u*i*f*l+t*c*f*l+d*o*r*h-s*p*r*h-d*i*a*h+t*p*a*h+s*i*f*h-t*o*f*h-u*o*r*v+s*c*r*v+u*i*a*v-t*c*a*v-s*i*A*v+t*o*A*v},inverseMat4:function(e,t){t||(t=e);var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8],A=e[9],h=e[10],d=e[11],p=e[12],f=e[13],v=e[14],g=e[15],m=i*a-r*o,_=i*l-n*o,y=i*u-s*o,b=r*l-n*a,w=r*u-s*a,B=n*u-s*l,x=c*f-A*p,P=c*v-h*p,C=c*g-d*p,M=A*v-h*f,k=A*g-d*f,E=h*g-d*v,F=1/(m*E-_*k+y*M+b*C-w*P+B*x);return t[0]=(a*E-l*k+u*M)*F,t[1]=(-r*E+n*k-s*M)*F,t[2]=(f*B-v*w+g*b)*F,t[3]=(-A*B+h*w-d*b)*F,t[4]=(-o*E+l*C-u*P)*F,t[5]=(i*E-n*C+s*P)*F,t[6]=(-p*B+v*y-g*_)*F,t[7]=(c*B-h*y+d*_)*F,t[8]=(o*k-a*C+u*x)*F,t[9]=(-i*k+r*C-s*x)*F,t[10]=(p*w-f*y+g*m)*F,t[11]=(-c*w+A*y-d*m)*F,t[12]=(-o*M+a*P-l*x)*F,t[13]=(i*M-r*P+n*x)*F,t[14]=(-p*b+f*_-v*m)*F,t[15]=(c*b-A*_+h*m)*F,t},traceMat4:function(e){return e[0]+e[5]+e[10]+e[15]},translationMat4v:function(e,t){var i=t||le.identityMat4();return i[12]=e[0],i[13]=e[1],i[14]=e[2],i},translationMat3v:function(e,t){var i=t||le.identityMat3();return i[6]=e[0],i[7]=e[1],i},translationMat4c:(X=new re(3),function(e,t,i,r){return X[0]=e,X[1]=t,X[2]=i,le.translationMat4v(X,r)}),translationMat4s:function(e,t){return le.translationMat4c(e,e,e,t)},translateMat4v:function(e,t){return le.translateMat4c(e[0],e[1],e[2],t)},translateMat4c:function(e,t,i,r){var n=r[3];r[0]+=n*e,r[1]+=n*t,r[2]+=n*i;var s=r[7];r[4]+=s*e,r[5]+=s*t,r[6]+=s*i;var o=r[11];r[8]+=o*e,r[9]+=o*t,r[10]+=o*i;var a=r[15];return r[12]+=a*e,r[13]+=a*t,r[14]+=a*i,r},setMat4Translation:function(e,t,i){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=e[15],i},rotationMat4v:function(e,t,i){var r,n,s,o,a,l,u=le.normalizeVec4([t[0],t[1],t[2],0],[]),c=Math.sin(e),A=Math.cos(e),h=1-A,d=u[0],p=u[1],f=u[2];return r=d*p,n=p*f,s=f*d,o=d*c,a=p*c,l=f*c,(i=i||le.mat4())[0]=h*d*d+A,i[1]=h*r+l,i[2]=h*s-a,i[3]=0,i[4]=h*r-l,i[5]=h*p*p+A,i[6]=h*n+o,i[7]=0,i[8]=h*s+a,i[9]=h*n-o,i[10]=h*f*f+A,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},rotationMat4c:function(e,t,i,r,n){return le.rotationMat4v(e,[t,i,r],n)},scalingMat4v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:le.identityMat4();return t[0]=e[0],t[5]=e[1],t[10]=e[2],t},scalingMat3v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:le.identityMat3();return t[0]=e[0],t[4]=e[1],t},scalingMat4c:function(){var e=new re(3);return function(t,i,r,n){return e[0]=t,e[1]=i,e[2]=r,le.scalingMat4v(e,n)}}(),scaleMat4c:function(e,t,i,r){return r[0]*=e,r[4]*=t,r[8]*=i,r[1]*=e,r[5]*=t,r[9]*=i,r[2]*=e,r[6]*=t,r[10]*=i,r[3]*=e,r[7]*=t,r[11]*=i,r},scaleMat4v:function(e,t){var i=e[0],r=e[1],n=e[2];return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,t},scalingMat4s:function(e){return le.scalingMat4c(e,e,e)},rotationTranslationMat4:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:le.mat4(),r=e[0],n=e[1],s=e[2],o=e[3],a=r+r,l=n+n,u=s+s,c=r*a,A=r*l,h=r*u,d=n*l,p=n*u,f=s*u,v=o*a,g=o*l,m=o*u;return i[0]=1-(d+f),i[1]=A+m,i[2]=h-g,i[3]=0,i[4]=A-m,i[5]=1-(c+f),i[6]=p+v,i[7]=0,i[8]=h+g,i[9]=p-v,i[10]=1-(c+d),i[11]=0,i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=1,i},mat4ToEuler:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:le.vec4(),r=le.clamp,n=e[0],s=e[4],o=e[8],a=e[1],l=e[5],u=e[9],c=e[2],A=e[6],h=e[10];return"XYZ"===t?(i[1]=Math.asin(r(o,-1,1)),Math.abs(o)<.99999?(i[0]=Math.atan2(-u,h),i[2]=Math.atan2(-s,n)):(i[0]=Math.atan2(A,l),i[2]=0)):"YXZ"===t?(i[0]=Math.asin(-r(u,-1,1)),Math.abs(u)<.99999?(i[1]=Math.atan2(o,h),i[2]=Math.atan2(a,l)):(i[1]=Math.atan2(-c,n),i[2]=0)):"ZXY"===t?(i[0]=Math.asin(r(A,-1,1)),Math.abs(A)<.99999?(i[1]=Math.atan2(-c,h),i[2]=Math.atan2(-s,l)):(i[1]=0,i[2]=Math.atan2(a,n))):"ZYX"===t?(i[1]=Math.asin(-r(c,-1,1)),Math.abs(c)<.99999?(i[0]=Math.atan2(A,h),i[2]=Math.atan2(a,n)):(i[0]=0,i[2]=Math.atan2(-s,l))):"YZX"===t?(i[2]=Math.asin(r(a,-1,1)),Math.abs(a)<.99999?(i[0]=Math.atan2(-u,l),i[1]=Math.atan2(-c,n)):(i[0]=0,i[1]=Math.atan2(o,h))):"XZY"===t&&(i[2]=Math.asin(-r(s,-1,1)),Math.abs(s)<.99999?(i[0]=Math.atan2(A,l),i[1]=Math.atan2(o,n)):(i[0]=Math.atan2(-u,h),i[1]=0)),i[0]*=le.RADTODEG,i[1]*=le.RADTODEG,i[2]*=le.RADTODEG,i},composeMat4:function(e,t,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:le.mat4();return le.quaternionToRotationMat4(t,r),le.scaleMat4v(i,r),le.translateMat4v(e,r),r},decomposeMat4:function(){var e=new re(3),t=new re(16);return function(i,r,n,s){e[0]=i[0],e[1]=i[1],e[2]=i[2];var o=le.lenVec3(e);e[0]=i[4],e[1]=i[5],e[2]=i[6];var a=le.lenVec3(e);e[8]=i[8],e[9]=i[9],e[10]=i[10];var l=le.lenVec3(e);le.determinantMat4(i)<0&&(o=-o),r[0]=i[12],r[1]=i[13],r[2]=i[14],t.set(i);var u=1/o,c=1/a,A=1/l;return t[0]*=u,t[1]*=u,t[2]*=u,t[4]*=c,t[5]*=c,t[6]*=c,t[8]*=A,t[9]*=A,t[10]*=A,le.mat4ToQuaternion(t,n),s[0]=o,s[1]=a,s[2]=l,this}}(),getColMat4:function(e,t){var i=4*t;return[e[i],e[i+1],e[i+2],e[i+3]]},setRowMat4:function(e,t,i){e[t]=i[0],e[t+4]=i[1],e[t+8]=i[2],e[t+12]=i[3]},lookAtMat4v:function(e,t,i,r){r||(r=le.mat4());var n,s,o,a,l,u,c,A,h,d,p=e[0],f=e[1],v=e[2],g=i[0],m=i[1],_=i[2],y=t[0],b=t[1],w=t[2];return p===y&&f===b&&v===w?le.identityMat4():(n=p-y,s=f-b,o=v-w,a=m*(o*=d=1/Math.sqrt(n*n+s*s+o*o))-_*(s*=d),l=_*(n*=d)-g*o,u=g*s-m*n,(d=Math.sqrt(a*a+l*l+u*u))?(a*=d=1/d,l*=d,u*=d):(a=0,l=0,u=0),c=s*u-o*l,A=o*a-n*u,h=n*l-s*a,(d=Math.sqrt(c*c+A*A+h*h))?(c*=d=1/d,A*=d,h*=d):(c=0,A=0,h=0),r[0]=a,r[1]=c,r[2]=n,r[3]=0,r[4]=l,r[5]=A,r[6]=s,r[7]=0,r[8]=u,r[9]=h,r[10]=o,r[11]=0,r[12]=-(a*p+l*f+u*v),r[13]=-(c*p+A*f+h*v),r[14]=-(n*p+s*f+o*v),r[15]=1,r)},lookAtMat4c:function(e,t,i,r,n,s,o,a,l){return le.lookAtMat4v([e,t,i],[r,n,s],[o,a,l],[])},orthoMat4c:function(e,t,i,r,n,s,o){o||(o=le.mat4());var a=t-e,l=r-i,u=s-n;return o[0]=2/a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2/l,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=-2/u,o[11]=0,o[12]=-(e+t)/a,o[13]=-(r+i)/l,o[14]=-(s+n)/u,o[15]=1,o},frustumMat4v:function(e,t,i){i||(i=le.mat4());var r=[e[0],e[1],e[2],0],n=[t[0],t[1],t[2],0];le.addVec4(n,r,se),le.subVec4(n,r,oe);var s=2*r[2],o=oe[0],a=oe[1],l=oe[2];return i[0]=s/o,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=s/a,i[6]=0,i[7]=0,i[8]=se[0]/o,i[9]=se[1]/a,i[10]=-se[2]/l,i[11]=-1,i[12]=0,i[13]=0,i[14]=-s*n[2]/l,i[15]=0,i},frustumMat4:function(e,t,i,r,n,s,o){o||(o=le.mat4());var a=t-e,l=r-i,u=s-n;return o[0]=2*n/a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*n/l,o[6]=0,o[7]=0,o[8]=(t+e)/a,o[9]=(r+i)/l,o[10]=-(s+n)/u,o[11]=-1,o[12]=0,o[13]=0,o[14]=-s*n*2/u,o[15]=0,o},perspectiveMat4:function(e,t,i,r,n){var s=[],o=[];return s[2]=i,o[2]=r,o[1]=s[2]*Math.tan(e/2),s[1]=-o[1],o[0]=o[1]*t,s[0]=-o[0],le.frustumMat4v(s,o,n)},compareMat4:function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},transformPoint3:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:le.vec3(),r=t[0],n=t[1],s=t[2];return i[0]=e[0]*r+e[4]*n+e[8]*s+e[12],i[1]=e[1]*r+e[5]*n+e[9]*s+e[13],i[2]=e[2]*r+e[6]*n+e[10]*s+e[14],i},transformPoint4:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:le.vec4();return i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],i},transformPoints3:function(e,t,i){for(var r,n,s,o,a,l=i||[],u=t.length,c=e[0],A=e[1],h=e[2],d=e[3],p=e[4],f=e[5],v=e[6],g=e[7],m=e[8],_=e[9],y=e[10],b=e[11],w=e[12],B=e[13],x=e[14],P=e[15],C=0;C<u;++C)r=(o=t[C])[0],n=o[1],s=o[2],(a=l[C]||(l[C]=[0,0,0]))[0]=c*r+p*n+m*s+w,a[1]=A*r+f*n+_*s+B,a[2]=h*r+v*n+y*s+x,a[3]=d*r+g*n+b*s+P;return l.length=u,l},transformPositions3:function(e,t){var i,r,n,s,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,a=t.length,l=e[0],u=e[1],c=e[2];e[3];var A=e[4],h=e[5],d=e[6];e[7];var p=e[8],f=e[9],v=e[10];e[11];var g=e[12],m=e[13],_=e[14];for(e[15],i=0;i<a;i+=3)r=t[i+0],n=t[i+1],s=t[i+2],o[i+0]=l*r+A*n+p*s+g,o[i+1]=u*r+h*n+f*s+m,o[i+2]=c*r+d*n+v*s+_;return o},transformPositions4:function(e,t){var i,r,n,s,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,a=t.length,l=e[0],u=e[1],c=e[2],A=e[3],h=e[4],d=e[5],p=e[6],f=e[7],v=e[8],g=e[9],m=e[10],_=e[11],y=e[12],b=e[13],w=e[14],B=e[15];for(i=0;i<a;i+=4)r=t[i+0],n=t[i+1],s=t[i+2],o[i+0]=l*r+h*n+v*s+y,o[i+1]=u*r+d*n+g*s+b,o[i+2]=c*r+p*n+m*s+w,o[i+3]=A*r+f*n+_*s+B;return o},transformVec3:function(e,t,i){var r=t[0],n=t[1],s=t[2];return(i=i||this.vec3())[0]=e[0]*r+e[4]*n+e[8]*s,i[1]=e[1]*r+e[5]*n+e[9]*s,i[2]=e[2]*r+e[6]*n+e[10]*s,i},transformVec4:function(e,t,i){var r=t[0],n=t[1],s=t[2],o=t[3];return(i=i||le.vec4())[0]=e[0]*r+e[4]*n+e[8]*s+e[12]*o,i[1]=e[1]*r+e[5]*n+e[9]*s+e[13]*o,i[2]=e[2]*r+e[6]*n+e[10]*s+e[14]*o,i[3]=e[3]*r+e[7]*n+e[11]*s+e[15]*o,i},rotateVec2:function(e,t,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,n=Math.cos(i),s=Math.sin(i),o=e[0]-t[0],a=e[1]-t[1];return r[0]=o*n-a*s+t[0],r[1]=o*s+a*n+t[1],e},rotateVec3X:function(e,t,i,r){var n=[],s=[];return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],s[0]=n[0],s[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),s[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r},rotateVec3Y:function(e,t,i,r){var n=[],s=[];return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],s[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),s[1]=n[1],s[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r},rotateVec3Z:function(e,t,i,r){var n=[],s=[];return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],s[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),s[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),s[2]=n[2],r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r},projectVec4:function(e,t){var i=1/e[3];return(t=t||le.vec2())[0]=e[0]*i,t[1]=e[1]*i,t},unprojectVec3:(G=new re(16),z=new re(16),W=new re(16),function(e,t,i,r){return this.transformVec3(this.mulMat4(this.inverseMat4(t,G),this.inverseMat4(i,z),W),e,r)}),lerpVec3:function(e,t,i,r,n,s){var o=s||le.vec3(),a=(e-t)/(i-t);return o[0]=r[0]+a*(n[0]-r[0]),o[1]=r[1]+a*(n[1]-r[1]),o[2]=r[2]+a*(n[2]-r[2]),o},lerpMat4:function(e,t,i,r,n,s){var o=s||le.mat4(),a=(e-t)/(i-t);return o[0]=r[0]+a*(n[0]-r[0]),o[1]=r[1]+a*(n[1]-r[1]),o[2]=r[2]+a*(n[2]-r[2]),o[3]=r[3]+a*(n[3]-r[3]),o[4]=r[4]+a*(n[4]-r[4]),o[5]=r[5]+a*(n[5]-r[5]