parsegraph-camera
Advanced tools
Comparing version 1.4.22 to 1.4.23-dev
@@ -1,2 +0,367 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.parsegraph_camera=e():t.parsegraph_camera=e()}(this,(()=>(()=>{var t={255:function(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t,e,r,i){return[t-r/2,e-i/2,t+r/2,e-i/2,t+r/2,e+i/2,t-r/2,e-i/2,t+r/2,e+i/2,t-r/2,e+i/2]}function i(t,e,r){return[[-t,e,r],[t,e,r],[t,e,-r],[-t,e,-r],[t,-e,r],[-t,-e,r],[-t,-e,-r],[t,-e,-r],[t,e,r],[t,-e,r],[t,-e,-r],[t,e,-r],[-t,-e,r],[-t,e,r],[-t,e,-r],[-t,-e,-r],[t,e,r],[-t,e,r],[-t,-e,r],[t,-e,r],[t,-e,-r],[-t,-e,-r],[-t,e,-r],[t,e,-r]]}function n(){return[0,0,1,0,1,1,0,0,1,1,0,1]}function a(){var t=new Float32Array(9);return t[0]=1,t[4]=1,t[8]=1,t}function o(t){return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]]}function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)throw new Error("At least two matrices must be provided.");if(1===t.length)return t[0];for(var r=o(t[0]),i=1;i<t.length;++i){var n=r,a=t[i];r=[n[0]*a[0]+n[1]*a[3]+n[2]*a[6],n[0]*a[1]+n[1]*a[4]+n[2]*a[7],n[0]*a[2]+n[1]*a[5]+n[2]*a[8],n[3]*a[0]+n[4]*a[3]+n[5]*a[6],n[3]*a[1]+n[4]*a[4]+n[5]*a[7],n[3]*a[2]+n[4]*a[5]+n[5]*a[8],n[6]*a[0]+n[7]*a[3]+n[8]*a[6],n[6]*a[1]+n[7]*a[4]+n[8]*a[7],n[6]*a[2]+n[7]*a[5]+n[8]*a[8]]}return r}function h(t,e,r){return m(t,e[0]*r[0]+e[1]*r[3]+e[2]*r[6],e[0]*r[1]+e[1]*r[4]+e[2]*r[7],e[0]*r[2]+e[1]*r[5]+e[2]*r[8],e[3]*r[0]+e[4]*r[3]+e[5]*r[6],e[3]*r[1]+e[4]*r[4]+e[5]*r[7],e[3]*r[2]+e[4]*r[5]+e[5]*r[8],e[6]*r[0]+e[7]*r[3]+e[8]*r[6],e[6]*r[1]+e[7]*r[4]+e[8]*r[7],e[6]*r[2]+e[7]*r[5]+e[8]*r[8])}function c(t,e,r){return[t[0]*e+t[1]*r+t[2],t[3]*e+t[4]*r+t[5]]}function u(t,e){return l(a(),t,e)}function l(t,e,r){return m(t,1,0,0,0,1,0,e,r,1)}function f(t){var e=Math.cos(t),r=Math.sin(t);return[e,-r,0,r,e,0,0,0,1]}function p(t,e){return 1===arguments.length&&(e=t),d(a(),t,e)}function m(t,e,r,i,n,a,o,s,h,c){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t[4]=a,t[5]=o,t[6]=s,t[7]=h,t[8]=c,t}function d(t,e,r){return 2===arguments.length&&(r=e),m(t,e,0,0,0,r,0,0,0,1)}function g(t){var e=function(e,r){return t[3*r+e]},r=1/(e(0,0)*(e(1,1)*e(2,2)-e(2,1)*e(1,2))-e(0,1)*(e(1,0)*e(2,2)-e(1,2)*e(2,0))+e(0,2)*(e(1,0)*e(2,1)-e(1,1)*e(2,0)));return[(e(1,1)*e(2,2)-e(2,1)*e(1,2))*r,(e(0,2)*e(2,1)-e(0,1)*e(2,2))*r,(e(0,1)*e(1,2)-e(0,2)*e(1,1))*r,(e(1,2)*e(2,0)-e(1,0)*e(2,2))*r,(e(0,0)*e(2,2)-e(0,2)*e(2,0))*r,(e(1,0)*e(0,2)-e(0,0)*e(1,2))*r,(e(1,0)*e(2,1)-e(2,0)*e(1,1))*r,(e(2,0)*e(0,1)-e(0,0)*e(2,1))*r,(e(0,0)*e(1,1)-e(1,0)*e(0,1))*r]}function y(t,e,r,i){return[t+.5*(r-t),e+.5*(i-e)]}t.r(e),t.d(e,{generateRectangleVertices:()=>r,getVerts:()=>i,generateRectangleTexcoords:()=>n,matrixIdentity3x3:()=>a,matrixCopy3x3:()=>o,matrixMultiply3x3:()=>s,matrixMultiply3x3I:()=>h,matrixTransform2D:()=>c,makeTranslation3x3:()=>u,makeTranslation3x3I:()=>l,makeRotation3x3:()=>f,makeScale3x3:()=>p,matrixSet3x3:()=>m,makeScale3x3I:()=>d,makeInverse3x3:()=>g,midPoint:()=>y,getVFlip:()=>_,setVFlip:()=>v,flipVFlip:()=>w,make2DProjection:()=>M,subtractVectors3D:()=>b,normalize3D:()=>N,cross3D:()=>j,makePerspective:()=>S,makeTranslation4x4:()=>k,makeXRotation:()=>O,makeYRotation:()=>P,makeZRotation:()=>V,makeScale4x4:()=>T,matrixMultiply4x4:()=>R,makeInverse4x4:()=>X,matrixVectorMultiply4x4:()=>Y,makeLookAt:()=>I});var x=!1;function _(){return x}function v(t){x=!!t}function w(){x=!x}function M(t,e,r){void 0===r&&(r=_());var i=(r=!0===r)?-1:1;return[2/t,0,0,0,-2/(i*e),0,-1,i,1]}function b(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function N(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);return e>1e-5?[t[0]/e,t[1]/e,t[2]/e]:[0,0,0]}function j(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function S(t,e,r,i){var n=Math.tan(.5*Math.PI-.5*t),a=1/(r-i);return[n/e,0,0,0,0,n,0,0,0,0,(r+i)*a,-1,0,0,r*i*a*2,0]}function k(t,e,r){return[1,0,0,0,0,1,0,0,0,0,1,0,t,e,r,1]}function O(t){var e=Math.cos(t),r=Math.sin(t);return[1,0,0,0,0,e,r,0,0,-r,e,0,0,0,0,1]}function P(t){var e=Math.cos(t),r=Math.sin(t);return[e,0,-r,0,0,1,0,0,r,0,e,0,0,0,0,1]}function V(t){var e=Math.cos(t),r=Math.sin(t);return[e,r,0,0,-r,e,0,0,0,0,1,0,0,0,0,1]}function T(t,e,r){return[t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1]}function R(t,e){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],h=t[6],c=t[7],u=t[8],l=t[9],f=t[10],p=t[11],m=t[12],d=t[13],g=t[14],y=t[15],x=e[0],_=e[1],v=e[2],w=e[3],M=e[4],b=e[5],N=e[6],j=e[7],S=e[8],k=e[9],O=e[10],P=e[11],V=e[12],T=e[13],R=e[14],X=e[15];return[r*x+i*M+n*S+a*V,r*_+i*b+n*k+a*T,r*v+i*N+n*O+a*R,r*w+i*j+n*P+a*X,o*x+s*M+h*S+c*V,o*_+s*b+h*k+c*T,o*v+s*N+h*O+c*R,o*w+s*j+h*P+c*X,u*x+l*M+f*S+p*V,u*_+l*b+f*k+p*T,u*v+l*N+f*O+p*R,u*w+l*j+f*P+p*X,m*x+d*M+g*S+y*V,m*_+d*b+g*k+y*T,m*v+d*N+g*O+y*R,m*w+d*j+g*P+y*X]}function X(t){var e=t[0],r=t[1],i=t[2],n=t[3],a=t[4],o=t[5],s=t[6],h=t[7],c=t[8],u=t[9],l=t[10],f=t[11],p=t[12],m=t[13],d=t[14],g=t[15],y=l*g,x=d*f,_=s*g,v=d*h,w=s*f,M=l*h,b=i*g,N=d*n,j=i*f,S=l*n,k=i*h,O=s*n,P=c*m,V=p*u,T=a*m,R=p*o,X=a*u,Y=c*o,I=e*m,A=p*r,D=e*u,C=c*r,F=e*o,z=a*r,E=y*o+v*u+w*m-(x*o+_*u+M*m),q=x*r+b*u+S*m-(y*r+N*u+j*m),G=_*r+N*o+k*m-(v*r+b*o+O*m),J=M*r+j*o+O*u-(w*r+S*o+k*u),L=1/(e*E+a*q+c*G+p*J);return[L*E,L*q,L*G,L*J,L*(x*a+_*c+M*p-(y*a+v*c+w*p)),L*(y*e+N*c+j*p-(x*e+b*c+S*p)),L*(v*e+b*a+O*p-(_*e+N*a+k*p)),L*(w*e+S*a+k*c-(M*e+j*a+O*c)),L*(P*h+R*f+X*g-(V*h+T*f+Y*g)),L*(V*n+I*f+C*g-(P*n+A*f+D*g)),L*(T*n+A*h+F*g-(R*n+I*h+z*g)),L*(Y*n+D*h+z*f-(X*n+C*h+F*f)),L*(T*l+Y*d+V*s-(X*d+P*s+R*l)),L*(D*d+P*i+A*l-(I*l+C*d+V*i)),L*(I*s+z*d+R*i-(F*d+T*i+A*s)),L*(F*l+X*i+C*s-(D*s+z*l+Y*i))]}function Y(t,e){for(var r=[],i=0;i<4;++i){r[i]=0;for(var n=0;n<4;++n)r[i]+=t[n]*e[4*n+i]}return r}function I(t,e,r){var i=N(b(t,e)),n=j(r,i),a=j(i,n);return[n[0],n[1],n[2],0,a[0],a[1],a[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],1]}return e})()}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var a=e[i]={exports:{}};return t[i].call(a.exports,a,a.exports,r),a.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";function t(t,e,r,i,n,a,o,s){var h=r/2,c=i/2,u=o/2,l=s/2;return!(n-u>t+h||n+u<t-h||a-l>e+c||a+l<e-c)}function e(t,e,r,i,n,a,o,s){var h=r/2,c=i/2,u=o/2,l=s/2;return!(n+u>t+h||n-u<t-h||a+l>e+c||a-l<e-c)}r.r(i),r.d(i,{containsAll:()=>e,containsAny:()=>t,default:()=>a});var n=r(255);const a=function(){function t(){this._cameraX=0,this._cameraY=0,this._scale=1,this._width=NaN,this._height=NaN,this._aspectRatio=NaN,this._changeVersion=0,this._vflip=(0,n.getVFlip)()}return t.prototype.setSize=function(t,e){return(this._width!==t||this._height!==e)&&(isNaN(this._width)||isNaN(this._height)||this.adjustOrigin((t-this._width)/(2*this._scale),(e-this._height)/(2*this._scale)),this._width=t,this._height=e,this._aspectRatio=this._width/this._height,this.hasChanged(),!0)},t.prototype.transform=function(t,e){var r=(0,n.matrixTransform2D)((0,n.makeInverse3x3)(this.worldMatrix()),t,e);return[r[0],r[1]]},t.prototype.zoomToPoint=function(t,e,r){var i=this.transform(e,r);this.setScale(this.scale()*t);var a=(0,n.matrixTransform2D)((0,n.makeInverse3x3)(this.worldMatrix()),e,r);this.adjustOrigin(a[0]-i[0],a[1]-i[1])},t.prototype.setOrigin=function(t,e){t==this._cameraX&&e==this._cameraY||(this._cameraX=t,this._cameraY=e,this.hasChanged())},t.prototype.changeVersion=function(){return this._changeVersion},t.prototype.hasChanged=function(){++this._changeVersion,this._worldMatrix=null},t.prototype.toJSON=function(){return{cameraX:this._cameraX,cameraY:this._cameraY,scale:this._scale,width:this._width,height:this._height}},t.prototype.restore=function(t){this.setOrigin(t.cameraX,t.cameraY),this.setScale(t.scale)},t.prototype.copy=function(t){this.setSize(t.width(),t.height()),this.setOrigin(t.x(),t.y()),this.setScale(t.scale())},t.prototype.scale=function(){return this._scale},t.prototype.x=function(){return this._cameraX},t.prototype.y=function(){return this._cameraY},t.prototype.setScale=function(t){this._scale=t,this.hasChanged()},t.prototype.toString=function(){return"("+this._cameraX+", "+this._cameraY+", "+this._scale+")"},t.prototype.adjustOrigin=function(t,e){if(0!=t||0!=e){if(Number.isNaN(t)||Number.isNaN(e))throw new Error("Adjusted origin must not be null. (Given "+t+", "+e+")");this._cameraX+=t,this._cameraY+=e,this.hasChanged()}},t.prototype.worldMatrix=function(){return(0,n.matrixMultiply3x3)((0,n.makeTranslation3x3)(this.x(),this.y()),(0,n.makeScale3x3)(this.scale(),this.scale()))},t.prototype.aspectRatio=function(){return this._aspectRatio},t.prototype.width=function(){return this._width},t.prototype.height=function(){return this._height},t.prototype.canProject=function(){return!Number.isNaN(this._width)&&!Number.isNaN(this._height)},t.prototype.projectionMatrix=function(){if(!this.canProject())throw new Error("Camera cannot create a projection matrix because the target canvas has no size. Use canProject() to handle.");return(0,n.make2DProjection)(this._width,this._height)},t.prototype.project=function(){return this._worldMatrix&&(0,n.getVFlip)()===this._vflip||(this._vflip=(0,n.getVFlip)(),this._worldMatrix=(0,n.matrixMultiply3x3)(this.worldMatrix(),this.projectionMatrix())),this._worldMatrix},t.prototype.containsAny=function(t){if(t.isNaN())return!1;var e=-this.x()+this.width()/(2*this.scale());if(t.x()-t.width()/2>e+this.width()/this.scale()/2)return!1;if(t.x()+t.width()/2<e-this.width()/this.scale()/2)return!1;var r=-this.y()+this.height()/(2*this.scale());return!(t.y()-t.height()/2>r+this.height()/this.scale()/2||t.y()+t.height()/2<r-this.height()/this.scale()/2)},t.prototype.containsAll=function(t){if(t.isNaN())return!1;var r=this;return e(-r.x()+r.width()/(2*r.scale()),-r.y()+r.height()/(2*r.scale()),r.width()/r.scale(),r.height()/r.scale(),t.x(),t.y(),t.width(),t.height())},t}()})(),i})())); | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["parsegraph_camera"] = factory(); | ||
else | ||
root["parsegraph_camera"] = factory(); | ||
})(this, () => { | ||
return /******/ (() => { // webpackBootstrap | ||
/******/ var __webpack_modules__ = ({ | ||
/***/ "./src/containsAll.ts": | ||
/*!****************************!*\ | ||
!*** ./src/containsAll.ts ***! | ||
\****************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "default": () => (/* binding */ containsAll) | ||
/* harmony export */ }); | ||
function containsAll(viewportX, viewportY, viewWidth, viewHeight, cx, cy, width, height) { | ||
var viewHalfWidth = viewWidth / 2; | ||
var viewHalfHeight = viewHeight / 2; | ||
var halfWidth = width / 2; | ||
var halfHeight = height / 2; | ||
if (cx + halfWidth > viewportX + viewHalfWidth) { | ||
return false; | ||
} | ||
if (cx - halfWidth < viewportX - viewHalfWidth) { | ||
return false; | ||
} | ||
if (cy + halfHeight > viewportY + viewHalfHeight) { | ||
return false; | ||
} | ||
if (cy - halfHeight < viewportY - viewHalfHeight) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
/***/ }), | ||
/***/ "./src/containsAny.ts": | ||
/*!****************************!*\ | ||
!*** ./src/containsAny.ts ***! | ||
\****************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "default": () => (/* binding */ containsAny) | ||
/* harmony export */ }); | ||
function containsAny(viewportX, viewportY, viewWidth, viewHeight, cx, cy, width, height) { | ||
var viewHalfWidth = viewWidth / 2; | ||
var viewHalfHeight = viewHeight / 2; | ||
var halfWidth = width / 2; | ||
var halfHeight = height / 2; | ||
/* function dump() { | ||
console.log("viewportX=" + viewportX); | ||
console.log("viewportY=" + viewportY); | ||
console.log("viewWidth=" + viewWidth); | ||
console.log("viewHeight=" + viewHeight); | ||
console.log("cx=" + cx); | ||
console.log("cy=" + cy); | ||
console.log("width=" + width); | ||
console.log("height=" + height); | ||
};*/ | ||
if (cx - halfWidth > viewportX + viewHalfWidth) { | ||
// console.log(1); | ||
// dump(); | ||
return false; | ||
} | ||
if (cx + halfWidth < viewportX - viewHalfWidth) { | ||
// console.log(2); | ||
// dump(); | ||
return false; | ||
} | ||
if (cy - halfHeight > viewportY + viewHalfHeight) { | ||
// console.log("Viewport min is greater than given's max"); | ||
// dump(); | ||
return false; | ||
} | ||
if (cy + halfHeight < viewportY - viewHalfHeight) { | ||
// console.log("Viewport does not contain any: given vmax' + | ||
// ' is less than viewport's vmin"); | ||
// dump(); | ||
return false; | ||
} | ||
return true; | ||
} | ||
/***/ }), | ||
/***/ "./node_modules/parsegraph-matrix/dist/src/index.js": | ||
/*!**********************************************************!*\ | ||
!*** ./node_modules/parsegraph-matrix/dist/src/index.js ***! | ||
\**********************************************************/ | ||
/***/ (function(module) { | ||
!function(t,n){ true?module.exports=n():0}(this,(function(){return(()=>{"use strict";var t={d:(n,r)=>{for(var e in r)t.o(r,e)&&!t.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:r[e]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};function r(t,n,r,e){return[t-r/2,n-e/2,t+r/2,n-e/2,t+r/2,n+e/2,t-r/2,n-e/2,t+r/2,n+e/2,t-r/2,n+e/2]}function e(t,n,r){return[[-t,n,r],[t,n,r],[t,n,-r],[-t,n,-r],[t,-n,r],[-t,-n,r],[-t,-n,-r],[t,-n,-r],[t,n,r],[t,-n,r],[t,-n,-r],[t,n,-r],[-t,-n,r],[-t,n,r],[-t,n,-r],[-t,-n,-r],[t,n,r],[-t,n,r],[-t,-n,r],[t,-n,r],[t,-n,-r],[-t,-n,-r],[-t,n,-r],[t,n,-r]]}function o(){return[0,0,1,0,1,1,0,0,1,1,0,1]}function a(){var t=new Float32Array(9);return t[0]=1,t[4]=1,t[8]=1,t}function i(t){return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]]}function u(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(0===t.length)throw new Error("At least two matrices must be provided.");if(1===t.length)return t[0];for(var r=i(t[0]),e=1;e<t.length;++e){var o=r,a=t[e];r=[o[0]*a[0]+o[1]*a[3]+o[2]*a[6],o[0]*a[1]+o[1]*a[4]+o[2]*a[7],o[0]*a[2]+o[1]*a[5]+o[2]*a[8],o[3]*a[0]+o[4]*a[3]+o[5]*a[6],o[3]*a[1]+o[4]*a[4]+o[5]*a[7],o[3]*a[2]+o[4]*a[5]+o[5]*a[8],o[6]*a[0]+o[7]*a[3]+o[8]*a[6],o[6]*a[1]+o[7]*a[4]+o[8]*a[7],o[6]*a[2]+o[7]*a[5]+o[8]*a[8]]}return r}function c(t,n,r){return p(t,n[0]*r[0]+n[1]*r[3]+n[2]*r[6],n[0]*r[1]+n[1]*r[4]+n[2]*r[7],n[0]*r[2]+n[1]*r[5]+n[2]*r[8],n[3]*r[0]+n[4]*r[3]+n[5]*r[6],n[3]*r[1]+n[4]*r[4]+n[5]*r[7],n[3]*r[2]+n[4]*r[5]+n[5]*r[8],n[6]*r[0]+n[7]*r[3]+n[8]*r[6],n[6]*r[1]+n[7]*r[4]+n[8]*r[7],n[6]*r[2]+n[7]*r[5]+n[8]*r[8])}function f(t,n,r){return[t[0]*n+t[1]*r+t[2],t[3]*n+t[4]*r+t[5]]}function l(t,n){return s(a(),t,n)}function s(t,n,r){return p(t,1,0,0,0,1,0,n,r,1)}function m(t){var n=Math.cos(t),r=Math.sin(t);return[n,-r,0,r,n,0,0,0,1]}function x(t,n){return 1===arguments.length&&(n=t),v(a(),t,n)}function p(t,n,r,e,o,a,i,u,c,f){return t[0]=n,t[1]=r,t[2]=e,t[3]=o,t[4]=a,t[5]=i,t[6]=u,t[7]=c,t[8]=f,t}function v(t,n,r){return 2===arguments.length&&(r=n),p(t,n,0,0,0,r,0,0,0,1)}function h(t){var n=function(n,r){return t[3*r+n]},r=1/(n(0,0)*(n(1,1)*n(2,2)-n(2,1)*n(1,2))-n(0,1)*(n(1,0)*n(2,2)-n(1,2)*n(2,0))+n(0,2)*(n(1,0)*n(2,1)-n(1,1)*n(2,0)));return[(n(1,1)*n(2,2)-n(2,1)*n(1,2))*r,(n(0,2)*n(2,1)-n(0,1)*n(2,2))*r,(n(0,1)*n(1,2)-n(0,2)*n(1,1))*r,(n(1,2)*n(2,0)-n(1,0)*n(2,2))*r,(n(0,0)*n(2,2)-n(0,2)*n(2,0))*r,(n(1,0)*n(0,2)-n(0,0)*n(1,2))*r,(n(1,0)*n(2,1)-n(2,0)*n(1,1))*r,(n(2,0)*n(0,1)-n(0,0)*n(2,1))*r,(n(0,0)*n(1,1)-n(1,0)*n(0,1))*r]}function d(t,n,r,e){return[t+.5*(r-t),n+.5*(e-n)]}t.r(n),t.d(n,{generateRectangleVertices:()=>r,getVerts:()=>e,generateRectangleTexcoords:()=>o,matrixIdentity3x3:()=>a,matrixCopy3x3:()=>i,matrixMultiply3x3:()=>u,matrixMultiply3x3I:()=>c,matrixTransform2D:()=>f,makeTranslation3x3:()=>l,makeTranslation3x3I:()=>s,makeRotation3x3:()=>m,makeScale3x3:()=>x,matrixSet3x3:()=>p,makeScale3x3I:()=>v,makeInverse3x3:()=>h,midPoint:()=>d,getVFlip:()=>g,setVFlip:()=>M,flipVFlip:()=>k,make2DProjection:()=>b,subtractVectors3D:()=>S,normalize3D:()=>j,cross3D:()=>P,makePerspective:()=>I,makeTranslation4x4:()=>T,makeXRotation:()=>V,makeYRotation:()=>R,makeZRotation:()=>w,makeScale4x4:()=>D,matrixMultiply4x4:()=>O,makeInverse4x4:()=>F,matrixVectorMultiply4x4:()=>_,makeLookAt:()=>A});var y=!1;function g(){return y}function M(t){y=!!t}function k(){y=!y}function b(t,n,r){void 0===r&&(r=g());var e=(r=!0===r)?-1:1;return[2/t,0,0,0,-2/(e*n),0,-1,e,1]}function S(t,n){return[t[0]-n[0],t[1]-n[1],t[2]-n[2]]}function j(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);return n>1e-5?[t[0]/n,t[1]/n,t[2]/n]:[0,0,0]}function P(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function I(t,n,r,e){var o=Math.tan(.5*Math.PI-.5*t),a=1/(r-e);return[o/n,0,0,0,0,o,0,0,0,0,(r+e)*a,-1,0,0,r*e*a*2,0]}function T(t,n,r){return[1,0,0,0,0,1,0,0,0,0,1,0,t,n,r,1]}function V(t){var n=Math.cos(t),r=Math.sin(t);return[1,0,0,0,0,n,r,0,0,-r,n,0,0,0,0,1]}function R(t){var n=Math.cos(t),r=Math.sin(t);return[n,0,-r,0,0,1,0,0,r,0,n,0,0,0,0,1]}function w(t){var n=Math.cos(t),r=Math.sin(t);return[n,r,0,0,-r,n,0,0,0,0,1,0,0,0,0,1]}function D(t,n,r){return[t,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1]}function O(t,n){var r=t[0],e=t[1],o=t[2],a=t[3],i=t[4],u=t[5],c=t[6],f=t[7],l=t[8],s=t[9],m=t[10],x=t[11],p=t[12],v=t[13],h=t[14],d=t[15],y=n[0],g=n[1],M=n[2],k=n[3],b=n[4],S=n[5],j=n[6],P=n[7],I=n[8],T=n[9],V=n[10],R=n[11],w=n[12],D=n[13],O=n[14],F=n[15];return[r*y+e*b+o*I+a*w,r*g+e*S+o*T+a*D,r*M+e*j+o*V+a*O,r*k+e*P+o*R+a*F,i*y+u*b+c*I+f*w,i*g+u*S+c*T+f*D,i*M+u*j+c*V+f*O,i*k+u*P+c*R+f*F,l*y+s*b+m*I+x*w,l*g+s*S+m*T+x*D,l*M+s*j+m*V+x*O,l*k+s*P+m*R+x*F,p*y+v*b+h*I+d*w,p*g+v*S+h*T+d*D,p*M+v*j+h*V+d*O,p*k+v*P+h*R+d*F]}function F(t){var n=t[0],r=t[1],e=t[2],o=t[3],a=t[4],i=t[5],u=t[6],c=t[7],f=t[8],l=t[9],s=t[10],m=t[11],x=t[12],p=t[13],v=t[14],h=t[15],d=s*h,y=v*m,g=u*h,M=v*c,k=u*m,b=s*c,S=e*h,j=v*o,P=e*m,I=s*o,T=e*c,V=u*o,R=f*p,w=x*l,D=a*p,O=x*i,F=a*l,_=f*i,A=n*p,q=x*r,z=n*l,C=f*r,E=n*i,L=a*r,X=d*i+M*l+k*p-(y*i+g*l+b*p),Y=y*r+S*l+I*p-(d*r+j*l+P*p),Z=g*r+j*i+T*p-(M*r+S*i+V*p),B=b*r+P*i+V*l-(k*r+I*i+T*l),G=1/(n*X+a*Y+f*Z+x*B);return[G*X,G*Y,G*Z,G*B,G*(y*a+g*f+b*x-(d*a+M*f+k*x)),G*(d*n+j*f+P*x-(y*n+S*f+I*x)),G*(M*n+S*a+V*x-(g*n+j*a+T*x)),G*(k*n+I*a+T*f-(b*n+P*a+V*f)),G*(R*c+O*m+F*h-(w*c+D*m+_*h)),G*(w*o+A*m+C*h-(R*o+q*m+z*h)),G*(D*o+q*c+E*h-(O*o+A*c+L*h)),G*(_*o+z*c+L*m-(F*o+C*c+E*m)),G*(D*s+_*v+w*u-(F*v+R*u+O*s)),G*(z*v+R*e+q*s-(A*s+C*v+w*e)),G*(A*u+L*v+O*e-(E*v+D*e+q*u)),G*(E*s+F*e+C*u-(z*u+L*s+_*e))]}function _(t,n){for(var r=[],e=0;e<4;++e){r[e]=0;for(var o=0;o<4;++o)r[e]+=t[o]*n[4*o+e]}return r}function A(t,n,r){var e=j(S(t,n)),o=P(r,e),a=P(e,o);return[o[0],o[1],o[2],0,a[0],a[1],a[2],0,e[0],e[1],e[2],0,t[0],t[1],t[2],1]}return n})()})); | ||
/***/ }) | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
/******/ /* webpack/runtime/compat get default export */ | ||
/******/ (() => { | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = (module) => { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ () => (module['default']) : | ||
/******/ () => (module); | ||
/******/ __webpack_require__.d(getter, { a: getter }); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/define property getters */ | ||
/******/ (() => { | ||
/******/ // define getter functions for harmony exports | ||
/******/ __webpack_require__.d = (exports, definition) => { | ||
/******/ for(var key in definition) { | ||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
/******/ (() => { | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = (exports) => { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it need to be in strict mode. | ||
(() => { | ||
"use strict"; | ||
/*!**********************!*\ | ||
!*** ./src/index.ts ***! | ||
\**********************/ | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||
/* harmony export */ "containsAll": () => (/* reexport safe */ _containsAll__WEBPACK_IMPORTED_MODULE_1__["default"]), | ||
/* harmony export */ "containsAny": () => (/* reexport safe */ _containsAny__WEBPACK_IMPORTED_MODULE_0__["default"]), | ||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | ||
/* harmony export */ }); | ||
/* harmony import */ var _containsAny__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./containsAny */ "./src/containsAny.ts"); | ||
/* harmony import */ var _containsAll__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./containsAll */ "./src/containsAll.ts"); | ||
/* harmony import */ var parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! parsegraph-matrix */ "./node_modules/parsegraph-matrix/dist/src/index.js"); | ||
/* harmony import */ var parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__); | ||
var Camera = /** @class */function () { | ||
function Camera() { | ||
this._cameraX = 0; | ||
this._cameraY = 0; | ||
this._scale = 1; | ||
this._width = NaN; | ||
this._height = NaN; | ||
this._aspectRatio = NaN; | ||
this._changeVersion = 0; | ||
this._vflip = (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.getVFlip)(); | ||
} | ||
Camera.prototype.setSize = function (width, height) { | ||
if (this._width === width && this._height === height) { | ||
return false; | ||
} | ||
if (!isNaN(this._width) && !isNaN(this._height)) { | ||
this.adjustOrigin((width - this._width) / (2 * this._scale), (height - this._height) / (2 * this._scale)); | ||
} | ||
this._width = width; | ||
this._height = height; | ||
this._aspectRatio = this._width / this._height; | ||
this.hasChanged(); | ||
return true; | ||
}; | ||
Camera.prototype.transform = function (x, y) { | ||
var mouseInWorld = (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.matrixTransform2D)((0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.makeInverse3x3)(this.worldMatrix()), x, y); | ||
return [mouseInWorld[0], mouseInWorld[1]]; | ||
}; | ||
Camera.prototype.zoomToPoint = function (scaleFactor, x, y) { | ||
// Get the current mouse position, in world space. | ||
var mouseInWorld = this.transform(x, y); | ||
// console.log("mouseInWorld=" + mouseInWorld[0] + ", " + mouseInWorld[1]); | ||
// Adjust the scale. | ||
this.setScale(this.scale() * scaleFactor); | ||
// Get the new mouse position, in world space. | ||
var mouseAdjustment = (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.matrixTransform2D)((0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.makeInverse3x3)(this.worldMatrix()), x, y); | ||
// console.log( | ||
// "mouseAdjustment=" + | ||
// mouseAdjustment[0] + | ||
// ", " + | ||
// mouseAdjustment[1]); | ||
// Adjust the origin by the movement of the fixed point. | ||
this.adjustOrigin(mouseAdjustment[0] - mouseInWorld[0], mouseAdjustment[1] - mouseInWorld[1]); | ||
}; | ||
Camera.prototype.setOrigin = function (x, y) { | ||
if (x == this._cameraX && y == this._cameraY) { | ||
return; | ||
} | ||
this._cameraX = x; | ||
this._cameraY = y; | ||
this.hasChanged(); | ||
}; | ||
Camera.prototype.changeVersion = function () { | ||
return this._changeVersion; | ||
}; | ||
Camera.prototype.hasChanged = function () { | ||
++this._changeVersion; | ||
this._worldMatrix = null; | ||
}; | ||
Camera.prototype.toJSON = function () { | ||
return { | ||
cameraX: this._cameraX, | ||
cameraY: this._cameraY, | ||
scale: this._scale, | ||
width: this._width, | ||
height: this._height | ||
}; | ||
}; | ||
Camera.prototype.restore = function (json) { | ||
this.setOrigin(json.cameraX, json.cameraY); | ||
this.setScale(json.scale); | ||
}; | ||
Camera.prototype.copy = function (other) { | ||
this.setSize(other.width(), other.height()); | ||
this.setOrigin(other.x(), other.y()); | ||
this.setScale(other.scale()); | ||
}; | ||
Camera.prototype.scale = function () { | ||
return this._scale; | ||
}; | ||
Camera.prototype.x = function () { | ||
return this._cameraX; | ||
}; | ||
Camera.prototype.y = function () { | ||
return this._cameraY; | ||
}; | ||
Camera.prototype.setScale = function (scale) { | ||
this._scale = scale; | ||
this.hasChanged(); | ||
}; | ||
Camera.prototype.toString = function () { | ||
return "(" + this._cameraX + ", " + this._cameraY + ", " + this._scale + ")"; | ||
}; | ||
Camera.prototype.adjustOrigin = function (x, y) { | ||
if (x == 0 && y == 0) { | ||
return; | ||
} | ||
if (Number.isNaN(x) || Number.isNaN(y)) { | ||
throw new Error("Adjusted origin must not be null. (Given " + x + ", " + y + ")"); | ||
} | ||
this._cameraX += x; | ||
this._cameraY += y; | ||
this.hasChanged(); | ||
}; | ||
Camera.prototype.worldMatrix = function () { | ||
return (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.matrixMultiply3x3)((0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.makeTranslation3x3)(this.x(), this.y()), (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.makeScale3x3)(this.scale(), this.scale())); | ||
}; | ||
Camera.prototype.aspectRatio = function () { | ||
return this._aspectRatio; | ||
}; | ||
Camera.prototype.width = function () { | ||
return this._width; | ||
}; | ||
Camera.prototype.height = function () { | ||
return this._height; | ||
}; | ||
Camera.prototype.canProject = function () { | ||
return !Number.isNaN(this._width) && !Number.isNaN(this._height); | ||
}; | ||
Camera.prototype.projectionMatrix = function () { | ||
if (!this.canProject()) { | ||
throw new Error("Camera cannot create a projection matrix because the " + "target canvas has no size. Use canProject() to handle."); | ||
} | ||
return (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.make2DProjection)(this._width, this._height); | ||
}; | ||
Camera.prototype.project = function () { | ||
if (!this._worldMatrix || (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.getVFlip)() !== this._vflip) { | ||
this._vflip = (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.getVFlip)(); | ||
this._worldMatrix = (0,parsegraph_matrix__WEBPACK_IMPORTED_MODULE_2__.matrixMultiply3x3)(this.worldMatrix(), this.projectionMatrix()); | ||
} | ||
return this._worldMatrix; | ||
}; | ||
Camera.prototype.containsAny = function (s) { | ||
if (s.isNaN()) { | ||
return false; | ||
} | ||
var viewportX = -this.x() + this.width() / (this.scale() * 2); | ||
if (s.x() - s.width() / 2 > viewportX + this.width() / this.scale() / 2) { | ||
return false; | ||
} | ||
if (s.x() + s.width() / 2 < viewportX - this.width() / this.scale() / 2) { | ||
return false; | ||
} | ||
var viewportY = -this.y() + this.height() / (this.scale() * 2); | ||
if (s.y() - s.height() / 2 > viewportY + this.height() / this.scale() / 2) { | ||
return false; | ||
} | ||
if (s.y() + s.height() / 2 < viewportY - this.height() / this.scale() / 2) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
Camera.prototype.containsAll = function (s) { | ||
if (s.isNaN()) { | ||
return false; | ||
} | ||
var camera = this; | ||
return (0,_containsAll__WEBPACK_IMPORTED_MODULE_1__["default"])(-camera.x() + camera.width() / (camera.scale() * 2), -camera.y() + camera.height() / (camera.scale() * 2), camera.width() / camera.scale(), camera.height() / camera.scale(), s.x(), s.y(), s.width(), s.height()); | ||
}; | ||
return Camera; | ||
}(); | ||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Camera); | ||
})(); | ||
/******/ return __webpack_exports__; | ||
/******/ })() | ||
; | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "parsegraph-camera", | ||
"version": "1.4.22", | ||
"version": "1.4.23-dev", | ||
"description": "camera", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
154714
15
859
1