Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

camera-2d-simple

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camera-2d-simple - npm Package Compare versions

Comparing version 2.0.0-rc2 to 2.0.0

dist/camera-2d.esm.js

2

CHANGELOG.md

@@ -10,2 +10,4 @@ **v2.0.0**

- Removed `camera.position` and `camera.transformation` as both are unnecessary.
- Update to glMatrix v3
- Release as ESM

@@ -12,0 +14,0 @@ **v1.2.0**

38

dist/camera-2d.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('gl-matrix')) :
typeof define === 'function' && define.amd ? define(['gl-matrix'], factory) :
(global.createCamera2d = factory(global.glMatrix));
}(this, (function (glMatrix) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('gl-matrix/mat4'), require('gl-matrix/vec4')) :
typeof define === 'function' && define.amd ? define(['gl-matrix/mat4', 'gl-matrix/vec4'], factory) :
(global = global || self, global.createCamera2d = factory(global.glMatrix.mat4, global.glMatrix.vec4));
}(this, (function (mat4, vec4) { 'use strict';

@@ -23,13 +23,13 @@ var VIEW_CENTER = [0, 0, 0, 1];

var view = glMatrix.mat4.create();
var view = mat4.create();
var getRotation = function () { return Math.acos(view[0]); };
var getScaling = function () { return glMatrix.mat4.getScaling(scratch0, view)[0]; };
var getScaling = function () { return mat4.getScaling(scratch0, view)[0]; };
var getDistance = function () { return 1 / getScaling(); };
var getTranslation = function () { return glMatrix.mat4.getTranslation(scratch0, view).slice(0, 2); };
var getTranslation = function () { return mat4.getTranslation(scratch0, view).slice(0, 2); };
var getTarget = function () { return glMatrix.vec4.transformMat4(scratch0, VIEW_CENTER, glMatrix.mat4.invert(scratch2, view)); };
var getTarget = function () { return vec4.transformMat4(scratch0, VIEW_CENTER, mat4.invert(scratch2, view)); };

@@ -46,3 +46,3 @@ var getView = function () { return view; };

// Reset the view
view = glMatrix.mat4.create();
view = mat4.create();

@@ -63,7 +63,7 @@ translate([-x, -y]);

var t = glMatrix.mat4.fromTranslation(scratch1, scratch0);
var t = mat4.fromTranslation(scratch1, scratch0);
// Translate about the viewport center
// This is identical to `i * t * i * view` where `i` is the identity matrix
glMatrix.mat4.multiply(view, t, view);
mat4.multiply(view, t, view);
};

@@ -78,16 +78,16 @@

var s = glMatrix.mat4.fromScaling(scratch1, scratch0);
var s = mat4.fromScaling(scratch1, scratch0);
var scaleCenter = mousePos ? mousePos.concat( [0]) : VIEW_CENTER;
var a = glMatrix.mat4.fromTranslation(scratch0, scaleCenter);
var a = mat4.fromTranslation(scratch0, scaleCenter);
// Translate about the scale center
// I.e., the mouse position or the view center
glMatrix.mat4.multiply(
mat4.multiply(
view,
a,
glMatrix.mat4.multiply(
mat4.multiply(
view,
s,
glMatrix.mat4.multiply(view, glMatrix.mat4.invert(scratch2, a), view)
mat4.multiply(view, mat4.invert(scratch2, a), view)
)

@@ -98,8 +98,8 @@ );

var rotate = function (rad) {
var r = glMatrix.mat4.create();
glMatrix.mat4.fromRotation(r, rad, [0, 0, 1]);
var r = mat4.create();
mat4.fromRotation(r, rad, [0, 0, 1]);
// Rotate about the viewport center
// This is identical to `i * r * i * view` where `i` is the identity matrix
glMatrix.mat4.multiply(view, r, view);
mat4.multiply(view, r, view);
};

@@ -106,0 +106,0 @@

@@ -1,1 +0,1 @@

!function(t,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a(require("gl-matrix")):"function"==typeof define&&define.amd?define(["gl-matrix"],a):t.createCamera2d=a(t.glMatrix)}(this,function(t){"use strict";var a=[0,0,0,1];return function(r,e,n){void 0===r&&(r=[0,0]),void 0===e&&(e=1),void 0===n&&(n=0);var o=new Float32Array(16),i=new Float32Array(16),m=new Float32Array(16),l=t.mat4.create(),u=function(){return t.mat4.getScaling(o,l)[0]},c=function(a,r,e){void 0===a&&(a=[]);var n=a[0];void 0===n&&(n=0);var o=a[1];void 0===o&&(o=0),void 0===r&&(r=1),void 0===e&&(e=0),l=t.mat4.create(),f([-n,-o]),d(e),v(1/r)},f=function(a){void 0===a&&(a=[]);var r=a[0];void 0===r&&(r=0);var e=a[1];void 0===e&&(e=0),o[0]=r,o[1]=e,o[2]=0;var n=t.mat4.fromTranslation(i,o);t.mat4.multiply(l,n,l)},v=function(r,e){if(!(r<=0)){o[0]=r,o[1]=r,o[2]=1;var n=t.mat4.fromScaling(i,o),u=e?e.concat([0]):a,c=t.mat4.fromTranslation(o,u);t.mat4.multiply(l,c,t.mat4.multiply(l,n,t.mat4.multiply(l,t.mat4.invert(m,c),l)))}},d=function(a){var r=t.mat4.create();t.mat4.fromRotation(r,a,[0,0,1]),t.mat4.multiply(l,r,l)};return c(r,e,n),{get translation(){return t.mat4.getTranslation(o,l).slice(0,2)},get target(){return t.vec4.transformMat4(o,a,t.mat4.invert(m,l))},get scaling(){return u()},get distance(){return 1/u()},get rotation(){return Math.acos(l[0])},get view(){return l},lookAt:c,translate:f,pan:f,rotate:d,scale:v,zoom:v,reset:function(){c(r,e,n)},set:function(t){!t||t.length<16||(l=t)}}}});
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("gl-matrix/mat4"),require("gl-matrix/vec4")):"function"==typeof define&&define.amd?define(["gl-matrix/mat4","gl-matrix/vec4"],r):(t=t||self).createCamera2d=r(t.glMatrix.mat4,t.glMatrix.vec4)}(this,(function(t,r){"use strict";var e=[0,0,0,1];return function(n,a,i){void 0===n&&(n=[0,0]),void 0===a&&(a=1),void 0===i&&(i=0);var o=new Float32Array(16),l=new Float32Array(16),u=new Float32Array(16),c=t.create(),v=function(){return t.getScaling(o,c)[0]},f=function(r,e,n){void 0===r&&(r=[]);var a=r[0];void 0===a&&(a=0);var i=r[1];void 0===i&&(i=0),void 0===e&&(e=1),void 0===n&&(n=0),c=t.create(),m([-a,-i]),g(n),d(1/e)},m=function(r){void 0===r&&(r=[]);var e=r[0];void 0===e&&(e=0);var n=r[1];void 0===n&&(n=0),o[0]=e,o[1]=n,o[2]=0;var a=t.fromTranslation(l,o);t.multiply(c,a,c)},d=function(r,n){if(!(r<=0)){o[0]=r,o[1]=r,o[2]=1;var a=t.fromScaling(l,o),i=n?n.concat([0]):e,v=t.fromTranslation(o,i);t.multiply(c,v,t.multiply(c,a,t.multiply(c,t.invert(u,v),c)))}},g=function(r){var e=t.create();t.fromRotation(e,r,[0,0,1]),t.multiply(c,e,c)};return f(n,a,i),{get translation(){return t.getTranslation(o,c).slice(0,2)},get target(){return r.transformMat4(o,e,t.invert(u,c))},get scaling(){return v()},get distance(){return 1/v()},get rotation(){return Math.acos(c[0])},get view(){return c},lookAt:f,translate:m,pan:m,rotate:g,scale:d,zoom:d,reset:function(){f(n,a,i)},set:function(t){!t||t.length<16||(c=t)}}}}));
{
"name": "camera-2d-simple",
"version": "2.0.0-rc2",
"version": "2.0.0",
"description": "2D camera for WebGL",

@@ -13,28 +13,27 @@ "author": "Fritz Lekschas",

"main": "dist/camera-2d.js",
"module": "src/index.js",
"module": "dist/camera-2d.esm.js",
"unpkg": "dist/camera-2d.min.js",
"jsdelivr": "dist/camera-2d.min.js",
"files": [
"src/index.js",
"dist/camera-2d.js",
"dist/camera-2d.min.js"
"dist"
],
"dependencies": {
"gl-matrix": "^2.7.0"
"gl-matrix": "~3.1.0"
},
"peerDependencies": {
"gl-matrix": "^2.7.0"
"gl-matrix": "~3.1.0"
},
"devDependencies": {
"eslint": "^5.4.0",
"eslint-config-prettier": "^v3.1.0",
"esm": "^3.0.84",
"husky": "^1.1.2",
"prettier": "1.14.3",
"pretty-quick": "^1.7.0",
"rollup": "^0.64.1",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-terser": "^1.0.1",
"@rollup/plugin-buble": "^0.21.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^v6.10.0",
"esm": "^3.2.25",
"husky": "^4.2.1",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1",
"rollup": "^1.31.0",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-terser": "^5.2.0",
"tap-spec": "^5.0.0",
"tape": "^4.9.1"
"tape": "^4.13.0"
},

@@ -41,0 +40,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc