🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

gsv-injection

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gsv-injection - npm Package Compare versions

Comparing version

to
0.0.5

6

dist/index.d.ts
export declare class Mesh {
private getHeading;
textureURI: string;

@@ -17,2 +18,3 @@ vertices: number[];

private initialized;
constructor(getHeading: () => number);
init(gl: any, oldWebGl: any): void;

@@ -39,4 +41,8 @@ private handleTextureLoaded(image, texture, gl, oldWebGl);

}
export declare var activeMeshes: Mesh[];
export declare function init(canvasContainer: any): void;
export declare function addMesh(mesh: Mesh): void;
export declare function removeMesh(mesh: Mesh): void;
export declare function setDebugAcceptor(acceptor: {
accept: (name: string, value: any) => void;
}): void;

66

dist/index.js
"use strict";
var utils = require("./utils");
var mathUtils = require("./mathUtils");
var decompose = require("mat4-decompose");
var drawDebugger = new utils.Debugger();
var Mesh = (function () {
function Mesh() {
function Mesh(getHeading) {
this.getHeading = getHeading;
this.rotation = 0;

@@ -48,3 +51,3 @@ this.translation = {

if (bindAttributes) {
oldWebGl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
oldWebGl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
}

@@ -56,7 +59,11 @@ this.indicesBuffer = oldWebGl.createBuffer();

Mesh.prototype.applyTransformation = function (initialMatrix) {
var rotationMatrix = mathUtils.zRotation(this.rotation);
var translationMatrix = mathUtils.translation(this.translation.x, this.translation.y, this.translation.z);
var resultMatrix = mathUtils.multiply(translationMatrix, rotationMatrix);
resultMatrix = mathUtils.multiply(initialMatrix, resultMatrix);
return new Float32Array(resultMatrix);
var matrices = [];
var matrixRotation = getMatrixRotation(initialMatrix);
var headingDelta = Math.PI + matrixRotation.heading + mathUtils.toRad(this.getHeading());
matrices.push(mathUtils.zRotation(this.rotation));
matrices.push(mathUtils.xRotation(-matrixRotation.pitch));
matrices.push(mathUtils.translation(this.translation.x, this.translation.y, this.translation.z));
matrices.push(mathUtils.zRotation(headingDelta));
matrices.push(initialMatrix);
return new Float32Array(mathUtils.multiplyMatrices(matrices));
};

@@ -70,3 +77,3 @@ Mesh.prototype.draw = function (gl, oldWebGl, uniforms) {

oldWebGl.bindTexture(gl.TEXTURE_2D, this.texture);
oldWebGl.uniform4fv(uniforms.uniform4fv.location, [1, 1, 0, 0]);
oldWebGl.uniform4fv(uniforms.uniform4fv.location, [5, 5, 0, 0]);
oldWebGl.uniform1f(uniforms.uniform1f.location, 1);

@@ -81,2 +88,31 @@ if (uniforms.uniformMatrix4fv) {

exports.Mesh = Mesh;
function getMatrixRotation(matrix) {
var translation = [0, 0, 0];
var scale = [0, 0, 0];
var skew = [0, 0, 0];
var perspective = [0, 0, 0, 0];
var quaternion = [0, 0, 0, 0];
decompose(mathUtils.transpose(matrix), translation, scale, skew, perspective, quaternion);
drawDebugger.setValue('translation', translation);
drawDebugger.setValue('scale', scale);
drawDebugger.setValue('perspective', perspective);
drawDebugger.setValue('quaternion', quaternion);
return getQaternionRotation(quaternion);
}
function getQaternionRotation(quaternion) {
var q = quaternion;
var ysqr = q[1] * q[1];
var t0 = 2.0 * (q[3] * q[0] + q[1] * q[2]);
var t1 = 1.0 - 2.0 * (q[0] * q[0] + ysqr);
var roll = Math.atan2(t0, t1);
var t2 = 2.0 * (q[3] * q[1] - q[2] * q[0]);
t2 = t2 > 1.0 ? 1.0 : t2;
t2 = t2 < -1.0 ? -1.0 : t2;
var pitch = Math.asin(t2);
drawDebugger.setValue('pitch', pitch);
drawDebugger.setValue('roll', roll);
var t3 = 2.0 * (q[3] * q[2] + q[0] * q[1]);
var t4 = 1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2]);
return { heading: Math.atan2(t3, t4), pitch: pitch };
}
var Uniforms = (function () {

@@ -88,5 +124,5 @@ function Uniforms() {

exports.Uniforms = Uniforms;
var activeMeshes = [];
exports.activeMeshes = [];
function drawScene(gl, oldWebGl, uniforms) {
activeMeshes.forEach(function (mesh) {
exports.activeMeshes.forEach(function (mesh) {
if (!mesh.texture) {

@@ -130,3 +166,3 @@ mesh.init(gl, oldWebGl);

function addMesh(mesh) {
activeMeshes.push(mesh);
exports.activeMeshes.push(mesh);
}

@@ -136,3 +172,3 @@ exports.addMesh = addMesh;

var filteredMeshes = [];
activeMeshes.forEach(function (activeMesh) {
exports.activeMeshes.forEach(function (activeMesh) {
if (activeMesh === mesh) {

@@ -143,5 +179,9 @@ return;

});
activeMeshes = filteredMeshes;
exports.activeMeshes = filteredMeshes;
}
exports.removeMesh = removeMesh;
function setDebugAcceptor(acceptor) {
drawDebugger.setValueAcceptor(acceptor);
}
exports.setDebugAcceptor = setDebugAcceptor;
//# sourceMappingURL=index.js.map

@@ -6,2 +6,13 @@ export declare function translation(tx: any, ty: any, tz: any): any[];

export declare function scaling(sx: any, sy: any, sz: any): any[];
export declare function multiplyMatrices(matrices: any): any;
export declare function multiply(a: any, b: any): number[];
export declare function transpose(matrix: any): number[];
export declare function toRad(grad: any): number;
export declare function toGrad(rad: any): number;
export declare function normalizeAngleGrad(grad: any): number;
export declare function normalizeAngleRad(rad: any): number;
export declare function normalize(v: any): {
x: number;
y: number;
z: number;
};

@@ -53,2 +53,10 @@ "use strict";

exports.scaling = scaling;
function multiplyMatrices(matrices) {
var resultMatrix = matrices[0];
for (var i = 1; i < matrices.length; i++) {
resultMatrix = multiply(matrices[i], resultMatrix);
}
return resultMatrix;
}
exports.multiplyMatrices = multiplyMatrices;
function multiply(a, b) {

@@ -107,2 +115,37 @@ var a00 = a[0 * 4 + 0];

exports.multiply = multiply;
function transpose(matrix) {
var transposed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
for (var i = 0; i < 4; i++) {
for (var j = 0; j < 4; j++) {
var index1 = 4 * i + j;
var index2 = 4 * j + i;
transposed[index1] = matrix[index2];
}
}
return transposed;
}
exports.transpose = transpose;
var radToGrad = 180 / Math.PI;
function toRad(grad) {
return grad / radToGrad;
}
exports.toRad = toRad;
function toGrad(rad) {
return radToGrad * rad;
}
exports.toGrad = toGrad;
function normalizeAngleGrad(grad) {
var rad = toRad(grad);
return toGrad(Math.atan2(Math.sin(rad), Math.cos(rad)));
}
exports.normalizeAngleGrad = normalizeAngleGrad;
function normalizeAngleRad(rad) {
return Math.atan2(Math.sin(rad), Math.cos(rad));
}
exports.normalizeAngleRad = normalizeAngleRad;
function normalize(v) {
var length = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
return { x: v.x / length, y: v.y / length, z: v.z / length };
}
exports.normalize = normalize;
//# sourceMappingURL=mathUtils.js.map
/// <reference path="../typings/main.d.ts" />
export declare function setup(callback: (webGl, oldWebGl, uniforms) => void, isGlEnabled: (gl) => boolean): void;
export declare class Debugger {
private acceptor;
setValueAcceptor(acceptor: {
accept: (name: string, value: any) => void;
}): void;
setValue(name: string, value: any): void;
}

@@ -29,2 +29,23 @@ "use strict";

]);
desiredCases.push([
'drawElements',
'uniform4fv',
'bindTexture',
'bindBuffer',
'vertexAttribPointer',
'bindBuffer',
'vertexAttribPointer',
'bindBuffer'
]);
desiredCases.push([
'drawElements',
'uniform1f',
'uniform4fv',
'bindTexture',
'bindBuffer',
'vertexAttribPointer',
'bindBuffer',
'vertexAttribPointer',
'bindBuffer'
]);
function methodCalled(methodName) {

@@ -123,2 +144,3 @@ lastCalls.unshift(methodName);

}
//console.log(methodName);
if (methodName === "useProgram") {

@@ -185,2 +207,17 @@ lastProgram = args[0];

exports.setup = setup;
var Debugger = (function () {
function Debugger() {
}
Debugger.prototype.setValueAcceptor = function (acceptor) {
this.acceptor = acceptor;
};
Debugger.prototype.setValue = function (name, value) {
if (!this.acceptor) {
return;
}
this.acceptor.accept(name, value);
};
return Debugger;
}());
exports.Debugger = Debugger;
//# sourceMappingURL=utils.js.map

5

package.json
{
"name": "gsv-injection",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/index.js",

@@ -10,3 +10,3 @@ "scripts": {

"dependencies": {
"typescript-compiler": "1.4.1-2",
"mat4-decompose": "*",
"underscore": "^1.8.3"

@@ -28,2 +28,3 @@ },

"devDependencies": {
"typescript-compiler": "1.4.1-2",
"typings": "^0.5.1",

@@ -30,0 +31,0 @@ "typescript": "1.8.7",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet