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

oo3d

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oo3d - npm Package Compare versions

Comparing version 0.0.34 to 0.0.41

src/uri.litcoffee

475

build/oo3d.js
// Generated by CoffeeScript 1.9.2
/*! Oo3d 0.0.31 //// MIT Licence //// http://oo3d.richplastow.com/ */
/*! Oo3d 0.0.41 //// MIT Licence //// http://oo3d.richplastow.com/ */
(function() {
var Camera, Item, Layer, Main, Program, Renderer, mat4, pick, ª, ªA, ªB, ªC, ªE, ªF, ªN, ªO, ªR, ªS, ªU, ªV, ªW, ªX, ªex, ªhas, ªisU, ªredefine, ªtype, ªuid,
var Camera, Item, Layer, Main, Program, Renderer, mat4, pick, uri, ª, ªA, ªB, ªC, ªE, ªF, ªN, ªO, ªR, ªS, ªU, ªV, ªW, ªX, ªex, ªhas, ªisU, ªredefine, ªtype, ªuid,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },

@@ -12,3 +12,3 @@ hasProp = {}.hasOwnProperty;

ªV = '0.0.31';
ªV = '0.0.41';

@@ -153,9 +153,10 @@ ªA = 'array';

Item = (function() {
Item.prototype.C = 'Item';
Item.prototype.C = "/src/class-item.litcoffee:Item";
Item.prototype.toString = function() {
return "[object " + this.C + "]";
return "[object Item]";
};
function Item(main1, index1, config) {
var M;
this.main = main1;

@@ -166,33 +167,46 @@ this.index = index1;

}
M = this.C + ":constructor()\n ";
if (ªO !== ªtype(config)) {
throw TypeError("`config` must be object not " + (ªtype(config)));
throw TypeError(M + "`config` must be object not " + (ªtype(config)));
}
if (ªO !== ªtype(this.main)) {
throw TypeError("`main` must be object not " + (ªtype(this.main)));
throw TypeError(M + "`main` must be object not " + (ªtype(this.main)));
}
if ('[object Oo3d]' !== '' + this.main) {
throw TypeError("`main` must be [object Oo3d] not " + this.main);
throw TypeError(M + "`main` must be [object Oo3d] not " + this.main);
}
if (ªN !== ªtype(this.index)) {
throw TypeError("`index` must be number not " + (ªtype(this.index)));
throw TypeError(M + "`index` must be number not " + (ªtype(this.index)));
}
this.color = pick.indexToColor(this.index);
this.positionBuffer = this.main.positionBuffers[config.positionI];
this.positionBuffer = this.main.positionBuffers[config.positionI || 0];
if (!this.positionBuffer) {
throw Error("config.positionI " + config.positionI + " does not exist");
throw Error(M + "`config.positionI` " + config.positionI + " does not exist");
}
this.colorBuffer = this.main.colorBuffers[config.colorI];
this.colorBuffer = this.main.colorBuffers[config.colorI || 0];
if (!this.colorBuffer) {
throw Error("config.colorI " + config.colorI + " does not exist");
throw Error(M + "`config.colorI` " + config.colorI + " does not exist");
}
if (this.positionBuffer.count !== this.colorBuffer.count) {
throw Error("config.positionI mismatches config.colorI");
throw Error(M + "`config.positionI` mismatches config.colorI");
}
this.count = this.positionBuffer.count;
if (ªA === ªtype(config.blend)) {
this.renderMode = config.renderMode || 'TRIANGLES';
if (!Item.validRenderMode[this.renderMode]) {
throw Error(M + "`config.renderMode` " + this.renderMode + " is not recognised by WebGL");
}
if (!config.blend) {
this.sBlend = null;
this.dBlend = null;
} else if (ªA !== ªtype(config.blend)) {
throw Error(M + "If set, `config.blend` must be array not " + (ªtype(config.blend)));
} else {
if (!Item.validBlend[config.blend[0]]) {
throw Error(M + "`config.blend[0]` is not recognised by WebGL");
}
if (!Item.validBlend[config.blend[1]]) {
throw Error(M + "`config.blend[1]` is not recognised by WebGL");
}
this.sBlend = this.main.gl[config.blend[0]];
this.dBlend = this.main.gl[config.blend[1]];
} else {
this.sBlend = null;
this.dBlend = null;
}

@@ -209,10 +223,97 @@ this.matTransform = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);

this.tZ = 0;
this.renderMode = config.renderMode || 'TRIANGLES';
if (ªN !== ªtype(this.main.gl[this.renderMode])) {
throw Error("`renderMode` " + this.renderMode + " is not recognised by WebGL");
}
}
Item.prototype.xx = function() {};
Item.prototype.getSnapshot = function(format) {
var m, mat;
if ('log' === format) {
m = this.matTransform;
return "m:[" + m[0] + "," + m[1] + "," + m[2] + "," + m[3] + ", " + m[4] + "," + m[5] + "," + m[6] + "," + m[7] + ", " + m[8] + "," + m[9] + "," + m[10] + "," + m[11] + ", " + m[12] + "," + m[13] + "," + m[14] + "," + m[15] + "], rX:" + this.rX + ", rY:" + this.rY + ", rZ:" + this.rZ + ", sX:" + this.sX + ", sY:" + this.sY + ", sZ:" + this.sZ + ", tX:" + this.tX + ", tY:" + this.tY + ", tZ:" + this.tZ;
} else if ('uri' === format) {
return [uri.r2uri(this.rX), uri.r2uri(this.rY), uri.r2uri(this.rZ), uri.s2uri(this.sX), uri.s2uri(this.sY), uri.s2uri(this.sZ), uri.t2uri(this.tX), uri.t2uri(this.tY), uri.t2uri(this.tZ)].join('');
} else {
mat = new Float32Array(16);
mat.set(this.matTransform);
return {
mat: mat,
rX: this.rX,
rY: this.rY,
rZ: this.rZ,
sX: this.sX,
sY: this.sY,
sZ: this.sZ,
tX: this.tX,
tY: this.tY,
tZ: this.tZ
};
}
};
Item.prototype.setSnapshot = function(snapshot) {
var M, captureFn, captureFns, captureI, captureKey, captureKeys, captureLength, captureLengths, ch, chI, format, isUC, l, m, matches, results;
M = this.C + ":setSnapshot()\n ";
format = ªtype(snapshot);
if (ªS === format) {
format = 'm:[' === snapshot.slice(0, 3) ? 'log' : 'uri';
}
if ('log' === format) {
matches = snapshot.match(/^m:\[(.*)\],\s*rX:(-?[.\d]*),\s*rY:(-?[.\d]*),\s*rZ:(-?[.\d]*),\s*sX:(-?[.\d]*),\s*sY:(-?[.\d]*),\s*sZ:(-?[.\d]*),\s*tX:(-?[.\d]*),\s*tY:(-?[.\d]*),\s*tZ:(-?[.\d]*)$/);
if (null === matches) {
throw Error(M + "log-format snapshot is invalid");
}
snapshot = matches[0], m = matches[1], this.rX = matches[2], this.rY = matches[3], this.rZ = matches[4], this.sX = matches[5], this.sY = matches[6], this.sZ = matches[7], this.tX = matches[8], this.tY = matches[9], this.tZ = matches[10];
return this.matTransform = new Float32Array(m.split(','));
} else if ('uri' === format) {
isUC = {
A: 1,
B: 1,
C: 1,
D: 1,
E: 1,
F: 1,
G: 1,
H: 1,
I: 1,
J: 1,
K: 1,
L: 1,
M: 1,
N: 1,
O: 1,
P: 1,
Q: 1,
R: 1,
S: 1,
T: 1,
U: 1,
V: 1,
W: 1,
X: 1,
Y: 1,
Z: 1
};
captureKeys = ['rX', 'rY', 'rZ', 'sX', 'sY', 'sZ', 'tX', 'tY', 'tZ'];
captureLengths = [2, 2, 2, 3, 3, 3, 3, 3, 3];
captureFns = [uri.uri2r, uri.uri2r, uri.uri2r, uri.uri2s, uri.uri2s, uri.uri2s, uri.uri2t, uri.uri2t, uri.uri2t];
chI = 0;
l = snapshot.length;
captureI = 0;
results = [];
while (chI < l) {
captureKey = captureKeys[captureI];
captureLength = captureLengths[captureI];
captureFn = captureFns[captureI];
ch = snapshot[chI];
if (isUC[ch]) {
chI++;
this[captureKey] = captureFn(ch);
} else {
this[captureKey] = captureFn(snapshot.substr(chI, captureLength));
chI += captureLength;
}
results.push(captureI++);
}
return results;
}
};
return Item;

@@ -222,2 +323,26 @@

Item.validRenderMode = {
'POINTS': 1,
'LINES': 1,
'LINE_STRIP': 1,
'LINE_LOOP': 1,
'TRIANGLES': 1,
'TRIANGLE_STRIP': 1,
'TRIANGLE_FAN': 1
};
Item.validBlend = {
'ZERO': 1,
'ONE': 1,
'SRC_COLOR': 1,
'ONE_MINUS_SRC_COLOR': 1,
'DST_COLOR': 1,
'ONE_MINUS_DST_COLOR': 1,
'SRC_ALPHA': 1,
'ONE_MINUS_SRC_ALPHA': 1,
'DST_ALPHA': 1,
'ONE_MINUS_DST_ALPHA': 1,
'SRC_ALPHA_SATURATE': 1
};
Layer = (function() {

@@ -340,2 +465,3 @@ Layer.prototype.C = 'Layer';

this.initCanvas();
this.initBuffers();
}

@@ -377,2 +503,7 @@ }

Main.prototype.initBuffers = function() {
this.addPositionBuffer([]);
return this.addColorBuffer([]);
};
Main.prototype.cleanUp = function() {};

@@ -940,2 +1071,300 @@

uri = {};
uri.r2Tenmin = function(r) {
return Math.round(r * uri.RESOLUTION_R);
};
uri.tenmin2r = function(r) {
return r / uri.RESOLUTION_R;
};
uri.r2uri = function(radians) {
var PI2, c1, c1i, c2, c2i, tenmin;
PI2 = Math.PI * 2;
radians = radians % PI2;
if (0 > radians) {
radians += PI2;
}
tenmin = uri.r2Tenmin(radians);
c1 = uri.USUAL_R2URI[tenmin];
if (c1) {
return c1;
}
c1i = tenmin % 36;
c2i = (tenmin - c1i) / 36;
c1 = "0123456789abcdefghijklmnopqrstuvwxyz"[c1i];
c2 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX"[c2i];
return '' + c1 + c2;
};
uri.s2uri = function(s) {
var c1, c2, c3, m, n, nM64, neg;
if (0 > s) {
neg = true;
s = Math.abs(s);
}
if (0.0001 > s) {
return 'A';
}
if (0.001 > s) {
m = neg ? 'a' : 'p';
n = s * 10000000;
} else if (0.01 > s) {
m = neg ? 'b' : 'o';
n = s * 1000000;
} else if (0.1 > s) {
m = neg ? 'c' : 'n';
n = s * 100000;
} else if (1 > s) {
m = neg ? 'd' : 'm';
n = s * 10000;
} else if (10 > s) {
m = neg ? 'e' : 'l';
n = s * 1000;
} else if (100 > s) {
m = neg ? 'f' : 'k';
n = s * 100;
} else if (1000 > s) {
m = neg ? 'g' : 'j';
n = s * 10;
} else if (10000 > s) {
m = neg ? 'h' : 'i';
n = s;
} else {
return 'Z';
}
n = Math.floor(n);
c1 = uri.USUAL_S2URI[m + n];
if (c1) {
return c1;
}
nM64 = n % 64;
c1 = m;
c2 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"[nM64];
c3 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"[(n - nM64) / 64];
return c1 + c2 + c3;
};
uri.t2uri = function(t) {
var c1, c2, c3, m, n, nM64, neg;
if (0 > t) {
neg = true;
t = Math.abs(t);
}
if (0.0001 > t) {
return 'A';
}
if (0.001 > t) {
m = neg ? 'a' : 'p';
n = t * 10000000;
} else if (0.01 > t) {
m = neg ? 'b' : 'o';
n = t * 1000000;
} else if (0.1 > t) {
m = neg ? 'c' : 'n';
n = t * 100000;
} else if (1 > t) {
m = neg ? 'd' : 'm';
n = t * 10000;
} else if (10 > t) {
m = neg ? 'e' : 'l';
n = t * 1000;
} else if (100 > t) {
m = neg ? 'f' : 'k';
n = t * 100;
} else if (1000 > t) {
m = neg ? 'g' : 'j';
n = t * 10;
} else if (10000 > t) {
m = neg ? 'h' : 'i';
n = t;
} else {
return 'Z';
}
n = Math.floor(n);
c1 = uri.USUAL_T2URI[m + n];
if (c1) {
return c1;
}
nM64 = n % 64;
c1 = m;
c2 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"[nM64];
c3 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"[(n - nM64) / 64];
return c1 + c2 + c3;
};
uri.uri2r = function(str) {
var c1, c2, usual;
usual = uri.USUAL_URI2R[str];
if (ªN === typeof usual) {
return uri.tenmin2r(usual);
}
c1 = uri.B64DECODE[str[0]];
c2 = uri.B64DECODE[str[1]];
return uri.tenmin2r(c1 * 60 + c2);
};
uri.uri2s = function(str) {
var c1, c2, c3, usual;
usual = uri.USUAL_URI2S[str];
if (ªN === typeof usual) {
return usual;
}
c1 = uri.MULTIPLIER[str[0]];
c2 = uri.B64DECODE[str[1]];
c3 = uri.B64DECODE[str[2]];
return c1 * (c2 + c3 * 64);
};
uri.uri2t = function(str) {
var c1, c2, c3, usual;
usual = uri.USUAL_URI2T[str];
if (ªN === typeof usual) {
return usual;
}
c1 = uri.MULTIPLIER[str[0]];
c2 = uri.B64DECODE[str[1]];
c3 = uri.B64DECODE[str[2]];
return c1 * (c2 + c3 * 64);
};
uri.RESOLUTION_R = 1 / (Math.PI * 2 / 36 / 60);
uri.USUAL_R2URI = (function() {
var PI, out;
PI = Math.PI;
out = {};
out[0] = 'A';
out[uri.r2Tenmin(PI / 6.0)] = 'B';
out[uri.r2Tenmin(PI / 4.0)] = 'C';
out[uri.r2Tenmin(PI / 3.0)] = 'D';
out[uri.r2Tenmin(PI * 0.5)] = 'E';
out[uri.r2Tenmin(PI / 1.5)] = 'F';
out[uri.r2Tenmin(PI * 0.75)] = 'G';
out[uri.r2Tenmin(PI / 1.2)] = 'H';
out[uri.r2Tenmin(PI)] = 'I';
out[uri.r2Tenmin(PI / 6.0 + PI)] = 'J';
out[uri.r2Tenmin(PI / 4.0 + PI)] = 'K';
out[uri.r2Tenmin(PI / 3.0 + PI)] = 'L';
out[uri.r2Tenmin(PI * 1.5)] = 'M';
out[uri.r2Tenmin(PI / 1.5 + PI)] = 'N';
out[uri.r2Tenmin(PI * 1.75)] = 'O';
out[uri.r2Tenmin(PI / 1.2 + PI)] = 'P';
out[uri.r2Tenmin(PI * 2.0)] = 'Q';
return out;
})();
uri.USUAL_URI2R = (function() {
var key, out, ref, val;
out = {};
ref = uri.USUAL_R2URI;
for (key in ref) {
val = ref[key];
out[val] = +key;
}
return out;
})();
uri.USUAL_S2URI = {
d1250: 'C',
d2500: 'D',
d5000: 'E',
e1000: 'F',
e2000: 'G',
e4000: 'H',
e8000: 'I',
m1250: 'R',
m2500: 'S',
m5000: 'T',
l1000: 'U',
l2000: 'V',
l4000: 'W',
l8000: 'X'
};
uri.USUAL_URI2S = {
A: 0,
C: -0.125,
D: -0.25,
E: -0.5,
F: -1,
G: -2,
H: -4,
I: -8,
R: 0.125,
S: 0.25,
T: 0.5,
U: 1,
V: 2,
W: 4,
X: 8,
Z: 10000
};
uri.USUAL_T2URI = {
d1250: 'C',
d2500: 'D',
d5000: 'E',
e1000: 'F',
e2000: 'G',
e4000: 'H',
e8000: 'I',
m1250: 'R',
m2500: 'S',
m5000: 'T',
l1000: 'U',
l2000: 'V',
l4000: 'W',
l8000: 'X'
};
uri.USUAL_URI2T = {
A: 0,
C: -0.125,
D: -0.25,
E: -0.5,
F: -1,
G: -2,
H: -4,
I: -8,
R: 0.125,
S: 0.25,
T: 0.5,
U: 1,
V: 2,
W: 4,
X: 8,
Z: 10000
};
uri.MULTIPLIER = {
a: -1 / 10000000,
b: -1 / 1000000,
c: -1 / 100000,
d: -1 / 10000,
e: -1 / 1000,
f: -1 / 100,
g: -1 / 10,
h: -1,
p: 1 / 10000000,
o: 1 / 1000000,
n: 1 / 100000,
m: 1 / 10000,
l: 1 / 1000,
k: 1 / 100,
j: 1 / 10,
i: 1
};
uri.B64DECODE = (function() {
var b64, i, j, out;
out = {};
b64 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
for (i = j = 0; j <= 63; i = ++j) {
out[b64[i]] = i;
}
return out;
})();
Program = (function() {

@@ -942,0 +1371,0 @@ Program.prototype.C = 'Program';

2

package.json
{
"name": "oo3d",
"version": "0.0.34",
"version": "0.0.41",
"description": "The Oopish WebGL engine",

@@ -5,0 +5,0 @@ "main": "build/oo3d.js",

Sorry, the diff of this file is too big to display

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

Sorry, the diff of this file is not supported yet

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