@cognite/3d-camera-controls
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cognite=e():t.cognite=e()}(window,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=44)}([function(t,e){var n=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=n)},function(t,e,n){t.exports=!n(2)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){var n=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:n)(t)}},function(t,e,n){var i=n(24),r=n(7);t.exports=function(t){return i(r(t))}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var i=n(36),r=n(35),s=n(33),o=Object.defineProperty;e.f=n(1)?Object.defineProperty:function(t,e,n){if(i(t),e=s(e,!0),i(n),r)try{return o(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var i=n(4),r=n(0),s=n(39),o=n(37),a=n(8),h=function(t,e,n){var c,u,l,d=t&h.F,f=t&h.G,p=t&h.S,m=t&h.P,v=t&h.B,g=t&h.W,y=f?r:r[e]||(r[e]={}),E=y.prototype,b=f?i:p?i[e]:(i[e]||{}).prototype;for(c in f&&(n=e),n)(u=!d&&b&&void 0!==b[c])&&a(y,c)||(l=u?b[c]:n[c],y[c]=f&&"function"!=typeof b[c]?n[c]:v&&u?s(l,i):g&&b[c]==l?function(t){var e=function(e,n,i){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,i)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(l):m&&"function"==typeof l?s(Function.call,l):l,m&&((y.virtual||(y.virtual={}))[c]=l,t&h.R&&E&&!E[c]&&o(E,c,l)))};h.F=1,h.G=2,h.S=4,h.P=8,h.B=16,h.W=32,h.U=64,h.R=128,t.exports=h},function(t,e,n){"use strict";e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){t.exports=function(t){var e=n.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)};var n=Object.prototype.toString},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.KeyMapUS={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause/break",20:"capslock",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"leftwindow",92:"rightwindow",93:"select",96:"numpad-0",97:"numpad-1",98:"numpad-2",99:"numpad-3",100:"numpad-4",101:"numpad-5",102:"numpad-6",103:"numpad-7",104:"numpad-8",105:"numpad-9",106:"multiply",107:"add",109:"subtract",110:"decimalpoint",111:"divide",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:"semicolon",187:"equals",188:"comma",189:"dash",190:"period",191:"forwardslash",192:"graveaccent",219:"openbracket",220:"backslash",221:"closebraket",222:"singlequote"}},function(t,e,n){var i=n(10),r=n(0),s=n(2);t.exports=function(t,e){var n=(r.Object||{})[t]||Object[t],o={};o[t]=e(n),i(i.S+i.F*s(function(){n(1)}),"Object",o)}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e){var n=0,i=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+i).toString(36))}},function(t,e){t.exports=!0},function(t,e,n){var i=n(0),r=n(4),s=r["__core-js_shared__"]||(r["__core-js_shared__"]={});(t.exports=function(t,e){return s[t]||(s[t]=void 0!==e?e:{})})("versions",[]).push({version:i.version,mode:n(17)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,e,n){var i=n(18)("keys"),r=n(16);t.exports=function(t){return i[t]||(i[t]=r(t))}},function(t,e,n){var i=n(5),r=Math.max,s=Math.min;t.exports=function(t,e){return(t=i(t))<0?r(t+e,0):s(t,e)}},function(t,e,n){var i=n(5),r=Math.min;t.exports=function(t){return t>0?r(i(t),9007199254740991):0}},function(t,e,n){var i=n(6),r=n(21),s=n(20);t.exports=function(t){return function(e,n,o){var a,h=i(e),c=r(h.length),u=s(o,c);if(t&&n!=n){for(;c>u;)if((a=h[u++])!=a)return!0}else for(;c>u;u++)if((t||u in h)&&h[u]===n)return t||u||0;return!t&&-1}}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var i=n(23);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==i(t)?t.split(""):Object(t)}},function(t,e,n){var i=n(8),r=n(6),s=n(22)(!1),o=n(19)("IE_PROTO");t.exports=function(t,e){var n,a=r(t),h=0,c=[];for(n in a)n!=o&&i(a,n)&&c.push(n);for(;e.length>h;)i(a,n=e[h++])&&(~s(c,n)||c.push(n));return c}},function(t,e,n){var i=n(25),r=n(15);t.exports=Object.keys||function(t){return i(t,r)}},function(t,e,n){var i=n(7);t.exports=function(t){return Object(i(t))}},function(t,e,n){var i=n(27),r=n(26);n(14)("keys",function(){return function(t){return r(i(t))}})},function(t,e,n){n(28),t.exports=n(0).Object.keys},function(t,e,n){t.exports={default:n(29),__esModule:!0}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=s(n(30)),r=s(n(11));function s(t){return t&&t.__esModule?t:{default:t}}e.default=function t(e){var n=this;(0,r.default)(this,t),this.isPressed=function(t){return n.keys[t]>=1},this.comsumePressed=function(t){var e=2===n.keys[t];return e&&(n.keys[t]=1),e},this.keys={},(0,i.default)(e).forEach(function(t){n.keys[e[t]]=0}),window.addEventListener("keydown",function(t){t.keyCode in e&&0===n.keys[e[t.keyCode]]&&(n.keys[e[t.keyCode]]=2)}),window.addEventListener("keyup",function(t){t.keyCode in e&&(n.keys[e[t.keyCode]]=0)}),window.addEventListener("blur",function(){(0,i.default)(n.keys).forEach(function(t){n.keys[t]=0})})}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var i=n(3);t.exports=function(t,e){if(!i(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!i(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}},function(t,e,n){var i=n(3),r=n(4).document,s=i(r)&&i(r.createElement);t.exports=function(t){return s?r.createElement(t):{}}},function(t,e,n){t.exports=!n(1)&&!n(2)(function(){return 7!=Object.defineProperty(n(34)("div"),"a",{get:function(){return 7}}).a})},function(t,e,n){var i=n(3);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},function(t,e,n){var i=n(9),r=n(32);t.exports=n(1)?function(t,e,n){return i.f(t,e,r(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var i=n(38);t.exports=function(t,e,n){if(i(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,r){return t.call(e,n,i,r)}}return function(){return t.apply(e,arguments)}}},function(t,e,n){var i=n(10);i(i.S+i.F*!n(1),"Object",{defineProperty:n(9).f})},function(t,e,n){n(40);var i=n(0).Object;t.exports=function(t,e,n){return i.defineProperty(t,e,n)}},function(t,e,n){t.exports={default:n(41),__esModule:!0}},function(t,e,n){"use strict";e.__esModule=!0;var i,r=n(42),s=(i=r)&&i.__esModule?i:{default:i};e.default=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),(0,s.default)(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CameraControls=void 0;var i=h(n(11)),r=h(n(43)),s=h(n(31)),o=n(13),a=h(n(12));function h(t){return t&&t.__esModule?t:{default:t}}var c=void 0,u={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5,ROTATE_FP:6,FP_NAVIGATE:7},l=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");e.CameraControls=function(){function t(e,n){var r=this;(0,i.default)(this,t),this.on=function(t,e){var n=r.eventListeners;if(!(0,a.default)(e))throw new Error("func parameter is not a function");if(null==n[t])throw new Error("Invalid type parameter: "+t);n[t].push(e)},this.off=function(t,e){var n=r.eventListeners;if(!(0,a.default)(e))throw new Error("func parameter is not a function");if(null==n[t])throw new Error("Invalid type parameter: "+t);var i=n[t].indexOf(e);-1!==i&&n[t].splice(i,1)},this.object=e,this.domElement=n,this.enabled=!0,this.minDistance=0,this.maxDistance=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.dampingFactor=.5,this.draggingDampingFactor=.1,this.minZoomDistance=.3,this.maxZoomDistance=1,this.panSpeed=30,this.minPanDistance=1,this.rotationSpeed=.005,this.enableKeyboardNavigation=!0,this.minDistToTarget=2,this.target=new c.Vector3,this.targetEnd=new c.Vector3,this.spherical=new c.Spherical,this.spherical.setFromVector3(this.object.position),this.sphericalEnd=(new c.Spherical).copy(this.spherical),this.state=u.NONE,this.keyboard=new s.default(o.KeyMapUS),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.wasdKeys=["w","a","s","d"],this.mouse=new c.Vector2,this.plane=new c.Plane,this.line3=new c.Line3,this.v3=new c.Vector3,this.raycaster=new c.Raycaster,this.xColumn=new c.Vector3,this.yColumn=new c.Vector3,this.dragStart=new c.Vector2,this.dollyStart=new c.Vector2,this.onMouseDown=this.onMouseDown.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onMouseWheel=this.onMouseWheel.bind(this),this.onContextMenu=this.onContextMenu.bind(this),this.dragging=this.dragging.bind(this),this.startDragging=this.startDragging.bind(this),this.endDragging=this.endDragging.bind(this),this.eventListeners={cameraChanged:[]},this.needsUpdate=!0,this.update(),this.domElement?(this.domElement.addEventListener("mousedown",this.onMouseDown),this.domElement.addEventListener("touchstart",this.onTouchStart),this.domElement.addEventListener("wheel",this.onMouseWheel),this.domElement.addEventListener("DOMMouseScroll",this.onMouseWheel),this.domElement.addEventListener("contextmenu",this.onContextMenu),this.dispose=function(){r.domElement.removeEventListener("mousedown",r.onMouseDown),r.domElement.removeEventListener("touchstart",r.onTouchStart),r.domElement.removeEventListener("wheel",r.onMouseWheel),r.domElement.removeEventListener("DOMMouseScroll",r.onMouseWheel),r.domElement.removeEventListener("contextmenu",r.onContextMenu),document.removeEventListener("mousemove",r.dragging),document.removeEventListener("touchmove",r.dragging),document.removeEventListener("mouseup",r.endDragging),document.removeEventListener("touchend",r.endDragging)}):this.dispose=function(){}}return(0,r.default)(t,null,[{key:"install",value:function(t){c=t}}]),(0,r.default)(t,[{key:"onMouseDown",value:function(t){var e=this;if(this.enabled){t.preventDefault();var n=this.state;switch(this.elementRect=this.domElement.getBoundingClientRect(),t.button){case c.MOUSE.LEFT:var i=this.keyboard.isPressed("shift");if(this.state=i?u.ROTATE_FP:u.ROTATE,this.state===u.ROTATE)this.wasdKeys.filter(function(t){return e.keyboard.isPressed(t)}).length>0&&(this.state=u.ROTATE_FP);break;case c.MOUSE.MIDDLE:this.state=u.DOLLY;break;case c.MOUSE.RIGHT:this.state=u.PAN}n===u.NONE&&this.startDragging(t)}}},{key:"onTouchStart",value:function(t){if(this.enabled){t.preventDefault(),this.elementRect=this.domElement.getBoundingClientRect();var e=this.state;switch(t.touches.length){case 1:this.state=u.TOUCH_ROTATE;break;case 2:this.state=u.TOUCH_DOLLY;break;case 3:this.state=u.TOUCH_PAN}e===u.NONE&&this.startDragging(t)}}},{key:"onMouseWheel",value:function(t){if(this.enabled){t.preventDefault();var e=t.offsetX/this.domElement.clientWidth*2-1,n=-t.offsetY/this.domElement.clientHeight*2+1,i=0;if(t.wheelDelta)i=-t.wheelDelta/40;else if(t.detail)i=t.detail;else if(t.deltaY){var r=l?1:40;i=t.deltaY/r}i<0?this.dollyIn(e,n,Math.abs(i)):this.dollyOut(e,n,Math.abs(i))}}},{key:"checkKeyboardEvents",value:function(){var t=this;if(this.enabled&&this.enableKeyboardNavigation){var e=this.keyboard,n=e.isPressed("shift"),i=n?2:.6,r=function(e,n){var r=t.getZoomDistance(!0,i);t.pan(e*r,n*r,!0)},s=!1,o=function(){s=!0};e.isPressed("w")&&(o(),this.dollyIn(0,0,i)),e.isPressed("s")&&(o(),this.dollyOut(0,0,i)),e.isPressed("a")&&(o(),r(1,0)),e.isPressed("d")&&(o(),r(-1,0)),e.isPressed("e")&&(o(),r(0,1)),e.isPressed("q")&&(o(),r(0,-1));var a=n?10:5;e.isPressed("left")&&(o(),this.rotatetFP(a,0)),e.isPressed("up")&&(o(),this.rotatetFP(0,.5*a)),e.isPressed("down")&&(o(),this.rotatetFP(0,.5*-a)),e.isPressed("right")&&(o(),this.rotatetFP(-a,0)),s&&(this.needsUpdate=!0)}}},{key:"onContextMenu",value:function(t){this.enabled&&t.preventDefault()}},{key:"startDragging",value:function(t){if(this.enabled){t.preventDefault();var e=t.touches?t.touches[0]:t,n=e.clientX,i=e.clientY;if(this.dragStart.set(n,i),this.state===u.TOUCH_DOLLY){var r=n-t.touches[1].pageX,s=i-t.touches[1].pageY,o=Math.sqrt(r*r+s*s);this.dollyStart.set(0,o)}this.dampingFactor=this.draggingDampingFactor,document.addEventListener("mousemove",this.dragging,{passive:!1}),document.addEventListener("touchmove",this.dragging,{passive:!1}),document.addEventListener("mouseup",this.endDragging),document.addEventListener("touchend",this.endDragging)}}},{key:"dragging",value:function(t){if(this.enabled){t.preventDefault();var e=t.touches?t.touches[0]:t,n=e.clientX,i=e.clientY,r=this.dragStart.x-n,s=this.dragStart.y-i;switch(this.dragStart.set(n,i),this.state){case u.ROTATE:case u.TOUCH_ROTATE:var o=2*Math.PI*r/this.elementRect.width,a=2*Math.PI*s/this.elementRect.height;this.rotate(o,a,!0);break;case u.DOLLY:break;case u.TOUCH_DOLLY:var h=n-t.touches[1].pageX,c=i-t.touches[1].pageY,l=Math.sqrt(h*h+c*c),d=this.dollyStart.y-l,f=(n+t.touches[1].pageX)/2,p=(i+t.touches[1].pageY)/2,m=f/this.domElement.clientWidth*2-1,v=-p/this.domElement.clientHeight*2+1;d>0?this.dollyOut(m,v):d<0&&this.dollyIn(m,v),this.dollyStart.set(0,l);break;case u.PAN:case u.TOUCH_PAN:var g=this.getZoomDistance(!0,1),y=-g*this.panSpeed*(r/this.elementRect.height),E=-g*this.panSpeed*(s/this.elementRect.height);this.pan(y,E,!0);break;case u.ROTATE_FP:this.rotatetFP(r,s)}}}},{key:"endDragging",value:function(){this.enabled&&(this.dampingFactor=this.dampingFactor,this.state=u.NONE,document.removeEventListener("mousemove",this.dragging),document.removeEventListener("touchmove",this.dragging),document.removeEventListener("mouseup",this.endDragging),document.removeEventListener("touchend",this.endDragging))}},{key:"dollyIn",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.dolly(this.getZoomDistance(!0,n),!0,t,e)}},{key:"dollyOut",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.dolly(this.getZoomDistance(!1,n),!0,t,e)}},{key:"rotate",value:function(t,e,n){this.rotateTo(this.sphericalEnd.theta+t,this.sphericalEnd.phi+e,n)}},{key:"rotateTo",value:function(t,e,n){var i=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,t)),r=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,e));this.sphericalEnd.theta=i,this.sphericalEnd.phi=r,this.sphericalEnd.radius=this.spherical.radius,this.sphericalEnd.makeSafe(),this.targetEnd.copy(this.target),n||(this.spherical.theta=this.sphericalEnd.theta,this.spherical.phi=this.sphericalEnd.phi),this.needsUpdate=!0}},{key:"rotatetFP",value:function(t,e){var n=this.object.clone();n.position.setFromSpherical(this.sphericalEnd).add(this.targetEnd),n.lookAt(this.targetEnd),n.rotateY(t*this.rotationSpeed),n.rotateX(e*this.rotationSpeed);var i=new c.Vector3;n.getWorldDirection(i),this.v3.subVectors(this.targetEnd,n.position);var r=this.targetEnd.distanceTo(n.position);this.targetEnd.addVectors(n.position,i.multiplyScalar(r)),this.sphericalEnd.setFromVector3(this.v3.subVectors(n.position,this.targetEnd)),function(t,e){for(var n=2*Math.PI,i=.5*n;Math.abs(t.theta-e.theta)>i;)t.theta+=t.theta<e.theta?n:-n}(this.sphericalEnd,this.spherical),this.needsUpdate=!0}},{key:"getZoomDistance",value:function(t,e){var n=this.sphericalEnd.radius,i=void 0,r=this.minDistToTarget,s=100*r;if(n<=this.minDistToTarget)i=this.minZoomDistance;else if(n>=s)i=this.maxZoomDistance;else{var o=(this.maxZoomDistance-this.minZoomDistance)/(s-r);i=this.minZoomDistance+o*(n-r)}return t&&(i=-i),i*=e}},{key:"dolly",value:function(t,e,n,i){this.dollyTo(this.sphericalEnd.radius+t,e,n,i)}},{key:"dollyTo",value:function(t,e,n,i){var r=c.Math.clamp(t,this.minDistance,this.maxDistance),s=this.sphericalEnd.radius-r;this.mouse.set(n,i);var o=this.object.clone();o.position.setFromSpherical(this.sphericalEnd).add(this.targetEnd),o.lookAt(this.targetEnd),this.raycaster.setFromCamera(this.mouse,o);var a=new c.Vector3;o.getWorldDirection(a);var h=this.plane;h.setFromNormalAndCoplanarPoint(a,this.targetEnd);var u=this.raycaster.ray.direction.clone().multiplyScalar(s);o.position.add(u);var l=this.line3,d=-h.distanceToPoint(o.position);l.set(o.position,o.position.clone().add(a.clone().multiplyScalar(2*d))),h.intersectLine(l,this.targetEnd),this.sphericalEnd.radius=this.targetEnd.distanceTo(o.position);var f=this.minDistToTarget-this.sphericalEnd.radius;if(f>0){var p=new c.Vector3;o.getWorldDirection(p),this.targetEnd.add(p.multiplyScalar(f)),this.sphericalEnd.radius=this.minDistToTarget}e||(this.spherical.radius=this.sphericalEnd.radius,this.update()),this.needsUpdate=!0}},{key:"pan",value:function(t,e,n){var i=this.object.clone();i.position.setFromSpherical(this.sphericalEnd).add(this.targetEnd),i.lookAt(this.targetEnd),i.updateMatrix(),this.xColumn.setFromMatrixColumn(i.matrix,0),this.yColumn.setFromMatrixColumn(i.matrix,1),this.xColumn.multiplyScalar(t),this.yColumn.multiplyScalar(-e);var r=this.v3.copy(this.xColumn).add(this.yColumn);this.targetEnd.add(r),n||this.target.copy(this.targetEnd),this.needsUpdate=!0}},{key:"moveTo",value:function(t,e,n,i){this.targetEnd.set(t,e,n),i||this.target.copy(this.targetEnd),this.needsUpdate=!0}},{key:"getState",value:function(){return this.state}},{key:"reset",value:function(t){this.targetEnd.copy(this.target0),this.sphericalEnd.setFromVector3(this.position0),this.sphericalEnd.theta=this.sphericalEnd.theta%(2*Math.PI),this.spherical.theta=this.spherical.theta%(2*Math.PI),t||(this.target.copy(this.targetEnd),this.spherical.copy(this.sphericalEnd)),this.needsUpdate=!0}},{key:"getCameraPosition",value:function(){var t=this.target.clone(),e=new c.Vector3;return e.setFromSpherical(this.spherical).add(t),{position:e,target:t}}},{key:"setCameraPosition",value:function(t,e){this.target0.copy(e),this.position0.copy(t.clone().sub(e)),this.reset()}},{key:"update",value:function(t){var e=this,n=1;null!=t&&(n=this.dampingFactor*t/.016),n=c.Math.clamp(n,0,1);var i=this.sphericalEnd.theta-this.spherical.theta,r=this.sphericalEnd.phi-this.spherical.phi,s=this.sphericalEnd.radius-this.spherical.radius,o=(new c.Vector3).subVectors(this.targetEnd,this.target);Math.abs(i)>.001||Math.abs(r)>.001||Math.abs(s)>.001||Math.abs(o.x)>.001||Math.abs(o.y)>.001||Math.abs(o.z)>.001?(this.spherical.set(this.spherical.radius+s*n,this.spherical.phi+r*n,this.spherical.theta+i*n),this.target.add(o.multiplyScalar(n)),this.needsUpdate=!0):(this.spherical.copy(this.sphericalEnd),this.target.copy(this.targetEnd)),this.spherical.makeSafe(),this.object.position.setFromSpherical(this.spherical).add(this.target),this.object.lookAt(this.target),this.checkKeyboardEvents();var a=this.needsUpdate;return a&&this.eventListeners.cameraChanged.forEach(function(t){t(e.object.position,e.target)}),this.needsUpdate=!1,a}}]),t}()}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cognite=e():t.cognite=e()}(window,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=44)}([function(t,e){var n=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=n)},function(t,e,n){t.exports=!n(2)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){var n=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:n)(t)}},function(t,e,n){var i=n(24),r=n(7);t.exports=function(t){return i(r(t))}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var i=n(36),r=n(35),s=n(33),o=Object.defineProperty;e.f=n(1)?Object.defineProperty:function(t,e,n){if(i(t),e=s(e,!0),i(n),r)try{return o(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var i=n(4),r=n(0),s=n(39),o=n(37),a=n(8),h=function(t,e,n){var c,u,l,d=t&h.F,f=t&h.G,p=t&h.S,m=t&h.P,v=t&h.B,g=t&h.W,y=f?r:r[e]||(r[e]={}),E=y.prototype,b=f?i:p?i[e]:(i[e]||{}).prototype;for(c in f&&(n=e),n)(u=!d&&b&&void 0!==b[c])&&a(y,c)||(l=u?b[c]:n[c],y[c]=f&&"function"!=typeof b[c]?n[c]:v&&u?s(l,i):g&&b[c]==l?function(t){var e=function(e,n,i){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,i)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(l):m&&"function"==typeof l?s(Function.call,l):l,m&&((y.virtual||(y.virtual={}))[c]=l,t&h.R&&E&&!E[c]&&o(E,c,l)))};h.F=1,h.G=2,h.S=4,h.P=8,h.B=16,h.W=32,h.U=64,h.R=128,t.exports=h},function(t,e,n){"use strict";e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){t.exports=function(t){var e=n.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)};var n=Object.prototype.toString},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.KeyMapUS={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause/break",20:"capslock",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"leftwindow",92:"rightwindow",93:"select",96:"numpad-0",97:"numpad-1",98:"numpad-2",99:"numpad-3",100:"numpad-4",101:"numpad-5",102:"numpad-6",103:"numpad-7",104:"numpad-8",105:"numpad-9",106:"multiply",107:"add",109:"subtract",110:"decimalpoint",111:"divide",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:"semicolon",187:"equals",188:"comma",189:"dash",190:"period",191:"forwardslash",192:"graveaccent",219:"openbracket",220:"backslash",221:"closebraket",222:"singlequote"}},function(t,e,n){var i=n(10),r=n(0),s=n(2);t.exports=function(t,e){var n=(r.Object||{})[t]||Object[t],o={};o[t]=e(n),i(i.S+i.F*s(function(){n(1)}),"Object",o)}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e){var n=0,i=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+i).toString(36))}},function(t,e){t.exports=!0},function(t,e,n){var i=n(0),r=n(4),s=r["__core-js_shared__"]||(r["__core-js_shared__"]={});(t.exports=function(t,e){return s[t]||(s[t]=void 0!==e?e:{})})("versions",[]).push({version:i.version,mode:n(17)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,e,n){var i=n(18)("keys"),r=n(16);t.exports=function(t){return i[t]||(i[t]=r(t))}},function(t,e,n){var i=n(5),r=Math.max,s=Math.min;t.exports=function(t,e){return(t=i(t))<0?r(t+e,0):s(t,e)}},function(t,e,n){var i=n(5),r=Math.min;t.exports=function(t){return t>0?r(i(t),9007199254740991):0}},function(t,e,n){var i=n(6),r=n(21),s=n(20);t.exports=function(t){return function(e,n,o){var a,h=i(e),c=r(h.length),u=s(o,c);if(t&&n!=n){for(;c>u;)if((a=h[u++])!=a)return!0}else for(;c>u;u++)if((t||u in h)&&h[u]===n)return t||u||0;return!t&&-1}}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var i=n(23);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==i(t)?t.split(""):Object(t)}},function(t,e,n){var i=n(8),r=n(6),s=n(22)(!1),o=n(19)("IE_PROTO");t.exports=function(t,e){var n,a=r(t),h=0,c=[];for(n in a)n!=o&&i(a,n)&&c.push(n);for(;e.length>h;)i(a,n=e[h++])&&(~s(c,n)||c.push(n));return c}},function(t,e,n){var i=n(25),r=n(15);t.exports=Object.keys||function(t){return i(t,r)}},function(t,e,n){var i=n(7);t.exports=function(t){return Object(i(t))}},function(t,e,n){var i=n(27),r=n(26);n(14)("keys",function(){return function(t){return r(i(t))}})},function(t,e,n){n(28),t.exports=n(0).Object.keys},function(t,e,n){t.exports={default:n(29),__esModule:!0}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=s(n(30)),r=s(n(11));function s(t){return t&&t.__esModule?t:{default:t}}e.default=function t(e){var n=this;(0,r.default)(this,t),this.isPressed=function(t){return n.keys[t]>=1},this.comsumePressed=function(t){var e=2===n.keys[t];return e&&(n.keys[t]=1),e},this.keys={},(0,i.default)(e).forEach(function(t){n.keys[e[t]]=0}),window.addEventListener("keydown",function(t){t.keyCode in e&&0===n.keys[e[t.keyCode]]&&(n.keys[e[t.keyCode]]=2)}),window.addEventListener("keyup",function(t){t.keyCode in e&&(n.keys[e[t.keyCode]]=0)}),window.addEventListener("blur",function(){(0,i.default)(n.keys).forEach(function(t){n.keys[t]=0})})}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var i=n(3);t.exports=function(t,e){if(!i(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!i(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}},function(t,e,n){var i=n(3),r=n(4).document,s=i(r)&&i(r.createElement);t.exports=function(t){return s?r.createElement(t):{}}},function(t,e,n){t.exports=!n(1)&&!n(2)(function(){return 7!=Object.defineProperty(n(34)("div"),"a",{get:function(){return 7}}).a})},function(t,e,n){var i=n(3);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},function(t,e,n){var i=n(9),r=n(32);t.exports=n(1)?function(t,e,n){return i.f(t,e,r(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var i=n(38);t.exports=function(t,e,n){if(i(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,r){return t.call(e,n,i,r)}}return function(){return t.apply(e,arguments)}}},function(t,e,n){var i=n(10);i(i.S+i.F*!n(1),"Object",{defineProperty:n(9).f})},function(t,e,n){n(40);var i=n(0).Object;t.exports=function(t,e,n){return i.defineProperty(t,e,n)}},function(t,e,n){t.exports={default:n(41),__esModule:!0}},function(t,e,n){"use strict";e.__esModule=!0;var i,r=n(42),s=(i=r)&&i.__esModule?i:{default:i};e.default=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),(0,s.default)(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CameraControls=void 0;var i=h(n(11)),r=h(n(43)),s=h(n(31)),o=n(13),a=h(n(12));function h(t){return t&&t.__esModule?t:{default:t}}var c=void 0,u={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5,ROTATE_FP:6,FP_NAVIGATE:7},l=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");e.CameraControls=function(){function t(e,n){var r=this;(0,i.default)(this,t),this.on=function(t,e){var n=r.eventListeners;if(!(0,a.default)(e))throw new Error("func parameter is not a function");if(null==n[t])throw new Error("Invalid type parameter: "+t);n[t].push(e)},this.off=function(t,e){var n=r.eventListeners;if(!(0,a.default)(e))throw new Error("func parameter is not a function");if(null==n[t])throw new Error("Invalid type parameter: "+t);var i=n[t].indexOf(e);-1!==i&&n[t].splice(i,1)},this.object=e,this.domElement=n,this.enabled=!0,this.minDistance=0,this.maxDistance=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.dampingFactor=.5,this.draggingDampingFactor=.1,this.minZoomDistance=.3,this.maxZoomDistance=1,this.panSpeed=30,this.minPanDistance=1,this.rotationSpeed=.005,this.enableKeyboardNavigation=!0,this.minDistToTarget=2,this.target=new c.Vector3,this.targetEnd=new c.Vector3,this.spherical=new c.Spherical,this.spherical.setFromVector3(this.object.position),this.sphericalEnd=(new c.Spherical).copy(this.spherical),this.state=u.NONE,this.keyboard=new s.default(o.KeyMapUS),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.wasdKeys=["w","a","s","d"],this.mouse=new c.Vector2,this.plane=new c.Plane,this.line3=new c.Line3,this.v3=new c.Vector3,this.raycaster=new c.Raycaster,this.xColumn=new c.Vector3,this.yColumn=new c.Vector3,this.dragStart=new c.Vector2,this.dollyStart=new c.Vector2,this.onMouseDown=this.onMouseDown.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onMouseWheel=this.onMouseWheel.bind(this),this.onContextMenu=this.onContextMenu.bind(this),this.dragging=this.dragging.bind(this),this.startDragging=this.startDragging.bind(this),this.endDragging=this.endDragging.bind(this),this.eventListeners={cameraChange:[]},this.needsUpdate=!0,this.update(),this.domElement?(this.domElement.addEventListener("mousedown",this.onMouseDown),this.domElement.addEventListener("touchstart",this.onTouchStart),this.domElement.addEventListener("wheel",this.onMouseWheel),this.domElement.addEventListener("DOMMouseScroll",this.onMouseWheel),this.domElement.addEventListener("contextmenu",this.onContextMenu),this.dispose=function(){r.domElement.removeEventListener("mousedown",r.onMouseDown),r.domElement.removeEventListener("touchstart",r.onTouchStart),r.domElement.removeEventListener("wheel",r.onMouseWheel),r.domElement.removeEventListener("DOMMouseScroll",r.onMouseWheel),r.domElement.removeEventListener("contextmenu",r.onContextMenu),document.removeEventListener("mousemove",r.dragging),document.removeEventListener("touchmove",r.dragging),document.removeEventListener("mouseup",r.endDragging),document.removeEventListener("touchend",r.endDragging)}):this.dispose=function(){}}return(0,r.default)(t,null,[{key:"install",value:function(t){c=t}}]),(0,r.default)(t,[{key:"onMouseDown",value:function(t){var e=this;if(this.enabled){t.preventDefault();var n=this.state;switch(this.elementRect=this.domElement.getBoundingClientRect(),t.button){case c.MOUSE.LEFT:var i=this.keyboard.isPressed("shift");if(this.state=i?u.ROTATE_FP:u.ROTATE,this.state===u.ROTATE)this.wasdKeys.filter(function(t){return e.keyboard.isPressed(t)}).length>0&&(this.state=u.ROTATE_FP);break;case c.MOUSE.MIDDLE:this.state=u.DOLLY;break;case c.MOUSE.RIGHT:this.state=u.PAN}n===u.NONE&&this.startDragging(t)}}},{key:"onTouchStart",value:function(t){if(this.enabled){t.preventDefault(),this.elementRect=this.domElement.getBoundingClientRect();var e=this.state;switch(t.touches.length){case 1:this.state=u.TOUCH_ROTATE;break;case 2:this.state=u.TOUCH_DOLLY;break;case 3:this.state=u.TOUCH_PAN}e===u.NONE&&this.startDragging(t)}}},{key:"onMouseWheel",value:function(t){if(this.enabled){t.preventDefault();var e=t.offsetX/this.domElement.clientWidth*2-1,n=-t.offsetY/this.domElement.clientHeight*2+1,i=0;if(t.wheelDelta)i=-t.wheelDelta/40;else if(t.detail)i=t.detail;else if(t.deltaY){var r=l?1:40;i=t.deltaY/r}i<0?this.dollyIn(e,n,Math.abs(i)):this.dollyOut(e,n,Math.abs(i))}}},{key:"checkKeyboardEvents",value:function(){var t=this;if(this.enabled&&this.enableKeyboardNavigation){var e=this.keyboard,n=e.isPressed("shift"),i=n?2:.6,r=function(e,n){var r=t.getZoomDistance(!0,i);t.pan(e*r,n*r,!0)},s=!1,o=function(){s=!0};e.isPressed("w")&&(o(),this.dollyIn(0,0,i)),e.isPressed("s")&&(o(),this.dollyOut(0,0,i)),e.isPressed("a")&&(o(),r(1,0)),e.isPressed("d")&&(o(),r(-1,0)),e.isPressed("e")&&(o(),r(0,1)),e.isPressed("q")&&(o(),r(0,-1));var a=n?10:5;e.isPressed("left")&&(o(),this.rotatetFP(a,0)),e.isPressed("up")&&(o(),this.rotatetFP(0,.5*a)),e.isPressed("down")&&(o(),this.rotatetFP(0,.5*-a)),e.isPressed("right")&&(o(),this.rotatetFP(-a,0)),s&&(this.needsUpdate=!0)}}},{key:"onContextMenu",value:function(t){this.enabled&&t.preventDefault()}},{key:"startDragging",value:function(t){if(this.enabled){t.preventDefault();var e=t.touches?t.touches[0]:t,n=e.clientX,i=e.clientY;if(this.dragStart.set(n,i),this.state===u.TOUCH_DOLLY){var r=n-t.touches[1].pageX,s=i-t.touches[1].pageY,o=Math.sqrt(r*r+s*s);this.dollyStart.set(0,o)}this.dampingFactor=this.draggingDampingFactor,document.addEventListener("mousemove",this.dragging,{passive:!1}),document.addEventListener("touchmove",this.dragging,{passive:!1}),document.addEventListener("mouseup",this.endDragging),document.addEventListener("touchend",this.endDragging)}}},{key:"dragging",value:function(t){if(this.enabled){t.preventDefault();var e=t.touches?t.touches[0]:t,n=e.clientX,i=e.clientY,r=this.dragStart.x-n,s=this.dragStart.y-i;switch(this.dragStart.set(n,i),this.state){case u.ROTATE:case u.TOUCH_ROTATE:var o=2*Math.PI*r/this.elementRect.width,a=2*Math.PI*s/this.elementRect.height;this.rotate(o,a,!0);break;case u.DOLLY:break;case u.TOUCH_DOLLY:var h=n-t.touches[1].pageX,c=i-t.touches[1].pageY,l=Math.sqrt(h*h+c*c),d=this.dollyStart.y-l,f=(n+t.touches[1].pageX)/2,p=(i+t.touches[1].pageY)/2,m=f/this.domElement.clientWidth*2-1,v=-p/this.domElement.clientHeight*2+1;d>0?this.dollyOut(m,v):d<0&&this.dollyIn(m,v),this.dollyStart.set(0,l);break;case u.PAN:case u.TOUCH_PAN:var g=this.getZoomDistance(!0,1),y=-g*this.panSpeed*(r/this.elementRect.height),E=-g*this.panSpeed*(s/this.elementRect.height);this.pan(y,E,!0);break;case u.ROTATE_FP:this.rotatetFP(r,s)}}}},{key:"endDragging",value:function(){this.enabled&&(this.dampingFactor=this.dampingFactor,this.state=u.NONE,document.removeEventListener("mousemove",this.dragging),document.removeEventListener("touchmove",this.dragging),document.removeEventListener("mouseup",this.endDragging),document.removeEventListener("touchend",this.endDragging))}},{key:"dollyIn",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.dolly(this.getZoomDistance(!0,n),!0,t,e)}},{key:"dollyOut",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.dolly(this.getZoomDistance(!1,n),!0,t,e)}},{key:"rotate",value:function(t,e,n){this.rotateTo(this.sphericalEnd.theta+t,this.sphericalEnd.phi+e,n)}},{key:"rotateTo",value:function(t,e,n){var i=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,t)),r=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,e));this.sphericalEnd.theta=i,this.sphericalEnd.phi=r,this.sphericalEnd.radius=this.spherical.radius,this.sphericalEnd.makeSafe(),this.targetEnd.copy(this.target),n||(this.spherical.theta=this.sphericalEnd.theta,this.spherical.phi=this.sphericalEnd.phi),this.needsUpdate=!0}},{key:"rotatetFP",value:function(t,e){var n=this.object.clone();n.position.setFromSpherical(this.sphericalEnd).add(this.targetEnd),n.lookAt(this.targetEnd),n.rotateY(t*this.rotationSpeed),n.rotateX(e*this.rotationSpeed);var i=new c.Vector3;n.getWorldDirection(i),this.v3.subVectors(this.targetEnd,n.position);var r=this.targetEnd.distanceTo(n.position);this.targetEnd.addVectors(n.position,i.multiplyScalar(r)),this.sphericalEnd.setFromVector3(this.v3.subVectors(n.position,this.targetEnd)),function(t,e){for(var n=2*Math.PI,i=.5*n;Math.abs(t.theta-e.theta)>i;)t.theta+=t.theta<e.theta?n:-n}(this.sphericalEnd,this.spherical),this.needsUpdate=!0}},{key:"getZoomDistance",value:function(t,e){var n=this.sphericalEnd.radius,i=void 0,r=this.minDistToTarget,s=100*r;if(n<=this.minDistToTarget)i=this.minZoomDistance;else if(n>=s)i=this.maxZoomDistance;else{var o=(this.maxZoomDistance-this.minZoomDistance)/(s-r);i=this.minZoomDistance+o*(n-r)}return t&&(i=-i),i*=e}},{key:"dolly",value:function(t,e,n,i){this.dollyTo(this.sphericalEnd.radius+t,e,n,i)}},{key:"dollyTo",value:function(t,e,n,i){var r=c.Math.clamp(t,this.minDistance,this.maxDistance),s=this.sphericalEnd.radius-r;this.mouse.set(n,i);var o=this.object.clone();o.position.setFromSpherical(this.sphericalEnd).add(this.targetEnd),o.lookAt(this.targetEnd),this.raycaster.setFromCamera(this.mouse,o);var a=new c.Vector3;o.getWorldDirection(a);var h=this.plane;h.setFromNormalAndCoplanarPoint(a,this.targetEnd);var u=this.raycaster.ray.direction.clone().multiplyScalar(s);o.position.add(u);var l=this.line3,d=-h.distanceToPoint(o.position);l.set(o.position,o.position.clone().add(a.clone().multiplyScalar(2*d))),h.intersectLine(l,this.targetEnd),this.sphericalEnd.radius=this.targetEnd.distanceTo(o.position);var f=this.minDistToTarget-this.sphericalEnd.radius;if(f>0){var p=new c.Vector3;o.getWorldDirection(p),this.targetEnd.add(p.multiplyScalar(f)),this.sphericalEnd.radius=this.minDistToTarget}e||(this.spherical.radius=this.sphericalEnd.radius,this.update()),this.needsUpdate=!0}},{key:"pan",value:function(t,e,n){var i=this.object.clone();i.position.setFromSpherical(this.sphericalEnd).add(this.targetEnd),i.lookAt(this.targetEnd),i.updateMatrix(),this.xColumn.setFromMatrixColumn(i.matrix,0),this.yColumn.setFromMatrixColumn(i.matrix,1),this.xColumn.multiplyScalar(t),this.yColumn.multiplyScalar(-e);var r=this.v3.copy(this.xColumn).add(this.yColumn);this.targetEnd.add(r),n||this.target.copy(this.targetEnd),this.needsUpdate=!0}},{key:"moveTo",value:function(t,e,n,i){this.targetEnd.set(t,e,n),i||this.target.copy(this.targetEnd),this.needsUpdate=!0}},{key:"getState",value:function(){return this.state}},{key:"reset",value:function(t){this.targetEnd.copy(this.target0),this.sphericalEnd.setFromVector3(this.position0),this.sphericalEnd.theta=this.sphericalEnd.theta%(2*Math.PI),this.spherical.theta=this.spherical.theta%(2*Math.PI),t||(this.target.copy(this.targetEnd),this.spherical.copy(this.sphericalEnd)),this.needsUpdate=!0}},{key:"getCameraPosition",value:function(){var t=this.target.clone(),e=new c.Vector3;return e.setFromSpherical(this.spherical).add(t),{position:e,target:t}}},{key:"setCameraPosition",value:function(t,e){this.target0.copy(e),this.position0.copy(t.clone().sub(e)),this.reset()}},{key:"update",value:function(t){var e=this,n=1;null!=t&&(n=this.dampingFactor*t/.016),n=c.Math.clamp(n,0,1);var i=this.sphericalEnd.theta-this.spherical.theta,r=this.sphericalEnd.phi-this.spherical.phi,s=this.sphericalEnd.radius-this.spherical.radius,o=(new c.Vector3).subVectors(this.targetEnd,this.target);Math.abs(i)>.001||Math.abs(r)>.001||Math.abs(s)>.001||Math.abs(o.x)>.001||Math.abs(o.y)>.001||Math.abs(o.z)>.001?(this.spherical.set(this.spherical.radius+s*n,this.spherical.phi+r*n,this.spherical.theta+i*n),this.target.add(o.multiplyScalar(n)),this.needsUpdate=!0):(this.spherical.copy(this.sphericalEnd),this.target.copy(this.targetEnd)),this.spherical.makeSafe(),this.object.position.setFromSpherical(this.spherical).add(this.target),this.object.lookAt(this.target),this.checkKeyboardEvents();var a=this.needsUpdate;return a&&this.eventListeners.cameraChange.forEach(function(t){t(e.object.position,e.target)}),this.needsUpdate=!1,a}}]),t}()}])}); |
{ | ||
"name": "@cognite/3d-camera-controls", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"contributors": [ | ||
@@ -5,0 +5,0 @@ "Fredrik Anfinsen <fredrik.anfinsen@cognite.com>" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26467