Found 30 repositories(showing 30)
Loubaris
Lightweight pseudo-3D FPS engine built with Python and Pygame, uses sprites and maths.
spritejs
Matrix and Vector model for spritejs.
MattDrivenDev
A simple (don't ask about the matrix math!) SNES-style Mode7 camera for a sprite-based MonoGame game.
clayasaurus
ArcLib is a collection of useful 2D game programming library code. All libraries are dependent on the Arc core, simply known as Arc. Arc contains a core that provides basic windowing, input, drawing, and math functionality. From there, Arc offers several add-ons for advanced features such as OpenAL sound, scenegraph, GUI, 2d physics, freetype font rendering, particle effects, sprites, a camera system, and more.
SaiGaneshRachamadugu
2D Basket ball game using unity 2D, Sprites, Line renderer and Vector Math
mrthris32ra
A Math-based tower defense (TD) game project that I'm working on. I use Grok AI to create the sprites, towers, enemies, and much more.
willshion
// Thre e.js - http://github.com/mrdoob/three.js 'use strict'; var THREE = THREE || { REVISION: "49" }; self.Int32Array || (self.Int32Array = Array, self.Float32Array = Array); (function() { for (var a = 0, b = ["ms", "moz", "webkit", "o"], c = 0; c < b.length && !window.requestAnimationFrame; ++c) { window.requestAnimationFrame = window[b[c] + "RequestAnimationFrame"]; window.cancelAnimationFrame = window[b[c] + "CancelAnimationFrame"] || window[b[c] + "CancelRequestAnimationFrame"] } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(b) { var c = Date.now() , f = Math.max(0, 16 - (c - a)) , g = window.setTimeout(function() { b(c + f) }, f); a = c + f; return g } ; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(a) { clearTimeout(a) } })(); THREE.Clock = function(a) { this.autoStart = a !== void 0 ? a : true; this.elapsedTime = this.oldTime = this.startTime = 0; this.running = false } ; THREE.Clock.prototype.start = function() { this.oldTime = this.startTime = Date.now(); this.running = true } ; THREE.Clock.prototype.stop = function() { this.getElapsedTime(); this.running = false } ; THREE.Clock.prototype.getElapsedTime = function() { return this.elapsedTime = this.elapsedTime + this.getDelta() } ; THREE.Clock.prototype.getDelta = function() { var a = 0; this.autoStart && !this.running && this.start(); if (this.running) { var b = Date.now() , a = 0.001 * (b - this.oldTime); this.oldTime = b; this.elapsedTime = this.elapsedTime + a } return a } ; THREE.Color = function(a) { a !== void 0 && this.setHex(a); return this } ; THREE.Color.prototype = { constructor: THREE.Color, r: 1, g: 1, b: 1, copy: function(a) { this.r = a.r; this.g = a.g; this.b = a.b; return this }, copyGammaToLinear: function(a) { this.r = a.r * a.r; this.g = a.g * a.g; this.b = a.b * a.b; return this }, copyLinearToGamma: function(a) { this.r = Math.sqrt(a.r); this.g = Math.sqrt(a.g); this.b = Math.sqrt(a.b); return this }, convertGammaToLinear: function() { var a = this.r , b = this.g , c = this.b; this.r = a * a; this.g = b * b; this.b = c * c; return this }, convertLinearToGamma: function() { this.r = Math.sqrt(this.r); this.g = Math.sqrt(this.g); this.b = Math.sqrt(this.b); return this }, setRGB: function(a, b, c) { this.r = a; this.g = b; this.b = c; return this }, setHSV: function(a, b, c) { var d, e, f; if (c === 0) this.r = this.g = this.b = 0; else { d = Math.floor(a * 6); e = a * 6 - d; a = c * (1 - b); f = c * (1 - b * e); b = c * (1 - b * (1 - e)); switch (d) { case 1: this.r = f; this.g = c; this.b = a; break; case 2: this.r = a; this.g = c; this.b = b; break; case 3: this.r = a; this.g = f; this.b = c; break; case 4: this.r = b; this.g = a; this.b = c; break; case 5: this.r = c; this.g = a; this.b = f; break; case 6: case 0: this.r = c; this.g = b; this.b = a } } return this }, setHex: function(a) { a = Math.floor(a); this.r = (a >> 16 & 255) / 255; this.g = (a >> 8 & 255) / 255; this.b = (a & 255) / 255; return this }, lerpSelf: function(a, b) { this.r = this.r + (a.r - this.r) * b; this.g = this.g + (a.g - this.g) * b; this.b = this.b + (a.b - this.b) * b; return this }, getHex: function() { return Math.floor(this.r * 255) << 16 ^ Math.floor(this.g * 255) << 8 ^ Math.floor(this.b * 255) }, getContextStyle: function() { return "rgb(" + Math.floor(this.r * 255) + "," + Math.floor(this.g * 255) + "," + Math.floor(this.b * 255) + ")" }, clone: function() { return (new THREE.Color).setRGB(this.r, this.g, this.b) } }; THREE.Vector2 = function(a, b) { this.x = a || 0; this.y = b || 0 } ; THREE.Vector2.prototype = { constructor: THREE.Vector2, set: function(a, b) { this.x = a; this.y = b; return this }, copy: function(a) { this.x = a.x; this.y = a.y; return this }, add: function(a, b) { this.x = a.x + b.x; this.y = a.y + b.y; return this }, addSelf: function(a) { this.x = this.x + a.x; this.y = this.y + a.y; return this }, sub: function(a, b) { this.x = a.x - b.x; this.y = a.y - b.y; return this }, subSelf: function(a) { this.x = this.x - a.x; this.y = this.y - a.y; return this }, multiplyScalar: function(a) { this.x = this.x * a; this.y = this.y * a; return this }, divideScalar: function(a) { if (a) { this.x = this.x / a; this.y = this.y / a } else this.set(0, 0); return this }, negate: function() { return this.multiplyScalar(-1) }, dot: function(a) { return this.x * a.x + this.y * a.y }, lengthSq: function() { return this.x * this.x + this.y * this.y }, length: function() { return Math.sqrt(this.lengthSq()) }, normalize: function() { return this.divideScalar(this.length()) }, distanceTo: function(a) { return Math.sqrt(this.distanceToSquared(a)) }, distanceToSquared: function(a) { var b = this.x - a.x , a = this.y - a.y; return b * b + a * a }, setLength: function(a) { return this.normalize().multiplyScalar(a) }, lerpSelf: function(a, b) { this.x = this.x + (a.x - this.x) * b; this.y = this.y + (a.y - this.y) * b; return this }, equals: function(a) { return a.x === this.x && a.y === this.y }, isZero: function() { return this.lengthSq() < 1.0E-4 }, clone: function() { return new THREE.Vector2(this.x,this.y) } }; THREE.Vector3 = function(a, b, c) { this.x = a || 0; this.y = b || 0; this.z = c || 0 } ; THREE.Vector3.prototype = { constructor: THREE.Vector3, set: function(a, b, c) { this.x = a; this.y = b; this.z = c; return this }, setX: function(a) { this.x = a; return this }, setY: function(a) { this.y = a; return this }, setZ: function(a) { this.z = a; return this }, copy: function(a) { this.x = a.x; this.y = a.y; this.z = a.z; return this }, add: function(a, b) { this.x = a.x + b.x; this.y = a.y + b.y; this.z = a.z + b.z; return this }, addSelf: function(a) { this.x = this.x + a.x; this.y = this.y + a.y; this.z = this.z + a.z; return this }, addScalar: function(a) { this.x = this.x + a; this.y = this.y + a; this.z = this.z + a; return this }, sub: function(a, b) { this.x = a.x - b.x; this.y = a.y - b.y; this.z = a.z - b.z; return this }, subSelf: function(a) { this.x = this.x - a.x; this.y = this.y - a.y; this.z = this.z - a.z; return this }, multiply: function(a, b) { this.x = a.x * b.x; this.y = a.y * b.y; this.z = a.z * b.z; return this }, multiplySelf: function(a) { this.x = this.x * a.x; this.y = this.y * a.y; this.z = this.z * a.z; return this }, multiplyScalar: function(a) { this.x = this.x * a; this.y = this.y * a; this.z = this.z * a; return this }, divideSelf: function(a) { this.x = this.x / a.x; this.y = this.y / a.y; this.z = this.z / a.z; return this }, divideScalar: function(a) { if (a) { this.x = this.x / a; this.y = this.y / a; this.z = this.z / a } else this.z = this.y = this.x = 0; return this }, negate: function() { return this.multiplyScalar(-1) }, dot: function(a) { return this.x * a.x + this.y * a.y + this.z * a.z }, lengthSq: function() { return this.x * this.x + this.y * this.y + this.z * this.z }, length: function() { return Math.sqrt(this.lengthSq()) }, lengthManhattan: function() { return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) }, normalize: function() { return this.divideScalar(this.length()) }, setLength: function(a) { return this.normalize().multiplyScalar(a) }, lerpSelf: function(a, b) { this.x = this.x + (a.x - this.x) * b; this.y = this.y + (a.y - this.y) * b; this.z = this.z + (a.z - this.z) * b; return this }, cross: function(a, b) { this.x = a.y * b.z - a.z * b.y; this.y = a.z * b.x - a.x * b.z; this.z = a.x * b.y - a.y * b.x; return this }, crossSelf: function(a) { var b = this.x , c = this.y , d = this.z; this.x = c * a.z - d * a.y; this.y = d * a.x - b * a.z; this.z = b * a.y - c * a.x; return this }, distanceTo: function(a) { return Math.sqrt(this.distanceToSquared(a)) }, distanceToSquared: function(a) { return (new THREE.Vector3).sub(this, a).lengthSq() }, getPositionFromMatrix: function(a) { this.x = a.elements[12]; this.y = a.elements[13]; this.z = a.elements[14]; return this }, getRotationFromMatrix: function(a, b) { var c = b ? b.x : 1 , d = b ? b.y : 1 , e = b ? b.z : 1 , f = a.elements[0] / c , g = a.elements[4] / d , c = a.elements[1] / c , d = a.elements[5] / d , h = a.elements[9] / e , j = a.elements[10] / e; this.y = Math.asin(a.elements[8] / e); e = Math.cos(this.y); if (Math.abs(e) > 1.0E-5) { this.x = Math.atan2(-h / e, j / e); this.z = Math.atan2(-g / e, f / e) } else { this.x = 0; this.z = Math.atan2(c, d) } return this }, getScaleFromMatrix: function(a) { var b = this.set(a.elements[0], a.elements[1], a.elements[2]).length() , c = this.set(a.elements[4], a.elements[5], a.elements[6]).length() , a = this.set(a.elements[8], a.elements[9], a.elements[10]).length(); this.x = b; this.y = c; this.z = a }, equals: function(a) { return a.x === this.x && a.y === this.y && a.z === this.z }, isZero: function() { return this.lengthSq() < 1.0E-4 }, clone: function() { return new THREE.Vector3(this.x,this.y,this.z) } }; THREE.Vector4 = function(a, b, c, d) { this.x = a || 0; this.y = b || 0; this.z = c || 0; this.w = d !== void 0 ? d : 1 } ; THREE.Vector4.prototype = { constructor: THREE.Vector4, set: function(a, b, c, d) { this.x = a; this.y = b; this.z = c; this.w = d; return this }, copy: function(a) { this.x = a.x; this.y = a.y; this.z = a.z; this.w = a.w !== void 0 ? a.w : 1; return this }, add: function(a, b) { this.x = a.x + b.x; this.y = a.y + b.y; this.z = a.z + b.z; this.w = a.w + b.w; return this }, addSelf: function(a) { this.x = this.x + a.x; this.y = this.y + a.y; this.z = this.z + a.z; this.w = this.w + a.w; return this }, sub: function(a, b) { this.x = a.x - b.x; this.y = a.y - b.y; this.z = a.z - b.z; this.w = a.w - b.w; return this }, subSelf: function(a) { this.x = this.x - a.x; this.y = this.y - a.y; this.z = this.z - a.z; this.w = this.w - a.w; return this }, multiplyScalar: function(a) { this.x = this.x * a; this.y = this.y * a; this.z = this.z * a; this.w = this.w * a; return this }, divideScalar: function(a) { if (a) { this.x = this.x / a; this.y = this.y / a; this.z = this.z / a; this.w = this.w / a } else { this.z = this.y = this.x = 0; this.w = 1 } return this }, negate: function() { return this.multiplyScalar(-1) }, dot: function(a) { return this.x * a.x + this.y * a.y + this.z * a.z + this.w * a.w }, lengthSq: function() { return this.dot(this) }, length: function() { return Math.sqrt(this.lengthSq()) }, normalize: function() { return this.divideScalar(this.length()) }, setLength: function(a) { return this.normalize().multiplyScalar(a) }, lerpSelf: function(a, b) { this.x = this.x + (a.x - this.x) * b; this.y = this.y + (a.y - this.y) * b; this.z = this.z + (a.z - this.z) * b; this.w = this.w + (a.w - this.w) * b; return this }, clone: function() { return new THREE.Vector4(this.x,this.y,this.z,this.w) } }; THREE.Frustum = function() { this.planes = [new THREE.Vector4, new THREE.Vector4, new THREE.Vector4, new THREE.Vector4, new THREE.Vector4, new THREE.Vector4] } ; THREE.Frustum.prototype.setFromMatrix = function(a) { var b, c = this.planes, d = a.elements, a = d[0]; b = d[1]; var e = d[2] , f = d[3] , g = d[4] , h = d[5] , j = d[6] , l = d[7] , k = d[8] , p = d[9] , m = d[10] , o = d[11] , q = d[12] , n = d[13] , r = d[14] , d = d[15]; c[0].set(f - a, l - g, o - k, d - q); c[1].set(f + a, l + g, o + k, d + q); c[2].set(f + b, l + h, o + p, d + n); c[3].set(f - b, l - h, o - p, d - n); c[4].set(f - e, l - j, o - m, d - r); c[5].set(f + e, l + j, o + m, d + r); for (a = 0; a < 6; a++) { b = c[a]; b.divideScalar(Math.sqrt(b.x * b.x + b.y * b.y + b.z * b.z)) } } ; THREE.Frustum.prototype.contains = function(a) { for (var b = this.planes, c = a.matrixWorld, d = c.elements, c = -a.geometry.boundingSphere.radius * c.getMaxScaleOnAxis(), e = 0; e < 6; e++) { a = b[e].x * d[12] + b[e].y * d[13] + b[e].z * d[14] + b[e].w; if (a <= c) return false } return true } ; THREE.Frustum.__v1 = new THREE.Vector3; THREE.Ray = function(a, b) { function c(a, b, c) { q.sub(c, a); u = q.dot(b); t = n.add(a, r.copy(b).multiplyScalar(u)); return y = c.distanceTo(t) } function d(a, b, c, d) { q.sub(d, b); n.sub(c, b); r.sub(a, b); s = q.dot(q); w = q.dot(n); H = q.dot(r); E = n.dot(n); z = n.dot(r); v = 1 / (s * E - w * w); A = (E * H - w * z) * v; J = (s * z - w * H) * v; return A >= 0 && J >= 0 && A + J < 1 } this.origin = a || new THREE.Vector3; this.direction = b || new THREE.Vector3; var e = 1.0E-4; this.setPrecision = function(a) { e = a } ; var f = new THREE.Vector3 , g = new THREE.Vector3 , h = new THREE.Vector3 , j = new THREE.Vector3 , l = new THREE.Vector3 , k = new THREE.Vector3 , p = new THREE.Vector3 , m = new THREE.Vector3 , o = new THREE.Vector3; this.intersectObject = function(a) { var b, n = []; if (a instanceof THREE.Particle) { var q = c(this.origin, this.direction, a.matrixWorld.getPosition()); if (q > a.scale.x) return []; b = { distance: q, point: a.position, face: null , object: a }; n.push(b) } else if (a instanceof THREE.Mesh) { var q = c(this.origin, this.direction, a.matrixWorld.getPosition()) , r = THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(), a.matrixWorld.getColumnY().length(), a.matrixWorld.getColumnZ().length()); if (q > a.geometry.boundingSphere.radius * Math.max(r.x, Math.max(r.y, r.z))) return n; var s, i, t = a.geometry, u = t.vertices, C; a.matrixRotationWorld.extractRotation(a.matrixWorld); q = 0; for (r = t.faces.length; q < r; q++) { b = t.faces[q]; l.copy(this.origin); k.copy(this.direction); C = a.matrixWorld; p = C.multiplyVector3(p.copy(b.centroid)).subSelf(l); m = a.matrixRotationWorld.multiplyVector3(m.copy(b.normal)); s = k.dot(m); if (!(Math.abs(s) < e)) { i = m.dot(p) / s; if (!(i < 0) && (a.doubleSided || (a.flipSided ? s > 0 : s < 0))) { o.add(l, k.multiplyScalar(i)); if (b instanceof THREE.Face3) { f = C.multiplyVector3(f.copy(u[b.a])); g = C.multiplyVector3(g.copy(u[b.b])); h = C.multiplyVector3(h.copy(u[b.c])); if (d(o, f, g, h)) { b = { distance: l.distanceTo(o), point: o.clone(), face: b, object: a }; n.push(b) } } else if (b instanceof THREE.Face4) { f = C.multiplyVector3(f.copy(u[b.a])); g = C.multiplyVector3(g.copy(u[b.b])); h = C.multiplyVector3(h.copy(u[b.c])); j = C.multiplyVector3(j.copy(u[b.d])); if (d(o, f, g, j) || d(o, g, h, j)) { b = { distance: l.distanceTo(o), point: o.clone(), face: b, object: a }; n.push(b) } } } } } } return n } ; this.intersectObjects = function(a) { for (var b = [], c = 0, d = a.length; c < d; c++) Array.prototype.push.apply(b, this.intersectObject(a[c])); b.sort(function(a, b) { return a.distance - b.distance }); return b } ; var q = new THREE.Vector3, n = new THREE.Vector3, r = new THREE.Vector3, u, t, y, s, w, H, E, z, v, A, J } ; THREE.Rectangle = function() { function a() { f = d - b; g = e - c } var b, c, d, e, f, g, h = true; this.getX = function() { return b } ; this.getY = function() { return c } ; this.getWidth = function() { return f } ; this.getHeight = function() { return g } ; this.getLeft = function() { return b } ; this.getTop = function() { return c } ; this.getRight = function() { return d } ; this.getBottom = function() { return e } ; this.set = function(f, g, k, p) { h = false; b = f; c = g; d = k; e = p; a() } ; this.addPoint = function(f, g) { if (h) { h = false; b = f; c = g; d = f; e = g } else { b = b < f ? b : f; c = c < g ? c : g; d = d > f ? d : f; e = e > g ? e : g } a() } ; this.add3Points = function(f, g, k, p, m, o) { if (h) { h = false; b = f < k ? f < m ? f : m : k < m ? k : m; c = g < p ? g < o ? g : o : p < o ? p : o; d = f > k ? f > m ? f : m : k > m ? k : m; e = g > p ? g > o ? g : o : p > o ? p : o } else { b = f < k ? f < m ? f < b ? f : b : m < b ? m : b : k < m ? k < b ? k : b : m < b ? m : b; c = g < p ? g < o ? g < c ? g : c : o < c ? o : c : p < o ? p < c ? p : c : o < c ? o : c; d = f > k ? f > m ? f > d ? f : d : m > d ? m : d : k > m ? k > d ? k : d : m > d ? m : d; e = g > p ? g > o ? g > e ? g : e : o > e ? o : e : p > o ? p > e ? p : e : o > e ? o : e } a() } ; this.addRectangle = function(f) { if (h) { h = false; b = f.getLeft(); c = f.getTop(); d = f.getRight(); e = f.getBottom() } else { b = b < f.getLeft() ? b : f.getLeft(); c = c < f.getTop() ? c : f.getTop(); d = d > f.getRight() ? d : f.getRight(); e = e > f.getBottom() ? e : f.getBottom() } a() } ; this.inflate = function(f) { b = b - f; c = c - f; d = d + f; e = e + f; a() } ; this.minSelf = function(f) { b = b > f.getLeft() ? b : f.getLeft(); c = c > f.getTop() ? c : f.getTop(); d = d < f.getRight() ? d : f.getRight(); e = e < f.getBottom() ? e : f.getBottom(); a() } ; this.intersects = function(a) { return d < a.getLeft() || b > a.getRight() || e < a.getTop() || c > a.getBottom() ? false : true } ; this.empty = function() { h = true; e = d = c = b = 0; a() } ; this.isEmpty = function() { return h } } ; THREE.Math = { clamp: function(a, b, c) { return a < b ? b : a > c ? c : a }, clampBottom: function(a, b) { return a < b ? b : a }, mapLinear: function(a, b, c, d, e) { return d + (a - b) * (e - d) / (c - b) }, random16: function() { return (65280 * Math.random() + 255 * Math.random()) / 65535 }, randInt: function(a, b) { return a + Math.floor(Math.random() * (b - a + 1)) }, randFloat: function(a, b) { return a + Math.random() * (b - a) }, randFloatSpread: function(a) { return a * (0.5 - Math.random()) }, sign: function(a) { return a < 0 ? -1 : a > 0 ? 1 : 0 } }; THREE.Matrix3 = function() { this.elements = new Float32Array(9) } ; THREE.Matrix3.prototype = { constructor: THREE.Matrix3, getInverse: function(a) { var b = a.elements , a = b[10] * b[5] - b[6] * b[9] , c = -b[10] * b[1] + b[2] * b[9] , d = b[6] * b[1] - b[2] * b[5] , e = -b[10] * b[4] + b[6] * b[8] , f = b[10] * b[0] - b[2] * b[8] , g = -b[6] * b[0] + b[2] * b[4] , h = b[9] * b[4] - b[5] * b[8] , j = -b[9] * b[0] + b[1] * b[8] , l = b[5] * b[0] - b[1] * b[4] , b = b[0] * a + b[1] * e + b[2] * h; b === 0 && console.warn("Matrix3.getInverse(): determinant == 0"); var b = 1 / b , k = this.elements; k[0] = b * a; k[1] = b * c; k[2] = b * d; k[3] = b * e; k[4] = b * f; k[5] = b * g; k[6] = b * h; k[7] = b * j; k[8] = b * l; return this }, transpose: function() { var a, b = this.elements; a = b[1]; b[1] = b[3]; b[3] = a; a = b[2]; b[2] = b[6]; b[6] = a; a = b[5]; b[5] = b[7]; b[7] = a; return this }, transposeIntoArray: function(a) { var b = this.m; a[0] = b[0]; a[1] = b[3]; a[2] = b[6]; a[3] = b[1]; a[4] = b[4]; a[5] = b[7]; a[6] = b[2]; a[7] = b[5]; a[8] = b[8]; return this } }; THREE.Matrix4 = function(a, b, c, d, e, f, g, h, j, l, k, p, m, o, q, n) { this.elements = new Float32Array(16); this.set(a !== void 0 ? a : 1, b || 0, c || 0, d || 0, e || 0, f !== void 0 ? f : 1, g || 0, h || 0, j || 0, l || 0, k !== void 0 ? k : 1, p || 0, m || 0, o || 0, q || 0, n !== void 0 ? n : 1) } ; THREE.Matrix4.prototype = { constructor: THREE.Matrix4, set: function(a, b, c, d, e, f, g, h, j, l, k, p, m, o, q, n) { var r = this.elements; r[0] = a; r[4] = b; r[8] = c; r[12] = d; r[1] = e; r[5] = f; r[9] = g; r[13] = h; r[2] = j; r[6] = l; r[10] = k; r[14] = p; r[3] = m; r[7] = o; r[11] = q; r[15] = n; return this }, identity: function() { this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); return this }, copy: function(a) { a = a.elements; this.set(a[0], a[4], a[8], a[12], a[1], a[5], a[9], a[13], a[2], a[6], a[10], a[14], a[3], a[7], a[11], a[15]); return this }, lookAt: function(a, b, c) { var d = this.elements , e = THREE.Matrix4.__v1 , f = THREE.Matrix4.__v2 , g = THREE.Matrix4.__v3; g.sub(a, b).normalize(); if (g.length() === 0) g.z = 1; e.cross(c, g).normalize(); if (e.length() === 0) { g.x = g.x + 1.0E-4; e.cross(c, g).normalize() } f.cross(g, e); d[0] = e.x; d[4] = f.x; d[8] = g.x; d[1] = e.y; d[5] = f.y; d[9] = g.y; d[2] = e.z; d[6] = f.z; d[10] = g.z; return this }, multiply: function(a, b) { var c = a.elements , d = b.elements , e = this.elements , f = c[0] , g = c[4] , h = c[8] , j = c[12] , l = c[1] , k = c[5] , p = c[9] , m = c[13] , o = c[2] , q = c[6] , n = c[10] , r = c[14] , u = c[3] , t = c[7] , y = c[11] , c = c[15] , s = d[0] , w = d[4] , H = d[8] , E = d[12] , z = d[1] , v = d[5] , A = d[9] , J = d[13] , K = d[2] , R = d[6] , P = d[10] , D = d[14] , M = d[3] , G = d[7] , i = d[11] , d = d[15]; e[0] = f * s + g * z + h * K + j * M; e[4] = f * w + g * v + h * R + j * G; e[8] = f * H + g * A + h * P + j * i; e[12] = f * E + g * J + h * D + j * d; e[1] = l * s + k * z + p * K + m * M; e[5] = l * w + k * v + p * R + m * G; e[9] = l * H + k * A + p * P + m * i; e[13] = l * E + k * J + p * D + m * d; e[2] = o * s + q * z + n * K + r * M; e[6] = o * w + q * v + n * R + r * G; e[10] = o * H + q * A + n * P + r * i; e[14] = o * E + q * J + n * D + r * d; e[3] = u * s + t * z + y * K + c * M; e[7] = u * w + t * v + y * R + c * G; e[11] = u * H + t * A + y * P + c * i; e[15] = u * E + t * J + y * D + c * d; return this }, multiplySelf: function(a) { return this.multiply(this, a) }, multiplyToArray: function(a, b, c) { var d = this.elements; this.multiply(a, b); c[0] = d[0]; c[1] = d[1]; c[2] = d[2]; c[3] = d[3]; c[4] = d[4]; c[5] = d[5]; c[6] = d[6]; c[7] = d[7]; c[8] = d[8]; c[9] = d[9]; c[10] = d[10]; c[11] = d[11]; c[12] = d[12]; c[13] = d[13]; c[14] = d[14]; c[15] = d[15]; return this }, multiplyScalar: function(a) { var b = this.elements; b[0] = b[0] * a; b[4] = b[4] * a; b[8] = b[8] * a; b[12] = b[12] * a; b[1] = b[1] * a; b[5] = b[5] * a; b[9] = b[9] * a; b[13] = b[13] * a; b[2] = b[2] * a; b[6] = b[6] * a; b[10] = b[10] * a; b[14] = b[14] * a; b[3] = b[3] * a; b[7] = b[7] * a; b[11] = b[11] * a; b[15] = b[15] * a; return this }, multiplyVector3: function(a) { var b = this.elements , c = a.x , d = a.y , e = a.z , f = 1 / (b[3] * c + b[7] * d + b[11] * e + b[15]); a.x = (b[0] * c + b[4] * d + b[8] * e + b[12]) * f; a.y = (b[1] * c + b[5] * d + b[9] * e + b[13]) * f; a.z = (b[2] * c + b[6] * d + b[10] * e + b[14]) * f; return a }, multiplyVector4: function(a) { var b = this.elements , c = a.x , d = a.y , e = a.z , f = a.w; a.x = b[0] * c + b[4] * d + b[8] * e + b[12] * f; a.y = b[1] * c + b[5] * d + b[9] * e + b[13] * f; a.z = b[2] * c + b[6] * d + b[10] * e + b[14] * f; a.w = b[3] * c + b[7] * d + b[11] * e + b[15] * f; return a }, rotateAxis: function(a) { var b = this.elements , c = a.x , d = a.y , e = a.z; a.x = c * b[0] + d * b[4] + e * b[8]; a.y = c * b[1] + d * b[5] + e * b[9]; a.z = c * b[2] + d * b[6] + e * b[10]; a.normalize(); return a }, crossVector: function(a) { var b = this.elements , c = new THREE.Vector4; c.x = b[0] * a.x + b[4] * a.y + b[8] * a.z + b[12] * a.w; c.y = b[1] * a.x + b[5] * a.y + b[9] * a.z + b[13] * a.w; c.z = b[2] * a.x + b[6] * a.y + b[10] * a.z + b[14] * a.w; c.w = a.w ? b[3] * a.x + b[7] * a.y + b[11] * a.z + b[15] * a.w : 1; return c }, determinant: function() { var a = this.elements , b = a[0] , c = a[4] , d = a[8] , e = a[12] , f = a[1] , g = a[5] , h = a[9] , j = a[13] , l = a[2] , k = a[6] , p = a[10] , m = a[14] , o = a[3] , q = a[7] , n = a[11] , a = a[15]; return e * h * k * o - d * j * k * o - e * g * p * o + c * j * p * o + d * g * m * o - c * h * m * o - e * h * l * q + d * j * l * q + e * f * p * q - b * j * p * q - d * f * m * q + b * h * m * q + e * g * l * n - c * j * l * n - e * f * k * n + b * j * k * n + c * f * m * n - b * g * m * n - d * g * l * a + c * h * l * a + d * f * k * a - b * h * k * a - c * f * p * a + b * g * p * a }, transpose: function() { var a = this.elements, b; b = a[1]; a[1] = a[4]; a[4] = b; b = a[2]; a[2] = a[8]; a[8] = b; b = a[6]; a[6] = a[9]; a[9] = b; b = a[3]; a[3] = a[12]; a[12] = b; b = a[7]; a[7] = a[13]; a[13] = b; b = a[11]; a[11] = a[14]; a[14] = b; return this }, flattenToArray: function(a) { var b = this.elements; a[0] = b[0]; a[1] = b[1]; a[2] = b[2]; a[3] = b[3]; a[4] = b[4]; a[5] = b[5]; a[6] = b[6]; a[7] = b[7]; a[8] = b[8]; a[9] = b[9]; a[10] = b[10]; a[11] = b[11]; a[12] = b[12]; a[13] = b[13]; a[14] = b[14]; a[15] = b[15]; return a }, flattenToArrayOffset: function(a, b) { var c = this.elements; a[b] = c[0]; a[b + 1] = c[1]; a[b + 2] = c[2]; a[b + 3] = c[3]; a[b + 4] = c[4]; a[b + 5] = c[5]; a[b + 6] = c[6]; a[b + 7] = c[7]; a[b + 8] = c[8]; a[b + 9] = c[9]; a[b + 10] = c[10]; a[b + 11] = c[11]; a[b + 12] = c[12]; a[b + 13] = c[13]; a[b + 14] = c[14]; a[b + 15] = c[15]; return a }, getPosition: function() { var a = this.elements; return THREE.Matrix4.__v1.set(a[12], a[13], a[14]) }, setPosition: function(a) { var b = this.elements; b[12] = a.x; b[13] = a.y; b[14] = a.z; return this }, getColumnX: function() { var a = this.elements; return THREE.Matrix4.__v1.set(a[0], a[1], a[2]) }, getColumnY: function() { var a = this.elements; return THREE.Matrix4.__v1.set(a[4], a[5], a[6]) }, getColumnZ: function() { var a = this.elements; return THREE.Matrix4.__v1.set(a[8], a[9], a[10]) }, getInverse: function(a) { var b = this.elements , c = a.elements , d = c[0] , e = c[4] , f = c[8] , g = c[12] , h = c[1] , j = c[5] , l = c[9] , k = c[13] , p = c[2] , m = c[6] , o = c[10] , q = c[14] , n = c[3] , r = c[7] , u = c[11] , c = c[15]; b[0] = l * q * r - k * o * r + k * m * u - j * q * u - l * m * c + j * o * c; b[4] = g * o * r - f * q * r - g * m * u + e * q * u + f * m * c - e * o * c; b[8] = f * k * r - g * l * r + g * j * u - e * k * u - f * j * c + e * l * c; b[12] = g * l * m - f * k * m - g * j * o + e * k * o + f * j * q - e * l * q; b[1] = k * o * n - l * q * n - k * p * u + h * q * u + l * p * c - h * o * c; b[5] = f * q * n - g * o * n + g * p * u - d * q * u - f * p * c + d * o * c; b[9] = g * l * n - f * k * n - g * h * u + d * k * u + f * h * c - d * l * c; b[13] = f * k * p - g * l * p + g * h * o - d * k * o - f * h * q + d * l * q; b[2] = j * q * n - k * m * n + k * p * r - h * q * r - j * p * c + h * m * c; b[6] = g * m * n - e * q * n - g * p * r + d * q * r + e * p * c - d * m * c; b[10] = e * k * n - g * j * n + g * h * r - d * k * r - e * h * c + d * j * c; b[14] = g * j * p - e * k * p - g * h * m + d * k * m + e * h * q - d * j * q; b[3] = l * m * n - j * o * n - l * p * r + h * o * r + j * p * u - h * m * u; b[7] = e * o * n - f * m * n + f * p * r - d * o * r - e * p * u + d * m * u; b[11] = f * j * n - e * l * n - f * h * r + d * l * r + e * h * u - d * j * u; b[15] = e * l * p - f * j * p + f * h * m - d * l * m - e * h * o + d * j * o; this.multiplyScalar(1 / a.determinant()); return this }, setRotationFromEuler: function(a, b) { var c = this.elements , d = a.x , e = a.y , f = a.z , g = Math.cos(d) , d = Math.sin(d) , h = Math.cos(e) , e = Math.sin(e) , j = Math.cos(f) , f = Math.sin(f); switch (b) { case "YXZ": var l = h * j , k = h * f , p = e * j , m = e * f; c[0] = l + m * d; c[4] = p * d - k; c[8] = g * e; c[1] = g * f; c[5] = g * j; c[9] = -d; c[2] = k * d - p; c[6] = m + l * d; c[10] = g * h; break; case "ZXY": l = h * j; k = h * f; p = e * j; m = e * f; c[0] = l - m * d; c[4] = -g * f; c[8] = p + k * d; c[1] = k + p * d; c[5] = g * j; c[9] = m - l * d; c[2] = -g * e; c[6] = d; c[10] = g * h; break; case "ZYX": l = g * j; k = g * f; p = d * j; m = d * f; c[0] = h * j; c[4] = p * e - k; c[8] = l * e + m; c[1] = h * f; c[5] = m * e + l; c[9] = k * e - p; c[2] = -e; c[6] = d * h; c[10] = g * h; break; case "YZX": l = g * h; k = g * e; p = d * h; m = d * e; c[0] = h * j; c[4] = m - l * f; c[8] = p * f + k; c[1] = f; c[5] = g * j; c[9] = -d * j; c[2] = -e * j; c[6] = k * f + p; c[10] = l - m * f; break; case "XZY": l = g * h; k = g * e; p = d * h; m = d * e; c[0] = h * j; c[4] = -f; c[8] = e * j; c[1] = l * f + m; c[5] = g * j; c[9] = k * f - p; c[2] = p * f - k; c[6] = d * j; c[10] = m * f + l; break; default: l = g * j; k = g * f; p = d * j; m = d * f; c[0] = h * j; c[4] = -h * f; c[8] = e; c[1] = k + p * e; c[5] = l - m * e; c[9] = -d * h; c[2] = m - l * e; c[6] = p + k * e; c[10] = g * h } return this }, setRotationFromQuaternion: function(a) { var b = this.elements , c = a.x , d = a.y , e = a.z , f = a.w , g = c + c , h = d + d , j = e + e , a = c * g , l = c * h , c = c * j , k = d * h , d = d * j , e = e * j , g = f * g , h = f * h , f = f * j; b[0] = 1 - (k + e); b[4] = l - f; b[8] = c + h; b[1] = l + f; b[5] = 1 - (a + e); b[9] = d - g; b[2] = c - h; b[6] = d + g; b[10] = 1 - (a + k); return this }, compose: function(a, b, c) { var d = this.elements , e = THREE.Matrix4.__m1 , f = THREE.Matrix4.__m2; e.identity(); e.setRotationFromQuaternion(b); f.makeScale(c.x, c.y, c.z); this.multiply(e, f); d[12] = a.x; d[13] = a.y; d[14] = a.z; return this }, decompose: function(a, b, c) { var d = this.elements , e = THREE.Matrix4.__v1 , f = THREE.Matrix4.__v2 , g = THREE.Matrix4.__v3; e.set(d[0], d[1], d[2]); f.set(d[4], d[5], d[6]); g.set(d[8], d[9], d[10]); a = a instanceof THREE.Vector3 ? a : new THREE.Vector3; b = b instanceof THREE.Quaternion ? b : new THREE.Quaternion; c = c instanceof THREE.Vector3 ? c : new THREE.Vector3; c.x = e.length(); c.y = f.length(); c.z = g.length(); a.x = d[12]; a.y = d[13]; a.z = d[14]; d = THREE.Matrix4.__m1; d.copy(this); d.elements[0] = d.elements[0] / c.x; d.elements[1] = d.elements[1] / c.x; d.elements[2] = d.elements[2] / c.x; d.elements[4] = d.elements[4] / c.y; d.elements[5] = d.elements[5] / c.y; d.elements[6] = d.elements[6] / c.y; d.elements[8] = d.elements[8] / c.z; d.elements[9] = d.elements[9] / c.z; d.elements[10] = d.elements[10] / c.z; b.setFromRotationMatrix(d); return [a, b, c] }, extractPosition: function(a) { var b = this.elements , a = a.elements; b[12] = a[12]; b[13] = a[13]; b[14] = a[14]; return this }, extractRotation: function(a) { var b = this.elements , a = a.elements , c = THREE.Matrix4.__v1 , d = 1 / c.set(a[0], a[1], a[2]).length() , e = 1 / c.set(a[4], a[5], a[6]).length() , c = 1 / c.set(a[8], a[9], a[10]).length(); b[0] = a[0] * d; b[1] = a[1] * d; b[2] = a[2] * d; b[4] = a[4] * e; b[5] = a[5] * e; b[6] = a[6] * e; b[8] = a[8] * c; b[9] = a[9] * c; b[10] = a[10] * c; return this }, translate: function(a) { var b = this.elements , c = a.x , d = a.y , a = a.z; b[12] = b[0] * c + b[4] * d + b[8] * a + b[12]; b[13] = b[1] * c + b[5] * d + b[9] * a + b[13]; b[14] = b[2] * c + b[6] * d + b[10] * a + b[14]; b[15] = b[3] * c + b[7] * d + b[11] * a + b[15]; return this }, rotateX: function(a) { var b = this.elements , c = b[4] , d = b[5] , e = b[6] , f = b[7] , g = b[8] , h = b[9] , j = b[10] , l = b[11] , k = Math.cos(a) , a = Math.sin(a); b[4] = k * c + a * g; b[5] = k * d + a * h; b[6] = k * e + a * j; b[7] = k * f + a * l; b[8] = k * g - a * c; b[9] = k * h - a * d; b[10] = k * j - a * e; b[11] = k * l - a * f; return this }, rotateY: function(a) { var b = this.elements , c = b[0] , d = b[1] , e = b[2] , f = b[3] , g = b[8] , h = b[9] , j = b[10] , l = b[11] , k = Math.cos(a) , a = Math.sin(a); b[0] = k * c - a * g; b[1] = k * d - a * h; b[2] = k * e - a * j; b[3] = k * f - a * l; b[8] = k * g + a * c; b[9] = k * h + a * d; b[10] = k * j + a * e; b[11] = k * l + a * f; return this }, rotateZ: function(a) { var b = this.elements , c = b[0] , d = b[1] , e = b[2] , f = b[3] , g = b[4] , h = b[5] , j = b[6] , l = b[7] , k = Math.cos(a) , a = Math.sin(a); b[0] = k * c + a * g; b[1] = k * d + a * h; b[2] = k * e + a * j; b[3] = k * f + a * l; b[4] = k * g - a * c; b[5] = k * h - a * d; b[6] = k * j - a * e; b[7] = k * l - a * f; return this }, rotateByAxis: function(a, b) { var c = this.elements; if (a.x === 1 && a.y === 0 && a.z === 0) return this.rotateX(b); if (a.x === 0 && a.y === 1 && a.z === 0) return this.rotateY(b); if (a.x === 0 && a.y === 0 && a.z === 1) return this.rotateZ(b); var d = a.x , e = a.y , f = a.z , g = Math.sqrt(d * d + e * e + f * f) , d = d / g , e = e / g , f = f / g , g = d * d , h = e * e , j = f * f , l = Math.cos(b) , k = Math.sin(b) , p = 1 - l , m = d * e * p , o = d * f * p , p = e * f * p , d = d * k , q = e * k , k = f * k , f = g + (1 - g) * l , g = m + k , e = o - q , m = m - k , h = h + (1 - h) * l , k = p + d , o = o + q , p = p - d , j = j + (1 - j) * l , l = c[0] , d = c[1] , q = c[2] , n = c[3] , r = c[4] , u = c[5] , t = c[6] , y = c[7] , s = c[8] , w = c[9] , H = c[10] , E = c[11]; c[0] = f * l + g * r + e * s; c[1] = f * d + g * u + e * w; c[2] = f * q + g * t + e * H; c[3] = f * n + g * y + e * E; c[4] = m * l + h * r + k * s; c[5] = m * d + h * u + k * w; c[6] = m * q + h * t + k * H; c[7] = m * n + h * y + k * E; c[8] = o * l + p * r + j * s; c[9] = o * d + p * u + j * w; c[10] = o * q + p * t + j * H; c[11] = o * n + p * y + j * E; return this }, scale: function(a) { var b = this.elements , c = a.x , d = a.y , a = a.z; b[0] = b[0] * c; b[4] = b[4] * d; b[8] = b[8] * a; b[1] = b[1] * c; b[5] = b[5] * d; b[9] = b[9] * a; b[2] = b[2] * c; b[6] = b[6] * d; b[10] = b[10] * a; b[3] = b[3] * c; b[7] = b[7] * d; b[11] = b[11] * a; return this }, getMaxScaleOnAxis: function() { var a = this.elements; return Math.sqrt(Math.max(a[0] * a[0] + a[1] * a[1] + a[2] * a[2], Math.max(a[4] * a[4] + a[5] * a[5] + a[6] * a[6], a[8] * a[8] + a[9] * a[9] + a[10] * a[10]))) }, makeTranslation: function(a, b, c) { this.set(1, 0, 0, a, 0, 1, 0, b, 0, 0, 1, c, 0, 0, 0, 1); return this }, makeRotationX: function(a) { var b = Math.cos(a) , a = Math.sin(a); this.set(1, 0, 0, 0, 0, b, -a, 0, 0, a, b, 0, 0, 0, 0, 1); return this }, makeRotationY: function(a) { var b = Math.cos(a) , a = Math.sin(a); this.set(b, 0, a, 0, 0, 1, 0, 0, -a, 0, b, 0, 0, 0, 0, 1); return this }, makeRotationZ: function(a) { var b = Math.cos(a) , a = Math.sin(a); this.set(b, -a, 0, 0, a, b, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); return this }, makeRotationAxis: function(a, b) { var c = Math.cos(b) , d = Math.sin(b) , e = 1 - c , f = a.x , g = a.y , h = a.z , j = e * f , l = e * g; this.set(j * f + c, j * g - d * h, j * h + d * g, 0, j * g + d * h, l * g + c, l * h - d * f, 0, j * h - d * g, l * h + d * f, e * h * h + c, 0, 0, 0, 0, 1); return this }, makeScale: function(a, b, c) { this.set(a, 0, 0, 0, 0, b, 0, 0, 0, 0, c, 0, 0, 0, 0, 1); return this }, makeFrustum: function(a, b, c, d, e, f) { var g = this.elements; g[0] = 2 * e / (b - a); g[4] = 0; g[8] = (b + a) / (b - a); g[12] = 0; g[1] = 0; g[5] = 2 * e / (d - c); g[9] = (d + c) / (d - c); g[13] = 0; g[2] = 0; g[6] = 0; g[10] = -(f + e) / (f - e); g[14] = -2 * f * e / (f - e); g[3] = 0; g[7] = 0; g[11] = -1; g[15] = 0; return this }, makePerspective: function(a, b, c, d) { var a = c * Math.tan(a * Math.PI / 360) , e = -a; return this.makeFrustum(e * b, a * b, e, a, c, d) }, makeOrthographic: function(a, b, c, d, e, f) { var g = this.elements , h = b - a , j = c - d , l = f - e; g[0] = 2 / h; g[4] = 0; g[8] = 0; g[12] = -((b + a) / h); g[1] = 0; g[5] = 2 / j; g[9] = 0; g[13] = -((c + d) / j); g[2] = 0; g[6] = 0; g[10] = -2 / l; g[14] = -((f + e) / l); g[3] = 0; g[7] = 0; g[11] = 0; g[15] = 1; return this }, clone: function() { var a = this.elements; return new THREE.Matrix4(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]) } }; THREE.Matrix4.__v1 = new THREE.Vector3; THREE.Matrix4.__v2 = new THREE.Vector3; THREE.Matrix4.__v3 = new THREE.Vector3; THREE.Matrix4.__m1 = new THREE.Matrix4; THREE.Matrix4.__m2 = new THREE.Matrix4; THREE.Object3D = function() { this.id = THREE.Object3DCount++; this.name = ""; this.parent = void 0; this.children = []; this.up = new THREE.Vector3(0,1,0); this.position = new THREE.Vector3; this.rotation = new THREE.Vector3; this.eulerOrder = "XYZ"; this.scale = new THREE.Vector3(1,1,1); this.flipSided = this.doubleSided = false; this.renderDepth = null ; this.rotationAutoUpdate = true; this.matrix = new THREE.Matrix4; this.matrixWorld = new THREE.Matrix4; this.matrixRotationWorld = new THREE.Matrix4; this.matrixWorldNeedsUpdate = this.matrixAutoUpdate = true; this.quaternion = new THREE.Quaternion; this.useQuaternion = false; this.boundRadius = 0; this.boundRadiusScale = 1; this.visible = true; this.receiveShadow = this.castShadow = false; this.frustumCulled = true; this._vector = new THREE.Vector3 } ; THREE.Object3D.prototype = { constructor: THREE.Object3D, applyMatrix: function(a) { this.matrix.multiply(a, this.matrix); this.scale.getScaleFromMatrix(this.matrix); this.rotation.getRotationFromMatrix(this.matrix, this.scale); this.position.getPositionFromMatrix(this.matrix) }, translate: function(a, b) { this.matrix.rotateAxis(b); this.position.addSelf(b.multiplyScalar(a)) }, translateX: function(a) { this.translate(a, this._vector.set(1, 0, 0)) }, translateY: function(a) { this.translate(a, this._vector.set(0, 1, 0)) }, translateZ: function(a) { this.translate(a, this._vector.set(0, 0, 1)) }, lookAt: function(a) { this.matrix.lookAt(a, this.position, this.up); this.rotationAutoUpdate && this.rotation.getRotationFromMatrix(this.matrix) }, add: function(a) { if (a === this) console.warn("THREE.Object3D.add: An object can't be added as a child of itself."); else if (a instanceof THREE.Object3D) { a.parent !== void 0 && a.parent.remove(a); a.parent = this; this.children.push(a); for (var b = this; b.parent !== void 0; ) b = b.parent; b !== void 0 && b instanceof THREE.Scene && b.__addObject(a) } }, remove: function(a) { var b = this.children.indexOf(a); if (b !== -1) { a.parent = void 0; this.children.splice(b, 1); for (b = this; b.parent !== void 0; ) b = b.parent; b !== void 0 && b instanceof THREE.Scene && b.__removeObject(a) } }, getChildByName: function(a, b) { var c, d, e; c = 0; for (d = this.children.length; c < d; c++) { e = this.children[c]; if (e.name === a) return e; if (b) { e = e.getChildByName(a, b); if (e !== void 0) return e } } }, updateMatrix: function() { this.matrix.setPosition(this.position); this.useQuaternion ? this.matrix.setRotationFromQuaternion(this.quaternion) : this.matrix.setRotationFromEuler(this.rotation, this.eulerOrder); if (this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1) { this.matrix.scale(this.scale); this.boundRadiusScale = Math.max(this.scale.x, Math.max(this.scale.y, this.scale.z)) } this.matrixWorldNeedsUpdate = true }, updateMatrixWorld: function(a) { this.matrixAutoUpdate && this.updateMatrix(); if (this.matrixWorldNeedsUpdate || a) { this.parent ? this.matrixWorld.multiply(this.parent.matrixWorld, this.matrix) : this.matrixWorld.copy(this.matrix); this.matrixWorldNeedsUpdate = false; a = true } for (var b = 0, c = this.children.length; b < c; b++) this.children[b].updateMatrixWorld(a) } }; THREE.Object3DCount = 0; THREE.Projector = function() { function a() { var a = g[f] = g[f] || new THREE.RenderableObject; f++; return a } function b() { var a = l[j] = l[j] || new THREE.RenderableVertex; j++; return a } function c(a, b) { return b.z - a.z } function d(a, b) { var c = 0 , d = 1 , e = a.z + a.w , f = b.z + b.w , g = -a.z + a.w , h = -b.z + b.w; if (e >= 0 && f >= 0 && g >= 0 && h >= 0) return true; if (e < 0 && f < 0 || g < 0 && h < 0) return false; e < 0 ? c = Math.max(c, e / (e - f)) : f < 0 && (d = Math.min(d, e / (e - f))); g < 0 ? c = Math.max(c, g / (g - h)) : h < 0 && (d = Math.min(d, g / (g - h))); if (d < c) return false; a.lerpSelf(b, c); b.lerpSelf(a, 1 - d); return true } var e, f, g = [], h, j, l = [], k, p, m = [], o, q = [], n, r, u = [], t, y, s = [], w = { objects: [], sprites: [], lights: [], elements: [] }, H = new THREE.Vector3, E = new THREE.Vector4, z = new THREE.Matrix4, v = new THREE.Matrix4, A = new THREE.Frustum, J = new THREE.Vector4, K = new THREE.Vector4; this.projectVector = function(a, b) { b.matrixWorldInverse.getInverse(b.matrixWorld); z.multiply(b.projectionMatrix, b.matrixWorldInverse); z.multiplyVector3(a); return a } ; this.unprojectVector = function(a, b) { b.projectionMatrixInverse.getInverse(b.projectionMatrix); z.multiply(b.matrixWorld, b.projectionMatrixInverse); z.multiplyVector3(a); return a } ; this.pickingRay = function(a, b) { var c; a.z = -1; c = new THREE.Vector3(a.x,a.y,1); this.unprojectVector(a, b); this.unprojectVector(c, b); c.subSelf(a).normalize(); return new THREE.Ray(a,c) } ; this.projectGraph = function(b, d) { f = 0; w.objects.length = 0; w.sprites.length = 0; w.lights.length = 0; var g = function(b) { if (b.visible !== false) { if ((b instanceof THREE.Mesh || b instanceof THREE.Line) && (b.frustumCulled === false || A.contains(b))) { H.copy(b.matrixWorld.getPosition()); z.multiplyVector3(H); e = a(); e.object = b; e.z = H.z; w.objects.push(e) } else if (b instanceof THREE.Sprite || b instanceof THREE.Particle) { H.copy(b.matrixWorld.getPosition()); z.multiplyVector3(H); e = a(); e.object = b; e.z = H.z; w.sprites.push(e) } else b instanceof THREE.Light && w.lights.push(b); for (var c = 0, d = b.children.length; c < d; c++) g(b.children[c]) } } ; g(b); d && w.objects.sort(c); return w } ; this.projectScene = function(a, e, f) { var g = e.near, G = e.far, i = false, H, U, C, Y, F, ea, fa, ia, O, Q, Z, $, ha, Ma, Ka; y = r = o = p = 0; w.elements.length = 0; if (e.parent === void 0) { console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."); a.add(e) } a.updateMatrixWorld(); e.matrixWorldInverse.getInverse(e.matrixWorld); z.multiply(e.projectionMatrix, e.matrixWorldInverse); A.setFromMatrix(z); w = this.projectGraph(a, false); a = 0; for (H = w.objects.length; a < H; a++) { O = w.objects[a].object; Q = O.matrixWorld; j = 0; if (O instanceof THREE.Mesh) { Z = O.geometry; $ = O.geometry.materials; Y = Z.vertices; ha = Z.faces; Ma = Z.faceVertexUvs; Z = O.matrixRotationWorld.extractRotation(Q); U = 0; for (C = Y.length; U < C; U++) { h = b(); h.positionWorld.copy(Y[U]); Q.multiplyVector3(h.positionWorld); h.positionScreen.copy(h.positionWorld); z.multiplyVector4(h.positionScreen); h.positionScreen.x = h.positionScreen.x / h.positionScreen.w; h.positionScreen.y = h.positionScreen.y / h.positionScreen.w; h.visible = h.positionScreen.z > g && h.positionScreen.z < G } Y = 0; for (U = ha.length; Y < U; Y++) { C = ha[Y]; if (C instanceof THREE.Face3) { F = l[C.a]; ea = l[C.b]; fa = l[C.c]; if (F.visible && ea.visible && fa.visible) { i = (fa.positionScreen.x - F.positionScreen.x) * (ea.positionScreen.y - F.positionScreen.y) - (fa.positionScreen.y - F.positionScreen.y) * (ea.positionScreen.x - F.positionScreen.x) < 0; if (O.doubleSided || i != O.flipSided) { ia = m[p] = m[p] || new THREE.RenderableFace3; p++; k = ia; k.v1.copy(F); k.v2.copy(ea); k.v3.copy(fa) } else continue } else continue } else if (C instanceof THREE.Face4) { F = l[C.a]; ea = l[C.b]; fa = l[C.c]; ia = l[C.d]; if (F.visible && ea.visible && fa.visible && ia.visible) { i = (ia.positionScreen.x - F.positionScreen.x) * (ea.positionScreen.y - F.positionScreen.y) - (ia.positionScreen.y - F.positionScreen.y) * (ea.positionScreen.x - F.positionScreen.x) < 0 || (ea.positionScreen.x - fa.positionScreen.x) * (ia.positionScreen.y - fa.positionScreen.y) - (ea.positionScreen.y - fa.positionScreen.y) * (ia.positionScreen.x - fa.positionScreen.x) < 0; if (O.doubleSided || i != O.flipSided) { Ka = q[o] = q[o] || new THREE.RenderableFace4; o++; k = Ka; k.v1.copy(F); k.v2.copy(ea); k.v3.copy(fa); k.v4.copy(ia) } else continue } else continue } k.normalWorld.copy(C.normal); !i && (O.flipSided || O.doubleSided) && k.normalWorld.negate(); Z.multiplyVector3(k.normalWorld); k.centroidWorld.copy(C.centroid); Q.multiplyVector3(k.centroidWorld); k.centroidScreen.copy(k.centroidWorld); z.multiplyVector3(k.centroidScreen); fa = C.vertexNormals; F = 0; for (ea = fa.length; F < ea; F++) { ia = k.vertexNormalsWorld[F]; ia.copy(fa[F]); !i && (O.flipSided || O.doubleSided) && ia.negate(); Z.multiplyVector3(ia) } F = 0; for (ea = Ma.length; F < ea; F++) if (Ka = Ma[F][Y]) { fa = 0; for (ia = Ka.length; fa < ia; fa++) k.uvs[F][fa] = Ka[fa] } k.material = O.material; k.faceMaterial = C.materialIndex !== null ? $[C.materialIndex] : null ; k.z = k.centroidScreen.z; w.elements.push(k) } } else if (O instanceof THREE.Line) { v.multiply(z, Q); Y = O.geometry.vertices; F = b(); F.positionScreen.copy(Y[0]); v.multiplyVector4(F.positionScreen); Q = O.type === THREE.LinePieces ? 2 : 1; U = 1; for (C = Y.length; U < C; U++) { F = b(); F.positionScreen.copy(Y[U]); v.multiplyVector4(F.positionScreen); if (!((U + 1) % Q > 0)) { ea = l[j - 2]; J.copy(F.positionScreen); K.copy(ea.positionScreen); if (d(J, K)) { J.multiplyScalar(1 / J.w); K.multiplyScalar(1 / K.w); $ = u[r] = u[r] || new THREE.RenderableLine; r++; n = $; n.v1.positionScreen.copy(J); n.v2.positionScreen.copy(K); n.z = Math.max(J.z, K.z); n.material = O.material; w.elements.push(n) } } } } } a = 0; for (H = w.sprites.length; a < H; a++) { O = w.sprites[a].object; Q = O.matrixWorld; if (O instanceof THREE.Particle) { E.set(Q.elements[12], Q.elements[13], Q.elements[14], 1); z.multiplyVector4(E); E.z = E.z / E.w; if (E.z > 0 && E.z < 1) { g = s[y] = s[y] || new THREE.RenderableParticle; y++; t = g; t.x = E.x / E.w; t.y = E.y / E.w; t.z = E.z; t.rotation = O.rotation.z; t.scale.x = O.scale.x * Math.abs(t.x - (E.x + e.projectionMatrix.elements[0]) / (E.w + e.projectionMatrix.elements[12])); t.scale.y = O.scale.y * Math.abs(t.y - (E.y + e.projectionMatrix.elements[5]) / (E.w + e.projectionMatrix.elements[13])); t.material = O.material; w.elements.push(t) } } } f && w.elements.sort(c); return w } } ; THREE.Quaternion = function(a, b, c, d) { this.x = a || 0; this.y = b || 0; this.z = c || 0; this.w = d !== void 0 ? d : 1 } ; THREE.Quaternion.prototype = { constructor: THREE.Quaternion, set: function(a, b, c, d) { this.x = a; this.y = b; this.z = c; this.w = d; return this }, copy: function(a) { this.x = a.x; this.y = a.y; this.z = a.z; this.w = a.w; return this }, setFromEuler: function(a) { var b = Math.PI / 360 , c = a.x * b , d = a.y * b , e = a.z * b , a = Math.cos(d) , d = Math.sin(d) , b = Math.cos(-e) , e = Math.sin(-e) , f = Math.cos(c) , c = Math.sin(c) , g = a * b , h = d * e; this.w = g * f - h * c; this.x = g * c + h * f; this.y = d * b * f + a * e * c; this.z = a * e * f - d * b * c; return this }, setFromAxisAngle: function(a, b) { var c = b / 2 , d = Math.sin(c); this.x = a.x * d; this.y = a.y * d; this.z = a.z * d; this.w = Math.cos(c); return this }, setFromRotationMatrix: function(a) { var b = Math.pow(a.determinant(), 1 / 3); this.w = Math.sqrt(Math.max(0, b + a.elements[0] + a.elements[5] + a.elements[10])) / 2; this.x = Math.sqrt(Math.max(0, b + a.elemen
joenot443
A very simple implementation of vector operations in Apple's SpriteKit.
MozeeB
Procedural pixel art game asset generator. 136 sprites with animations, JSON metadata, texture atlases, and GIF export. Characters, enemies, terrain, effects, natural objects — all generated from math. No hand-drawn art required.
k-shirmohammadi
A simple top-down shooter game built in Processing (Java mode). The player rotates to face the mouse, shoots moving obstacles, and restarts after collisions. Demonstrates object-oriented design, rotation maths, sprite animation, and game state logic.
KMcCand
A clone of the game Tarzan Ball from Cool Math Games. Click with the mouse to shoot out Tarzan's tongue and grab onto things in order to reach the target. Featuring proper physics, sprite animation, and a UI for making new levels.
RobDOH
This python code demonstrates numbers and math. CSCI 1511 introduces basic concepts of game design and programming. I learnt the Python programming language constructs to write programs that integrate classes, class methods, and class instances, built upon basic structures such as: input method handling, 2D sprite manipulation and animation, collision detection, game physics and basic artificial intelligence.
inoculate23
SVG Math function sprite generator
xrainoxu
A fun math practice app I built for my 7-year-old daughter to help her master addition and subtraction within 20 through three engaging game modes: Timed Challenge, Challenge Mode, and Free Practice. Built with Claude Code CLI.
Heitor0
A MakeCode project
darzu
MakeCode Arcade extension for helpful math functions.
Bhavesh8238
No description available
Thanhha456
the math of acceleration and friction, compute collisions between sprites, animate sprites
rafaelsilvdarosa
trabalhando loops for e math random para gerar linhas e algumas sprites na tela.
herrethan
A simple math game page for kids, featuring a sprite-animated clay crazy professor guy
cademon101
A way to view 2d sprites in a 3d environment using the top down engine plug in, Math taken from youtube "doom sprite" tutorials
DreamSpoon
Use some math and Java to display a spiral of level segments from classic NES games, with sprites.
Steven-Wilson
A simple 2D vector math library in pure python usable for sprite-based games and other lightweight vector needs.
iLukman
Math Quest Adventure is a very simple Python game where player sprites will combat monsters by answering multiple choice questions on mathematical questions.
CaiporaGames
This is a project showing how to create snake, hair, cloth... in a 2D environment using math and sprites. It is possible to create incredable creatures!
MateuszKretkowski
TextureMappingProject is a System which helps Indie Game Develepers. This Repo uses Math to replace object's default sprite, into any combination of pixels in real-time.
AloysiusSundar
A Snake esque Godzilla game that I made for a friend, it's a little shabby but making this was a lot of fun and it was nice to stare at sprite sheets instead of math functions for a while
theKorax
This is a 2d platformer game about solving math and chemistry equations in a fun, engaging way. Using the Corgi Engine assets package for 2d and 2.5d platformers along with various custom sprites and scripts, my team and I built this,
momo1478
A C++ application made using the QT framework, SFML sprite and networking library, and Box2D physics simulation library. Players protect a tower by answering math problems on cannon balls fired toward a tower. Teacher and Student logins are featured with a server mounted database backend.
J-Peres
A clone of the game Tarzan Ball from Cool Math Games. Click with the mouse to shoot out Tarzan's tongue and grab onto things in order to reach the target. Featuring proper physics, sprite animation, and a UI for making new levels. Worked with @KMcCand, Daniel Wen, Ishaan Kannan (CS 3 - California Insitute of Technology). Play here: http://www.its.caltech.edu/%7Eblank/cs3-21sp/tarzan-ball.html
All 30 repositories loaded