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.43 to 0.0.48

src/import-modules.litcoffee

666

build/oo3d.js
// Generated by CoffeeScript 1.9.2
/*! Oo3d 0.0.43 //// MIT Licence //// http://oo3d.richplastow.com/ */
/*! Oo3d 0.0.47 //// MIT Licence //// http://oo3d.richplastow.com/ */
(function() {
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,
var Item, Layer, Main, Nwang, Program, Renderer, mat4, pick, uri, ª, ªA, ªB, ªC, ªE, ªF, ªMAX, ªMIN, ª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.43';
ªV = '0.0.47';

@@ -35,2 +35,6 @@ ªA = 'array';

ªMAX = 9007199254740991;
ªMIN = -9007199254740991;
ªW = this;

@@ -90,257 +94,2 @@

Camera = (function() {
Camera.prototype.C = 'Camera';
Camera.prototype.toString = function() {
return "[object " + this.C + "]";
};
function Camera(main1, config) {
this.main = main1;
if (config == null) {
config = {};
}
if (ªO !== ªtype(config)) {
throw TypeError("`config` must be object not " + (ªtype(config)));
}
if (ªO !== ªtype(this.main)) {
throw TypeError("`main` must be object not " + (ªtype(this.main)));
}
if ('[object Oo3d]' !== '' + this.main) {
throw TypeError("`main` must be [object Oo3d] not " + this.main);
}
this.fovy = config.fovy;
if (!this.fovy) {
this.fovy = 0.785398163;
} else if ('number' !== ªtype(this.fovy)) {
throw TypeError("If set, config.fovy must be number not " + (ªtype(this.fovy)));
} else if (0 >= this.fovy) {
throw RangeError("If set, config.fovy must be greater than 0 not " + this.fovy);
}
this.aspect = config.aspect;
if (!this.aspect) {
this.aspect = this.main.$main.width / this.main.$main.height;
} else if ('number' !== ªtype(this.aspect)) {
throw TypeError("If set, config.aspect must be number not " + (ªtype(this.aspect)));
} else if (0 >= this.aspect) {
throw RangeError("If set, config.aspect must be greater than 0 not " + this.aspect);
}
this.rX = 0;
this.rY = 0;
this.rZ = 0;
this.sX = 1;
this.sY = 1;
this.sZ = 1;
this.tX = 0;
this.tY = 0;
this.tZ = -4;
this.matTransform = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -4, 1]);
this.matProjection = mat4.perspective(this.fovy, this.aspect, 1, 100);
ª(this.fovy, this.aspect);
this.matCamera = null;
this.updateCamera();
}
Camera.prototype.updateCamera = function() {
return this.matCamera = new Float32Array(mat4.multiply(this.matProjection, this.matTransform));
};
Camera.prototype.xx = function() {};
return Camera;
})();
Item = (function() {
Item.prototype.C = "/src/class-item.litcoffee:Item";
Item.prototype.toString = function() {
return "[object Item]";
};
function Item(main1, index1, config) {
var M;
this.main = main1;
this.index = index1;
if (config == null) {
config = {};
}
M = this.C + ":constructor()\n ";
if (ªO !== ªtype(config)) {
throw TypeError(M + "`config` must be object not " + (ªtype(config)));
}
if (ªO !== ªtype(this.main)) {
throw TypeError(M + "`main` must be object not " + (ªtype(this.main)));
}
if ('[object Oo3d]' !== '' + this.main) {
throw TypeError(M + "`main` must be [object Oo3d] not " + this.main);
}
if (ªN !== ª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 || 0];
if (!this.positionBuffer) {
throw Error(M + "`config.positionI` " + config.positionI + " does not exist");
}
this.colorBuffer = this.main.colorBuffers[config.colorI || 0];
if (!this.colorBuffer) {
throw Error(M + "`config.colorI` " + config.colorI + " does not exist");
}
if (this.positionBuffer.count !== this.colorBuffer.count) {
throw Error(M + "`config.positionI` mismatches config.colorI");
}
this.count = this.positionBuffer.count;
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]];
}
this.matTransform = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
this.rX = 0;
this.rY = 0;
this.rZ = 0;
this.sX = 1;
this.sY = 1;
this.sZ = 1;
this.tX = 0;
this.tY = 0;
this.tZ = 0;
}
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;
})();
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() {

@@ -423,13 +172,17 @@ Layer.prototype.C = 'Layer';

Main = (function() {
Main.prototype.C = ªC;
Main.prototype.C = "/src/class-main.litcoffee:" + ªC;
Main.prototype.toString = function() {
return "[object " + this.C + "]";
return "[object " + ªC + "]";
};
function Main(config) {
var k, v;
var M, k, v;
if (config == null) {
config = {};
}
M = this.C + ":constructor()\n ";
if (ªO !== ªtype(config)) {
throw TypeError(M + "Optional `config` is " + (ªtype(config)) + " not object");
}
for (k in config) {

@@ -439,16 +192,37 @@ v = config[k];

}
if (!Nwang) {
throw Error(M + "Dependency 'Nwang' could not be found");
}
this.nwang = new Nwang;
this.$main = config.$main || null;
if (this.$main && ('htmlcanvaselement' !== ªtype(this.$main))) {
throw Error("If set, config.$main must be HTMLCanvasElement not " + (ªtype(this.$main)));
if (this.$main && '[object HTMLCanvasElement]' !== '' + this.$main) {
throw TypeError(M + "Optional `config.$main` is " + (ªtype(this.$main)) + " not HTMLCanvasElement");
}
this.gl = null;
if (ªA === ªtype(config.background)) {
this.bkgndR = config.background[0];
this.bkgndG = config.background[1];
this.bkgndB = config.background[2];
this.bkgndA = config.background[3];
} else {
if (!config.bkgnd) {
this.bkgndR = this.bkgndG = this.bkgndB = 0.25;
this.bkgndA = 1;
} else if ('float32array' === ªtype(config.bkgnd)) {
if (4 !== config.bkgnd.length) {
throw Error(M + "If set `config.bkgnd` must contain four elements");
}
this.bkgndR = config.bkgnd[0] || 0;
this.bkgndG = config.bkgnd[1] || 0;
this.bkgndB = config.bkgnd[2] || 0;
this.bkgndA = config.bkgnd[3] || 0;
if (0 > this.bkgndR || this.bkgndR > 1) {
throw RangeError(M + "`config.bkgnd[0]` (red) is not within range 0-1");
}
if (0 > this.bkgndG || this.bkgndG > 1) {
throw RangeError(M + "`config.bkgnd[1]` (green) is not within range 0-1");
}
if (0 > this.bkgndB || this.bkgndB > 1) {
throw RangeError(M + "`config.bkgnd[2]` (blue) is not within range 0-1");
}
if (0 > this.bkgndA || this.bkgndA > 1) {
throw RangeError(M + "`config.bkgnd[3]` (alpha) is not within range 0-1");
}
} else {
throw TypeError(M + "Optional `config.bkgnd` is " + (ªtype(config.bkgnd)) + " not float32array");
}
this.gl = null;
this.cameras = [];

@@ -458,3 +232,3 @@ this.programs = [];

this.layers = [];
this.items = [];
this.meshes = [];
this.positionBuffers = [];

@@ -472,3 +246,4 @@ this.colorBuffers = [];

Main.prototype.initGL = function() {
var ctx, j, len, ref;
var M, ctx, j, len, ref;
M = this.C + ":initGL()\n ";
try {

@@ -478,3 +253,2 @@ ref = ['webgl', 'experimental-webgl'];

ctx = ref[j];
ª(ctx);
this.gl = this.$main.getContext(ctx, {

@@ -491,3 +265,3 @@ preserveDrawingBuffer: true

if (!this.gl) {
throw Error("Unable to initialize WebGL. Your browser may not support it.");
throw Error(M + "Unable to initialize WebGL. Your browser may not support it.");
}

@@ -513,6 +287,6 @@ };

Main.prototype.addItem = function(config) {
Main.prototype.addMesh = function(config) {
var index;
index = this.items.length;
this.items[index] = new Item(this, index, config);
index = this.meshes.length;
this.meshes[index] = new Item.Mesh(this, index, config);
return index;

@@ -524,4 +298,3 @@ };

index = this.cameras.length;
this.cameras[index] = new Camera(this, config);
ª(index);
this.cameras[index] = new Item.Camera(this, index, config);
return index;

@@ -592,3 +365,3 @@ };

var c, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, mat, s, target, x0, y0, z0;
target = this.items[targetIndex] || this.cameras[0];
target = this.meshes[targetIndex] || this.cameras[0];
mat = target.matTransform;

@@ -673,3 +446,3 @@ x0 = 0 === x;

var mat, target, x1, y1, z1;
target = this.items[targetIndex] || this.cameras[0];
target = this.meshes[targetIndex] || this.cameras[0];
mat = target.matTransform;

@@ -708,3 +481,3 @@ x1 = 1 === x;

var mat, target, x0, y0, z0;
target = this.items[targetIndex] || this.cameras[0];
target = this.meshes[targetIndex] || this.cameras[0];
mat = target.matTransform;

@@ -751,3 +524,3 @@ x0 = 0 === x;

var mat, target;
target = this.items[targetIndex] || this.cameras[0];
target = this.meshes[targetIndex] || this.cameras[0];
mat = target.matTransform;

@@ -767,3 +540,6 @@ target.rX = target.rY = target.rZ = 0;

Main.prototype.setRenderMode = function(renderMode, targetIndex) {
this.items[targetIndex].renderMode = renderMode;
if (!this.meshes[targetIndex]) {
return;
}
this.meshes[targetIndex].renderMode = renderMode;
return this;

@@ -779,3 +555,3 @@ };

Main.prototype.getItemIByColor = function(color) {
Main.prototype.getMeshIByColor = function(color) {
return pick.colorToIndex(color);

@@ -803,5 +579,5 @@ };

Main.prototype.getItemSnapshot = function(itemI) {
Main.prototype.getMeshSnapshot = function(meshI) {
var item, mat;
item = this.items[itemI];
item = this.meshes[meshI];
mat = new Float32Array(16);

@@ -840,5 +616,5 @@ mat.set(item.matTransform);

Main.prototype.setItemSnapshot = function(snapshot, itemI) {
Main.prototype.setMeshSnapshot = function(snapshot, meshI) {
var item;
item = this.items[itemI];
item = this.meshes[meshI];
item.matTransform = new Float32Array(16);

@@ -888,2 +664,10 @@ item.matTransform.set(snapshot.mat);

if (ªF === typeof define && define.amd) {
} else if (ªO === typeof module && module && module.exports) {
Nwang = require('nwang');
} else {
Nwang = window.Nwang;
}
mat4 = {};

@@ -1201,2 +985,3 @@

}
n = n / 4;
n = Math.floor(n);

@@ -1211,2 +996,5 @@ c1 = uri.USUAL_S2URI[m + n];

c3 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"[(n - nM64) / 64];
if (ªU === typeof c1 || ªU === typeof c2 || ªU === typeof c3) {
ª('UNDEFINED RESULT s2uri(' + s + ')', n, nM64, (n - nM64) / 64, '' + c1 + c2 + c3);
}
return c1 + c2 + c3;

@@ -1251,2 +1039,3 @@ };

}
n = n / 4;
n = Math.floor(n);

@@ -1261,2 +1050,5 @@ c1 = uri.USUAL_T2URI[m + n];

c3 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"[(n - nM64) / 64];
if (ªU === typeof c1 || ªU === typeof c2 || ªU === typeof c3) {
ª('UNDEFINED RESULT t2uri(' + t + ')', n, nM64, (n - nM64) / 64, '' + c1 + c2 + c3);
}
return c1 + c2 + c3;

@@ -1285,3 +1077,3 @@ };

c3 = uri.B64DECODE[str[2]];
return c1 * (c2 + c3 * 64);
return c1 * (c2 + c3 * 64 * 4);
};

@@ -1298,3 +1090,3 @@

c3 = uri.B64DECODE[str[2]];
return c1 * (c2 + c3 * 64);
return c1 * (c2 + c3 * 64 * 4);
};

@@ -1440,2 +1232,243 @@

Item = (function() {
Item.prototype.C = "/src/item/base-item.litcoffee:Item";
Item.prototype.toString = function() {
return "[object Item]";
};
function Item(main1, index1, config) {
var M;
this.main = main1;
this.index = index1;
if (config == null) {
config = {};
}
M = "/src/item/base-item.litcoffee:Item:constructor()\n ";
if (ªO !== ªtype(config)) {
throw TypeError(M + "Optional `config` is " + (ªtype(config)) + " not object");
}
if (ªO !== ªtype(this.main)) {
throw TypeError(M + "`main` is " + (ªtype(this.main)) + " not object");
}
if ('[object Oo3d]' !== '' + this.main) {
throw TypeError(M + "`main` is '" + this.main + "' not '[object Oo3d]'");
}
if (ªN !== ªtype(this.index)) {
throw TypeError(M + "`index` is " + (ªtype(this.index)) + " not number");
}
if (ªMAX < this.index || this.index % 1 || 0 > this.index) {
throw RangeError(M + "`index` is " + this.index + " not 0 or a positive integer below 2^53");
}
this.matTransform = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
this.rX = 0;
this.rY = 0;
this.rZ = 0;
this.sX = 1;
this.sY = 1;
this.sZ = 1;
this.tX = 0;
this.tY = 0;
this.tZ = 0;
}
Item.prototype.getSnapshot = function(format) {
var M, m, mat, sf3;
M = "/src/item/base-item.litcoffee:Item:getSnapshot()\n ";
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 ('nwang' === format) {
sf3 = this.main.nwang.sf3;
return [sf3(this.rX), sf3(this.rY), sf3(this.rZ), sf3(this.sX), sf3(this.sY), sf3(this.sZ), sf3(this.tX), sf3(this.tY), sf3(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, l, m, matches, nwang;
M = "/src/item/base-item.litcoffee:Item:setSnapshot()\n ";
format = ªtype(snapshot);
if (ªS === format) {
format = 'm:[' === snapshot.slice(0, 3) ? 'log' : 'nwang';
}
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];
this.matTransform = new Float32Array(m.split(','));
} else if ('nwang' === format) {
nwang = this.main.nwang;
captureKeys = ['rX', 'rY', 'rZ', 'sX', 'sY', 'sZ', 'tX', 'tY', 'tZ'];
captureLengths = [1, 1, 1, 1, 1, 1, 1, 1, 1];
captureFns = [nwang.sf3, nwang.sf3, nwang.sf3, nwang.sf3, nwang.sf3, nwang.sf3, nwang.sf3, nwang.sf3, nwang.sf3];
chI = 0;
l = snapshot.length;
captureI = 0;
while (chI < l) {
captureKey = captureKeys[captureI];
captureLength = captureLengths[captureI];
captureFn = captureFns[captureI];
ch = snapshot[chI];
chI++;
this[captureKey] = captureFn(ch);
captureI++;
}
}
this.matTransform = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
this.main.rotate(this.rX, this.rY, this.rZ, this.index);
this.main.scale(this.sX, this.sY, this.sZ, this.index);
return this.main.translate(this.tX, this.tY, this.tZ, this.index);
};
return Item;
})();
Item.Camera = (function(superClass) {
extend(Camera, superClass);
Camera.prototype.C = "/src/item/class-item-camera.litcoffee:Item.Camera";
Camera.prototype.toString = function() {
return "[object Item.Camera]";
};
function Camera(main, index, config) {
var M;
if (config == null) {
config = {};
}
M = this.C + ":constructor()\n ";
Camera.__super__.constructor.call(this, main, index, config);
this.fovy = config.fovy;
if (ªU === ªtype(this.fovy)) {
this.fovy = 0.785398163;
} else if (ªN !== ªtype(this.fovy)) {
throw TypeError(M + "Optional `config.fovy` is " + (ªtype(this.fovy)) + " not number");
} else if (0 >= this.fovy) {
throw RangeError(M + "Optional `config.fovy` is " + this.fovy + " not greater than zero");
}
this.aspect = config.aspect;
if (ªU === ªtype(this.aspect)) {
this.aspect = this.main.$main.width / this.main.$main.height;
} else if (ªN !== ªtype(this.aspect)) {
throw TypeError(M + "Optional `config.aspect` is " + (ªtype(this.aspect)) + " not number");
} else if (0 >= this.aspect) {
throw RangeError(M + "Optional `config.aspect` is " + this.aspect + " not greater than zero");
}
this.matProjection = mat4.perspective(this.fovy, this.aspect, 1, 100);
this.matCamera = null;
this.matTransform[14] = -4;
this.tZ = -4;
this.updateCamera();
}
Camera.prototype.updateCamera = function() {
return this.matCamera = new Float32Array(mat4.multiply(this.matProjection, this.matTransform));
};
Camera.prototype.xx = function() {};
return Camera;
})(Item);
Item.Mesh = (function(superClass) {
extend(Mesh, superClass);
Mesh.prototype.C = "/src/item/class-item-mesh.litcoffee:Item.Mesh";
Mesh.prototype.toString = function() {
return "[object Item.Mesh]";
};
function Mesh(main, index, config) {
var M;
if (config == null) {
config = {};
}
M = this.C + ":constructor()\n ";
Mesh.__super__.constructor.call(this, main, index, config);
Mesh.__super__.constructor.call(this, main, index, config);
this.color = pick.indexToColor(this.index);
this.positionBuffer = this.main.positionBuffers[config.positionI || 0];
if (!this.positionBuffer) {
throw Error(M + "`config.positionI` " + config.positionI + " does not exist");
}
this.colorBuffer = this.main.colorBuffers[config.colorI || 0];
if (!this.colorBuffer) {
throw Error(M + "`config.colorI` " + config.colorI + " does not exist");
}
if (this.positionBuffer.count !== this.colorBuffer.count) {
throw Error(M + "`config.positionI` mismatches config.colorI");
}
this.count = this.positionBuffer.count;
this.renderMode = config.renderMode || 'TRIANGLES';
if (!Item.Mesh.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.Mesh.validBlend[config.blend[0]]) {
throw Error(M + "`config.blend[0]` is not recognised by WebGL");
}
if (!Item.Mesh.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]];
}
}
Mesh.prototype.xx = function(xx) {};
return Mesh;
})(Item);
Item.Mesh.validRenderMode = {
'POINTS': 1,
'LINES': 1,
'LINE_STRIP': 1,
'LINE_LOOP': 1,
'TRIANGLES': 1,
'TRIANGLE_STRIP': 1,
'TRIANGLE_FAN': 1
};
Item.Mesh.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
};
Program = (function() {

@@ -1537,3 +1570,3 @@ Program.prototype.C = 'Program';

Flat.prototype.vertexSource = function() {
return "attribute vec3 aVtxPosition;\nattribute vec4 aVtxColor;\n\nuniform mat4 uMatTransform;\nuniform mat4 uMatCamera;\n\nvarying vec4 vColor; // declare `vColor`\n\nvoid main() {\n\n //// Increase the size of gl.POINT from 1px to 4px. \n gl_PointSize = 4.0;\n\n //// Apply the Camera and Item transforms to each vertex position. \n //// Note that the order of these three is important. \n gl_Position = uMatCamera * uMatTransform * vec4(aVtxPosition, 1);\n\n //// Pass the vertex-color attribute unchanged to the fragment-shader. \n vColor = aVtxColor;\n}";
return "attribute vec3 aVtxPosition;\nattribute vec4 aVtxColor;\n\nuniform mat4 uMatTransform;\nuniform mat4 uMatCamera;\n\nvarying vec4 vColor; // declare `vColor`\n\nvoid main() {\n\n //// Increase the size of gl.POINT from 1px to 4px. \n gl_PointSize = 4.0;\n\n //// Apply the Camera and Mesh transforms to each vertex position. \n //// Note that the order of these three is important. \n gl_Position = uMatCamera * uMatTransform * vec4(aVtxPosition, 1);\n\n //// Pass the vertex-color attribute unchanged to the fragment-shader. \n vColor = aVtxColor;\n}";
};

@@ -1570,7 +1603,7 @@

this.uMatCameraLoc = gl.getUniformLocation(this.program, 'uMatCamera');
this.uItemColorLoc = gl.getUniformLocation(this.program, 'uItemColor');
this.uMeshColorLoc = gl.getUniformLocation(this.program, 'uMeshColor');
}
FlatItem.prototype.vertexSource = function() {
return "attribute vec3 aVtxPosition;\n\nuniform mat4 uMatTransform;\nuniform mat4 uMatCamera;\n\nuniform vec4 uItemColor; // the Item renders as a single flat color\n\n\nvarying vec4 vColor; // declare `vColor`\n\nvoid main() {\n\n //// Multiply the position by the camera transformation and matrices. \n //// Note that the order of these three is important. \n gl_Position = uMatCamera * uMatTransform * vec4(aVtxPosition, 1);\n\n //// Pass the vertex-color attribute unchanged to the fragment-shader. \n vColor = uItemColor;\n\n}";
return "attribute vec3 aVtxPosition;\n\nuniform mat4 uMatTransform;\nuniform mat4 uMatCamera;\n\nuniform vec4 uMeshColor; // the mesh renders as a single flat color\n\n\nvarying vec4 vColor; // declare `vColor`\n\nvoid main() {\n\n //// Multiply the position by the camera transformation and matrices. \n //// Note that the order of these three is important. \n gl_Position = uMatCamera * uMatTransform * vec4(aVtxPosition, 1);\n\n //// Pass the vertex-color attribute unchanged to the fragment-shader. \n vColor = uMeshColor;\n\n}";
};

@@ -1658,15 +1691,15 @@

this.uMatCameraLoc = this.main.gl.getUniformLocation(this.program.program, 'uMatCamera');
if (!config.itemIs) {
this.items = [];
} else if ('uint16array' !== ªtype(config.itemIs)) {
throw TypeError("If set, config.itemIs must be Uint16Array not " + (ªtype(config.itemIs)));
if (!config.meshIs) {
this.meshes = [];
} else if ('uint16array' !== ªtype(config.meshIs)) {
throw TypeError("If set, config.meshIs must be Uint16Array not " + (ªtype(config.meshIs)));
} else {
this.items = (function() {
this.meshes = (function() {
var j, len, ref, results;
ref = config.itemIs;
ref = config.meshIs;
results = [];
for (j = 0, len = ref.length; j < len; j++) {
i = ref[j];
results.push(this.main.items[i] || (function() {
throw RangeError("No such index " + i + " in main.items");
results.push(this.main.meshes[i] || (function() {
throw RangeError("No such index " + i + " in main.meshes");
})());

@@ -1680,3 +1713,3 @@ }

Renderer.prototype.render = function() {
var $main, aVtxColorLoc, aVtxPositionLoc, gl, index, item, main, mode, uItemColorLoc, uMatTransformLoc;
var $main, aVtxColorLoc, aVtxPositionLoc, gl, index, main, mesh, mode, uMatTransformLoc, uMeshColorLoc;
main = this.main;

@@ -1688,3 +1721,3 @@ $main = main.$main;

uMatTransformLoc = this.program.uMatTransformLoc;
uItemColorLoc = this.program.uItemColorLoc;
uMeshColorLoc = this.program.uMeshColorLoc;
if (!gl) {

@@ -1698,23 +1731,26 @@ throw Error("The WebGL rendering context is " + (ªtype(gl)));

}
index = this.items.length;
index = this.meshes.length;
while (index--) {
item = this.items[index];
gl.uniformMatrix4fv(uMatTransformLoc, gl.FALSE, item.matTransform);
if (uItemColorLoc) {
gl.uniform4fv(uItemColorLoc, item.color);
mesh = this.meshes[index];
if (!mesh) {
continue;
}
gl.bindBuffer(gl.ARRAY_BUFFER, item.positionBuffer);
gl.uniformMatrix4fv(uMatTransformLoc, gl.FALSE, mesh.matTransform);
if (uMeshColorLoc) {
gl.uniform4fv(uMeshColorLoc, mesh.color);
}
gl.bindBuffer(gl.ARRAY_BUFFER, mesh.positionBuffer);
gl.vertexAttribPointer(aVtxPositionLoc, 3, gl.FLOAT, false, 0, 0);
if (aVtxColorLoc) {
gl.bindBuffer(gl.ARRAY_BUFFER, item.colorBuffer);
gl.bindBuffer(gl.ARRAY_BUFFER, mesh.colorBuffer);
gl.vertexAttribPointer(aVtxColorLoc, 4, gl.FLOAT, false, 0, 0);
}
if (null !== item.sBlend) {
if (null !== mesh.sBlend) {
gl.enable(gl.BLEND);
gl.blendFunc(item.sBlend, item.dBlend);
gl.blendFunc(mesh.sBlend, mesh.dBlend);
} else {
gl.disable(gl.BLEND);
}
mode = gl[item.renderMode];
gl.drawArrays(mode, 0, item.count);
mode = gl[mesh.renderMode];
gl.drawArrays(mode, 0, mesh.count);
gl.flush();

@@ -1721,0 +1757,0 @@ }

Usage
=====
1. [Basic Usage](http://oo3d.richplastow.com/usage/01-basic-usage.html)
2. [Basic Picker](http://oo3d.richplastow.com/usage/02-basic-picker.html)
3. [Pick Transform](http://oo3d.richplastow.com/usage/03-pick-transform.html)
4. [Scene Builder](http://oo3d.richplastow.com/usage/04-scene-builder.html)
1. [Simple Scene](http://oo3d.richplastow.com/usage/01-simple-scene.html)
4. [Basic Usage](http://oo3d.richplastow.com/usage/04-basic-usage.html)
5. [Basic Picker](http://oo3d.richplastow.com/usage/05-basic-picker.html)
6. [Pick Transform](http://oo3d.richplastow.com/usage/06-pick-transform.html)
7. [Scene Builder](http://oo3d.richplastow.com/usage/07-scene-builder.html)
{
"name": "oo3d",
"version": "0.0.43",
"version": "0.0.48",
"description": "The Oopish WebGL engine",

@@ -17,2 +17,3 @@ "main": "build/oo3d.js",

"dependencies": {
"nwang": "0.0.2"
},

@@ -19,0 +20,0 @@ "keywords": [

@@ -11,5 +11,13 @@ Oo3d

- [NPM Package](https://www.npmjs.com/package/oo3d)
#### Test
- [Test](http://oo3d.richplastow.com/test/run-test.html)
#### Usage
- [Usage](http://oo3d.richplastow.com/#/doc/usage)

Sorry, the diff of this file is not supported yet

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

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

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