Skip to content

Instantly share code, notes, and snippets.

/gist:9941966

Created Apr 2, 2014
Embed
What would you like to do?
/*! 31-03-2014 */
function pad(a, b) {
var c = "0" + a;
return c.substr(c.length - b)
}
function updateCountdown() {
var a = Date.now(),
b = (deadline - a) / 1e3;
b = Math.floor(b);
var c = b / 60;
c = Math.floor(c);
var d = c / 60;
d = Math.floor(d);
var e = d / 24;
e = Math.floor(e),
b -= 60 * c,
c -= 60 * d,
d -= 24 * e,
document.querySelector("#countdownDays .value").innerHTML = pad(e, 2),
document.querySelector("#countdownHours .value").innerHTML = pad(d, 2),
document.querySelector("#countdownMinutes .value").innerHTML = pad(c, 2),
document.querySelector("#countdownSeconds .value").innerHTML = pad(b, 2)
}
Function.prototype.bind || (Function.prototype.bind = function(a) {
if ("function" != typeof this)
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
var b = Array.prototype.slice.call(arguments, 1),
c = this,
d = function() {},
e = function() {
return c.apply(this instanceof d && a ? this: a, b.concat(Array.prototype.slice.call(arguments)))
};
return d.prototype = this.prototype,
e.prototype = new d,
e
});
var THREE = THREE || {
REVISION: "58"
};
self.console = self.console || {
info: function() {},
log: function() {},
debug: function() {},
warn: function() {},
error: function() {}
},
self.Int32Array = self.Int32Array || Array,
self.Float32Array = self.Float32Array || Array,
String.prototype.trim = String.prototype.trim || function() {
return this.replace(/^\s+|\s+$/g, "")
},
THREE.extend = function(a, b) {
if (Object.keys)
for (var c = Object.keys(b), d = 0, e = c.length; e > d; d++) {
var f = c[d];
Object.defineProperty(a, f, Object.getOwnPropertyDescriptor(b, f))
} else
for (f in c = {}.hasOwnProperty, b)
c.call(b, f) && (a[f] = b[f]);
return a
},
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"];
void 0 === window.requestAnimationFrame && (window.requestAnimationFrame = function(b) {
var c = Date.now(),
d = Math.max(0, 16 - (c - a)),
e = window.setTimeout(function() {
b(c + d)
}, d);
return a = c + d,
e
}),
window.cancelAnimationFrame = window.cancelAnimationFrame || function(a) {
window.clearTimeout(a)
}
} (),
THREE.CullFaceNone = 0,
THREE.CullFaceBack = 1,
THREE.CullFaceFront = 2,
THREE.CullFaceFrontBack = 3,
THREE.FrontFaceDirectionCW = 0,
THREE.FrontFaceDirectionCCW = 1,
THREE.BasicShadowMap = 0,
THREE.PCFShadowMap = 1,
THREE.PCFSoftShadowMap = 2,
THREE.FrontSide = 0,
THREE.BackSide = 1,
THREE.DoubleSide = 2,
THREE.NoShading = 0,
THREE.FlatShading = 1,
THREE.SmoothShading = 2,
THREE.NoColors = 0,
THREE.FaceColors = 1,
THREE.VertexColors = 2,
THREE.NoBlending = 0,
THREE.NormalBlending = 1,
THREE.AdditiveBlending = 2,
THREE.SubtractiveBlending = 3,
THREE.MultiplyBlending = 4,
THREE.CustomBlending = 5,
THREE.AddEquation = 100,
THREE.SubtractEquation = 101,
THREE.ReverseSubtractEquation = 102,
THREE.ZeroFactor = 200,
THREE.OneFactor = 201,
THREE.SrcColorFactor = 202,
THREE.OneMinusSrcColorFactor = 203,
THREE.SrcAlphaFactor = 204,
THREE.OneMinusSrcAlphaFactor = 205,
THREE.DstAlphaFactor = 206,
THREE.OneMinusDstAlphaFactor = 207,
THREE.DstColorFactor = 208,
THREE.OneMinusDstColorFactor = 209,
THREE.SrcAlphaSaturateFactor = 210,
THREE.MultiplyOperation = 0,
THREE.MixOperation = 1,
THREE.AddOperation = 2,
THREE.UVMapping = function() {},
THREE.CubeReflectionMapping = function() {},
THREE.CubeRefractionMapping = function() {},
THREE.SphericalReflectionMapping = function() {},
THREE.SphericalRefractionMapping = function() {},
THREE.RepeatWrapping = 1e3,
THREE.ClampToEdgeWrapping = 1001,
THREE.MirroredRepeatWrapping = 1002,
THREE.NearestFilter = 1003,
THREE.NearestMipMapNearestFilter = 1004,
THREE.NearestMipMapLinearFilter = 1005,
THREE.LinearFilter = 1006,
THREE.LinearMipMapNearestFilter = 1007,
THREE.LinearMipMapLinearFilter = 1008,
THREE.UnsignedByteType = 1009,
THREE.ByteType = 1010,
THREE.ShortType = 1011,
THREE.UnsignedShortType = 1012,
THREE.IntType = 1013,
THREE.UnsignedIntType = 1014,
THREE.FloatType = 1015,
THREE.UnsignedShort4444Type = 1016,
THREE.UnsignedShort5551Type = 1017,
THREE.UnsignedShort565Type = 1018,
THREE.AlphaFormat = 1019,
THREE.RGBFormat = 1020,
THREE.RGBAFormat = 1021,
THREE.LuminanceFormat = 1022,
THREE.LuminanceAlphaFormat = 1023,
THREE.RGB_S3TC_DXT1_Format = 2001,
THREE.RGBA_S3TC_DXT1_Format = 2002,
THREE.RGBA_S3TC_DXT3_Format = 2003,
THREE.RGBA_S3TC_DXT5_Format = 2004,
THREE.Color = function(a) {
return void 0 !== a && this.set(a),
this
},
THREE.Color.prototype = {
constructor: THREE.Color,
r: 1,
g: 1,
b: 1,
set: function(a) {
return a instanceof THREE.Color ? this.copy(a) : "number" == typeof a ? this.setHex(a) : "string" == typeof a && this.setStyle(a),
this
},
setHex: function(a) {
return a = Math.floor(a),
this.r = (a >> 16 & 255) / 255,
this.g = (a >> 8 & 255) / 255,
this.b = (255 & a) / 255,
this
},
setRGB: function(a, b, c) {
return this.r = a,
this.g = b,
this.b = c,
this
},
setHSL: function(a, b, c) {
if (0 === b)
this.r = this.g = this.b = c;
else {
var d = function(a, b, c) {
return 0 > c && (c += 1),
c > 1 && (c -= 1),
1 / 6 > c ? a + 6 * (b - a) * c: .5 > c ? b: 2 / 3 > c ? a + 6 * (b - a) * (2 / 3 - c) : a
},
b = .5 >= c ? c * (1 + b) : c + b - c * b,
c = 2 * c - b;
this.r = d(c, b, a + 1 / 3),
this.g = d(c, b, a),
this.b = d(c, b, a - 1 / 3)
}
return this
},
setStyle: function(a) {
return / ^rgb\ ((\d + ), (\d + ), (\d + )\)
$ / i.test(a) ? (a = /^rgb\((\d+),(\d+),(\d+)\)$/i.exec(a), this.r = Math.min(255, parseInt(a[1], 10)) / 255, this.g = Math.min(255, parseInt(a[2], 10)) / 255, this.b = Math.min(255, parseInt(a[3], 10)) / 255, this) : /^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.test(a) ? (a = /^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.exec(a), this.r = Math.min(100, parseInt(a[1], 10)) / 100, this.g = Math.min(100, parseInt(a[2], 10)) / 100, this.b = Math.min(100, parseInt(a[3], 10)) / 100, this) : /^\#([0-9a-f]{6})$/i.test(a) ? (a = /^\#([0-9a-f]{6})$/i.exec(a), this.setHex(parseInt(a[1], 16)), this) : /^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(a) ? (a = /^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(a), this.setHex(parseInt(a[1] + a[1] + a[2] + a[2] + a[3] + a[3], 16)), this) : /^(\w+)$/i.test(a) ? (this.setHex(THREE.ColorKeywords[a]), this) : void 0
},
copy: function(a) {
return this.r = a.r,
this.g = a.g,
this.b = a.b,
this
},
copyGammaToLinear: function(a) {
return this.r = a.r * a.r,
this.g = a.g * a.g,
this.b = a.b * a.b,
this
},
copyLinearToGamma: function(a) {
return this.r = Math.sqrt(a.r),
this.g = Math.sqrt(a.g),
this.b = Math.sqrt(a.b),
this
},
convertGammaToLinear: function() {
var a = this.r,
b = this.g,
c = this.b;
return this.r = a * a,
this.g = b * b,
this.b = c * c,
this
},
convertLinearToGamma: function() {
return this.r = Math.sqrt(this.r),
this.g = Math.sqrt(this.g),
this.b = Math.sqrt(this.b),
this
},
getHex: function() {
return 255 * this.r << 16^255 * this.g << 8^255 * this.b << 0
},
getHexString: function() {
return ("000000" + this.getHex().toString(16)).slice( - 6)
},
getHSL: function() {
var a = {
h: 0,
s: 0,
l: 0
};
return function() {
var b,
c = this.r,
d = this.g,
e = this.b,
f = Math.max(c, d, e),
g = Math.min(c, d, e),
h = (g + f) / 2;
if (g === f)
g = b = 0;
else {
var i = f - g,
g = .5 >= h ? i / (f + g) : i / (2 - f - g);
switch (f) {
case c:
b = (d - e) / i + (e > d ? 6: 0);
break;
case d:
b = (e - c) / i + 2;
break;
case e:
b = (c - d) / i + 4
}
b /= 6
}
return a.h = b,
a.s = g,
a.l = h,
a
}
} (),
getStyle: function() {
return "rgb(" + (255 * this.r | 0) + "," + (255 * this.g | 0) + "," + (255 * this.b | 0) + ")"
},
offsetHSL: function(a, b, c) {
var d = this.getHSL();
return d.h += a,
d.s += b,
d.l += c,
this.setHSL(d.h, d.s, d.l),
this
},
add: function(a) {
return this.r += a.r,
this.g += a.g,
this.b += a.b,
this
},
addColors: function(a, b) {
return this.r = a.r + b.r,
this.g = a.g + b.g,
this.b = a.b + b.b,
this
},
addScalar: function(a) {
return this.r += a,
this.g += a,
this.b += a,
this
},
multiply: function(a) {
return this.r *= a.r,
this.g *= a.g,
this.b *= a.b,
this
},
multiplyScalar: function(a) {
return this.r *= a,
this.g *= a,
this.b *= a,
this
},
lerp: function(a, b) {
return this.r += (a.r - this.r) * b,
this.g += (a.g - this.g) * b,
this.b += (a.b - this.b) * b,
this
},
equals: function(a) {
return a.r === this.r && a.g === this.g && a.b === this.b
},
clone: function() {
return (new THREE.Color).setRGB(this.r, this.g, this.b)
}
},
THREE.ColorKeywords = {
aliceblue: 15792383,
antiquewhite: 16444375,
aqua: 65535,
aquamarine: 8388564,
azure: 15794175,
beige: 16119260,
bisque: 16770244,
black: 0,
blanchedalmond: 16772045,
blue: 255,
blueviolet: 9055202,
brown: 10824234,
burlywood: 14596231,
cadetblue: 6266528,
chartreuse: 8388352,
chocolate: 13789470,
coral: 16744272,
cornflowerblue: 6591981,
cornsilk: 16775388,
crimson: 14423100,
cyan: 65535,
darkblue: 139,
darkcyan: 35723,
darkgoldenrod: 12092939,
darkgray: 11119017,
darkgreen: 25600,
darkgrey: 11119017,
darkkhaki: 12433259,
darkmagenta: 9109643,
darkolivegreen: 5597999,
darkorange: 16747520,
darkorchid: 10040012,
darkred: 9109504,
darksalmon: 15308410,
darkseagreen: 9419919,
darkslateblue: 4734347,
darkslategray: 3100495,
darkslategrey: 3100495,
darkturquoise: 52945,
darkviolet: 9699539,
deeppink: 16716947,
deepskyblue: 49151,
dimgray: 6908265,
dimgrey: 6908265,
dodgerblue: 2003199,
firebrick: 11674146,
floralwhite: 16775920,
forestgreen: 2263842,
fuchsia: 16711935,
gainsboro: 14474460,
ghostwhite: 16316671,
gold: 16766720,
goldenrod: 14329120,
gray: 8421504,
green: 32768,
greenyellow: 11403055,
grey: 8421504,
honeydew: 15794160,
hotpink: 16738740,
indianred: 13458524,
indigo: 4915330,
ivory: 16777200,
khaki: 15787660,
lavender: 15132410,
lavenderblush: 16773365,
lawngreen: 8190976,
lemonchiffon: 16775885,
lightblue: 11393254,
lightcoral: 15761536,
lightcyan: 14745599,
lightgoldenrodyellow: 16448210,
lightgray: 13882323,
lightgreen: 9498256,
lightgrey: 13882323,
lightpink: 16758465,
lightsalmon: 16752762,
lightseagreen: 2142890,
lightskyblue: 8900346,
lightslategray: 7833753,
lightslategrey: 7833753,
lightsteelblue: 11584734,
lightyellow: 16777184,
lime: 65280,
limegreen: 3329330,
linen: 16445670,
magenta: 16711935,
maroon: 8388608,
mediumaquamarine: 6737322,
mediumblue: 205,
mediumorchid: 12211667,
mediumpurple: 9662683,
mediumseagreen: 3978097,
mediumslateblue: 8087790,
mediumspringgreen: 64154,
mediumturquoise: 4772300,
mediumvioletred: 13047173,
midnightblue: 1644912,
mintcream: 16121850,
mistyrose: 16770273,
moccasin: 16770229,
navajowhite: 16768685,
navy: 128,
oldlace: 16643558,
olive: 8421376,
olivedrab: 7048739,
orange: 16753920,
orangered: 16729344,
orchid: 14315734,
palegoldenrod: 15657130,
palegreen: 10025880,
paleturquoise: 11529966,
palevioletred: 14381203,
papayawhip: 16773077,
peachpuff: 16767673,
peru: 13468991,
pink: 16761035,
plum: 14524637,
powderblue: 11591910,
purple: 8388736,
red: 16711680,
rosybrown: 12357519,
royalblue: 4286945,
saddlebrown: 9127187,
salmon: 16416882,
sandybrown: 16032864,
seagreen: 3050327,
seashell: 16774638,
sienna: 10506797,
silver: 12632256,
skyblue: 8900331,
slateblue: 6970061,
slategray: 7372944,
slategrey: 7372944,
snow: 16775930,
springgreen: 65407,
steelblue: 4620980,
tan: 13808780,
teal: 32896,
thistle: 14204888,
tomato: 16737095,
turquoise: 4251856,
violet: 15631086,
wheat: 16113331,
white: 16777215,
whitesmoke: 16119285,
yellow: 16776960,
yellowgreen: 10145074
},
THREE.Quaternion = function(a, b, c, d) {
this.x = a || 0,
this.y = b || 0,
this.z = c || 0,
this.w = void 0 !== d ? d: 1
},
THREE.Quaternion.prototype = {
constructor: THREE.Quaternion,
set: function(a, b, c, d) {
return this.x = a,
this.y = b,
this.z = c,
this.w = d,
this
},
copy: function(a) {
return this.x = a.x,
this.y = a.y,
this.z = a.z,
this.w = a.w,
this
},
setFromEuler: function(a, b) {
var c = Math.cos(a.x / 2),
d = Math.cos(a.y / 2),
e = Math.cos(a.z / 2),
f = Math.sin(a.x / 2),
g = Math.sin(a.y / 2),
h = Math.sin(a.z / 2);
return void 0 === b || "XYZ" === b ? (this.x = f * d * e + c * g * h, this.y = c * g * e - f * d * h, this.z = c * d * h + f * g * e, this.w = c * d * e - f * g * h) : "YXZ" === b ? (this.x = f * d * e + c * g * h, this.y = c * g * e - f * d * h, this.z = c * d * h - f * g * e, this.w = c * d * e + f * g * h) : "ZXY" === b ? (this.x = f * d * e - c * g * h, this.y = c * g * e + f * d * h, this.z = c * d * h + f * g * e, this.w = c * d * e - f * g * h) : "ZYX" === b ? (this.x = f * d * e - c * g * h, this.y = c * g * e + f * d * h, this.z = c * d * h - f * g * e, this.w = c * d * e + f * g * h) : "YZX" === b ? (this.x = f * d * e + c * g * h, this.y = c * g * e + f * d * h, this.z = c * d * h - f * g * e, this.w = c * d * e - f * g * h) : "XZY" === b && (this.x = f * d * e - c * g * h, this.y = c * g * e - f * d * h, this.z = c * d * h + f * g * e, this.w = c * d * e + f * g * h),
this
},
setFromAxisAngle: function(a, b) {
var c = b / 2,
d = Math.sin(c);
return this.x = a.x * d,
this.y = a.y * d,
this.z = a.z * d,
this.w = Math.cos(c),
this
},
setFromRotationMatrix: function(a) {
var b = a.elements,
c = b[0],
a = b[4],
d = b[8],
e = b[1],
f = b[5],
g = b[9],
h = b[2],
i = b[6],
b = b[10],
j = c + f + b;
return j > 0 ? (c = .5 / Math.sqrt(j + 1), this.w = .25 / c, this.x = (i - g) * c, this.y = (d - h) * c, this.z = (e - a) * c) : c > f && c > b ? (c = 2 * Math.sqrt(1 + c - f - b), this.w = (i - g) / c, this.x = .25 * c, this.y = (a + e) / c, this.z = (d + h) / c) : f > b ? (c = 2 * Math.sqrt(1 + f - c - b), this.w = (d - h) / c, this.x = (a + e) / c, this.y = .25 * c, this.z = (g + i) / c) : (c = 2 * Math.sqrt(1 + b - c - f), this.w = (e - a) / c, this.x = (d + h) / c, this.y = (g + i) / c, this.z = .25 * c),
this
},
inverse: function() {
return this.conjugate().normalize(),
this
},
conjugate: function() {
return this.x *= -1,
this.y *= -1,
this.z *= -1,
this
},
lengthSq: function() {
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
},
length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
},
normalize: function() {
var a = this.length();
return 0 === a ? (this.z = this.y = this.x = 0, this.w = 1) : (a = 1 / a, this.x *= a, this.y *= a, this.z *= a, this.w *= a),
this
},
multiply: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Quaternion's .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), this.multiplyQuaternions(a, b)) : this.multiplyQuaternions(this, a)
},
multiplyQuaternions: function(a, b) {
var c = a.x,
d = a.y,
e = a.z,
f = a.w,
g = b.x,
h = b.y,
i = b.z,
j = b.w;
return this.x = c * j + f * g + d * i - e * h,
this.y = d * j + f * h + e * g - c * i,
this.z = e * j + f * i + c * h - d * g,
this.w = f * j - c * g - d * h - e * i,
this
},
multiplyVector3: function(a) {
return console.warn("DEPRECATED: Quaternion's .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),
a.applyQuaternion(this)
},
slerp: function(a, b) {
var c = this.x,
d = this.y,
e = this.z,
f = this.w,
g = f * a.w + c * a.x + d * a.y + e * a.z;
if (0 > g ? (this.w = -a.w, this.x = -a.x, this.y = -a.y, this.z = -a.z, g = -g) : this.copy(a), g >= 1)
return this.w = f,
this.x = c,
this.y = d,
this.z = e,
this;
var h = Math.acos(g),
i = Math.sqrt(1 - g * g);
return.001 > Math.abs(i) ? (this.w = .5 * (f + this.w), this.x = .5 * (c + this.x), this.y = .5 * (d + this.y), this.z = .5 * (e + this.z), this) : (g = Math.sin((1 - b) * h) / i, h = Math.sin(b * h) / i, this.w = f * g + this.w * h, this.x = c * g + this.x * h, this.y = d * g + this.y * h, this.z = e * g + this.z * h, this)
},
equals: function(a) {
return a.x === this.x && a.y === this.y && a.z === this.z && a.w === this.w
},
fromArray: function(a) {
return this.x = a[0],
this.y = a[1],
this.z = a[2],
this.w = a[3],
this
},
toArray: function() {
return [this.x, this.y, this.z, this.w]
},
clone: function() {
return new THREE.Quaternion(this.x, this.y, this.z, this.w)
}
},
THREE.Quaternion.slerp = function(a, b, c, d) {
return c.copy(a).slerp(b, d)
},
THREE.Vector2 = function(a, b) {
this.x = a || 0,
this.y = b || 0
},
THREE.Vector2.prototype = {
constructor: THREE.Vector2,
set: function(a, b) {
return this.x = a,
this.y = b,
this
},
setX: function(a) {
return this.x = a,
this
},
setY: function(a) {
return this.y = a,
this
},
setComponent: function(a, b) {
switch (a) {
case 0:
this.x = b;
break;
case 1:
this.y = b;
break;
default:
throw Error("index is out of range: " + a)
}
},
getComponent: function(a) {
switch (a) {
case 0:
return this.x;
case 1:
return this.y;
default:
throw Error("index is out of range: " + a)
}
},
copy: function(a) {
return this.x = a.x,
this.y = a.y,
this
},
add: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Vector2's .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(a, b)) : (this.x += a.x, this.y += a.y, this)
},
addVectors: function(a, b) {
return this.x = a.x + b.x,
this.y = a.y + b.y,
this
},
addScalar: function(a) {
return this.x += a,
this.y += a,
this
},
sub: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Vector2's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(a, b)) : (this.x -= a.x, this.y -= a.y, this)
},
subVectors: function(a, b) {
return this.x = a.x - b.x,
this.y = a.y - b.y,
this
},
multiplyScalar: function(a) {
return this.x *= a,
this.y *= a,
this
},
divideScalar: function(a) {
return 0 !== a ? (this.x /= a, this.y /= a) : this.set(0, 0),
this
},
min: function(a) {
return this.x > a.x && (this.x = a.x),
this.y > a.y && (this.y = a.y),
this
},
max: function(a) {
return this.x < a.x && (this.x = a.x),
this.y < a.y && (this.y = a.y),
this
},
clamp: function(a, b) {
return this.x < a.x ? this.x = a.x: this.x > b.x && (this.x = b.x),
this.y < a.y ? this.y = a.y: this.y > b.y && (this.y = b.y),
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.x * this.x + this.y * this.y)
},
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) {
var b = this.length();
return 0 !== b && a !== b && this.multiplyScalar(a / b),
this
},
lerp: function(a, b) {
return this.x += (a.x - this.x) * b,
this.y += (a.y - this.y) * b,
this
},
equals: function(a) {
return a.x === this.x && a.y === this.y
},
fromArray: function(a) {
return this.x = a[0],
this.y = a[1],
this
},
toArray: function() {
return [this.x, this.y]
},
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) {
return this.x = a,
this.y = b,
this.z = c,
this
},
setX: function(a) {
return this.x = a,
this
},
setY: function(a) {
return this.y = a,
this
},
setZ: function(a) {
return this.z = a,
this
},
setComponent: function(a, b) {
switch (a) {
case 0:
this.x = b;
break;
case 1:
this.y = b;
break;
case 2:
this.z = b;
break;
default:
throw Error("index is out of range: " + a)
}
},
getComponent: function(a) {
switch (a) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
default:
throw Error("index is out of range: " + a)
}
},
copy: function(a) {
return this.x = a.x,
this.y = a.y,
this.z = a.z,
this
},
add: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Vector3's .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(a, b)) : (this.x += a.x, this.y += a.y, this.z += a.z, this)
},
addScalar: function(a) {
return this.x += a,
this.y += a,
this.z += a,
this
},
addVectors: function(a, b) {
return this.x = a.x + b.x,
this.y = a.y + b.y,
this.z = a.z + b.z,
this
},
sub: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Vector3's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(a, b)) : (this.x -= a.x, this.y -= a.y, this.z -= a.z, this)
},
subVectors: function(a, b) {
return this.x = a.x - b.x,
this.y = a.y - b.y,
this.z = a.z - b.z,
this
},
multiply: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Vector3's .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), this.multiplyVectors(a, b)) : (this.x *= a.x, this.y *= a.y, this.z *= a.z, this)
},
multiplyScalar: function(a) {
return this.x *= a,
this.y *= a,
this.z *= a,
this
},
multiplyVectors: function(a, b) {
return this.x = a.x * b.x,
this.y = a.y * b.y,
this.z = a.z * b.z,
this
},
applyMatrix3: function(a) {
var b = this.x,
c = this.y,
d = this.z,
a = a.elements;
return this.x = a[0] * b + a[3] * c + a[6] * d,
this.y = a[1] * b + a[4] * c + a[7] * d,
this.z = a[2] * b + a[5] * c + a[8] * d,
this
},
applyMatrix4: function(a) {
var b = this.x,
c = this.y,
d = this.z,
a = a.elements;
return this.x = a[0] * b + a[4] * c + a[8] * d + a[12],
this.y = a[1] * b + a[5] * c + a[9] * d + a[13],
this.z = a[2] * b + a[6] * c + a[10] * d + a[14],
this
},
applyProjection: function(a) {
var b = this.x,
c = this.y,
d = this.z,
a = a.elements,
e = 1 / (a[3] * b + a[7] * c + a[11] * d + a[15]);
return this.x = (a[0] * b + a[4] * c + a[8] * d + a[12]) * e,
this.y = (a[1] * b + a[5] * c + a[9] * d + a[13]) * e,
this.z = (a[2] * b + a[6] * c + a[10] * d + a[14]) * e,
this
},
applyQuaternion: function(a) {
var b = this.x,
c = this.y,
d = this.z,
e = a.x,
f = a.y,
g = a.z,
a = a.w,
h = a * b + f * d - g * c,
i = a * c + g * b - e * d,
j = a * d + e * c - f * b,
b = -e * b - f * c - g * d;
return this.x = h * a + b * -e + i * -g - j * -f,
this.y = i * a + b * -f + j * -e - h * -g,
this.z = j * a + b * -g + h * -f - i * -e,
this
},
transformDirection: function(a) {
var b = this.x,
c = this.y,
d = this.z,
a = a.elements;
return this.x = a[0] * b + a[4] * c + a[8] * d,
this.y = a[1] * b + a[5] * c + a[9] * d,
this.z = a[2] * b + a[6] * c + a[10] * d,
this.normalize(),
this
},
divide: function(a) {
return this.x /= a.x,
this.y /= a.y,
this.z /= a.z,
this
},
divideScalar: function(a) {
return 0 !== a ? (this.x /= a, this.y /= a, this.z /= a) : this.z = this.y = this.x = 0,
this
},
min: function(a) {
return this.x > a.x && (this.x = a.x),
this.y > a.y && (this.y = a.y),
this.z > a.z && (this.z = a.z),
this
},
max: function(a) {
return this.x < a.x && (this.x = a.x),
this.y < a.y && (this.y = a.y),
this.z < a.z && (this.z = a.z),
this
},
clamp: function(a, b) {
return this.x < a.x ? this.x = a.x: this.x > b.x && (this.x = b.x),
this.y < a.y ? this.y = a.y: this.y > b.y && (this.y = b.y),
this.z < a.z ? this.z = a.z: this.z > b.z && (this.z = b.z),
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.x * this.x + this.y * this.y + this.z * this.z)
},
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) {
var b = this.length();
return 0 !== b && a !== b && this.multiplyScalar(a / b),
this
},
lerp: function(a, b) {
return this.x += (a.x - this.x) * b,
this.y += (a.y - this.y) * b,
this.z += (a.z - this.z) * b,
this
},
cross: function(a, b) {
if (void 0 !== b)
return console.warn("DEPRECATED: Vector3's .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),
this.crossVectors(a, b);
var c = this.x,
d = this.y,
e = this.z;
return this.x = d * a.z - e * a.y,
this.y = e * a.x - c * a.z,
this.z = c * a.y - d * a.x,
this
},
crossVectors: function(a, b) {
return 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,
this
},
angleTo: function(a) {
return a = this.dot(a) / (this.length() * a.length()),
Math.acos(THREE.Math.clamp(a, -1, 1))
},
distanceTo: function(a) {
return Math.sqrt(this.distanceToSquared(a))
},
distanceToSquared: function(a) {
var b = this.x - a.x,
c = this.y - a.y,
a = this.z - a.z;
return b * b + c * c + a * a
},
setEulerFromRotationMatrix: function(a, b) {
function c(a) {
return Math.min(Math.max(a, -1), 1)
}
var d = a.elements,
e = d[0],
f = d[4],
g = d[8],
h = d[1],
i = d[5],
j = d[9],
k = d[2],
l = d[6],
d = d[10];
return void 0 === b || "XYZ" === b ? (this.y = Math.asin(c(g)), .99999 > Math.abs(g) ? (this.x = Math.atan2( - j, d), this.z = Math.atan2( - f, e)) : (this.x = Math.atan2(l, i), this.z = 0)) : "YXZ" === b ? (this.x = Math.asin( - c(j)), .99999 > Math.abs(j) ? (this.y = Math.atan2(g, d), this.z = Math.atan2(h, i)) : (this.y = Math.atan2( - k, e), this.z = 0)) : "ZXY" === b ? (this.x = Math.asin(c(l)), .99999 > Math.abs(l) ? (this.y = Math.atan2( - k, d), this.z = Math.atan2( - f, i)) : (this.y = 0, this.z = Math.atan2(h, e))) : "ZYX" === b ? (this.y = Math.asin( - c(k)), .99999 > Math.abs(k) ? (this.x = Math.atan2(l, d), this.z = Math.atan2(h, e)) : (this.x = 0, this.z = Math.atan2( - f, i))) : "YZX" === b ? (this.z = Math.asin(c(h)), .99999 > Math.abs(h) ? (this.x = Math.atan2( - j, i), this.y = Math.atan2( - k, e)) : (this.x = 0, this.y = Math.atan2(g, d))) : "XZY" === b && (this.z = Math.asin( - c(f)), .99999 > Math.abs(f) ? (this.x = Math.atan2(l, i), this.y = Math.atan2(g, e)) : (this.x = Math.atan2( - j, d), this.y = 0)),
this
},
setEulerFromQuaternion: function(a, b) {
function c(a) {
return Math.min(Math.max(a, -1), 1)
}
var d = a.x * a.x,
e = a.y * a.y,
f = a.z * a.z,
g = a.w * a.w;
return void 0 === b || "XYZ" === b ? (this.x = Math.atan2(2 * (a.x * a.w - a.y * a.z), g - d - e + f), this.y = Math.asin(c(2 * (a.x * a.z + a.y * a.w))), this.z = Math.atan2(2 * (a.z * a.w - a.x * a.y), g + d - e - f)) : "YXZ" === b ? (this.x = Math.asin(c(2 * (a.x * a.w - a.y * a.z))), this.y = Math.atan2(2 * (a.x * a.z + a.y * a.w), g - d - e + f), this.z = Math.atan2(2 * (a.x * a.y + a.z * a.w), g - d + e - f)) : "ZXY" === b ? (this.x = Math.asin(c(2 * (a.x * a.w + a.y * a.z))), this.y = Math.atan2(2 * (a.y * a.w - a.z * a.x), g - d - e + f), this.z = Math.atan2(2 * (a.z * a.w - a.x * a.y), g - d + e - f)) : "ZYX" === b ? (this.x = Math.atan2(2 * (a.x * a.w + a.z * a.y), g - d - e + f), this.y = Math.asin(c(2 * (a.y * a.w - a.x * a.z))), this.z = Math.atan2(2 * (a.x * a.y + a.z * a.w), g + d - e - f)) : "YZX" === b ? (this.x = Math.atan2(2 * (a.x * a.w - a.z * a.y), g - d + e - f), this.y = Math.atan2(2 * (a.y * a.w - a.x * a.z), g + d - e - f), this.z = Math.asin(c(2 * (a.x * a.y + a.z * a.w)))) : "XZY" === b && (this.x = Math.atan2(2 * (a.x * a.w + a.y * a.z), g - d + e - f), this.y = Math.atan2(2 * (a.x * a.z + a.y * a.w), g + d - e - f), this.z = Math.asin(c(2 * (a.z * a.w - a.x * a.y)))),
this
},
getPositionFromMatrix: function(a) {
return this.x = a.elements[12],
this.y = a.elements[13],
this.z = a.elements[14],
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();
return this.x = b,
this.y = c,
this.z = a,
this
},
getColumnFromMatrix: function(a, b) {
var c = 4 * a,
d = b.elements;
return this.x = d[c],
this.y = d[c + 1],
this.z = d[c + 2],
this
},
equals: function(a) {
return a.x === this.x && a.y === this.y && a.z === this.z
},
fromArray: function(a) {
return this.x = a[0],
this.y = a[1],
this.z = a[2],
this
},
toArray: function() {
return [this.x, this.y, this.z]
},
clone: function() {
return new THREE.Vector3(this.x, this.y, this.z)
}
},
THREE.extend(THREE.Vector3.prototype, {
applyEuler: function() {
var a = new THREE.Quaternion;
return function(b, c) {
var d = a.setFromEuler(b, c);
return this.applyQuaternion(d),
this
}
} (),
applyAxisAngle: function() {
var a = new THREE.Quaternion;
return function(b, c) {
var d = a.setFromAxisAngle(b, c);
return this.applyQuaternion(d),
this
}
} (),
projectOnVector: function() {
var a = new THREE.Vector3;
return function(b) {
return a.copy(b).normalize(),
b = this.dot(a),
this.copy(a).multiplyScalar(b)
}
} (),
projectOnPlane: function() {
var a = new THREE.Vector3;
return function(b) {
return a.copy(this).projectOnVector(b),
this.sub(a)
}
} (),
reflect: function() {
var a = new THREE.Vector3;
return function(b) {
return a.copy(this).projectOnVector(b).multiplyScalar(2),
this.subVectors(a, this)
}
} ()
}),
THREE.Vector4 = function(a, b, c, d) {
this.x = a || 0,
this.y = b || 0,
this.z = c || 0,
this.w = void 0 !== d ? d: 1
},
THREE.Vector4.prototype = {
constructor: THREE.Vector4,
set: function(a, b, c, d) {
return this.x = a,
this.y = b,
this.z = c,
this.w = d,
this
},
setX: function(a) {
return this.x = a,
this
},
setY: function(a) {
return this.y = a,
this
},
setZ: function(a) {
return this.z = a,
this
},
setW: function(a) {
return this.w = a,
this
},
setComponent: function(a, b) {
switch (a) {
case 0:
this.x = b;
break;
case 1:
this.y = b;
break;
case 2:
this.z = b;
break;
case 3:
this.w = b;
break;
default:
throw Error("index is out of range: " + a)
}
},
getComponent: function(a) {
switch (a) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
case 3:
return this.w;
default:
throw Error("index is out of range: " + a)
}
},
copy: function(a) {
return this.x = a.x,
this.y = a.y,
this.z = a.z,
this.w = void 0 !== a.w ? a.w: 1,
this
},
add: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Vector4's .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(a, b)) : (this.x += a.x, this.y += a.y, this.z += a.z, this.w += a.w, this)
},
addScalar: function(a) {
return this.x += a,
this.y += a,
this.z += a,
this.w += a,
this
},
addVectors: function(a, b) {
return this.x = a.x + b.x,
this.y = a.y + b.y,
this.z = a.z + b.z,
this.w = a.w + b.w,
this
},
sub: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Vector4's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(a, b)) : (this.x -= a.x, this.y -= a.y, this.z -= a.z, this.w -= a.w, this)
},
subVectors: function(a, b) {
return this.x = a.x - b.x,
this.y = a.y - b.y,
this.z = a.z - b.z,
this.w = a.w - b.w,
this
},
multiplyScalar: function(a) {
return this.x *= a,
this.y *= a,
this.z *= a,
this.w *= a,
this
},
applyMatrix4: function(a) {
var b = this.x,
c = this.y,
d = this.z,
e = this.w,
a = a.elements;
return this.x = a[0] * b + a[4] * c + a[8] * d + a[12] * e,
this.y = a[1] * b + a[5] * c + a[9] * d + a[13] * e,
this.z = a[2] * b + a[6] * c + a[10] * d + a[14] * e,
this.w = a[3] * b + a[7] * c + a[11] * d + a[15] * e,
this
},
divideScalar: function(a) {
return 0 !== a ? (this.x /= a, this.y /= a, this.z /= a, this.w /= a) : (this.z = this.y = this.x = 0, this.w = 1),
this
},
setAxisAngleFromQuaternion: function(a) {
this.w = 2 * Math.acos(a.w);
var b = Math.sqrt(1 - a.w * a.w);
return 1e - 4 > b ? (this.x = 1, this.z = this.y = 0) : (this.x = a.x / b, this.y = a.y / b, this.z = a.z / b),
this
},
setAxisAngleFromRotationMatrix: function(a) {
var b,
c,
d,
a = a.elements,
e = a[0];
d = a[4];
var f = a[8],
g = a[1],
h = a[5],
i = a[9];
c = a[2],
b = a[6];
var j = a[10];
return.01 > Math.abs(d - g) && .01 > Math.abs(f - c) && .01 > Math.abs(i - b) ? .1 > Math.abs(d + g) && .1 > Math.abs(f + c) && .1 > Math.abs(i + b) && .1 > Math.abs(e + h + j - 3) ? (this.set(1, 0, 0, 0), this) : (a = Math.PI, e = (e + 1) / 2, h = (h + 1) / 2, j = (j + 1) / 2, d = (d + g) / 4, f = (f + c) / 4, i = (i + b) / 4, e > h && e > j ? .01 > e ? (b = 0, d = c = .707106781) : (b = Math.sqrt(e), c = d / b, d = f / b) : h > j ? .01 > h ? (b = .707106781, c = 0, d = .707106781) : (c = Math.sqrt(h), b = d / c, d = i / c) : .01 > j ? (c = b = .707106781, d = 0) : (d = Math.sqrt(j), b = f / d, c = i / d), this.set(b, c, d, a), this) : (a = Math.sqrt((b - i) * (b - i) + (f - c) * (f - c) + (g - d) * (g - d)), .001 > Math.abs(a) && (a = 1), this.x = (b - i) / a, this.y = (f - c) / a, this.z = (g - d) / a, this.w = Math.acos((e + h + j - 1) / 2), this)
},
min: function(a) {
return this.x > a.x && (this.x = a.x),
this.y > a.y && (this.y = a.y),
this.z > a.z && (this.z = a.z),
this.w > a.w && (this.w = a.w),
this
},
max: function(a) {
return this.x < a.x && (this.x = a.x),
this.y < a.y && (this.y = a.y),
this.z < a.z && (this.z = a.z),
this.w < a.w && (this.w = a.w),
this
},
clamp: function(a, b) {
return this.x < a.x ? this.x = a.x: this.x > b.x && (this.x = b.x),
this.y < a.y ? this.y = a.y: this.y > b.y && (this.y = b.y),
this.z < a.z ? this.z = a.z: this.z > b.z && (this.z = b.z),
this.w < a.w ? this.w = a.w: this.w > b.w && (this.w = b.w),
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.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
},
length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
},
lengthManhattan: function() {
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w)
},
normalize: function() {
return this.divideScalar(this.length())
},
setLength: function(a) {
var b = this.length();
return 0 !== b && a !== b && this.multiplyScalar(a / b),
this
},
lerp: function(a, b) {
return this.x += (a.x - this.x) * b,
this.y += (a.y - this.y) * b,
this.z += (a.z - this.z) * b,
this.w += (a.w - this.w) * b,
this
},
equals: function(a) {
return a.x === this.x && a.y === this.y && a.z === this.z && a.w === this.w
},
fromArray: function(a) {
return this.x = a[0],
this.y = a[1],
this.z = a[2],
this.w = a[3],
this
},
toArray: function() {
return [this.x, this.y, this.z, this.w]
},
clone: function() {
return new THREE.Vector4(this.x, this.y, this.z, this.w)
}
},
THREE.Line3 = function(a, b) {
this.start = void 0 !== a ? a: new THREE.Vector3,
this.end = void 0 !== b ? b: new THREE.Vector3
},
THREE.Line3.prototype = {
constructor: THREE.Line3,
set: function(a, b) {
return this.start.copy(a),
this.end.copy(b),
this
},
copy: function(a) {
return this.start.copy(a.start),
this.end.copy(a.end),
this
},
center: function(a) {
return (a || new THREE.Vector3).addVectors(this.start, this.end).multiplyScalar(.5)
},
delta: function(a) {
return (a || new THREE.Vector3).subVectors(this.end, this.start)
},
distanceSq: function() {
return this.start.distanceToSquared(this.end)
},
distance: function() {
return this.start.distanceTo(this.end)
},
at: function(a, b) {
var c = b || new THREE.Vector3;
return this.delta(c).multiplyScalar(a).add(this.start)
},
closestPointToPointParameter: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function(c, d) {
a.subVectors(c, this.start),
b.subVectors(this.end, this.start);
var e = b.dot(b),
e = b.dot(a) / e;
return d && (e = THREE.Math.clamp(e, 0, 1)),
e
}
} (),
closestPointToPoint: function(a, b, c) {
return a = this.closestPointToPointParameter(a, b),
c = c || new THREE.Vector3,
this.delta(c).multiplyScalar(a).add(this.start)
},
applyMatrix4: function(a) {
return this.start.applyMatrix4(a),
this.end.applyMatrix4(a),
this
},
equals: function(a) {
return a.start.equals(this.start) && a.end.equals(this.end)
},
clone: function() {
return (new THREE.Line3).copy(this)
}
},
THREE.Box2 = function(a, b) {
this.min = void 0 !== a ? a: new THREE.Vector2(1 / 0, 1 / 0),
this.max = void 0 !== b ? b: new THREE.Vector2( - 1 / 0, -1 / 0)
},
THREE.Box2.prototype = {
constructor: THREE.Box2,
set: function(a, b) {
return this.min.copy(a),
this.max.copy(b),
this
},
setFromPoints: function(a) {
if (0 < a.length) {
var b = a[0];
this.min.copy(b),
this.max.copy(b);
for (var c = 1, d = a.length; d > c; c++)
b = a[c],
b.x < this.min.x ? this.min.x = b.x: b.x > this.max.x && (this.max.x = b.x),
b.y < this.min.y ? this.min.y = b.y: b.y > this.max.y && (this.max.y = b.y)
} else
this.makeEmpty();
return this
},
setFromCenterAndSize: function() {
var a = new THREE.Vector2;
return function(b, c) {
var d = a.copy(c).multiplyScalar(.5);
return this.min.copy(b).sub(d),
this.max.copy(b).add(d),
this
}
} (),
copy: function(a) {
return this.min.copy(a.min),
this.max.copy(a.max),
this
},
makeEmpty: function() {
return this.min.x = this.min.y = 1 / 0,
this.max.x = this.max.y = -1 / 0,
this
},
empty: function() {
return this.max.x < this.min.x || this.max.y < this.min.y
},
center: function(a) {
return (a || new THREE.Vector2).addVectors(this.min, this.max).multiplyScalar(.5)
},
size: function(a) {
return (a || new THREE.Vector2).subVectors(this.max, this.min)
},
expandByPoint: function(a) {
return this.min.min(a),
this.max.max(a),
this
},
expandByVector: function(a) {
return this.min.sub(a),
this.max.add(a),
this
},
expandByScalar: function(a) {
return this.min.addScalar( - a),
this.max.addScalar(a),
this
},
containsPoint: function(a) {
return a.x < this.min.x || a.x > this.max.x || a.y < this.min.y || a.y > this.max.y ? !1: !0
},
containsBox: function(a) {
return this.min.x <= a.min.x && a.max.x <= this.max.x && this.min.y <= a.min.y && a.max.y <= this.max.y ? !0: !1
},
getParameter: function(a) {
return new THREE.Vector2((a.x - this.min.x) / (this.max.x - this.min.x), (a.y - this.min.y) / (this.max.y - this.min.y))
},
isIntersectionBox: function(a) {
return a.max.x < this.min.x || a.min.x > this.max.x || a.max.y < this.min.y || a.min.y > this.max.y ? !1: !0
},
clampPoint: function(a, b) {
return (b || new THREE.Vector2).copy(a).clamp(this.min, this.max)
},
distanceToPoint: function() {
var a = new THREE.Vector2;
return function(b) {
return a.copy(b).clamp(this.min, this.max).sub(b).length()
}
} (),
intersect: function(a) {
return this.min.max(a.min),
this.max.min(a.max),
this
},
union: function(a) {
return this.min.min(a.min),
this.max.max(a.max),
this
},
translate: function(a) {
return this.min.add(a),
this.max.add(a),
this
},
equals: function(a) {
return a.min.equals(this.min) && a.max.equals(this.max)
},
clone: function() {
return (new THREE.Box2).copy(this)
}
},
THREE.Box3 = function(a, b) {
this.min = void 0 !== a ? a: new THREE.Vector3(1 / 0, 1 / 0, 1 / 0),
this.max = void 0 !== b ? b: new THREE.Vector3( - 1 / 0, -1 / 0, -1 / 0)
},
THREE.Box3.prototype = {
constructor: THREE.Box3,
set: function(a, b) {
return this.min.copy(a),
this.max.copy(b),
this
},
setFromPoints: function(a) {
if (0 < a.length) {
var b = a[0];
this.min.copy(b),
this.max.copy(b);
for (var c = 1, d = a.length; d > c; c++)
b = a[c],
b.x < this.min.x ? this.min.x = b.x: b.x > this.max.x && (this.max.x = b.x),
b.y < this.min.y ? this.min.y = b.y: b.y > this.max.y && (this.max.y = b.y),
b.z < this.min.z ? this.min.z = b.z: b.z > this.max.z && (this.max.z = b.z)
} else
this.makeEmpty();
return this
},
setFromCenterAndSize: function() {
var a = new THREE.Vector3;
return function(b, c) {
var d = a.copy(c).multiplyScalar(.5);
return this.min.copy(b).sub(d),
this.max.copy(b).add(d),
this
}
} (),
copy: function(a) {
return this.min.copy(a.min),
this.max.copy(a.max),
this
},
makeEmpty: function() {
return this.min.x = this.min.y = this.min.z = 1 / 0,
this.max.x = this.max.y = this.max.z = -1 / 0,
this
},
empty: function() {
return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z
},
center: function(a) {
return (a || new THREE.Vector3).addVectors(this.min, this.max).multiplyScalar(.5)
},
size: function(a) {
return (a || new THREE.Vector3).subVectors(this.max, this.min)
},
expandByPoint: function(a) {
return this.min.min(a),
this.max.max(a),
this
},
expandByVector: function(a) {
return this.min.sub(a),
this.max.add(a),
this
},
expandByScalar: function(a) {
return this.min.addScalar( - a),
this.max.addScalar(a),
this
},
containsPoint: function(a) {
return a.x < this.min.x || a.x > this.max.x || a.y < this.min.y || a.y > this.max.y || a.z < this.min.z || a.z > this.max.z ? !1: !0
},
containsBox: function(a) {
return this.min.x <= a.min.x && a.max.x <= this.max.x && this.min.y <= a.min.y && a.max.y <= this.max.y && this.min.z <= a.min.z && a.max.z <= this.max.z ? !0: !1
},
getParameter: function(a) {
return new THREE.Vector3((a.x - this.min.x) / (this.max.x - this.min.x), (a.y - this.min.y) / (this.max.y - this.min.y), (a.z - this.min.z) / (this.max.z - this.min.z))
},
isIntersectionBox: function(a) {
return a.max.x < this.min.x || a.min.x > this.max.x || a.max.y < this.min.y || a.min.y > this.max.y || a.max.z < this.min.z || a.min.z > this.max.z ? !1: !0
},
clampPoint: function(a, b) {
return (b || new THREE.Vector3).copy(a).clamp(this.min, this.max)
},
distanceToPoint: function() {
var a = new THREE.Vector3;
return function(b) {
return a.copy(b).clamp(this.min, this.max).sub(b).length()
}
} (),
getBoundingSphere: function() {
var a = new THREE.Vector3;
return function(b) {
return b = b || new THREE.Sphere,
b.center = this.center(),
b.radius = .5 * this.size(a).length(),
b
}
} (),
intersect: function(a) {
return this.min.max(a.min),
this.max.min(a.max),
this
},
union: function(a) {
return this.min.min(a.min),
this.max.max(a.max),
this
},
applyMatrix4: function() {
var a = [new THREE.Vector3, new THREE.Vector3, new THREE.Vector3, new THREE.Vector3, new THREE.Vector3, new THREE.Vector3, new THREE.Vector3, new THREE.Vector3];
return function(b) {
return a[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(b),
a[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(b),
a[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(b),
a[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(b),
a[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(b),
a[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(b),
a[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(b),
a[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(b),
this.makeEmpty(),
this.setFromPoints(a),
this
}
} (),
translate: function(a) {
return this.min.add(a),
this.max.add(a),
this
},
equals: function(a) {
return a.min.equals(this.min) && a.max.equals(this.max)
},
clone: function() {
return (new THREE.Box3).copy(this)
}
},
THREE.Matrix3 = function(a, b, c, d, e, f, g, h, i) {
this.elements = new Float32Array(9),
this.set(void 0 !== a ? a: 1, b || 0, c || 0, d || 0, void 0 !== e ? e: 1, f || 0, g || 0, h || 0, void 0 !== i ? i: 1)
},
THREE.Matrix3.prototype = {
constructor: THREE.Matrix3,
set: function(a, b, c, d, e, f, g, h, i) {
var j = this.elements;
return j[0] = a,
j[3] = b,
j[6] = c,
j[1] = d,
j[4] = e,
j[7] = f,
j[2] = g,
j[5] = h,
j[8] = i,
this
},
identity: function() {
return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1),
this
},
copy: function(a) {
return a = a.elements,
this.set(a[0], a[3], a[6], a[1], a[4], a[7], a[2], a[5], a[8]),
this
},
multiplyVector3: function(a) {
return console.warn("DEPRECATED: Matrix3's .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),
a.applyMatrix3(this)
},
multiplyVector3Array: function() {
var a = new THREE.Vector3;
return function(b) {
for (var c = 0, d = b.length; d > c; c += 3)
a.x = b[c],
a.y = b[c + 1],
a.z = b[c + 2],
a.applyMatrix3(this),
b[c] = a.x,
b[c + 1] = a.y,
b[c + 2] = a.z;
return b
}
} (),
multiplyScalar: function(a) {
var b = this.elements;
return b[0] *= a,
b[3] *= a,
b[6] *= a,
b[1] *= a,
b[4] *= a,
b[7] *= a,
b[2] *= a,
b[5] *= a,
b[8] *= a,
this
},
determinant: function() {
var a = this.elements,
b = a[0],
c = a[1],
d = a[2],
e = a[3],
f = a[4],
g = a[5],
h = a[6],
i = a[7],
a = a[8];
return b * f * a - b * g * i - c * e * a + c * g * h + d * e * i - d * f * h
},
getInverse: function(a, b) {
var c = a.elements,
d = this.elements;
if (d[0] = c[10] * c[5] - c[6] * c[9], d[1] = -c[10] * c[1] + c[2] * c[9], d[2] = c[6] * c[1] - c[2] * c[5], d[3] = -c[10] * c[4] + c[6] * c[8], d[4] = c[10] * c[0] - c[2] * c[8], d[5] = -c[6] * c[0] + c[2] * c[4], d[6] = c[9] * c[4] - c[5] * c[8], d[7] = -c[9] * c[0] + c[1] * c[8], d[8] = c[5] * c[0] - c[1] * c[4], c = c[0] * d[0] + c[1] * d[3] + c[2] * d[6], 0 === c) {
if (b)
throw Error("Matrix3.getInverse(): can't invert matrix, determinant is 0");
return console.warn("Matrix3.getInverse(): can't invert matrix, determinant is 0"),
this.identity(),
this
}
return this.multiplyScalar(1 / c),
this
},
transpose: function() {
var a,
b = this.elements;
return 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,
this
},
getNormalMatrix: function(a) {
return this.getInverse(a).transpose(),
this
},
transposeIntoArray: function(a) {
var b = this.elements;
return 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],
this
},
clone: function() {
var a = this.elements;
return new THREE.Matrix3(a[0], a[3], a[6], a[1], a[4], a[7], a[2], a[5], a[8])
}
},
THREE.Matrix4 = function(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {
var q = this.elements = new Float32Array(16);
q[0] = void 0 !== a ? a: 1,
q[4] = b || 0,
q[8] = c || 0,
q[12] = d || 0,
q[1] = e || 0,
q[5] = void 0 !== f ? f: 1,
q[9] = g || 0,
q[13] = h || 0,
q[2] = i || 0,
q[6] = j || 0,
q[10] = void 0 !== k ? k: 1,
q[14] = l || 0,
q[3] = m || 0,
q[7] = n || 0,
q[11] = o || 0,
q[15] = void 0 !== p ? p: 1
},
THREE.Matrix4.prototype = {
constructor: THREE.Matrix4,
set: function(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {
var q = this.elements;
return q[0] = a,
q[4] = b,
q[8] = c,
q[12] = d,
q[1] = e,
q[5] = f,
q[9] = g,
q[13] = h,
q[2] = i,
q[6] = j,
q[10] = k,
q[14] = l,
q[3] = m,
q[7] = n,
q[11] = o,
q[15] = p,
this
},
identity: function() {
return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1),
this
},
copy: function(a) {
return 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]),
this
},
extractPosition: function(a) {
return console.warn("DEPRECATED: Matrix4's .extractPosition() has been renamed to .copyPosition()."),
this.copyPosition(a)
},
copyPosition: function(a) {
var b = this.elements,
a = a.elements;
return b[12] = a[12],
b[13] = a[13],
b[14] = a[14],
this
},
extractRotation: function() {
var a = new THREE.Vector3;
return function(b) {
var c = this.elements,
b = b.elements,
d = 1 / a.set(b[0], b[1], b[2]).length(),
e = 1 / a.set(b[4], b[5], b[6]).length(),
f = 1 / a.set(b[8], b[9], b[10]).length();
return c[0] = b[0] * d,
c[1] = b[1] * d,
c[2] = b[2] * d,
c[4] = b[4] * e,
c[5] = b[5] * e,
c[6] = b[6] * e,
c[8] = b[8] * f,
c[9] = b[9] * f,
c[10] = b[10] * f,
this
}
} (),
setRotationFromEuler: function(a, b) {
return console.warn("DEPRECATED: Matrix4's .setRotationFromEuler() has been deprecated in favor of makeRotationFromEuler. Please update your code."),
this.makeRotationFromEuler(a, b)
},
makeRotationFromEuler: 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),
i = Math.cos(f),
f = Math.sin(f);
if (void 0 === b || "XYZ" === b) {
var j = g * i,
k = g * f,
l = d * i,
m = d * f;
c[0] = h * i,
c[4] = -h * f,
c[8] = e,
c[1] = k + l * e,
c[5] = j - m * e,
c[9] = -d * h,
c[2] = m - j * e,
c[6] = l + k * e,
c[10] = g * h
} else "YXZ" === b ? (j = h * i, k = h * f, l = e * i, m = e * f, c[0] = j + m * d, c[4] = l * d - k, c[8] = g * e, c[1] = g * f, c[5] = g * i, c[9] = -d, c[2] = k * d - l, c[6] = m + j * d, c[10] = g * h) : "ZXY" === b ? (j = h * i, k = h * f, l = e * i, m = e * f, c[0] = j - m * d, c[4] = -g * f, c[8] = l + k * d, c[1] = k + l * d, c[5] = g * i, c[9] = m - j * d, c[2] = -g * e, c[6] = d, c[10] = g * h) : "ZYX" === b ? (j = g * i, k = g * f, l = d * i, m = d * f, c[0] = h * i, c[4] = l * e - k, c[8] = j * e + m, c[1] = h * f, c[5] = m * e + j, c[9] = k * e - l, c[2] = -e, c[6] = d * h, c[10] = g * h) : "YZX" === b ? (j = g * h, k = g * e, l = d * h, m = d * e, c[0] = h * i, c[4] = m - j * f, c[8] = l * f + k, c[1] = f, c[5] = g * i, c[9] = -d * i, c[2] = -e * i, c[6] = k * f + l, c[10] = j - m * f) : "XZY" === b && (j = g * h, k = g * e, l = d * h, m = d * e, c[0] = h * i, c[4] = -f, c[8] = e * i, c[1] = j * f + m, c[5] = g * i, c[9] = k * f - l, c[2] = l * f - k, c[6] = d * i, c[10] = m * f + j);
return c[3] = 0,
c[7] = 0,
c[11] = 0,
c[12] = 0,
c[13] = 0,
c[14] = 0,
c[15] = 1,
this
},
setRotationFromQuaternion: function(a) {
return console.warn("DEPRECATED: Matrix4's .setRotationFromQuaternion() has been deprecated in favor of makeRotationFromQuaternion. Please update your code."),
this.makeRotationFromQuaternion(a)
},
makeRotationFromQuaternion: function(a) {
var b = this.elements,
c = a.x,
d = a.y,
e = a.z,
f = a.w,
g = c + c,
h = d + d,
i = e + e,
a = c * g,
j = c * h,
c = c * i,
k = d * h,
d = d * i,
e = e * i,
g = f * g,
h = f * h,
f = f * i;
return b[0] = 1 - (k + e),
b[4] = j - f,
b[8] = c + h,
b[1] = j + f,
b[5] = 1 - (a + e),
b[9] = d - g,
b[2] = c - h,
b[6] = d + g,
b[10] = 1 - (a + k),
b[3] = 0,
b[7] = 0,
b[11] = 0,
b[12] = 0,
b[13] = 0,
b[14] = 0,
b[15] = 1,
this
},
lookAt: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3,
c = new THREE.Vector3;
return function(d, e, f) {
var g = this.elements;
return c.subVectors(d, e).normalize(),
0 === c.length() && (c.z = 1),
a.crossVectors(f, c).normalize(),
0 === a.length() && (c.x += 1e - 4, a.crossVectors(f, c).normalize()),
b.crossVectors(c, a),
g[0] = a.x,
g[4] = b.x,
g[8] = c.x,
g[1] = a.y,
g[5] = b.y,
g[9] = c.y,
g[2] = a.z,
g[6] = b.z,
g[10] = c.z,
this
}
} (),
multiply: function(a, b) {
return void 0 !== b ? (console.warn("DEPRECATED: Matrix4's .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), this.multiplyMatrices(a, b)) : this.multiplyMatrices(this, a)
},
multiplyMatrices: function(a, b) {
var c = a.elements,
d = b.elements,
e = this.elements,
f = c[0],
g = c[4],
h = c[8],
i = c[12],
j = c[1],
k = c[5],
l = c[9],
m = c[13],
n = c[2],
o = c[6],
p = c[10],
q = c[14],
r = c[3],
s = c[7],
t = c[11],
c = c[15],
u = d[0],
v = d[4],
w = d[8],
x = d[12],
y = d[1],
z = d[5],
A = d[9],
B = d[13],
C = d[2],
D = d[6],
E = d[10],
F = d[14],
G = d[3],
H = d[7],
I = d[11],
d = d[15];
return e[0] = f * u + g * y + h * C + i * G,
e[4] = f * v + g * z + h * D + i * H,
e[8] = f * w + g * A + h * E + i * I,
e[12] = f * x + g * B + h * F + i * d,
e[1] = j * u + k * y + l * C + m * G,
e[5] = j * v + k * z + l * D + m * H,
e[9] = j * w + k * A + l * E + m * I,
e[13] = j * x + k * B + l * F + m * d,
e[2] = n * u + o * y + p * C + q * G,
e[6] = n * v + o * z + p * D + q * H,
e[10] = n * w + o * A + p * E + q * I,
e[14] = n * x + o * B + p * F + q * d,
e[3] = r * u + s * y + t * C + c * G,
e[7] = r * v + s * z + t * D + c * H,
e[11] = r * w + s * A + t * E + c * I,
e[15] = r * x + s * B + t * F + c * d,
this
},
multiplyToArray: function(a, b, c) {
var d = this.elements;
return this.multiplyMatrices(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],
this
},
multiplyScalar: function(a) {
var b = this.elements;
return b[0] *= a,
b[4] *= a,
b[8] *= a,
b[12] *= a,
b[1] *= a,
b[5] *= a,
b[9] *= a,
b[13] *= a,
b[2] *= a,
b[6] *= a,
b[10] *= a,
b[14] *= a,
b[3] *= a,
b[7] *= a,
b[11] *= a,
b[15] *= a,
this
},
multiplyVector3: function(a) {
return console.warn("DEPRECATED: Matrix4's .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."),
a.applyProjection(this)
},
multiplyVector4: function(a) {
return console.warn("DEPRECATED: Matrix4's .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),
a.applyMatrix4(this)
},
multiplyVector3Array: function() {
var a = new THREE.Vector3;
return function(b) {
for (var c = 0, d = b.length; d > c; c += 3)
a.x = b[c],
a.y = b[c + 1],
a.z = b[c + 2],
a.applyProjection(this),
b[c] = a.x,
b[c + 1] = a.y,
b[c + 2] = a.z;
return b
}
} (),
rotateAxis: function(a) {
console.warn("DEPRECATED: Matrix4's .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),
a.transformDirection(this)
},
crossVector: function(a) {
return console.warn("DEPRECATED: Matrix4's .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),
a.applyMatrix4(this)
},
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],
i = a[13],
j = a[2],
k = a[6],
l = a[10],
m = a[14];
return a[3] * ( + e * h * k - d * i * k - e * g * l + c * i * l + d * g * m - c * h * m) + a[7] * ( + b * h * m - b * i * l + e * f * l - d * f * m + d * i * j - e * h * j) + a[11] * ( + b * i * k - b * g * m - e * f * k + c * f * m + e * g * j - c * i * j) + a[15] * ( - d * g * j - b * h * k + b * g * l + d * f * k - c * f * l + c * h * j)
},
transpose: function() {
var a,
b = this.elements;
return a = b[1],
b[1] = b[4],
b[4] = a,
a = b[2],
b[2] = b[8],
b[8] = a,
a = b[6],
b[6] = b[9],
b[9] = a,
a = b[3],
b[3] = b[12],
b[12] = a,
a = b[7],
b[7] = b[13],
b[13] = a,
a = b[11],
b[11] = b[14],
b[14] = a,
this
},
flattenToArray: function(a) {
var b = this.elements;
return 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],
a
},
flattenToArrayOffset: function(a, b) {
var c = this.elements;
return 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],
a
},
getPosition: function() {
var a = new THREE.Vector3;
return function() {
console.warn("DEPRECATED: Matrix4's .getPosition() has been removed. Use Vector3.getPositionFromMatrix( matrix ) instead.");
var b = this.elements;
return a.set(b[12], b[13], b[14])
}
} (),
setPosition: function(a) {
var b = this.elements;
return b[12] = a.x,
b[13] = a.y,
b[14] = a.z,
this
},
getInverse: function(a, b) {
var c = this.elements,
d = a.elements,
e = d[0],
f = d[4],
g = d[8],
h = d[12],
i = d[1],
j = d[5],
k = d[9],
l = d[13],
m = d[2],
n = d[6],
o = d[10],
p = d[14],
q = d[3],
r = d[7],
s = d[11],
t = d[15];
if (c[0] = k * p * r - l * o * r + l * n * s - j * p * s - k * n * t + j * o * t, c[4] = h * o * r - g * p * r - h * n * s + f * p * s + g * n * t - f * o * t, c[8] = g * l * r - h * k * r + h * j * s - f * l * s - g * j * t + f * k * t, c[12] = h * k * n - g * l * n - h * j * o + f * l * o + g * j * p - f * k * p, c[1] = l * o * q - k * p * q - l * m * s + i * p * s + k * m * t - i * o * t, c[5] = g * p * q - h * o * q + h * m * s - e * p * s - g * m * t + e * o * t, c[9] = h * k * q - g * l * q - h * i * s + e * l * s + g * i * t - e * k * t, c[13] = g * l * m - h * k * m + h * i * o - e * l * o - g * i * p + e * k * p, c[2] = j * p * q - l * n * q + l * m * r - i * p * r - j * m * t + i * n * t, c[6] = h * n * q - f * p * q - h * m * r + e * p * r + f * m * t - e * n * t, c[10] = f * l * q - h * j * q + h * i * r - e * l * r - f * i * t + e * j * t, c[14] = h * j * m - f * l * m - h * i * n + e * l * n + f * i * p - e * j * p, c[3] = k * n * q - j * o * q - k * m * r + i * o * r + j * m * s - i * n * s, c[7] = f * o * q - g * n * q + g * m * r - e * o * r - f * m * s + e * n * s, c[11] = g * j * q - f * k * q - g * i * r + e * k * r + f * i * s - e * j * s, c[15] = f * k * m - g * j * m + g * i * n - e * k * n - f * i * o + e * j * o, c = d[0] * c[0] + d[1] * c[4] + d[2] * c[8] + d[3] * c[12], 0 == c) {
if (b)
throw Error("Matrix4.getInverse(): can't invert matrix, determinant is 0");
return console.warn("Matrix4.getInverse(): can't invert matrix, determinant is 0"),
this.identity(),
this
}
return this.multiplyScalar(1 / c),
this
},
translate: function() {
console.warn("DEPRECATED: Matrix4's .translate() has been removed.")
},
rotateX: function() {
console.warn("DEPRECATED: Matrix4's .rotateX() has been removed.")
},
rotateY: function() {
console.warn("DEPRECATED: Matrix4's .rotateY() has been removed.")
},
rotateZ: function() {
console.warn("DEPRECATED: Matrix4's .rotateZ() has been removed.")
},
rotateByAxis: function() {
console.warn("DEPRECATED: Matrix4's .rotateByAxis() has been removed.")
},
scale: function(a) {
var b = this.elements,
c = a.x,
d = a.y,
a = a.z;
return b[0] *= c,
b[4] *= d,
b[8] *= a,
b[1] *= c,
b[5] *= d,
b[9] *= a,
b[2] *= c,
b[6] *= d,
b[10] *= a,
b[3] *= c,
b[7] *= d,
b[11] *= a,
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) {
return this.set(1, 0, 0, a, 0, 1, 0, b, 0, 0, 1, c, 0, 0, 0, 1),
this
},
makeRotationX: function(a) {
var b = Math.cos(a),
a = Math.sin(a);
return this.set(1, 0, 0, 0, 0, b, -a, 0, 0, a, b, 0, 0, 0, 0, 1),
this
},
makeRotationY: function(a) {
var b = Math.cos(a),
a = Math.sin(a);
return this.set(b, 0, a, 0, 0, 1, 0, 0, -a, 0, b, 0, 0, 0, 0, 1),
this
},
makeRotationZ: function(a) {
var b = Math.cos(a),
a = Math.sin(a);
return this.set(b, -a, 0, 0, a, b, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1),
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,
i = e * f,
j = e * g;
return this.set(i * f + c, i * g - d * h, i * h + d * g, 0, i * g + d * h, j * g + c, j * h - d * f, 0, i * h - d * g, j * h + d * f, e * h * h + c, 0, 0, 0, 0, 1),
this
},
makeScale: function(a, b, c) {
return this.set(a, 0, 0, 0, 0, b, 0, 0, 0, 0, c, 0, 0, 0, 0, 1),
this
},
compose: function(a, b, c) {
return console.warn("DEPRECATED: Matrix4's .compose() has been deprecated in favor of makeFromPositionQuaternionScale. Please update your code."),
this.makeFromPositionQuaternionScale(a, b, c)
},
makeFromPositionQuaternionScale: function(a, b, c) {
return this.makeRotationFromQuaternion(b),
this.scale(c),
this.setPosition(a),
this
},
makeFromPositionEulerScale: function(a, b, c, d) {
return this.makeRotationFromEuler(b, c),
this.scale(d),
this.setPosition(a),
this
},
makeFrustum: function(a, b, c, d, e, f) {
var g = this.elements;
return 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,
this
},
makePerspective: function(a, b, c, d) {
var a = c * Math.tan(THREE.Math.degToRad(.5 * a)),
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,
i = c - d,
j = f - e;
return g[0] = 2 / h,
g[4] = 0,
g[8] = 0,
g[12] = -((b + a) / h),
g[1] = 0,
g[5] = 2 / i,
g[9] = 0,
g[13] = -((c + d) / i),
g[2] = 0,
g[6] = 0,
g[10] = -2 / j,
g[14] = -((f + e) / j),
g[3] = 0,
g[7] = 0,
g[11] = 0,
g[15] = 1,
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.extend(THREE.Matrix4.prototype, {
decompose: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3,
c = new THREE.Vector3,
d = new THREE.Matrix4;
return function(e, f, g) {
var h = this.elements;
return a.set(h[0], h[1], h[2]),
b.set(h[4], h[5], h[6]),
c.set(h[8], h[9], h[10]),
e = e instanceof THREE.Vector3 ? e: new THREE.Vector3,
f = f instanceof THREE.Quaternion ? f: new THREE.Quaternion,
g = g instanceof THREE.Vector3 ? g: new THREE.Vector3,
g.x = a.length(),
g.y = b.length(),
g.z = c.length(),
e.x = h[12],
e.y = h[13],
e.z = h[14],
d.copy(this),
d.elements[0] /= g.x,
d.elements[1] /= g.x,
d.elements[2] /= g.x,
d.elements[4] /= g.y,
d.elements[5] /= g.y,
d.elements[6] /= g.y,
d.elements[8] /= g.z,
d.elements[9] /= g.z,
d.elements[10] /= g.z,
f.setFromRotationMatrix(d),
[e, f, g]
}
} ()
}),
THREE.Ray = function(a, b) {
this.origin = void 0 !== a ? a: new THREE.Vector3,
this.direction = void 0 !== b ? b: new THREE.Vector3
},
THREE.Ray.prototype = {
constructor: THREE.Ray,
set: function(a, b) {
return this.origin.copy(a),
this.direction.copy(b),
this
},
copy: function(a) {
return this.origin.copy(a.origin),
this.direction.copy(a.direction),
this
},
at: function(a, b) {
return (b || new THREE.Vector3).copy(this.direction).multiplyScalar(a).add(this.origin)
},
recast: function() {
var a = new THREE.Vector3;
return function(b) {
return this.origin.copy(this.at(b, a)),
this
}
} (),
closestPointToPoint: function(a, b) {
var c = b || new THREE.Vector3;
c.subVectors(a, this.origin);
var d = c.dot(this.direction);
return c.copy(this.direction).multiplyScalar(d).add(this.origin)
},
distanceToPoint: function() {
var a = new THREE.Vector3;
return function(b) {
var c = a.subVectors(b, this.origin).dot(this.direction);
return a.copy(this.direction).multiplyScalar(c).add(this.origin),
a.distanceTo(b)
}
} (),
isIntersectionSphere: function(a) {
return this.distanceToPoint(a.center) <= a.radius
},
isIntersectionPlane: function(a) {
return 0 != a.normal.dot(this.direction) || 0 == a.distanceToPoint(this.origin) ? !0: !1
},
distanceToPlane: function(a) {
var b = a.normal.dot(this.direction);
return 0 != b ? -(this.origin.dot(a.normal) + a.constant) / b: 0 == a.distanceToPoint(this.origin) ? 0: void 0
},
intersectPlane: function(a, b) {
var c = this.distanceToPlane(a);
return void 0 === c ? void 0: this.at(c, b)
},
applyMatrix4: function(a) {
return this.direction.add(this.origin).applyMatrix4(a),
this.origin.applyMatrix4(a),
this.direction.sub(this.origin),
this
},
equals: function(a) {
return a.origin.equals(this.origin) && a.direction.equals(this.direction)
},
clone: function() {
return (new THREE.Ray).copy(this)
}
},
THREE.Sphere = function(a, b) {
this.center = void 0 !== a ? a: new THREE.Vector3,
this.radius = void 0 !== b ? b: 0
},
THREE.Sphere.prototype = {
constructor: THREE.Sphere,
set: function(a, b) {
return this.center.copy(a),
this.radius = b,
this
},
setFromCenterAndPoints: function(a, b) {
for (var c = 0, d = 0, e = b.length; e > d; d++)
var f = a.distanceToSquared(b[d]),
c = Math.max(c, f);
return this.center = a,
this.radius = Math.sqrt(c),
this
},
copy: function(a) {
return this.center.copy(a.center),
this.radius = a.radius,
this
},
empty: function() {
return 0 >= this.radius
},
containsPoint: function(a) {
return a.distanceToSquared(this.center) <= this.radius * this.radius
},
distanceToPoint: function(a) {
return a.distanceTo(this.center) - this.radius
},
intersectsSphere: function(a) {
var b = this.radius + a.radius;
return a.center.distanceToSquared(this.center) <= b * b
},
clampPoint: function(a, b) {
var c = this.center.distanceToSquared(a),
d = b || new THREE.Vector3;
return d.copy(a),
c > this.radius * this.radius && (d.sub(this.center).normalize(), d.multiplyScalar(this.radius).add(this.center)),
d
},
getBoundingBox: function(a) {
return a = a || new THREE.Box3,
a.set(this.center, this.center),
a.expandByScalar(this.radius),
a
},
applyMatrix4: function(a) {
return this.center.applyMatrix4(a),
this.radius *= a.getMaxScaleOnAxis(),
this
},
translate: function(a) {
return this.center.add(a),
this
},
equals: function(a) {
return a.center.equals(this.center) && a.radius === this.radius
},
clone: function() {
return (new THREE.Sphere).copy(this)
}
},
THREE.Frustum = function(a, b, c, d, e, f) {
this.planes = [void 0 !== a ? a: new THREE.Plane, void 0 !== b ? b: new THREE.Plane, void 0 !== c ? c: new THREE.Plane, void 0 !== d ? d: new THREE.Plane, void 0 !== e ? e: new THREE.Plane, void 0 !== f ? f: new THREE.Plane]
},
THREE.Frustum.prototype = {
constructor: THREE.Frustum,
set: function(a, b, c, d, e, f) {
var g = this.planes;
return g[0].copy(a),
g[1].copy(b),
g[2].copy(c),
g[3].copy(d),
g[4].copy(e),
g[5].copy(f),
this
},
copy: function(a) {
for (var b = this.planes, c = 0; 6 > c; c++)
b[c].copy(a.planes[c]);
return this
},
setFromMatrix: function(a) {
var b = this.planes,
c = a.elements,
a = c[0],
d = c[1],
e = c[2],
f = c[3],
g = c[4],
h = c[5],
i = c[6],
j = c[7],
k = c[8],
l = c[9],
m = c[10],
n = c[11],
o = c[12],
p = c[13],
q = c[14],
c = c[15];
return b[0].setComponents(f - a, j - g, n - k, c - o).normalize(),
b[1].setComponents(f + a, j + g, n + k, c + o).normalize(),
b[2].setComponents(f + d, j + h, n + l, c + p).normalize(),
b[3].setComponents(f - d, j - h, n - l, c - p).normalize(),
b[4].setComponents(f - e, j - i, n - m, c - q).normalize(),
b[5].setComponents(f + e, j + i, n + m, c + q).normalize(),
this
},
intersectsObject: function() {
var a = new THREE.Vector3;
return function(b) {
var c = b.matrixWorld,
d = this.planes,
b = -b.geometry.boundingSphere.radius * c.getMaxScaleOnAxis();
for (a.getPositionFromMatrix(c), c = 0; 6 > c; c++)
if (d[c].distanceToPoint(a) < b)
return ! 1;
return ! 0
}
} (),
intersectsSphere: function(a) {
for (var b = this.planes, c = a.center, a = -a.radius, d = 0; 6 > d; d++)
if (b[d].distanceToPoint(c) < a)
return ! 1;
return ! 0
},
containsPoint: function(a) {
for (var b = this.planes, c = 0; 6 > c; c++)
if (0 > b[c].distanceToPoint(a))
return ! 1;
return ! 0
},
clone: function() {
return (new THREE.Frustum).copy(this)
}
},
THREE.Plane = function(a, b) {
this.normal = void 0 !== a ? a: new THREE.Vector3(1, 0, 0),
this.constant = void 0 !== b ? b: 0
},
THREE.Plane.prototype = {
constructor: THREE.Plane,
set: function(a, b) {
return this.normal.copy(a),
this.constant = b,
this
},
setComponents: function(a, b, c, d) {
return this.normal.set(a, b, c),
this.constant = d,
this
},
setFromNormalAndCoplanarPoint: function(a, b) {
return this.normal.copy(a),
this.constant = -b.dot(this.normal),
this
},
setFromCoplanarPoints: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function(c, d, e) {
return d = a.subVectors(e, d).cross(b.subVectors(c, d)).normalize(),
this.setFromNormalAndCoplanarPoint(d, c),
this
}
} (),
copy: function(a) {
return this.normal.copy(a.normal),
this.constant = a.constant,
this
},
normalize: function() {
var a = 1 / this.normal.length();
return this.normal.multiplyScalar(a),
this.constant *= a,
this
},
negate: function() {
return this.constant *= -1,
this.normal.negate(),
this
},
distanceToPoint: function(a) {
return this.normal.dot(a) + this.constant
},
distanceToSphere: function(a) {
return this.distanceToPoint(a.center) - a.radius
},
projectPoint: function(a, b) {
return this.orthoPoint(a, b).sub(a).negate()
},
orthoPoint: function(a, b) {
var c = this.distanceToPoint(a);
return (b || new THREE.Vector3).copy(this.normal).multiplyScalar(c)
},
isIntersectionLine: function(a) {
var b = this.distanceToPoint(a.start),
a = this.distanceToPoint(a.end);
return 0 > b && a > 0 || 0 > a && b > 0
},
intersectLine: function() {
var a = new THREE.Vector3;
return function(b, c) {
var d = c || new THREE.Vector3,
e = b.delta(a),
f = this.normal.dot(e);
return 0 != f ? (f = -(b.start.dot(this.normal) + this.constant) / f, 0 > f || f > 1 ? void 0: d.copy(e).multiplyScalar(f).add(b.start)) : 0 == this.distanceToPoint(b.start) ? d.copy(b.start) : void 0
}
} (),
coplanarPoint: function(a) {
return (a || new THREE.Vector3).copy(this.normal).multiplyScalar( - this.constant)
},
applyMatrix4: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function(c, d) {
var d = d || (new THREE.Matrix3).getNormalMatrix(c),
e = a.copy(this.normal).applyMatrix3(d),
f = this.coplanarPoint(b);
return f.applyMatrix4(c),
this.setFromNormalAndCoplanarPoint(e, f),
this
}
} (),
translate: function(a) {
return this.constant -= a.dot(this.normal),
this
},
equals: function(a) {
return a.normal.equals(this.normal) && a.constant == this.constant
},
clone: function() {
return (new THREE.Plane).copy(this)
}
},
THREE.Math = {
clamp: function(a, b, c) {
return b > a ? b: a > c ? c: a
},
clampBottom: function(a, b) {
return b > a ? b: a
},
mapLinear: function(a, b, c, d, e) {
return d + (a - b) * (e - d) / (c - b)
},
smoothstep: function(a, b, c) {
return b >= a ? 0: a >= c ? 1: (a = (a - b) / (c - b), a * a * (3 - 2 * a))
},
smootherstep: function(a, b, c) {
return b >= a ? 0: a >= c ? 1: (a = (a - b) / (c - b), a * a * a * (a * (6 * a - 15) + 10))
},
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 * (.5 - Math.random())
},
sign: function(a) {
return 0 > a ? -1: a > 0 ? 1: 0
},
degToRad: function() {
var a = Math.PI / 180;
return function(b) {
return b * a
}
} (),
radToDeg: function() {
var a = 180 / Math.PI;
return function(b) {
return b * a
}
} ()
},
THREE.Spline = function(a) {
function b(a, b, c, d, e, f, g) {
return a = .5 * (c - a),
d = .5 * (d - b),
(2 * (b - c) + a + d) * g + ( - 3 * (b - c) - 2 * a - d) * f + a * e + b
}
this.points = a;
var c,
d,
e,
f,
g,
h,
i,
j,
k,
l = [],
m = {
x: 0,
y: 0,
z: 0
};
this.initFromArray = function(a) {
this.points = [];
for (var b = 0; b < a.length; b++)
this.points[b] = {
x: a[b][0],
y: a[b][1],
z: a[b][2]
}
},
this.getPoint = function(a) {
return c = (this.points.length - 1) * a,
d = Math.floor(c),
e = c - d,
l[0] = 0 === d ? d: d - 1,
l[1] = d,
l[2] = d > this.points.length - 2 ? this.points.length - 1: d + 1,
l[3] = d > this.points.length - 3 ? this.points.length - 1: d + 2,
h = this.points[l[0]],
i = this.points[l[1]],
j = this.points[l[2]],
k = this.points[l[3]],
f = e * e,
g = e * f,
m.x = b(h.x, i.x, j.x, k.x, e, f, g),
m.y = b(h.y, i.y, j.y, k.y, e, f, g),
m.z = b(h.z, i.z, j.z, k.z, e, f, g),
m
},
this.getControlPointsArray = function() {
var a,
b,
c = this.points.length,
d = [];
for (a = 0; c > a; a++)
b = this.points[a],
d[a] = [b.x, b.y, b.z];
return d
},
this.getLength = function(a) {
var b,
c,
d,
e = b = b = 0,
f = new THREE.Vector3,
g = new THREE.Vector3,
h = [],
i = 0;
for (h[0] = 0, a || (a = 100), c = this.points.length * a, f.copy(this.points[0]), a = 1; c > a; a++)
b = a / c,
d = this.getPoint(b),
g.copy(d),
i += g.distanceTo(f),
f.copy(d),
b *= this.points.length - 1,
b = Math.floor(b),
b != e && (h[b] = i, e = b);
return h[h.length] = i,
{
chunks: h,
total: i
}
},
this.reparametrizeByArcLength = function(a) {
var b,
c,
d,
e,
f,
g,
h = [],
i = new THREE.Vector3,
j = this.getLength();
for (h.push(i.copy(this.points[0]).clone()), b = 1; b < this.points.length; b++) {
for (c = j.chunks[b] - j.chunks[b - 1], g = Math.ceil(a * c / j.total), e = (b - 1) / (this.points.length - 1), f = b / (this.points.length - 1), c = 1; g - 1 > c; c++)
d = e + c * (1 / g) * (f - e),
d = this.getPoint(d),
h.push(i.copy(d).clone());
h.push(i.copy(this.points[b]).clone())
}
this.points = h
}
},
THREE.Triangle = function(a, b, c) {
this.a = void 0 !== a ? a: new THREE.Vector3,
this.b = void 0 !== b ? b: new THREE.Vector3,
this.c = void 0 !== c ? c: new THREE.Vector3
},
THREE.Triangle.normal = function() {
var a = new THREE.Vector3;
return function(b, c, d, e) {
return e = e || new THREE.Vector3,
e.subVectors(d, c),
a.subVectors(b, c),
e.cross(a),
b = e.lengthSq(),
b > 0 ? e.multiplyScalar(1 / Math.sqrt(b)) : e.set(0, 0, 0)
}
} (),
THREE.Triangle.barycoordFromPoint = function() {
var a = new THREE.Vector3,
b = new THREE.Vector3,
c = new THREE.Vector3;
return function(d, e, f, g, h) {
a.subVectors(g, e),
b.subVectors(f, e),
c.subVectors(d, e);
var d = a.dot(a),
e = a.dot(b),
f = a.dot(c),
i = b.dot(b),
g = b.dot(c),
j = d * i - e * e,
h = h || new THREE.Vector3;
return 0 == j ? h.set( - 2, -1, -1) : (j = 1 / j, i = (i * f - e * g) * j, d = (d * g - e * f) * j, h.set(1 - i - d, d, i))
}
} (),
THREE.Triangle.containsPoint = function() {
var a = new THREE.Vector3;
return function(b, c, d, e) {
return b = THREE.Triangle.barycoordFromPoint(b, c, d, e, a),
0 <= b.x && 0 <= b.y && 1 >= b.x + b.y
}
} (),
THREE.Triangle.prototype = {
constructor: THREE.Triangle,
set: function(a, b, c) {
return this.a.copy(a),
this.b.copy(b),
this.c.copy(c),
this
},
setFromPointsAndIndices: function(a, b, c, d) {
return this.a.copy(a[b]),
this.b.copy(a[c]),
this.c.copy(a[d]),
this
},
copy: function(a) {
return this.a.copy(a.a),
this.b.copy(a.b),
this.c.copy(a.c),
this
},
area: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function() {
return a.subVectors(this.c, this.b),
b.subVectors(this.a, this.b),
.5 * a.cross(b).length()
}
} (),
midpoint: function(a) {
return (a || new THREE.Vector3).addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3)
},
normal: function(a) {
return THREE.Triangle.normal(this.a, this.b, this.c, a)
},
plane: function(a) {
return (a || new THREE.Plane).setFromCoplanarPoints(this.a, this.b, this.c)
},
barycoordFromPoint: function(a, b) {
return THREE.Triangle.barycoordFromPoint(a, this.a, this.b, this.c, b)
},
containsPoint: function(a) {
return THREE.Triangle.containsPoint(a, this.a, this.b, this.c)
},
equals: function(a) {
return a.a.equals(this.a) && a.b.equals(this.b) && a.c.equals(this.c)
},
clone: function() {
return (new THREE.Triangle).copy(this)
}
},
THREE.Vertex = function(a) {
return console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead."),
a
},
THREE.UV = function(a, b) {
return console.warn("THREE.UV has been DEPRECATED. Use THREE.Vector2 instead."),
new THREE.Vector2(a, b)
},
THREE.Clock = function(a) {
this.autoStart = void 0 !== a ? a: !0,
this.elapsedTime = this.oldTime = this.startTime = 0,
this.running = !1
},
THREE.Clock.prototype = {
constructor: THREE.Clock,
start: function() {
this.oldTime = this.startTime = void 0 !== window.performance && void 0 !== window.performance.now ? window.performance.now() : Date.now(),
this.running = !0
},
stop: function() {
this.getElapsedTime(),
this.running = !1
},
getElapsedTime: function() {
return this.getDelta(),
this.elapsedTime
},
getDelta: function() {
var a = 0;
if (this.autoStart && !this.running && this.start(), this.running) {
var b = void 0 !== window.performance && void 0 !== window.performance.now ? window.performance.now() : Date.now(),
a = .001 * (b - this.oldTime);
this.oldTime = b,
this.elapsedTime += a
}
return a
}
},
THREE.EventDispatcher = function() {},
THREE.EventDispatcher.prototype = {
constructor: THREE.EventDispatcher,
addEventListener: function(a, b) {
void 0 === this._listeners && (this._listeners = {});
var c = this._listeners;
void 0 === c[a] && (c[a] = []),
-1 === c[a].indexOf(b) && c[a].push(b)
},
hasEventListener: function(a, b) {
if (void 0 === this._listeners)
return ! 1;
var c = this._listeners;
return void 0 !== c[a] && -1 !== c[a].indexOf(b) ? !0: !1
},
removeEventListener: function(a, b) {
if (void 0 !== this._listeners) {
var c = this._listeners,
d = c[a].indexOf(b); - 1 !== d && c[a].splice(d, 1)
}
},
dispatchEvent: function(a) {
if (void 0 !== this._listeners) {
var b = this._listeners[a.type];
if (void 0 !== b) {
a.target = this;
for (var c = 0, d = b.length; d > c; c++)
b[c].call(this, a)
}
}
}
},
function(a) {
a.Raycaster = function(b, c, d, e) {
this.ray = new a.Ray(b, c),
0 < this.ray.direction.lengthSq() && this.ray.direction.normalize(),
this.near = d || 0,
this.far = e || 1 / 0
};
var b = new a.Sphere,
c = new a.Ray,
d = new a.Plane,
e = new a.Vector3,
f = new a.Vector3,
g = new a.Matrix4,
h = function(a, b) {
return a.distance - b.distance
},
i = function(h, j, k) {
if (h instanceof a.Particle) {
f.getPositionFromMatrix(h.matrixWorld);
var l = j.ray.distanceToPoint(f);
if (l > h.scale.x)
return k;
k.push({
distance: l,
point: h.position,
face: null,
object: h
})
} else if (h instanceof a.LOD)
f.getPositionFromMatrix(h.matrixWorld),
l = j.ray.origin.distanceTo(f),
i(h.getObjectForDistance(l), j, k);
else if (h instanceof a.Mesh) {
if (f.getPositionFromMatrix(h.matrixWorld), b.set(f, h.geometry.boundingSphere.radius * h.matrixWorld.getMaxScaleOnAxis()), !j.ray.isIntersectionSphere(b))
return k;
var m,
n,
o,
l = h.geometry,
p = l.vertices,
q = h.material instanceof a.MeshFaceMaterial,
r = !0 === q ? h.material.materials: null,
s = h.material.side,
t = j.precision;
g.getInverse(h.matrixWorld),
c.copy(j.ray).applyMatrix4(g);
for (var u = 0, v = l.faces.length; v > u; u++) {
var w = l.faces[u],
s = !0 === q ? r[w.materialIndex] : h.material;
if (void 0 !== s) {
d.setFromNormalAndCoplanarPoint(w.normal, p[w.a]);
var x = c.distanceToPlane(d);
if (! (Math.abs(x) < t || 0 > x)) {
if (s = s.side, s !== a.DoubleSide && (m = c.direction.dot(d.normal), !(s === a.FrontSide ? 0 > m: m > 0)))
continue;
if (! (x < j.near || x > j.far)) {
if (e = c.at(x, e), w instanceof a.Face3) {
if (s = p[w.a], m = p[w.b], n = p[w.c], !a.Triangle.containsPoint(e, s, m, n))
continue
} else {
if (! (w instanceof a.Face4))
throw Error("face type not supported");
if (s = p[w.a], m = p[w.b], n = p[w.c], o = p[w.d], !a.Triangle.containsPoint(e, s, m, o) && !a.Triangle.containsPoint(e, m, n, o))
continue
}
k.push({
distance: x,
point: j.ray.at(x),
face: w,
faceIndex: u,
object: h
})
}
}
}
}
}
},
j = function(a, b, c) {
for (var a = a.getDescendants(), d = 0, e = a.length; e > d; d++)
i(a[d], b, c)
};
a.Raycaster.prototype.precision = 1e - 4,
a.Raycaster.prototype.set = function(a, b) {
this.ray.set(a, b),
0 < this.ray.direction.length() && this.ray.direction.normalize()
},
a.Raycaster.prototype.intersectObject = function(a, b) {
var c = [];
return ! 0 === b && j(a, this, c),
i(a, this, c),
c.sort(h),
c
},
a.Raycaster.prototype.intersectObjects = function(a, b) {
for (var c = [], d = 0, e = a.length; e > d; d++)
i(a[d], this, c),
!0 === b && j(a[d], this, c);
return c.sort(h),
c
}
} (THREE),
THREE.Object3D = function() {
this.id = THREE.Object3DIdCount++,
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 = THREE.Object3D.defaultEulerOrder,
this.scale = new THREE.Vector3(1, 1, 1),
this.renderDepth = null,
this.rotationAutoUpdate = !0,
this.matrix = new THREE.Matrix4,
this.matrixWorld = new THREE.Matrix4,
this.matrixWorldNeedsUpdate = this.matrixAutoUpdate = !0,
this.quaternion = new THREE.Quaternion,
this.useQuaternion = !1,
this.visible = !0,
this.receiveShadow = this.castShadow = !1,
this.frustumCulled = !0,
this.userData = {}
},
THREE.Object3D.prototype = {
constructor: THREE.Object3D,
applyMatrix: function() {
var a = new THREE.Matrix4;
return function(b) {
this.matrix.multiplyMatrices(b, this.matrix),
this.position.getPositionFromMatrix(this.matrix),
this.scale.getScaleFromMatrix(this.matrix),
a.extractRotation(this.matrix),
!0 === this.useQuaternion ? this.quaternion.setFromRotationMatrix(a) : this.rotation.setEulerFromRotationMatrix(a, this.eulerOrder)
}
} (),
rotateOnAxis: function() {
var a = new THREE.Quaternion,
b = new THREE.Quaternion;
return function(c, d) {
return a.setFromAxisAngle(c, d),
!0 === this.useQuaternion ? this.quaternion.multiply(a) : (b.setFromEuler(this.rotation, this.eulerOrder), b.multiply(a), this.rotation.setEulerFromQuaternion(b, this.eulerOrder)),
this
}
} (),
translateOnAxis: function() {
var a = new THREE.Vector3;
return function(b, c) {
return a.copy(b),
!0 === this.useQuaternion ? a.applyQuaternion(this.quaternion) : a.applyEuler(this.rotation, this.eulerOrder),
this.position.add(a.multiplyScalar(c)),
this
}
} (),
translate: function(a, b) {
return console.warn("DEPRECATED: Object3D's .translate() has been removed. Use .translateOnAxis( axis, distance ) instead. Note args have been changed."),
this.translateOnAxis(b, a)
},
translateX: function() {
var a = new THREE.Vector3(1, 0, 0);
return function(b) {
return this.translateOnAxis(a, b)
}
} (),
translateY: function() {
var a = new THREE.Vector3(0, 1, 0);
return function(b) {
return this.translateOnAxis(a, b)
}
} (),
translateZ: function() {
var a = new THREE.Vector3(0, 0, 1);
return function(b) {
return this.translateOnAxis(a, b)
}
} (),
localToWorld: function(a) {
return a.applyMatrix4(this.matrixWorld)
},
worldToLocal: function() {
var a = new THREE.Matrix4;
return function(b) {
return b.applyMatrix4(a.getInverse(this.matrixWorld))
}
} (),
lookAt: function() {
var a = new THREE.Matrix4;
return function(b) {
a.lookAt(b, this.position, this.up),
!0 === this.useQuaternion ? this.quaternion.setFromRotationMatrix(a) : this.rotation.setEulerFromRotationMatrix(a, this.eulerOrder)
}
} (),
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) {
void 0 !== a.parent && a.parent.remove(a),
a.parent = this,
this.children.push(a);
for (var b = this; void 0 !== b.parent;)
b = b.parent;
void 0 !== b && b instanceof THREE.Scene && b.__addObject(a)
}
},
remove: function(a) {
var b = this.children.indexOf(a);
if ( - 1 !== b) {
for (a.parent = void 0, this.children.splice(b, 1), b = this; void 0 !== b.parent;)
b = b.parent;
void 0 !== b && b instanceof THREE.Scene && b.__removeObject(a)
}
},
traverse: function(a) {
a(this);
for (var b = 0, c = this.children.length; c > b; b++)
this.children[b].traverse(a)
},
getObjectById: function(a, b) {
for (var c = 0, d = this.children.length; d > c; c++) {
var e = this.children[c];
if (e.id === a || !0 === b && (e = e.getObjectById(a, b), void 0 !== e))
return e
}
},
getObjectByName: function(a, b) {
for (var c = 0, d = this.children.length; d > c; c++) {
var e = this.children[c];
if (e.name === a || !0 === b && (e = e.getObjectByName(a, b), void 0 !== e))
return e
}
},
getChildByName: function(a, b) {
return console.warn("DEPRECATED: Object3D's .getChildByName() has been renamed to .getObjectByName()."),
this.getObjectByName(a, b)
},
getDescendants: function(a) {
void 0 === a && (a = []),
Array.prototype.push.apply(a, this.children);
for (var b = 0, c = this.children.length; c > b; b++)
this.children[b].getDescendants(a);
return a
},
updateMatrix: function() { ! 1 === this.useQuaternion ? this.matrix.makeFromPositionEulerScale(this.position, this.rotation, this.eulerOrder, this.scale) : this.matrix.makeFromPositionQuaternionScale(this.position, this.quaternion, this.scale),
this.matrixWorldNeedsUpdate = !0
},
updateMatrixWorld: function(a) { ! 0 === this.matrixAutoUpdate && this.updateMatrix(),
(!0 === this.matrixWorldNeedsUpdate || !0 === a) && (void 0 === this.parent ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, a = !0);
for (var b = 0, c = this.children.length; c > b; b++)
this.children[b].updateMatrixWorld(a)
},
clone: function(a) {
void 0 === a && (a = new THREE.Object3D),
a.name = this.name,
a.up.copy(this.up),
a.position.copy(this.position),
a.rotation instanceof THREE.Vector3 && a.rotation.copy(this.rotation),
a.eulerOrder = this.eulerOrder,
a.scale.copy(this.scale),
a.renderDepth = this.renderDepth,
a.rotationAutoUpdate = this.rotationAutoUpdate,
a.matrix.copy(this.matrix),
a.matrixWorld.copy(this.matrixWorld),
a.matrixAutoUpdate = this.matrixAutoUpdate,
a.matrixWorldNeedsUpdate = this.matrixWorldNeedsUpdate,
a.quaternion.copy(this.quaternion),
a.useQuaternion = this.useQuaternion,
a.visible = this.visible,
a.castShadow = this.castShadow,
a.receiveShadow = this.receiveShadow,
a.frustumCulled = this.frustumCulled,
a.userData = JSON.parse(JSON.stringify(this.userData));
for (var b = 0; b < this.children.length; b++)
a.add(this.children[b].clone());
return a
}
},
THREE.Object3D.defaultEulerOrder = "XYZ",
THREE.Object3DIdCount = 0,
THREE.Projector = function() {
function a() {
if (f === r) {
var a = new THREE.RenderableObject;
return q.push(a),
r++,
f++,
a
}
return q[f++]
}
function b() {
if (h === t) {
var a = new THREE.RenderableVertex;
return s.push(a),
t++,
h++,
a
}
return s[h++]
}
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;
return e >= 0 && f >= 0 && g >= 0 && h >= 0 ? !0: 0 > e && 0 > f || 0 > g && 0 > h ? !1: (0 > e ? c = Math.max(c, e / (e - f)) : 0 > f && (d = Math.min(d, e / (e - f))), 0 > g ? c = Math.max(c, g / (g - h)) : 0 > h && (d = Math.min(d, g / (g - h))), c > d ? !1: (a.lerp(b, c), b.lerp(a, 1 - d), !0))
}
var e,
f,
g,
h,
i,
j,
k,
l,
m,
n,
o,
p,
q = [],
r = 0,
s = [],
t = 0,
u = [],
v = 0,
w = [],
x = 0,
y = [],
z = 0,
A = [],
B = 0,
C = {
objects: [],
sprites: [],
lights: [],
elements: []
},
D = new THREE.Vector3,
E = new THREE.Vector4,
F = new THREE.Box3(new THREE.Vector3( - 1, -1, -1), new THREE.Vector3(1, 1, 1)),
G = new THREE.Box3,
H = Array(3),
I = Array(4),
J = new THREE.Matrix4,
K = new THREE.Matrix4,
L = new THREE.Matrix4,
M = new THREE.Matrix3,
N = new THREE.Matrix3,
O = new THREE.Vector3,
P = new THREE.Frustum,
Q = new THREE.Vector4,
R = new THREE.Vector4;
this.projectVector = function(a, b) {
return b.matrixWorldInverse.getInverse(b.matrixWorld),
K.multiplyMatrices(b.projectionMatrix, b.matrixWorldInverse),
a.applyProjection(K)
},
this.unprojectVector = function(a, b) {
return b.projectionMatrixInverse.getInverse(b.projectionMatrix),
K.multiplyMatrices(b.matrixWorld, b.projectionMatrixInverse),
a.applyProjection(K)
},
this.pickingRay = function(a, b) {
a.z = -1;
var c = new THREE.Vector3(a.x, a.y, 1);
return this.unprojectVector(a, b),
this.unprojectVector(c, b),
c.sub(a).normalize(),
new THREE.Raycaster(a, c)
},
this.projectScene = function(q, r, t, S) {
var T,
U,
V,
W,
X,
Y,
Z,
$,
_,
ab,
bb,
cb,
db,
eb = !1;
o = m = k = j = 0,
C.elements.length = 0,
!0 === q.autoUpdate && q.updateMatrixWorld(),
void 0 === r.parent && r.updateMatrixWorld(),
J.copy(r.matrixWorldInverse.getInverse(r.matrixWorld)),
K.multiplyMatrices(r.projectionMatrix, J),
N.getNormalMatrix(J),
P.setFromMatrix(K),
f = 0,
C.objects.length = 0,
C.sprites.length = 0,
C.lights.length = 0;
var fb = function(b) {
for (var c = 0, d = b.children.length; d > c; c++) {
var f = b.children[c]; ! 1 !== f.visible && (f instanceof THREE.Light ? C.lights.push(f) : f instanceof THREE.Mesh || f instanceof THREE.Line ? (!1 === f.frustumCulled || !0 === P.intersectsObject(f)) && (e = a(), e.object = f, null !== f.renderDepth ? e.z = f.renderDepth: (D.getPositionFromMatrix(f.matrixWorld), D.applyProjection(K), e.z = D.z), C.objects.push(e)) : f instanceof THREE.Sprite || f instanceof THREE.Particle ? (e = a(), e.object = f, null !== f.renderDepth ? e.z = f.renderDepth: (D.getPositionFromMatrix(f.matrixWorld), D.applyProjection(K), e.z = D.z), C.sprites.push(e)) : (e = a(), e.object = f, null !== f.renderDepth ? e.z = f.renderDepth: (D.getPositionFromMatrix(f.matrixWorld), D.applyProjection(K), e.z = D.z), C.objects.push(e)), fb(f))
}
};
for (fb(q), !0 === t && C.objects.sort(c), q = 0, t = C.objects.length; t > q; q++)
if ($ = C.objects[q].object, p = $.matrixWorld, h = 0, $ instanceof THREE.Mesh) {
for (_ = $.geometry, V = _.vertices, ab = _.faces, _ = _.faceVertexUvs, M.getNormalMatrix(p), cb = $.material instanceof THREE.MeshFaceMaterial, db = !0 === cb ? $.material: null, T = 0, U = V.length; U > T; T++)
g = b(),
g.positionWorld.copy(V[T]).applyMatrix4(p),
g.positionScreen.copy(g.positionWorld).applyMatrix4(K),
g.positionScreen.x /= g.positionScreen.w,
g.positionScreen.y /= g.positionScreen.w,
g.positionScreen.z /= g.positionScreen.w,
g.visible = !( - 1 > g.positionScreen.x || 1 < g.positionScreen.x || -1 > g.positionScreen.y || 1 < g.positionScreen.y || -1 > g.positionScreen.z || 1 < g.positionScreen.z);
for (V = 0, T = ab.length; T > V; V++) {
U = ab[V];
var gb = !0 === cb ? db.materials[U.materialIndex] : $.material;
if (void 0 !== gb) {
if (Y = gb.side, U instanceof THREE.Face3) {
if (W = s[U.a], X = s[U.b], Z = s[U.c], H[0] = W.positionScreen, H[1] = X.positionScreen, H[2] = Z.positionScreen, !0 !== W.visible && !0 !== X.visible && !0 !== Z.visible && !F.isIntersectionBox(G.setFromPoints(H)))
continue;
if (eb = 0 > (Z.positionScreen.x - W.positionScreen.x) * (X.positionScreen.y - W.positionScreen.y) - (Z.positionScreen.y - W.positionScreen.y) * (X.positionScreen.x - W.positionScreen.x), Y !== THREE.DoubleSide && eb !== (Y === THREE.FrontSide))
continue;
j === v ? (bb = new THREE.RenderableFace3, u.push(bb), v++, j++, i = bb) : i = u[j++],
i.v1.copy(W),
i.v2.copy(X),
i.v3.copy(Z)
} else if (U instanceof THREE.Face4) {
if (W = s[U.a], X = s[U.b], Z = s[U.c], bb = s[U.d], I[0] = W.positionScreen, I[1] = X.positionScreen, I[2] = Z.positionScreen, I[3] = bb.positionScreen, !0 !== W.visible && !0 !== X.visible && !0 !== Z.visible && !0 !== bb.visible && !F.isIntersectionBox(G.setFromPoints(I)))
continue;
if (eb = 0 > (bb.positionScreen.x - W.positionScreen.x) * (X.positionScreen.y - W.positionScreen.y) - (bb.positionScreen.y - W.positionScreen.y) * (X.positionScreen.x - W.positionScreen.x) || 0 > (X.positionScreen.x - Z.positionScreen.x) * (bb.positionScreen.y - Z.positionScreen.y) - (X.positionScreen.y - Z.positionScreen.y) * (bb.positionScreen.x - Z.positionScreen.x), Y !== THREE.DoubleSide && eb !== (Y === THREE.FrontSide))
continue;
if (k === x) {
var hb = new THREE.RenderableFace4;
w.push(hb),
x++,
k++,
i = hb
} else
i = w[k++];
i.v1.copy(W),
i.v2.copy(X),
i.v3.copy(Z),
i.v4.copy(bb)
}
for (i.normalModel.copy(U.normal), !1 === eb && (Y === THREE.BackSide || Y === THREE.DoubleSide) && i.normalModel.negate(), i.normalModel.applyMatrix3(M).normalize(), i.normalModelView.copy(i.normalModel).applyMatrix3(N), i.centroidModel.copy(U.centroid).applyMatrix4(p), Z = U.vertexNormals, W = 0, X = Z.length; X > W; W++)
bb = i.vertexNormalsModel[W],
bb.copy(Z[W]),
!1 === eb && (Y === THREE.BackSide || Y === THREE.DoubleSide) && bb.negate(),
bb.applyMatrix3(M).normalize(),
i.vertexNormalsModelView[W].copy(bb).applyMatrix3(N);
for (i.vertexNormalsLength = Z.length, W = 0, X = _.length; X > W; W++)
if (bb = _[W][V], void 0 !== bb)
for (Y = 0, Z = bb.length; Z > Y; Y++)
i.uvs[W][Y] = bb[Y];
i.color = U.color,
i.material = gb,
O.copy(i.centroidModel).applyProjection(K),
i.z = O.z,
C.elements.push(i)
}
}
} else if ($ instanceof THREE.Line)
for (L.multiplyMatrices(K, p), V = $.geometry.vertices, W = b(), W.positionScreen.copy(V[0]).applyMatrix4(L), ab = $.type === THREE.LinePieces ? 2: 1, T = 1, U = V.length; U > T; T++)
W = b(),
W.positionScreen.copy(V[T]).applyMatrix4(L),
(T + 1) % ab > 0 || (X = s[h - 2], Q.copy(W.positionScreen), R.copy(X.positionScreen), !0 === d(Q, R) && (Q.multiplyScalar(1 / Q.w), R.multiplyScalar(1 / R.w), m === z ? (_ = new THREE.RenderableLine, y.push(_), z++, m++, l = _) : l = y[m++], l.v1.positionScreen.copy(Q), l.v2.positionScreen.copy(R), l.z = Math.max(Q.z, R.z), l.material = $.material, $.material.vertexColors === THREE.VertexColors && (l.vertexColors[0].copy($.geometry.colors[T]), l.vertexColors[1].copy($.geometry.colors[T - 1])), C.elements.push(l)));
for (q = 0, t = C.sprites.length; t > q; q++)
$ = C.sprites[q].object,
p = $.matrixWorld,
$ instanceof THREE.Particle && (E.set(p.elements[12], p.elements[13], p.elements[14], 1), E.applyMatrix4(K), E.z /= E.w, 0 < E.z && 1 > E.z && (o === B ? (eb = new THREE.RenderableParticle, A.push(eb), B++, o++, n = eb) : n = A[o++], n.object = $, n.x = E.x / E.w, n.y = E.y / E.w, n.z = E.z, n.rotation = $.rotation.z, n.scale.x = $.scale.x * Math.abs(n.x - (E.x + r.projectionMatrix.elements[0]) / (E.w + r.projectionMatrix.elements[12])), n.scale.y = $.scale.y * Math.abs(n.y - (E.y + r.projectionMatrix.elements[5]) / (E.w + r.projectionMatrix.elements[13])), n.material = $.material, C.elements.push(n)));
return ! 0 === S && C.elements.sort(c),
C
}
},
THREE.Face3 = function(a, b, c, d, e, f) {
this.a = a,
this.b = b,
this.c = c,
this.normal = d instanceof THREE.Vector3 ? d: new THREE.Vector3,
this.vertexNormals = d instanceof Array ? d: [],
this.color = e instanceof THREE.Color ? e: new THREE.Color,
this.vertexColors = e instanceof Array ? e: [],
this.vertexTangents = [],
this.materialIndex = void 0 !== f ? f: 0,
this.centroid = new THREE.Vector3
},
THREE.Face3.prototype = {
constructor: THREE.Face3,
clone: function() {
var a = new THREE.Face3(this.a, this.b, this.c);
a.normal.copy(this.normal),
a.color.copy(this.color),
a.centroid.copy(this.centroid),
a.materialIndex = this.materialIndex;
var b,
c;
for (b = 0, c = this.vertexNormals.length; c > b; b++)
a.vertexNormals[b] = this.vertexNormals[b].clone();
for (b = 0, c = this.vertexColors.length; c > b; b++)
a.vertexColors[b] = this.vertexColors[b].clone();
for (b = 0, c = this.vertexTangents.length; c > b; b++)
a.vertexTangents[b] = this.vertexTangents[b].clone();
return a
}
},
THREE.Face4 = function(a, b, c, d, e, f, g) {
this.a = a,
this.b = b,
this.c = c,
this.d = d,
this.normal = e instanceof THREE.Vector3 ? e: new THREE.Vector3,
this.vertexNormals = e instanceof Array ? e: [],
this.color = f instanceof THREE.Color ? f: new THREE.Color,
this.vertexColors = f instanceof Array ? f: [],
this.vertexTangents = [],
this.materialIndex = void 0 !== g ? g: 0,
this.centroid = new THREE.Vector3
},
THREE.Face4.prototype = {
constructor: THREE.Face4,
clone: function() {
var a = new THREE.Face4(this.a, this.b, this.c, this.d);
a.normal.copy(this.normal),
a.color.copy(this.color),
a.centroid.copy(this.centroid),
a.materialIndex = this.materialIndex;
var b,
c;
for (b = 0, c = this.vertexNormals.length; c > b; b++)
a.vertexNormals[b] = this.vertexNormals[b].clone();
for (b = 0, c = this.vertexColors.length; c > b; b++)
a.vertexColors[b] = this.vertexColors[b].clone();
for (b = 0, c = this.vertexTangents.length; c > b; b++)
a.vertexTangents[b] = this.vertexTangents[b].clone();
return a
}
},
THREE.Geometry = function() {
this.id = THREE.GeometryIdCount++,
this.name = "",
this.vertices = [],
this.colors = [],
this.normals = [],
this.faces = [],
this.faceUvs = [[]],
this.faceVertexUvs = [[]],
this.morphTargets = [],
this.morphColors = [],
this.morphNormals = [],
this.skinWeights = [],
this.skinIndices = [],
this.lineDistances = [],
this.boundingSphere = this.boundingBox = null,
this.hasTangents = !1,
this.dynamic = !0,
this.buffersNeedUpdate = this.lineDistancesNeedUpdate = this.colorsNeedUpdate = this.tangentsNeedUpdate = this.normalsNeedUpdate = this.uvsNeedUpdate = this.elementsNeedUpdate = this.verticesNeedUpdate = !1
},
THREE.Geometry.prototype = {
constructor: THREE.Geometry,
addEventListener: THREE.EventDispatcher.prototype.addEventListener,
hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
applyMatrix: function(a) {
for (var b = (new THREE.Matrix3).getNormalMatrix(a), c = 0, d = this.vertices.length; d > c; c++)
this.vertices[c].applyMatrix4(a);
for (c = 0, d = this.faces.length; d > c; c++) {
var e = this.faces[c];
e.normal.applyMatrix3(b).normalize();
for (var f = 0, g = e.vertexNormals.length; g > f; f++)
e.vertexNormals[f].applyMatrix3(b).normalize();
e.centroid.applyMatrix4(a)
}
},
computeCentroids: function() {
var a,
b,
c;
for (a = 0, b = this.faces.length; b > a; a++)
c = this.faces[a],
c.centroid.set(0, 0, 0),
c instanceof THREE.Face3 ? (c.centroid.add(this.vertices[c.a]), c.centroid.add(this.vertices[c.b]), c.centroid.add(this.vertices[c.c]), c.centroid.divideScalar(3)) : c instanceof THREE.Face4 && (c.centroid.add(this.vertices[c.a]), c.centroid.add(this.vertices[c.b]), c.centroid.add(this.vertices[c.c]), c.centroid.add(this.vertices[c.d]), c.centroid.divideScalar(4))
},
computeFaceNormals: function() {
for (var a = new THREE.Vector3, b = new THREE.Vector3, c = 0, d = this.faces.length; d > c; c++) {
var e = this.faces[c],
f = this.vertices[e.a],
g = this.vertices[e.b];
a.subVectors(this.vertices[e.c], g),
b.subVectors(f, g),
a.cross(b),
a.normalize(),
e.normal.copy(a)
}
},
computeVertexNormals: function(a) {
var b,
c,
d,
e;
if (void 0 === this.__tmpVertices) {
for (e = this.__tmpVertices = Array(this.vertices.length), b = 0, c = this.vertices.length; c > b; b++)
e[b] = new THREE.Vector3;
for (b = 0, c = this.faces.length; c > b; b++)
d = this.faces[b],
d instanceof THREE.Face3 ? d.vertexNormals = [new THREE.Vector3, new THREE.Vector3, new THREE.Vector3] : d instanceof THREE.Face4 && (d.vertexNormals = [new THREE.Vector3, new THREE.Vector3, new THREE.Vector3, new THREE.Vector3])
} else
for (e = this.__tmpVertices, b = 0, c = this.vertices.length; c > b; b++)
e[b].set(0, 0, 0);
if (a) {
var f,
g,
h,
i = new THREE.Vector3,
j = new THREE.Vector3,
k = new THREE.Vector3,
l = new THREE.Vector3,
m = new THREE.Vector3;
for (b = 0, c = this.faces.length; c > b; b++)
d = this.faces[b],
d instanceof THREE.Face3 ? (a = this.vertices[d.a], f = this.vertices[d.b], g = this.vertices[d.c], i.subVectors(g, f), j.subVectors(a, f), i.cross(j), e[d.a].add(i), e[d.b].add(i), e[d.c].add(i)) : d instanceof THREE.Face4 && (a = this.vertices[d.a], f = this.vertices[d.b], g = this.vertices[d.c], h = this.vertices[d.d], k.subVectors(h, f), j.subVectors(a, f), k.cross(j), e[d.a].add(k), e[d.b].add(k), e[d.d].add(k), l.subVectors(h, g), m.subVectors(f, g), l.cross(m), e[d.b].add(l), e[d.c].add(l), e[d.d].add(l))
} else
for (b = 0, c = this.faces.length; c > b; b++)
d = this.faces[b],
d instanceof THREE.Face3 ? (e[d.a].add(d.normal), e[d.b].add(d.normal), e[d.c].add(d.normal)) : d instanceof THREE.Face4 && (e[d.a].add(d.normal), e[d.b].add(d.normal), e[d.c].add(d.normal), e[d.d].add(d.normal));
for (b = 0, c = this.vertices.length; c > b; b++)
e[b].normalize();
for (b = 0, c = this.faces.length; c > b; b++)
d = this.faces[b],
d instanceof THREE.Face3 ? (d.vertexNormals[0].copy(e[d.a]), d.vertexNormals[1].copy(e[d.b]), d.vertexNormals[2].copy(e[d.c])) : d instanceof THREE.Face4 && (d.vertexNormals[0].copy(e[d.a]), d.vertexNormals[1].copy(e[d.b]), d.vertexNormals[2].copy(e[d.c]), d.vertexNormals[3].copy(e[d.d]))
},
computeMorphNormals: function() {
var a,
b,
c,
d,
e;
for (c = 0, d = this.faces.length; d > c; c++)
for (e = this.faces[c], e.__originalFaceNormal ? e.__originalFaceNormal.copy(e.normal) : e.__originalFaceNormal = e.normal.clone(), e.__originalVertexNormals || (e.__originalVertexNormals = []), a = 0, b = e.vertexNormals.length; b > a; a++)
e.__originalVertexNormals[a] ? e.__originalVertexNormals[a].copy(e.vertexNormals[a]) : e.__originalVertexNormals[a] = e.vertexNormals[a].clone();
var f = new THREE.Geometry;
for (f.faces = this.faces, a = 0, b = this.morphTargets.length; b > a; a++) {
if (!this.morphNormals[a]) {
this.morphNormals[a] = {},
this.morphNormals[a].faceNormals = [],
this.morphNormals[a].vertexNormals = [];
var g,
h,
i = this.morphNormals[a].faceNormals,
j = this.morphNormals[a].vertexNormals;
for (c = 0, d = this.faces.length; d > c; c++)
e = this.faces[c],
g = new THREE.Vector3,
h = e instanceof THREE.Face3 ? {
a: new THREE.Vector3,
b: new THREE.Vector3,
c: new THREE.Vector3
}: {
a: new THREE.Vector3,
b: new THREE.Vector3,
c: new THREE.Vector3,
d: new THREE.Vector3
},
i.push(g),
j.push(h)
}
for (i = this.morphNormals[a], f.vertices = this.morphTargets[a].vertices, f.computeFaceNormals(), f.computeVertexNormals(), c = 0, d = this.faces.length; d > c; c++)
e = this.faces[c],
g = i.faceNormals[c],
h = i.vertexNormals[c],
g.copy(e.normal),
e instanceof THREE.Face3 ? (h.a.copy(e.vertexNormals[0]), h.b.copy(e.vertexNormals[1]), h.c.copy(e.vertexNormals[2])) : (h.a.copy(e.vertexNormals[0]), h.b.copy(e.vertexNormals[1]), h.c.copy(e.vertexNormals[2]), h.d.copy(e.vertexNormals[3]))
}
for (c = 0, d = this.faces.length; d > c; c++)
e = this.faces[c],
e.normal = e.__originalFaceNormal,
e.vertexNormals = e.__originalVertexNormals
},
computeTangents: function() {
function a(a, b, c, d, e, f, y) {
h = a.vertices[b],
i = a.vertices[c],
j = a.vertices[d],
k = g[e],
l = g[f],
m = g[y],
n = i.x - h.x,
o = j.x - h.x,
p = i.y - h.y,
q = j.y - h.y,
r = i.z - h.z,
s = j.z - h.z,
t = l.x - k.x,
u = m.x - k.x,
v = l.y - k.y,
w = m.y - k.y,
x = 1 / (t * w - u * v),
B.set((w * n - v * o) * x, (w * p - v * q) * x, (w * r - v * s) * x),
C.set((t * o - u * n) * x, (t * q - u * p) * x, (t * s - u * r) * x),
z[b].add(B),
z[c].add(B),
z[d].add(B),
A[b].add(C),
A[c].add(C),
A[d].add(C)
}
var b,
c,
d,
e,
f,
g,
h,
i,
j,
k,
l,
m,
n,
o,
p,
q,
r,
s,
t,
u,
v,
w,
x,
y,
z = [],
A = [],
B = new THREE.Vector3,
C = new THREE.Vector3,
D = new THREE.Vector3,
E = new THREE.Vector3,
F = new THREE.Vector3;
for (b = 0, c = this.vertices.length; c > b; b++)
z[b] = new THREE.Vector3,
A[b] = new THREE.Vector3;
for (b = 0, c = this.faces.length; c > b; b++)
f = this.faces[b],
g = this.faceVertexUvs[0][b],
f instanceof THREE.Face3 ? a(this, f.a, f.b, f.c, 0, 1, 2) : f instanceof THREE.Face4 && (a(this, f.a, f.b, f.d, 0, 1, 3), a(this, f.b, f.c, f.d, 1, 2, 3));
var G = ["a", "b", "c", "d"];
for (b = 0, c = this.faces.length; c > b; b++)
for (f = this.faces[b], d = 0; d < f.vertexNormals.length; d++)
F.copy(f.vertexNormals[d]),
e = f[G[d]],
y = z[e],
D.copy(y),
D.sub(F.multiplyScalar(F.dot(y))).normalize(),
E.crossVectors(f.vertexNormals[d], y),
e = E.dot(A[e]),
e = 0 > e ? -1: 1,
f.vertexTangents[d] = new THREE.Vector4(D.x, D.y, D.z, e);
this.hasTangents = !0
},
computeLineDistances: function() {
for (var a = 0, b = this.vertices, c = 0, d = b.length; d > c; c++)
c > 0 && (a += b[c].distanceTo(b[c - 1])),
this.lineDistances[c] = a
},
computeBoundingBox: function() {
null === this.boundingBox && (this.boundingBox = new THREE.Box3),
this.boundingBox.setFromPoints(this.vertices)
},
computeBoundingSphere: function() {
null === this.boundingSphere && (this.boundingSphere = new THREE.Sphere),
this.boundingSphere.setFromCenterAndPoints(this.boundingSphere.center, this.vertices)
},
mergeVertices: function() {
var a,
b,
c,
d,
e,
f,
g = {},
h = [],
i = [],
j = Math.pow(10, 4);
for (this.__tmpVertices = void 0, b = 0, c = this.vertices.length; c > b; b++)
a = this.vertices[b],
a = [Math.round(a.x * j), Math.round(a.y * j), Math.round(a.z * j)].join("_"),
void 0 === g[a] ? (g[a] = b, h.push(this.vertices[b]), i[b] = h.length - 1) : i[b] = i[g[a]];
for (j = [], b = 0, c = this.faces.length; c > b; b++)
if (g = this.faces[b], g instanceof THREE.Face3) {
for (g.a = i[g.a], g.b = i[g.b], g.c = i[g.c], d = [g.a, g.b, g.c], a = -1, e = 0; 3 > e; e++)
if (d[e] == d[(e + 1) % 3]) {
j.push(b);
break
}
} else if (g instanceof THREE.Face4) {
for (g.a = i[g.a], g.b = i[g.b], g.c = i[g.c], g.d = i[g.d], d = [g.a, g.b, g.c, g.d], a = -1, e = 0; 4 > e; e++)
d[e] == d[(e + 1) % 4] && (a >= 0 && j.push(b), a = e);
if (a >= 0) {
d.splice(a, 1);
var k = new THREE.Face3(d[0], d[1], d[2], g.normal, g.color, g.materialIndex);
for (d = 0, e = this.faceVertexUvs.length; e > d; d++)(f = this.faceVertexUvs[d][b]) && f.splice(a, 1);
g.vertexNormals && 0 < g.vertexNormals.length && (k.vertexNormals = g.vertexNormals, k.vertexNormals.splice(a, 1)),
g.vertexColors && 0 < g.vertexColors.length && (k.vertexColors = g.vertexColors, k.vertexColors.splice(a, 1)),
this.faces[b] = k
}
}
for (b = j.length - 1; b >= 0; b--)
for (this.faces.splice(b, 1), d = 0, e = this.faceVertexUvs.length; e > d; d++)
this.faceVertexUvs[d].splice(b, 1);
return i = this.vertices.length - h.length,
this.vertices = h,
i
},
clone: function() {
for (var a = new THREE.Geometry, b = this.vertices, c = 0, d = b.length; d > c; c++)
a.vertices.push(b[c].clone());
for (b = this.faces, c = 0, d = b.length; d > c; c++)
a.faces.push(b[c].clone());
for (b = this.faceVertexUvs[0], c = 0, d = b.length; d > c; c++) {
for (var e = b[c], f = [], g = 0, h = e.length; h > g; g++)
f.push(new THREE.Vector2(e[g].x, e[g].y));
a.faceVertexUvs[0].push(f)
}
return a
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
}
},
THREE.GeometryIdCount = 0,
THREE.BufferGeometry = function() {
this.id = THREE.GeometryIdCount++,
this.attributes = {},
this.dynamic = !1,
this.offsets = [],
this.boundingSphere = this.boundingBox = null,
this.hasTangents = !1,
this.morphTargets = []
},
THREE.BufferGeometry.prototype = {
constructor: THREE.BufferGeometry,
addEventListener: THREE.EventDispatcher.prototype.addEventListener,
hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
applyMatrix: function(a) {
var b,
c;
this.attributes.position && (b = this.attributes.position.array),
this.attributes.normal && (c = this.attributes.normal.array),
void 0 !== b && (a.multiplyVector3Array(b), this.verticesNeedUpdate = !0),
void 0 !== c && ((new THREE.Matrix3).getNormalMatrix(a).multiplyVector3Array(c), this.normalizeNormals(), this.normalsNeedUpdate = !0)
},
computeBoundingBox: function() {
null === this.boundingBox && (this.boundingBox = new THREE.Box3);
var a = this.attributes.position.array;
if (a) {
var b,
c,
d,
e = this.boundingBox;
3 <= a.length && (e.min.x = e.max.x = a[0], e.min.y = e.max.y = a[1], e.min.z = e.max.z = a[2]);
for (var f = 3, g = a.length; g > f; f += 3)
b = a[f],
c = a[f + 1],
d = a[f + 2],
b < e.min.x ? e.min.x = b: b > e.max.x && (e.max.x = b),
c < e.min.y ? e.min.y = c: c > e.max.y && (e.max.y = c),
d < e.min.z ? e.min.z = d: d > e.max.z && (e.max.z = d)
} (void 0 === a || 0 === a.length) && (this.boundingBox.min.set(0, 0, 0), this.boundingBox.max.set(0, 0, 0))
},
computeBoundingSphere: function() {
null === this.boundingSphere && (this.boundingSphere = new THREE.Sphere);
var a = this.attributes.position.array;
if (a) {
for (var b, c, d, e = 0, f = 0, g = a.length; g > f; f += 3)
b = a[f],
c = a[f + 1],
d = a[f + 2],
b = b * b + c * c + d * d,
b > e && (e = b);
this.boundingSphere.radius = Math.sqrt(e)
}
},
computeVertexNormals: function() {
if (this.attributes.position) {
var a,
b,
c,
d;
if (a = this.attributes.position.array.length, void 0 === this.attributes.normal)
this.attributes.normal = {
itemSize: 3,
array: new Float32Array(a),
numItems: a
};
else
for (a = 0, b = this.attributes.normal.array.length; b > a; a++)
this.attributes.normal.array[a] = 0;
var e,
f,
g,
h,
i,
j,
k = this.attributes.position.array,
l = this.attributes.normal.array,
m = new THREE.Vector3,
n = new THREE.Vector3,
o = new THREE.Vector3,
p = new THREE.Vector3,
q = new THREE.Vector3;
if (this.attributes.index) {
var r = this.attributes.index.array,
s = this.offsets;
for (c = 0, d = s.length; d > c;++c) {
b = s[c].start,
e = s[c].count;
var t = s[c].index;
for (a = b, b += e; b > a; a += 3)
e = t + r[a],
f = t + r[a + 1],
g = t + r[a + 2],
h = k[3 * e],
i = k[3 * e + 1],
j = k[3 * e + 2],
m.set(h, i, j),
h = k[3 * f],
i = k[3 * f + 1],
j = k[3 * f + 2],
n.set(h, i, j),
h = k[3 * g],
i = k[3 * g + 1],
j = k[3 * g + 2],
o.set(h, i, j),
p.subVectors(o, n),
q.subVectors(m, n),
p.cross(q),
l[3 * e] += p.x,
l[3 * e + 1] += p.y,
l[3 * e + 2] += p.z,
l[3 * f] += p.x,
l[3 * f + 1] += p.y,
l[3 * f + 2] += p.z,
l[3 * g] += p.x,
l[3 * g + 1] += p.y,
l[3 * g + 2] += p.z
}
} else
for (a = 0, b = k.length; b > a; a += 9)
h = k[a],
i = k[a + 1],
j = k[a + 2],
m.set(h, i, j),
h = k[a + 3],
i = k[a + 4],
j = k[a + 5],
n.set(h, i, j),
h = k[a + 6],
i = k[a + 7],
j = k[a + 8],
o.set(h, i, j),
p.subVectors(o, n),
q.subVectors(m, n),
p.cross(q),
l[a] = p.x,
l[a + 1] = p.y,
l[a + 2] = p.z,
l[a + 3] = p.x,
l[a + 4] = p.y,
l[a + 5] = p.z,
l[a + 6] = p.x,
l[a + 7] = p.y,
l[a + 8] = p.z;
this.normalizeNormals(),
this.normalsNeedUpdate = !0
}
},
normalizeNormals: function() {
for (var a, b, c, d = this.attributes.normal.array, e = 0, f = d.length; f > e; e += 3)
a = d[e],
b = d[e + 1],
c = d[e + 2],