@xtctwins/tctwins-core
Version:
Web Programming Toolkit for 3D/2D BIM and CAD
542 lines • 4.06 MB
JavaScript
var _marked=/*#__PURE__*/_regeneratorRuntime().mark(makeStringIterator),_marked2=/*#__PURE__*/_regeneratorRuntime().mark(makeMeshPrimitiveIterator);function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty2(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function _regeneratorRuntime(){return e;};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value;},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{define({},"");}catch(t){define=function define(t,e,r){return t[e]=r;};}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a;}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)};}catch(t){return{type:"throw",arg:t};}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this;});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach(function(e){define(t,e,function(t){return this._invoke(e,t);});});}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==_typeof2(h)&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){invoke("next",t,i,a);},function(t){invoke("throw",t,i,a);}):e.resolve(h).then(function(t){u.value=t,i(u);},function(t){return invoke("throw",t,i,a);});}a(c.arg);}var r;o(this,"_invoke",{value:function value(t,n){function callInvokeWithMethodAndArg(){return new e(function(e,r){invoke(t,n,e,r);});}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done};}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg);}};}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator["return"]&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y);}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0);}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o<e.length;)if(n.call(e,o))return next.value=e[o],next.done=!1,next;return next.value=t,next.done=!0,next;};return i.next=i;}}throw new TypeError(_typeof2(e)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===GeneratorFunction||"GeneratorFunction"===(e.displayName||e.name));},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t;},e.awrap=function(t){return{__await:t};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this;}),e.AsyncIterator=AsyncIterator,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(wrap(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next();});},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this;}),define(g,"toString",function(){return"[object Generator]";}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function next(){for(;r.length;){var t=r.pop();if(t in e)return next.value=t,next.done=!1,next;}return next.done=!0,next;};},e.values=values,Context.prototype={constructor:Context,reset:function reset(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(e){if(this.done)throw e;var r=this;function handle(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o;}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}else if(c){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}}}},abrupt:function abrupt(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break;}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a);},complete:function complete(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y;},finish:function finish(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y;}},"catch":function _catch(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y;}},e;}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value;}catch(n){return void e(n);}i.done?t(u):Promise.resolve(u).then(r,o);}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n);}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n);}_next(void 0);});};}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){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 _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n6=0,F=function F(){};return{s:F,n:function n(){return _n6>=r.length?{done:!0}:{done:!1,value:r[_n6++]};},e:function e(r){throw r;},f:F};}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 o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest();}function _nonIterableRest(){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 _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1;}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r;}finally{try{if(!f&&null!=t["return"]&&(u=t["return"](),Object(u)!==u))return;}finally{if(o)throw n;}}return a;}}function _arrayWithHoles(r){if(Array.isArray(r))return r;}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof2(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,e,r,o){var p=_get(_getPrototypeOf(1&o?t.prototype:t),e,r);return 2&o?function(t){return p.apply(r,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}function _defineProperty2(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _typeof2(o){"@babel/helpers - typeof";return _typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof2(o);}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof2(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof2(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof2(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _awaitAsyncGenerator(e){return new _OverloadYield(e,0);}function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator(e.apply(this,arguments));};}function AsyncGenerator(e){var r,t;function resume(r,t){try{var n=e[r](t),o=n.value,u=o instanceof _OverloadYield;Promise.resolve(u?o.v:o).then(function(t){if(u){var i="return"===r?"return":"next";if(!o.k||t.done)return resume(i,t);t=e[i](t).value;}settle(n.done?"return":"normal",t);},function(e){resume("throw",e);});}catch(e){settle("throw",e);}}function settle(e,n){switch(e){case"return":r.resolve({value:n,done:!0});break;case"throw":r.reject(n);break;default:r.resolve({value:n,done:!1});}(r=r.next)?resume(r.key,r.arg):t=null;}this._invoke=function(e,n){return new Promise(function(o,u){var i={key:e,arg:n,resolve:o,reject:u,next:null};t?t=t.next=i:(r=t=i,resume(e,n));});},"function"!=typeof e["return"]&&(this["return"]=void 0);}AsyncGenerator.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this;},AsyncGenerator.prototype.next=function(e){return this._invoke("next",e);},AsyncGenerator.prototype["throw"]=function(e){return this._invoke("throw",e);},AsyncGenerator.prototype["return"]=function(e){return this._invoke("return",e);};function _OverloadYield(e,d){this.v=e,this.k=d;}function _asyncIterator(r){var n,t,o,e=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,o=Symbol.iterator);e--;){if(t&&null!=(n=r[t]))return n.call(r);if(o&&null!=(n=r[o]))return new AsyncFromSyncIterator(n.call(r));t="@@asyncIterator",o="@@iterator";}throw new TypeError("Object is not async iterable");}function AsyncFromSyncIterator(r){function AsyncFromSyncIteratorContinuation(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var n=r.done;return Promise.resolve(r.value).then(function(r){return{value:r,done:n};});}return AsyncFromSyncIterator=function AsyncFromSyncIterator(r){this.s=r,this.n=r.next;},AsyncFromSyncIterator.prototype={s:null,n:null,next:function next(){return AsyncFromSyncIteratorContinuation(this.n.apply(this.s,arguments));},"return":function _return(r){var n=this.s["return"];return void 0===n?Promise.resolve({value:r,done:!0}):AsyncFromSyncIteratorContinuation(n.apply(this.s,arguments));},"throw":function _throw(r){var n=this.s["return"];return void 0===n?Promise.reject(r):AsyncFromSyncIteratorContinuation(n.apply(this.s,arguments));}},new AsyncFromSyncIterator(r);}/**
* A PointerLens shows a magnified view of a {@link Viewer}'s canvas, centered at the position of the
* mouse or touch pointer.
*
* This component is used by {@link DistanceMeasurementsControl} and {@link AngleMeasurementsControl}
* to help position the pointer when snap-to-vertex or snap-toedge is enabled.
*
* [[Run example](https://xeokit.github.io/xeokit-sdk/examples/measurements/#distance_modelWithMeasurements)]
*
* ````JavaScript
*
* import {Viewer, XTCLoaderPlugin, AngleMeasurementsPlugin, AngleMeasurementsMouseControl, PointerLens} from "../../dist/xeokit-sdk.es.js";
*
* const viewer = new Viewer({
* canvasId: "myCanvas",
* dtxEnabled: true
* });
*
* viewer.camera.eye = [-3.93, 2.85, 27.01];
* viewer.camera.look = [4.40, 3.72, 8.89];
* viewer.camera.up = [-0.01, 0.99, 0.039];
*
* const xtcLoader = new XTCLoaderPlugin(viewer);
*
* const sceneModel = xtcLoader.load({
* id: "myModel",
* src: "../../assets/models/xtc/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xtc",
* edges: true
* });
*
* const angleMeasurements = new AngleMeasurementsPlugin(viewer);
*
* const angleMeasurementsMouseControl = new AngleMeasurementsMouseControl(angleMeasurements, {
* pointerLens : new PointerLens(viewer, {
* zoomFactor: 2
* })
* })
*
* angleMeasurementsMouseControl.activate();
* ````
*/var PointerLens=/*#__PURE__*/function(){/**
* Constructs a new PointerLens.
* @param viewer The Viewer
* @param [cfg] PointerLens configuration.
* @param [cfg.active=true] Whether PointerLens is active. The PointerLens can only be shown when this is `true` (default).
*/function PointerLens(viewer){var _this2=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointerLens);this.viewer=viewer;this.scene=this.viewer.scene;this._lensCursorDiv=document.createElement("div");this._lensCursorDiv.setAttribute("class","pointerLensCursor");document.body.append(this._lensCursorDiv);this._lensCursorDiv.style.background="pink";this._lensCursorDiv.style.border="2px solid red";this._lensCursorDiv.style.borderRadius="20px";this._lensCursorDiv.style.width="10px";this._lensCursorDiv.style.height="10px";this._lensCursorDiv.style.margin="-200px -200px";this._lensCursorDiv.style.zIndex="100000";this._lensCursorDiv.style.position="absolute";this._lensCursorDiv.style.pointerEvents="none";this._lensContainer=document.createElement("div");this._lensContainer.setAttribute("class","pointerLens");this._lensContainer.style.border="1px solid black";this._lensContainer.style.background="white";// this._lensContainer.style.opacity = "0";
this._lensContainer.style.borderRadius="50%";this._lensContainer.style.width="300px";this._lensContainer.style.height="300px";this._lensContainer.style.marginTop="85px";this._lensContainer.style.marginLeft="25px";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.style.background = "darkblue";
this._lensCanvas.style.borderRadius="50%";this._lensCanvas.style.width="300px";this._lensCanvas.style.height="300px";this._lensCanvas.style.zIndex="15000";this._lensCanvas.style.pointerEvents="none";document.body.appendChild(this._lensContainer);this._lensContainer.appendChild(this._lensCanvas);this._lensCanvasContext=this._lensCanvas.getContext("2d");this._canvasElement=this.viewer.scene.canvas.canvas;this._canvasPos=null;this._snappedCanvasPos=null;this._lensPosToggle=true;this._zoomLevel=cfg.zoomFactor!==undefined?cfg.zoomFactor:2;this._active=cfg.active!==false;this._visible=false;this._snapped=false;this._onViewerRendering=this.viewer.scene.on("rendering",function(){if(_this2._active&&_this2._visible){_this2.update();}});}/**
* Updates this PointerLens.
*/return _createClass(PointerLens,[{key:"update",value:function update(){if(!this._active||!this._visible){return;}if(!this._canvasPos){return;}var lensRect=this._lensContainer.getBoundingClientRect();var canvasRect=this._canvasElement.getBoundingClientRect();var pointerOnLens=this._canvasPos[0]<lensRect.right&&this._canvasPos[0]>lensRect.left&&this._canvasPos[1]<lensRect.bottom&&this._canvasPos[1]>lensRect.top;this._lensContainer.style.marginLeft="25px";if(pointerOnLens){if(this._lensPosToggle){this._lensContainer.style.marginTop="".concat(canvasRect.bottom-canvasRect.top-this._lensCanvas.height-85,"px");}else{this._lensContainer.style.marginTop="85px";}this._lensPosToggle=!this._lensPosToggle;}this._lensCanvasContext.clearRect(0,0,this._lensCanvas.width,this._lensCanvas.height);var size=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,// source canvas
this._canvasPos[0]-size/2,// source x (zoom center)
this._canvasPos[1]-size/2,// source y (zoom center)
size,// source width
size,// source height
0,// destination x
0,// destination y
this._lensCanvas.width,// destination width
this._lensCanvas.height// destination height
);var centerLensCanvas=[(lensRect.left+lensRect.right)/2,(lensRect.top+lensRect.bottom)/2];if(this._snappedCanvasPos){var deltaX=this._snappedCanvasPos[0]-this._canvasPos[0];var deltaY=this._snappedCanvasPos[1]-this._canvasPos[1];this._lensCursorDiv.style.marginLeft="".concat(centerLensCanvas[0]+deltaX*this._zoomLevel-10,"px");this._lensCursorDiv.style.marginTop="".concat(centerLensCanvas[1]+deltaY*this._zoomLevel-10,"px");}else{this._lensCursorDiv.style.marginLeft="".concat(centerLensCanvas[0]-10,"px");this._lensCursorDiv.style.marginTop="".concat(centerLensCanvas[1]-10,"px");}}/**
* Sets the zoom factor for the lens.
*
* This is `2` by default.
*
* @param zoomFactor
*/},{key:"zoomFactor",get:/**
* Gets the zoom factor for the lens.
*
* This is `2` by default.
*
* @returns Number
*/function get(){return this._zoomLevel;}/**
* Sets the canvas central position of the lens.
* @param canvasPos
*/,set:function set(zoomFactor){this._zoomLevel=zoomFactor;this.update();}},{key:"canvasPos",get:/**
* Gets the canvas central position of the lens.
* @returns {Number[]}
*/function get(){return this._canvasPos;}/**
* Sets the canvas coordinates of the pointer.
* @param snappedCanvasPos
*/,set:function set(canvasPos){this._canvasPos=canvasPos;this.update();}},{key:"snappedCanvasPos",get:/**
* Gets the canvas coordinates of the snapped pointer.
* @returns {Number[]}
*/function get(){return this._snappedCanvasPos;}/**
* Sets if the cursor has snapped to anything.
* This is set by plugins.
* @param snapped
* @private
*/,set:function set(snappedCanvasPos){this._snappedCanvasPos=snappedCanvasPos;this.update();}},{key:"snapped",get:/**
* Gets if the cursor has snapped to anything.
* This is called by plugins.
* @returns {Boolean}
* @private
*/function get(){return this._snapped;}/**
* Sets if this PointerLens is active.
* @param active
*/,set:function set(snapped){this._snapped=snapped;if(snapped){this._lensCursorDiv.style.background="greenyellow";this._lensCursorDiv.style.border="2px solid green";}else{this._lensCursorDiv.style.background="pink";this._lensCursorDiv.style.border="2px solid red";}}},{key:"active",get:/**
* Gets if this PointerLens is active.
* @returns {Boolean}
*/function get(){return this._active;}/**
* Sets if this PointerLens is visible.
* This is set by plugins.
* @param visible
* @private
*/,set:function set(active){this._active=active;this._lensContainer.style.visibility=active&&this._visible?"visible":"hidden";if(!active||!this._visible){this._lensCursorDiv.style.marginLeft="-100px";this._lensCursorDiv.style.marginTop="-100px";}this.update();}},{key:"visible",get:/**
* Gets if this PointerLens is visible.
* This is called by plugins.
* @returns {Boolean}
* @private
*/function get(){return this._visible;}/**
* Destroys this PointerLens.
*/,set:function set(visible){this._visible=visible;this._lensContainer.style.visibility=visible&&this._active?"visible":"hidden";if(!visible||!this._active){this._lensCursorDiv.style.marginLeft="-100px";this._lensCursorDiv.style.marginTop="-100px";}this.update();}},{key:"destroy",value:function destroy(){if(!this._destroyed){this.viewer.scene.off(this._onViewerRendering);this._lensContainer.removeChild(this._lensCanvas);document.body.removeChild(this._lensContainer);this._destroyed=true;}}}]);}();// Some temporary vars to help avoid garbage collection
var doublePrecision=true;var FloatArrayType=doublePrecision?Float64Array:Float32Array;var tempVec3a$K=new FloatArrayType(3);var tempMat1=new FloatArrayType(16);var tempMat2=new FloatArrayType(16);var tempVec4$2=new FloatArrayType(4);/**
* @private
*/var math={setDoublePrecisionEnabled:function setDoublePrecisionEnabled(enable){doublePrecision=enable;FloatArrayType=doublePrecision?Float64Array:Float32Array;},getDoublePrecisionEnabled:function getDoublePrecisionEnabled(){return doublePrecision;},MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:10000000,/**
* The number of radiians in a degree (0.0174532925).
* @property DEGTORAD
* @type {Number}
*/DEGTORAD:0.0174532925,/**
* The number of degrees in a radian.
* @property RADTODEG
* @type {Number}
*/RADTODEG:57.295779513,unglobalizeObjectId:function unglobalizeObjectId(modelId,globalId){var idx=globalId.indexOf("#");return idx===modelId.length&&globalId.startsWith(modelId)?globalId.substring(idx+1):globalId;},globalizeObjectId:function globalizeObjectId(modelId,objectId){return modelId+"#"+objectId;},/**
* Returns:
* - x != 0 => 1/x,
* - x == 1 => 1
*
* @param {number} x
*/safeInv:function safeInv(x){var retVal=1/x;if(isNaN(retVal)||!isFinite(retVal)){return 1;}return retVal;},/**
* Returns a new, uninitialized two-element vector.
* @method vec2
* @param [values] Initial values.
* @static
* @returns {Number[]}
*/vec2:function vec2(values){return new FloatArrayType(values||2);},/**
* Returns a new, uninitialized three-element vector.
* @method vec3
* @param [values] Initial values.
* @static
* @returns {Number[]}
*/vec3:function vec3(values){return new FloatArrayType(values||3);},/**
* Returns a new, uninitialized four-element vector.
* @method vec4
* @param [values] Initial values.
* @static
* @returns {Number[]}
*/vec4:function vec4(values){return new FloatArrayType(values||4);},/**
* Returns a new, uninitialized 3x3 matrix.
* @method mat3
* @param [values] Initial values.
* @static
* @returns {Number[]}
*/mat3:function mat3(values){return new FloatArrayType(values||9);},/**
* Converts a 3x3 matrix to 4x4
* @method mat3ToMat4
* @param mat3 3x3 matrix.
* @param mat4 4x4 matrix
* @static
* @returns {Number[]}
*/mat3ToMat4:function mat3ToMat4(mat3){var mat4=arguments.length>1&&arguments[1]!==undefined?arguments[1]:new FloatArrayType(16);mat4[0]=mat3[0];mat4[1]=mat3[1];mat4[2]=mat3[2];mat4[3]=0;mat4[4]=mat3[3];mat4[5]=mat3[4];mat4[6]=mat3[5];mat4[7]=0;mat4[8]=mat3[6];mat4[9]=mat3[7];mat4[10]=mat3[8];mat4[11]=0;mat4[12]=0;mat4[13]=0;mat4[14]=0;mat4[15]=1;return mat4;},/**
* Returns a new, uninitialized 4x4 matrix.
* @method mat4
* @param [values] Initial values.
* @static
* @returns {Number[]}
*/mat4:function mat4(values){return new FloatArrayType(values||16);},/**
* Converts a 4x4 matrix to 3x3
* @method mat4ToMat3
* @param mat4 4x4 matrix.
* @param mat3 3x3 matrix
* @static
* @returns {Number[]}
*/mat4ToMat3:function mat4ToMat3(mat4,mat3){// TODO
//return new FloatArrayType(values || 9);
},/**
* Converts a list of double-precision values to a list of high-part floats and a list of low-part floats.
* @param doubleVals
* @param floatValsHigh
* @param floatValsLow
*/doublesToFloats:function doublesToFloats(doubleVals,floatValsHigh,floatValsLow){var floatPair=new FloatArrayType(2);for(var _i2=0,len=doubleVals.length;_i2<len;_i2++){math.splitDouble(doubleVals[_i2],floatPair);floatValsHigh[_i2]=floatPair[0];floatValsLow[_i2]=floatPair[1];}},/**
* Splits a double value into two floats.
* @param value
* @param floatPair
*/splitDouble:function splitDouble(value,floatPair){var hi=FloatArrayType.from([value])[0];var low=value-hi;floatPair[0]=hi;floatPair[1]=low;},/**
* Returns a new UUID.
* @method createUUID
* @static
* @return string The new UUID
*/createUUID:function(){var lut=[];for(var _i3=0;_i3<256;_i3++){lut[_i3]=(_i3<16?"0":"")+_i3.toString(16);}return function(){var d0=Math.random()*0xffffffff|0;var d1=Math.random()*0xffffffff|0;var d2=Math.random()*0xffffffff|0;var d3=Math.random()*0xffffffff|0;return"".concat(lut[d0&0xff]+lut[d0>>8&0xff]+lut[d0>>16&0xff]+lut[d0>>24&0xff],"-").concat(lut[d1&0xff]).concat(lut[d1>>8&0xff],"-").concat(lut[d1>>16&0x0f|0x40]).concat(lut[d1>>24&0xff],"-").concat(lut[d2&0x3f|0x80]).concat(lut[d2>>8&0xff],"-").concat(lut[d2>>16&0xff]).concat(lut[d2>>24&0xff]).concat(lut[d3&0xff]).concat(lut[d3>>8&0xff]).concat(lut[d3>>16&0xff]).concat(lut[d3>>24&0xff]);};}(),/**
* Clamps a value to the given range.
* @param {Number} value Value to clamp.
* @param {Number} min Lower bound.
* @param {Number} max Upper bound.
* @returns {Number} Clamped result.
*/clamp:function clamp(value,min,max){return Math.max(min,Math.min(max,value));},/**
* Floating-point modulus
* @method fmod
* @static
* @param {Number} a
* @param {Number} b
* @returns {*}
*/fmod:function fmod(a,b){if(a<b){console.error("math.fmod : Attempting to find modulus within negative range - would be infinite loop - ignoring");return a;}while(b<=a){a-=b;}return a;},/**
* Returns true if the two 3-element vectors are the same.
* @param v1
* @param v2
* @returns {Boolean}
*/compareVec3:function compareVec3(v1,v2){return v1[0]===v2[0]&&v1[1]===v2[1]&&v1[2]===v2[2];},/**
* Negates a three-element vector.
* @method negateVec3
* @static
* @param {Array(Number)} v Vector to negate
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/negateVec3:function negateVec3(v,dest){if(!dest){dest=v;}dest[0]=-v[0];dest[1]=-v[1];dest[2]=-v[2];return dest;},/**
* Negates a four-element vector.
* @method negateVec4
* @static
* @param {Array(Number)} v Vector to negate
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/negateVec4:function negateVec4(v,dest){if(!dest){dest=v;}dest[0]=-v[0];dest[1]=-v[1];dest[2]=-v[2];dest[3]=-v[3];return dest;},/**
* Adds one four-element vector to another.
* @method addVec4
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/addVec4:function addVec4(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]+v[0];dest[1]=u[1]+v[1];dest[2]=u[2]+v[2];dest[3]=u[3]+v[3];return dest;},/**
* Adds a scalar value to each element of a four-element vector.
* @method addVec4Scalar
* @static
* @param {Array(Number)} v The vector
* @param {Number} s The scalar
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/addVec4Scalar:function addVec4Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]+s;dest[1]=v[1]+s;dest[2]=v[2]+s;dest[3]=v[3]+s;return dest;},/**
* Adds one three-element vector to another.
* @method addVec3
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/addVec3:function addVec3(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]+v[0];dest[1]=u[1]+v[1];dest[2]=u[2]+v[2];return dest;},/**
* Adds a scalar value to each element of a three-element vector.
* @method addVec4Scalar
* @static
* @param {Array(Number)} v The vector
* @param {Number} s The scalar
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/addVec3Scalar:function addVec3Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]+s;dest[1]=v[1]+s;dest[2]=v[2]+s;return dest;},/**
* Subtracts one four-element vector from another.
* @method subVec4
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Vector to subtract
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/subVec4:function subVec4(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]-v[0];dest[1]=u[1]-v[1];dest[2]=u[2]-v[2];dest[3]=u[3]-v[3];return dest;},/**
* Subtracts one three-element vector from another.
* @method subVec3
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Vector to subtract
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/subVec3:function subVec3(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]-v[0];dest[1]=u[1]-v[1];dest[2]=u[2]-v[2];return dest;},/**
* Subtracts one two-element vector from another.
* @method subVec2
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Vector to subtract
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/subVec2:function subVec2(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]-v[0];dest[1]=u[1]-v[1];return dest;},/**
* Get the geometric mean of the vectors.
* @method geometricMeanVec2
* @static
* @param {...Array(Number)} vectors Vec2 to mean
* @return {Array(Number)} The geometric mean vec2
*/geometricMeanVec2:function geometricMeanVec2(){for(var _len5=arguments.length,vectors=new Array(_len5),_key5=0;_key5<_len5;_key5++){vectors[_key5]=arguments[_key5];}var geometricMean=new FloatArrayType(vectors[0]);for(var _i4=1;_i4<vectors.length;_i4++){geometricMean[0]+=vectors[_i4][0];geometricMean[1]+=vectors[_i4][1];}geometricMean[0]/=vectors.length;geometricMean[1]/=vectors.length;return geometricMean;},/**
* Subtracts a scalar value from each element of a four-element vector.
* @method subVec4Scalar
* @static
* @param {Array(Number)} v The vector
* @param {Number} s The scalar
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/subVec4Scalar:function subVec4Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]-s;dest[1]=v[1]-s;dest[2]=v[2]-s;dest[3]=v[3]-s;return dest;},/**
* Sets each element of a 4-element vector to a scalar value minus the value of that element.
* @method subScalarVec4
* @static
* @param {Array(Number)} v The vector
* @param {Number} s The scalar
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/subScalarVec4:function subScalarVec4(v,s,dest){if(!dest){dest=v;}dest[0]=s-v[0];dest[1]=s-v[1];dest[2]=s-v[2];dest[3]=s-v[3];return dest;},/**
* Multiplies one three-element vector by another.
* @method mulVec3
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/mulVec3:function mulVec3(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]*v[0];dest[1]=u[1]*v[1];dest[2]=u[2]*v[2];return dest;},/**
* Multiplies one three-element vector by another.
* @method mulVec4
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/mulVec4:function mulVec4(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]*v[0];dest[1]=u[1]*v[1];dest[2]=u[2]*v[2];dest[3]=u[3]*v[3];return dest;},/**
* Multiplies each element of a four-element vector by a scalar.
* @method mulVec34calar
* @static
* @param {Array(Number)} v The vector
* @param {Number} s The scalar
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/mulVec4Scalar:function mulVec4Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]*s;dest[1]=v[1]*s;dest[2]=v[2]*s;dest[3]=v[3]*s;return dest;},/**
* Multiplies each element of a three-element vector by a scalar.
* @method mulVec3Scalar
* @static
* @param {Array(Number)} v The vector
* @param {Number} s The scalar
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/mulVec3Scalar:function mulVec3Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]*s;dest[1]=v[1]*s;dest[2]=v[2]*s;return dest;},/**
* Multiplies each element of a two-element vector by a scalar.
* @method mulVec2Scalar
* @static
* @param {Array(Number)} v The vector
* @param {Number} s The scalar
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, v otherwise
*/mulVec2Scalar:function mulVec2Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]*s;dest[1]=v[1]*s;return dest;},/**
* Divides one three-element vector by another.
* @method divVec3
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/divVec3:function divVec3(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]/v[0];dest[1]=u[1]/v[1];dest[2]=u[2]/v[2];return dest;},/**
* Divides one four-element vector by another.
* @method divVec4
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @param {Array(Number)} [dest] Destination vector
* @return {Array(Number)} dest if specified, u otherwise
*/divVec4:function divVec4(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]/v[0];dest[1]=u[1]/v[1];dest[2]=u[2]/v[2];dest[3]=u[3]/v[3];return dest;},/**
* Divides a scalar by a three-element vector, returning a new vector.
* @method divScalarVec3
* @static
* @param v vec3
* @param s scalar
* @param dest vec3 - optional destination
* @return [] dest if specified, v otherwise
*/divScalarVec3:function divScalarVec3(s,v,dest){if(!dest){dest=v;}dest[0]=s/v[0];dest[1]=s/v[1];dest[2]=s/v[2];return dest;},/**
* Divides a three-element vector by a scalar.
* @method divVec3Scalar
* @static
* @param v vec3
* @param s scalar
* @param dest vec3 - optional destination
* @return [] dest if specified, v otherwise
*/divVec3Scalar:function divVec3Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]/s;dest[1]=v[1]/s;dest[2]=v[2]/s;return dest;},/**
* Divides a four-element vector by a scalar.
* @method divVec4Scalar
* @static
* @param v vec4
* @param s scalar
* @param dest vec4 - optional destination
* @return [] dest if specified, v otherwise
*/divVec4Scalar:function divVec4Scalar(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]/s;dest[1]=v[1]/s;dest[2]=v[2]/s;dest[3]=v[3]/s;return dest;},/**
* Divides a scalar by a four-element vector, returning a new vector.
* @method divScalarVec4
* @static
* @param s scalar
* @param v vec4
* @param dest vec4 - optional destination
* @return [] dest if specified, v otherwise
*/divScalarVec4:function divScalarVec4(s,v,dest){if(!dest){dest=v;}dest[0]=s/v[0];dest[1]=s/v[1];dest[2]=s/v[2];dest[3]=s/v[3];return dest;},/**
* Returns the dot product of two four-element vectors.
* @method dotVec4
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @return The dot product
*/dotVec4:function dotVec4(u,v){return u[0]*v[0]+u[1]*v[1]+u[2]*v[2]+u[3]*v[3];},/**
* Returns the cross product of two four-element vectors.
* @method cross3Vec4
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @return The cross product
*/cross3Vec4:function cross3Vec4(u,v){var u0=u[0];var u1=u[1];var u2=u[2];var v0=v[0];var v1=v[1];var v2=v[2];return[u1*v2-u2*v1,u2*v0-u0*v2,u0*v1-u1*v0,0.0];},/**
* Returns the cross product of two three-element vectors.
* @method cross3Vec3
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @return The cross product
*/cross3Vec3:function cross3Vec3(u,v,dest){if(!dest){dest=u;}var x=u[0];var y=u[1];var z=u[2];var x2=v[0];var y2=v[1];var z2=v[2];dest[0]=y*z2-z*y2;dest[1]=z*x2-x*z2;dest[2]=x*y2-y*x2;return dest;},sqLenVec4:function sqLenVec4(v){// TODO
return math.dotVec4(v,v);},/**
* Returns the length of a four-element vector.
* @method lenVec4
* @static
* @param {Array(Number)} v The vector
* @return The length
*/lenVec4:function lenVec4(v){return Math.sqrt(math.sqLenVec4(v));},/**
* Returns the dot product of two three-element vectors.
* @method dotVec3
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @return The dot product
*/dotVec3:function dotVec3(u,v){return u[0]*v[0]+u[1]*v[1]+u[2]*v[2];},/**
* Returns the dot product of two two-element vectors.
* @method dotVec4
* @static
* @param {Array(Number)} u First vector
* @param {Array(Number)} v Second vector
* @return The dot product
*/dotVec2:function dotVec2(u,v){return u[0]*v[0]+u[1]*v[1];},sqLenVec3:function sqLenVec3(v){return math.dotVec3(v,v);},sqLenVec2:function sqLenVec2(v){return math.dotVec2(v,v);},/**
* Returns the length of a three-element vector.
* @method lenVec3
* @static
* @param {Array(Number)} v The vector
* @return The length
*/lenVec3:function lenVec3(v){return Math.sqrt(math.sqLenVec3(v));},distVec3:function(){var vec=new FloatArrayType(3);return function(v,w){return math.lenVec3(math.subVec3(v,w,vec));};}(),/**
* Returns the length of a two-element vector.
* @method lenVec2
* @static
* @param {Array(Number)} v The vector
* @return The length
*/lenVec2:function lenVec2(v){return Math.sqrt(math.sqLenVec2(v));},distVec2:function(){var vec=new FloatArrayType(2);return function(v,w){return math.lenVec2(math.subVec2(v,w,vec));};}(),/**
* @method rcpVec3
* @static
* @param v vec3
* @param dest vec3 - optional destination
* @return [] dest if specified, v otherwise
*
*/rcpVec3:function rcpVec3(v,dest){return math.divScalarVec3(1.0,v,dest);},/**
* Normalizes a four-element vector
* @method normalizeVec4
* @static
* @param v vec4
* @param dest vec4 - optional destination
* @return [] dest if specified, v otherwise
*
*/normalizeVec4:function normalizeVec4(v,dest){var f=1.0/math.lenVec4(v);return math.mulVec4Scalar(v,f,dest);},/**
* Normalizes a three-element vector
* @method normalizeVec4
* @static
*/normalizeVec3:function normalizeVec3(v,dest){var f=1.0/math.lenVec3(v);return math.mulVec3Scalar(v,f,dest);},/**
* Normalizes a two-element vector
* @method normalizeVec2
* @static
*/normalizeVec2:function normalizeVec2(v,dest){var f=1.0/math.lenVec2(v);return math.mulVec2Scalar(v,f,dest);},/**
* Gets the angle between two vectors
* @method angleVec3
* @param v
* @param w
* @returns {number}
*/angleVec3:function angleVec3(v,w){var theta=math.dotVec3(v,w)/Math.sqrt(math.sqLenVec3(v)*math.sqLenVec3(w));theta=theta<-1?-1:theta>1?1:theta;// Clamp to handle numerical problems
return Math.acos(theta);},/**
* Creates a three-element vector from the rotation part of a sixteen-element matrix.
* @param m
* @param dest
*/vec3FromMat4Scale:function(){var tempVec3=new FloatArrayType(3);return function(m,dest){tempVec3[0]=m[0];tempVec3[1]=m[1];tempVec3[2]=m[2];dest[0]=math.lenVec3(tempVec3);tempVec3[0]=m[4];tempVec3[1]=m[5];tempVec3[2]=m[6];dest[1]=math.lenVec3(tempVec3);tempVec3[0]=m[8];tempVec3[1]=m[9];tempVec3[2]=m[10];dest[2]=math.lenVec3(tempVec3);return dest;};}(),/**
* Converts an n-element vector to a JSON-serializable
* array with values rounded to two decimal places.
*/vecToArray:function(){function trunc(v){return Math.round(v*100000)/100000;}return function(v){v=Array.prototype.slice.call(v);for(var _i5=0,len=v.length;_i5<len;_i5++){v[_i5]=trunc(v[_i5]);}return v;};}(),/**
* Converts a 3-element vector from an array to an object of the form ````{x:999, y:999, z:999}````.
* @param arr
* @returns {{x: *, y: *, z: *}}
*/xyzArrayToObject:function xyzArrayToObject(arr){return{x:arr[0],y:arr[1],z:arr[2]};},/**
* Converts a 3-element vector object of the form ````{x:999, y:999, z:999}```` to an array.
* @param xyz
* @param [arry]
* @returns {*[]}
*/xyzObjectToArray:function xyzObjectToArray(xyz,arry){arry=arry||math.vec3();arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;},/**
* Duplicates a 4x4 identity matrix.
* @method dupMat4
* @static
*/dupMat4:function dupMat4(m){return m.slice(0,16);},/**
* Extracts a 3x3 matrix from a 4x4 matrix.
* @method mat4To3
* @static
*/mat4To3:function mat4To3(m){return[m[0],m[1],m[2],m[4],m[5],m[6],m[8],m[9],m[10]];},/**
* Returns a 4x4 matrix with each element set to the given scalar value.
* @method m4s
* @static
*/m4s:function m4s(s){return[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s];},/**
* Returns a 4x4 matrix with each element set to zero.
* @method setMat4ToZeroes
* @static
*/setMat4ToZeroes:function setMat4ToZeroes(){return math.m4s(0.0);},/**
* Returns a 4x4 matrix with each element set to 1.0.
* @method setMat4ToOnes
* @static
*/setMat4ToOnes:function setMat4ToOnes(){return math.m4s(1.0);},/**
* Returns a 4x4 matrix with each element set to 1.0.
* @method setMat4ToOnes
* @static
*/diagonalMat4v:function diagonalMat4v(v){return new FloatArrayType([v[0],0.0,0.0,0.0,0.0,v[1],0.0,0.0,0.0,0.0,v[2],0.0,0.0,0.0,0.0,v[3]]);},/**
* Returns a 4x4 matrix with diagonal elements set to the given vector.
* @method diagonalMat4c
* @static
*/diagonalMat4c:function diagonalMat4c(x,y,z,w){return math.diagonalMat4v([x,y,z,w]);},/**
* Returns a 4x4 matrix with diagonal elements set to the given scalar.
* @method diagonalMat4s
* @static
*/diagonalMat4s:function diagonalMat4s(s){return math.diagonalMat4c(s,s,s,s);},/**
* Returns a 4x4 identity matrix.
* @method identityMat4
* @static
*/identityMat4:function identityMat4(){var mat=arguments.length>0&&arguments[0]!==undefined?arguments[0]:new FloatArrayType(16);mat[0]=1.0;mat[1]=0.0;mat[2]=0.0;mat[3]=0.0;mat[4]=0.0;mat[5]=1.0;mat[6]=0.0;mat[7]=0.0;mat[8]=0.0;mat[9]=0.0;mat[10]=1.0;mat[11]=0.0;mat[12]=0.0;mat[13]=0.0;mat[14]=0.0;mat[15]=1.0;return mat;},/**
* Returns a 3x3 identity matrix.
* @method identityMat3
* @static
*/identityMat3:function identityMat3(){var mat=arguments.length>0&&arguments[0]!==undefined?arguments[0]:new FloatArrayType(9);mat[0]=1.0;mat[1]=0.0;mat[2]=0.0;mat[3]=0.0;mat[4]=1.0;mat[5]=0.0;mat[6]=0.0;mat[7]=0.0;mat[8]=1.0;return mat;},/**
* Tests if the given 4x4 matrix is the identity matrix.
* @method isIdentityMat4
* @static
*/isIdentityMat4:function isIdentityMat4(m){if(m[0]!==1.0||m[1]!==0.0||m[2]!==0.0||m[3]!==0.0||m[4]!==0.0||m[5]!==1.0||m[6]!==0.0||m[7]!==0.0||m[8]!==0.0||m[9]!==0.0||m[10]!==1.0||m[11]!==0.0||m[12]!==0.0||m[13]!==0.0||m[14]!==0.0||m[15]!==1.0){return false;}return true;},/**
* Negates the given 4x4 matrix.
* @method negateMat4
* @static
*/negateMat4:function negateMat4(m,dest){if(!dest){dest=m;}dest[0]=-m[0];dest[1]=-m[1];dest[2]=-m[2];dest[3]=-m[3];dest[4]=-m[4];dest[5]=-m[5];dest[6]=-m[6];dest[7]=-m[7];dest[8]=-m[8];dest[9]=-m[9];dest[10]=-m[10];dest[11]=-m[11];dest[12]=-m[12];dest[13]=-m[13];dest[14]=-m[14];dest[15]=-m[15];return dest;},/**
* Adds the given 4x4 matrices together.
* @method addMat4
* @static
*/addMat4:function addMat4(a,b,dest){if(!dest){dest=a;}dest[0]=a[0]+b[0];dest[1]=a[1]+b[1];dest[2]=a[2]+b[2];dest[3]=a[3]+b[3];dest[4]=a[4]+b[4];dest[5]=a[5]+b[5];dest[6]=a[6]+b[6];dest[7]=a[7]+b[7];dest[8]=a[8]+b[8];dest[9]=a[9]+b[9];dest[10]=a[10]+b[10];dest[11]=a[11]+b[11];dest[12]=a[12]+b[12];dest[13]=a[13]+b[13];dest[14]=a[14]+b[14];dest[15]=a[15]+b[15];return dest;},/**
* Adds the given scalar to each element of the given 4x4 matrix.
* @method addMat4Scalar
* @static
*/addMat4Scala